Strange error after moving to 64-bit
Posted: Sat Oct 17, 2009 12:22 am
Hello again
I have finally got some time to play around with 64-bit OS development. I've decided to continue using grub as my bootloader, and I switched to 64-bit ELF using AOUT_KLUDGE. I've now managed to get the computer into long mode, and I can jump to my C kernel. I all seem to work very well, but I've encountered a strange error while trying to implement a simple text mode video driver. My clear screen function uses memsetw() to clear the screen buffer. In the following I've created to different implementations of this function, one that uses pointers (1) and one that use the screenbuffer as an array (2). I my 32-bit OS I use the one with pointers (1) and it works very well. In my new 64-bit test system, it causes a reboot in both qemu and bochs, but (2) works fine.
Number 1, with pointers
Number 2, as an array
Anybody who have an idea about, why it does not work with pointers, but as an array? Bochs returns the following error:
My linker script and assembler stub can be downloaded here:
http://pub.mitsted.dk/link.ld
http://pub.mitsted.dk/boot.asm
I have finally got some time to play around with 64-bit OS development. I've decided to continue using grub as my bootloader, and I switched to 64-bit ELF using AOUT_KLUDGE. I've now managed to get the computer into long mode, and I can jump to my C kernel. I all seem to work very well, but I've encountered a strange error while trying to implement a simple text mode video driver. My clear screen function uses memsetw() to clear the screen buffer. In the following I've created to different implementations of this function, one that uses pointers (1) and one that use the screenbuffer as an array (2). I my 32-bit OS I use the one with pointers (1) and it works very well. In my new 64-bit test system, it causes a reboot in both qemu and bochs, but (2) works fine.
Number 1, with pointers
Code: Select all
uint16_t *memsetw(uint16_t *dest, uint16_t val, int len)
{
uint16_t *dp = (uint16_t *)dest;
while(len-- > 0) *dp++ = val;
return dest;
}
Code: Select all
uint16_t *memsetw(uint16_t *dest, uint16_t val, int len)
{
while(len-- > 0) dest[len] = val;
return dest;
}
Code: Select all
00055164694e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00055164694e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00055164694e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00055164694i[CPU0 ] CPU is in long mode (active)
00055164694i[CPU0 ] CS.d_b = 16 bit
00055164694i[CPU0 ] SS.d_b = 32 bit
00055164694i[CPU0 ] EFER = 0x00000501
http://pub.mitsted.dk/link.ld
http://pub.mitsted.dk/boot.asm