This commit is contained in:
2026-08-11 17:48:20 +02:00
committed by Marvin Friedrich
parent cf33867e68
commit 0e2d4ed8c6
55 changed files with 279 additions and 346 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
#include <zinnia/channel.h>
#include <zinnia/handle.h>
#include <zinnia/ipc/init.h>
#include <zinnia/system.h>
#include <common/compiler.h>
#include <stdio.h>
@@ -22,7 +21,7 @@ static void zn_printf(const char* msg, ...) {
int main(int argc, char* argv[], char* envp[]) {
zn_printf("devd: starting...\n");
zn_handle_t channel = getauxval(AT_INIT_HANDLE);
zn_handle_t channel = getauxval(0x1000);
// while (true) {}
uacpi_status status = uacpi_initialize(0);
+4 -24
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -1,3 +1,3 @@
subdir('initd')
subdir('devd')
subdir('posixd')
subdir('unix')
+20 -14
View File
@@ -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>
@@ -29,38 +28,45 @@ static void zn_printf(const char* msg, ...) {
zn_handle_t channel;
int other_fn(void* arg) {
zn_printf("posixd: Hello from the other thread named \"%s\"!\n", (const char*)arg);
channel = getauxval(AT_INIT_HANDLE);
struct message {
size_t id;
};
struct ipc_init_register_rq msg = {
.id = IPC_MSG_FOO,
};
#define MSG_HI \
IPC_START \
IPC_STRING \
IPC_END
int other_fn(void* arg) {
zn_printf("unix: Hello from the other thread named \"%s\"!\n", (const char*)arg);
channel = getauxval(0x1000);
struct message msg = {.id = 1};
char name[] = "posixd";
zn_status_t status = zn_channel_write(channel, nullptr, &msg, 0, sizeof(msg) + sizeof(name));
if (status != ZN_OK) {
zn_printf("posixd: %s\n", zn_status_to_string(status));
zn_printf("unix: %s\n", zn_status_to_string(status));
}
return 69;
}
int main(int argc, char* argv[], char* envp[]) {
zn_printf("posixd: starting...\n");
const char* thread_name = "posix_second_thread";
zn_printf("unix: starting...\n");
const char* thread_name = "unix_second_thread";
thrd_t thread;
int res = thrd_create(&thread, other_fn, (void*)thread_name);
if (res != thrd_success)
zn_printf("posixd: errno: %s\n", strerror(errno));
zn_printf("posixd: second thread created\n");
zn_printf("unix: errno: %s\n", strerror(errno));
zn_printf("unix: second thread created\n");
int res2;
zn_printf("posixd: waiting on second thread...\n");
zn_printf("unix: waiting on second thread...\n");
thrd_join(thread, &res2);
zn_printf("posixd: second thread exited with: %i\n", res2);
zn_printf("unix: second thread exited with: %i\n", res2);
return 0;
}
@@ -1,7 +1,7 @@
configure_file(configuration: cfg, output: 'config.h')
executable(
'posixd',
'unix',
'main.c',
'uname.c',
link_args: '-static',