1/1
About
by Unknown on Dec 31, 2003 |
Not available! | ||
Thanks
----- Original Message -----
From: Simon Srot simons@o... >
To: List about "OpenRISC cores, free "microprocessors
openrisc@o... >
Date: 30 Dec 2003 12:31:45 +0000
Subject: Re: [openrisc] About "malloc" in the simulator and in the
FPGA
Hi,
I think you confuse some things here. Malloc is C library function
which
at some point calls OS kernel function for memory allocation via
system
call (this is this l.sys instruction that you mentioned).
You will need to have OS (linux or uClinux) setup on your
environment
(simulator or real board) to run programs like this. Check
http://www.opencores.org/projects/or1k/uClinux for more information
on
this.
Simon
On Tue, 2003-12-30 at 08:07, Cool_ABen@s... wrote:
> Hi All:
> Recently I wrote a little program "test.c" to test the "malloc"
> and "free" functions. The codes are as follows:
>
> "test.c":
>
> #include
> #include
>
> int main()
> {
> char * p;
> p = malloc(8*sizeof(char));
> if (p == NULL)
> return -1;
> free(p)
> return 0;
> }
>
> and the "makefile" script is as follows:
>
> "makefile":
>
> common = ../sw/support/libsupport.a
> all:test
>
> test: test.o ../sw/support/reset-icdc.o \
> /opt/or32-uclinux/lib/libc.a \
>
/opt/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/libgcc.a
>
> or32-uclinux-ld -T ../sw/support/orp.ld $? -o $@.or32 $(common)
>
> test.o: test.c > or32-uclinux-gcc -g -c -o test.o test.c > > > > the support package is downloaded from the cvsweb "/ or1k / orp /
> orp_soc / sw" of the opencore.org and the libsupport is in it
too.
>
> and the orp.ld script used by or32-uclinux-ld is as follows: > > MEMORY > { > vectors : ORIGIN = 0x00000000, LENGTH = 0x00002000 > flash : ORIGIN = 0x04000000, LENGTH = 0x00200000 > ram : ORIGIN = 0x00002000, LENGTH = 0x001f0000 > mp3data : ORIGIN = 0x001f2000, LENGTH = 0x00004000 > } > > SECTIONS > { > .reset : > { > *(.reset) > } > flash > > .text ALIGN(0x04): > { > _text_bin = .; > *(.text) > _text_end = .; > } > flash > > .rodata : > { > _rodata_bin = .; > *(.rodata) > _rodata_end = .; > } > flash > > .dummy ALIGN(0x04): > { > _src_beg = .; > } > flash > > .vectors : > AT ( ADDR (.dummy) ) > { > _vec_start = .; > *(.vectors) > _vec_end = .; > } > vectors > > .data : > AT ( ADDR (.dummy) + SIZEOF (.vectors) ) > { > _dst_beg = .; > *(.data) > _dst_end = .; > } > ram > > .mp3data : > { > _mp3_begin = .; > *(.mp3) > _mp3_end = .; > } > mp3data > > .bss : > { > *(.bss) > } > ram > > .stack : > { > *(.stack) > _src_addr = .; > } > ram > } > > > then I run the makefile script and the test.or32 is generated. > First I put it in the simulator . I set the breakpoint at the line "p = malloc
> (8*sizeof(char));". When entering the function of malloc,many
circles of
> instructions comes,among malloc_init , udivsi3 ,modsi3 and so
on. After
> many instructions ,it comes to the mmap functions and
implement the
> instruction "l.sys 0x1".Then it comes to 0xc00 and implements
the "l.j 0"
> for ever.
> > So I send the test.or32 to the fpga board running the or rtl. But to my
> disappoint ,the "p" equals NULL and means that malloc cannot
work.
>
> I don't know what to do .And anyone can save me? Thanks a lot. > I think simulator should support the malloc operation at least.Or I should
> study the code of malloc.c in ulibc library? Thanks a lot.
> > Thanks and Regards > > > |
1/1