Page 1 of 1

valid idt

Posted: Tue Oct 14, 2008 1:25 pm
by mobruan
hi, why this is not a valid idt?
Thanks

Re: valid idt

Posted: Tue Oct 14, 2008 1:25 pm
by mobruan
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]

Re: valid idt

Posted: Tue Oct 14, 2008 2:28 pm
by Combuster
Why are you systematically getting complaints about your coding style?

People can't read this. Rewrite it.

Re: valid idt

Posted: Tue Oct 14, 2008 2:45 pm
by Craze Frog
How can people complain of his coding style? He doesn't even have one!

Re: valid idt

Posted: Tue Oct 14, 2008 2:46 pm
by Combuster
hear hear!

Re: valid idt

Posted: Tue Oct 14, 2008 4:09 pm
by neon
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)

Re: valid idt

Posted: Tue Oct 14, 2008 5:55 pm
by mobruan
i like this way! hear...
now serius what is the other way, give me some example...
thanks!

Re: valid idt

Posted: Tue Oct 14, 2008 6:15 pm
by neon
i like this way! hear...
now serius what is the other way, give me some example...
thanks!
Can you rephrase this? I dont understand what you are referring to here.

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.

Re: valid idt

Posted: Tue Oct 14, 2008 6:49 pm
by Walling
mobruan wrote:i like this way! hear...
now serius what is the other way, give me some example...
thanks!
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.

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:
Oh, and by the way, use indentation and use [ code] [ /code] tags in your posts. :)

Re: valid idt

Posted: Wed Oct 15, 2008 2:11 am
by egos
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

Re: valid idt

Posted: Wed Oct 15, 2008 8:26 am
by mobruan
Thanks!
I´ll try do this way!

Re: valid idt

Posted: Wed Oct 15, 2008 8:39 am
by mobruan
it´s me again, i dont know how to use assembly together with c.
Anyone has a good tutorial?

Re: valid idt

Posted: Wed Oct 15, 2008 5:00 pm
by Walling
mobruan wrote:it´s me again, i dont know how to use assembly together with c.
Anyone has a good tutorial?
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?