mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
First attempt at a UART driver. I'm not sure it's the most stable. Now that userspace is handling displaying logs, also removed serial and log output support from the kernel.
74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
#include <j6/errors.h>
|
|
#include <j6/types.h>
|
|
|
|
#include "logger.h"
|
|
#include "objects/process.h"
|
|
#include "syscalls/helpers.h"
|
|
|
|
namespace syscalls {
|
|
|
|
j6_status_t
|
|
process_create(j6_handle_t *handle)
|
|
{
|
|
process *child = construct_handle<process>(handle);
|
|
log::debug(logs::task, "Process %llx created", child->koid());
|
|
return j6_status_ok;
|
|
}
|
|
|
|
j6_status_t
|
|
process_start(j6_handle_t handle, uintptr_t entrypoint, j6_handle_t * handles, size_t handles_count)
|
|
{
|
|
process &p = process::current();
|
|
process *c = get_handle<process>(handle);
|
|
if (handles_count && !handles)
|
|
return j6_err_invalid_arg;
|
|
|
|
for (size_t i = 0; i < handles_count; ++i) {
|
|
kobject *o = p.lookup_handle(handles[i]);
|
|
if (o) c->add_handle(o);
|
|
}
|
|
|
|
return j6_err_nyi;
|
|
}
|
|
|
|
j6_status_t
|
|
process_kill(j6_handle_t handle)
|
|
{
|
|
process &p = process::current();
|
|
process *c = get_handle<process>(handle);
|
|
if (!c) return j6_err_invalid_arg;
|
|
|
|
log::debug(logs::task, "Process %llx killed by process %llx", c->koid(), p.koid());
|
|
c->exit(-1u);
|
|
|
|
return j6_status_ok;
|
|
}
|
|
|
|
j6_status_t
|
|
process_exit(int32_t status)
|
|
{
|
|
process &p = process::current();
|
|
log::debug(logs::task, "Process %llx exiting with code %d", p.koid(), status);
|
|
|
|
p.exit(status);
|
|
|
|
log::error(logs::task, "returned to exit syscall");
|
|
return j6_err_unexpected;
|
|
}
|
|
|
|
j6_status_t
|
|
process_give_handle(j6_handle_t handle, j6_handle_t sender, j6_handle_t *receiver)
|
|
{
|
|
process *dest = get_handle<process>(handle);
|
|
if (!dest) return j6_err_invalid_arg;
|
|
|
|
kobject *o = get_handle<kobject>(sender);
|
|
j6_handle_t out = dest->add_handle(o);
|
|
|
|
if (receiver)
|
|
*receiver = out;
|
|
return j6_status_ok;
|
|
}
|
|
|
|
} // namespace syscalls
|