nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pic.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <sys/io.h>
3 #include <stdio.h>
4 #include <assert.h>
5 #include <stdarg.h>
6 
7 #include <pic.h>
8 
9 #define CLOCK 1193180
10 
12 enum port_t {
16 
19 
23 
25  CG_6845_INDEX = 0x3D4,
26  CG_6845_DATA = 0x3D5,
32  CG_6845_STATUS = 0x3DA,
38 };
39 
40 void pic_init(void)
41 {
43  outb(PIC_FIRST_COMMAND, 0x11);
51 
53  outb(PIC_SECOND_COMMAND, 0x11);
61 }
62 
63 void timer_init(unsigned long frequency)
64 {
65  unsigned long divisor = CLOCK / frequency;
66  outb(TIMER_MODE_CONTROL, 0x34);
67  outb(TIMER_COUNTER_DIVISOR, divisor & 0xff);
68  outb(TIMER_COUNTER_DIVISOR, (divisor >> 8) & 0xff);
69 }
70 
71 /* End of a file */