Compare commits

...

2 commits

Author SHA1 Message Date
Imbus
b8b8f58fee Cleaning up init, splitting out banner to separate header. 2025-01-11 15:52:03 +01:00
Imbus
bae44d0333 Halt system on shell exit 2025-01-11 15:51:10 +01:00
2 changed files with 31 additions and 14 deletions

25
user/banner.h Normal file
View file

@ -0,0 +1,25 @@
unsigned char banner[] = {
0x0a, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96,
0x88, 0xe2, 0x95, 0x97, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88,
0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88,
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x0a, 0x20, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2,
0x96, 0x88, 0xe2, 0x95, 0x97, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0xe2, 0x96,
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91,
0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
0x95, 0x90, 0xe2, 0x95, 0x9d, 0x0a, 0x20, 0x20, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91, 0x20,
0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x91, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96,
0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x0a, 0x20, 0x20,
0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97,
0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96,
0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x90,
0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x97, 0x0a, 0x20, 0x20, 0xe2,
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
0x95, 0x97, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
0x95, 0x94, 0xe2, 0x95, 0x9d, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2,
0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x95, 0x94, 0xe2, 0x95, 0x9d, 0x0a, 0x20, 0x20, 0xe2, 0x95,
0x9a, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20,
0x20, 0xe2, 0x95, 0x9a, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x9d, 0x20, 0x20, 0x20,
0xe2, 0x95, 0x9a, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2, 0x95, 0x90, 0xe2,
0x95, 0x9d, 0x0a, 0x0a, 0x00,
};

View file

@ -8,21 +8,10 @@
#include "kernel/file.h"
#include "user/user.h"
#include "kernel/fcntl.h"
#include "user/banner.h"
char *argv[] = { "sh", 0 };
// clang-format off
const char *banner =
"\n $$\\ $$\\ $$$$$$\\\n"
" $$ | $$ | $$ __$$\\ \n"
" \\$$\\ $$ |$$\\ $$\\ $$ / \\__|\n"
" \\$$$$ / \\$$\\ $$ |$$$$$$$\\ \n"
" $$ $$< \\$$\\$$ / $$ __$$\\ \n"
" $$ /\\$$\\ \\$$$ / $$ / $$ |\n"
" $$ / $$ | \\$ / $$$$$$ |\n"
" \\__| \\__| \\_/ \\______/\n\n";
// clang-format on
int
main(void)
{
@ -37,7 +26,8 @@ main(void)
for(;;) {
printf("init: starting sh\n");
printf(banner);
// printf(banner);
printf((const char *)banner);
pid = fork();
if(pid < 0) {
printf("init: fork failed\n");
@ -54,7 +44,9 @@ main(void)
// or if a parentless process exits.
wpid = wait((int *)0);
if(wpid == pid) {
// the shell exited; restart it.
// FIXME: Obviously not how things should be done
printf("\nShell exited... Halting\n");
halt();
break;
} else if(wpid < 0) {
printf("init: wait returned an error\n");