Exemple #1
0
//funzione che inizializza un'area con il gestore passato come parametro
void init_area(memaddr area, memaddr handler){	
//i parametri sono l'area da inizializzare e il gestore relativo
	state_t *newArea = (state_t*) area;
	STST(newArea);
	newArea->pc = handler;
	newArea->sp = RAM_TOP;
	//interrupt disabilitati e kernel-mode
	newArea->cpsr = STATUS_ALL_INT_DISABLE((newArea->cpsr) | STATUS_SYS_MODE);
}
Exemple #2
0
/*
@brief Populate a new processor state area.
@param area Physical address of the area.
@param handler Physical address of the handler.
@return Void.
*/
HIDDEN void populateArea(memaddr oldArea, memaddr handler)
{
	state_t *newArea;

	/* The new area points to the old area */
	newArea = (state_t *) oldArea;
	
	/* Save the current processor state */
	STST(newArea);
	
	/* Assign to Program Counter the Exception Handler address */
	newArea->pc = handler;
	newArea->sp = RAM_TOP;
	
	/* Masked interrupts; Virtual Memory off; Kernel Mode on */
	newArea->CP15_Control &= ~(0x1);
	newArea->cpsr = STATUS_ALL_INT_DISABLE(newArea->cpsr) | STATUS_SYS_MODE;
}
Exemple #3
0
/**
  * @brief Funzione che popola le New Areas
  * @param area : indirizzo dell'area da popolare
  * @param handler : inidirizzo del gestore dell'area
  * @return void.
 */
HIDDEN void populate(memaddr area, memaddr handler)
{
	/* Nuova area da popolare */
	state_t *newArea;
	
	/* La nuova area punta alla vecchia */
	newArea = (state_t *) area;
	
	/* Salva lo stato corrente del processore */
	STST(newArea);
	
	/* Imposta il PC all'indirizzo del gestore delle eccezioni */
	newArea->pc_epc = newArea->reg_t9 = handler;
	
	newArea->reg_sp = RAMTOP;
	
	/* Interrupt mascherati, Memoria Virtuale spenta, Kernel Mode attivo */
	newArea->status = (newArea->status | STATUS_KUc) & ~STATUS_INT_UNMASKED & ~STATUS_VMp;
}
Exemple #4
0
int main(void)
{
	/************* INIZIALIZZAZIONE DEL SISTEMA */
	/* Inizializzazione del vettore dei lock a PASS */
	initLock();
	/* Inizializzo le new (e old) area di tutte le CPU */
	initAreas(pnew_old_areas, NUM_CPU);
	/* Inizializzo le strutture dati di Phase1 */
	initPcbs();
	initASL();
	/* Inizializzo le strutture dello scheduler */
	initReadyQueues();
	
	
	/************* CARICAMENTO DEI PROCESSI NELLE READY QUEUE */
	
		/* Test phase2 */
		//pcb_t *phase2 = allocPcb();
		//STST(&(phase2->p_s));
		//phase2->p_s.status = getSTATUS();
		//phase2->p_s.pc_epc = phase2->p_s.reg_t9 = (memaddr)p2test;
		//phase2->p_s.reg_sp = PFRAMES_START;
		//addReady(phase2);
		
		/* Test di alcuni processi di prova */
		pcb_t *test1 = allocPcb();
		STST(&(test1->p_s));
		test1->p_s.status = getSTATUS();
		(test1->p_s).pc_epc = (test1->p_s).reg_t9 = (memaddr)print1;
		test1->p_s.reg_sp = PFRAMES_START;
		addReady(test1);
		
		/* Test di alcuni processi di prova */
		pcb_t *test2 = allocPcb();
		STST(&(test2->p_s));
		test2->p_s.status = getSTATUS();
		test2->p_s.pc_epc = test2->p_s.reg_t9 = (memaddr)print2;
		test2->p_s.reg_sp = test1->p_s.reg_sp-FRAME_SIZE;
		addReady(test2);
		
		pcb_t *test3 = allocPcb();
		STST(&(test3->p_s));
		test3->p_s.status = getSTATUS();
		test3->p_s.pc_epc = test3->p_s.reg_t9 = (memaddr)print3;
		test3->p_s.reg_sp = test2->p_s.reg_sp-FRAME_SIZE;
		addReady(test3);

		pcb_t *test4 = allocPcb();
		STST(&(test4->p_s));
		test4->p_s.status = getSTATUS();
		test4->p_s.pc_epc = test4->p_s.reg_t9 = (memaddr)print4;
		test4->p_s.reg_sp = test3->p_s.reg_sp-FRAME_SIZE;
		addReady(test4);
	
	/************* ESECUZIONE DEI PROCESSI */
	/* Inizializzo la Interrupt Routing Table dinamica */
	/* initIRT(); */
	/* Inizializzo le altre CPU e faccio partire lo scheduler */
	initCpus();
	return 0;
}