I have part of my trampoline done(It was perfect, then I decided I want a higher half kernel.), the way it gets linked into my kernel causes it to be at 0x1000000 but all symbols are linked as if it was at 0xc0000000.
Here's my code:
format elf
extrn 'main' as main
public trampoline as 'trampoline'
section '.text' executable
trampoline:
mov eax,[gdtr.gdt]
call vtop
mov [gdtr.gdt],eax
mov eax,gdtr
call vtop
lgdt [eax]
jmp 8:@f ; I've tried : - (0xc0000000 - 0x1000000) Error: value out of range
@@:
mov dword[0xb8000], 'e r ' ; Test that never gets printed
mov ax,16
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov esp,0x7c00
; Enable paging
push ebx
push eax
call main
mov dword[0xb8000], 'e r '
mov dword[0xb8004], 'r o '
mov dword[0xb8008], 'r : '
mov dword[0xb800c], 'r e '
mov dword[0xb8010], 't '
mov dword[0xb8014], 'b y '
mov dword[0xb8018], ' m '
mov dword[0xb801c], 'a i '
mov dword[0xb8020], 'n ! '
cli
hlt
; Turn virtual addr into physical addr
vtop:
sub eax,(0xc0000000 - 0x1000000)
ret
section '.data' writeable
gdtr:
.size dw gdt_size
.gdt dd gdt
gdt:
.null:
dq 0
.code_sys:
dw 0xffff
dw 0x0000
db 0x00
db 10011010b
db 11001111b
db 0x00
.data_sys:
dw 0xffff
dw 0x0000
db 0x00
db 10010010b
db 11001111b
db 0x00
gdt_size=$-gdt