I am not doing higher half without paging. I am using the GDT trick so that the actual address would wrap around. And I would get a similar mapping as I would get without paging. This was what I planned to use until I have paging enabled. Sorry for using the term higher half
The current segments are
Code: Select all
ES =0010 40000000 ffffffff 40cf9300 DPL=0 DS [-WA]
CS =0008 40000000 ffffffff 40cf9a00 DPL=0 CS32 [-R-]
SS =0010 40000000 ffffffff 40cf9300 DPL=0 DS [-WA]
DS =0010 40000000 ffffffff 40cf9300 DPL=0 DS [-WA]
FS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
GS =0000 00000000 0000ffff 00009300 DPL=0 DS16 [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 00000a44 00000027
The code to set up these addresses is :-
Code: Select all
mov ax, 0x10 ; set data segments to data selector (0x10)
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 90000h ; stack begins from 90000h
;Write something to the video memory
mov byte [0xC00B8000], 'P'
mov byte [0xC00B8001], 1Bh
mov eax , 0x2BADB000
push ebx ; The multiboot header structure is pushed onto the stack
mov ecx , 0xC0000C00
jmp 0x08:0xC0000C00
And now I am against GDT trick as well , I would make a simple paging system in the bootloader itself , enable paging in it. Keep the last PTE and PDE as their physical addresses and will work this way .I just want to know the problem and learn my lesson and maybe grab a little sleep before office in the morning.
The GDT is
Code: Select all
gdt_data:
dd 0 ; null descriptor
dd 0
; Offset 0x8 bytes from start of GDT: Descriptor code therfore is 8
; gdt code: ; code descriptor
dw 0FFFFh ; limit low
dw 0x00 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0x40 ; base high
; Offset 16 bytes (0x10) from start of GDT. Descriptor code therfore is 0x10.
; gdt data: ; data descriptor
dw 0FFFFh ; limit low (Same as code)
dw 0x000 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0x40 ; base high
; gdt temp data
dw 0xFFFF
dw 0x0
db 0
db 10010010b
db 11001111b
db 0
; gdt temp code
dw 0xFFFF
dw 0x0
db 0x0
db 10011010b
db 11001111b
db 0x0
The GDT is loaded as below
Code: Select all
end_of_gdt:
toc:
dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT)
dd gdt_data ; base of GDT
lgdt_load_asm :
mov si , lgdt_load_asm_string
call print_string
cli ; make sure to clear interrupts first!
lgdt [toc] ; load GDT into GDTR
;call pmode_enter
sti
ret
lgdt_load_asm_string db "Loading the decriptor tables",0
I am sorry for cluttering it all with too much of code but I wanted to be complete.