4 * execute BIOS int 10h calls in x86 real mode environment
5 * Copyright 1999 Egbert Eich
12 #include <X11/Xdefs.h>
15 #define SEG_ADDR(x) (((x) >> 4) & 0x00F000)
16 #define SEG_OFF(x) ((x) & 0x0FFFF)
18 #define SET_BIOS_SCRATCH 0x1
19 #define RESTORE_BIOS_SCRATCH 0x2
21 /* int10 info structure */
31 struct _int10Mem
* mem
;
45 } xf86Int10InfoRec
, *xf86Int10InfoPtr
;
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
;
61 } legacyVGARec
, *legacyVGAPtr
;
63 /* OS dependent functions */
64 xf86Int10InfoPtr
xf86InitInt10(int entityIndex
);
65 xf86Int10InfoPtr
xf86ExtendedInitInt10(int entityIndex
, int Flags
);
66 void xf86FreeInt10(xf86Int10InfoPtr pInt
);
67 void *xf86Int10AllocPages(xf86Int10InfoPtr pInt
, int num
, int *off
);
68 void xf86Int10FreePages(xf86Int10InfoPtr pInt
, void *pbase
, int num
);
69 pointer
xf86int10Addr(xf86Int10InfoPtr pInt
, CARD32 addr
);
71 /* x86 executor related functions */
72 void xf86ExecX86int10(xf86Int10InfoPtr pInt
);
76 #define I_S_DEFAULT_INT_VECT 0xFF065
77 #define SYS_SIZE 0x100000
78 #define SYS_BIOS 0xF0000
80 #define BIOS_SIZE 0x10000
81 #else /* a bug in DGUX requires this - let's try it */
82 #define BIOS_SIZE (0x10000 - 1)
84 #define LOW_PAGE_SIZE 0x600
86 #define VRAM_SIZE 0x20000
87 #define V_BIOS_SIZE 0x10000
88 #define V_BIOS 0xC0000
89 #define BIOS_SCRATCH_OFF 0x449
90 #define BIOS_SCRATCH_END 0x466
91 #define BIOS_SCRATCH_LEN (BIOS_SCRATCH_END - BIOS_SCRATCH_OFF + 1)
92 #define HIGH_MEM V_BIOS
93 #define HIGH_MEM_SIZE (SYS_BIOS - HIGH_MEM)
94 #define SEG_ADR(type, seg, reg) type((seg << 4) + (X86_##reg))
95 #define SEG_EADR(type, seg, reg) type((seg << 4) + (X86_E##reg))
97 #define X86_TF_MASK 0x00000100
98 #define X86_IF_MASK 0x00000200
99 #define X86_IOPL_MASK 0x00003000
100 #define X86_NT_MASK 0x00004000
101 #define X86_VM_MASK 0x00020000
102 #define X86_AC_MASK 0x00040000
103 #define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */
104 #define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */
105 #define X86_ID_MASK 0x00200000
107 #define MEM_RB(name, addr) (*name->mem->rb)(name, addr)
108 #define MEM_RW(name, addr) (*name->mem->rw)(name, addr)
109 #define MEM_RL(name, addr) (*name->mem->rl)(name, addr)
110 #define MEM_WB(name, addr, val) (*name->mem->wb)(name, addr, val)
111 #define MEM_WW(name, addr, val) (*name->mem->ww)(name, addr, val)
112 #define MEM_WL(name, addr, val) (*name->mem->wl)(name, addr, val)
114 /* OS dependent functions */
115 Bool
MapCurrentInt10(xf86Int10InfoPtr pInt
);
116 /* x86 executor related functions */
117 Bool
xf86Int10ExecSetup(xf86Int10InfoPtr pInt
);
120 extern xf86Int10InfoPtr Int10Current
;
121 int int_handler(xf86Int10InfoPtr pInt
);
124 int setup_int(xf86Int10InfoPtr pInt
);
125 void finish_int(xf86Int10InfoPtr
, int sig
);
126 CARD32
getIntVect(xf86Int10InfoPtr pInt
, int num
);
127 void pushw(xf86Int10InfoPtr pInt
, CARD16 val
);
128 int run_bios_int(int num
, xf86Int10InfoPtr pInt
);
129 void dump_code(xf86Int10InfoPtr pInt
);
130 void dump_registers(xf86Int10InfoPtr pInt
);
131 void stack_trace(xf86Int10InfoPtr pInt
);
132 xf86Int10InfoPtr
getInt10Rec(int entityIndex
);
133 CARD8
bios_checksum(const CARD8
*start
, int size
);
134 void LockLegacyVGA(xf86Int10InfoPtr pInt
, legacyVGAPtr vga
);
135 void UnlockLegacyVGA(xf86Int10InfoPtr pInt
, legacyVGAPtr vga
);
137 void xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt
, Bool save
);
139 int port_rep_inb(xf86Int10InfoPtr pInt
,
140 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
141 int port_rep_inw(xf86Int10InfoPtr pInt
,
142 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
143 int port_rep_inl(xf86Int10InfoPtr pInt
,
144 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
145 int port_rep_outb(xf86Int10InfoPtr pInt
,
146 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
147 int port_rep_outw(xf86Int10InfoPtr pInt
,
148 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
149 int port_rep_outl(xf86Int10InfoPtr pInt
,
150 CARD16 port
, CARD32 base
, int d_f
, CARD32 count
);
152 CARD8
x_inb(CARD16 port
);
153 CARD16
x_inw(CARD16 port
);
154 void x_outb(CARD16 port
, CARD8 val
);
155 void x_outw(CARD16 port
, CARD16 val
);
156 CARD32
x_inl(CARD16 port
);
157 void x_outl(CARD16 port
, CARD32 val
);
159 CARD8
Mem_rb(CARD32 addr
);
160 CARD16
Mem_rw(CARD32 addr
);
161 CARD32
Mem_rl(CARD32 addr
);
162 void Mem_wb(CARD32 addr
, CARD8 val
);
163 void Mem_ww(CARD32 addr
, CARD16 val
);
164 void Mem_wl(CARD32 addr
, CARD32 val
);
167 void setup_int_vect(xf86Int10InfoPtr pInt
);
168 int setup_system_bios(void *base_addr
);
169 void reset_int_vect(xf86Int10InfoPtr pInt
);
170 void set_return_trap(xf86Int10InfoPtr pInt
);
171 void * xf86HandleInt10Options(ScrnInfoPtr pScrn
, int entityIndex
);
172 Bool
int10skip(const void* options
);
173 Bool
int10_check_bios(int scrnIndex
, int codeSeg
,
174 const unsigned char* vbiosMem
);
175 Bool
initPrimary(const void* options
);
176 BusType
xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt
);
177 Bool
xf86int10GetBiosSegment(xf86Int10InfoPtr pInt
, void *base
);
179 void dprint(unsigned long start
, unsigned long size
);
183 int mapPciRom(int pciEntity
, unsigned char *address
);
185 #endif /* _INT10_PRIVATE */
186 #endif /* _XF86INT10_H */