Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
pcb_t *makeInit() {
	// Init the first process
	pcb_t *pcb = allocPcb();
	pcb->p_pid = 1;
	// Processor Status Register
	pcb->p_s.cpsr = STATUS_SYS_MODE;
	pcb->p_s.cpsr = STATUS_ALL_INT_ENABLE(pcb->p_s.cpsr);
	pcb->p_s.cpsr = STATUS_ENABLE_TIMER(pcb->p_s.cpsr);
	// System Control Register
	pcb->p_s.CP15_Control = CP15_CONTROL_NULL;
	// Other registers
	pcb->p_s.pc = (memaddr) init;
	pcb->p_s.sp = RAM_TOP-FRAMESIZE;
	return pcb;
}
Exemplo n.º 3
0
void processSet( struct pcb_t *p, memaddr start, int priority){
	// Abilita gli interrupt, il Local Timer e la kernel-mode
  	p->p_s.cpsr = STATUS_ALL_INT_ENABLE(p->p_s.cpsr) | STATUS_SYS_MODE;
    	// Disabilita la memoria virtuale
    	p->p_s.CP15_Control = (p->p_s.CP15_Control) & ~(ENABLE_VM);
	p->p_s.cpsr = STATUS_ENABLE_TIMER(p->p_s.cpsr);
    	p->p_s.sp = RAM_TOP - FRAME_SIZE;
    	// Assegna a PC l'indirizzo della funzione esterna test()
    	p->p_s.pc = (memaddr) start;
	p->priority = priority;
    	//assegno un pid al processo
	p->pid = newpid();
	activeProcesses[first->pid-1] = p;
	//inserisco il processo dove di competenza
	insertProcQ(priority_queue( priority ), p);
}