1
2
3
4
5
6
7
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
24#define PTR_TO_REAL_MODE(sym)\
25 (void *)(REALMODE_BASE + ((char *)&(sym) - (char *)&asm_realmode_code))
26
27
28
29
30
31
32
33extern unsigned char asm_realmode_call, __realmode_interrupt;
34extern 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
60struct 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
76struct realmode_idt {
77 u16 offset, cs;
78};
79
80void x86_exception(struct eregs *info);
81
82
83extern unsigned char __idt_handler;
84extern unsigned int __idt_handler_size;
85extern unsigned char asm_realmode_code;
86extern unsigned int asm_realmode_code_size;
87
88asmlinkage void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
89 u32 esi, u32 edi);
90
91asmlinkage void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx,
92 u32 edx, u32 esi, u32 edi);
93
94int int10_handler(void);
95int int12_handler(void);
96int int16_handler(void);
97int int1a_handler(void);
98#endif
99
100#endif
101