[comp.os.minix] reprogrramming 8959A's

schmitz@addamax.UUCP (04/24/89)

Here's the code to reprogram the 8259A's for use in protected mode:

				--Michael
				schmitz@uiucuxc.cs.uiuc.edu!addamax

inta00		EQU	020h	; I/O port for first 8259A
inta01		EQU	021h	; mask register port for first 8259A
intb00		EQU	0a0h	; I/O port for second 8259A -- not used below
intb01		EQU	0a1h	; mask register port for second 8259A

;----------------------------------------------------------------------------;
; init_8259a								     ;
;	Sends initialization sequences to the two 8259A's.  Note that they   ;
;	are programmed to generate interrupt vectors starting with 32.	     ;
;	Thus the clock, on IRQ0, generates interrupt number 32, and the	     ;
;	keyboard, on IRQ1, generates interrupt number 33.		     ;
;----------------------------------------------------------------------------;
init_8259a	PROC
	mov	al, 011h
	out	inta00, al
	jmp	SHORT $ + 2
	mov	al, 020h		; interrupts start at 32
	out	inta01, al
	jmp	SHORT $ + 2
	mov	al, 04h
	out	inta01, al
	jmp	SHORT $ + 2
	mov	al, 01h
	out	inta01, al
	jmp	SHORT $ + 2

	mov	al, 011h
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 028h		; interrupts start at 40
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 02h	
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 01h
	out	intb01, al
	jmp	SHORT $ + 2
	ret
init_8259a	ENDP

PAGE

;----------------------------------------------------------------------------;
; restore_8259a								     ;
;	Sends initialization sequences to the two 8259A's.  Note that they   ;
;	are programmed to generate interrupt vectors starting with 8.	     ;
;	Thus the clock, on IRQ0, generates interrupt number 8, and the	     ;
;	keyboard, on IRQ1, generates interrupt number 9.		     ;
;----------------------------------------------------------------------------;
restore_8259a	PROC
	mov	al, 011h
	out	inta00, al
	jmp	SHORT $ + 2
	mov	al, 8h			; interrupts start at 8
	out	inta01, al
	jmp	SHORT $ + 2
	mov	al, 04h
	out	inta01, al
	jmp	SHORT $ + 2
	mov	al, 01h
	out	inta01, al
	jmp	SHORT $ + 2

	mov	al, 011h
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 10h			; interrupts start at 16
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 02h
	out	intb01, al
	jmp	SHORT $ + 2
	mov	al, 01h
	out	intb01, al
	jmp	SHORT $ + 2
	ret
restore_8259a	ENDP