flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Linked at virt addr, but executing at phys addr, help please

Author
Thread Post new topic Reply to topic
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
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:
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
    
Post 11 Aug 2010, 07:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.