irq.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * irq.h
  3. *
  4. * Copyright (C) 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _IRQ_H_
  20. #define _IRQ_H_
  21. #include <common.h>
  22. #include <interrupt.h>
  23. #define IRQ_INT_BASE 0x20
  24. #define MAX_IRQ_COUNT 16
  25. #define PRIMARY_IRQ_INT IRQ_INT_BASE
  26. #define SECONDARY_IRQ_INT (IRQ_INT_BASE + 8)
  27. #define PRIMARY_PIC_CMD 0x20
  28. #define SECONDARY_PIC_CMD 0xA0
  29. #define PRIMARY_PIC_DATA 0x21
  30. #define SECONDARY_PIC_DATA 0xA1
  31. #define PRIMARY_PIC_CASCADE_IRQ 2
  32. #define SECONDARY_PIC_CASCADE_IRQ 1
  33. #define PIC_8086_MODE 0x01
  34. typedef void (*irq_handler_proc_t)(registers_t *regs, byte_t irq_num);
  35. typedef struct
  36. {
  37. list_entry_t list;
  38. irq_handler_proc_t procedure;
  39. bool_t exclusive;
  40. } irq_handler_t;
  41. dword_t register_irq_handler(byte_t irq_num, irq_handler_proc_t handler_proc, bool_t exclusive);
  42. dword_t unregister_irq_handler(byte_t irq_num, irq_handler_proc_t handler_proc);
  43. byte_t alloc_irq();
  44. void free_irq(byte_t number);
  45. void irq_init();
  46. #endif