1 # pcboot - bootable PC demo/game kernel
2 # Copyright (C) 2018 John Tsiombikas <nuclear@member.fsf.org>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
25 /* void set_idt(uint32_t addr, uint16_t limit) */
35 /* int get_intr_flag() */
40 # bit 9 of eflags is IF
45 /* void set_intr_flag(int onoff) */
55 /* interrupt entry with error code macro
56 * this macro generates an interrupt entry point for the
57 * exceptions which include error codes in the stack frame
59 .macro ientry_err n name
60 .globl intr_entry_\name
66 /* interrupt entry without error code macro
67 * this macro generates an interrupt entry point for the interrupts
68 * and exceptions which do not include error codes in the stack frame
69 * it pushes a dummy error code (0), to make the stack frame identical
71 .macro ientry_noerr n name
72 .globl intr_entry_\name
79 /* common code used by all entry points. calls dispatch_intr()
84 /* save general purpose registers */
88 /* restore general purpose registers */
90 /* remove error code and intr num from stack */
94 /* special case for the timer interrupt, to avoid all the overhead of
95 * going through the C interrupt dispatcher 250 times each second
98 .global intr_entry_fast_timer
99 intr_entry_fast_timer:
101 # signal end of interrupt
109 /* XXX not necessary for now, just leaving it in in case it's useful
112 * intr_ret is called by context_switch to return from the kernel
113 * to userspace. The argument is a properly formed intr_frame
114 * structure with the saved context of the new task.
116 * First thing to do is remove the return address pointing back
117 * to context_switch, which then leaves us with a proper interrupt
118 * stack frame, so we can jump right in the middle of the regular
119 * interrupt return code above.
126 /* by including interrupts.h with ASM defined, the macros above
127 * are expanded to generate all required interrupt entry points