POK(kernelpart)
|
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 00017 00018 #include <errno.h> 00019 #include <bsp.h> 00020 #include <core/time.h> 00021 #include <core/sched.h> 00022 #include <arch/x86/ioports.h> 00023 #include <arch/x86/interrupt.h> 00024 00025 #include "pic.h" 00026 00027 #include "pit.h" 00028 00029 #define OSCILLATOR_RATE 1193180 00030 #define PIT_BASE 0x40 00031 #define PIT_IRQ 0 00032 00033 INTERRUPT_HANDLER (pit_interrupt) 00034 { 00035 (void) frame; 00036 pok_pic_eoi (PIT_IRQ); 00037 CLOCK_HANDLER 00038 } 00039 00040 pok_ret_t pok_x86_qemu_timer_init () 00041 { 00042 uint16_t pit_freq; 00043 00044 pit_freq = POK_TIMER_FREQUENCY; 00045 00046 outb (PIT_BASE + 3, 0x34); /* Channel0, rate generator, Set LSB then MSB */ 00047 outb (PIT_BASE, (OSCILLATOR_RATE / pit_freq) & 0xff); 00048 outb (PIT_BASE, ((OSCILLATOR_RATE / pit_freq) >> 8) & 0xff); 00049 00050 pok_bsp_irq_register (PIT_IRQ, pit_interrupt); 00051 00052 return (POK_ERRNO_OK); 00053 } 00054 00055