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