summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/TODO4
-rw-r--r--include/bootabi/bootparam.h60
-rw-r--r--include/bootabi/efi.h454
-rw-r--r--include/elf.h228
-rw-r--r--include/limits.h83
-rw-r--r--include/stddef.h46
-rw-r--r--include/stdint.h71
-rw-r--r--include/string.h39
8 files changed, 985 insertions, 0 deletions
diff --git a/include/TODO b/include/TODO
new file mode 100644
index 0000000..a845564
--- /dev/null
+++ b/include/TODO
@@ -0,0 +1,4 @@
+* elf.h has lots of missing definitions
+* stdint.h and stddef.h are missing a 32 bit zarch check
+* LOTS of testing needs to happen with various architectures
+* everything is missing the "extern C" bit that allows for C++
diff --git a/include/bootabi/bootparam.h b/include/bootabi/bootparam.h
new file mode 100644
index 0000000..0ec28d9
--- /dev/null
+++ b/include/bootabi/bootparam.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef SYS_BOOTPARAM_H
+#define SYS_BOOTPARAM_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#define FIRMWARE_UEFI 1
+#define FIRMWARE_OSBI 2
+
+#define MAX_CMDLINE_SIZE 1024
+
+#define BOOTPARAM_MAGIC 0x424F4F54 // "BOOT"
+
+enum mem_type {
+ MEM_USABLE,
+ MEM_IO,
+ MEM_ACPI,
+ MEM_ACPI_RECLAIM,
+ MEM_PERSIST,
+ MEM_FIRMWARE,
+};
+
+typedef struct mmap_entry {
+ uint8_t mem_type;
+ uint64_t num_pages;
+ uintptr_t start;
+ struct mmap_entry *next;
+} mmap_entry_t;
+
+typedef struct bootparam {
+ uint32_t magic;
+ uint32_t firmware_id;
+ void *stack_ptr;
+ void *heap_ptr;
+ void *firmware_params;
+ uint32_t num_mmap_entries;
+ mmap_entry_t *mmap;
+ char cmdline[MAX_CMDLINE_SIZE];
+} bootparam_t;
+
+#endif
diff --git a/include/bootabi/efi.h b/include/bootabi/efi.h
new file mode 100644
index 0000000..9db688d
--- /dev/null
+++ b/include/bootabi/efi.h
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef BOOTABI_EFI_H
+#define BOOTABI_EFI_H
+
+#include <stdint.h>
+#include <uchar.h>
+#include <limits.h>
+
+#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
+#define EFI_OPEN_PROTOCOL_BY_GET_PROTOCOL 0x00000002
+#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
+#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
+#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
+#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
+
+#define EFI_TRUE 1
+#define EFI_FALSE 0
+
+typedef struct efi_guid {
+ uint32_t data1;
+ uint16_t data2;
+ uint16_t data3;
+ uint8_t data4[8];
+} efi_guid_t;
+
+static const efi_guid_t EFI_FILE_INFO_ID = {0x09576E92, 0x6D3F, 0x11D2, {0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}};
+static const efi_guid_t EFI_LOAD_FILE_PROTOCOL_ID = {0x5B1B31A1, 0x9562, 0x11D2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}};
+static const efi_guid_t EFI_DEVICE_PATH_PROTOCOL_ID = {0x09576E91, 0x6D3F, 0x11D2, {0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}};
+static const efi_guid_t EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_ID = {0x0964E5B22, 0x6459, 0x11D2, {0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}};
+static const efi_guid_t EFI_LOADED_IMAGE_PROTOCOL_ID = {0x5B1B31A1, 0x9562, 0x11d2, {0x8E,0x3F,0x00,0xA0,0xC9,0x69,0x72,0x3B}};
+static const efi_guid_t EFI_GRAPHICS_OUTPUT_PROTOCOL_ID = {0x9042A9DE, 0x23DC, 0x4A38, {0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A}};
+
+typedef struct efi_time {
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t PAD0;
+ uint32_t nsecond;
+ uint16_t time_zone;
+ uint8_t dst;
+ uint8_t PAD1;
+} efi_time_t;
+
+typedef struct efi_time_cap {
+ uint32_t resolution;
+ uint32_t accuracy;
+ uint8_t set_to_zero;
+} efi_time_cap_t;
+
+enum efi_alloc_type {
+ AllocateAnyPages,
+ AllocateMaxAddress,
+ AllocateAddress,
+ MaxAllocateType,
+};
+
+enum efi_memory_type {
+ ReservedMemory,
+ LoaderCode,
+ LoaderData,
+ BootSrvCode,
+ BootSrvData,
+ RuntimeSrvCode,
+ RuntimeSrvData,
+ ConventionalMemory,
+ UnusableMemory,
+ ACPIReclaimMemory,
+ ACPIMemoryNVS,
+ MemoryMappedIO,
+ MemoryMappedIOPortSpace,
+ PalCode,
+ PersistentMemory,
+ UnacceptedMemory,
+ MaxMemory,
+};
+
+#define EFIERR(X) ((uint64_t)(0x8000000000000000 | (X)))
+
+enum efi_status {
+ EFI_SUCCESS,
+ EFI_LOAD_ERROR,
+ EFI_INVALID_PARAMETER,
+ EFI_UNSUPPORTED,
+ EFI_BAD_BUFFER_SIZE,
+ EFI_BUFFER_TOO_SMALL,
+ EFI_NOT_READY,
+ EFI_DEVICE_ERROR,
+ EFI_WRITE_PROTECTED,
+ EFI_OUT_OF_RESOURCES,
+ EFI_VOLUME_CORRUPTED,
+ EFI_VOLUME_FULL,
+ EFI_NO_MEDIA,
+ EFI_MEDIA_CHANGED,
+ EFI_NOT_FOUND,
+ EFI_ACCESS_DENIED,
+ EFI_NO_RESPONSE,
+ EFI_NO_MAPPING,
+ EFI_TIMEOUT,
+ EFI_NOT_STARTED,
+ EFI_ALREADY_STARTED,
+ EFI_ABORTED,
+ EFI_ICMP_ERROR,
+ EFI_TFTP_ERROR,
+ EFI_PROTOCOL_ERROR,
+ EFI_INCOMPATIBLE_VERSION,
+ EFI_SECURITY_VIOLATION,
+ EFI_CRC_ERROR,
+ EFI_END_OF_MEDIA,
+ EFI_END_OF_FILE,
+ EFI_INVALID_LANGUAGE,
+ EFI_COMPROMISED_DATA,
+ EFI_IP_ADDRESS_CONFLICT,
+ EFI_HTTP_ERROR,
+};
+
+static char* efi_status_str[] = {
+ "Success",
+ "Load error",
+ "Invalid parameter",
+ "Unsupported operation",
+ "Bad buffer size",
+ "Buffer too small",
+ "Not ready",
+ "Device error",
+ "Write protected",
+ "Out of resources",
+ "Volume corrupted",
+ "Volume full",
+ "No media",
+ "Media changed",
+ "Not found",
+ "Access denied",
+ "No response",
+ "No mapping",
+ "Operation timeout",
+ "Operation not started",
+ "Operation already started",
+ "Operation aborted",
+ "ICMP error",
+ "TFTP error",
+ "Protocol error",
+ "Incompatible version",
+ "Security violation",
+ "Checksum error",
+ "End of media",
+ "End of file",
+ "Invalid language",
+ "Compressed data",
+ "IP conflict",
+ "HTTP error"
+};
+
+enum efi_reset_type {
+ EFI_RESET_COLD,
+ EFI_RESET_WARM,
+ EFI_RESET_SHUTDOWN,
+ EFI_RESET_PFORM_SPECIFIC,
+};
+
+typedef struct efi_memory_descriptor {
+ uint32_t type;
+ uintptr_t physical_start;
+ uintptr_t virtual_start;
+ uint64_t num_pages;
+ uint64_t attribute;
+} efi_memory_descriptor_t;
+
+typedef struct efi_input_key {
+ uint16_t scancode;
+ uint16_t unicode;
+} efi_input_key_t;
+
+typedef struct efi_text_input {
+ uint64_t (*read_key_stroke)(struct efi_text_input *this, efi_input_key_t *key);
+ void *wait_for_key;
+} efi_text_input_t;
+
+typedef struct efi_text_output_mode {
+ int32_t max_mode;
+ int32_t mode;
+ int32_t attribute;
+ int32_t cursor_x;
+ int32_t cursor_y;
+ uint8_t cursor_enable;
+} efi_text_output_mode_t;
+
+typedef struct efi_text_output {
+ uint64_t (*reset)(struct efi_text_output*, uint8_t);
+ uint64_t (*output_str)(struct efi_text_output*, char16_t*);
+ uint64_t (*test_string)(struct efi_text_output*, char16_t*);
+ uint64_t (*query_mode)(struct efi_text_output*, uint64_t);
+ uint64_t (*set_mode)(struct efi_text_output*, uint64_t);
+ uint64_t (*set_attribute)(struct efi_text_output*, uint64_t);
+ uint64_t (*clear_screen)(struct efi_text_output*);
+ uint64_t (*set_cursor)(struct efi_text_output*, uint64_t, uint64_t);
+ uint64_t (*enable_cursor)(struct efi_text_output*, uint8_t);
+ efi_text_output_mode_t *mode;
+} efi_text_output_t;
+
+typedef struct efi_device_path {
+ uint8_t type;
+ uint8_t sub_type;
+ uint8_t length[2];
+} efi_device_path_t;
+
+typedef struct efi_protocol_entry {
+ void *agent_handle;
+ void *controller_handle;
+ uint32_t attributes;
+ uint32_t count;
+} efi_protocol_entry_t;
+
+typedef struct efi_cap_hdr {
+ efi_guid_t cap_guid;
+ uint32_t header_sz;
+ uint32_t flags;
+ uint32_t cap_sz;
+} efi_cap_hdr_t;
+
+#define EFI_FILE_MODE_READ (1 << 0)
+#define EFI_FILE_MODE_WRITE (2 << 0)
+#define EFI_FILE_MODE_CREATE (8 << 60)
+
+#define EFI_FILE_READ_ONLY (1 << 0)
+#define EFI_FILE_HIDDEN (2 << 0)
+#define EFI_FILE_SYSTEM (4 << 0)
+#define EFI_FILE_RESERVED (8 << 0)
+#define EFI_FILE_DIRECTORY (1 << 4)
+#define EFI_FILE_ARCHIVE (2 << 4)
+#define EFI_FILE_VALID_ATTR (55 << 0)
+
+#define FILENAME_MAX 255
+
+typedef struct efi_file_io_token {
+ void *event;
+ uint64_t status;
+ uint64_t bufsz;
+ void *buffer;
+} efi_file_io_token_t;
+
+typedef struct efi_file_protocol {
+ uint64_t revision;
+ uint64_t (*open)(struct efi_file_protocol*, struct efi_file_protocol**, char16_t*, uint64_t, uint64_t);
+ uint64_t (*close)(struct efi_file_protocol*);
+ uint64_t (*deletef)(struct efi_file_protocol*);
+ uint64_t (*read)(struct efi_file_protocol*, uint64_t*, void*);
+ uint64_t (*write)(struct efi_file_protocol*, uint64_t*, void*);
+ uint64_t (*get_position)(struct efi_file_protocol*, uint64_t*);
+ uint64_t (*set_position)(struct efi_file_protocol*, uint64_t);
+ uint64_t (*get_info)(struct efi_file_protocol*, efi_guid_t*, uint64_t*, void*);
+ uint64_t (*set_info)(struct efi_file_protocol*, efi_guid_t*, uint64_t, void*);
+ uint64_t (*flush)(struct efi_file_protocol*);
+ uint64_t (*open_ex)(struct efi_file_protocol*, struct efi_file_protocol**, char16_t*, uint64_t, uint64_t, efi_file_io_token_t*);
+ uint64_t (*read_ex)(struct efi_file_protocol*, efi_file_io_token_t*);
+ uint64_t (*write_ex)(struct efi_file_protocol*, efi_file_io_token_t*);
+ uint64_t (*flush_ex)(struct efi_file_protocol*, efi_file_io_token_t*);
+} efi_file_protocol_t;
+
+typedef struct efi_file_info {
+ uint64_t size;
+ uint64_t file_size;
+ uint64_t phys_size;
+ efi_time_t ctime;
+ efi_time_t atime;
+ efi_time_t mtime;
+ uint64_t attribute;
+ uint16_t filename[FILENAME_MAX];
+} efi_file_info_t;
+
+typedef struct efi_simple_file_system_protocol {
+ uint32_t revision;
+ uint64_t (*open_volume)(void*, efi_file_protocol_t**);
+} efi_simple_file_system_protocol_t;
+
+typedef struct efi_table_hdr {
+ uint64_t signature;
+ uint32_t revision;
+ uint32_t header_sz;
+ uint32_t crc32;
+ uint32_t RESERVED;
+} efi_table_hdr_t;
+
+typedef struct efi_runtime {
+ efi_table_hdr_t header;
+ uint64_t (*gettime)(efi_time_t*, efi_time_cap_t*);
+ uint64_t (*settime)(efi_time_t*);
+ uint64_t (*getwaketime)(uint8_t*, uint8_t*, efi_time_t*);
+ uint64_t (*setwaketime)(uint8_t, efi_time_t*);
+ uint64_t (*setvmap)(uint64_t, uint64_t, uint32_t, efi_memory_descriptor_t*);
+ uint64_t (*convert_pointer)(uint64_t, void**);
+ uint64_t (*getvar)(uint16_t*, efi_guid_t*, uint32_t*, uint64_t*, void*);
+ uint64_t (*getnextvar)(uint64_t*, uint16_t*, efi_guid_t*);
+ uint64_t (*setvar)(uint16_t*, efi_guid_t*, uint32_t, uint64_t, void*);
+ uint64_t (*gethimon)(uint64_t*);
+ uint64_t (*reset_system)(int, uint64_t, uint64_t, uint16_t*);
+ uint64_t (*update_cap)(efi_cap_hdr_t**, uint64_t, uintptr_t);
+ uint64_t (*query_cap)(efi_cap_hdr_t**, uint64_t, uint64_t*, int*);
+ uint64_t (*query_var)(uint32_t, uint64_t*, uint64_t*, uint64_t*);
+} efi_runtime_t;
+
+typedef struct efi_boot {
+ efi_table_hdr_t header;
+ uint64_t (*raise_tpl)(uint64_t);
+ uint64_t (*restore_tpl)(uint64_t);
+ uint64_t (*allocate_pages)(int, int, uint64_t, uintptr_t*);
+ uint64_t (*free_pages)(uintptr_t, uint64_t);
+ uint64_t (*get_memory_map)(uint64_t*, efi_memory_descriptor_t*, uint64_t*, uint64_t*, uint32_t*);
+ uint64_t (*allocate_pool)(int, uint64_t, void**);
+ uint64_t (*free_pool)(void*);
+ uint64_t (*create_event)(uint32_t, uint64_t, void*, void*, void*);
+ uint64_t (*set_timer)(void*, int, uint64_t);
+ uint64_t (*wait_event)(uint64_t, void*, uint64_t*);
+ uint64_t (*signal_event)(void*);
+ uint64_t (*close_event)(void*);
+ uint64_t (*check_event)(void*);
+ void *install_protocol_interface;
+ void *reinstall_protocol_interface;
+ void *uninstall_protocol_interface;
+ uint64_t (*handle_protocol)(void**, const efi_guid_t*, void**);
+ uint64_t (*pc_handle_protocol)(void**, const efi_guid_t*, void**);
+ uint64_t (*register_protocol)(efi_guid_t*, void*, void**);
+ uint64_t (*locate_handle)(int, efi_guid_t*, void*, uint64_t*, void**);
+ uint64_t (*locate_device_path)(efi_guid_t*, efi_device_path_t**, void**);
+ uint64_t (*install_cfg_table)(efi_guid_t*, void*);
+ uint64_t (*load_image)(uint8_t, void*, efi_device_path_t*, void*, uint64_t, void**);
+ uint64_t (*start_image)(void*, uint64_t*, uint16_t**);
+ uint64_t (*exit)(void*, uint64_t, uint64_t, uint16_t*);
+ uint64_t (*unload_image)(void);
+ uint64_t (*exit_boot_services)(void*, uint64_t);
+ uint64_t (*gethimon)(uint64_t*);
+ uint64_t (*stall)(uint64_t);
+ uint64_t (*setwatchdog)(uint64_t, uint64_t, uint64_t, uint16_t*);
+ uint64_t (*connect_cont)(void*, void**, efi_device_path_t*, uint8_t);
+ uint64_t (*disconnect_cont)(void*, void*, void*);
+ uint64_t (*open_protocol)(void*, efi_guid_t*, void**, void*, void*, uint32_t);
+ uint64_t (*close_protocol)(void*, efi_guid_t*, void*, void*);
+ uint64_t (*open_protocol_info)(void*, efi_guid_t*, efi_protocol_entry_t**, uint64_t*);
+ uint64_t (*protocols_per_handle)(void*, efi_guid_t***, uint64_t*);
+ uint64_t (*locate_handle_buffer)(int, efi_guid_t*, void*, uint64_t*, void***);
+ uint64_t (*locate_protocol)(efi_guid_t*, void*, void**);
+ void *install_many_protocols;
+ void *uninstall_many_protocols;
+ uint64_t (*calc_crc32)(void*, uint64_t, uint32_t*);
+} efi_boot_t;
+
+typedef struct efi_system {
+ efi_table_hdr_t header;
+ uint16_t *firmware_vendor;
+ uint32_t firmware_revision;
+ void *console_in_handle;
+ efi_text_input_t *console_in;
+ void *console_out_handle;
+ efi_text_output_t *console_out;
+ void *console_err_handle;
+ efi_text_output_t *console_err;
+ efi_runtime_t *runtime;
+ efi_boot_t *bootsrv;
+ uint64_t num_entries;
+ void *config_table;
+} efi_system_t;
+
+typedef struct efi_load_file_protocol {
+ uint64_t (*load_file)(struct efi_load_file_protocol*, efi_device_path_t*, uint8_t, uint64_t, void*);
+} efi_load_file_protocol_t;
+
+typedef struct efi_loaded_image_protocol {
+ uint64_t revision;
+ void *parent_handle;
+ efi_system_t *system_table;
+ void *device_handle;
+ uint16_t *file_path;
+ void *RESERVED;
+ uint32_t options_size;
+ void *options;
+ void *image_base;
+ uint64_t image_size;
+ uint64_t image_code_type;
+ uint64_t image_data_type;
+} efi_loaded_image_protocol_t;
+
+typedef struct efi_pixel_bitmask {
+ uint32_t red;
+ uint32_t green;
+ uint32_t blue;
+ uint32_t alpha;
+} efi_pixel_bitmask_t;
+
+enum efi_gop_pixel_format {
+ RGBA8,
+ BGRA8,
+ BIT_MASK,
+ BIT_ONLY,
+ FORMAT_MAX,
+};
+
+typedef struct efi_gop_info {
+ uint32_t version;
+ uint32_t width;
+ uint32_t height;
+ enum efi_gop_pixel_format format;
+ efi_pixel_bitmask_t pixel_info;
+ uint32_t pixels_per_scaline;
+} efi_gop_info_t;
+
+typedef struct efi_gop_mode {
+ uint32_t max_mode;
+ uint32_t mode;
+ efi_gop_info_t *info;
+ uint64_t info_sz;
+ uintptr_t fb_base;
+ uint64_t fb_sz;
+} efi_gop_mode_t;
+
+typedef struct efi_gop {
+ uint64_t (*query_mode)();
+ uint64_t (*set_mode)();
+ uint64_t (*blt)();
+ efi_gop_mode_t *mode;
+} efi_gop_t;
+
+typedef struct efi_bootparam {
+ efi_system_t *st;
+ efi_memory_descriptor_t *mmap;
+ uint64_t mmap_size;
+ uint64_t mmap_key;
+ uint64_t mmap_dsize;
+ efi_gop_mode_t* gop_mode;
+} efi_bootparam_t;
+
+uint64_t efi_abi_wrapper(void *efi_func, ...);
+uint64_t sysv_abi_wrapper(void *sysv_func, ...);
+
+#endif
diff --git a/include/elf.h b/include/elf.h
new file mode 100644
index 0000000..6ffcf5d
--- /dev/null
+++ b/include/elf.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef ELF_H
+#define ELF_H
+
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+
+#include <stdint.h>
+
+#define EI_NIDENT (16)
+
+#define ELF_MAGIC "\177ELF"
+
+#define EI_CLASS 4
+#define ELFCLASSNONE 0
+#define ELFCLASS32 1
+#define ELFCLASS64 2
+#define ELFCLASSNUM 3
+
+#define EI_DATA 5
+#define ELFDATANONE 0
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+#define ELFDATANUM 3
+
+#define ELFOSABI_SYSV 0
+#define ELFOSABI_HPUX 1
+#define ELFOSABI_NETBSD 2
+#define ELFOSABI_LINUX 3
+#define ELFOSABI_SOLARIS 6
+#define ELFOSABI_AIX 7
+#define ELFOSABI_IRIX 8
+#define ELFOSABI_FREEBSD 9
+#define ELFOSABI_OPENBSD 12
+#define ELFOSABI_ARM_AEABI 64
+#define ELFOSABI_ARM 97
+#define ELFOSABI_STANDALONE 255
+
+#define ET_NONE 0
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+#define ET_NUM 5
+#define ET_LOOS 0xFE00
+#define ET_HIOS 0xFEFF
+#define ET_LOPROC 0xFF00
+#define ET_HIPROC 0xFFFF
+
+#define EM_NONE 0
+#define EM_M32 1
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_68K 4
+#define EM_88K 5
+#define EM_IAMCU 6
+#define EM_860 7
+#define EM_MIPS 8
+#define EM_S370 9
+#define EM_MIPS_RS3_LE 10
+#define EM_PARISC 15
+#define EM_VPP500 17
+#define EM_SPARC32PLUS 18
+#define EM_960 19
+#define EM_PPC 20
+#define EM_PPC64 21
+#define EM_S390 22
+#define EM_SPU 23
+#define EM_V800 36
+#define EM_FR20 37
+#define EM_RH32 38
+#define EM_RCE 39
+#define EM_ARM 40
+#define EM_FAKE_ALPHA 41
+#define EM_SH 42
+#define EM_SPARCV9 43
+#define EM_TRICORE 44
+#define EM_ARC 45
+#define EM_H8_300 46
+#define EM_H8_300H 47
+#define EM_H8S 48
+#define EM_H8_500 49
+#define EM_IA_64 50
+#define EM_MIPS_X 51
+// TODO: the rest of these
+#define EM_X86_64 62
+#define EM_AARCH64 183
+#define EM_RISCV 243
+
+#define PT_NULL 0
+#define PT_LOAD 1
+#define PT_DYNAMIC 2
+#define PT_INTERP 3
+#define PT_NOTE 4
+#define PT_SHLIB 5
+#define PT_PHDR 6
+#define PT_TLS 7
+#define PT_NUM 8
+#define PT_LOOS 0x60000000
+#define PT_GNU_EH_FRAME 0x6474e550
+#define PT_GNU_STACK 0x6474e551
+#define PT_GNU_RELRO 0x6474e552
+#define PT_GNU_PROPERTY 0x6474e553
+#define PT_GNU_SFRAME 0x6474e554
+
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JUMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+#define R_X86_64_DTPMOD64 16
+#define R_X86_64_DTPOFF64 17
+#define R_X86_64_TPOFF64 18
+#define R_X86_64_TLSGD 19
+#define R_X86_64_TLSLD 20
+#define R_X86_64_DTPOFF32 21
+#define R_X86_64_GOTTPOFF 22
+#define R_X86_64_TPOFF32 23
+#define R_X86_64_PC64 24
+#define R_X86_64_GOTOFF64 25
+#define R_X86_64_GOTPC32 26
+#define R_X86_64_GOT64 27
+#define R_X86_64_GOTPCREL64 28
+#define R_X86_64_GOTPC64 29
+#define R_X86_64_GOTPLT64 30
+#define R_X86_64_PLTOFF64 31
+#define R_X86_64_SIZE32 32
+#define R_X86_64_SIZE64 33
+// TODO
+#define R_X86_64_NUM 43
+
+typedef struct {
+ uint8_t e_ident[16];
+ uint16_t e_type;
+ uint16_t e_machine;
+ uint32_t e_version;
+ uint32_t e_entry;
+ uint32_t e_phoff;
+ uint32_t e_shoff;
+ uint32_t e_flags;
+ uint16_t e_ehsize;
+ uint16_t e_phentsize;
+ uint16_t e_phnum;
+ uint16_t e_shentsize;
+ uint16_t e_shnum;
+ uint16_t e_shstrndx;
+} Elf32_Ehdr;
+
+typedef struct {
+ uint8_t e_ident[16];
+ uint16_t e_type;
+ uint16_t e_machine;
+ uint32_t e_version;
+ uint64_t e_entry;
+ uint64_t e_phoff;
+ uint64_t e_shoff;
+ uint32_t e_flags;
+ uint16_t e_ehsize;
+ uint16_t e_phentsize;
+ uint16_t e_phnum;
+ uint16_t e_shentsize;
+ uint16_t e_shnum;
+ uint16_t e_shstrndx;
+} Elf64_Ehdr;
+
+typedef struct {
+ uint32_t p_type;
+ uint32_t p_flags;
+ uint32_t p_offset;
+ uint32_t p_vaddr;
+ uint32_t p_paddr;
+ uint32_t p_filesz;
+ uint32_t p_memsz;
+ uint32_t p_align;
+} Elf32_Phdr;
+
+typedef struct {
+ uint32_t p_type;
+ uint32_t p_flags;
+ uint64_t p_offset;
+ uint64_t p_vaddr;
+ uint64_t p_paddr;
+ uint64_t p_filesz;
+ uint64_t p_memsz;
+ uint64_t p_align;
+} Elf64_Phdr;
+
+typedef struct {
+ uint32_t r_offset;
+ uint32_t r_info;
+} Elf32_Rel;
+
+typedef struct {
+ uint64_t r_offset;
+ uint64_t r_info;
+} Elf64_Rel;
+
+#endif
diff --git a/include/limits.h b/include/limits.h
new file mode 100644
index 0000000..6ee065d
--- /dev/null
+++ b/include/limits.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIMITS_H
+#define LIMITS_H
+
+#define CHAR_BIT 8
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+#define UCHAR_MAX 255
+
+#define CHAR_MIN SCHAR_MIN
+#define CHAR_MAX SCHAR_MAX
+
+#define SHRT_MIN (-32768)
+#define SHRT_MAX 32767
+#define USHRT_MAX 65535
+
+#define INT_MIN (-2147483648)
+#define INT_MAX 2147483647
+#define UINT_MAX 4294967295U
+
+#define LONG_MIN (-9223372036854775808L)
+#define LONG_MAX 9223372036854775807L
+#define ULONG_MAX 18446744073709551615UL
+
+#define FLT_RADIX 2
+#define FLT_MANT_DIG 24
+#define FLT_DIG 6
+#define FLT_MIN 1.175494351e-38F
+#define FLT_MAX 3.402823466e+38F
+
+#define DBL_MANT_DIG 53
+#define DBL_DIG 15
+#define DBL_MIN 2.2250738585072014e-308
+#define DBL_MAX 1.7976931348623157e+308
+
+#define INT8_MIN (-1-0x7F)
+#define INT16_MIN (-1-0x7FFF)
+#define INT32_MIN (-1-0x7FFFFFFF)
+#define INT64_MIN (-1-0x7FFFFFFFFFFFFFFF)
+
+#define INT8_MAX (0x7F)
+#define INT16_MAX (0x7FFF)
+#define INT32_MAX (0x7FFFFFFF)
+#define INT64_MAX (0x7FFFFFFFFFFFFFFF)
+
+#define UINT8_MAX (0xFF)
+#define UINT16_MAX (0xFFFF)
+#define UINT32_MAX (0xFFFFFFFF)
+#define UINT64_MAX (0xFFFFFFFFFFFFFFFF)
+
+#define INTPTR_MAX INT64_MAX
+#define UINTPTR_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST64_MIN INT64_MIN
+
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST64_MAX INT64_MAX
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST64_MIN INT64_MIN
+
+#endif
diff --git a/include/stddef.h b/include/stddef.h
new file mode 100644
index 0000000..f391a3a
--- /dev/null
+++ b/include/stddef.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef STDDEF_H
+#define STDDEF_H
+
+#include <stdint.h>
+
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__zarch__) || __riscv_xlen == 64
+typedef __int64_t ptrdiff_t;
+typedef __int64_t ssize_t;
+typedef __uint64_t size_t;
+typedef __uint32_t wchar_t;
+#elif defined(__i386__) || defined(__arm__) || __riscv_xlen == 32
+typedef __int32_t ptrdiff_t;
+typedef __int32_t ssize_t;
+typedef __uint32_t size_t;
+typedef __uint16_t wchar_t;
+#else
+#error "Unsupported architecture"
+#endif
+
+#define SIZE_MAX ((size_t)65535)
+#define offsetof(type, member) ((size_t)((char*)&(((type*)0)->member) - (char*)0))
+
+#endif
diff --git a/include/stdint.h b/include/stdint.h
new file mode 100644
index 0000000..c2328f8
--- /dev/null
+++ b/include/stdint.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef STDINT_H
+#define STDINT_H
+
+typedef unsigned char __u_char;
+typedef unsigned short __u_short;
+typedef unsigned int __u_int;
+
+typedef signed char __int8_t;
+typedef signed short int __int16_t;
+typedef signed int __int32_t;
+
+typedef __u_char __uint8_t;
+typedef __u_short __uint16_t;
+typedef __u_int __uint32_t;
+
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__zarch__) || __riscv_xlen == 64
+typedef unsigned long long __u_long;
+typedef signed long long __int64_t;
+typedef __u_long __uint64_t;
+typedef __int64_t intptr_t;
+typedef __uint64_t uintptr_t;
+#elif defined(__i386__) || defined(__arm__) || __riscv_xlen == 32
+typedef unsigned long __u_long;
+typedef signed long __int64_t;
+typedef __u_long __uint64_t;
+typedef __int32_t intptr_t;
+typedef __uint32_t uintptr_t;
+#else
+#error "Unsupported architecture"
+#endif
+
+typedef __int8_t __int_least8_t;
+typedef __int16_t __int_least16_t;
+typedef __int32_t __int_least32_t;
+typedef __int64_t __int_least64_t;
+
+typedef __uint8_t __uint_least8_t;
+typedef __uint16_t __uint_least16_t;
+typedef __uint32_t __uint_least32_t;
+typedef __uint64_t __uint_least64_t;
+
+typedef __int_least8_t int8_t;
+typedef __int_least16_t int16_t;
+typedef __int_least32_t int32_t;
+typedef __int_least64_t int64_t;
+
+typedef __uint_least8_t uint8_t;
+typedef __uint_least16_t uint16_t;
+typedef __uint_least32_t uint32_t;
+typedef __uint_least64_t uint64_t;
+
+#endif
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..b7db629
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef STRING_H
+#define STRING_H
+
+#include <stddef.h>
+
+int memcmp(const void *str1, const void *str2, size_t n);
+void* memcpy(void* __restrict dest, const void* __restrict src, size_t n);
+void* memmove(void* __restrict dest, const void* __restrict src, size_t n);
+void* memset(void *str, int c, size_t n);
+
+int strcmp(const char *str1, const char *str2);
+int strncmp(const char *str1, const char *str2, size_t n);
+size_t strlen(const char *str);
+char* strncpy(char* __restrict dest, const char* __restrict src, size_t n);
+char* strcpy(char* __restrict dest, const char* __restrict src);
+char* strncat(char* __restrict dest, const char* __restrict src, size_t n);
+char* strcat(char* __restrict dest, const char* __restrict src);
+char* strtok(char* __restrict str, const char* __restrict delim);
+
+#endif