Skip to content

Commit

Permalink
updaterro
Browse files Browse the repository at this point in the history
  • Loading branch information
werdl committed Jun 13, 2023
1 parent 051d03f commit e87599c
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 59 deletions.
2 changes: 1 addition & 1 deletion initrd/color.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TERM
PINK
1 change: 1 addition & 0 deletions initrd/user.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root
57 changes: 10 additions & 47 deletions kernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "util/splash.h" // generate random splash
#include <sys/cpuid.h> // cpuid utils
#include <nerd.h> // consts
#include <io/clr.h>
int gui();
int text_edit();
int move(const char * inp);
Expand All @@ -33,48 +34,7 @@ char typed2[1024];
char * position[3][3]={{"0,0","1,0","2,0"},
{"0,1","1,1","2,1"},
{"0,2","1,2","2,2"}}; // which gui box you are on
bool checkclr(char * color) {
return !memcmp(search("color.conf"),color,strlen(color));
}
#define check(x) checkclr(x)
int getcolors(bool type) {
static int defcol;
static int deftype;
if (check("TERM")) {
defcol=2;
deftype=10;
} else if (check("PINK")) {
defcol=5;
deftype=13;
} else if (check("BORE")) {
defcol=8;
deftype=7;
} else if (check("ANGER")) {
defcol=4;
deftype=12;
} else if (check("BLUE")) {
defcol=3;
deftype=11;
} else if (check("FIRE")) {
defcol=4;
deftype=14;
} else if (check("RETRO")) {
defcol=2;
deftype=14;
} else if (check("LIGHT")) {
panic("Light mode activated, defensive kernel panic initiated","Wrong mode",1);
}

if (type) { // default type
return deftype;
} else return defcol;
}
int defcol() {
return getcolors(0);
}
int deftype() {
return getcolors(1);
}

void keyboard_handler_main(void)
{
createfiles(); //function call from initrd.h
Expand Down Expand Up @@ -180,8 +140,11 @@ int kmain(void)
{
createfiles();
srand(rnd);
if (USER=="root") {sudo=true;}
if (search("user.conf")=="root") {sudo=true;}
else {sudo=false;}
if (search("user.conf")=="") {
panic("user.conf instantiated to empty string","No user set",1);
}
for (int y=0;y<1024;y++) {
typed[y]="";
}
Expand Down Expand Up @@ -229,15 +192,15 @@ int kmain(void)
printrn=false;
debug=false;
bool toclear=false;
printf("Logged in as ");
printf(USER);
printf("\n");
printf("Logged in as \"");
printf(search("user.conf"));
printf("\"\n");
// char buff[15];
// srand(rnd);
// itoa(rand(),buff,10);
// printf(buff);

printf("\nDebugging ON, OFF or SOME?\n");
printf("Debugging ON, OFF or SOME?\n");
bool q=true;
bool playing=false;
int toss;
Expand Down
7 changes: 5 additions & 2 deletions libc/file/initrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ void insert(file_t data) {
link->next = head;
head = link;
}
file_t fil_test1txt;file_t fil_test2txt;file_t fil_colorconf;file_t fil_boot_timeconf;void createfiles() {
file_t fil_test1txt;file_t fil_test2txt;file_t fil_colorconf;file_t fil_boot_timeconf;file_t fil_userconf;void createfiles() {
create_readonly("hellO!\n\
hi","test1.txt",&fil_test1txt);
insert(fil_test1txt);

create_readonly("bjasbj","test2.txt",&fil_test2txt);
insert(fil_test2txt);

create_readonly("TERM","color.conf",&fil_colorconf);
create_readonly("PINK","color.conf",&fil_colorconf);
insert(fil_colorconf);

create_readonly("5","boot_time.conf",&fil_boot_timeconf);
insert(fil_boot_timeconf);

create_readonly("root","user.conf",&fil_userconf);
insert(fil_userconf);
}
8 changes: 3 additions & 5 deletions libc/fs/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,14 @@ void dump() {
register int ebp asm("ebp");
printh(ebp);

printf("\nContents of source: ");
register int esi asm("esi");
printh(esi);
printf("\nContents of destination: ");
register int edi asm("edi");
printh(edi);
setclr(4,BLUE);
printf("\nTry restarting your computer\n");
printf("\nTry restarting your computer (");
printf(currentdebugmsg);
setclr(15,BLUE);
printf("_ _ _ _____ _____ ______ _____ ___________ _ ");
printf(")\n_ _ _ _____ _____ ______ _____ ___________ _ ");
printf("\n| \\ | | | | _ / ___| | ___ / ___| _ | _ | |");
printf("\n| \\| | ___ _ __ __| | | | \\ `--. | |_/ \\ `--.| | | | | | | |");
printf("\n| . ` |/ _ | '__/ _` | | | |`--. \\ | ___ \\`--. | | | | | | | |");
Expand Down
42 changes: 42 additions & 0 deletions libc/io/clr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
bool checkclr(char * color) {
return !memcmp(search("color.conf"),color,strlen(color));
}
#define check(x) checkclr(x)
int getcolors(bool type) {
static int defcol;
static int deftype;
if (check("TERM")) {
defcol=2;
deftype=10;
} else if (check("PINK")) {
defcol=5;
deftype=13;
} else if (check("BORE")) {
defcol=8;
deftype=7;
} else if (check("ANGER")) {
defcol=4;
deftype=12;
} else if (check("BLUE")) {
defcol=3;
deftype=11;
} else if (check("FIRE")) {
defcol=4;
deftype=14;
} else if (check("RETRO")) {
defcol=2;
deftype=14;
} else if (check("LIGHT")) {
panic("Light mode activated, defensive kernel panic initiated","Wrong mode",1);
}

if (type) { // default type
return deftype;
} else return defcol;
}
int defcol() {
return getcolors(0);
}
int deftype() {
return getcolors(1);
}
4 changes: 4 additions & 0 deletions libc/kernel/abort.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// #include <stdlib.h>
#include "kernel.h"
void dump();
char * currentdebugmsg;
char * currentpanicmsg;
void panic(const char * debug, const char * msg, bool fatal) {
currentdebugmsg=debug;
currentpanicmsg=msg;
setclr(11,0);
mse_nl();
printf("\nkernel: ");
Expand Down
4 changes: 1 addition & 3 deletions libc/kernel/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ void kprintd(const char * msg, bool second) {
}
#define OVERWRITE false //change to true: files can be overwritten\n
#define WARN true //change to false: warnings not given by default\n
#define FULLDEBUG false //change to true: enable full debugging by default\n
#define USER "root" //change default username: if changed to root, sudo will be autoenabled\n
#define BOOT_TIME 5 //the number of seconds the boot screen is shown\n
#define FULLDEBUG false //change to true: enable full debugging by default\n#define BOOT_TIME 5 //the number of seconds the boot screen is shown\n

2 changes: 1 addition & 1 deletion libc/random/rand.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ void srand(unsigned int seed)
next = seed;
}
unsigned int rnd=
1686641486
1686642180
;

0 comments on commit e87599c

Please sign in to comment.