[Zion] Add the ability to pass capabilities via endpoint call.
This commit is contained in:
parent
5b781bb394
commit
b516087922
18 changed files with 218 additions and 131 deletions
|
|
@ -2,90 +2,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "zcall_macros.h"
|
||||
#include "ztypes.h"
|
||||
|
||||
#define SYS0(name) \
|
||||
struct Z##name##Req {}; \
|
||||
[[nodiscard]] inline z_err_t Z##name() { \
|
||||
Z##name##Req req{}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#define SYS1(name, t1, a1) \
|
||||
struct Z##name##Req { \
|
||||
t1 a1; \
|
||||
}; \
|
||||
[[nodiscard]] inline z_err_t Z##name(t1 a1) { \
|
||||
Z##name##Req req{ \
|
||||
.a1 = a1, \
|
||||
}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#define SYS2(name, t1, a1, t2, a2) \
|
||||
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, \
|
||||
}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#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);
|
||||
|
||||
SYS1(ProcessExit, uint64_t, code);
|
||||
|
|
@ -127,10 +46,10 @@ SYS5(PortPoll, z_cap_t, port_cap, uint64_t*, num_bytes, void*, data, uint64_t*,
|
|||
SYS2(IrqRegister, uint64_t, irq_num, z_cap_t*, port_cap);
|
||||
|
||||
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);
|
||||
SYS6(EndpointSend, z_cap_t, endpoint_cap, uint64_t, num_bytes, const void*,
|
||||
data, uint64_t, num_caps, const z_cap_t*, caps, z_cap_t*, reply_port_cap);
|
||||
SYS6(EndpointRecv, z_cap_t, endpoint_cap, uint64_t*, num_bytes, void*, data,
|
||||
uint64_t*, num_caps, z_cap_t*, caps, 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);
|
||||
SYS5(ReplyPortRecv, z_cap_t, reply_port_cap, uint64_t*, num_bytes, void*, data,
|
||||
|
|
|
|||
104
zion/include/zcall_macros.h
Normal file
104
zion/include/zcall_macros.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
#pragma once
|
||||
#define SYS0(name) \
|
||||
struct Z##name##Req {}; \
|
||||
[[nodiscard]] inline z_err_t Z##name() { \
|
||||
Z##name##Req req{}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#define SYS1(name, t1, a1) \
|
||||
struct Z##name##Req { \
|
||||
t1 a1; \
|
||||
}; \
|
||||
[[nodiscard]] inline z_err_t Z##name(t1 a1) { \
|
||||
Z##name##Req req{ \
|
||||
.a1 = a1, \
|
||||
}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#define SYS2(name, t1, a1, t2, a2) \
|
||||
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, \
|
||||
}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#define SYS6(name, t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \
|
||||
struct Z##name##Req { \
|
||||
t1 a1; \
|
||||
t2 a2; \
|
||||
t3 a3; \
|
||||
t4 a4; \
|
||||
t5 a5; \
|
||||
t6 a6; \
|
||||
}; \
|
||||
[[nodiscard]] inline z_err_t Z##name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
|
||||
t6 a6) { \
|
||||
Z##name##Req req{ \
|
||||
.a1 = a1, \
|
||||
.a2 = a2, \
|
||||
.a3 = a3, \
|
||||
.a4 = a4, \
|
||||
.a5 = a5, \
|
||||
.a6 = a6, \
|
||||
}; \
|
||||
return SysCall1(kZion##name, &req); \
|
||||
}
|
||||
|
|
@ -63,6 +63,8 @@ const uint64_t kZionDebug = 0x1'0000;
|
|||
|
||||
typedef uint64_t z_cap_t;
|
||||
|
||||
const uint64_t kZionInvalidCapability = 0x0;
|
||||
|
||||
// General Capability Permissions
|
||||
const uint64_t kZionPerm_Write = 0x1;
|
||||
const uint64_t kZionPerm_Read = 0x2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue