2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY, without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
24 /* offset used to remap IRQ numbers (+32) */
26 /* conversion macros between IRQ and interrupt numbers */
27 #define IRQ_TO_INTR(x) ((x) + IRQ_OFFSET)
28 #define INTR_TO_IRQ(x) ((x) - IRQ_OFFSET)
29 /* checks whether a particular interrupt is an remapped IRQ */
30 #define IS_IRQ(n) ((n) >= IRQ_OFFSET && (n) < IRQ_OFFSET + 16)
32 /* general purpose registers as they are pushed by pusha */
34 uint32_t edi, esi, ebp, esp;
35 uint32_t ebx, edx, ecx, eax;
36 } __attribute__ ((packed));
38 /* structure used to pass the interrupt stack frame from the
39 * entry points to the C dispatch function.
42 /* registers pushed by pusha in intr_entry_* */
43 struct registers regs;
44 /* data segment selectors */
45 /* XXX removed: not needed unless we do dpl3 transitions
46 uint32_t ds, es, fs, gs;
48 /* interrupt number and error code pushed in intr_entry_* */
50 /* pushed by CPU during interrupt entry */
51 uint32_t eip, cs, eflags;
52 /* pushed by CPU during interrupt entry from user space */
53 /* XXX removed: again, not doing user space currently
56 } __attribute__ ((packed));
60 typedef void (*intr_func_t)(int);
64 void cleanup_intr(void);
66 struct intr_frame *get_intr_frame(void);
68 /* install high level interrupt callback */
69 void interrupt(int intr_num, intr_func_t func);
71 /* install low-level interrupt vector in IDT
72 * must be able to handle EOI and return with iret
74 void set_intr_entry(int num, void (*handler)(void));
76 void prog_pic(int offs);
77 void set_pic_mask(int pic, unsigned char mask);
78 unsigned char get_pic_mask(int pic);
79 void mask_irq(int irq);
80 void unmask_irq(int irq);
82 /* defined in intr_asm.S */
83 int get_intr_flag(void);
84 void set_intr_flag(int onoff);
86 void intr_ret(struct intr_frame ifrm);
88 void end_of_irq(int irq);