POK(kernelpart)
pic.c
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #include <types.h>
19 #include <errno.h>
20 
21 #include <arch/x86/ioports.h>
22 
23 #include "pic.h"
24 
26 {
29 
32 
35 
38 
39  /* Mask everything */
40  outb (PIC_MASTER_BASE + 1, 0xfb);
41  outb (PIC_SLAVE_BASE + 1, 0xff);
42 
43  return (POK_ERRNO_OK);
44 }
45 
47 {
48  uint8_t mask;
49 
50  if (irq > 15)
51  {
52  return (POK_ERRNO_EINVAL);
53  }
54 
55  if (irq < 8)
56  {
57  mask = inb (PIC_MASTER_BASE + 1);
58  outb (PIC_MASTER_BASE + 1, mask | (1 << irq));
59  }
60  else
61  {
62  mask = inb (PIC_SLAVE_BASE + 1);
63  outb (PIC_SLAVE_BASE + 1, mask | (1 << (irq - 8)));
64  }
65 
66  return (POK_ERRNO_OK);
67 }
68 
70 {
71  uint8_t mask;
72 
73  if (irq > 15)
74  return (POK_ERRNO_EINVAL);
75 
76  if (irq < 8)
77  {
78  mask = inb(PIC_MASTER_BASE + 1);
79  outb(PIC_MASTER_BASE + 1, mask & ~(1 << irq));
80  }
81  else
82  {
83  mask = inb(PIC_SLAVE_BASE + 1);
84  outb(PIC_SLAVE_BASE + 1, mask & ~(1 << (irq - 8)));
85  }
86 
87  return (POK_ERRNO_OK);
88 }
89 
90 void pok_pic_eoi (uint8_t irq)
91 {
92  if (irq >= 8)
93  {
94  outb (PIC_SLAVE_BASE, 0x20);
95  }
96 
97  outb (PIC_MASTER_BASE, 0x20);
98 }
99