📄 cpu_defs.c
字号:
CPUStatus |= CPU_STAT_LOCK; kprintf(("fin_int : [Exit]\n"));}BOOLras_int(unsigned int ims){ BOOL lock; BOOL result = TRUE; if(!CHECK_IMS(ims)) return FALSE; ims --; enter_system_critical_section(&lock); if(InterruptLevel[ims].ThreadHandle == NULL) { result = FALSE; }else InterruptLevel[ims].Flags |= INT_STAT_PENDING; leave_system_critiacl_section(&lock); return result;}unsigned intsns_int( void ){ BOOL lock; int result; if(sense_lock() == TRUE) return 0; enter_system_critical_section(&lock); result = isns_int(CurrentInterruptLevel); leave_system_critiacl_section(&lock); return result;}HANDLEsch_int( void ){ BOOL lock; HANDLE result; unsigned int level; if(sense_lock() == TRUE) return NULL; enter_system_critical_section(&lock); level = isns_int(CurrentInterruptLevel); if(level != 0) { result = InterruptLevel[level-1].ThreadHandle; }else result = NULL; leave_system_critiacl_section(&lock); return result;}DWORD LockerThreadID = 0;ERena_int(unsigned int ims){ BOOL lock; int i; enter_system_critical_section(&lock); i = isns_int(CurrentInterruptLevel); CPUStatus &= ~CPU_STAT_LOCK; LockerThreadID = 0; leave_system_critiacl_section(&lock); if(i != 0) HALInterruptRequest(0); return 0 /*E_OK*/;}ERdis_int(unsigned int ims){ BOOL lock; enter_system_critical_section(&lock); CPUStatus |= CPU_STAT_LOCK; if(LockerThreadID == 0) { LockerThreadID = GetCurrentThreadId(); }else { DWORD newThreadID = GetCurrentThreadId(); LockerThreadID = GetCurrentThreadId(); //ブレ〖ク弥き眷 } leave_system_critiacl_section(&lock); return 0;}ERchg_ims(unsigned int ims){ BOOL lock; int i; //chg_ims は ims==0 を钓す if(ims != 0 && !CHECK_IMS(ims)) return -17 /*E_PAR*/; enter_system_critical_section(&lock); CurrentInterruptLevel = ims; if(CurrentInterruptLevel == INT_NUMINTERRUPTS) CPUStatus |= CPU_STAT_LOCK; else CPUStatus &= ~CPU_STAT_LOCK; i = isns_int(ims); leave_system_critiacl_section(&lock); if(i != 0) HALInterruptRequest(0); return 0 /*E_OK*/;}ERget_ims(unsigned int *p_ims){ BOOL lock; if(p_ims == (void *)0l) return -17 /*E_PAR*/; enter_system_critical_section(&lock); if((CPUStatus & CPU_STAT_LOCK) != 0) *p_ims = INT_NUMINTERRUPTS; else *p_ims = CurrentInterruptLevel; leave_system_critiacl_section(&lock); return 0 /*E_OK*/;}ERvget_ims(unsigned int *p_ims){ BOOL lock; if(p_ims == (void *)0l) return -17 /*E_PAR*/; enter_system_critical_section(&lock); *p_ims = CurrentInterruptLevel; leave_system_critiacl_section(&lock); return 0 /*E_OK*/;}/* * 呵惧疤レベルWindows菇陇步毋嘲ハンドラ */LONG WINAPIHALExceptionHandler( EXCEPTION_POINTERS * exc ){ int i; int result; if((CPUStatus & CPU_STAT_EXC) == 0) CPUStatus |= CPU_STAT_DOUBLEFAULT; /* 窍集サ〖チ (鄂粗がせまいから...) */ CPUStatus |= CPU_STAT_EXC; for(i=0;i<EXC_MAXITEMS;i++) { if(ExceptionLevel[i].ExceptionCode == exc->ExceptionRecord->ExceptionCode) { result = EXCEPTION_CONTINUE_SEARCH; LOG_EXC_ENTER(i); ( * ((void (*)(void *,int *))ExceptionLevel[i].Routine)) (exc,&i); LOG_EXC_LEAVE(i); CPUStatus &= ~CPU_STAT_EXC; return result; } } CPUStatus &= ~CPU_STAT_EXC; return EXCEPTION_CONTINUE_SEARCH;}BOOLini_exc(void){ int i; for(i=0;i<EXC_MAXITEMS;i++) { ExceptionLevel[i].ExceptionCode = 0; ExceptionLevel[i].Routine = 0l; } AnotherExceptionFilter = SetUnhandledExceptionFilter(HALExceptionHandler); return TRUE;}voidfin_exc(void){ SetUnhandledExceptionFilter(AnotherExceptionFilter);}BOOLdef_exc(DWORD exc, void * routine){ int j; int i; /* 豺近ル〖チン */ if(routine == 0l) { kprintf(("def_exc : [UNREG] 0x%08x\n", exc)); for(i=0;i<EXC_MAXITEMS;i++) if(ExceptionLevel[i].ExceptionCode == exc) { ExceptionLevel[i].ExceptionCode = 0; ExceptionLevel[i].Routine = 0; return TRUE; } return FALSE; } /* 判峡ル〖チン */ kprintf(("def_exc : [REG] 0x%08x\n", exc)); j = EXC_MAXITEMS; for(i=0;i<EXC_MAXITEMS;i++) { if(ExceptionLevel[i].ExceptionCode != 0) { /* 判峡しようとしている戎规が贷に判峡されていないかどうか拇べる */ if(ExceptionLevel[i].ExceptionCode == exc) return FALSE; }else { /* 鄂き戎规の呵井を承える */ if(j > i) j = i; /* 贷判峡チェックがあるので、ここでbreakしてはダメ */ } } FatalAssertion(i == EXC_MAXITEMS, "No available exception slots left."); //This sequence will never change ExceptionLevel[j].Routine = routine; ExceptionLevel[j].ExceptionCode = exc; return TRUE;}ER set_intlogmask( unsigned int ims, BOOL mask ){ BOOL lock; if( !CHECK_IMS(ims) ) return FALSE; -- ims; enter_system_critical_section(&lock); if(mask == TRUE) InterruptLevel[ims].Flags |= INT_MOD_LOGMASK; else InterruptLevel[ims].Flags &= ~INT_MOD_LOGMASK; leave_system_critiacl_section(&lock); return TRUE;}unsigned int current_timer_clock_unit = TIMER_CLOCK_WINDOWS;ER set_clk(unsigned int clk){ BOOL lock; if(clk == 0) clk = TIMER_CLOCK_WINDOWS; hw_timer_terminate(); enter_system_critical_section(&lock); current_timer_clock_unit = clk; leave_system_critiacl_section(&lock); hw_timer_initialize(); return E_OK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -