Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-03-02 Thread sourav punoriyar
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ář  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ář  > > wrote:
> >
> > Hi Sourav,
> >
> > On 02/25/2017 08:59 PM, sourav punoriyar wrote:
> > > Before Loading HelenOS
> > > U-Boot# bdinfo
> > > *arch_number = 0x0E05*
> > > boot_params = 0x8100
> > 
> > > After loading HelenOS
> > > U-Boot# bootm 0x80007FC0 - {Booting HelenOS}
> > > ## Transferring control to NetBSD stage-2 loader (at address
> 8000) ...
> > 
> > > 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 = 8000 ?
> > > 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
> > HelenOS-devel@lists.modry.cz 
> > http://lists.modry.cz/listinfo/helenos-devel
> > 
> >
> >
> >
> >
> > ___
> > HelenOS-devel mailing list
> > HelenOS-devel@lists.modry.cz
> > http://lists.modry.cz/listinfo/helenos-devel
> >
>
> ___
> HelenOS-devel mailing list
> HelenOS-devel@lists.modry.cz
> http://lists.modry.cz/listinfo/helenos-devel
>
___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-03-02 Thread Jakub Jermář
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ář  > wrote:
> 
> Hi Sourav,
> 
> On 02/25/2017 08:59 PM, sourav punoriyar wrote:
> > Before Loading HelenOS
> > U-Boot# bdinfo
> > *arch_number = 0x0E05*
> > boot_params = 0x8100
> 
> > After loading HelenOS
> > U-Boot# bootm 0x80007FC0 - {Booting HelenOS}
> > ## Transferring control to NetBSD stage-2 loader (at address 8000) 
> ...
> 
> > 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 = 8000 ?
> > 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
> HelenOS-devel@lists.modry.cz 
> http://lists.modry.cz/listinfo/helenos-devel
> 
> 
> 
> 
> 
> ___
> HelenOS-devel mailing list
> HelenOS-devel@lists.modry.cz
> http://lists.modry.cz/listinfo/helenos-devel
> 

___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-03-02 Thread sourav punoriyar
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ář  wrote:

> Hi Sourav,
>
> On 02/25/2017 08:59 PM, sourav punoriyar wrote:
> > Before Loading HelenOS
> > U-Boot# bdinfo
> > *arch_number = 0x0E05*
> > boot_params = 0x8100
> 
> > After loading HelenOS
> > U-Boot# bootm 0x80007FC0 - {Booting HelenOS}
> > ## Transferring control to NetBSD stage-2 loader (at address 8000)
> ...
> 
> > 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 = 8000 ?
> > 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
> HelenOS-devel@lists.modry.cz
> http://lists.modry.cz/listinfo/helenos-devel
>
___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-02-24 Thread Jakub Jermář
Hi Sourav,

