kernel: separate headers into kernel and user headers

all kernel headers have been moved from include/mango to include/kernel
and include definitions that are only relevant to kernel-space.

any definitions that are relevant to both kernel- and user-space
(i.e. type definitions, syscall IDs) have been moved to
include/mango within libmango.
This commit is contained in:
2026-02-19 18:54:48 +00:00
parent e3dd48a0fa
commit 6019c9307d
117 changed files with 1361 additions and 3845 deletions

View File

@@ -0,0 +1,23 @@
#ifndef MANGO_STATUS_H_
#define MANGO_STATUS_H_
typedef unsigned int kern_status_t;
#define KERN_OK (0)
#define KERN_UNIMPLEMENTED (1)
#define KERN_NAME_EXISTS (2)
#define KERN_INVALID_ARGUMENT (3)
#define KERN_UNSUPPORTED (4)
#define KERN_NO_MEMORY (5)
#define KERN_NO_ENTRY (6)
#define KERN_WOULD_BLOCK (7)
#define KERN_BUSY (8)
#define KERN_NO_DEVICE (9)
#define KERN_DEVICE_STUCK (10)
#define KERN_IO_ERROR (11)
#define KERN_FATAL_ERROR (12)
#define KERN_BAD_STATE (13)
#define KERN_MEMORY_FAULT (14)
#define KERN_ACCESS_DENIED (15)
#endif

View File

@@ -0,0 +1,35 @@
#ifndef MANGO_SYSCALL_H_
#define MANGO_SYSCALL_H_
#define SYS_TASK_EXIT 1
#define SYS_TASK_CREATE 2
#define SYS_TASK_CREATE_THREAD 3
#define SYS_THREAD_START 30
#define SYS_VM_OBJECT_CREATE 4
#define SYS_VM_OBJECT_READ 5
#define SYS_VM_OBJECT_WRITE 6
#define SYS_VM_OBJECT_COPY 29
#define SYS_VM_REGION_CREATE 7
#define SYS_VM_REGION_READ 8
#define SYS_VM_REGION_WRITE 9
#define SYS_VM_REGION_MAP_ABSOLUTE 10
#define SYS_VM_REGION_MAP_RELATIVE 11
#define SYS_VM_REGION_UNMAP_ABSOLUTE 12
#define SYS_VM_REGION_UNMAP_RELATIVE 13
#define SYS_KERN_LOG 14
#define SYS_KERN_HANDLE_CLOSE 15
#define SYS_KERN_CONFIG_GET 16
#define SYS_KERN_CONFIG_SET 17
#define SYS_MSG_SEND 18
#define SYS_MSG_RECV 19
#define SYS_MSG_REPLY 20
#define SYS_MSG_READ 21
#define SYS_MSG_READ_HANDLES 22
#define SYS_MSG_WRITE 23
#define SYS_MSG_WRITE_HANDLES 24
#define SYS_CHANNEL_CREATE 25
#define SYS_PORT_CREATE 26
#define SYS_PORT_CONNECT 27
#define SYS_PORT_DISCONNECT 28
#endif

View File

@@ -0,0 +1,62 @@
#ifndef MANGO_TYPES_H_
#define MANGO_TYPES_H_
#include <stddef.h>
#include <stdint.h>
#define VM_PROT_READ 0x01u
#define VM_PROT_WRITE 0x02u
#define VM_PROT_EXEC 0x04u
#define VM_PROT_USER 0x08u
#define VM_PROT_SVR 0x10u
#define VM_PROT_NOCACHE 0x10u
#define VM_PROT_MAP_SPECIFIC 0x40u
/* if this flag is set, other tasks can connect to this channel using
* the port_connect_* syscalls.
* if this flag is NOT set, only threads in the task that owns the channel
* can create ports connecting to it. */
#define CHANNEL_F_ALLOW_DIRECT_CONNECTIONS 0x01u
/* msg_reply: once the reply has been sent, disconnect the port that sent the
* original message */
#define MSG_F_DISCONNECT_AFTER_REPLY 0x01u
#define VM_REGION_ANY_OFFSET ((off_t) - 1)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
#define KERN_CFG_INVALID 0x00u
#define KERN_CFG_PAGE_SIZE 0x01u
typedef uintptr_t phys_addr_t;
typedef uintptr_t virt_addr_t;
typedef uint64_t msgid_t;
typedef uint64_t off_t;
typedef unsigned int tid_t;
typedef uint32_t kern_handle_t;
typedef uint32_t kern_config_key_t;
typedef uint32_t vm_prot_t;
typedef uint32_t channel_flags_t;
typedef uint32_t msg_flags_t;
typedef unsigned int umode_t;
struct iovec {
virt_addr_t io_base;
size_t io_len;
};
struct handle_list {
kern_handle_t *l_handles;
size_t l_nr_handles;
};
struct msg {
struct iovec *msg_data;
size_t msg_data_count;
struct handle_list *msg_handles;
size_t msg_handles_count;
};
#endif