os/kernel/cpu/isr.h

51 lines
1.4 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>
2021-02-28 13:46:33 -06:00
#include <sys/types.h>
2020-07-22 19:26:55 -05:00
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
2021-02-28 13:46:33 -06:00
*
* If the PID is 0, the handler will be called directly, otherwise a thread will be made in the PID starting at the handler's address.
* \param n The IRQ to register a handler for
* \param pid The PID that will handle the interrupt.
* \param handler The address of the handler.
2020-07-25 16:54:37 -05:00
*/
2021-02-28 13:46:33 -06:00
void isr_register_handler(int n,pid_t pid,void* handler);
2020-07-22 19:26:55 -05:00
#endif