nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
x86_util.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <stdint.h>
3 #include <stddef.h>
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <errno.h>
7 
8 #include <object.h>
9 #include <list.h>
10 #include <thread.h>
11 #include <isr.h>
12 #include <x86_util.h>
13 
14 int x86_util_get_ring(struct thread *tcb)
15 {
16  struct pt_regs *reg;
17 
18  reg = (struct pt_regs *)tcb->esp;
19  if (!reg) {
20  return -EINVAL;
21  }
22 
23  return reg->cs & 0x03;
24 }
25 
26 
27 /* End of a file */