SECTION .data EXTERN _OSIntNesting EXTERN _OSTCBCur EXTERN _kybd_queue EXTERN _com1_queue SECTION .text ALIGN 16 BITS 32 GLOBAL _KeyboardISR GLOBAL _SerialISR EXTERN _OSIntEnter EXTERN _OSIntExit EXTERN _OSQPost ; -------------------------------------------------------------------- _KeyboardISR: ; -------------------------------------------------------------------- PUSHA ; Save interrupted task's context CALL _OSIntEnter ; Notify uC/OS-II of ISR CMP BYTE [_OSIntNesting], 1 ; if (OSIntNesting == 1) JNE SHORT _KeyboardISR1 MOV EAX, [_OSTCBCur] ; OSTCBCur->OSTCBStkPtr = ESP MOV [EAX], ESP _KeyboardISR1: IN AL,60h ; get scan code MOVZX EAX,AL PUSH EAX PUSH DWORD [_kybd_queue] CALL _OSQPost ADD ESP,8 MOV AL,20H ; Send EOI to PIC OUT 20H,AL CALL _OSIntExit ; Notify uC/OS-II of end of ISR POPA IRET ; Return to interrupted task ; -------------------------------------------------------------------- _SerialISR: ; -------------------------------------------------------------------- PUSHA ; Save interrupted task's context CALL _OSIntEnter ; Notify uC/OS-II of ISR CMP BYTE [_OSIntNesting], 1 ; if (OSIntNesting == 1) JNE SHORT _SerialISR1 MOV EAX, [_OSTCBCur] ; OSTCBCur->OSTCBStkPtr = ESP MOV [EAX], ESP _SerialISR1: MOV DX,3F8H IN AL,DX ; get serial byte MOVZX EAX,AL PUSH EAX PUSH DWORD [_com1_queue] CALL _OSQPost ADD ESP,8 MOV AL,20H ; Send EOI to PIC OUT 20H,AL CALL _OSIntExit ; Notify uC/OS-II of end of ISR POPA IRET ; Return to interrupted task END