valid idt
Re: valid idt
o32 mov eax, dword isr
o32 mov [3000], dword eax
mov ax, word [3002] ;interrupt descriptor
mov [3002], word 0x8
mov [3003], byte 0
mov [3004], byte 10001110b
mov [3005], word 0
mov [1006], word 263 ;limit
mov [1008], word 2992 ;base address idt
mov [1010], word 0x0000
lidt [1006]
o32 mov [3000], dword eax
mov ax, word [3002] ;interrupt descriptor
mov [3002], word 0x8
mov [3003], byte 0
mov [3004], byte 10001110b
mov [3005], word 0
mov [1006], word 263 ;limit
mov [1008], word 2992 ;base address idt
mov [1010], word 0x0000
lidt [1006]
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: valid idt
Why are you systematically getting complaints about your coding style?
People can't read this. Rewrite it.
People can't read this. Rewrite it.
-
- Member
- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
Re: valid idt
How can people complain of his coding style? He doesn't even have one!
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: valid idt
hear hear!
Re: valid idt
I hope you are not going to use that coding style for every single entry in the IDT...
Also, why are you setting the base address to the first idt descriptor entry - 8 bytes? The IDT doesnt reserve the first entry. IDTRs base address should point to the first entry in your IDT. (assumes I read your code right)
Also, why are you setting the base address to the first idt descriptor entry - 8 bytes? The IDT doesnt reserve the first entry. IDTRs base address should point to the first entry in your IDT. (assumes I read your code right)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: valid idt
i like this way! hear...
now serius what is the other way, give me some example...
thanks!
now serius what is the other way, give me some example...
thanks!
Re: valid idt
Can you rephrase this? I dont understand what you are referring to here.i like this way! hear...
now serius what is the other way, give me some example...
thanks!
If you are referring to your coding style, and are looking for other methods, simply search google. There are plenty of examples online (Some were provided in your previous threads).
If you are referring to my response with regards to the way you have set up the IDTR, that is the *only* way (That I know of, anyways) as described inside of the intel processor manuals.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: valid idt
Personally I would enter 32-bit protected mode and set up the IDT afterwards (and maybe code it in C). It makes it easier to handle things like 32-bit pointers. Just remember to disable interrupts until the IDT is setup.mobruan wrote:i like this way! hear...
now serius what is the other way, give me some example...
thanks!
Also try separating code and data, like this (I tried rewriting your code, it might contain errors though):
Code: Select all
SECTION .text ; Code section
BITS 32 ; We entered protected mode
...
setup_idt:
; Setup IDT entry 1 pointing to 'isr'.
mov eax, isr ; Load the ISR offset in EAX
mov [idt_entry_1 + 0], ax ; Store the offset bits 0..15
shr eax, 16
mov [idt_entry_1 + 6], ax ; Store the offset bits 16..31
; Load IDT.
lidt [idt]
...
SECTION .data ; Data section
idt:
dw idt_table_end - idt_table_begin - 1 ; Limit (automatically calculated)
dd idt_table_begin ; Base address
idt_table_begin:
; The following really should be replaced by some macro... google!
idt_entry_0:
dw 0 ; Offset bits 0..15
dw 0x8 ; Code segment selector
db 0, 10001110b ; Type and attributes
dw 0 ; Offset bits 16..31
idt_entry_1:
dw 0 ; Offset bits 0..15
dw 0x8 ; Code segment selector
db 0, 10001110b ; Type and attributes
dw 0 ; Offset bits 16..31
...
idt_table_end:
Re: valid idt
The static IDT does not need initializing at all.
Code: Select all
lidt [IDTR]
...
align 2
IDTR:
dw IDT_SIZE-1 ; 256*8-1
dd IDT
align 8
IDT:
desc KCODE, ehandler_0, DF_INT32 ; or DF_TRAP32
desc KCODE, ehandler_1, DF_INT32 ; or DF_TRAP32
...
IDT_SIZE = $-IDT
If you have seen bad English in my words, tell me what's wrong, please.
Re: valid idt
Thanks!
I´ll try do this way!
I´ll try do this way!
Re: valid idt
it´s me again, i dont know how to use assembly together with c.
Anyone has a good tutorial?
Anyone has a good tutorial?
Re: valid idt
You can find a lot of information about linking object files or using inline asm in C on the wiki and the web. Have you read the forum rules, and have you searched for the knowledge yourself?mobruan wrote:it´s me again, i dont know how to use assembly together with c.
Anyone has a good tutorial?