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

📄 pm.c

📁 gumstiz u-boot loader in linux
💻 C
📖 第 1 页 / 共 4 页
字号:
Set the real time clock frequency (for stereo modes).****************************************************************************/void PMAPI PM_setRealTimeClockFrequency(    int frequency){    /* Not supported under Win32 */    (void)frequency;}/****************************************************************************REMARKS:Restore the original real time clock handler.****************************************************************************/void PMAPI PM_restoreRealTimeClockHandler(void){    /* Not supported under Win32 */}/****************************************************************************REMARKS:Return the current operating system path or working directory.****************************************************************************/char * PMAPI PM_getCurrentPath(    char *path,    int maxLen){    return getcwd(path,maxLen);}/****************************************************************************REMARKS:Query a string from the registry (extended version).****************************************************************************/static ibool REG_queryStringEx(    HKEY hKey,    const char *szValue,    char *value,    ulong size){    DWORD   type;    if (RegQueryValueEx(hKey,(PCHAR)szValue,(PDWORD)NULL,(PDWORD)&type,(LPBYTE)value,(PDWORD)&size) == ERROR_SUCCESS)	return true;    return false;}/****************************************************************************REMARKS:Query a string from the registry.****************************************************************************/static ibool REG_queryString(    const char *szKey,    const char *szValue,    char *value,    DWORD size){    HKEY    hKey;    ibool   status = false;    memset(value,0,sizeof(value));    if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) {	status = REG_queryStringEx(hKey,szValue,value,size);	RegCloseKey(hKey);	}    return status;}/****************************************************************************REMARKS:Return the drive letter for the boot drive.****************************************************************************/char PMAPI PM_getBootDrive(void){    static char path[256];    GetSystemDirectory(path,sizeof(path));    return path[0];}/****************************************************************************REMARKS:Return the path to the VBE/AF driver files.****************************************************************************/const char * PMAPI PM_getVBEAFPath(void){    return "c:\\";}/****************************************************************************REMARKS:Return the path to the Nucleus driver files.****************************************************************************/const char * PMAPI PM_getNucleusPath(void){    static char path[256];    char        *env;    if ((env = getenv("NUCLEUS_PATH")) != NULL)	return env;    GetSystemDirectory(path,sizeof(path));    strcat(path,"\\nucleus");    return path;}/****************************************************************************REMARKS:Return the path to the Nucleus configuration files.****************************************************************************/const char * PMAPI PM_getNucleusConfigPath(void){    static char path[256];    strcpy(path,PM_getNucleusPath());    PM_backslash(path);    strcat(path,"config");    return path;}/****************************************************************************REMARKS:Return a unique identifier for the machine if possible.****************************************************************************/const char * PMAPI PM_getUniqueID(void){    return PM_getMachineName();}/****************************************************************************REMARKS:Get the name of the machine on the network.****************************************************************************/const char * PMAPI PM_getMachineName(void){    static char name[256];    if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name)))	return name;    if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name)))	return name;    return "Unknown";}/****************************************************************************REMARKS:Return a pointer to the real mode BIOS data area.****************************************************************************/void * PMAPI PM_getBIOSPointer(void){    if (_PM_haveWinNT) {	/* On Windows NT we have to map it physically directly */	    return PM_mapPhysicalAddr(0x400, 0x1000, true);	}    else {	/* For Windows 9x we can access this memory directly */	return (void*)0x400;	}}/****************************************************************************REMARKS:Return a pointer to 0xA0000 physical VGA graphics framebuffer.****************************************************************************/void * PMAPI PM_getA0000Pointer(void){    if (_PM_haveWinNT) {	/* On Windows NT we have to map it physically directly */	    return PM_mapPhysicalAddr(0xA0000, 0x0FFFF, false);	}    else {	/* Always use the 0xA0000 linear address so that we will use	 * whatever page table mappings are set up for us (ie: for virtual	 * bank switching.	 */	return (void*)0xA0000;	}}/****************************************************************************REMARKS:Map a physical address to a linear address in the callers process.****************************************************************************/void * PMAPI PM_mapPhysicalAddr(    ulong base,    ulong limit,    ibool isCached){    DWORD   inBuf[3];   /* Buffer to send data to VxD       */    DWORD   outBuf[1];  /* Buffer to receive data from VxD  */    DWORD   count;      /* Count of bytes returned from VxD */    if (!inited)	PM_init();    inBuf[0] = base;    inBuf[1] = limit;    inBuf[2] = isCached;    CHECK_FOR_PMHELP();    if (DeviceIoControl(_PM_hDevice, PMHELP_MAPPHYS32, inBuf, sizeof(inBuf),	    outBuf, sizeof(outBuf), &count, NULL))	return (void*)outBuf[0];    return NULL;}/****************************************************************************REMARKS:Free a physical address mapping allocated by PM_mapPhysicalAddr.****************************************************************************/void PMAPI PM_freePhysicalAddr(    void *ptr,    ulong limit){    /* We never free the mappings under Win32 (the VxD tracks them and     * reissues the same mappings until the system is rebooted).     */    (void)ptr;    (void)limit;}/****************************************************************************REMARKS:Find the physical address of a linear memory address in current process.****************************************************************************/ulong PMAPI PM_getPhysicalAddr(    void *p){    DWORD   inBuf[1];   /* Buffer to send data to VxD       */    DWORD   outBuf[1];  /* Buffer to receive data from VxD  */    DWORD   count;      /* Count of bytes returned from VxD */    if (!inited)	PM_init();    inBuf[0] = (ulong)p;    CHECK_FOR_PMHELP();    if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDR32, inBuf, sizeof(inBuf),	    outBuf, sizeof(outBuf), &count, NULL))	return outBuf[0];    return 0xFFFFFFFFUL;}/****************************************************************************REMARKS:Find the physical address of a linear memory address in current process.****************************************************************************/ibool PMAPI PM_getPhysicalAddrRange(    void *p,    ulong length,    ulong *physAddress){    DWORD   inBuf[3];   /* Buffer to send data to VxD       */    DWORD   outBuf[1];  /* Buffer to receive data from VxD  */    DWORD   count;      /* Count of bytes returned from VxD */    if (!inited)	PM_init();    inBuf[0] = (ulong)p;    inBuf[1] = (ulong)length;    inBuf[2] = (ulong)physAddress;    CHECK_FOR_PMHELP();    if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDRRANGE32, inBuf, sizeof(inBuf),	    outBuf, sizeof(outBuf), &count, NULL))	return outBuf[0];    return false;}/****************************************************************************REMARKS:Sleep for the specified number of milliseconds.****************************************************************************/void PMAPI PM_sleep(    ulong milliseconds){    Sleep(milliseconds);}/****************************************************************************REMARKS:Return the base I/O port for the specified COM port.****************************************************************************/int PMAPI PM_getCOMPort(int port){    /* TODO: Re-code this to determine real values using the Plug and Play */    /*       manager for the OS. */    switch (port) {	case 0: return 0x3F8;	case 1: return 0x2F8;	case 2: return 0x3E8;	case 3: return 0x2E8;	}    return 0;}/****************************************************************************REMARKS:Return the base I/O port for the specified LPT port.****************************************************************************/int PMAPI PM_getLPTPort(int port){    /* TODO: Re-code this to determine real values using the Plug and Play */    /*       manager for the OS. */    switch (port) {	case 0: return 0x3BC;	case 1: return 0x378;	case 2: return 0x278;	}    return 0;}/****************************************************************************REMARKS:Allocate a block of shared memory. For Win9x we allocate shared memoryas locked, global memory that is accessible from any memory context(including interrupt time context), which allows us to load our importantdata structure and code such that we can access it directly from a ring0 interrupt context.****************************************************************************/void * PMAPI PM_mallocShared(    long size){    DWORD   inBuf[1];   /* Buffer to send data to VxD       */    DWORD   outBuf[1];  /* Buffer to receive data from VxD  */    DWORD   count;      /* Count of bytes returned from VxD */    inBuf[0] = size;    CHECK_FOR_PMHELP();    if (DeviceIoControl(_PM_hDevice, PMHELP_MALLOCSHARED32, inBuf, sizeof(inBuf),	    outBuf, sizeof(outBuf), &count, NULL))	return (void*)outBuf[0];    return NULL;}/****************************************************************************REMARKS:Free a block of shared memory.****************************************************************************/void PMAPI PM_freeShared(    void *ptr){    DWORD   inBuf[1];   /* Buffer to send data to VxD       */    inBuf[0] = (ulong)ptr;    CHECK_FOR_PMHELP();    DeviceIoControl(_PM_hDevice, PMHELP_FREESHARED32, inBuf, sizeof(inBuf), NULL, 0, NULL, NULL);}/****************************************************************************REMARKS:Map a linear memory address to the calling process address space. Theaddress will have been allocated in another process using thePM_mapPhysicalAddr function.****************************************************************************/void * PMAPI PM_mapToProcess(    void *base,    ulong limit){    (void)base;    (void)limit;    return base;}/****************************************************************************REMARKS:Map a real mode pointer to a protected mode pointer.****************************************************************************/void * PMAPI PM_mapRealPointer(    uint r_seg,    uint r_off){    return (void*)(MK_PHYS(r_seg,r_off));

⌨️ 快捷键说明

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