On 02/24/2017 09:11 PM, sourav punoriyar wrote:
> from : HelenOS/boot/arch/arm32/src/asm.S and map files.
> 
> SYMBOL(start)
> ldr sp, =boot_stack
> b bootstrap
> 
> If we keep an inline assembly in
> 
> void bootstrap(void)
> {
>   int *store_r2_for_atags = 0;  
>   asm volatile ("mov %%r2, %0" : "=r" (store_r2_for_atags)); //TODO:
> Sourav Punoriyar
>   
> 
> Uboot store the params info in r2 and passes..
> As r2 is not used before branching to bootstrap( ). Will the above line
> of code will give me the value stored in r2. Are there possibilities of
> r2 getting modified before reaching to this line ?

I am afraid r2 can indeed get clobbered just before you save it at the
beginning of bootstrap. The reason is that the compiler knows that
bootstrap() has no arguments so it can use r2 as a scratch register for
whatever reason. To do this properly, you should either save it manually
in the asm.S file or pass it as an argument to bootstrap.

HTH,
Jakub


> 
> 
> Regards,
> Sourav Punoriyar
> 
> 
> On Thu, Feb 23, 2017 at 3:33 AM, Jakub Jermář  > wrote:
> 
> On 02/22/2017 09:40 PM, Jakub Jermář wrote:
> >> Confusions i am having:
> >> 1> The bootargs info are given in r2 register. How do i preserve it 
> when
> >> stage-2 boot-loader comes into action , because till the kernel comes
> >> into picture i will loose the info passed from uboot.
> >> ---> i feel i need to preserve the info passed from Uboot so that i
> >> can pass it down to the kernel and initialize boot_args via NetBSD
> >> stage-2 loader .
> >
> > Yes, the best way to communicate information between the loader and the
> > kernel is via the bootinfo structure. Just feel free to add a member
> > which will hold the address from r2. Note that this structure needs to
> > be modified in two places: in the loader and also in the kernel. We
> > should probably fix this dichotomy by moving it under abi/.
> 
> One more thing - the arguments can theoretically overlap with memory
> used by the kernel, so it may be a good idea to actually pass them as a
> copy rather than by reference to the kernel.
> 
> Jakub
> 
> ___
> HelenOS-devel mailing list
> HelenOS-devel@lists.modry.cz 
> http://lists.modry.cz/listinfo/helenos-devel
> 
> 
> 
> 
> 
> ___
> HelenOS-devel mailing list
> HelenOS-devel@lists.modry.cz
> http://lists.modry.cz/listinfo/helenos-devel
> 

___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-02-24 Thread sourav punoriyar
Hi,

Thanks a lot.

from : HelenOS/boot/arch/arm32/src/asm.S and map files.

SYMBOL(start)
ldr sp, =boot_stack
b bootstrap

If we keep an inline assembly in

void bootstrap(void)
{
  int *store_r2_for_atags = 0;
  asm volatile ("mov %%r2, %0" : "=r" (store_r2_for_atags)); //TODO: Sourav
Punoriyar
  

Uboot store the params info in r2 and passes..
As r2 is not used before branching to bootstrap( ). Will the above line of
code will give me the value stored in r2. Are there possibilities of r2
getting modified before reaching to this line ?


Regards,
Sourav Punoriyar


On Thu, Feb 23, 2017 at 3:33 AM, Jakub Jermář  wrote:

> On 02/22/2017 09:40 PM, Jakub Jermář wrote:
> >> Confusions i am having:
> >> 1> The bootargs info are given in r2 register. How do i preserve it when
> >> stage-2 boot-loader comes into action , because till the kernel comes
> >> into picture i will loose the info passed from uboot.
> >> ---> i feel i need to preserve the info passed from Uboot so that i
> >> can pass it down to the kernel and initialize boot_args via NetBSD
> >> stage-2 loader .
> >
> > Yes, the best way to communicate information between the loader and the
> > kernel is via the bootinfo structure. Just feel free to add a member
> > which will hold the address from r2. Note that this structure needs to
> > be modified in two places: in the loader and also in the kernel. We
> > should probably fix this dichotomy by moving it under abi/.
>
> One more thing - the arguments can theoretically overlap with memory
> used by the kernel, so it may be a good idea to actually pass them as a
> copy rather than by reference to the kernel.
>
> Jakub
>
> ___
> HelenOS-devel mailing list
> HelenOS-devel@lists.modry.cz
> http://lists.modry.cz/listinfo/helenos-devel
>
___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-02-23 Thread Jakub Jermář
On 02/22/2017 09:40 PM, Jakub Jermář wrote:
>> Confusions i am having:
>> 1> The bootargs info are given in r2 register. How do i preserve it when
>> stage-2 boot-loader comes into action , because till the kernel comes
>> into picture i will loose the info passed from uboot.
>> ---> i feel i need to preserve the info passed from Uboot so that i
>> can pass it down to the kernel and initialize boot_args via NetBSD
>> stage-2 loader .
> 
> Yes, the best way to communicate information between the loader and the
> kernel is via the bootinfo structure. Just feel free to add a member
> which will hold the address from r2. Note that this structure needs to
> be modified in two places: in the loader and also in the kernel. We
> should probably fix this dichotomy by moving it under abi/.

One more thing - the arguments can theoretically overlap with memory
used by the kernel, so it may be a good idea to actually pass them as a
copy rather than by reference to the kernel.

Jakub

___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel


Re: [HelenOS-devel] Fwd: Passing boot arguments in case of arm32 (beaglebone black)

2017-02-22 Thread Jakub Jermář
Hi Sourav,

thanks for looking into this first step of passing boot arguments to the
kernel and further on. Please see my replies below.

On 02/22/2017 08:02 PM, sourav punoriyar wrote:
> From the logs: "Transferring control to NetBSD stage-2 loader "
> Uboot transfers the control to NetBSD stage-2 loader.
> 
> From the boot code of arm32 in HelenOS i found that stage-2 loader loads
> the kernel.
> And we are not utilizing r2 register for any purpose.
> 
> 
> Confusions i am having:
> 1> The bootargs info are given in r2 register. How do i preserve it when
> stage-2 boot-loader comes into action , because till the kernel comes
> into picture i will loose the info passed from uboot.
> ---> i feel i need to preserve the info passed from Uboot so that i
> can pass it down to the kernel and initialize boot_args via NetBSD
> stage-2 loader .

Yes, the best way to communicate information between the loader and the
kernel is via the bootinfo structure. Just feel free to add a member
which will hold the address from r2. Note that this structure needs to
be modified in two places: in the loader and also in the kernel. We
should probably fix this dichotomy by moving it under abi/.

> 2> What is this "ns" image ?

ns is the first userspace task. The name stands for "naming service".

HTH,
Jakub

___
HelenOS-devel mailing list
HelenOS-devel@lists.modry.cz
http://lists.modry.cz/listinfo/helenos-devel