flat assembler
Message board for the users of flat assembler.

Index > OS Construction > 'ol IDT questions.

Author
Thread Post new topic Reply to topic
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 09 Feb 2010, 02:30
Well, I started reading about the IDT, ( here http://www.osdever.net/tutorials/interrupts.3.php )
and I saw that you could have a maximum of 256 entries. And I also saw
that I have to set up a IDT to make a keyboard driver easily. along with
needing to have to make a FDD driver. It also reads
Quote:
You are not required to have an IDT with a full 256 descriptors in it, just enough descriptors for the interrupts you are going to use.


So for my questions, do i have to have a minimum amount?
Do I have to make an int for every driver or function I make?

Or, can I get away by just making one or two 'dummy' ints as james
molly did here? http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html

I mean I know those dummy ints work, but could I make a full working
OS without having to right more than one entry?

_________________
Want hosting for free for your asm project? You can PM me. (*.fasm4u.net)
Post 09 Feb 2010, 02:30
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 09 Feb 2010, 02:38
Coddy41 wrote:
So for my questions, do i have to have a minimum amount?


32 (16 exceptions + 16 IRQ's) ?

Quote:
Do I have to make an int for every driver or function I make?


NO.
Post 09 Feb 2010, 02:38
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20409
Location: In your JS exploiting you and your system
revolution 09 Feb 2010, 02:57
It would probably be a good idea to have an IDT entry for at least the first 20 slots. Since currently the highest CPU int defined is 19 (#XM). After that you would also need some slots for the mobo IRQs, usually 16. And you have to have dummy entries for any unused slots.

So if you put your IRQ base at, say, 32 then that means you must have 48 IDT slots in the table (with 20-31 being null entries).
Post 09 Feb 2010, 02:57
View user's profile Send private message Visit poster's website Reply with quote
roboman



Joined: 03 Dec 2006
Posts: 122
Location: USA
roboman 09 Feb 2010, 03:13
I would think a safe thing to do is use the ones you want and have all the rest call an error function that goes to text mode, tells you what ver of the OS is running and says int *** not supported in this ver.
Post 09 Feb 2010, 03:13
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 09 Feb 2010, 03:56
AMD defines int 30 (#SX). 32 as IRQ base is actually the minimum as Intel documented the first 32 ints as reserved for processor use (and IBM thought it was funny to print the screen when BOUND instruction generates a #BR exception).
Post 09 Feb 2010, 03:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20409
Location: In your JS exploiting you and your system
revolution 09 Feb 2010, 05:26
It has been a while since I looked at the AMD docs. Looks like they have progressed a few things in the last few years.

I always found it very confounding that the original IBM BIOS used the low interrupts. Even though Intel said right from the start with the 8086 that 0-31 were reserved for future use.
Post 09 Feb 2010, 05:26
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 09 Feb 2010, 11:08
roboman wrote:
I would think a safe thing to do is use the ones you want and have all the rest call an error function that goes to text mode, tells you what ver of the OS is running and says int *** not supported in this ver.


it is a little boring to test code, and see a text mode instead of the graphix one, just to say there is an error.

just display a message with the exeption over every items on the screen is enough and go in an infinite loop, or only IRET (to test).

remember, the crash is a windows M$ (c)(tm)(r) design.
A design with a non active exeption panel is good.
for example, give to all (32+16) first entries a simple IRET exeption.

the IDT devellopped by DOSIN, cleaned by me, is very interesting.

just take a look at this:

Code:
align 8
dw 0
idtr    df @f-idt-1:idt
idt:
        dw isr0,sys_code,0x8E00,0
        dw isr1,sys_code,0x8E00,0
        dw isr2,sys_code,0x8E00,0
        dw isr3,sys_code,0x8E00,0
        dw isr4,sys_code,0x8E00,0
        dw isr5,sys_code,0x8E00,0
        dw isr6,sys_code,0x8E00,0
        dw isr7,sys_code,0x8E00,0
        dw isr8,sys_code,0x8E00,0
        dw isr9,sys_code,0x8E00,0
        dw isr10,sys_code,0x8E00,0
        dw isr11,sys_code,0x8E00,0
        dw isr12,sys_code,0x8E00,0
        dw isr13,sys_code,0x8E00,0
        dw isr14,sys_code,0x8E00,0
        dw isr15,sys_code,0x8E00,0
        dw isr16,sys_code,0x8E00,0
        dw isr17,sys_code,0x8E00,0
        dw isr18,sys_code,0x8E00,0
        dw isr19,sys_code,0x8E00,0
        dw isr20,sys_code,0x8E00,0
        dw isr21,sys_code,0x8E00,0
        dw isr22,sys_code,0x8E00,0
        dw isr23,sys_code,0x8E00,0
        dw isr24,sys_code,0x8E00,0
        dw isr25,sys_code,0x8E00,0
        dw isr26,sys_code,0x8E00,0
        dw isr27,sys_code,0x8E00,0
        dw isr28,sys_code,0x8E00,0
        dw isr29,sys_code,0x8E00,0
        dw isr30,sys_code,0x8E00,0
        dw isr31,sys_code,0x8E00,0
; hardware interrupt handlers    timer,keyboard,ect...
; irq0 =Timer -just used dos irq names - irq1 =keyboard etc...
        dw irq0,sys_code,0x8E00,0
        dw irq1,sys_code,0x8E00,0
        dw irq2,sys_code,0x8E00,0
        dw irq3,sys_code,0x8E00,0
        dw irq4,sys_code,0x8E00,0
        dw irq5,sys_code,0x8E00,0
        dw irq6,sys_code,0x8E00,0
        dw irq7,sys_code,0x8E00,0
@@:
    


Code:
;*********************************
;*      System Faults            *
;*********************************
isr0:
        call black_screen_of_death
        mov esi,E00
        call handle_int
        jmp $
isr1:
        call black_screen_of_death
        mov esi,E01
        call handle_int
        jmp $
isr2:
        call black_screen_of_death
        mov esi,E02
        call handle_int
        jmp $
isr3:
        call black_screen_of_death
        mov esi,E03
        call handle_int
        jmp $
isr4:
        call black_screen_of_death
        mov esi,E04
        call handle_int
        jmp $
isr5:
        call black_screen_of_death
        mov esi,E05
        call handle_int
        jmp $
isr6:
        call black_screen_of_death
        mov esi,E06
        call handle_int
        jmp $
isr7:
        call black_screen_of_death
        mov esi,E07
        call handle_int
        jmp $
isr8:
        call black_screen_of_death
        mov esi,E08
        call handle_int
        jmp $
isr9:
        call black_screen_of_death
        mov esi,E09
        call handle_int
        jmp $
isr10:
        call black_screen_of_death
        mov esi,E10
        call handle_int
        jmp $
isr11:
        call black_screen_of_death
        mov esi,E11
        call handle_int
        jmp $
isr12:
        call black_screen_of_death
        mov esi,E12
        call handle_int
        jmp $
isr13:
        call black_screen_of_death
        mov esi,E13
        call handle_int
        jmp $
isr14:
        call black_screen_of_death
        mov esi,E14
        call handle_int
        jmp $
isr15:
        call black_screen_of_death
        mov esi,E15
        call handle_int
        jmp $
isr16:
        call black_screen_of_death
        mov esi,E16
        call handle_int
        jmp $
isr17:
        call black_screen_of_death
        mov esi,E17
        call handle_int
        jmp $
isr18:
        jmp $
isr19:          
        jmp $
isr20:          
        jmp $
isr21:
        jmp $
isr22:
        jmp $
isr23:
        jmp $
isr24:                  
        jmp $
isr25:                  
        jmp $
isr26:          
        jmp $
isr27:          
        jmp $
isr28:          
        jmp $
isr29:                  
        jmp $
isr30:                  
        jmp $
isr31:                          
        jmp $
;*****************************************************************
;*               hardware interrupt handlers                     *
;* irq0 =Timer -I just used dos irq names - irq1 =keyboard etc.. *
;*****************************************************************
irq0:                   ;int 0x20 - int 0x27
        iret
irq1:                           
include 'irq1\irq1.inc'
irq2:
        iret
irq3:           
        iret
irq4:           
        iret
irq5:           
        iret
irq6:           
        iret
irq7:           
        iret
black_screen_of_death:
;        mov    [box.x],0
;        mov    [box.y],0
;        mov    eax,[xres]
;        mov    ebx,[yres]
;        mov    [box.xl],eax
;        mov    [box.xl],eax
;        mov    [box.c],0
;        call   box
        ret
handle_int:
;        mov    [txt.x],300
;        mov    [txt.y],200
;        mov    [txt.c0],0
;        mov    [txt.c1],0x00FF0000
;        mov    [txt.smooth],0
;        call   txt
        jmp    $  ;hlt system
;******************
;    Error Msgs   *
;******************
E00     db "Exception 00h - Division By Zero X/0",0
E01     db "Exception 01h - Debug .|.|.",0
E02     db "Exception 02h - Non Maskable Interrupt NMI",0
E03     db "Exception 03h - Breakpoint Exception .|.",0
E04     db "Exception 04h - Int 0 Detected Overflow >>",0
E05     db "Exception 05h - Out of Bounds <><!",0
E06     db "Exception 06h - Invalid Opcode ??",0
E07     db "Exception 07h - No Coprocessor /X87",0
E08     db "Exception 08h - Double Fault X2",0
E09     db "Exception 09h - Coprocessor Segment Overrun #X87",0
E10     db "Exception 0Ah - Bad TSS ",0
E11     db "Exception 0Bh - Segment Not Present #?",0
E12     db "Exception 0Ch - Stack Fault _-",0
E13     db "Exception 0Dh - General Protection Fault !G!",0
E14     db "Exception 0Eh - Page Fault !P!",0
E15     db "Exception 0Fh - Unknown Interrupt ?I?",0
E16     db "Exception 10h - Coprocessor Fault !X87!",0
E17     db "Exception 11h - Alignment Check |><|",0
;; added some Exceptions symbols for "real" informaticians brainfucking Laughing²
;; why? cause i want to show to "REAL" informaticians thay don't know anything to the " real official" computer world.
    


and of course, no IDT is there is no GDT.
Code:
align 4
align 2                                    ; for GDTR alignment
gdtr   df @f-gdt-1:gdt                     ; GDTR in memory
gdt:                                       ; GDT entry
       dq 0                                ; (0) NULL selector
linear_sel_1:                              ; (8h) linear Data segment, read/write, expand down
       dw 0FFFFh,0
       db 0,10010010b,11001111b,0
sys_code_1:                                ; (10h) Code segment, read/execute, nonconforming
       dw 0FFFFh,0
       db 0,10011010b,11001111b,0
sys_data_1:                                ; (18h) Data segment, read/write, expand down
       dw 0FFFFh,0
       db 0,10010010b,11001111b,0
Real_code_1:                               ; (20h) Real mode code segment
       dw 0FFFFh,0
       db 0,10011010b,0,0
Real_data_1:                               ; (28h) Real mode data segment
       dw 0FFFFh,0
       db 0,10010010b,0,0
sys_vesa_1:                                ; (30h) vesa segment, read/write, expand down
       dw 0FFFFh,0
       db 0,10010010b,11001111b,0
@@:                                        ; Used to calculate the size of the GDT
sys_vbuff_1:                                ; (30h) vesa segment, read/write, expand down
       dw 0FFFFh,0
       db 0,10010010b,11001111b,0
@@:                                        ; Used to calculate the size of the GDT
    


Very Happy

if the code don't works, directlly go to this place and dl the file:

http://board.flatassembler.net/topic.php?p=71998#71998


Last edited by edfed on 17 May 2010, 10:31; edited 1 time in total
Post 09 Feb 2010, 11:08
View user's profile Send private message Visit poster's website Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 09 Feb 2010, 16:09
OK, so a minimum of 32 entries and all can be dummy ints? Sounds easy
enough. Smile

@edfed: that code cleared up another question, thanks Very Happy

@roboman: Well considering my OS will be already in text mode as I don't
plan to have a GUI OS, should not be to hard Wink

thanks guys, ill ask if I run into any more rubix cubes Laughing

_________________
Want hosting for free for your asm project? You can PM me. (*.fasm4u.net)
Post 09 Feb 2010, 16:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20409
Location: In your JS exploiting you and your system
revolution 09 Feb 2010, 18:09
Coddy41 wrote:
OK, so a minimum of 32 entries and all can be dummy ints?
Where are you going to put the IRQs? With just 32 entries you would have to overlap the CPU exception ints. Confused
Post 09 Feb 2010, 18:09
View user's profile Send private message Visit poster's website Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41 09 Feb 2010, 19:43
Oh right! plus 16, thats not to many more, as you said 48...

_________________
Want hosting for free for your asm project? You can PM me. (*.fasm4u.net)
Post 09 Feb 2010, 19:43
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.