biosemu.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /****************************************************************************
  2. *
  3. * BIOS emulator and interface
  4. * to Realmode X86 Emulator Library
  5. *
  6. * Copyright (C) 1996-1999 SciTech Software, Inc.
  7. *
  8. * ========================================================================
  9. *
  10. * Permission to use, copy, modify, distribute, and sell this software and
  11. * its documentation for any purpose is hereby granted without fee,
  12. * provided that the above copyright notice appear in all copies and that
  13. * both that copyright notice and this permission notice appear in
  14. * supporting documentation, and that the name of the authors not be used
  15. * in advertising or publicity pertaining to distribution of the software
  16. * without specific, written prior permission. The authors makes no
  17. * representations about the suitability of this software for any purpose.
  18. * It is provided "as is" without express or implied warranty.
  19. *
  20. * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  21. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  22. * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  23. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  24. * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  25. * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  26. * PERFORMANCE OF THIS SOFTWARE.
  27. *
  28. * ========================================================================
  29. *
  30. * Language: ANSI C
  31. * Environment: Any
  32. * Developer: Kendall Bennett
  33. *
  34. * Description: Header file for the real mode x86 BIOS emulator, which is
  35. * used to warmboot any number of VGA compatible PCI/AGP
  36. * controllers under any OS, on any processor family that
  37. * supports PCI. We also allow the user application to call
  38. * real mode BIOS functions and Int 10h functions (including
  39. * the VESA BIOS).
  40. *
  41. ****************************************************************************/
  42. #ifndef __BIOSEMU_H
  43. #define __BIOSEMU_H
  44. #include <bios_emul.h>
  45. #ifdef __KERNEL__
  46. #include "x86emu.h"
  47. #else
  48. #include "x86emu.h"
  49. #include "pmapi.h"
  50. #include "pcilib.h"
  51. #endif
  52. /*---------------------- Macros and type definitions ----------------------*/
  53. #pragma pack(1)
  54. #define CRT_C 24 /* 24 CRT Controller Registers */
  55. #define ATT_C 21 /* 21 Attribute Controller Registers */
  56. #define GRA_C 9 /* 9 Graphics Controller Registers */
  57. #define SEQ_C 5 /* 5 Sequencer Registers */
  58. #define PAL_C 768 /* 768 Palette Registers */
  59. /****************************************************************************
  60. REMARKS:
  61. Data structure used to describe the details for the BIOS emulator system
  62. environment as used by the X86 emulator library.
  63. HEADER:
  64. biosemu.h
  65. MEMBERS:
  66. vgaInfo - VGA BIOS information structure
  67. biosmem_base - Base of the BIOS image
  68. biosmem_limit - Limit of the BIOS image
  69. busmem_base - Base of the VGA bus memory
  70. timer - Timer used to emulate PC timer ports
  71. timer0 - Latched value for timer 0
  72. timer0Latched - true if timer 0 value was just latched
  73. timer2 - Current value for timer 2
  74. emulateVGA - true to emulate VGA I/O and memory accesses
  75. ****************************************************************************/
  76. typedef struct {
  77. BE_VGAInfo vgaInfo;
  78. ulong biosmem_base;
  79. ulong biosmem_limit;
  80. ulong busmem_base;
  81. u32 timer0;
  82. int timer0Latched;
  83. u32 timer1;
  84. int timer1Latched;
  85. u32 timer2;
  86. int timer2Latched;
  87. int emulateVGA;
  88. u8 emu61;
  89. u8 emu70;
  90. int flipFlop3C0;
  91. u32 configAddress;
  92. u8 emu3C0;
  93. u8 emu3C1[ATT_C];
  94. u8 emu3C2;
  95. u8 emu3C4;
  96. u8 emu3C5[SEQ_C];
  97. u8 emu3C6;
  98. uint emu3C7;
  99. uint emu3C8;
  100. u8 emu3C9[PAL_C];
  101. u8 emu3CE;
  102. u8 emu3CF[GRA_C];
  103. u8 emu3D4;
  104. u8 emu3D5[CRT_C];
  105. u8 emu3DA;
  106. } BE_sysEnv;
  107. #ifdef __KERNEL__
  108. /* Define some types when compiling for the Linux kernel that normally
  109. * come from the SciTech PM library.
  110. */
  111. /****************************************************************************
  112. REMARKS:
  113. Structure describing the 32-bit extended x86 CPU registers
  114. HEADER:
  115. pmapi.h
  116. MEMBERS:
  117. eax - Value of the EAX register
  118. ebx - Value of the EBX register
  119. ecx - Value of the ECX register
  120. edx - Value of the EDX register
  121. esi - Value of the ESI register
  122. edi - Value of the EDI register
  123. cflag - Value of the carry flag
  124. ****************************************************************************/
  125. typedef struct {
  126. u32 eax;
  127. u32 ebx;
  128. u32 ecx;
  129. u32 edx;
  130. u32 esi;
  131. u32 edi;
  132. u32 cflag;
  133. } RMDWORDREGS;
  134. /****************************************************************************
  135. REMARKS:
  136. Structure describing the 16-bit x86 CPU registers
  137. HEADER:
  138. pmapi.h
  139. MEMBERS:
  140. ax - Value of the AX register
  141. bx - Value of the BX register
  142. cx - Value of the CX register
  143. dx - Value of the DX register
  144. si - Value of the SI register
  145. di - Value of the DI register
  146. cflag - Value of the carry flag
  147. ****************************************************************************/
  148. #ifdef __BIG_ENDIAN__
  149. typedef struct {
  150. u16 ax_hi, ax;
  151. u16 bx_hi, bx;
  152. u16 cx_hi, cx;
  153. u16 dx_hi, dx;
  154. u16 si_hi, si;
  155. u16 di_hi, di;
  156. u16 cflag_hi, cflag;
  157. } RMWORDREGS;
  158. #else
  159. typedef struct {
  160. u16 ax, ax_hi;
  161. u16 bx, bx_hi;
  162. u16 cx, cx_hi;
  163. u16 dx, dx_hi;
  164. u16 si, si_hi;
  165. u16 di, di_hi;
  166. u16 cflag, cflag_hi;
  167. } RMWORDREGS;
  168. #endif
  169. /****************************************************************************
  170. REMARKS:
  171. Structure describing the 8-bit x86 CPU registers
  172. HEADER:
  173. pmapi.h
  174. MEMBERS:
  175. al - Value of the AL register
  176. ah - Value of the AH register
  177. bl - Value of the BL register
  178. bh - Value of the BH register
  179. cl - Value of the CL register
  180. ch - Value of the CH register
  181. dl - Value of the DL register
  182. dh - Value of the DH register
  183. ****************************************************************************/
  184. #ifdef __BIG_ENDIAN__
  185. typedef struct {
  186. u16 ax_hi;
  187. u8 ah, al;
  188. u16 bx_hi;
  189. u8 bh, bl;
  190. u16 cx_hi;
  191. u8 ch, cl;
  192. u16 dx_hi;
  193. u8 dh, dl;
  194. } RMBYTEREGS;
  195. #else
  196. typedef struct {
  197. u8 al;
  198. u8 ah;
  199. u16 ax_hi;
  200. u8 bl;
  201. u8 bh;
  202. u16 bx_hi;
  203. u8 cl;
  204. u8 ch;
  205. u16 cx_hi;
  206. u8 dl;
  207. u8 dh;
  208. u16 dx_hi;
  209. } RMBYTEREGS;
  210. #endif
  211. /****************************************************************************
  212. REMARKS:
  213. Structure describing all the x86 CPU registers
  214. HEADER:
  215. pmapi.h
  216. MEMBERS:
  217. e - Member to access registers as 32-bit values
  218. x - Member to access registers as 16-bit values
  219. h - Member to access registers as 8-bit values
  220. ****************************************************************************/
  221. typedef union {
  222. RMDWORDREGS e;
  223. RMWORDREGS x;
  224. RMBYTEREGS h;
  225. } RMREGS;
  226. /****************************************************************************
  227. REMARKS:
  228. Structure describing all the x86 segment registers
  229. HEADER:
  230. pmapi.h
  231. MEMBERS:
  232. es - ES segment register
  233. cs - CS segment register
  234. ss - SS segment register
  235. ds - DS segment register
  236. fs - FS segment register
  237. gs - GS segment register
  238. ****************************************************************************/
  239. typedef struct {
  240. u16 es;
  241. u16 cs;
  242. u16 ss;
  243. u16 ds;
  244. u16 fs;
  245. u16 gs;
  246. } RMSREGS;
  247. #endif /* __KERNEL__ */
  248. #ifndef __KERNEL__
  249. /****************************************************************************
  250. REMARKS:
  251. Structure defining all the BIOS Emulator API functions as exported from
  252. the Binary Portable DLL.
  253. {secret}
  254. ****************************************************************************/
  255. typedef struct {
  256. ulong dwSize;
  257. ibool(PMAPIP BE_init) (u32 debugFlags, int memSize, BE_VGAInfo * info);
  258. void (PMAPIP BE_setVGA) (BE_VGAInfo * info);
  259. void (PMAPIP BE_getVGA) (BE_VGAInfo * info);
  260. void *(PMAPIP BE_mapRealPointer) (uint r_seg, uint r_off);
  261. void *(PMAPIP BE_getVESABuf) (uint * len, uint * rseg, uint * roff);
  262. void (PMAPIP BE_callRealMode) (uint seg, uint off, RMREGS * regs,
  263. RMSREGS * sregs);
  264. int (PMAPIP BE_int86) (int intno, RMREGS * in, RMREGS * out);
  265. int (PMAPIP BE_int86x) (int intno, RMREGS * in, RMREGS * out,
  266. RMSREGS * sregs);
  267. void *reserved1;
  268. void (PMAPIP BE_exit) (void);
  269. } BE_exports;
  270. /****************************************************************************
  271. REMARKS:
  272. Function pointer type for the Binary Portable DLL initialisation entry point.
  273. {secret}
  274. ****************************************************************************/
  275. typedef BE_exports *(PMAPIP BE_initLibrary_t) (PM_imports * PMImp);
  276. #endif
  277. #pragma pack()
  278. /*---------------------------- Global variables ---------------------------*/
  279. #ifdef __cplusplus
  280. extern "C" { /* Use "C" linkage when in C++ mode */
  281. #endif
  282. /* {secret} Global BIOS emulator system environment */
  283. extern BE_sysEnv _BE_env;
  284. /*-------------------------- Function Prototypes --------------------------*/
  285. /* BIOS emulator library entry points */
  286. int X86API BE_init(u32 debugFlags, int memSize, BE_VGAInfo * info,
  287. int shared);
  288. void X86API BE_setVGA(BE_VGAInfo * info);
  289. void X86API BE_getVGA(BE_VGAInfo * info);
  290. void X86API BE_setDebugFlags(u32 debugFlags);
  291. void *X86API BE_mapRealPointer(uint r_seg, uint r_off);
  292. void *X86API BE_getVESABuf(uint * len, uint * rseg, uint * roff);
  293. void X86API BE_callRealMode(uint seg, uint off, RMREGS * regs,
  294. RMSREGS * sregs);
  295. int X86API BE_int86(int intno, RMREGS * in, RMREGS * out);
  296. int X86API BE_int86x(int intno, RMREGS * in, RMREGS * out,
  297. RMSREGS * sregs);
  298. void X86API BE_exit(void);
  299. #ifdef __cplusplus
  300. } /* End of "C" linkage for C++ */
  301. #endif
  302. #endif /* __BIOSEMU_H */