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 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
|
|
|
}
|
|
|
|
|
|
|
|
z_err_t SysCall1(uint64_t code, const void* req);
|
|
|
|
|
2023-06-20 13:50:18 -07:00
|
|
|
SYS1(ProcessExit, uint64_t, code);
|
2023-05-30 20:55:03 -07:00
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZProcessSpawn(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-05-30 20:55:03 -07:00
|
|
|
|
2023-06-07 00:04:53 -07:00
|
|
|
// UNUSED for now, I think we can get away with just starting a thread.
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZProcessStart(z_cap_t proc_cap, z_cap_t thread_cap,
|
2023-06-07 08:50:08 -07:00
|
|
|
uint64_t entry, uint64_t arg1,
|
|
|
|
uint64_t arg2);
|
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-06 16:24:03 -07:00
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZThreadStart(z_cap_t thread_cap, uint64_t entry,
|
2023-06-07 08:50:08 -07:00
|
|
|
uint64_t arg1, uint64_t arg2);
|
2023-06-06 16:24:03 -07:00
|
|
|
|
2023-06-07 00:04:53 -07:00
|
|
|
void ZThreadExit();
|
2023-06-06 16:24:03 -07:00
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZAddressSpaceMap(z_cap_t vmas_cap, uint64_t vmas_offset,
|
|
|
|
z_cap_t vmmo_cap, uint64_t* vaddr);
|
|
|
|
[[nodiscard]] z_err_t ZMemoryObjectCreate(uint64_t size, z_cap_t* vmmo_cap);
|
2023-06-08 02:36:47 -07:00
|
|
|
[[nodiscard]] z_err_t ZMemoryObjectCreatePhysical(uint64_t paddr, uint64_t size,
|
2023-06-17 01:53:19 -07:00
|
|
|
z_cap_t* vmmo_cap);
|
2023-06-12 19:20:51 -07:00
|
|
|
[[nodiscard]] z_err_t ZMemoryObjectCreateContiguous(uint64_t size,
|
2023-06-17 01:53:19 -07:00
|
|
|
z_cap_t* vmmo_cap,
|
2023-06-12 19:20:51 -07:00
|
|
|
uint64_t* paddr);
|
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZTempPcieConfigObjectCreate(z_cap_t* vmmo_cap,
|
2023-06-07 22:45:42 -07:00
|
|
|
uint64_t* vmmo_size);
|
2023-06-07 08:50:08 -07:00
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZChannelCreate(z_cap_t* channel1, z_cap_t* channel2);
|
2023-06-17 02:01:21 -07:00
|
|
|
[[nodiscard]] z_err_t ZChannelSend(z_cap_t chan_cap, uint64_t num_bytes,
|
2023-06-19 18:39:46 -07:00
|
|
|
const void* data, uint64_t num_caps,
|
2023-06-17 02:01:21 -07:00
|
|
|
const z_cap_t* caps);
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZChannelRecv(z_cap_t chan_cap, uint64_t num_bytes,
|
2023-06-19 18:39:46 -07:00
|
|
|
void* data, uint64_t num_caps, z_cap_t* caps,
|
|
|
|
uint64_t* actual_bytes,
|
2023-06-07 08:50:08 -07:00
|
|
|
uint64_t* actual_caps);
|
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZPortCreate(z_cap_t* port_cap);
|
|
|
|
[[nodiscard]] z_err_t ZPortSend(z_cap_t port_cap, uint64_t num_bytes,
|
2023-06-19 18:39:46 -07:00
|
|
|
const void* data, uint64_t num_caps,
|
2023-06-17 01:53:19 -07:00
|
|
|
z_cap_t* caps);
|
|
|
|
[[nodiscard]] z_err_t ZPortRecv(z_cap_t port_cap, uint64_t num_bytes,
|
2023-06-19 18:39:46 -07:00
|
|
|
void* data, uint64_t num_caps, z_cap_t* caps,
|
|
|
|
uint64_t* actual_bytes, uint64_t* actual_caps);
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZPortPoll(z_cap_t port_cap, uint64_t num_bytes,
|
2023-06-19 18:39:46 -07:00
|
|
|
void* data, uint64_t num_caps, z_cap_t* caps,
|
|
|
|
uint64_t* actual_bytes, uint64_t* actual_caps);
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZIrqRegister(uint64_t irq_num, z_cap_t* port_cap);
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-17 01:53:19 -07:00
|
|
|
[[nodiscard]] z_err_t ZCapDuplicate(z_cap_t cap_in, z_cap_t* cap_out);
|
2023-06-17 00:59:44 -07:00
|
|
|
|
2023-06-07 08:50:08 -07:00
|
|
|
[[nodiscard]] z_err_t ZDebug(const char* message);
|