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

📄 pm.c

📁 linux下的BOOT程序原码,有需要的可以来下,保证好用
💻 C
📖 第 1 页 / 共 3 页
字号:
    /*       the page tables (PCD|PWT) since DMA memory blocks *cannot* be */    /*       cached! */    return p;}/****************************************************************************REMARKS:Frees a block of locked physical memory.****************************************************************************/void PMAPI PM_freeLockedMem(    void *p,    uint size,    ibool contiguous){    if (p)	PageFree((ulong)p,0);}/****************************************************************************REMARKS:Allocates a page aligned and page sized block of memory****************************************************************************/void * PMAPI PM_allocPage(    ibool locked){    MEMHANDLE   hMem;    void        *p;    /* TODO: This will need to be modified if the memory needs to be globally */    /*       accessible. Check how we implemented PM_mallocShared() as we */    /*       may need to do something similar in here. */    PageAllocate(1,PG_SYS,0,0,0,0,0,PAGEFIXED,&hMem,&p);    return p;}/****************************************************************************REMARKS:Free a page aligned and page sized block of memory****************************************************************************/void PMAPI PM_freePage(    void *p){    if (p)	PageFree((ulong)p,0);}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockDataPages(    void *p,    uint len,    PM_lockHandle *lh){    DWORD pgNum = (ulong)p >> 12;    DWORD nPages = (len + (ulong)p - (pgNum << 12) + 0xFFF) >> 12;    return LinPageLock(pgNum,nPages,0);}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockDataPages(    void *p,    uint len,    PM_lockHandle *lh){    DWORD pgNum = (ulong)p >> 12;    DWORD nPages = (len + (ulong)p - (pgNum << 12) + 0xFFF) >> 12;    return LinPageUnLock(pgNum,nPages,0);}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockCodePages(    void (*p)(),    uint len,    PM_lockHandle *lh){    return PM_lockDataPages((void*)p,len,lh);}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockCodePages(    void (*p)(),    uint len,    PM_lockHandle *lh){    return PM_unlockDataPages((void*)p,len,lh);}/****************************************************************************REMARKS:Set the real time clock frequency (for stereo modes).****************************************************************************/void PMAPI PM_setRealTimeClockFrequency(    int frequency){    static short convert[] = {	8192,	4096,	2048,	1024,	512,	256,	128,	64,	32,	16,	8,	4,	2,	-1,	};    int i;    /* First clear any pending RTC timeout if not cleared */    _PM_readCMOS(0x0C);    if (frequency == 0) {	/* Disable RTC timout */	_PM_writeCMOS(0x0A,_PM_oldCMOSRegA);	_PM_writeCMOS(0x0B,_PM_oldCMOSRegB & 0x0F);	}    else {	/* Convert frequency value to RTC clock indexes */	for (i = 0; convert[i] != -1; i++) {	    if (convert[i] == frequency)		break;	    }	/* Set RTC timout value and enable timeout */	_PM_writeCMOS(0x0A,0x20 | (i+3));	_PM_writeCMOS(0x0B,(_PM_oldCMOSRegB & 0x0F) | 0x40);	}}/****************************************************************************REMARKS:Real time clock interrupt handler, which calls the user registered C code.****************************************************************************/static BOOL __stdcall RTCInt_Handler(    VMHANDLE hVM,    IRQHANDLE hIRQ){    static char inside = 0;    /* Clear priority interrupt controller and re-enable interrupts so we     * dont lock things up for long.     */    VPICD_Phys_EOI(hIRQ);    /* Clear real-time clock timeout */    _PM_readCMOS(0x0C);    /* Now call the C based interrupt handler (but check for mutual     * exclusion since we may still be servicing an old interrupt when a     * new one comes along; if that happens we ignore the old one).     */    if (!inside) {	inside = 1;	enable();	_PM_rtcHandler();	inside = 0;	}    return TRUE;}/****************************************************************************REMARKS:Set the real time clock handler (used for software stereo modes).****************************************************************************/ibool PMAPI PM_setRealTimeClockHandler(    PM_intHandler ih,    int frequency){    struct VPICD_IRQ_Descriptor IRQdesc;    /* Save the old CMOS real time clock values */    _PM_oldCMOSRegA = _PM_readCMOS(0x0A);    _PM_oldCMOSRegB = _PM_readCMOS(0x0B);    /* Set the real time clock interrupt handler */    CHECK(ih != NULL);    _PM_rtcHandler = ih;    IRQdesc.VID_IRQ_Number      = 0x8;    IRQdesc.VID_Options         = 0;    IRQdesc.VID_Hw_Int_Proc     = (DWORD)VPICD_Thunk_HWInt(RTCInt_Handler, &RTCInt_Thunk);    IRQdesc.VID_EOI_Proc        = 0;    IRQdesc.VID_Virt_Int_Proc   = 0;    IRQdesc.VID_Mask_Change_Proc= 0;    IRQdesc.VID_IRET_Proc       = 0;    IRQdesc.VID_IRET_Time_Out   = 500;    if ((RTCIRQHandle = VPICD_Virtualize_IRQ(&IRQdesc)) == 0)	return false;    /* Program the real time clock default frequency */    PM_setRealTimeClockFrequency(frequency);    /* Unmask IRQ8 in the PIC */    VPICD_Physically_Unmask(RTCIRQHandle);    return true;}/****************************************************************************REMARKS:Restore the original real time clock handler.****************************************************************************/void PMAPI PM_restoreRealTimeClockHandler(void){    if (RTCIRQHandle) {	/* Restore CMOS registers and mask RTC clock */	_PM_writeCMOS(0x0A,_PM_oldCMOSRegA);	_PM_writeCMOS(0x0B,_PM_oldCMOSRegB);	/* Restore the interrupt vector */	VPICD_Set_Auto_Masking(RTCIRQHandle);	VPICD_Force_Default_Behavior(RTCIRQHandle);	RTCIRQHandle = 0;	}}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VxD****************************************************************************/PM_MODULE PMAPI PM_loadLibrary(    const char *szDLLName){    (void)szDLLName;    return NULL;}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VxD****************************************************************************/void * PMAPI PM_getProcAddress(    PM_MODULE hModule,    const char *szProcName){    (void)hModule;    (void)szProcName;    return NULL;}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VxD****************************************************************************/void PMAPI PM_freeLibrary(    PM_MODULE hModule){    (void)hModule;}/****************************************************************************REMARKS:Function to find the first file matching a search criteria in a directory.****************************************************************************/void *PMAPI PM_findFirstFile(    const char *filename,    PM_findData *findData){    /* TODO: This function should start a directory enumeration search */    /*       given the filename (with wildcards). The data should be */    /*       converted and returned in the findData standard form. */    (void)filename;    (void)findData;    return PM_FILE_INVALID;}/****************************************************************************REMARKS:Function to find the next file matching a search criteria in a directory.****************************************************************************/ibool PMAPI PM_findNextFile(    void *handle,    PM_findData *findData){    /* TODO: This function should find the next file in directory enumeration */    /*       search given the search criteria defined in the call to */    /*       PM_findFirstFile. The data should be converted and returned */    /*       in the findData standard form. */    (void)handle;    (void)findData;    return false;}/****************************************************************************REMARKS:Function to close the find process****************************************************************************/void PMAPI PM_findClose(    void *handle){    /* TODO: This function should close the find process. This may do */    /*       nothing for some OS'es. */    (void)handle;}/****************************************************************************REMARKS:Function to determine if a drive is a valid drive or not. Under Unix thisfunction will return false for anything except a value of 3 (consideredthe root drive, and equivalent to C: for non-Unix systems). The drivenumbering is:    1   - Drive A:    2   - Drive B:    3   - Drive C:    etc****************************************************************************/ibool PMAPI PM_driveValid(    char drive){    /* Not supported in a VxD */    (void)drive;    return false;}/****************************************************************************REMARKS:Function to get the current working directory for the specififed drive.Under Unix this will always return the current working directory regardlessof what the value of 'drive' is.****************************************************************************/void PMAPI PM_getdcwd(    int drive,    char *dir,    int len){    /* Not supported in a VxD */    (void)drive;    (void)dir;    (void)len;}/****************************************************************************PARAMETERS:base    - The starting physical base address of the regionsize    - The size in bytes of the regiontype    - Type to place into the MTRR registerRETURNS:Error code describing the result.REMARKS:Function to enable write combining for the specified region of memory.****************************************************************************/int PMAPI PM_enableWriteCombine(    ulong base,    ulong size,    uint type){    return MTRR_enableWriteCombine(base,size,type);}/****************************************************************************REMARKS:Function to change the file attributes for a specific file.****************************************************************************/void PMAPI PM_setFileAttr(    const char *filename,    uint attrib){    /* TODO: Implement this */    (void)filename;    (void)attrib;    PM_fatalError("PM_setFileAttr not implemented yet!");}/****************************************************************************REMARKS:Function to get the file attributes for a specific file.****************************************************************************/uint PMAPI PM_getFileAttr(    const char *filename){    /* TODO: Implement this */    (void)filename;    PM_fatalError("PM_getFileAttr not implemented yet!");    return 0;}/****************************************************************************REMARKS:Function to create a directory.****************************************************************************/ibool PMAPI PM_mkdir(    const char *filename){    /* TODO: Implement this */    (void)filename;    PM_fatalError("PM_mkdir not implemented yet!");    return false;}/****************************************************************************REMARKS:Function to remove a directory.****************************************************************************/ibool PMAPI PM_rmdir(    const char *filename){    /* TODO: Implement this */    (void)filename;    PM_fatalError("PM_rmdir not implemented yet!");    return false;}/****************************************************************************REMARKS:Function to get the file time and date for a specific file.****************************************************************************/ibool PMAPI PM_getFileTime(    const char *filename,    ibool gmTime,    PM_time *time){    /* TODO: Implement this! */    (void)filename;    (void)gmTime;    (void)time;    PM_fatalError("PM_getFileTime not implemented yet!");    return false;}/****************************************************************************REMARKS:Function to set the file time and date for a specific file.****************************************************************************/ibool PMAPI PM_setFileTime(    const char *filename,    ibool gmTime,    PM_time *time){    /* TODO: Implement this! */    (void)filename;    (void)gmTime;    (void)time;    PM_fatalError("PM_setFileTime not implemented yet!");    return false;}

⌨️ 快捷键说明

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