[U-Boot] [PATCH] sandbox: Add improved RAM simulation
Matthias Weisser
weisserm at arcor.de
Tue Nov 1 19:37:24 CET 2011
Am 01.11.2011 17:45, schrieb Simon Glass:
>>>> +#define CONFIG_SYS_SDRAM_BASE 0x20000000
>>>> ...
>>>> - mem = malloc(size);
>>>> + mem = os_mmap((void *)CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_SIZE,
>>>> + 0, 0, -1, 0);
>>>
>>> mmap() makes no guarantee that the requested address is what you'll get back.
>>> so there's no point in having this SDRAM_BASE define. punt it and pass in NULL
>>> instead.
>>
>> But it works in most cases :-) The point of adding it was that I really
>> like to have memory aligned on a 256MB boundary or so like it is in most
>> SOCs. But thats a personal preference. And if it doesn't work you can
>> still get the address of physical memory from bdinfo.
>
> Most?
I don't know the memory layout strategies for all the Linux/Unix variant
out there. But typically text/bss/data is in the lower address range
(some megs above 0) and in the upper range (right under kernel space)
there is space used for stack and shared objects. Even with ASLR the
address I used in the patch should be mappable.
>>> also, with Simon's other patch to md to use the remap func, the address of our
>>> memory backing store doesn't matter.
>>
>> Well, you are right. But with the posted patch you don't need any remap
>> function and md/mm/mtest/mw works out of the box.
>
> This is interesting. What is the test purpose of specifying a
> particular virtual address for your memory?
Emulating the behavior of a u-boot on real hardware as close as
possible. We have some chunk of memory at a given location. Thats it.
With a minimum of additional work we can also simulate additional banks
of RAM using multiple mmaps.
> If this is useful then we should make the mmap function fail if it
> cannot honour the address, since otherwise presumably some tests will
> fail.
Maybe. But on the other hand tests can always extract the actual address
of RAM from gd->bd->bi_dram[0].start. If test use these address we can
abandon the use of of fixed address. But I still thinks its nice to have
an aligned address of RAM start as this is what we have on (all?) real
hardware.
Regards
Matthias
More information about the U-Boot
mailing list