Posted: Fri May 02, 2008 4:31 am
If you are using GCC, put this after your variables:
This will ensure proper allignment.
JAL
Code: Select all
__attribute__((aligned(4096)))
JAL
The Place to Start for Operating System Developers
http://f.osdev.org/
Code: Select all
__attribute__((aligned(4096)))
Thanks very much, it works perfectlyjal wrote:If you are using GCC, put this after your variables:
This will ensure proper allignment.Code: Select all
__attribute__((aligned(4096)))
JAL
Glad I could be of help. This trick should also be used for other structures that need to be alligned at a certain boundary, e.g. TSS (also needs 4Kb allignment) and GDT/IDT (which should have 8 byte allignment, for cache optimalization, see Intel manuals).White-spirit wrote:Thanks very much, it works perfectly :-)
Code: Select all
read_virtual_checks(): read beyond limit
No, I'm afraid not :).White-spirit wrote:Just one more question, it is normal that many GPF happen after a page fault ?
What is 'after'? Still in your handler, or after the IRET?I'm trying to access 0xFFFFFFFF to see if the page fault handler works, effectively, an interrupt 14 is executed, but after, I get so many GPFs, with this error message in Bochs :Code: Select all
read_virtual_checks(): read beyond limit
Code: Select all
push 0x0E ; interrupt #
push 0 ; dummy error code
There's your problemSo there are two pushes
That's what I say ^^"pcmattman wrote:There's your problemSo there are two pushes
The processor automatically pushes the error code, so there's only one push. On non-error-code faults, you need to push a fake error code (hence two pushes).
Code: Select all
public isr0
isr0:
cli
push 0
push 0
jmp isr_common_stub
rept 31 id
{
public isr#id
isr#id:
cli
if ~ ( id > 7 & id < 15 )
push 0
end if
push id
jmp isr_common_stub
}
isr_common_stub:
pusha
mov ax,ds
push eax
mov ax,0x10 ; ax <== 10h
mov ds,ax ; ds <== 10h
mov es,ax ; es <== 10h
mov fs,ax ; fs <== 10h
mov gs,ax ; eg <== 10h
call isr_handler
pop ebx ; restores the old values
mov ds,bx
mov es,bx
mov fs,bx
mov gs,bx
popa
add esp, 8
sti
iret
Code: Select all
if ~ ( id > 7 & id < 15 )
It looks suspicious indeed, but it works, since & has a low priority. So id > 7 and id < 15 are evaluated (yielding 0 or 1), and the result is 0 or 1.pcmattman wrote:This looks suspicious, but I'm not 100% sure:
Shouldn't that & be an &&? Or do I just not understand the syntax?Code: Select all
if ~ ( id > 7 & id < 15 )