meta: rename kernel to Magenta

This commit is contained in:
2026-04-30 20:30:36 +01:00
parent 560da0daa0
commit 1db6de6bc2
65 changed files with 122 additions and 122 deletions
+12
View File
@@ -0,0 +1,12 @@
#ifndef MAGENTA_SIGNAL_H_
#define MAGENTA_SIGNAL_H_
#define THREAD_SIGNAL_STOPPED 0x01u
#define CHANNEL_SIGNAL_MSG_RECEIVED 0x01u
#define VM_CONTROLLER_SIGNAL_REQUEST_RECEIVED 0x01u
#define EQUEUE_SIGNAL_PACKET_RECEIVED 0x01u
#endif
+21
View File
@@ -0,0 +1,21 @@
#ifndef MAGENTA_STATUS_H_
#define MAGENTA_STATUS_H_
#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
+58
View File
@@ -0,0 +1,58 @@
#ifndef MAGENTA_SYSCALL_H_
#define MAGENTA_SYSCALL_H_
#define SYS_KERN_LOG 1
#define SYS_KERN_HANDLE_CLOSE 2
#define SYS_KERN_HANDLE_TRANSFER 3
#define SYS_KERN_HANDLE_CONTROL 4
#define SYS_KERN_CONFIG_GET 5
#define SYS_KERN_CONFIG_SET 6
#define SYS_KERN_OBJECT_WAIT 7
#define SYS_KERN_OBJECT_WAIT_ASYNC 8
#define SYS_TASK_EXIT 9
#define SYS_TASK_SELF 10
#define SYS_TASK_CREATE 11
#define SYS_TASK_CREATE_THREAD 12
#define SYS_TASK_GET_ADDRESS_SPACE 13
#define SYS_TASK_CONFIG_GET 14
#define SYS_TASK_CONFIG_SET 15
#define SYS_TASK_DUPLICATE 16
#define SYS_THREAD_SELF 17
#define SYS_THREAD_START 18
#define SYS_THREAD_EXIT 19
#define SYS_THREAD_CONFIG_GET 20
#define SYS_THREAD_CONFIG_SET 21
#define SYS_VM_OBJECT_CREATE 22
#define SYS_VM_OBJECT_READ 23
#define SYS_VM_OBJECT_WRITE 24
#define SYS_VM_OBJECT_COPY 25
#define SYS_ADDRESS_SPACE_READ 26
#define SYS_ADDRESS_SPACE_WRITE 27
#define SYS_ADDRESS_SPACE_MAP 28
#define SYS_ADDRESS_SPACE_UNMAP 29
#define SYS_ADDRESS_SPACE_RESERVE 30
#define SYS_ADDRESS_SPACE_RELEASE 31
#define SYS_MSG_SEND 32
#define SYS_MSG_RECV 33
#define SYS_MSG_REPLY 34
#define SYS_MSG_READ 35
#define SYS_MSG_WRITE 36
#define SYS_CHANNEL_CREATE 37
#define SYS_PORT_CREATE 38
#define SYS_PORT_CONNECT 39
#define SYS_PORT_DISCONNECT 40
#define SYS_EQUEUE_CREATE 41
#define SYS_EQUEUE_DEQUEUE 42
#define SYS_VM_CONTROLLER_CREATE 43
#define SYS_VM_CONTROLLER_RECV 44
#define SYS_VM_CONTROLLER_RECV_ASYNC 45
#define SYS_VM_CONTROLLER_CREATE_OBJECT 46
#define SYS_VM_CONTROLLER_PREPARE_ATTACH 47
#define SYS_VM_CONTROLLER_FINISH_ATTACH 48
#define SYS_VM_CONTROLLER_DETACH_OBJECT 49
#define SYS_VM_CONTROLLER_SUPPLY_PAGES 50
#define SYS_FUTEX_WAIT 51
#define SYS_FUTEX_WAKE 52
#define SYS_KERN_OBJECT_QUERY 53
#endif
+239
View File
@@ -0,0 +1,239 @@
#ifndef MAGENTA_TYPES_H_
#define MAGENTA_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
#define MAP_ADDRESS_ANY ((virt_addr_t) - 1)
#define MAP_ADDRESS_INVALID ((virt_addr_t)0)
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
/* task creation flags */
#define TASK_F_DEFAULT 0x0000u
#define TASK_F_CLONE_ALL_HANDLES 0x0001u
/* config keys for use with kern_config_get/kern_config_set */
#define KERN_CFG_INVALID 0x00000u
#define KERN_CFG_PAGE_SIZE 0x00001u
/* config keys for use with task_config_get/task_config_set */
#define TASK_CFG_INVALID 0x00000u
#define TASK_CFG_ID 0x10001u
/* config keys for use with thread_config_get/thread_config_set */
#define THREAD_CFG_INVALID 0x00000u
#define THREAD_CFG_FSBASE 0x20001u
#define THREAD_CFG_GSBASE 0x20002u
/* user-defined flags that can be set on handles */
#define KERN_HANDLE_FLAG0 0x10000000UL
#define KERN_HANDLE_FLAG1 0x20000000UL
#define KERN_HANDLE_FLAG2 0x40000000UL
#define KERN_HANDLE_FLAG3 0x80000000UL
/* flags to specify when creating address-space mappings */
/* this mapping is private. if a task with this mapping is duplicated,
the duplicate task will receive a copy-on-write mapping. changes to one
mapping will not be visible to the other. */
#define VM_PRIVATE 0x0000u
/* this mapping is shared. if a task with this mapping is duplicated,
* the duplicate will receive a mapping of the same data. changes to one mapping
* will be visibile to the other */
#define VM_SHARED 0x0001u
/* maximum number of handles that can be sent in a single message */
#define KERN_MSG_MAX_HANDLES 64
/* the corresponding handle should be ignored */
#define HANDLE_TRANSFER_IGNORE 0
/* the corresponding handle should be moved to the recipient task. the handle
* will be closed. */
#define HANDLE_TRANSFER_MOVE 1
/* the corresponding handle should be copied to the recipient task. the handle
* will remain valid for the sending task. */
#define HANDLE_TRANSFER_COPY 2
/* maximum number of objects that can be waited on in a single call to
* kern_object_wait */
#define KERN_WAIT_MAX_ITEMS 64
/* message types */
#define KERN_MSG_TYPE_NONE 0
#define KERN_MSG_TYPE_DATA 1
#define KERN_MSG_TYPE_EVENT 2
/* event message types */
#define KERN_MSG_EVENT_NONE 0
#define KERN_MSG_EVENT_CONNECTION 1
#define KERN_MSG_EVENT_DISCONNECTION 2
/* equeue packet types */
#define EQUEUE_PKT_VM_REQUEST 0x01u
#define EQUEUE_PKT_ASYNC_SIGNAL 0x02u
/* vm request types */
#define VM_REQUEST_READ 0x01u
#define VM_REQUEST_DIRTY 0x02u
#define VM_REQUEST_ATTACH 0x03u
#define VM_REQUEST_DETACH 0x04u
/* futex special values */
#define FUTEX_WAKE_ALL ((size_t)-1)
/* futex flags */
#define FUTEX_PRIVATE 0x01u
#define FUTEX_SHARED 0x02u
#define IOVEC(p, len) \
{ \
.io_base = (virt_addr_t)(p), \
.io_len = (len), \
}
#define MSG_HANDLE(mode, value) \
{ \
.hnd_mode = (mode), \
.hnd_value = (value), \
}
#define MSG(data, data_count, handles, handles_len) \
{ \
.msg_data = (data), \
.msg_data_count = (data_count), \
.msg_handles = (handles), \
.msg_handles_count = (handles_len), \
}
typedef uintptr_t phys_addr_t;
typedef uintptr_t virt_addr_t;
typedef uint64_t msgid_t;
typedef uint64_t off_t;
typedef uint64_t koid_t;
typedef uintptr_t equeue_key_t;
typedef unsigned int tid_t;
typedef unsigned int vm_controller_packet_type_t;
typedef unsigned int kern_status_t;
typedef uint32_t kern_handle_t;
typedef uint32_t kern_config_key_t;
typedef uint32_t vm_prot_t;
typedef uint32_t vm_flags_t;
typedef uint32_t task_flags_t;
typedef int64_t ssize_t;
typedef uint32_t kern_futex_t;
typedef uint32_t kern_msg_type_t;
typedef uint32_t kern_msg_event_type_t;
typedef unsigned short equeue_packet_type_t;
typedef unsigned int umode_t;
typedef struct {
koid_t obj_id;
} kern_object_info_t;
typedef struct {
virt_addr_t io_base;
size_t io_len;
} kern_iovec_t;
typedef struct {
kern_handle_t w_handle;
uint32_t w_waitfor;
uint32_t w_observed;
} kern_wait_item_t;
typedef struct {
unsigned int hnd_mode;
kern_handle_t hnd_value;
kern_status_t hnd_result;
} kern_msg_handle_t;
typedef struct {
/* transaction id. identifies a particular request/response exchange.
* used when replying to a particular message. */
msgid_t msg_id;
/* the id of the task that sent a particular message. */
tid_t msg_sender;
/* the id of the port or channel used to send a particular message. */
koid_t msg_endpoint;
/* the message type */
kern_msg_type_t msg_type;
union {
/* msg_type = KERN_MSG_TYPE_DATA */
struct {
/* a list of iovecs that point to the buffers that make
* up the main message data. */
kern_iovec_t *msg_data;
size_t msg_data_count;
/* a list of handle entries that contain the kernel
* handles included in a message. */
kern_msg_handle_t *msg_handles;
size_t msg_handles_count;
};
/* msg_type = KERN_MSG_TYPE_EVENT */
struct {
kern_msg_event_type_t msg_event;
};
};
} kern_msg_t;
typedef struct {
uint32_t s_observed;
} equeue_packet_async_signal_t;
typedef struct {
/* the key of the vm-object for which the page request relates, as
* specified when the vm-object was created */
equeue_key_t req_vmo;
/* page request type. one of VM_REQUEST_* */
unsigned short req_type;
/* the offset into the vm-object for which pages are being requested */
union {
/* used for:
* VM_REQUEST_READ
* VM_REQUEST_DIRTY
*/
struct {
off_t req_offset;
/* the length in bytes of the region being requested */
size_t req_length;
};
/* used for:
* VM_REQUEST_ATTACH
*/
struct {
/* the key of the original/source vmo. */
equeue_key_t req_src_vmo;
/* a request ID. used to retrieve information about
* the newly-attached object, as the server won't know
* about it yet, and won't have a handle to it. */
uint64_t req_id;
};
};
} equeue_packet_vm_request_t;
typedef struct {
/* the type of packet. one of EQUEUE_PKT_* */
equeue_packet_type_t p_type;
/* the key of the object that is responsible for the event, as specified
* when the event was first subscribed to */
equeue_key_t p_key;
union {
/* p_type = EQUEUE_PKT_VM_REQUEST */
equeue_packet_vm_request_t vm_request;
/* p_type = EQUEUE_PKT_ASYNC_SIGNAL */
equeue_packet_async_signal_t async_signal;
};
} equeue_packet_t;
#endif