void InstallCMOSHandler() { SendByteToPort(CMOSAddressPort, 0x8B); char PreviousValueOfRegisterB=ReadByteFromPort(CMOSAddressPort); SendByteToPort(CMOSAddressPort, 0x8B); SendByteToPort(CMOSDataPort, PreviousValueOfRegisterB | 0x40); //InstallIRQHandler(7,CMOSHandler); InstallIRQHandler(8,CMOSHandler); ReadRTC(); SendByteToPort(0x70,0x0C);// select register C ReadByteFromPort(0x71); // just throw away contents //PrintString(GetDateTime()); }
void Restart() { //restart dirty way :D :D triple fault >.< /* __asm__ __volatile__ ("cli"); ZeroTheIDT(); LoadIDTToProcessor(); __asm__ __volatile__ ("sti");*/ unsigned short good = 0x02; while (good & 0x02) good = ReadByteFromPort(0x64); SendByteToPort(0x64, 0xFE); }
void EnableA20()//silly old IBM intel standards 2al A 3ashan y7afzo 3ala el compatability { unsigned char x=ReadByteFromPort(0x92); x|=2; SendByteToPort(0x92,x); }
unsigned char GetRTCRegister(int reg) { SendByteToPort(CMOSAddressPort, reg); return ReadByteFromPort(CMOSDataPort); }
int IsUpdateLoading() { SendByteToPort(CMOSAddressPort, 0x0A); return (ReadByteFromPort(CMOSDataPort) & 0x80); }
static DWORD beep(__CMD_PARA_OBJ* lpCmdObj) { __KERNEL_THREAD_MESSAGE Msg; DWORD dwTimerID = 00100000; DWORD dwTimeSpan = 0L; __COMMON_OBJECT* lpTimerObject = NULL; UCHAR ucCtrlByte; if((NULL == lpCmdObj) || (lpCmdObj->byParameterNum < 2)) //Parameter check. { PrintLine(" Please input the beep time,in millionsecond."); return SYS_DIAG_CMD_PARSER_INVALID; } if(!Str2Hex(lpCmdObj->Parameter[1],&dwTimeSpan)) //Get the time span to beep. { PrintLine(" Invalid time parameter."); return SYS_DIAG_CMD_PARSER_INVALID; } // //Now,the variable dwTimeSpan countains the time to beep. // lpTimerObject = System.SetTimer((__COMMON_OBJECT*)&System, KernelThreadManager.lpCurrentKernelThread, dwTimerID, dwTimeSpan, NULL, NULL, TIMER_FLAGS_ONCE); if(NULL == lpTimerObject) //Failed to set timer. { PrintLine(" Can not set timer,please try again."); return SYS_DIAG_CMD_PARSER_FAILED; } // //Begin to beep. // ReadByteFromPort(&ucCtrlByte,0x61); ucCtrlByte |= 0x03; WriteByteToPort(ucCtrlByte,0x61); while(TRUE) { if(GetMessage(&Msg)) { if((Msg.wCommand == KERNEL_MESSAGE_TIMER) && //Beep time is over. (Msg.dwParam == dwTimerID)) { ucCtrlByte &= ~0x03; WriteByteToPort(ucCtrlByte,0x61); //Stop the beep. PrintLine(" Beep over"); goto __TERMINAL; } } } __TERMINAL: return SYS_DIAG_CMD_PARSER_SUCCESS; }