Exemplo n.º 1
0
/* c_irq_handler - custom irq handler called by assembly irq handler 
   after state has been saved/restored appropriately.
	Parameters: None 
*/
void c_irq_handler(){
	unsigned stamp;
	mmio_t oscr = (mmio_t)OSCR;
	mmio_t ossr = (mmio_t)OSSR;
	mmio_t osmr0 = (mmio_t)OSMR_0;
	if(*ossr & OSSR_M0){
		//keep global time by checking if oscr has overlapped start_time
		if(lastoscr<start_time && *oscr>=start_time){
			rollovercount++;
		}
		lastoscr = *oscr;
		dotime(&stamp);

		//set next interrupt for 10ms later
		*osmr0 = *oscr + OSTMR_FREQ/100;

		//unset interrupts
		*ossr |= OSSR_M0;

		//update devices and switch to highest prio task
		dev_update((unsigned long)stamp);
		dispatch_save();
	}
	if(*ossr & OSSR_M1)
		*ossr |= OSSR_M1;
	if(*ossr & OSSR_M2)
		*ossr |= OSSR_M2;
	if(*ossr & OSSR_M3)
		*ossr |= OSSR_M3;
}
Exemplo n.º 2
0
void irq_handler(void) {
	disable_interrupts();

	irq_time ++;
	dev_update(irq_time);
	reg_set(OSTMR_OSSR_ADDR, OSTMR_OSSR_M0);
	reg_write(OSTMR_OSCR_ADDR, TIMER_CLEAR);

	/* Wait for timer to reset */
	while(((volatile unsigned)reg_read(INT_ICPR_ADDR) >>INT_OSTMR_0) & 0x1);

	dispatch_save();
}
Exemplo n.º 3
0
// This function is called on all IRQ interrupts
void timer_inc(void)
{
  	uint32_t ossr;
	
	/* increment the number of the timer ticks */
	++num_timer_tick;

	/* add clocks to OSMR */
	osmr_count += CLOCKS_PER_TICK;
	reg_write(OSTMR_OSMR_ADDR(0), osmr_count);
	
	/* acknowledge interupt and set OSSR */
	ossr = reg_read(OSTMR_OSSR_ADDR);
	ossr |= OSTMR_OSSR_M0;
	reg_write(OSTMR_OSSR_ADDR, ossr);

	/* wake up any tasks waiting on devices */
	dev_update(num_timer_tick * MS_PER_TICK);
}
Exemplo n.º 4
0
//dispatch the handler
void C_IRQ_handler(){
	/* Check that a time interrupt has occured, if not, ignore it */
	/* Check if interrupt controller irq pending reg. bit 26 is set */
    if((reg_read(OSTMR_OSSR_ADDR) & OSTMR_OSSR_M0) && (reg_read(INT_ICPR_ADDR) >> INT_OSTMR_0)) {
			// Increment time by 10ms
			sys_time += 10;

			//clear the OSCR
			reg_write(OSTMR_OSCR_ADDR, 0);

      		// Writing a 1 to the bit acknowledges the match and hence, clears that bit
			reg_set(OSTMR_OSSR_ADDR, OSTMR_OSSR_M0);
			
			dev_update(sys_time);

	}


}
Exemplo n.º 5
0
/* IRQ_Handler updates system time whenever OS timer match 0 IRQ is serviced */
void irq_handler() {

    // ensure the irq is that from the match0 and counter0
    if (reg_read(INT_ICPR_ADDR) & (1 << 26)) {
        // update the current time
        current_time += 10;

        //handshake
        reg_set(OSTMR_OSSR_ADDR,OSTMR_OSSR_M0);

        // call again in 10 millis
        unsigned new_time = (unsigned)CLOCK_TO_10_MILLI + reg_read(OSTMR_OSCR_ADDR);
        reg_write(OSTMR_OSMR_ADDR(0), new_time);

        if (task_created) {
            dev_update(current_time);
        }
    }

}
Exemplo n.º 6
0
struct resp_data handle_server_msg(struct server_msg server_messege,
	struct status_data *status)
{
	struct resp_data resp_server;
	switch(server_messege.srv_cmd)
	 {
		case 0:
			dev_update();
			break;
		case 1:
			dev_restart();
			break;
		case 2:
			*status = dev_status_handle();
			break;
		case 3:	
			dev_log();
			break;
		default:
			uagent_printf(MSG_ERROR,"No such server command!");			
	 }
	 resp_server.srv_cmd = server_messege.srv_cmd;
	return resp_server;
}