Forums

Creating a stack in PPC860 bootloader

Started by Joe Bruin April 8, 2004
I need to deflated an inflated image file in the bootloader of a PPC860.
Planning on using the zlib routines and thus, need to run c routines in the
bootloader. However, the current bootloader doesn't have a stack, so i'd
assume i'll have to create a stack to call the c routines for decompression.
I have little experience in dealing w/ PPC860 bootloader and anybody could
give me some hints and direnctions? how difficult is it to create a stack?
thanks in advance.


"Joe Bruin" <clarencechung@earthlink.net> wrote in message
news:4C6dc.1375$A_4.1014@newsread1.news.pas.earthlink.net...
> I need to deflated an inflated image file in the bootloader of a PPC860. > Planning on using the zlib routines and thus, need to run c routines in
the
> bootloader. However, the current bootloader doesn't have a stack, so i'd > assume i'll have to create a stack to call the c routines for
decompression.
> I have little experience in dealing w/ PPC860 bootloader and anybody could > give me some hints and direnctions? how difficult is it to create a stack? > thanks in advance. > >
Setting up a stack in assembler for use by 'C' functions is quite easy. First allocate an area of memory to be used as the stack (various ways to do this - depend on the assembler you are using) and then setup 'r1' as the stack pointer. The value to put into 'r1' is the address of the start of the stack, plus the length of the stack you allocated, minus sixteen bytes. These sixteen bytes allocate space for a standard EABI stack frame and are used to save the previous state when the first 'C' routine is invoked. For more details on the PowerPC EABI follow these links: http://www.omega-environment.com/documentation/ppceabi.pdf http://www.omega-environment.com/documentation/SVR4abippc.pdf Also, you need to be aware that the ZLIB functions will themselves require a fair bit of workspace - depending on the type of compression used. Dave -- David J Edgar Cedaryacht Limited Macclesfield UK. http://www.omega-environment.com/
"Joe Bruin" <clarencechung@earthlink.net> writes:

>I need to deflated an inflated image file in the bootloader of a PPC860. >Planning on using the zlib routines and thus, need to run c routines in the >bootloader. However, the current bootloader doesn't have a stack, so i'd >assume i'll have to create a stack to call the c routines for decompression. >I have little experience in dealing w/ PPC860 bootloader and anybody could
Why reinvent the wheel? Why not using U-Boot as boot loader on your board? Best regards, Wolfgang Denk -- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Web: www.denx.de Committee, n.: A group of men who individually can do nothing but as a group decide that nothing can be done. - Fred Allen
Thanks for ur reply david.

I believe i successfully created a stack, however, when i tried to use
the zlib routines, it failed when it tried to allocate memory from
heap. so i believe the heap is not initialized. So how do i initialize
the heap? i'm using diab 4.2 compiler/assembler. I should have set up
the memory map correctly when linking.



"David J Edgar" <david@cd-yacht.demon.co.uk> wrote in message news:<CDYC404960619@cd-yacht.demon.co.uk>...
> "Joe Bruin" <clarencechung@earthlink.net> wrote in message > news:4C6dc.1375$A_4.1014@newsread1.news.pas.earthlink.net... > > I need to deflated an inflated image file in the bootloader of a PPC860. > > Planning on using the zlib routines and thus, need to run c routines in > the > > bootloader. However, the current bootloader doesn't have a stack, so i'd > > assume i'll have to create a stack to call the c routines for > decompression. > > I have little experience in dealing w/ PPC860 bootloader and anybody could > > give me some hints and direnctions? how difficult is it to create a stack? > > thanks in advance. > > > > > > Setting up a stack in assembler for use by 'C' functions is quite easy. > > First allocate an area of memory to be used as the stack (various ways to do > this - depend on the assembler you are using) and then setup 'r1' as the > stack pointer. The value to put into 'r1' is the address of the start of the > stack, plus the length of the stack you allocated, minus sixteen bytes. > These sixteen bytes allocate space for a standard EABI stack frame and are > used to save the previous state when the first 'C' routine is invoked. > > For more details on the PowerPC EABI follow these links: > > http://www.omega-environment.com/documentation/ppceabi.pdf > http://www.omega-environment.com/documentation/SVR4abippc.pdf > > Also, you need to be aware that the ZLIB functions will themselves require a > fair bit of workspace - depending on the type of compression used. > > Dave
On 13 Apr 2004 15:09:24 -0700, chung_clarence@yahoo.com (googler)
wrote:

>Thanks for ur reply david. > >I believe i successfully created a stack, however, when i tried to use >the zlib routines, it failed when it tried to allocate memory from >heap. so i believe the heap is not initialized. So how do i initialize >the heap? i'm using diab 4.2 compiler/assembler. I should have set up >the memory map correctly when linking.
It might suffice if you provide a malloc() function ? --- 42Bastian Do not email to bastian42@yahoo.com, it's a spam-only account :-) Use <same-name>@epost.de instead !