[kernel] Make stdout channel available to processes

The "fake" stdout channel is now being passed in the new j6_process_init
structure to processes, and nulldrv now uses it to print a message to
the console.
This commit is contained in:
2020-08-30 18:47:14 -07:00
parent 724b846ee4
commit 42455873ff
7 changed files with 58 additions and 10 deletions

View File

@@ -7,11 +7,14 @@
#include <j6libc/syscalls.h>
const char message[] = "Hello! This is a message being sent over a channel!";
const char message[] = "Hello! This is a message being sent over a channel!\n";
char inbuf[1024];
j6_handle_t chan = j6_handle_invalid;
j6_process_init *init = nullptr;
extern "C" {
void _init_libc(j6_process_init *);
int main(int, const char **);
}
@@ -40,6 +43,12 @@ thread_proc()
_syscall_thread_exit(0);
}
void
_init_libc(j6_process_init *i)
{
init = i;
}
int
main(int argc, const char **argv)
{
@@ -52,6 +61,11 @@ main(int argc, const char **argv)
if (result != j6_status_ok)
return result;
size_t size = sizeof(message);
result = _syscall_channel_send(init->output, &size, (void*)message);
if (result != j6_status_ok)
return result;
_syscall_system_log("main thread created channel");
result = _syscall_thread_create(reinterpret_cast<void*>(&thread_proc), &child);

View File

@@ -3,19 +3,22 @@ mymessage:
resq 1024
extern main
extern _init_libc
extern exit
section .text
global _start
_start:
xor rbp, rbp ; Sentinel rbp
push rbp
push rbp
mov rbp, rsp
mov rdi, rsp
sub rdi, 8
call _init_libc
mov rdi, 0
mov rsi, 0
call main
mov rdi, rax