OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 17, 2024 10:09 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Paging problems
PostPosted: Sat Jun 17, 2017 2:38 am 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 20
As to your first point, I'll do an "info reg" at _start to try to work out what's happening. On the point that you mentioned in your edit, I can't believe that I didn't notice that.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Sat Jun 17, 2017 2:49 am 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 210
It is also worthwhile to check the calling convention between boot32.s (which is compiled as code32) and paging.cpp (which is compiled as code64), as it applies when calling page_set.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Sat Jun 17, 2017 3:25 am 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 20
head... meet desk.

I am SUCH and IDIOT. Why did I not think to specify gcc to compile those bits of code as 32-bit I have no idea.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Sat Jun 17, 2017 6:39 am 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 210
I think I realized the situation a bit late :oops:.
A 32bit cpu, interpreting actual 64bit instructions as 32bit, seems to be the cause, unless something else turns up as the root cause for the weird behaviour.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Sat Jun 17, 2017 6:06 pm 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 20
Not quite. A 64-bit cpu, running what should be 32-bit instructions as 64-bit, while in protected(32-bit) mode.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Sun Jun 18, 2017 9:23 pm 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 20
Well. I managed to get my paging problem fixed by setting the page tables in my boot32.s file. Now I need to set the GDT. Can anyone translate this to AT&T assembly:

Code:
GDT64:                           ; Global Descriptor Table (64-bit).
    .Null: equ $ - GDT64         ; The null descriptor.
    dw 0                         ; Limit (low).
    dw 0                         ; Base (low).
    db 0                         ; Base (middle)
    db 0                         ; Access.
    db 0                         ; Granularity.
    db 0                         ; Base (high).
    .Code: equ $ - GDT64         ; The code descriptor.
    dw 0                         ; Limit (low).
    dw 0                         ; Base (low).
    db 0                         ; Base (middle)
    db 10011010b                 ; Access (exec/read).
    db 00100000b                 ; Granularity.
    db 0                         ; Base (high).
    .Data: equ $ - GDT64         ; The data descriptor.
    dw 0                         ; Limit (low).
    dw 0                         ; Base (low).
    db 0                         ; Base (middle)
    db 10010010b                 ; Access (read/write).
    db 00000000b                 ; Granularity.
    db 0                         ; Base (high).
    .Pointer:                    ; The GDT-pointer.
    dw $ - GDT64 - 1             ; Limit.
    dq GDT64                     ; Base.


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Mon Jun 19, 2017 12:21 am 
Offline
Member
Member

Joined: Sat Jul 02, 2016 7:02 am
Posts: 210
Would it not be better to understand what the bits and pieces of such a table mean, and then write one of your own directly in your desired assembly?


Top
 Profile  
 
 Post subject: Re: Paging problems
PostPosted: Mon Jun 19, 2017 7:30 pm 
Offline

Joined: Fri Jun 16, 2017 1:51 am
Posts: 20
For the most part, it was only the offset sections, "equ $ - GDT64" that got me. I managed to figure most of it out.

Code:
GDT64:
   .Null = . - GDT64
   .short 0
   .short 0
   .byte 0
   .byte 0
   .byte 0
   .byte 0
   .Code = . - GDT64
   .short 0
   .short 0
   .byte 0
   .byte 0x9A
   .byte 0x20
   .byte 0
   .Data = . - GDT64
   .short 0
   .short 0
   .byte 0
   .byte 0x92
   .byte 0
   .byte 0
   .Pointer:
   .short = . - GDT64 - 1
   .quad GDT64


My only remaining question is if I need to use $GDT64 instead of GDT64 in .pointer?

Edit: I did just realize that I couldn't use ".Code" or ".Data" for the GDT offsets because they might be assembled weirdly.

Edit 2: Okay, for some reason, when I try to set my data segment, it jumps to an entirely different area. Weird.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 116 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group