; ### DISCRIPTION ############################################################
; ###
; ### Continues the OSLDR16.asm and is linked in the next sector
; ### after OSLDR16.asm.
; ###
; ### Version list
; ### ver 1.0:
; ###   Clears the screen an prints a simple message.
; ###   Jumps to _main() in OSLDRC.C
; ###
; ### written by Robert Hanke.
; ### Copyright (c) 2007
; ###
; ### DISCRIPTION END ########################################################





; ### MACRO SECTION ##########################################################

%include "../PRJ/SRC/includes/macros.asm"

; ### MACRO SECTION END ######################################################





; ### COMPILER SECTION #######################################################

[BITS 32]
[CPU 386]

extern _main
extern _fault_handler
extern __support_start
extern __support_end

global start
global _isr0
global _isr1
global _isr2
global _isr3
global _isr4
global _isr5
global _isr6
global _isr7
global _isr8
global _isr9
global _isr10
global _isr11
global _isr12
global _isr13
global _isr14
global _isr15
global _isr16
global _isr17
global _isr18
global _isr19
global _isr20
global _isr21
global _isr22
global _isr23
global _isr24
global _isr25
global _isr26
global _isr27
global _isr28
global _isr29
global _isr30
global _isr31



; ### COMPILER SECTION END ###################################################





; ### CODE SECTION ###########################################################

start:	call	__support_start
	call	_main
	call	__support_end

hang:	jmp	hang





_isr0:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr1:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr2:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr3:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr4:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr5:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr6:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr7:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr8:	cli
	push	byte 0x08
	jmp	isr_common_stub

_isr9:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr10:	cli
	push	byte 0x0A
	jmp	isr_common_stub

_isr11:	cli
	push	byte 0x0B
	jmp	isr_common_stub

_isr12:	cli
	push	byte 0x0C
	jmp	isr_common_stub

_isr13:	cli
	push	byte 0x0D
	jmp	isr_common_stub

_isr14:	cli
	push	byte 0x0E
	jmp	isr_common_stub

_isr15:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr16:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr17:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr18:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr19:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr20:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr21:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr22:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr23:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr24:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr25:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr26:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr27:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr28:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr29:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr30:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

_isr31:	cli
	push	byte 0x00
	push	byte 0x00
	jmp	isr_common_stub

isr_common_stub:
	pusha
	push	ds
	push	es
	push	fs
	push	gs
	mov	ax, DATA_DESC			; Load the Kernel Data Segment descriptor!
	mov	ds, ax
	mov	es, ax
	mov	fs, ax
	mov	gs, ax
	mov	eax, esp			; Push us the stack
	push	eax
	mov	eax, _fault_handler
	call	eax				; A special call, preserves the 'eip' register
	pop	eax
	pop	gs
	pop	fs
	pop	es
	pop	ds
	popa
	add	esp, 0x08			; Cleans up the pushed error code and pushed ISR number
	iret					; pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP!

; ### CODE SECTION  END ######################################################