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

📄 pearpc.c

📁 OpenBIOS是一个开源的BIOS实现
💻 C
字号:
/*  *   Creation Date: <2004/08/28 18:38:22 greg> *   Time-stamp: <2004/08/28 18:38:22 greg> *    *	<pearpc.c> *    *   Copyright (C) 2004, Greg Watson *    *   derived from mol.c * *   Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) *    *   This program is free software; you can redistribute it and/or *   modify it under the terms of the GNU General Public License *   version 2 *    */#include "openbios/config.h"#include "openbios/kernel.h"#include "openbios/nvram.h"#include "libc/vsprintf.h"#include "libc/string.h"#include "pearpc/pearpc.h"#include <stdarg.h>#define UART_BASE 0x3f8// FIXMEunsigned long virt_offset = 0;voidexit( int status ){	for (;;);}voidfatal_error( const char *err ){	printk("Fatal error: %s\n", err );	exit(0);}voidpanic( const char *err ){	printk("Panic: %s\n", err );	exit(0);	/* won't come here... this keeps the gcc happy */	for( ;; )		;}/************************************************************************//*	print using OSI interface					*//************************************************************************/static int do_indent;intprintk( const char *fmt, ... ){	char *p, buf[1024];	/* XXX: no buffer overflow protection... */	va_list args;	int i;	va_start(args, fmt);	i=vsprintf(buf,fmt,args);	va_end(args);	for( p=buf; *p; p++ ) {		if( *p == '\n' )			do_indent = 0;		if( do_indent++ == 1 ) {			putchar( '>' );			putchar( '>' );			putchar( ' ' );		}		putchar( *p );	}	return i;}/************************************************************************//*	TTY iface							*//************************************************************************/static int ttychar = -1;static inttty_avail( void ){	return 1;}static inttty_putchar( int c ){	if( tty_avail() ) {		while (!(inb(UART_BASE + 0x05) & 0x20))			;		outb(c, UART_BASE);		while (!(inb(UART_BASE + 0x05) & 0x40))			;	}	return c;}intavailchar( void ){	if( !tty_avail() )		return 0;		if( ttychar < 0 )		ttychar = inb(UART_BASE);	return (ttychar >= 0);}intgetchar( void ){	int ch;	if( !tty_avail() )		return 0;	if( ttychar < 0 )		return inb(UART_BASE);	ch = ttychar;	ttychar = -1;	return ch;}intputchar( int c ){	if (c == '\n')		tty_putchar('\r');	return tty_putchar(c);}/************************************************************************//*	briQ specific stuff						*//************************************************************************/#define IO_NVRAM_PA_START 0x80860000#define IO_NVRAM_PA_END 0x80880000static char *nvram=(char *)IO_NVRAM_PA_START;voiddump_nvram(void){  static char hexdigit[] = "0123456789abcdef";  int i;  for (i = 0; i < 16*4; i++)    {      printk ("%c", hexdigit[nvram[i<<4] >> 4]);      printk ("%c", hexdigit[nvram[i<<4] % 16]);      if (!((i + 1) % 16))        {          printk ("\n");        }      else        {          printk (" ");        }    }	}intarch_nvram_size( void ){	return (IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4;}voidarch_nvram_put( char *buf ){	int i;	for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)		nvram[i<<4]=buf[i];	// memcpy(nvram, buf, IO_NVRAM_PA_END-IO_NVRAM_PA_START);	printk("new nvram:\n");	dump_nvram();}voidarch_nvram_get( char *buf ){	int i;	for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)		buf[i]=nvram[i<<4];	//memcpy(buf, nvram, IO_NVRAM_PA_END-IO_NVRAM_PA_START);	printk("current nvram:\n");	dump_nvram();}

⌨️ 快捷键说明

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