Porting (dl)malloc to mini

42 views
Skip to first unread message

theStack

unread,
Aug 16, 2009, 2:20:29 AM8/16/09
to bootmii-devel
Hi folks, we (lewurm and me) are currently working on USB support for
mini
(only OHCI for now) and need to implement support for allocating
dynamic memory
as this will surely be helpful, both for our host controller driver
and maybe
for future device drivers respectively mini features.

In ppcskel, Doug Leas version of malloc (dlmalloc) is used and it
seems to be
obvious to adapt it for mini, too. However, we have some problems
providing the
correct values of _sbrk_start and _sbrk_end in the ld linker script,
mini.ld.
We changed the position of mem2 in MEMORY from 0x13f00000 to
0x13e00000 to have
one more free megabyte at the end of the memory which can then be used
as heap
segment.
We don't know whether this is allowed or not, as it could conflict
with other
data that is stored in this memory area. In fact we get some IPC error
message
("IPC: Unhandled message: 0070001 .......") on the first gecko-upload
after a
cold-start when trying out some "big" (see patch) malloc() calls. That
is,
when "fun" is #defined in main.c:111. It seems the allocated memory
overwrites
some important data.

Get the patches on mini.ld, main.c and the new file malloc.c here on
git:
$ git checkout 4d854edb5
$ git checkout -b malloc
$ git pull git://github.com/lewurm/mini.git malloc

We would appreciate any kind of help!

Best regards,
theStack

P.S.: In types.h:34 there is a strange typedef causing a bunch of
compare
warnings in dlmalloc:
typedef s32 size_t;
Now, shouldn't size_t always be unsigned? Sizes can never be negative,
can't
they?

SquidMan

unread,
Aug 17, 2009, 4:23:16 PM8/17/09
to bootmii-devel
I think you might want to put the USB stuff in the PPC side.
MINI is supposed to be small and lightweight (it all fits into the
SRAM) and I don't think you could fit memory allocation _and_ USB code
into MINI. SRAM isn't that big ;)

comex

unread,
Aug 17, 2009, 4:29:01 PM8/17/09
to bootmi...@googlegroups.com
On Mon, Aug 17, 2009 at 4:23 PM, SquidMan<squid...@gmail.com> wrote:
>
> I think you might want to put the USB stuff in the PPC side.
> MINI is supposed to be small and lightweight (it all fits into the
> SRAM) and I don't think you could fit memory allocation _and_ USB code
> into MINI. SRAM isn't that big ;)

Note that it is possible to directly access the registers (including
OHCI) from PPC as long as whatever magic register is set.

--
-c.

bushing

unread,
Aug 17, 2009, 4:50:01 PM8/17/09
to bootmi...@googlegroups.com
HW_AHBPROT (0x0d800064) -- I just added this to http://wiibrew.org/wiki/Hardware/Hollywood_Registers.  If set to 0xFFFFFFFF, then the PPC can access all hardware directly.

(Note that this is the default value, so anything that runs under BootMii/boot2 already can do this.)
 
Reply all
Reply to author
Forward
0 new messages