POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/sparc/leon3/timer.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00023 #include <errno.h>
00024 #include <bsp.h>
00025 #include <core/time.h>
00026 #include <core/sched.h>
00027 #include <arch.h>
00028 
00029 #include "ioports.h"
00030 #include "sparc_conf.h"
00031 #include "timer.h"
00032 #include "irq.h"
00033 #include "../traps.h"
00034 
00039 void timer_isr(void)
00040 {
00041   ack_irq(TIMER_IRQ);
00042   CLOCK_HANDLER
00043   return;
00044 }
00045 
00050 pok_ret_t pok_bsp_time_init ()
00051 {
00052   outw(TIMER1 + TIMER_SCALER_OFFSET, 1);
00053   outw(TIMER1 + TIMER_SCAL_RELOAD_OFFSET, 1);
00054 
00055   outw(TIMER1 + TIMER_CNT_VAL_OFFSET, 1);
00056   outw(TIMER1 + TIMER_RELOAD_OFFSET, SPARC_PROC_FREQ / POK_TIMER_FREQUENCY);
00057   outw(TIMER1 + TIMER_CTRL_OFFSET,
00058        TIMER_CTRL_EN | TIMER_CTRL_RS | TIMER_CTRL_LD | TIMER_CTRL_IE);
00059 
00060   pok_arch_event_register(SPARC_TRAP_IRQ_BASE + TIMER_IRQ, timer_isr);
00061   unmask_irq(TIMER_IRQ);
00062   return (POK_ERRNO_OK);
00063 }