os/kernel/cpu/isr.h

47 lines
1.2 KiB
C
Raw Normal View History

2020-07-25 16:54:37 -05:00
/**
* \file
*/
2020-07-22 19:26:55 -05:00
#ifndef ISR_H
#define ISR_H
#include <stdint.h>
2020-07-25 16:54:37 -05:00
/**
* Saved state of the CPU when an interrupt occurs
*/
2020-07-22 19:26:55 -05:00
typedef struct {
2020-07-25 16:54:37 -05:00
uint32_t ds; //!< Data segment selector
uint32_t edi; //!< Pushed by pusha.
uint32_t esi; //!< Pushed by pusha.
uint32_t ebp; //!< Pushed by pusha.
uint32_t esp; //!< Pushed by pusha.
uint32_t ebx; //!< Pushed by pusha.
uint32_t edx; //!< Pushed by pusha.
uint32_t ecx; //!< Pushed by pusha.
uint32_t eax; //!< Pushed by pusha.
uint32_t int_no; //!< Interrupt number
uint32_t err_code; //!< Error code (if applicable)
uint32_t eip; //!< Pushed by the processor automatically
uint32_t cs; //!< Pushed by the processor automatically
uint32_t eflags; //!< Pushed by the processor automatically
uint32_t useresp; //!< Pushed by the processor automatically
uint32_t ss; //!< Pushed by the processor automatically
2020-07-22 19:26:55 -05:00
} registers_t;
2020-07-25 16:54:37 -05:00
typedef void (*isr_t)(registers_t*); //!< Type of an ISR handler function pointer
2020-07-22 19:26:55 -05:00
2020-07-25 16:54:37 -05:00
/**
* Install the interrupt handlers into the IDT.
*/
2020-07-22 19:26:55 -05:00
void isr_install();
2020-07-25 16:54:37 -05:00
/**
* Register an IRQ handler
* \param n the IRQ to register a handler for
* \param handler the handler to register
*/
2020-07-23 11:50:23 -05:00
void isr_register_handler(int n,isr_t handler);
2020-07-22 19:26:55 -05:00
#endif