The Pedigree Project  0.1
KernelCoreSyscallManager.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "pedigree/kernel/processor/KernelCoreSyscallManager.h"
21 #include "pedigree/kernel/Log.h"
22 #include "pedigree/kernel/process/Scheduler.h"
23 #include "pedigree/kernel/processor/SyscallManager.h"
24 #include "pedigree/kernel/processor/Syscalls.h"
25 #include "pedigree/kernel/processor/state.h"
26 
28 
30 {
31 }
32 
34 {
35 }
36 
37 void KernelCoreSyscallManager::initialise()
38 {
39  for (int i = 0; i < 16; i++)
40  {
41  m_Functions[i] = 0;
42  }
44 }
45 
47  Function_t function, uintptr_t p1, uintptr_t p2, uintptr_t p3, uintptr_t p4,
48  uintptr_t p5)
49 {
50  // if (function >= serviceEnd)
51  // {
52  // ERROR("KernelCoreSyscallManager: invalid function called: " << Dec <<
53  // static_cast<int>(function)); return 0;
54  // }
56  kernelCore, function, p1, p2, p3, p4, p5);
57 }
58 
59 uintptr_t KernelCoreSyscallManager::syscall(SyscallState &state)
60 {
61  NOTICE("???");
62  switch (state.getSyscallNumber())
63  {
64  case yield:
65 #ifdef THREADS
67 #endif
68  return 0;
69  default:
70  {
71  if (state.getSyscallNumber() >= 16 ||
72  m_Functions[state.getSyscallNumber()] == 0)
73  {
74  ERROR(
75  "KernelCoreSyscallManager: invalid syscall received: "
76  << Dec << state.getSyscallNumber());
77  return 0;
78  }
79  else
80  {
81  return m_Functions[state.getSyscallNumber()](state);
82  }
83  }
84  }
85 }
86 
88  Function_t function, SyscallCallback func)
89 {
90  m_Functions[function] = func;
91  return 0;
92 }
static EXPORTED_PUBLIC SyscallManager & instance()
static KernelCoreSyscallManager m_Instance
virtual uintptr_t syscall(SyscallState &state)
uintptr_t registerSyscall(Function_t function, SyscallCallback func)
#define NOTICE(text)
Definition: Log.h:74
static Scheduler & instance()
Definition: Scheduler.h:48
#define ERROR(text)
Definition: Log.h:82
void yield()
Definition: Scheduler.cc:135
Definition: Log.h:138
virtual bool registerSyscallHandler(Service_t Service, SyscallHandler *pHandler)=0
virtual uintptr_t syscall(Service_t service, uintptr_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0)=0
uintptr_t call(Function_t function, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0, uintptr_t p5=0)