Add: begin shell with help command
This commit is contained in:
Binary file not shown.
@@ -4,8 +4,6 @@
|
|||||||
#include "idt.h"
|
#include "idt.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define BUFFER_SIZE 256
|
|
||||||
|
|
||||||
int kmain(int retvalue)
|
int kmain(int retvalue)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -34,10 +32,7 @@ int kmain(int retvalue)
|
|||||||
//timer_install();
|
//timer_install();
|
||||||
keyboard_install();
|
keyboard_install();
|
||||||
|
|
||||||
char input_buffer[BUFFER_SIZE];
|
shell_install();
|
||||||
colorputs("Enter something: ", 9);
|
|
||||||
get_input(input_buffer, BUFFER_SIZE);
|
|
||||||
printf("\nYou entered: %s\n", input_buffer);
|
|
||||||
|
|
||||||
return retvalue;
|
return retvalue;
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/kernel/shell.c
Normal file
24
src/kernel/shell.c
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "system.h"
|
||||||
|
#include "../libc/stdio.h"
|
||||||
|
#include "../libc/string.h"
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 256
|
||||||
|
|
||||||
|
void shell_install()
|
||||||
|
{
|
||||||
|
while (1) // Bad!!
|
||||||
|
{
|
||||||
|
char input_buffer[BUFFER_SIZE];
|
||||||
|
colorputs("blankos> ", 9);
|
||||||
|
get_input(input_buffer, BUFFER_SIZE);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// Childish shell
|
||||||
|
|
||||||
|
if (strcmp(input_buffer, "help") == 0)
|
||||||
|
{
|
||||||
|
printf("This is the Blank Operating System\ndesigned for fun by xamidev\n\nCommand help:\n\n\thelp - shows this message\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,5 +21,6 @@ void timer_install();
|
|||||||
void delay(int ticks);
|
void delay(int ticks);
|
||||||
void keyboard_install();
|
void keyboard_install();
|
||||||
char keyboard_getchar();
|
char keyboard_getchar();
|
||||||
|
void shell_install();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ void putc(char c)
|
|||||||
case '\r':
|
case '\r':
|
||||||
VGA_X = 0;
|
VGA_X = 0;
|
||||||
break;
|
break;
|
||||||
|
case '\t':
|
||||||
|
VGA_X += 4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
putchar(VGA_X, VGA_Y, c);
|
putchar(VGA_X, VGA_Y, c);
|
||||||
VGA_X++;
|
VGA_X++;
|
||||||
@@ -114,6 +117,9 @@ void colorputc(char c, unsigned int color)
|
|||||||
case '\r':
|
case '\r':
|
||||||
VGA_X = 0;
|
VGA_X = 0;
|
||||||
break;
|
break;
|
||||||
|
case '\t':
|
||||||
|
VGA_X += 4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
putchar(VGA_X, VGA_Y, c);
|
putchar(VGA_X, VGA_Y, c);
|
||||||
putcolor(VGA_X, VGA_Y, color);
|
putcolor(VGA_X, VGA_Y, color);
|
||||||
|
|||||||
@@ -7,3 +7,13 @@ int strlen(char* str)
|
|||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strcmp(char* str1, char* str2)
|
||||||
|
{
|
||||||
|
while (*str1 && (*str1 == *str2))
|
||||||
|
{
|
||||||
|
str1++;
|
||||||
|
str2++;
|
||||||
|
}
|
||||||
|
return *(const unsigned char*)str1 - *(const unsigned char*)str2;
|
||||||
|
}
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
#define INCLUDE_STRING_H
|
#define INCLUDE_STRING_H
|
||||||
|
|
||||||
int strlen(char* str);
|
int strlen(char* str);
|
||||||
|
int strcmp(char* str1, char* str2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user