-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.c
More file actions
57 lines (50 loc) · 1.43 KB
/
console.c
File metadata and controls
57 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "kstd.h"
#include "vga.h"
extern uint8_t _kernel_end[];
extern uint8_t _kernel_start[];
void handle_shell(char *input){
size_t len = strlen(input);
char buf[len+1];
buf[len] = '\0';
memcpy(buf,input,len);
if(strcmp(buf,"hi")){
terminal_writestring("Hello, World\n");
return;
}
if(strcmp(buf,"yousef")){
terminal_writestring("Yousef is 5awal and metnak\n");
return;
}
if(strcmp(buf,"ksize")){
uint32_t diff = (uint32_t) _kernel_end - (uint32_t)_kernel_start;
char bbuf[12];
itoa(diff,bbuf,10);
terminal_writestring("Kernel is ");
terminal_writestring(bbuf);
terminal_writestring(" Bytes big\n");
return;
}
char* tokens[20];
size_t count = split(input,' ',tokens,20);
if(count > 0 && strcmp(tokens[0],"current")){
char a[2];
itoa(active_tty,a,10);
terminal_writestring(a);
terminal_writestring("\n");
return;
}
if (count > 0 && strcmp(tokens[0], "shell")) {
if (count < 2) {
terminal_writestring("Usage: <num>");
return;
}
int shell_num = stoia(tokens[1]);
if (shell_num > 2) {
terminal_writestring("Invalid argument\n");
return;
}
changeout(handle_shell, shell_num);
return;
}
terminal_writestring("Invalid command\n");
}