int main() { pcb_t *init; int i; /* Populate the processor state areas into the ROM Reserved Frame */ populateArea(SYSBK_NEWAREA, (memaddr) sysBpHandler); /* SYS/BP Exception Handling */ populateArea(PGMTRAP_NEWAREA, (memaddr) pgmTrapHandler); /* PgmTrap Exception Handling */ populateArea(INT_NEWAREA, (memaddr) intHandler); /* Interrupt Exception Handling */ populateArea(TLB_NEWAREA, (memaddr) tlbHandler); /* TLB Exception Handling */ /* Initialize data structures */ initPcbs(); initASL(); /* Initialize global variables */ ReadyQueue = mkEmptyProcQ(); CurrentProcess = NULL; ProcessCount = SoftBlockCount = TimerTick = PseudoClock = 0; /* Initialize device semaphores */ for (i = 0; i < DEV_PER_INT; i++) Semaphore.disk[i] = Semaphore.tape[i] = Semaphore.network[i] = Semaphore.printer[i] = Semaphore.terminalR[i] = Semaphore.terminalT[i] = 0; /* Initialize init method */ if (!(init = allocPcb())) PANIC(); /* Anomaly */ /* Enable interrupts; enable Kernel-Mode; disable Virtual Memory */ init->p_s.CP15_Control &= ~(0x1); init->p_s.cpsr = STATUS_SYS_MODE | STATUS_ALL_INT_ENABLE(init->p_s.cpsr); /* Initialize Stack Pointer */ init->p_s.sp = RAM_TOP - BUS_REG_RAM_SIZE; /* Initialize Program Counter with the test process */ init->p_s.pc = (memaddr) test; /* Insert init in ProcQ */ insertProcQ(&ReadyQueue, init); /* Initialize Process Id */ ProcessCount++; /* Start the timer tick */ StartTimerTick = getTODLO(); /* Call the scheduler */ scheduler(); /* Anomaly */ PANIC(); return 0; }
int main() { int i,j; /* Setting up CPU0 new areas in ROM. */ populateArea((state_t *)INT_NEWAREA,(memaddr)intHandler,0); populateArea((state_t *)TLB_NEWAREA,(memaddr)tlbHandler,0); populateArea((state_t *)PGMTRAP_NEWAREA,(memaddr)trapHandler,0); populateArea((state_t *)SYSBK_NEWAREA,(memaddr)sysHandler,0); /* Setting up CPU-n (with n >= 1) new areas in RAM, in a defined array of state_t pointers. */ for (i = 1; i < NUM_CPU; i++) for (j = 0; j < 4; j++) switch (j) { case 0: populateArea(&new_old_areas[i][1],(memaddr)intHandler,i); break; case 1: populateArea(&new_old_areas[i][3],(memaddr)tlbHandler,i); break; case 2: populateArea(&new_old_areas[i][5],(memaddr)trapHandler,i); break; case 3: populateArea(&new_old_areas[i][7],(memaddr)sysHandler,i); break; } /* Initialization of underlaying data structures. */ initPcbs(); initASL(); /* Inizialization of device semaphores. TODO */ if ((psClock_timer = getSemd(0)) != NULL) psClock_timer -> s_value = 0; if ((terminalWrite = getSemd(1)) != NULL) terminalWrite -> s_value = 0; if ((terminalRead = getSemd(2)) != NULL) terminalRead -> s_value = 0; /* Scheduler initialization process. */ initScheduler(i); return 1; }