stuff2
This commit is contained in:
+4
-24
@@ -1,6 +1,5 @@
|
||||
#include <zinnia/channel.h>
|
||||
#include <zinnia/handle.h>
|
||||
#include <zinnia/ipc/init.h>
|
||||
#include <zinnia/mem.h>
|
||||
#include <zinnia/status.h>
|
||||
#include <zinnia/system.h>
|
||||
@@ -12,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/auxv.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define ZN_ASSERT(expr) \
|
||||
do { \
|
||||
@@ -31,38 +31,18 @@ static void zn_printf(const char* msg, ...) {
|
||||
int32_t len = vsnprintf(buf, sizeof(buf), msg, args);
|
||||
va_end(args);
|
||||
|
||||
zn_log(buf, len);
|
||||
write(1, buf, len);
|
||||
// zn_log(buf, len);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[], char* envp[]) {
|
||||
zn_printf("initd: starting...\n");
|
||||
zn_handle_t channel = getauxval(AT_INIT_HANDLE);
|
||||
zn_handle_t channel = getauxval(0x1000);
|
||||
|
||||
while (true) {
|
||||
static thread_local zn_handle_t handles[32];
|
||||
static thread_local char buf[1024];
|
||||
|
||||
ZN_ASSERT(zn_channel_read(channel, handles, buf, ARRAY_SIZE(handles), ARRAY_SIZE(buf), nullptr, nullptr));
|
||||
|
||||
enum ipc_msg_id* msg = (enum ipc_msg_id*)buf;
|
||||
switch (*msg) {
|
||||
case IPC_MSG_FOO: {
|
||||
struct ipc_init_register_rq* foo = (struct ipc_init_register_rq*)msg;
|
||||
|
||||
char buf[32] = {0};
|
||||
IPC_GET_STRING(foo->data, &foo->name, buf);
|
||||
|
||||
zn_printf("initd: ipc_init_register_rq, peer = \"%s\"\n", buf);
|
||||
} break;
|
||||
case IPC_MSG_BAR: {
|
||||
struct ipc_kernel_msg* foo = (struct ipc_kernel_msg*)msg;
|
||||
|
||||
char buf[32] = {0};
|
||||
IPC_GET_STRING(foo->data, &foo->name, buf);
|
||||
zn_printf("initd: ipc_kernel_msg, msg = \"%s\"\n", buf);
|
||||
} break;
|
||||
case IPC_MSG_BAZ:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user