POK(kernelpart)
event.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 <libc.h>
19 
20 #include <types.h>
21 #include <errno.h>
22 #include <core/syscall.h>
23 
24 #include "event.h"
25 #include "sysdesc.h"
26 
27 #define IDT_SIZE 256
28 
29 idt_entry_t pok_idt[IDT_SIZE];
30 
32 {
33  pok_idt_init ();
34 
35 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_ERROR_HANDLING)
37 #endif
38 
40 
41  return (POK_ERRNO_OK);
42 }
43 
45 {
46  sysdesc_t sysdesc;
47 
48  /* Clear table */
49  memset(pok_idt, 0, sizeof (idt_entry_t) * IDT_SIZE);
50 
51  /* Load IDT */
52  sysdesc.limit = sizeof (pok_idt);
53  sysdesc.base = (uint32_t)pok_idt;
54 
55  asm ("lidt %0"
56  :
57  : "m" (sysdesc));
58 
59  return (POK_ERRNO_OK);
60 }
61 
63  uint16_t segsel,
64  uint32_t offset,
65  e_idte_type t,
66  int dpl)
67 {
68  pok_idt[index].offset_low = (offset) & 0xFFFF;
69  pok_idt[index].offset_high = (offset >> 16) & 0xFFFF;
70  pok_idt[index].segsel = segsel;
71  pok_idt[index].dpl = dpl;
72  pok_idt[index].type = t;
73  pok_idt[index].d = 1;
74  pok_idt[index].res0 = 0; /* reserved */
75  pok_idt[index].res1 = 0; /* reserved */
76  pok_idt[index].present = 1;
77 }
78