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