apic.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef CFLAT_APIC_H
  2. #define CFLAT_APIC_H
  3. #include <stdint.h>
  4. #include "apic-defs.h"
  5. typedef struct {
  6. uint8_t vector;
  7. uint8_t delivery_mode:3;
  8. uint8_t dest_mode:1;
  9. uint8_t delivery_status:1;
  10. uint8_t polarity:1;
  11. uint8_t remote_irr:1;
  12. uint8_t trig_mode:1;
  13. uint8_t mask:1;
  14. uint8_t reserve:7;
  15. uint8_t reserved[4];
  16. uint8_t dest_id;
  17. } ioapic_redir_entry_t;
  18. typedef enum trigger_mode {
  19. TRIGGER_EDGE = 0,
  20. TRIGGER_LEVEL,
  21. TRIGGER_MAX,
  22. } trigger_mode_t;
  23. void mask_pic_interrupts(void);
  24. void eoi(void);
  25. uint8_t apic_get_tpr(void);
  26. void apic_set_tpr(uint8_t tpr);
  27. void ioapic_write_redir(unsigned line, ioapic_redir_entry_t e);
  28. void ioapic_write_reg(unsigned reg, uint32_t value);
  29. ioapic_redir_entry_t ioapic_read_redir(unsigned line);
  30. uint32_t ioapic_read_reg(unsigned reg);
  31. void set_mask(unsigned line, int mask);
  32. void enable_apic(void);
  33. uint32_t apic_read(unsigned reg);
  34. bool apic_read_bit(unsigned reg, int n);
  35. void apic_write(unsigned reg, uint32_t val);
  36. void apic_icr_write(uint32_t val, uint32_t dest);
  37. uint32_t apic_id(void);
  38. int enable_x2apic(void);
  39. void reset_apic(void);
  40. #endif