summaryrefslogtreecommitdiff
path: root/lib/mlibc/sysdeps/ironclad/include/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/sysdeps/ironclad/include/sys
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/sysdeps/ironclad/include/sys')
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/ironclad_devices.h44
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/mac.h46
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/mount.h24
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/ptrace.h23
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/reboot.h16
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/sched2.h24
-rw-r--r--lib/mlibc/sysdeps/ironclad/include/sys/syscall.h187
7 files changed, 364 insertions, 0 deletions
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/ironclad_devices.h b/lib/mlibc/sysdeps/ironclad/include/sys/ironclad_devices.h
new file mode 100644
index 0000000..74f47f8
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/ironclad_devices.h
@@ -0,0 +1,44 @@
+#ifndef _SYS_IRONCLAD_DEVICES_H
+#define _SYS_IRONCLAD_DEVICES_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <asm/ioctls.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PS2MOUSE_2_1_SCALING 1
+#define PS2MOUSE_1_1_SCALING 2
+#define PS2MOUSE_SET_RES 3
+#define PS2MOUSE_SET_SAMPLE_RATE 4
+
+struct ironclad_mouse_data {
+ int x_variation;
+ int y_variation;
+ bool is_left;
+ bool is_right;
+};
+
+#define RTC_RD_TIME 1
+#define RTC_SET_TIME 2
+
+struct rtc_time {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday; /* unused */
+ int tm_yday; /* unused */
+ int tm_isdst; /* unused */
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_IRONCLAD_DEVICES_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/mac.h b/lib/mlibc/sysdeps/ironclad/include/sys/mac.h
new file mode 100644
index 0000000..d4cf76d
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/mac.h
@@ -0,0 +1,46 @@
+#ifndef _SYS_MAC_H
+#define _SYS_MAC_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAC_CAP_SCHED 0b00000000001
+#define MAC_CAP_SPAWN 0b00000000010
+#define MAC_CAP_ENTROPY 0b00000000100
+#define MAC_CAP_SYS_MEM 0b00000001000
+#define MAC_CAP_USE_NET 0b00000010000
+#define MAC_CAP_SYS_NET 0b00000100000
+#define MAC_CAP_SYS_MNT 0b00001000000
+#define MAC_CAP_SYS_PWR 0b00010000000
+#define MAC_CAP_PTRACE 0b00100000000
+#define MAC_CAP_SETUID 0b01000000000
+#define MAC_CAP_SYS_MAC 0b10000000000
+#define MAC_CAP_CLOCK 0b100000000000
+#define MAC_CAP_SIGNALALL 0b1000000000000
+unsigned long get_mac_capabilities(void);
+int set_mac_capabilities(unsigned long request);
+
+#define MAC_PERM_CONTENTS 0b0000001
+#define MAC_PERM_READ 0b0000010
+#define MAC_PERM_WRITE 0b0000100
+#define MAC_PERM_EXEC 0b0001000
+#define MAC_PERM_APPEND 0b0010000
+#define MAC_PERM_FLOCK 0b0100000
+#define MAC_PERM_DEV 0b1000000
+int add_mac_permissions(const char *path, int flags);
+
+#define MAC_DENY 0b001
+#define MAC_DENY_AND_SCREAM 0b010
+#define MAC_KILL 0b100
+int set_mac_enforcement(unsigned long enforcement);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_MAC_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/mount.h b/lib/mlibc/sysdeps/ironclad/include/sys/mount.h
new file mode 100644
index 0000000..51263fa
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/mount.h
@@ -0,0 +1,24 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MNT_EXT 1
+#define MNT_FAT 2
+
+#define MS_RDONLY 0b001
+#define MS_REMOUNT 0b010
+#define MS_RELATIME 0b100
+
+#define MNT_FORCE 1
+
+int mount(const char *source, const char *target, int type, int flags);
+int umount(const char *target, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_MOUNT_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/ptrace.h b/lib/mlibc/sysdeps/ironclad/include/sys/ptrace.h
new file mode 100644
index 0000000..3993753
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/ptrace.h
@@ -0,0 +1,23 @@
+#ifndef _SYS_PTRACE_H
+#define _SYS_PTRACE_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PTRACE_ATTACH 1
+#define PTRACE_DETACH 2
+#define PTRACE_CONT 3
+#define PTRACE_SYSCALL 4
+#define PTRACE_GETREGS 5
+int ptrace(int request, pid_t pid, void *addr, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_PTRACE_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/reboot.h b/lib/mlibc/sysdeps/ironclad/include/sys/reboot.h
new file mode 100644
index 0000000..c2dbbf2
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/reboot.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+
+#include <abi-bits/reboot.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int reboot(int arg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_REBOOT_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/sched2.h b/lib/mlibc/sysdeps/ironclad/include/sys/sched2.h
new file mode 100644
index 0000000..caeb86a
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/sched2.h
@@ -0,0 +1,24 @@
+#ifndef _SYS_SCHED2_H
+#define _SYS_SCHED2_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define THREAD_RT 0b0001
+#define THREAD_MONO 0b0010
+#define THREAD_MLOCK 0b0100
+#define THREAD_BANNED 0b1000
+int get_thread_sched(void);
+int set_thread_sched(int flags);
+int set_deadlines(int runtime, int period);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SCHED2_H
diff --git a/lib/mlibc/sysdeps/ironclad/include/sys/syscall.h b/lib/mlibc/sysdeps/ironclad/include/sys/syscall.h
new file mode 100644
index 0000000..01ab016
--- /dev/null
+++ b/lib/mlibc/sysdeps/ironclad/include/sys/syscall.h
@@ -0,0 +1,187 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+#include <stddef.h>
+
+#define SYSCALL0(NUM) ({ \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL1(NUM, ARG0) ({ \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL2(NUM, ARG0, ARG1) ({ \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL3(NUM, ARG0, ARG1, ARG2) ({ \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL4(NUM, ARG0, ARG1, ARG2, ARG3) ({ \
+ register __typeof(ARG3) arg_r12 asm("r12") = ARG3; \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2), \
+ "r"(arg_r12) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL5(NUM, ARG0, ARG1, ARG2, ARG3, ARG4) ({ \
+ register __typeof(ARG3) arg_r12 asm("r12") = ARG3; \
+ register __typeof(ARG4) arg_r8 asm("r8") = ARG4; \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2), \
+ "r"(arg_r12), "r"(arg_r8) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL6(NUM, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5) ({ \
+ register __typeof(ARG3) arg_r12 asm("r12") = ARG3; \
+ register __typeof(ARG4) arg_r8 asm("r8") = ARG4; \
+ register __typeof(ARG5) arg_r9 asm("r9") = ARG5; \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2), \
+ "r"(arg_r12), "r"(arg_r8), "r"(arg_r9) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL6(NUM, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5) ({ \
+ register __typeof(ARG3) arg_r12 asm("r12") = ARG3; \
+ register __typeof(ARG4) arg_r8 asm("r8") = ARG4; \
+ register __typeof(ARG5) arg_r9 asm("r9") = ARG5; \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2), \
+ "r"(arg_r12), "r"(arg_r8), "r"(arg_r9) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL7(NUM, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) ({ \
+ register __typeof(ARG3) arg_r12 asm("r12") = ARG3; \
+ register __typeof(ARG4) arg_r8 asm("r8") = ARG4; \
+ register __typeof(ARG5) arg_r9 asm("r9") = ARG5; \
+ register __typeof(ARG6) arg_r10 asm("r10") = ARG6; \
+ asm volatile ("syscall" \
+ : "=a"(ret), "=d"(errno) \
+ : "a"(NUM), "D"(ARG0), "S"(ARG1), "d"(ARG2), \
+ "r"(arg_r12), "r"(arg_r8), "r"(arg_r9), "r"(arg_r10) \
+ : "rcx", "r11", "memory"); \
+})
+
+#define SYSCALL_EXIT 0
+#define SYSCALL_ARCH_PRCTL 1
+#define SYSCALL_OPEN 2
+#define SYSCALL_CLOSE 3
+#define SYSCALL_READ 4
+#define SYSCALL_WRITE 5
+#define SYSCALL_SEEK 6
+#define SYSCALL_MMAP 7
+#define SYSCALL_MUNMAP 8
+#define SYSCALL_GETPID 9
+#define SYSCALL_GETPPID 10
+#define SYSCALL_EXEC 11
+#define SYSCALL_CLONE 12
+#define SYSCALL_WAIT 13
+#define SYSCALL_SOCKET 14
+#define SYSCALL_SETHOSTNAME 15
+#define SYSCALL_UNLINK 16
+#define SYSCALL_STAT 17
+#define SYSCALL_GETCWD 18
+#define SYSCALL_CHDIR 19
+#define SYSCALL_IOCTL 20
+#define SYSCALL_SCHED_YIELD 21
+#define SYSCALL_DELETE_TCLUSTER 22
+#define SYSCALL_PIPE 23
+#define SYSCALL_GETUID 24
+#define SYSCALL_RENAME 25
+#define SYSCALL_SYSCONF 26
+#define SYSCALL_SPAWN 27
+#define SYSCALL_GETTID 28
+#define SYSCALL_MANAGE_TCLUSTER 29
+#define SYSCALL_FCNTL 30
+#define SYSCALL_EXIT_THREAD 31
+#define SYSCALL_GETRANDOM 32
+#define SYSCALL_MPROTECT 33
+#define SYSCALL_SYNC 34
+#define SYSCALL_SET_MAC_CAPABILITIES 35
+#define SYSCALL_GET_MAC_CAPABILITIES 36
+#define SYSCALL_ADD_MAC_PERMISSIONS 37
+#define SYSCALL_SET_MAC_ENFORCEMENT 38
+#define SYSCALL_MOUNT 39
+#define SYSCALL_UMOUNT 40
+#define SYSCALL_READLINK 41
+#define SYSCALL_GETDENTS 42
+#define SYSCALL_MAKENODE 43
+#define SYSCALL_TRUNCATE 44
+#define SYSCALL_BIND 45
+#define SYSCALL_SYMLINK 46
+#define SYSCALL_CONNECT 47
+#define SYSCALL_OPENPTY 48
+#define SYSCALL_FSYNC 49
+#define SYSCALL_LINK 50
+#define SYSCALL_PTRACE 51
+#define SYSCALL_LISTEN 52
+#define SYSCALL_ACCEPT 53
+#define SYSCALL_GETRLIMIT 54
+#define SYSCALL_SETRLIMIT 55
+#define SYSCALL_ACCESS 56
+#define SYSCALL_POLL 57
+#define SYSCALL_GETEUID 58
+#define SYSCALL_SETUIDS 59
+#define SYSCALL_FCHMOD 60
+#define SYSCALL_UMASK 61
+#define SYSCALL_REBOOT 62
+#define SYSCALL_FCHOWN 63
+#define SYSCALL_PREAD 64
+#define SYSCALL_PWRITE 65
+#define SYSCALL_GETSOCKNAME 66
+#define SYSCALL_GETPEERNAME 67
+#define SYSCALL_SHUTDOWN 68
+#define SYSCALL_FUTEX 69
+#define SYSCALL_CLOCK 70
+#define SYSCALL_CLOCK_NANOSLEEP 71
+#define SYSCALL_GETRUSAGE 72
+#define SYSCALL_RECVFROM 73
+#define SYSCALL_SENDTO 74
+#define SYSCALL_CONFIG_NETINTER 75
+#define SYSCALL_UTIMES 76
+#define SYSCALL_CREATE_TCLUSTER 77
+#define SYSCALL_SWITCH_TCLUSTER 78
+#define SYSCALL_ACTUALLY_KILL 79
+#define SYSCALL_SIGNALPOST 80
+#define SYSCALL_SEND_SIGNAL 81
+#define SYSCALL_GETPRIO 82
+#define SYSCALL_SETPRIO 83
+#define SYSCALL_GETGID 84
+#define SYSCALL_GETEGID 85
+#define SYSCALL_SETGIDS 86
+#define SYSCALL_GETGROUPS 87
+#define SYSCALL_SETGROUPS 88
+#define SYSCALL_TTYNAME 89
+#define SYSCALL_FADVISE 90
+#define SYSCALL_SHMAT 91
+#define SYSCALL_SHMCTL 92
+#define SYSCALL_SHMDT 93
+#define SYSCALL_SHMGET 94
+#define SYSCALL_GETSOCKOPT 95
+#define SYSCALL_SETSOCKOPT 96
+#define SYSCALL_GETTIDID 97
+#define SYSCALL_SETTIDID 98
+
+#endif // _SYS_SYSCALL_H