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

📄 pm.c

📁 AT91RM9200-U-Boot at91rm9200u-boot移植源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************                   SciTech OS Portability Manager Library**  ========================================================================**    The contents of this file are subject to the SciTech MGL Public*    License Version 1.0 (the "License"); you may not use this file*    except in compliance with the License. You may obtain a copy of*    the License at http://www.scitechsoft.com/mgl-license.txt**    Software distributed under the License is distributed on an*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*    implied. See the License for the specific language governing*    rights and limitations under the License.**    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.**    The Initial Developer of the Original Code is SciTech Software, Inc.*    All Rights Reserved.**  ========================================================================** Language:     ANSI C* Environment:  BeOS** Description:  Implementation for the OS Portability Manager Library, which*               contains functions to implement OS specific services in a*               generic, cross platform API. Porting the OS Portability*               Manager library is the first step to porting any SciTech*               products to a new platform.*****************************************************************************/#include "pmapi.h"#include "drvlib/os/os.h"#include <stdio.h>#include <stdlib.h>#include <string.h>// TODO: Include any BeOS specific headers here!/*--------------------------- Global variables ----------------------------*/static void (PMAPIP fatalErrorCleanup)(void) = NULL;/*----------------------------- Implementation ----------------------------*/void PMAPI PM_init(void){    // TODO: Do any initialisation in here. This includes getting IOPL    //       access for the process calling PM_init. This will get called    //       more than once.    // TODO: If you support the supplied MTRR register stuff (you need to    //       be at ring 0 for this!), you should initialise it in here./* MTRR_init(); */}long PMAPI PM_getOSType(void){ return _OS_BEOS; }int PMAPI PM_getModeType(void){ return PM_386; }void PMAPI PM_backslash(char *s){    uint pos = strlen(s);    if (s[pos-1] != '/') {        s[pos] = '/';        s[pos+1] = '\0';        }}void PMAPI PM_setFatalErrorCleanup(    void (PMAPIP cleanup)(void)){    fatalErrorCleanup = cleanup;}void PMAPI PM_fatalError(const char *msg){    // TODO: If you are running in a GUI environment without a console,    //       this needs to be changed to bring up a fatal error message    //       box and terminate the program.    if (fatalErrorCleanup)        fatalErrorCleanup();    fprintf(stderr,"%s\n", msg);    exit(1);}void * PMAPI PM_getVESABuf(uint *len,uint *rseg,uint *roff){    // No BIOS access for the BeOS    return NULL;}int PMAPI PM_kbhit(void){    // TODO: This function checks if a key is available to be read. This    //       should be implemented, but is mostly used by the test programs    //       these days.    return true;}int PMAPI PM_getch(void){    // TODO: This returns the ASCII code of the key pressed. This    //       should be implemented, but is mostly used by the test programs    //       these days.    return 0xD;}int PMAPI PM_openConsole(void){    // TODO: Opens up a fullscreen console for graphics output. If your    //       console does not have graphics/text modes, this can be left    //       empty. The main purpose of this is to disable console switching    //       when in graphics modes if you can switch away from fullscreen    //       consoles (if you want to allow switching, this can be done    //       elsewhere with a full save/restore state of the graphics mode).    return 0;}int PMAPI PM_getConsoleStateSize(void){    // TODO: Returns the size of the console state buffer used to save the    //       state of the console before going into graphics mode. This is    //       used to restore the console back to normal when we are done.    return 1;}void PMAPI PM_saveConsoleState(void *stateBuf,int console_id){    // TODO: Saves the state of the console into the state buffer. This is    //       used to restore the console back to normal when we are done.    //       We will always restore 80x25 text mode after being in graphics    //       mode, so if restoring text mode is all you need to do this can    //       be left empty.}void PMAPI PM_restoreConsoleState(const void *stateBuf,int console_id){    // TODO: Restore the state of the console from the state buffer. This is    //       used to restore the console back to normal when we are done.    //       We will always restore 80x25 text mode after being in graphics    //       mode, so if restoring text mode is all you need to do this can    //       be left empty.}void PMAPI PM_closeConsole(int console_id){    // TODO: Close the console when we are done, going back to text mode.}void PM_setOSCursorLocation(int x,int y){    // TODO: Set the OS console cursor location to the new value. This is    //       generally used for new OS ports (used mostly for DOS).}void PM_setOSScreenWidth(int width,int height){    // TODO: Set the OS console screen width. This is generally unused for    //       new OS ports.}ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler ih, int frequency){    // TODO: Install a real time clock interrupt handler. Normally this    //       will not be supported from most OS'es in user land, so an    //       alternative mechanism is needed to enable software stereo.    //       Hence leave this unimplemented unless you have a high priority    //       mechanism to call the 32-bit callback when the real time clock    //       interrupt fires.    return false;}void PMAPI PM_setRealTimeClockFrequency(int frequency){    // TODO: Set the real time clock interrupt frequency. Used for stereo    //       LC shutter glasses when doing software stereo. Usually sets    //       the frequency to around 2048 Hz.}void PMAPI PM_restoreRealTimeClockHandler(void){    // TODO: Restores the real time clock handler.}char * PMAPI PM_getCurrentPath(    char *path,    int maxLen){    return getcwd(path,maxLen);}char PMAPI PM_getBootDrive(void){ return '/'; }const char * PMAPI PM_getVBEAFPath(void){ return PM_getNucleusConfigPath(); }const char * PMAPI PM_getNucleusPath(void){    char *env = getenv("NUCLEUS_PATH");    return env ? env : "/usr/lib/nucleus";}const char * PMAPI PM_getNucleusConfigPath(void){    static char path[256];    strcpy(path,PM_getNucleusPath());    PM_backslash(path);    strcat(path,"config");    return path;}const char * PMAPI PM_getUniqueID(void){    // TODO: Return a unique ID for the machine. If a unique ID is not    //       available, return the machine name.    static char buf[128];    gethostname(buf, 128);    return buf;}const char * PMAPI PM_getMachineName(void){    // TODO: Return the network machine name for the machine.    static char buf[128];    gethostname(buf, 128);    return buf;}void * PMAPI PM_getBIOSPointer(void){    // No BIOS access on the BeOS    return NULL;}void * PMAPI PM_getA0000Pointer(void){    static void *bankPtr;    if (!bankPtr)        bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true);    return bankPtr;}void * PMAPI PM_mapPhysicalAddr(ulong base,ulong limit,ibool isCached){    // TODO: This function maps a physical memory address to a linear    //       address in the address space of the calling process.    // NOTE: This function *must* be able to handle any phsyical base    //       address, and hence you will have to handle rounding of    //       the physical base address to a page boundary (ie: 4Kb on    //       x86 CPU's) to be able to properly map in the memory    //       region.    // NOTE: If possible the isCached bit should be used to ensure that    //       the PCD (Page Cache Disable) and PWT (Page Write Through)    //       bits are set to disable caching for a memory mapping used    //       for MMIO register access. We also disable caching using    //       the MTRR registers for Pentium Pro and later chipsets so if    //       MTRR support is enabled for your OS then you can safely ignore    //       the isCached flag and always enable caching in the page    //       tables.    return NULL;

⌨️ 快捷键说明

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