adding base shell implementation(but its busted atm)

This commit is contained in:
shockrah 2019-12-05 02:45:19 -08:00
parent adfb460a5e
commit f4cfc6f64b
2 changed files with 42 additions and 0 deletions

37
shell.c Normal file
View File

@ -0,0 +1,37 @@
#include "shell.h"
#include "stlio.h"
#include "mem.h"
#include "pit.h"
char line[LINE_LENGTH];
void jmain(void) {
memset((u8*)line, 0x00, LINE_LENGTH);
while(1) {
printf("jos % ");
read(line, LINE_LENGTH);
printf("\n");
//asm("xchg bx, bx");
if(!strcmp("break", line)) {
printf("breaking out");
memset((u8*)line, 0x00, LINE_LENGTH);
}
else if(!strcmp("timer", line)) {
printf("Time tick: ");
printhex(pit_timer_ticks);
memset((u8*)line, 0x00, LINE_LENGTH);
}
else {
printf("Attempting a second read: ");
read(line, LINE_LENGTH);
printf(line);
}
}
}
void strip_newline(char* line) {
for(u32 i = 0;i <strlen(line); i++) {
if(line[i] == '\n') {
line[i] = '\0';
}
}
}

5
shell.h Normal file
View File

@ -0,0 +1,5 @@
#include "types.h"
void strip_newline(char*);
void jmain(void);