Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 // Intel 8253/8254/82C54 Programmable Interval Timer (PIT). 00002 // Only used on uniprocessors; 00003 // SMP machines use the local APIC timer. 00004 00005 #include "types.h" 00006 #include "defs.h" 00007 #include "traps.h" 00008 #include "x86.h" 00009 00010 #define IO_TIMER1 0x040 // 8253 Timer #1 00011 00012 // Frequency of all three count-down timers; 00013 // (TIMER_FREQ/freq) is the appropriate count 00014 // to generate a frequency of freq Hz. 00015 00016 #define TIMER_FREQ 1193182 00017 #define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x)) 00018 00019 #define TIMER_MODE (IO_TIMER1 + 3) // timer mode port 00020 #define TIMER_SEL0 0x00 // select counter 0 00021 #define TIMER_RATEGEN 0x04 // mode 2, rate generator 00022 #define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first 00023 00024 void 00025 timerinit(void) 00026 { 00027 // Interrupt 100 times/sec. 00028 outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); 00029 outb(IO_TIMER1, TIMER_DIV(100) % 256); 00030 outb(IO_TIMER1, TIMER_DIV(100) / 256); 00031 picenable(IRQ_TIMER); 00032 }