summaryrefslogtreecommitdiffhomepage
path: root/dev/libSystem/SystemKit
diff options
context:
space:
mode:
Diffstat (limited to 'dev/libSystem/SystemKit')
-rw-r--r--dev/libSystem/SystemKit/Jail.h18
-rw-r--r--dev/libSystem/SystemKit/Macros.h2
-rw-r--r--dev/libSystem/SystemKit/Syscall.h24
-rw-r--r--dev/libSystem/SystemKit/System.h8
4 files changed, 41 insertions, 11 deletions
diff --git a/dev/libSystem/SystemKit/Jail.h b/dev/libSystem/SystemKit/Jail.h
index 998173f9..c23942c5 100644
--- a/dev/libSystem/SystemKit/Jail.h
+++ b/dev/libSystem/SystemKit/Jail.h
@@ -9,7 +9,8 @@
#include <libSystem/SystemKit/System.h>
/// @file Jail.h
-/// @brief NeKernel Jail System
+/// @author Amlal El Mahrouss
+/// @brief NeKernel Jail System, part of OpenEnclave.
struct JAIL_INFO;
struct JAIL;
@@ -19,4 +20,17 @@ struct JAIL_INFO {
SInt32 fParentID;
SInt32 fJailHash;
SInt64 fACL;
-}; \ No newline at end of file
+};
+
+/// @brief Jail information (we grab a JAIL from JailGetCurrent())
+struct JAIL {
+ struct JAIL_INFO* fServer;
+ struct JAIL_INFO* fClient;
+ SInt32 fJailHash;
+ SInt32 fParentID;
+ SInt64 fACL;
+};
+
+/// @brief Get the current jail
+/// @return Pointer to the current jail structure, or NULL if not in a jail
+IMPORT_C struct JAIL* JailGetCurrent(Void);
diff --git a/dev/libSystem/SystemKit/Macros.h b/dev/libSystem/SystemKit/Macros.h
index 2bdeff9d..25bc77ba 100644
--- a/dev/libSystem/SystemKit/Macros.h
+++ b/dev/libSystem/SystemKit/Macros.h
@@ -94,7 +94,7 @@ typedef nullPtr NullPtr;
#endif
#ifndef kib_cast
-#define kib_cast(X) (UInt64)((X) *1024)
+#define kib_cast(X) (UInt64)((X) * 1024)
#endif
#ifndef MIB
diff --git a/dev/libSystem/SystemKit/Syscall.h b/dev/libSystem/SystemKit/Syscall.h
index 436665ae..a1505b46 100644
--- a/dev/libSystem/SystemKit/Syscall.h
+++ b/dev/libSystem/SystemKit/Syscall.h
@@ -9,11 +9,27 @@
#include <libSystem/SystemKit/System.h>
#include <cstdarg>
-#ifndef SYSCALL_HASH
-#define SYSCALL_HASH(str) (UInt64) str
-#endif // !SYSCALL_HASH
-
IMPORT_C VoidPtr libsys_syscall_arg_1(SizeT id);
IMPORT_C VoidPtr libsys_syscall_arg_2(SizeT id, VoidPtr arg1);
IMPORT_C VoidPtr libsys_syscall_arg_3(SizeT id, VoidPtr arg1, VoidPtr arg3);
IMPORT_C VoidPtr libsys_syscall_arg_4(SizeT id, VoidPtr arg1, VoidPtr arg3, VoidPtr arg4);
+
+inline UInt64 libsys_hash_64(const Char* path) {
+ if (!path || *path == 0) return 0;
+
+ const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL;
+ const UInt64 FNV_PRIME = 0x100000001b3ULL;
+
+ UInt64 hash = FNV_OFFSET_BASIS;
+
+ while (*path) {
+ hash ^= (Char) (*path++);
+ hash *= FNV_PRIME;
+ }
+
+ return hash;
+}
+
+#ifndef SYSCALL_HASH
+#define SYSCALL_HASH(str) libsys_hash_64(str)
+#endif // !SYSCALL_HASH \ No newline at end of file
diff --git a/dev/libSystem/SystemKit/System.h b/dev/libSystem/SystemKit/System.h
index 421868ae..f46fe523 100644
--- a/dev/libSystem/SystemKit/System.h
+++ b/dev/libSystem/SystemKit/System.h
@@ -12,6 +12,10 @@ Purpose: System Call Interface.
#include <libSystem/SystemKit/Macros.h>
+/// @brief TTY device path.
+#define kPrintDevicePath "/devices/tty{}"
+#define kCDDevicePath "/devices/dvd{}"
+
// ------------------------------------------------------------------------------------------ //
/// @brief Types API.
// ------------------------------------------------------------------------------------------ //
@@ -309,8 +313,6 @@ IMPORT_C SInt32 PwrSendCode(_Output SInt32& code);
// CD-ROM API.
// ------------------------------------------------------------------------------------------ //
-#define kCDDevicePath "/devices/dvd{}"
-
IMPORT_C IORef CdOpenTray(Void);
IMPORT_C SInt32 CdEjectDrive(_Input IORef cdrom);
@@ -321,8 +323,6 @@ IMPORT_C SInt32 CdCloseTray(Void);
// TTY API.
// ------------------------------------------------------------------------------------------ //
-#define kPrintDevicePath "/devices/tty{}"
-
IMPORT_C SInt32 PrintOut(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...);
IMPORT_C SInt32 PrintIn(IORef file /* nullptr to direct to stdout */, const Char* fmt, ...);