1 |
|
---|
2 | /*
|
---|
3 | * XFree86 int10 module
|
---|
4 | * execute BIOS int 10h calls in x86 real mode environment
|
---|
5 | * Copyright 1999 Egbert Eich
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef _XF86INT10_H
|
---|
9 | #define _XF86INT10_H
|
---|
10 |
|
---|
11 | #include <X11/Xmd.h>
|
---|
12 | #include <X11/Xdefs.h>
|
---|
13 | #include "xf86Pci.h"
|
---|
14 |
|
---|
15 | #define SEG_ADDR(x) (((x) >> 4) & 0x00F000)
|
---|
16 | #define SEG_OFF(x) ((x) & 0x0FFFF)
|
---|
17 |
|
---|
18 | #define SET_BIOS_SCRATCH 0x1
|
---|
19 | #define RESTORE_BIOS_SCRATCH 0x2
|
---|
20 |
|
---|
21 | /* int10 info structure */
|
---|
22 | typedef struct {
|
---|
23 | int entityIndex;
|
---|
24 | CARD16 BIOSseg;
|
---|
25 | CARD16 inb40time;
|
---|
26 | ScrnInfoPtr pScrn;
|
---|
27 | pointer cpuRegs;
|
---|
28 | char *BIOSScratch;
|
---|
29 | int Flags;
|
---|
30 | pointer private;
|
---|
31 | struct _int10Mem *mem;
|
---|
32 | int num;
|
---|
33 | int ax;
|
---|
34 | int bx;
|
---|
35 | int cx;
|
---|
36 | int dx;
|
---|
37 | int si;
|
---|
38 | int di;
|
---|
39 | int es;
|
---|
40 | int bp;
|
---|
41 | int flags;
|
---|
42 | int stackseg;
|
---|
43 | struct pci_device *dev;
|
---|
44 | struct pci_io_handle *io;
|
---|
45 | } xf86Int10InfoRec, *xf86Int10InfoPtr;
|
---|
46 |
|
---|
47 | typedef struct _int10Mem {
|
---|
48 | CARD8 (*rb) (xf86Int10InfoPtr, int);
|
---|
49 | CARD16 (*rw) (xf86Int10InfoPtr, int);
|
---|
50 | CARD32 (*rl) (xf86Int10InfoPtr, int);
|
---|
51 | void (*wb) (xf86Int10InfoPtr, int, CARD8);
|
---|
52 | void (*ww) (xf86Int10InfoPtr, int, CARD16);
|
---|
53 | void (*wl) (xf86Int10InfoPtr, int, CARD32);
|
---|
54 | } int10MemRec, *int10MemPtr;
|
---|
55 |
|
---|
56 | typedef struct {
|
---|
57 | CARD8 save_msr;
|
---|
58 | CARD8 save_pos102;
|
---|
59 | CARD8 save_vse;
|
---|
60 | CARD8 save_46e8;
|
---|
61 | } legacyVGARec, *legacyVGAPtr;
|
---|
62 |
|
---|
63 | /* OS dependent functions */
|
---|
64 | extern _X_EXPORT xf86Int10InfoPtr xf86InitInt10(int entityIndex);
|
---|
65 | extern _X_EXPORT xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex,
|
---|
66 | int Flags);
|
---|
67 | extern _X_EXPORT void xf86FreeInt10(xf86Int10InfoPtr pInt);
|
---|
68 | extern _X_EXPORT void *xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num,
|
---|
69 | int *off);
|
---|
70 | extern _X_EXPORT void xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase,
|
---|
71 | int num);
|
---|
72 | extern _X_EXPORT pointer xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr);
|
---|
73 |
|
---|
74 | /* x86 executor related functions */
|
---|
75 | extern _X_EXPORT void xf86ExecX86int10(xf86Int10InfoPtr pInt);
|
---|
76 |
|
---|
77 | #ifdef _INT10_PRIVATE
|
---|
78 |
|
---|
79 | #define I_S_DEFAULT_INT_VECT 0xFF065
|
---|
80 | #define SYS_SIZE 0x100000
|
---|
81 | #define SYS_BIOS 0xF0000
|
---|
82 | #if 1
|
---|
83 | #define BIOS_SIZE 0x10000
|
---|
84 | #else /* a bug in DGUX requires this - let's try it */
|
---|
85 | #define BIOS_SIZE (0x10000 - 1)
|
---|
86 | #endif
|
---|
87 | #define LOW_PAGE_SIZE 0x600
|
---|
88 | #define V_RAM 0xA0000
|
---|
89 | #define VRAM_SIZE 0x20000
|
---|
90 | #define V_BIOS_SIZE 0x10000
|
---|
91 | #define V_BIOS 0xC0000
|
---|
92 | #define BIOS_SCRATCH_OFF 0x449
|
---|
93 | #define BIOS_SCRATCH_END 0x466
|
---|
94 | #define BIOS_SCRATCH_LEN (BIOS_SCRATCH_END - BIOS_SCRATCH_OFF + 1)
|
---|
95 | #define HIGH_MEM V_BIOS
|
---|
96 | #define HIGH_MEM_SIZE (SYS_BIOS - HIGH_MEM)
|
---|
97 | #define SEG_ADR(type, seg, reg) type((seg << 4) + (X86_##reg))
|
---|
98 | #define SEG_EADR(type, seg, reg) type((seg << 4) + (X86_E##reg))
|
---|
99 |
|
---|
100 | #define X86_TF_MASK 0x00000100
|
---|
101 | #define X86_IF_MASK 0x00000200
|
---|
102 | #define X86_IOPL_MASK 0x00003000
|
---|
103 | #define X86_NT_MASK 0x00004000
|
---|
104 | #define X86_VM_MASK 0x00020000
|
---|
105 | #define X86_AC_MASK 0x00040000
|
---|
106 | #define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */
|
---|
107 | #define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */
|
---|
108 | #define X86_ID_MASK 0x00200000
|
---|
109 |
|
---|
110 | #define MEM_RB(name, addr) (*name->mem->rb)(name, addr)
|
---|
111 | #define MEM_RW(name, addr) (*name->mem->rw)(name, addr)
|
---|
112 | #define MEM_RL(name, addr) (*name->mem->rl)(name, addr)
|
---|
113 | #define MEM_WB(name, addr, val) (*name->mem->wb)(name, addr, val)
|
---|
114 | #define MEM_WW(name, addr, val) (*name->mem->ww)(name, addr, val)
|
---|
115 | #define MEM_WL(name, addr, val) (*name->mem->wl)(name, addr, val)
|
---|
116 |
|
---|
117 | /* OS dependent functions */
|
---|
118 | extern _X_EXPORT Bool MapCurrentInt10(xf86Int10InfoPtr pInt);
|
---|
119 |
|
---|
120 | /* x86 executor related functions */
|
---|
121 | extern _X_EXPORT Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt);
|
---|
122 |
|
---|
123 | /* int.c */
|
---|
124 | extern _X_EXPORT xf86Int10InfoPtr Int10Current;
|
---|
125 | int int_handler(xf86Int10InfoPtr pInt);
|
---|
126 |
|
---|
127 | /* helper_exec.c */
|
---|
128 | int setup_int(xf86Int10InfoPtr pInt);
|
---|
129 | void finish_int(xf86Int10InfoPtr, int sig);
|
---|
130 | CARD32 getIntVect(xf86Int10InfoPtr pInt, int num);
|
---|
131 | void pushw(xf86Int10InfoPtr pInt, CARD16 val);
|
---|
132 | int run_bios_int(int num, xf86Int10InfoPtr pInt);
|
---|
133 | void dump_code(xf86Int10InfoPtr pInt);
|
---|
134 | void dump_registers(xf86Int10InfoPtr pInt);
|
---|
135 | void stack_trace(xf86Int10InfoPtr pInt);
|
---|
136 | CARD8 bios_checksum(const CARD8 *start, int size);
|
---|
137 | void LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga);
|
---|
138 | void UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga);
|
---|
139 |
|
---|
140 | #if defined (_PC)
|
---|
141 | extern _X_EXPORT void xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt,
|
---|
142 | Bool save);
|
---|
143 | #endif
|
---|
144 | int port_rep_inb(xf86Int10InfoPtr pInt,
|
---|
145 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
146 | int port_rep_inw(xf86Int10InfoPtr pInt,
|
---|
147 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
148 | int port_rep_inl(xf86Int10InfoPtr pInt,
|
---|
149 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
150 | int port_rep_outb(xf86Int10InfoPtr pInt,
|
---|
151 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
152 | int port_rep_outw(xf86Int10InfoPtr pInt,
|
---|
153 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
154 | int port_rep_outl(xf86Int10InfoPtr pInt,
|
---|
155 | CARD16 port, CARD32 base, int d_f, CARD32 count);
|
---|
156 |
|
---|
157 | CARD8 x_inb(CARD16 port);
|
---|
158 | CARD16 x_inw(CARD16 port);
|
---|
159 | void x_outb(CARD16 port, CARD8 val);
|
---|
160 | void x_outw(CARD16 port, CARD16 val);
|
---|
161 | CARD32 x_inl(CARD16 port);
|
---|
162 | void x_outl(CARD16 port, CARD32 val);
|
---|
163 |
|
---|
164 | CARD8 Mem_rb(CARD32 addr);
|
---|
165 | CARD16 Mem_rw(CARD32 addr);
|
---|
166 | CARD32 Mem_rl(CARD32 addr);
|
---|
167 | void Mem_wb(CARD32 addr, CARD8 val);
|
---|
168 | void Mem_ww(CARD32 addr, CARD16 val);
|
---|
169 | void Mem_wl(CARD32 addr, CARD32 val);
|
---|
170 |
|
---|
171 | /* helper_mem.c */
|
---|
172 | void setup_int_vect(xf86Int10InfoPtr pInt);
|
---|
173 | int setup_system_bios(void *base_addr);
|
---|
174 | void reset_int_vect(xf86Int10InfoPtr pInt);
|
---|
175 | void set_return_trap(xf86Int10InfoPtr pInt);
|
---|
176 | extern _X_EXPORT void *xf86HandleInt10Options(ScrnInfoPtr pScrn,
|
---|
177 | int entityIndex);
|
---|
178 | Bool int10skip(const void *options);
|
---|
179 | Bool int10_check_bios(int scrnIndex, int codeSeg,
|
---|
180 | const unsigned char *vbiosMem);
|
---|
181 | Bool initPrimary(const void *options);
|
---|
182 | extern _X_EXPORT BusType xf86int10GetBiosLocationType(const xf86Int10InfoPtr
|
---|
183 | pInt);
|
---|
184 | extern _X_EXPORT Bool xf86int10GetBiosSegment(xf86Int10InfoPtr pInt,
|
---|
185 | void *base);
|
---|
186 | #ifdef DEBUG
|
---|
187 | void dprint(unsigned long start, unsigned long size);
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | #endif /* _INT10_PRIVATE */
|
---|
191 | #endif /* _XF86INT10_H */
|
---|