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

📄 bios.c

📁 国产CPU-龙芯(loongson)BIOS源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************                        BIOS emulator and interface*                      to Realmode X86 Emulator Library**               Copyright (C) 1996-1999 SciTech Software, Inc.**  ========================================================================**  Permission to use, copy, modify, distribute, and sell this software and*  its documentation for any purpose is hereby granted without fee,*  provided that the above copyright notice appear in all copies and that*  both that copyright notice and this permission notice appear in*  supporting documentation, and that the name of the authors not be used*  in advertising or publicity pertaining to distribution of the software*  without specific, written prior permission.  The authors makes no*  representations about the suitability of this software for any purpose.*  It is provided "as is" without express or implied warranty.**  THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,*  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO*  EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR*  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF*  USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR*  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR*  PERFORMANCE OF THIS SOFTWARE.**  ========================================================================** Language:     ANSI C* Environment:  Any* Developer:    Kendall Bennett** Description:  Module implementing the BIOS specific functions.*****************************************************************************//* BE CAREFUL: outb here is using linux style outb(value,addr) * while pmon&xfree86 are different */#include <stdio.h>#include <dev/pci/pcivar.h>#include <linux/types.h>#include <linux/pci.h>#include <linux/io.h>#include "biosemui.h"/****************************************************************************PARAMETERS:intno   - Interrupt number being servicedREMARKS:Handler for undefined interrupts.****************************************************************************/static void  undefined_intr(    int intno){    if (BE_rdw(intno * 4 + 2) == BIOS_SEG)        printf("biosEmu: undefined interrupt %xh called!\n",intno);    else        X86EMU_prepareForInt(intno);}/****************************************************************************PARAMETERS:intno   - Interrupt number being servicedREMARKS:This function handles the default system BIOS Int 10h (the default is storedin the Int 42h vector by the system BIOS at bootup). We only need to handlea small number of special functions used by the BIOS during POST time.****************************************************************************/static void  int42(    int intno){    switch (M.x86.R_AH) {    case 0x00:	/* Set Video Mode                                     */	/* Enter:  AL = video mode number                     */	/* Leave:  Nothing                                    */	/* Implemented (except for clearing the screen)       */	{                                         /* Localise */	    int i;	    u16 ioport, int1d, regvals, tmp;	    u8 mode, cgamode, cgacolour;	    /*	     * Ignore all mode numbers but 0x00-0x13.  Some systems also ignore	     * 0x0B and 0x0C, but don't do that here.	     */	    if (M.x86.R_AL > 0x13)		break;	    /*	     * You didn't think that was really the mode set, did you?  There	     * are only so many slots in the video parameter table...	     */	    mode = M.x86.R_AL;	    ioport = 0x03D4;	    switch (BE_rdb( 0x0410) & 0x30) {	    case 0x30:                  /* MDA */		mode = 0x07;            /* Force mode to 0x07 */		ioport = 0x03B4;		break;	    case 0x10:                  /* CGA 40x25 */		if (mode >= 0x07)		    mode = 0x01;		break;	    case 0x20:                  /* CGA 80x25 (MCGA?) */		if (mode >= 0x07)		    mode = 0x03;		break;	    case 0x00:                  /* EGA/VGA */		if (mode >= 0x07)       /* Don't try MDA timings */		    mode = 0x01;        /* !?!?! */		break;	    }	    /* Locate data in video parameter table */	    int1d = BE_rdw( 0x1d << 2);	    regvals = ((mode >> 1) << 4) + int1d;	    cgacolour = 0x30;	    if (mode == 0x06) {		regvals -= 0x10;		cgacolour = 0x3F;	    }	    /** Update BIOS Data Area **/	    /* Video mode */	    BE_wrb( 0x0449, mode);	    /* Columns */	    tmp = BE_rdb( mode + int1d + 0x48);	    BE_wrw( 0x044A, tmp);	    /* Page length */	    tmp = BE_rdw( (mode & 0x06) + int1d + 0x40);	    BE_wrw( 0x044C, tmp);	    /* Start Address */	    BE_wrw( 0x044E, 0);	    /* Cursor positions, one for each display page */	    for (i = 0x0450; i < 0x0460; i += 2)		BE_wrw( i, 0);	    /* Cursor start & end scanlines */	    tmp = BE_rdb( regvals + 0x0B);	    BE_wrb( 0x0460, tmp);	    tmp = BE_rdb( regvals + 0x0A);	    BE_wrb( 0x0461, tmp);	    /* Current display page number */	    BE_wrb( 0x0462, 0);	    /* CRTC I/O address */	    BE_wrw( 0x0463, ioport);	    /* CGA Mode register value */	    cgamode = BE_rdb( mode + int1d + 0x50);	    BE_wrb( 0x0465, cgamode);	    /* CGA Colour register value */	    BE_wrb( 0x0466, cgacolour);	    /* Rows */	    BE_wrb( 0x0484, (25 - 1));	    /* Programme the mode */	    linux_outb(cgamode & 0x37, ioport + 4);   /* Turn off screen */	    for (i = 0; i < 0x10; i++) {		tmp = BE_rdb( regvals + i);		linux_outb(i, ioport);		linux_outb(tmp, ioport + 1);	    }	    linux_outb(cgacolour, ioport + 5);        /* Select colour mode */	    linux_outb(cgamode, ioport + 4);          /* Turn on screen */	}	break;    case 0x01:	/* Set Cursor Type                                    */	/* Enter:  CH = starting line for cursor              */	/*         CL = ending line for cursor                */	/* Leave:  Nothing                                    */	/* Implemented                                        */	{                                         /* Localise */	    u16 ioport = BE_rdw( 0x0463);	    BE_wrb( 0x0460, M.x86.R_CL);	    BE_wrb( 0x0461, M.x86.R_CH);	    linux_outb(0x0A, ioport);	    linux_outb(M.x86.R_CH, ioport + 1);	    linux_outb(0x0B, ioport);	    linux_outb(M.x86.R_CL, ioport + 1);	}	break;    case 0x02:	/* Set Cursor Position                                */	/* Enter:  BH = display page number                   */	/*         DH = row                                   */	/*         DL = column                                */	/* Leave:  Nothing                                    */	/* Implemented                                        */	{                                         /* Localise */	    u16 offset, ioport;	    BE_wrb( (M.x86.R_BH << 1) + 0x0450, M.x86.R_DL);	    BE_wrb( (M.x86.R_BH << 1) + 0x0451, M.x86.R_DH);	    if (M.x86.R_BH != BE_rdb( 0x0462))		break;	    offset = (M.x86.R_DH * BE_rdw( 0x044A)) + M.x86.R_DL;	    offset += BE_rdw( 0x044E) << 1;	    ioport = BE_rdw( 0x0463);	    linux_outb(0x0E, ioport);	    linux_outb(offset >> 8, ioport + 1);	    linux_outb(0x0F, ioport);	    linux_outb(offset&0xFF,ioport + 1);	}	break;    case 0x03:	/* Get Cursor Position                                */	/* Enter:  BH = display page number                   */	/* Leave:  CH = starting line for cursor              */	/*         CL = ending line for cursor                */	/*         DH = row                                   */	/*         DL = column                                */	/* Implemented                                        */	{                                         /* Localise */	    M.x86.R_CL = BE_rdb( 0x0460);	    M.x86.R_CH = BE_rdb( 0x0461);	    M.x86.R_DL = BE_rdb( (M.x86.R_BH << 1) + 0x0450);	    M.x86.R_DH = BE_rdb( (M.x86.R_BH << 1) + 0x0451);	}	break;    case 0x04:	/* Get Light Pen Position                             */	/* Enter:  Nothing                                    */	/* Leave:  AH = 0x01 (down/triggered) or 0x00 (not)   */	/*         BX = pixel column                          */	/*         CX = pixel row                             */	/*         DH = character row                         */	/*         DL = character column                      */	/* Not Implemented                                    */	{                                         /* Localise */	    printf("Not implemented: Get Light Pen Position\n");	    M.x86.R_AH = M.x86.R_BX = M.x86.R_CX = M.x86.R_DX = 0;	}	break;    case 0x05:	/* Set Display Page                                   */	/* Enter:  AL = display page number                   */	/* Leave:  Nothing                                    */	/* Implemented                                        */	{                                         /* Localise */	    u16 start, ioport = BE_rdw( 0x0463);	    u8 x, y;	    /* Calculate new start address */	    BE_wrb( 0x0462, M.x86.R_AL);	    start = M.x86.R_AL * BE_rdw( 0x044C);	    BE_wrw( 0x044E, start);	    start <<= 1;	    /* Update start address */	    linux_outb(0x0C, ioport);	    linux_outb(start>>8,ioport + 1);	    linux_outb(0x0D, ioport);	    linux_outb(start&0xFF,ioport + 1);	    /* Switch cursor position */	    y = BE_rdb( (M.x86.R_AL << 1) + 0x0450);	    x = BE_rdb( (M.x86.R_AL << 1) + 0x0451);	    start += (y * BE_rdw( 0x044A)) + x;	    /* Update cursor position */	    linux_outb(0x0E, ioport);	    linux_outb(start >> 8,ioport + 1); 	    linux_outb(0x0F, ioport); 

⌨️ 快捷键说明

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