[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
x86 assembly questions
I am working on multiboot 2 support in the NetBSD kernel, and I experience
a few problems with EFI bootstrap.
In EFI, the kernel is loaded at 0x4078000, while the code in i386 locore.S
assumes it is at 0x100000. For that reason, native bootstrap startprog32 in
src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S copies the kernel
from the loaded address to 0x100000.
We cannot assume a multiboot 2 compliant loader will do that for us. Hence
I introduced an EFI32 entry point in locore.S and adapted the code
from startprog32 to copy the kernel in locore.S. The kernel copy is done
by a rep movsl instruction:
x0x40780b1 rep movsl %ds:(%esi),%es:(%edi)
At that time, I have:
First question: how %ds and %es are used here? They are supposed to
determine the higher bits of addresses used by rep movsl, but if I
step in rep mosvl, I can see the copy is indeed done from 0x4078000
to 0x100000, just like if %ds and %es were ignored or set to zero.
Then %ecx should contains the size in sizeof(long). I understand it
should copy from 0x100000 to 0x100000 + (4 * 0x4ef400), which is
0x14bd000, but when I break after rep movsl instruction, the code
at 0x40780b3 has been clobered. This suggests the copy went too
far and I did not correctly understood how rep movsl works. Where is
Last question: modifying %ss raises an exception. Why?
Main Index |
Thread Index |