2023-05-29 00:32:54 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-06-17 01:45:53 -07:00
|
|
|
#include "ztypes.h"
|
2023-05-29 00:32:54 -07:00
|
|
|
|
2023-06-20 14:10:28 -07:00
|
|
|
#define SYS0(name) \
|
|
|
|
struct Z##name##Req {}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name() { \
|
|
|
|
Z##name##Req req{}; \
|
|
|
|
return SysCall1(kZion##name, &req); \
|
|
|
|
}
|
|
|
|
|
2023-06-20 13:50:18 -07:00
|
|
|
#define SYS1(name, t1, a1) \
|
2023-06-20 13:43:12 -07:00
|
|
|
struct Z##name##Req { \
|
|
|
|
t1 a1; \
|
|
|
|
}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name(t1 a1) { \
|
|
|
|
Z##name##Req req{ \
|
|
|
|
.a1 = a1, \
|
|
|
|
}; \
|
2023-06-20 13:50:18 -07:00
|
|
|
return SysCall1(kZion##name, &req); \
|
2023-06-20 13:43:12 -07:00
|
|
|
}
|
|
|
|
|
2023-06-20 13:50:18 -07:00
|
|
|
#define SYS2(name, t1, a1, t2, a2) \
|
2023-06-20 13:43:12 -07:00
|
|
|
struct Z##name##Req { \
|
|
|
|
t1 a1; \
|
|
|
|
t2 a2; \
|
|
|
|
}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name(t1 a1, t2 a2) { \
|
|
|
|
Z##name##Req req{ \
|
|
|
|
.a1 = a1, \
|
|
|
|
.a2 = a2, \
|
|
|
|
}; \
|
2023-06-20 13:50:18 -07:00
|
|
|
return SysCall1(kZion##name, &req); \
|
2023-06-20 13:43:12 -07:00
|
|
|
}
|
|
|
|
|
2023-06-20 14:01:43 -07:00
|
|
|
#define SYS3(name, t1, a1, t2, a2, t3, a3) \
|
|
|
|
struct Z##name##Req { \
|
|
|
|
t1 a1; \
|
|
|
|
t2 a2; \
|
|
|
|
t3 a3; \
|
|
|
|
}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name(t1 a1, t2 a2, t3 a3) { \
|
|
|
|
Z##name##Req req{ \
|
|
|
|
.a1 = a1, \
|
|
|
|
.a2 = a2, \
|
|
|
|
.a3 = a3, \
|
|
|
|
}; \
|
|
|
|
return SysCall1(kZion##name, &req); \
|
|
|
|
}
|
2023-06-20 13:43:12 -07:00
|
|
|
|
2023-06-20 14:01:43 -07:00
|
|
|
#define SYS4(name, t1, a1, t2, a2, t3, a3, t4, a4) \
|
|
|
|
struct Z##name##Req { \
|
|
|
|
t1 a1; \
|
|
|
|
t2 a2; \
|
|
|
|
t3 a3; \
|
|
|
|
t4 a4; \
|
|
|
|
}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name(t1 a1, t2 a2, t3 a3, t4 a4) { \
|
|
|
|
Z##name##Req req{ \
|
|
|
|
.a1 = a1, \
|
|
|
|
.a2 = a2, \
|
|
|
|
.a3 = a3, \
|
|
|
|
.a4 = a4, \
|
|
|
|
}; \
|
|
|
|
return SysCall1(kZion##name, &req); \
|
|
|
|
}
|
2023-05-30 20:55:03 -07:00
|
|
|
|
2023-06-20 14:01:43 -07:00
|
|
|
#define SYS5(name, t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \
|
|
|
|
struct Z##name##Req { \
|
|
|
|
t1 a1; \
|
|
|
|
t2 a2; \
|
|
|
|
t3 a3; \
|
|
|
|
t4 a4; \
|
|
|
|
t5 a5; \
|
|
|
|
}; \
|
|
|
|
[[nodiscard]] inline z_err_t Z##name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
|
|
|
|
Z##name##Req req{ \
|
|
|
|
.a1 = a1, \
|
|
|
|
.a2 = a2, \
|
|
|
|
.a3 = a3, \
|
|
|
|
.a4 = a4, \
|
|
|
|
.a5 = a5, \
|
|
|
|
}; \
|
|
|
|
return SysCall1(kZion##name, &req); \
|
|
|
|
}
|
|
|
|
|
|
|
|
z_err_t SysCall1(uint64_t code, const void* req);
|
2023-05-30 20:55:03 -07:00
|
|
|
|
2023-06-20 14:01:43 -07:00
|
|
|
SYS1(ProcessExit, uint64_t, code);
|
|
|
|
SYS5(ProcessSpawn, z_cap_t, proc_cap, z_cap_t, bootstrap_cap, z_cap_t*,
|
|
|
|
new_proc_cap, z_cap_t*, new_vmas_cap, z_cap_t*, new_bootstrap_cap);
|
2023-06-06 16:24:03 -07:00
|
|
|
|
2023-06-20 13:50:18 -07:00
|
|
|
SYS2(ThreadCreate, z_cap_t, proc_cap, z_cap_t*, thread_cap);
|
2023-06-20 14:10:28 -07:00
|
|
|
SYS4(ThreadStart, z_cap_t, thread_cap, uint64_t, entry, uint64_t, arg1,
|
|
|
|
uint64_t, arg2);
|
|
|
|
SYS0(ThreadExit);
|
2023-06-22 02:17:50 -07:00
|
|
|
SYS1(ThreadWait, z_cap_t, thread_cap);
|
2023-06-06 16:24:03 -07:00
|
|
|
|
2023-06-20 14:26:06 -07:00
|
|
|
SYS4(AddressSpaceMap, z_cap_t, vmas_cap, uint64_t, vmas_offset, z_cap_t,
|
|
|
|
vmmo_cap, uint64_t*, vaddr);
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-20 14:26:06 -07:00
|
|
|
SYS2(MemoryObjectCreate, uint64_t, size, z_cap_t*, vmmo_cap);
|
|
|
|
SYS3(MemoryObjectCreatePhysical, uint64_t, paddr, uint64_t, size, z_cap_t*,
|
|
|
|
vmmo_cap);
|
|
|
|
SYS3(MemoryObjectCreateContiguous, uint64_t, size, z_cap_t*, vmmo_cap,
|
|
|
|
uint64_t*, paddr);
|
2023-06-07 08:50:08 -07:00
|
|
|
|
2023-06-20 14:41:44 -07:00
|
|
|
SYS2(ChannelCreate, z_cap_t*, channel1, z_cap_t*, channel2);
|
|
|
|
SYS5(ChannelSend, z_cap_t, chan_cap, uint64_t, num_bytes, const void*, data,
|
|
|
|
uint64_t, num_caps, z_cap_t*, caps);
|
|
|
|
SYS5(ChannelRecv, z_cap_t, chan_cap, uint64_t*, num_bytes, void*, data,
|
|
|
|
uint64_t*, num_caps, z_cap_t*, caps);
|
2023-06-07 08:50:08 -07:00
|
|
|
|
2023-06-20 14:55:54 -07:00
|
|
|
SYS1(PortCreate, z_cap_t*, port_cap);
|
|
|
|
SYS5(PortSend, z_cap_t, port_cap, uint64_t, num_bytes, const void*, data,
|
|
|
|
uint64_t, num_caps, z_cap_t*, caps);
|
|
|
|
SYS5(PortRecv, z_cap_t, port_cap, uint64_t*, num_bytes, void*, data, uint64_t*,
|
|
|
|
num_caps, z_cap_t*, caps);
|
|
|
|
SYS5(PortPoll, z_cap_t, port_cap, uint64_t*, num_bytes, void*, data, uint64_t*,
|
|
|
|
num_caps, z_cap_t*, caps);
|
|
|
|
|
|
|
|
SYS2(IrqRegister, uint64_t, irq_num, z_cap_t*, port_cap);
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-21 21:26:24 -07:00
|
|
|
SYS1(EndpointCreate, z_cap_t*, endpoint_cap);
|
|
|
|
SYS4(EndpointSend, z_cap_t, endpoint_cap, uint64_t, num_bytes, const void*,
|
|
|
|
data, z_cap_t*, reply_port_cap);
|
|
|
|
SYS4(EndpointRecv, z_cap_t, endpoint_cap, uint64_t*, num_bytes, void*, data,
|
|
|
|
z_cap_t*, reply_port_cap);
|
|
|
|
SYS5(ReplyPortSend, z_cap_t, reply_port_cap, uint64_t, num_bytes, const void*,
|
|
|
|
data, uint64_t, num_caps, z_cap_t*, caps);
|
2023-06-21 23:14:42 -07:00
|
|
|
SYS5(ReplyPortRecv, z_cap_t, reply_port_cap, uint64_t*, num_bytes, void*, data,
|
|
|
|
uint64_t*, num_caps, z_cap_t*, caps);
|
2023-06-21 21:26:24 -07:00
|
|
|
|
2023-06-20 15:03:33 -07:00
|
|
|
SYS2(CapDuplicate, z_cap_t, cap_in, z_cap_t*, cap_out);
|
2023-06-17 00:59:44 -07:00
|
|
|
|
2023-06-20 15:03:33 -07:00
|
|
|
SYS1(Debug, const char*, message);
|