2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018-2023 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/>.
23 #define enable_intr() asm volatile("sti")
24 #define disable_intr() asm volatile("cli")
25 #define halt_cpu() asm volatile("hlt")
27 #define CALLER_EIP(eip) \
29 "mov 4(%%ebp), %0\n\t" \
30 : "=a" ((uint32_t)eip))
32 static inline uint8_t inp(uint16_t port)
42 static inline uint16_t inpw(uint16_t port)
52 static inline uint32_t inpd(uint16_t port)
62 #define outp(port, src) \
65 :: "a" ((uint8_t)(src)), "dN" ((uint16_t)(port)))
67 #define outpw(port, src) \
70 :: "a" ((uint16_t)(src)), "dN" ((uint16_t)(port)))
72 #define outpd(port, src) \
75 :: "a" ((uint32_t)(src)), "dN" ((uint16_t)(port)))
77 /* delay for about 1us */
78 #define iodelay() outp(0x80, 0)
80 #define get_ebp(ebp) \
83 : "=g"((uint32_t)(ebp)))
85 #endif /* ASMOPS_H_ */