⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rombios.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 5 页
字号:
    and eax, #0x0000FFFF    shl ebx, #16    add eax, ebx    shr ebx, #16    SEG SS      cmp eax, dword ptr [di]    ret    ;; sub function  lsubl:  lsubul:    SEG SS    sub ax,[di]    SEG SS    sbb bx,2[di]    ret    ;; mul function  lmull:  lmulul:    and eax, #0x0000FFFF    shl ebx, #16    add eax, ebx    SEG SS    mul eax, dword ptr [di]    mov ebx, eax    shr ebx, #16    ret    ;; dec function  ldecl:  ldecul:    SEG SS    dec dword ptr [bx]    ret    ;; or function  lorl:  lorul:    SEG SS    or  ax,[di]    SEG SS    or  bx,2[di]    ret    ;; inc function  lincl:  lincul:    SEG SS    inc dword ptr [bx]    ret    ;; tst function  ltstl:  ltstul:    and eax, #0x0000FFFF    shl ebx, #16    add eax, ebx    shr ebx, #16    test eax, eax    ret    ;; sr function  lsrul:    mov  cx,di    jcxz lsr_exit    and  eax, #0x0000FFFF    shl  ebx, #16    add  eax, ebx  lsr_loop:    shr  eax, #1    loop lsr_loop    mov  ebx, eax    shr  ebx, #16  lsr_exit:    ret    ;; sl function  lsll:  lslul:    mov  cx,di    jcxz lsl_exit    and  eax, #0x0000FFFF    shl  ebx, #16    add  eax, ebx  lsl_loop:     shl  eax, #1    loop lsl_loop    mov  ebx, eax    shr  ebx, #16  lsl_exit:    ret    idiv_:    cwd    idiv bx    ret  idiv_u:    xor dx,dx    div bx    ret  ldivul:    and  eax, #0x0000FFFF    shl  ebx, #16    add  eax, ebx    xor  edx, edx    SEG SS    mov  bx,  2[di]    shl  ebx, #16    SEG SS    mov  bx,  [di]    div  ebx    mov  ebx, eax    shr  ebx, #16    ret  ASM_END// for access to RAM area which is used by interrupt vectors// and BIOS Data Areatypedef struct {  unsigned char filler1[0x400];  unsigned char filler2[0x6c];  Bit16u ticks_low;  Bit16u ticks_high;  Bit8u  midnight_flag;  } bios_data_t;#define BiosData ((bios_data_t  *) 0)#if BX_USE_ATADRV  typedef struct {    Bit16u heads;      // # heads    Bit16u cylinders;  // # cylinders    Bit16u spt;        // # sectors / track    } chs_t;  // DPTE definition  typedef struct {    Bit16u iobase1;    Bit16u iobase2;    Bit8u  prefix;    Bit8u  unused;    Bit8u  irq;    Bit8u  blkcount;    Bit8u  dma;    Bit8u  pio;    Bit16u options;    Bit16u reserved;    Bit8u  revision;    Bit8u  checksum;    } dpte_t;   typedef struct {    Bit8u  iface;        // ISA or PCI    Bit16u iobase1;      // IO Base 1    Bit16u iobase2;      // IO Base 2    Bit8u  irq;          // IRQ    } ata_channel_t;  typedef struct {    Bit8u  type;         // Detected type of ata (ata/atapi/none/unknown)    Bit8u  device;       // Detected type of attached devices (hd/cd/none)    Bit8u  removable;    // Removable device flag    Bit8u  lock;         // Locks for removable devices    // Bit8u  lba_capable;  // LBA capable flag - always yes for bochs devices    Bit8u  mode;         // transfert mode : PIO 16/32 bits - IRQ - ISADMA - PCIDMA    Bit16u blksize;      // block size    Bit8u  translation;  // type of translation    chs_t  lchs;         // Logical CHS    chs_t  pchs;         // Physical CHS    Bit32u sectors;      // Total sectors count    } ata_device_t;  typedef struct {    // ATA channels info    ata_channel_t channels[BX_MAX_ATA_INTERFACES];    // ATA devices info    ata_device_t  devices[BX_MAX_ATA_DEVICES];    //    // map between (bios hd id - 0x80) and ata channels    Bit8u  hdcount, hdidmap[BX_MAX_ATA_DEVICES];                    // map between (bios cd id - 0xE0) and ata channels    Bit8u  cdcount, cdidmap[BX_MAX_ATA_DEVICES];                    // Buffer for DPTE table    dpte_t dpte;    // Count of transferred sectors and bytes    Bit16u trsfsectors;    Bit32u trsfbytes;    } ata_t;  #if BX_ELTORITO_BOOT  // ElTorito Device Emulation data   typedef struct {    Bit8u  active;    Bit8u  media;    Bit8u  emulated_drive;    Bit8u  controller_index;    Bit16u device_spec;    Bit32u ilba;    Bit16u buffer_segment;    Bit16u load_segment;    Bit16u sector_count;        // Virtual device    chs_t  vdevice;    } cdemu_t;#endif // BX_ELTORITO_BOOT  #include "32bitgateway.h"  // for access to EBDA area  //     The EBDA structure should conform to   //     http://www.cybertrails.com/~fys/rombios.htm document  //     I made the ata and cdemu structs begin at 0x121 in the EBDA seg  // EBDA must be at most 768 bytes; it lives at 0x9fc00, and the boot   // device tables are at 0x9ff00 -- 0x9ffff  typedef struct {    unsigned char ebda_size;    unsigned char cmos_shutdown_status;    unsigned char filler1[0x3B];    // FDPT - Can be splitted in data members if needed    unsigned char fdpt0[0x10];    unsigned char fdpt1[0x10];    unsigned char filler2[0xC4];    // ATA Driver data    ata_t   ata;#if BX_ELTORITO_BOOT    // El Torito Emulation data    cdemu_t cdemu;#endif // BX_ELTORITO_BOOT    upcall_t upcall;    } ebda_data_t;    #define EBDA_CMOS_SHUTDOWN_STATUS_OFFSET 1  #define EbdaData ((ebda_data_t *) 0)  // for access to the int13ext structure  typedef struct {    Bit8u  size;    Bit8u  reserved;    Bit16u count;    Bit16u offset;    Bit16u segment;    Bit32u lba1;    Bit32u lba2;    } int13ext_t;   #define Int13Ext ((int13ext_t *) 0)  // Disk Physical Table definition  typedef struct {    Bit16u  size;    Bit16u  infos;    Bit32u  cylinders;    Bit32u  heads;    Bit32u  spt;    Bit32u  sector_count1;    Bit32u  sector_count2;    Bit16u  blksize;    Bit16u  dpte_offset;    Bit16u  dpte_segment;    Bit16u  key;    Bit8u   dpi_length;    Bit8u   reserved1;    Bit16u  reserved2;    Bit8u   host_bus[4];    Bit8u   iface_type[8];    Bit8u   iface_path[8];    Bit8u   device_path[8];    Bit8u   reserved3;    Bit8u   checksum;    } dpt_t;   #define Int13DPT ((dpt_t *) 0)#endif // BX_USE_ATADRVtypedef struct {  union {    struct {      Bit16u di, si, bp, sp;      Bit16u bx, dx, cx, ax;      } r16;    struct {      Bit16u filler[4];      Bit8u  bl, bh, dl, dh, cl, ch, al, ah;      } r8;    } u;  } pusha_regs_t;typedef struct { union {  struct {    Bit32u edi, esi, ebp, esp;    Bit32u ebx, edx, ecx, eax;    } r32;  struct {    Bit16u di, filler1, si, filler2, bp, filler3, sp, filler4;    Bit16u bx, filler5, dx, filler6, cx, filler7, ax, filler8;    } r16;  struct {    Bit32u filler[4];    Bit8u  bl, bh;     Bit16u filler1;    Bit8u  dl, dh;     Bit16u filler2;    Bit8u  cl, ch;    Bit16u filler3;    Bit8u  al, ah;    Bit16u filler4;    } r8;  } u;} pushad_regs_t;typedef struct {  union {    struct {      Bit16u flags;      } r16;    struct {      Bit8u  flagsl;      Bit8u  flagsh;      } r8;    } u;  } flags_t;#define SetCF(x)   x.u.r8.flagsl |= 0x01#define SetZF(x)   x.u.r8.flagsl |= 0x40#define ClearCF(x) x.u.r8.flagsl &= 0xfe#define ClearZF(x) x.u.r8.flagsl &= 0xbf#define GetCF(x)   (x.u.r8.flagsl & 0x01)typedef struct {  Bit16u ip;  Bit16u cs;  flags_t flags;  } iret_addr_t;static Bit8u          inb();static Bit8u          inb_cmos();static void           outb();static void           outb_cmos();static Bit16u         inw();static void           outw();static void           init_rtc();static bx_bool        rtc_updating();static Bit8u          read_byte();static Bit16u         read_word();static void           write_byte();static void           write_word();static void           bios_printf();static void           copy_e820_table();static Bit8u          inhibit_mouse_int_and_events();static void           enable_mouse_int_and_events();static Bit8u          send_to_mouse_ctrl();static Bit8u          get_mouse_data();static void           set_kbd_command_byte();static void           int09_function();static void           int13_harddisk();static void           int13_cdrom();static void           int13_cdemu();static void           int13_eltorito();static void           int13_diskette_function();static void           int14_function();static void           int15_function();static void           int16_function();static void           int17_function();static void           int18_function();static void           int1a_function();static void           int70_function();static void           int74_function();static Bit16u         get_CS();//static Bit16u         get_DS();//static void           set_DS();static Bit16u         get_SS();static unsigned int   enqueue_key();static unsigned int   dequeue_key();static void           get_hd_geometry();static void           set_diskette_ret_status();static void           set_diskette_current_cyl();static void           determine_floppy_media();static bx_bool        floppy_drive_exists();static bx_bool        floppy_drive_recal();static bx_bool        floppy_media_known();static bx_bool        floppy_media_sense();static bx_bool        set_enable_a20();static void           debugger_on();static void           debugger_off();static void           keyboard_init();static void           keyboard_panic();static void           shutdown_status_panic();static void           nmi_handler_msg();static void           print_bios_banner();static void           print_boot_device();static void           print_boot_failure();static void           print_cdromboot_failure();# if BX_USE_ATADRV// ATA / ATAPI drivervoid   ata_init();void   ata_detect();void   ata_reset();Bit16u ata_cmd_non_data();Bit16u ata_cmd_data_in();Bit16u ata_cmd_data_out();Bit16u ata_cmd_packet();Bit16u atapi_get_sense();Bit16u atapi_is_ready();Bit16u atapi_is_cdrom();#endif // BX_USE_ATADRV#if BX_ELTORITO_BOOTvoid   cdemu_init();Bit8u  cdemu_isactive();Bit8u  cdemu_emulated_drive();Bit16u cdrom_boot();#endif // BX_ELTORITO_BOOTstatic char bios_cvs_version_string[] = "$Revision: 1.138 $";static char bios_date_string[] = "$Date: 2005/05/07 15:55:26 $";static char CVSID[] = "$Id: rombios.c,v 1.138 2005/05/07 15:55:26 vruppert Exp $";/* Offset to skip the CVS $Id: prefix */ #define bios_version_string  (CVSID + 4)#define BIOS_PRINTF_HALT     1#define BIOS_PRINTF_SCREEN   2#define BIOS_PRINTF_INFO     4#define BIOS_PRINTF_DEBUG    8#define BIOS_PRINTF_ALL      (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO)#define BIOS_PRINTF_DEBHALT  (BIOS_PRINTF_SCREEN | BIOS_PRINTF_INFO | BIOS_PRINTF_HALT)#define printf(format, p...)  bios_printf(BIOS_PRINTF_SCREEN, format, ##p)// Defines the output macros. // BX_DEBUG goes to INFO port until we can easily choose debug info on a // per-device basis. Debug info are sent only in debug mode#if DEBUG_ROMBIOS#  define BX_DEBUG(format, p...)  bios_printf(BIOS_PRINTF_INFO, format, ##p)    #else#  define BX_DEBUG(format, p...) #endif#define BX_INFO(format, p...)   bios_printf(BIOS_PRINTF_INFO, format, ##p)#define BX_PANIC(format, p...)  bios_printf(BIOS_PRINTF_DEBHALT, format, ##p)#if DEBUG_ATA#  define BX_DEBUG_ATA(a...) BX_DEBUG(a)#else#  define BX_DEBUG_ATA(a...)#endif#if DEBUG_INT13_HD#  define BX_DEBUG_INT13_HD(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT13_HD(a...)#endif#if DEBUG_INT13_CD#  define BX_DEBUG_INT13_CD(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT13_CD(a...)#endif#if DEBUG_INT13_ET#  define BX_DEBUG_INT13_ET(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT13_ET(a...)#endif#if DEBUG_INT13_FL#  define BX_DEBUG_INT13_FL(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT13_FL(a...)#endif#if DEBUG_INT15#  define BX_DEBUG_INT15(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT15(a...)#endif#if DEBUG_INT16#  define BX_DEBUG_INT16(a...) BX_DEBUG(a)#else#  define BX_DEBUG_INT16(a...)#endif#if DEBUG_INT1A#  define BX_DEBUG_INT1A(a...) BX_DEBUG(a)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -