Paging problems
-
- Posts: 20
- Joined: Fri Jun 16, 2017 1:51 am
- Libera.chat IRC: Maka_Albarn
Re: Paging problems
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.
Re: Paging problems
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.
-
- Posts: 20
- Joined: Fri Jun 16, 2017 1:51 am
- Libera.chat IRC: Maka_Albarn
Re: Paging problems
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.
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.
Re: Paging problems
I think I realized the situation a bit late .
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.
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.
-
- Posts: 20
- Joined: Fri Jun 16, 2017 1:51 am
- Libera.chat IRC: Maka_Albarn
Re: Paging problems
Not quite. A 64-bit cpu, running what should be 32-bit instructions as 64-bit, while in protected(32-bit) mode.
-
- Posts: 20
- Joined: Fri Jun 16, 2017 1:51 am
- Libera.chat IRC: Maka_Albarn
Re: Paging problems
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: Select all
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.
Re: Paging problems
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?
-
- Posts: 20
- Joined: Fri Jun 16, 2017 1:51 am
- Libera.chat IRC: Maka_Albarn
Re: Paging problems
For the most part, it was only the offset sections, "equ $ - GDT64" that got me. I managed to figure most of it out.
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.
Code: Select all
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
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.