1 /* 2 * From Coreboot file device/oprom/realmode/x86.h 3 * 4 * Copyright (C) 2007 Advanced Micro Devices, Inc. 5 * Copyright (C) 2009-2010 coresystems GmbH 6 * 7 * SPDX-License-Identifier: GPL-2.0 8 */ 9 10 #ifndef _X86_LIB_BIOS_H 11 #define _X86_LIB_BIOS_H 12 13 #include <linux/linkage.h> 14 15 #define REALMODE_BASE 0x600 16 17 #ifdef __ASSEMBLY__ 18 19 #define PTR_TO_REAL_MODE(x) (x - asm_realmode_code + REALMODE_BASE) 20 21 #else 22 23 /* Convert a symbol address to our real mode area */ 24 #define PTR_TO_REAL_MODE(sym)\ 25 (void *)(REALMODE_BASE + ((char *)&(sym) - (char *)&asm_realmode_code)) 26 27 /* 28 * The following symbols cannot be used directly. They need to be fixed up 29 * to point to the correct address location after the code has been copied 30 * to REALMODE_BASE. Absolute symbols are not used because those symbols are 31 * relocated by U-Boot. 32 */ 33 extern unsigned char asm_realmode_call, __realmode_interrupt; 34 extern unsigned char asm_realmode_buffer; 35 36 #define DOWNTO8(A) \ 37 union { \ 38 struct { \ 39 union { \ 40 struct { \ 41 uint8_t A##l; \ 42 uint8_t A##h; \ 43 } __packed; \ 44 uint16_t A##x; \ 45 } __packed; \ 46 uint16_t h##A##x; \ 47 } __packed; \ 48 uint32_t e##A##x; \ 49 } __packed; 50 51 #define DOWNTO16(A) \ 52 union { \ 53 struct { \ 54 uint16_t A; \ 55 uint16_t h##A; \ 56 } __packed; \ 57 uint32_t e##A; \ 58 } __packed; 59 60 struct eregs { 61 DOWNTO8(a); 62 DOWNTO8(c); 63 DOWNTO8(d); 64 DOWNTO8(b); 65 DOWNTO16(sp); 66 DOWNTO16(bp); 67 DOWNTO16(si); 68 DOWNTO16(di); 69 uint32_t vector; 70 uint32_t error_code; 71 uint32_t eip; 72 uint32_t cs; 73 uint32_t eflags; 74 }; 75 76 struct realmode_idt { 77 u16 offset, cs; 78 }; 79 80 void x86_exception(struct eregs *info); 81 82 /* From x86_asm.S */ 83 extern unsigned char __idt_handler; 84 extern unsigned int __idt_handler_size; 85 extern unsigned char asm_realmode_code; 86 extern unsigned int asm_realmode_code_size; 87 88 asmlinkage void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx, 89 u32 esi, u32 edi); 90 91 asmlinkage void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx, 92 u32 edx, u32 esi, u32 edi); 93 94 int int10_handler(void); 95 int int12_handler(void); 96 int int16_handler(void); 97 int int1a_handler(void); 98 #endif /*__ASSEMBLY__ */ 99 100 #endif 101