All pastes #1773975 Raw Edit

Miscellany

public text v1 · immutable
#1773975 ·published 2010-02-01 04:05 UTC
rendered paste body
; Copyright (c) 2008 Julian Bayardo
;
; Permission is hereby granted, free of charge, to any person
; obtaining a copy of this software and associated documentation
; files (the "Software"), to deal in the Software without
; restriction, including without limitation the rights to use,
; copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the
; Software is furnished to do so, subject to the following
; conditions:
;
; The above copyright notice and this permission notice shall be
; included in all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
; OTHER DEALINGS IN THE SOFTWARE.

GLOBAL isr0, isr1, isr2, isr3, isr4, isr5, isr6, isr7, isr8, isr9
GLOBAL isr10, isr11, isr12, isr13, isr14, isr15, isr16, isr17, isr18, isr19
GLOBAL isr20, isr21, isr22, isr23, isr24, isr25, isr26, isr27, isr28, isr29
GLOBAL isr30, isr31
GLOBAL gdt_flush, idt_flush
EXTERN isr_handler

gdt_flush:
    mov eax, [esp+4]
    lgdt [eax]
    mov ax, 0010h
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax
    ret

idt_flush:
    mov eax, [esp+4]
    lidt [eax]
    ret

;  0: Divide By Zero Exception
isr0:
	cli
	push byte 0000h
	push byte 0000h
	jmp isr_common_stub

; 1: Debug Exception
isr1:
	cli
	push byte 0000h
	push byte 0001h
	jmp isr_common_stub

; 2: Non Maskable Interrupt Exception
isr2:
	cli
	push byte 0000h
	push byte 0002h
	jmp isr_common_stub

; 3: Int 3 Exception
isr3:
	cli
	push byte 0000h
	push byte 0003h
	jmp isr_common_stub

; 4: INTO Exception
isr4:
	cli
	push byte 0000h
	push byte 0004h
	jmp isr_common_stub

; 5: Out of Bounds Exception
isr5:
	cli
	push byte 0000h
	push byte 0005h
	jmp isr_common_stub

; 6: Invalid Opcode Exception
isr6:
	cli
	push byte 0000h
	push byte 0006h
	jmp isr_common_stub

; 7: Coprocessor Not Available Exception
isr7:
	cli
	push byte 0000h
	push byte 0007h
	jmp isr_common_stub

; 8: Double Fault Exception (With error code)
isr8:
	cli
	push byte 0008h
	jmp isr_common_stub

; 9: Coprocessor Segment Overrun Exception
isr9:
	cli
	push byte 0000h
	push byte 0009h
	jmp isr_common_stub

; 10: Bad TSS Exception (code)
isr10:
	cli
	push byte 000Ah
	jmp isr_common_stub

; 11: Segment Not Present Exception (code)
isr11:
	cli
	push byte 000Bh
	jmp isr_common_stub

; 12: Stack Fault Exception (code)
isr12:
	cli
	push byte 000Ch
	jmp isr_common_stub

; 13: General Protection Fault Exception (code)
isr13:
	cli
	push byte 000Dh
	jmp isr_common_stub

; 14: Page Fault Exception (code)
isr14:
	cli
	push byte 000Eh
	jmp isr_common_stub

; 15: Reserved Exception
isr15:
	cli
	push byte 0000h
	push byte 000Fh
	jmp isr_common_stub

; 16: Floating Point Exception
isr16:
	cli
	push byte 0000h
	push byte 0010h
	jmp isr_common_stub

; 17: Alignment Check Exception
isr17:
	cli
	push byte 0000h
	push byte 0011h
	jmp isr_common_stub

; 18: Machine Check Exception
isr18:
	cli
	push byte 0000h
	push byte 0012h
	jmp isr_common_stub

; 19: Reserved
isr19:
	cli
	push byte 0000h
	push byte 0013h
	jmp isr_common_stub

; 20: Reserved
isr20:
	cli
	push byte 0000h
	push byte 0014h
	jmp isr_common_stub

; 21: Reserved
isr21:
	cli
	push byte 0000h
	push byte 0015h
	jmp isr_common_stub

; 22: Reserved
isr22:
	cli
	push byte 0000h
	push byte 0016h
	jmp isr_common_stub

; 23: Reserved
isr23:
	cli
	push byte 0000h
	push byte 0017h
	jmp isr_common_stub

; 24: Reserved
isr24:
	cli
	push byte 0000h
	push byte 0018h
	jmp isr_common_stub

; 25: Reserved ( Dude Error )
isr25:
	cli
	push byte 0000h
	push byte 0019h
	jmp isr_common_stub

; 26: Reserved
isr26:
	cli
	push byte 0000h
	push byte 001Ah
	jmp isr_common_stub

; 27: Reserved
isr27:
	cli
	push byte 0000h
	push byte 001Bh
	jmp isr_common_stub

; 28: Reserved
isr28:
	cli
	push byte 0000h
	push byte 001Ch
	jmp isr_common_stub

; 29: Reserved
isr29:
	cli
	push byte 0000h
	push byte 001Dh
	jmp isr_common_stub

; 30: Reserved
isr30:
	cli
	push byte 0000h
	push byte 001Eh
	jmp isr_common_stub

; 31: Reserved
isr31:
	cli
	push byte 0000h
	push byte 001Fh
	jmp isr_common_stub

isr_common_stub:
	pusha
	push ds
	push es
	push fs
	push gs
	mov ax, 0010h
	mov ds, ax
	mov es, ax
	mov fs, ax
	mov gs, ax
	mov eax, esp
	push eax
	mov eax, isr_handler
	call eax
	pop eax
	pop gs
	pop fs
	pop es
	pop ds
	popa
	add esp, 0008h
	iret