recently I'm working on my bare metal studies and get stucked at the memory structure of the bare metal programs. And now I'm focusing on the following 4 questions:
Question 1.
I've read some codes from dwelch67 and found there are many "mov sp, #0x8000" in the code, and the kernel.img itself will be loaded to 0x8000 on a running Pi. So should the memory layout in a running Pi like this below?
Code: Select all
========= top of the mem space
NOT USED
--------- end of the bare metal program
BARE METAL
PROGRAM
--------- 0x00008000
STACK SPACE
GROWING
DOWNWARDS
========= 0x00000000
As a result, the LDRs for the interrupt handling (is it called IVT?) at the beginning should also be loaded to 0x8000 with other codes in kernel.img? That means, RESET interrupts should make ARM jump to 0x8000, IRQ interrupts to 0x801C, etc.?
Question 3.
We should initialize each SP for different running modes. Is there any "common way" or conventions to do this? Or, which considerations we should take to make a proper memory structure?
Question 4.
I've been told that the memory space in RPi are shared between VC and ARM. There is a 512MB space for B+, and the ratio between the space for VC and ARM can be modified in config.txt. So I read the documents about config.txt and found there may be an option called gpu_mem to do this. By default the value of this option is 64MB. As a result, we could only use the lower (512 - 64) * 1024 * 1024 * 8 / 32 = 0x07000000 addresses in the total 0x08000000 addresses? However I've found "mov sp, #0x08000000" in some examples. So what am I missing here?
Many Thx!
xiguawanou