Hi
Attaching patch to pass boot arguments from Uboot to HeleonOS kernel.
Regards,
Sourav Punoriyar
Bazaar identity: Sourav Punoriyar <sourav.punoriyar@spunor>
On Fri, Mar 3, 2017 at 12:17 AM, sourav punoriyar <[email protected]>
wrote:
> Hi Jakub,
>
>
> I will create a patch and share it with as soon as possible.
>
> Regards,
> Sourav Punoriyar
>
> On Fri, Mar 3, 2017 at 1:23 AM, Jakub Jermář <[email protected]> wrote:
>
>> Hi Sourav,
>>
>> would you mind sharing a patch? This is really not that helpful as I can
>> only guess what you have done.
>>
>> Thanks,
>> Jakub
>>
>> On 03/02/2017 08:14 PM, sourav punoriyar wrote:
>> > Hi Jakub,
>> >
>> > I was able to pass boot_args from uboot till kernel.
>> >
>> > The issue was i was looking in wrong direction.
>> > After going through uboot for Netbsd i found the solution..
>> >
>> > *Some assumptions i made i kernel.*
>> >
>> > As no length is passed , i have taken max arguments size to be 4096
>> bytes.
>> > I have used str_cpy in (arm32_pre_main) so that no buffer overflow
>> happens.
>> >
>> > I will come up with a structure to keep parsed arguments and a parser
>> > function to collect the arguments separately.
>> >
>> > Please give your opinion and suggestions so that i can make it better.
>> >
>> >
>> > Regards,
>> > Sourav Punoriyar
>> >
>> > On Sun, Feb 26, 2017 at 4:29 AM, Jakub Jermář <[email protected]
>> > <mailto:[email protected]>> wrote:
>> >
>> > Hi Sourav,
>> >
>> > On 02/25/2017 08:59 PM, sourav punoriyar wrote:
>> > > Before Loading HelenOS
>> > > U-Boot# bdinfo
>> > > *arch_number = 0x00000E05*
>> > > boot_params = 0x80000100
>> > <snip>
>> > > After loading HelenOS
>> > > U-Boot# bootm 0x80007FC0 - {Booting HelenOS}
>> > > ## Transferring control to NetBSD stage-2 loader (at address
>> 80000000) ...
>> > <snip>
>> > > I am just trying to read bdinfo , just to build confidence.
>> > > But, I am not getting the expected values :-(
>> > > I doubt is it something related to LOAD ADDRESS = 80000000 ?
>> > > beagebone _black Load = 80008000 ?
>> >
>> > Yes, the address to which the bbxm and bbone loader is linked seems
>> to
>> > conflict with the address where u-boot puts the arguments. You can
>> try
>> > moving the link/load address a little bit higher and see if it
>> helps.
>> > See boot/arch/arm32/Makefile.inc.
>> >
>> > Jakub
>> >
>> > _______________________________________________
>> > HelenOS-devel mailing list
>> > [email protected] <mailto:[email protected]>
>> > http://lists.modry.cz/listinfo/helenos-devel
>> > <http://lists.modry.cz/listinfo/helenos-devel>
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > HelenOS-devel mailing list
>> > [email protected]
>> > http://lists.modry.cz/listinfo/helenos-devel
>> >
>>
>> _______________________________________________
>> HelenOS-devel mailing list
>> [email protected]
>> http://lists.modry.cz/listinfo/helenos-devel
>>
>
>
=== modified file 'boot/arch/arm32/include/main.h'
--- boot/arch/arm32/include/main.h 2013-03-24 14:55:36 +0000
+++ boot/arch/arm32/include/main.h 2017-03-05 17:02:19 +0000
@@ -94,7 +94,7 @@
-extern void bootstrap(void);
+extern void bootstrap(char *);
#endif
=== modified file 'boot/arch/arm32/include/types.h'
--- boot/arch/arm32/include/types.h 2012-04-02 15:52:07 +0000
+++ boot/arch/arm32/include/types.h 2017-03-05 17:03:58 +0000
@@ -56,6 +56,7 @@
typedef struct {
size_t cnt;
task_t tasks[TASKMAP_MAX_RECORDS];
+ char *cmdline;
} bootinfo_t;
#endif
=== modified file 'boot/arch/arm32/src/asm.S'
--- boot/arch/arm32/src/asm.S 2016-04-21 20:00:18 +0000
+++ boot/arch/arm32/src/asm.S 2017-03-05 17:05:49 +0000
@@ -33,6 +33,7 @@
SYMBOL(start)
ldr sp, =boot_stack
+ mov r0,r3
b bootstrap
.section BOOTPT
=== modified file 'boot/arch/arm32/src/main.c'
--- boot/arch/arm32/src/main.c 2015-10-06 20:23:44 +0000
+++ boot/arch/arm32/src/main.c 2017-03-05 17:41:04 +0000
@@ -82,12 +82,14 @@
static bootinfo_t bootinfo;
-void bootstrap(void)
+
+void bootstrap(char* boot_args)
{
/* Enable MMU and caches */
mmu_start();
version_print();
-
+ bootinfo.cmdline = boot_args;
+
printf("Boot data: %p -> %p\n", &bdata_start, &bdata_end);
printf("\nMemory statistics\n");
printf(" %p|%p: bootstrap stack\n", &boot_stack, &boot_stack);
@@ -101,7 +103,7 @@
components[i].start, components[i].name, components[i].inflated,
components[i].size);
}
-
+ printf(" %p : boot _args passed to kernel\n",bootinfo.cmdline);
void *dest[COMPONENTS];
size_t top = 0;
size_t cnt = 0;
=== modified file 'kernel/arch/arm32/include/arch/arch.h'
--- kernel/arch/arm32/include/arch/arch.h 2016-06-06 16:29:56 +0000
+++ kernel/arch/arm32/include/arch/arch.h 2017-03-05 17:12:24 +0000
@@ -52,10 +52,14 @@
typedef struct {
size_t cnt;
utask_t tasks[TASKMAP_MAX_RECORDS];
+ char *cmdline;
} bootinfo_t;
extern void arm32_pre_main(void *entry, bootinfo_t *bootinfo);
+#define KERNEL_CMDLINE 4096
+char boot_args[KERNEL_CMDLINE];
+
#endif
/** @}
=== modified file 'kernel/arch/arm32/src/arm32.c'
--- kernel/arch/arm32/src/arm32.c 2016-06-06 16:29:56 +0000
+++ kernel/arch/arm32/src/arm32.c 2017-03-05 17:16:10 +0000
@@ -63,7 +63,7 @@
arch_ops_t *arch_ops = &arm32_ops;
-
+extern char boot_args[KERNEL_CMDLINE];
/** Performs arm32-specific initialization before main_bsp() is called. */
void arm32_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
{
@@ -77,6 +77,7 @@
bootinfo->tasks[i].name);
}
+ str_cpy(boot_args, KERNEL_CMDLINE, bootinfo->cmdline);
/* Initialize machine_ops pointer. */
machine_ops_init();
}
=== modified file 'kernel/generic/src/main/main.c'
--- kernel/generic/src/main/main.c 2016-12-26 20:02:04 +0000
+++ kernel/generic/src/main/main.c 2017-03-05 17:19:47 +0000
@@ -205,6 +205,7 @@
/* not reached */
}
+extern char boot_args[4096];
/** Main kernel routine for bootstrap CPU using new stack.
*
* Second part of main_bsp().
@@ -217,6 +218,7 @@
version_print();
+ printf("bootargs kernel : [%s] \n",boot_args);
LOG("\nconfig.base=%p config.kernel_size=%zu"
"\nconfig.stack_base=%p config.stack_size=%zu",
(void *) config.base, config.kernel_size,
_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel