I am trying to access the linear framebuffer in long mode. I have written my own boot code and the video mode (vesa 0118 - linear mode) is queried and initialised in real mode. I use Parallels on my mac to test the code.
After entering 32-bit protected mode, I can use the dword address in [vesa query buffer + 40] to write directly to video memory. This seems to work fine.
But after entering 64-bit long mode, if I try to access that same address (in lower dword of rdi, upper dword is zeroed first), no pixels show up on screen.
I had expected as such because I see the possible problems, but I don't know what they are and how to fix them. Meanwhile, I see several texts on the internet talking about using linear framebuffer mode with vesa. They are all aimed at 32-bit protected mode but lots of them seem to tell that long mode should work just fine, although they never explicitly do it.
Can anyone help me get it right?
Here's some assembler-code:
Code: Select all
org 7C00h
USE16
boot_code:
... move to 9000h ...
... read sectors to 1600h ...
... enable A20 ...
... jump to 1600h ...
org 1600h
kernel_start:
; get the info from VESA
mov ax, 0x8000
mov es, ax
mov ax, 0x4F01
mov cx, 0x0118 + 0100000000000000b
xor di, di
int 10h
; initialise VESA 1024x768x24-bit
mov ax, 0x4F02
mov bx, 0x0118 + 0100000000000000b
xor di, di
int 10h
lgdt [cs:GDTR]
; Switch to protected mode
mov eax, cr0
or al, 1
mov cr0, eax
jmp CODE_SELECTOR:protectedmode_start
USE32
protectedmode_start:
; Load 4 GB data descriptor to all data segment registers
mov eax, DATA_SELECTOR
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Store some pixel data in the VESA linear framebuffer, this works perfectly
mov edi, [0x80000 + 40]
mov eax, 0xFFFF0000
mov ecx, 65536 / 4
rep stosd
... do some switching to long mode stuff, enable paging (2MB pages), make the
first 512MB addressable, ...
jmp LONG_SELECTOR:longmode_start
USE64
longmode_start:
... do some PIC, interrupts, whatever initialisations ...
... I have already tested, I can use textmode fine, I can address my memory
fine, everything seems to be initialized correctly ...
xor rdi, rdi
mov edi, [0x80000 + 40]
mov eax, 0xFFFFFFFF
mov rcx, 65536 / 4
rep stosd
; Nothing (changes) on screen...
...
Dirk.