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