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

📄 bios.c

📁 国产CPU-龙芯(loongson)BIOS源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
        case 0xB103:                    /* Find PCI class code */            M.x86.R_AH = DEVICE_NOT_FOUND;            if (M.x86.R_ECX == _BE_env.vgaInfo.pciInfo->pa.pa_class) {               M.x86.R_AH = SUCCESSFUL;               M.x86.R_BX = pciSlot;            }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB108:                    /* Read configuration byte */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_read_config_byte(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,&M.x86.R_CL);		printf("read_config_byte(0x%x)=0x%x\n",M.x86.R_DI, M.x86.R_CL);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB109:                    /* Read configuration word */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_read_config_word(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,&M.x86.R_CX);		printf("read_config_word(0x%x)=0x%x\n",M.x86.R_DI, M.x86.R_CX);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB10A:                    /* Read configuration dword */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_read_config_dword(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,&M.x86.R_ECX);		printf("read_config_dword(0x%x)=0x%x\n",M.x86.R_DI, M.x86.R_ECX);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB10B:                    /* Write configuration byte */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_write_config_byte(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,M.x86.R_CL);		printf("write_config_byte(0x%x)=0x%x\n",M.x86.R_DI, M.x86.R_CL);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB10C:                    /* Write configuration word */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_write_config_word(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,M.x86.R_CX);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        case 0xB10D:                    /* Write configuration dword */            M.x86.R_AH = BAD_REGISTER_NUMBER;            if (M.x86.R_BX == pciSlot) {                M.x86.R_AH = SUCCESSFUL;		pci_write_config_dword(_BE_env.vgaInfo.pciInfo,M.x86.R_DI,M.x86.R_ECX);                }            CONDITIONAL_SET_FLAG((M.x86.R_AH != SUCCESSFUL), F_CF);            break;        default:            printf("biosEmu/bios.int1a: unknown function AX=%#04x\n", M.x86.R_AX);        }}/* inte6: handle initialization */static void  inte6(int unused){	printf("int E6: not implemented\n");}#if 1static void  int15(int intno){    switch (M.x86.R_AX) {	case 0x7f01:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=0x0;		break;	case 0x7f03:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_BX=0x0;		break;	case 0x7f05:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		break;	case 0x7f06:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=0x0;		break;	case 0x7f07:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		pci_read_config_word(_BE_env.vgaInfo.pciInfo,0x0,&M.x86.R_BX);		pci_read_config_word(_BE_env.vgaInfo.pciInfo,0x2,&M.x86.R_CX);		break;	case 0x7f08:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=M.x86.R_BL & 0xf0;		break;	case 0x7f09:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=0x0;		break;	case 0x7f0a:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=0x0;		break;	case 0x7f14:		printf("int 15:AX=%x\n",M.x86.R_AX);		M.x86.R_AX=0x007f;		M.x86.R_BL=0x1;		break;         default:		printf("int 15:AX=%x is not emulation\n",M.x86.R_AX);    }		}#endif/****************************************************************************REMARKS:This function initialises the BIOS emulation functions for the specificPCI display device. We insulate the real mode BIOS from any other deviceson the bus, so that it will work correctly thinking that it is the onlydevice present on the bus (ie: avoiding any adapters present in from ofthe device we are trying to control).****************************************************************************/void _BE_bios_init(    u32 *intrTab){    int                 i;    X86EMU_intrFuncs    bios_intr_tab[256];    for (i = 0; i < 256; ++i) {        intrTab[i] = BIOS_SEG << 16;        bios_intr_tab[i] = undefined_intr;    }    bios_intr_tab[0x10] = int10;    bios_intr_tab[0x1A] = int1A;    bios_intr_tab[0x42] = int42;    bios_intr_tab[0x6d] = int6d;    bios_intr_tab[0xe6] = inte6;    bios_intr_tab[0x15] = int15;	    X86EMU_setupIntrFuncs(bios_intr_tab);}/* fill into emulator memory values that a vga bios might expect */intfillin_key_datas(void){    /*     * This table is normally located at 0xF000:0xF0A4.  However, int 0x42,     * function 0 (Mode Set) expects it (or a copy) somewhere in the bottom     * 64kB.  Note that because this data doesn't survive POST, int 0x42 should     * only be used during EGA/VGA BIOS initialisation.     */    const char VideoParms[] = {	/* Timing for modes 0x00 & 0x01 */	0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c,	0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,	/* Timing for modes 0x02 & 0x03 */	0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c,	0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,	/* Timing for modes 0x04, 0x05 & 0x06 */	0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70,	0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,	/* Timing for mode 0x07 */	0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19,	0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,	/* Display page lengths in little endian order */	0x00, 0x08, /* Modes 0x00 and 0x01 */	0x00, 0x10, /* Modes 0x02 and 0x03 */	0x00, 0x40, /* Modes 0x04 and 0x05 */	0x00, 0x40, /* Modes 0x06 and 0x07 */	/* Number of columns for each mode */	40, 40, 80, 80, 40, 40, 80, 80,	/* CGA Mode register value for each mode */	0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29,	/* Padding */	0x00, 0x00, 0x00, 0x00	};    int i;    unsigned char *sys_base,*mem_base;    mem_base = (char *)M.mem_base;    sys_base = (char *)_BE_env.sysmem_base;    for (i = 0; i < sizeof(VideoParms); i++)	    mem_base[i + 0x1000 - sizeof(VideoParms)] = VideoParms[i];    BE_wrw( 0x1d<<2 , 0x1000 - sizeof(VideoParms)); /* ?? */    BE_wrw((0x1d<<2) + 2, 0);    /* font tables default location (int 1F) */    BE_wrw(0x1f<<2,0xfa6e);    /* int 11 default location (Get Equipment Configuration) */    BE_wrw( 0x11 << 2, 0xf84d);    /* int 12 default location (Get Conventional Memory Size) */    BE_wrw( 0x12 << 2, 0xf841);    /* int 15 default location (I/O System Extensions) */    BE_wrw( 0x15 << 2, 0xf859);    /* int 1A default location (RTC, PCI and others) */    BE_wrw( 0x1a << 2, 0xff6e);    /* int 05 default location (Bound Exceeded) */    BE_wrw( 0x05 << 2, 0xff54);    /* int 08 default location (Double Fault) */    BE_wrw( 0x08 << 2, 0xfea5);    /* int 13 default location (Disk) */    BE_wrw( 0x13 << 2, 0xec59);    /* int 0E default location (Page Fault) */    BE_wrw( 0x0e << 2, 0xef57);    /* int 17 default location (Parallel Port) */    BE_wrw( 0x17 << 2, 0xefd2);    /* fdd table default location (int 1e) */    BE_wrw( 0x1e << 2, 0xefc7);    /* Set Equipment flag to VGA?? */    i = BE_rdb(0x0410) & 0xCF;     BE_wrb(0x0410, 0);    /* XXX Perhaps setup more of the BDA here.  See also int42(0x00). */    /* set bios date */    strcpy(sys_base + 0x0FFF5, "06/11/99");    /* set up eisa ident string */    strcpy(sys_base + 0x0FFD9, "PCI_ISA");    /* write system model id for IBM-AT */    *((unsigned char *)(sys_base + 0x0FFFE)) = 0xfc;    /*printf("M.membase=%lx,BE_env.sysmem_base=%lx,sys_base=%p,mem_base=%p\n",M.mem_base,_BE_env.sysmem_base,sys_base,mem_base);*/    printf("%c%c\n",BE_rdb(0xFFFD9),BE_rdb(0xFFFDA));    return 1;}/* * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make * an attempt to detect a legacy ISA card. If they find one they might * act very strange: for example they might configure the card as a * monochrome card. This might cause some drivers to choke. * To avoid this we attempt legacy VGA by writing to all know VGA * disable registers before we call the BIOS initialization and * restore the original values afterwards. In beween we hold our * breath. To get to a (possibly exising) ISA card need to disable * our current PCI card. *//* * This is just for booting: we just want to catch pure * legacy vga therefore we don't worry about mmio etc. * This stuff should really go into vgaHW.c. However then * the driver would have to load the vga-module prior to * doing int10. */voidLockLegacyVGA(void){#if 0    _BE_env.vgaInfo.save_msr = linux_inb(0x3CC);    _BE_env.vgaInfo.save_vse = linux_inb(0x3C3);    _BE_env.vgaInfo.save_46e8 =linux_inb(0x46e8);    _BE_env.vgaInfo.save_pos102 = linux_inb(0x102);    linux_outb(~0x03 & _BE_env.vgaInfo.save_msr,0x3c2);    linux_outb(~0x01 & _BE_env.vgaInfo.save_vse,0x3c3);    linux_outb(~0x08 & _BE_env.vgaInfo.save_46e8,0x46e8);    linux_outb(~0x01 & _BE_env.vgaInfo.save_pos102,0x102);#endif}voidUnlockLegacyVGA(void){#if 0    linux_outb(_BE_env.vgaInfo.save_pos102,0x102);    linux_outb(_BE_env.vgaInfo.save_46e8,0x46e8);    linux_outb(_BE_env.vgaInfo.save_vse,0x3c3);    linux_outb(_BE_env.vgaInfo.save_msr,0x3c2);#endif}

⌨️ 快捷键说明

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