uboot/drivers/bios_emulator/include/biosemu.h
<<
>>
Prefs
   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
  43#ifndef __BIOSEMU_H
  44#define __BIOSEMU_H
  45
  46#include <bios_emul.h>
  47
  48#ifdef __KERNEL__
  49#include "x86emu.h"
  50#else
  51#include "x86emu.h"
  52#include "pmapi.h"
  53#include "pcilib.h"
  54#endif
  55
  56/*---------------------- Macros and type definitions ----------------------*/
  57
  58#pragma pack(1)
  59
  60#define CRT_C   24              /* 24  CRT Controller Registers             */
  61#define ATT_C   21              /* 21  Attribute Controller Registers       */
  62#define GRA_C   9               /* 9   Graphics Controller Registers        */
  63#define SEQ_C   5               /* 5   Sequencer Registers                  */
  64#define PAL_C   768             /* 768 Palette Registers                    */
  65
  66/****************************************************************************
  67REMARKS:
  68Data structure used to describe the details for the BIOS emulator system
  69environment as used by the X86 emulator library.
  70
  71HEADER:
  72biosemu.h
  73
  74MEMBERS:
  75vgaInfo         - VGA BIOS information structure
  76biosmem_base    - Base of the BIOS image
  77biosmem_limit   - Limit of the BIOS image
  78busmem_base     - Base of the VGA bus memory
  79timer           - Timer used to emulate PC timer ports
  80timer0          - Latched value for timer 0
  81timer0Latched   - true if timer 0 value was just latched
  82timer2          - Current value for timer 2
  83emulateVGA      - true to emulate VGA I/O and memory accesses
  84****************************************************************************/
  85
  86typedef struct {
  87        BE_VGAInfo vgaInfo;
  88        ulong biosmem_base;
  89        ulong biosmem_limit;
  90        ulong busmem_base;
  91
  92        u32 timer0;
  93        int timer0Latched;
  94        u32 timer1;
  95        int timer1Latched;
  96        u32 timer2;
  97        int timer2Latched;
  98
  99        int emulateVGA;
 100        u8 emu61;
 101        u8 emu70;
 102        int flipFlop3C0;
 103        u32 configAddress;
 104        u8 emu3C0;
 105        u8 emu3C1[ATT_C];
 106        u8 emu3C2;
 107        u8 emu3C4;
 108        u8 emu3C5[SEQ_C];
 109        u8 emu3C6;
 110        uint emu3C7;
 111        uint emu3C8;
 112        u8 emu3C9[PAL_C];
 113        u8 emu3CE;
 114        u8 emu3CF[GRA_C];
 115        u8 emu3D4;
 116        u8 emu3D5[CRT_C];
 117        u8 emu3DA;
 118
 119} BE_sysEnv;
 120
 121#ifdef __KERNEL__
 122
 123/* Define some types when compiling for the Linux kernel that normally
 124 * come from the SciTech PM library.
 125 */
 126
 127/****************************************************************************
 128REMARKS:
 129Structure describing the 32-bit extended x86 CPU registers
 130
 131HEADER:
 132pmapi.h
 133
 134MEMBERS:
 135eax     - Value of the EAX register
 136ebx     - Value of the EBX register
 137ecx     - Value of the ECX register
 138edx     - Value of the EDX register
 139esi     - Value of the ESI register
 140edi     - Value of the EDI register
 141cflag   - Value of the carry flag
 142****************************************************************************/
 143typedef struct {
 144        u32 eax;
 145        u32 ebx;
 146        u32 ecx;
 147        u32 edx;
 148        u32 esi;
 149        u32 edi;
 150        u32 cflag;
 151} RMDWORDREGS;
 152
 153/****************************************************************************
 154REMARKS:
 155Structure describing the 16-bit x86 CPU registers
 156
 157HEADER:
 158pmapi.h
 159
 160MEMBERS:
 161ax      - Value of the AX register
 162bx      - Value of the BX register
 163cx      - Value of the CX register
 164dx      - Value of the DX register
 165si      - Value of the SI register
 166di      - Value of the DI register
 167cflag   - Value of the carry flag
 168****************************************************************************/
 169#ifdef __BIG_ENDIAN__
 170typedef struct {
 171        u16 ax_hi, ax;
 172        u16 bx_hi, bx;
 173        u16 cx_hi, cx;
 174        u16 dx_hi, dx;
 175        u16 si_hi, si;
 176        u16 di_hi, di;
 177        u16 cflag_hi, cflag;
 178} RMWORDREGS;
 179#else
 180typedef struct {
 181        u16 ax, ax_hi;
 182        u16 bx, bx_hi;
 183        u16 cx, cx_hi;
 184        u16 dx, dx_hi;
 185        u16 si, si_hi;
 186        u16 di, di_hi;
 187        u16 cflag, cflag_hi;
 188} RMWORDREGS;
 189#endif
 190
 191/****************************************************************************
 192REMARKS:
 193Structure describing the 8-bit x86 CPU registers
 194
 195HEADER:
 196pmapi.h
 197
 198MEMBERS:
 199al      - Value of the AL register
 200ah      - Value of the AH register
 201bl      - Value of the BL register
 202bh      - Value of the BH register
 203cl      - Value of the CL register
 204ch      - Value of the CH register
 205dl      - Value of the DL register
 206dh      - Value of the DH register
 207****************************************************************************/
 208#ifdef __BIG_ENDIAN__
 209typedef struct {
 210        u16 ax_hi;
 211        u8 ah, al;
 212        u16 bx_hi;
 213        u8 bh, bl;
 214        u16 cx_hi;
 215        u8 ch, cl;
 216        u16 dx_hi;
 217        u8 dh, dl;
 218} RMBYTEREGS;
 219#else
 220typedef struct {
 221        u8 al;
 222        u8 ah;
 223        u16 ax_hi;
 224        u8 bl;
 225        u8 bh;
 226        u16 bx_hi;
 227        u8 cl;
 228        u8 ch;
 229        u16 cx_hi;
 230        u8 dl;
 231        u8 dh;
 232        u16 dx_hi;
 233} RMBYTEREGS;
 234#endif
 235
 236/****************************************************************************
 237REMARKS:
 238Structure describing all the x86 CPU registers
 239
 240HEADER:
 241pmapi.h
 242
 243MEMBERS:
 244e   - Member to access registers as 32-bit values
 245x   - Member to access registers as 16-bit values
 246h   - Member to access registers as 8-bit values
 247****************************************************************************/
 248typedef union {
 249        RMDWORDREGS e;
 250        RMWORDREGS x;
 251        RMBYTEREGS h;
 252} RMREGS;
 253
 254/****************************************************************************
 255REMARKS:
 256Structure describing all the x86 segment registers
 257
 258HEADER:
 259pmapi.h
 260
 261MEMBERS:
 262es  - ES segment register
 263cs  - CS segment register
 264ss  - SS segment register
 265ds  - DS segment register
 266fs  - FS segment register
 267gs  - GS segment register
 268****************************************************************************/
 269typedef struct {
 270        u16 es;
 271        u16 cs;
 272        u16 ss;
 273        u16 ds;
 274        u16 fs;
 275        u16 gs;
 276} RMSREGS;
 277
 278#endif                          /* __KERNEL__ */
 279
 280#ifndef __KERNEL__
 281
 282/****************************************************************************
 283REMARKS:
 284Structure defining all the BIOS Emulator API functions as exported from
 285the Binary Portable DLL.
 286{secret}
 287****************************************************************************/
 288typedef struct {
 289        ulong dwSize;
 290         ibool(PMAPIP BE_init) (u32 debugFlags, int memSize, BE_VGAInfo * info);
 291        void (PMAPIP BE_setVGA) (BE_VGAInfo * info);
 292        void (PMAPIP BE_getVGA) (BE_VGAInfo * info);
 293        void *(PMAPIP BE_mapRealPointer) (uint r_seg, uint r_off);
 294        void *(PMAPIP BE_getVESABuf) (uint * len, uint * rseg, uint * roff);
 295        void (PMAPIP BE_callRealMode) (uint seg, uint off, RMREGS * regs,
 296                                       RMSREGS * sregs);
 297        int (PMAPIP BE_int86) (int intno, RMREGS * in, RMREGS * out);
 298        int (PMAPIP BE_int86x) (int intno, RMREGS * in, RMREGS * out,
 299                                RMSREGS * sregs);
 300        void *reserved1;
 301        void (PMAPIP BE_exit) (void);
 302} BE_exports;
 303
 304/****************************************************************************
 305REMARKS:
 306Function pointer type for the Binary Portable DLL initialisation entry point.
 307{secret}
 308****************************************************************************/
 309typedef BE_exports *(PMAPIP BE_initLibrary_t) (PM_imports * PMImp);
 310#endif
 311
 312#pragma pack()
 313
 314/*---------------------------- Global variables ---------------------------*/
 315
 316#ifdef  __cplusplus
 317extern "C" {                    /* Use "C" linkage when in C++ mode */
 318#endif
 319
 320/* {secret} Global BIOS emulator system environment */
 321        extern BE_sysEnv _BE_env;
 322
 323/*-------------------------- Function Prototypes --------------------------*/
 324
 325/* BIOS emulator library entry points */
 326        int X86API BE_init(u32 debugFlags, int memSize, BE_VGAInfo * info,
 327                           int shared);
 328        void X86API BE_setVGA(BE_VGAInfo * info);
 329        void X86API BE_getVGA(BE_VGAInfo * info);
 330        void X86API BE_setDebugFlags(u32 debugFlags);
 331        void *X86API BE_mapRealPointer(uint r_seg, uint r_off);
 332        void *X86API BE_getVESABuf(uint * len, uint * rseg, uint * roff);
 333        void X86API BE_callRealMode(uint seg, uint off, RMREGS * regs,
 334                                    RMSREGS * sregs);
 335        int X86API BE_int86(int intno, RMREGS * in, RMREGS * out);
 336        int X86API BE_int86x(int intno, RMREGS * in, RMREGS * out,
 337                             RMSREGS * sregs);
 338        void X86API BE_exit(void);
 339
 340#ifdef  __cplusplus
 341}                               /* End of "C" linkage for C++       */
 342#endif
 343#endif                          /* __BIOSEMU_H */
 344