Files
rosetta/sys/ld/main.c

63 lines
1.3 KiB
C
Raw Normal View History

#define MSG_IMPLEMENTATION
2026-02-19 19:30:07 +00:00
#include <mango/log.h>
#include <mango/msg.h>
2026-02-19 19:30:07 +00:00
#include <mango/types.h>
#include <rosetta/fs.h>
#include <stdio.h>
2026-02-23 18:46:13 +00:00
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
2026-02-19 19:30:07 +00:00
int main(
int argc,
const char **argv,
kern_handle_t task,
kern_handle_t address_space,
uintptr_t bsp_base)
{
2026-02-23 18:46:13 +00:00
void *brk = sbrk(0);
kern_logf("brk=%p", brk);
void *buf = malloc(64);
if (buf) {
memset(buf, 0x0, 64);
kern_logf("allocated 64 bytes at %p", buf);
} else {
kern_logf("malloc() failed");
}
kern_handle_t port;
kern_status_t status = port_create(&port);
if (status != KERN_OK) {
kern_logf("port creation failed %d", status);
return -1;
}
#if 1
port_connect(port, 0, 0);
const char *str = "hello";
char new_buf[512] = {0};
struct msg_string new = {.str_buf = new_buf, .str_max = sizeof new_buf};
kern_logf("sending msg: uppercase(%s)", str);
status = fs_uppercase(port, str, &new);
kern_logf("uppercase(%s) = %s", str, new_buf);
const char *path = "/usr/lib/libc.so";
int flags = 4;
int err = 0;
kern_logf("sending msg: open(%s, %d)", path, flags);
status = fs_open(port, path, flags, &err);
if (status != KERN_OK) {
kern_logf("open call failed (status %d)", status);
} else {
kern_logf("open(%s, %d) = %d", path, flags, err);
}
#endif
2026-02-19 19:30:07 +00:00
return 0;
}