POK(kernelpart)
syscalls.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 
25 #include <errno.h>
26 #include <core/debug.h>
27 #include <core/partition.h>
28 #include <core/syscall.h>
29 
30 #include "gdt.h"
31 #include "event.h"
32 
33 #define PARTITION_ID(cs) (((cs >> 3) - 4) / 2)
34 
36 {
37  pok_syscall_info_t syscall_info;
38  pok_ret_t syscall_ret;
39  pok_syscall_args_t* syscall_args;
40  pok_syscall_id_t syscall_id;
41 
42  /*
43  * Give informations about syscalls: which partition, thread
44  * initiates the syscall, the base addr of the partition and so on.
45  */
46  syscall_info.partition = PARTITION_ID (frame->cs);
47  syscall_info.base_addr = pok_partitions[syscall_info.partition].base_addr;
48  syscall_info.thread = POK_SCHED_CURRENT_THREAD;
49 
50  syscall_args = (pok_syscall_args_t*) (frame->ebx + syscall_info.base_addr);
51 
52  /*
53  * Get the syscall id in the eax register
54  */
55  syscall_id = (pok_syscall_id_t) frame->eax;
56 
57  /*
58  * Check that pointer is inside the adress space
59  */
60  if (POK_CHECK_PTR_IN_PARTITION(syscall_info.partition, syscall_args) == 0)
61  {
62  syscall_ret = POK_ERRNO_EINVAL;
63  }
64  else
65  {
66  /*
67  * Perform the syscall baby !
68  */
69  syscall_ret = pok_core_syscall (syscall_id, syscall_args, &syscall_info);
70  }
71 
72  /*
73  * And finally, put the return value in eax register
74  */
75  asm ("movl %0, %%eax \n"
76  :
77  : "m" (syscall_ret));
78 }
79 
84 {
87  (uint32_t) syscall_gate,
89  3);
90 
91  return (POK_ERRNO_OK);
92 }
93