-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.c
More file actions
141 lines (118 loc) · 3.54 KB
/
Copy pathkernel.c
File metadata and controls
141 lines (118 loc) · 3.54 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#define TEXT_COLOUR 0x0a
#include <stdbool.h>
#include "ports.h"
#include "games.h"
#include "screen.h"
#include "cursor.h"
#include "tools.h"
#include "strings.h"
#include "isr.h"
#include "keyboard.h"
#include "types.h"
#include "hardware.h"
#include "sound.h"
#define OSVER "1.0"
char prompt[] = "BustOS>";
void kernel() {
set_colour(TEXT_COLOUR);
clear_screen();
print_logo();
char welcome[] = "Welcome To BustOS - 32 Bit Protected Mode\n";
printf(welcome);
char isr_msg[] = "Installing interrupt service routines (ISRs).\n";
printf(isr_msg);
isr_install();
char kb_msg[] = "Initializing keyboard (IRQ 1).\n";
printf(kb_msg);
init_keyboard();
char enable_msg[] = "Enabling external interrupts.\n";
printf(enable_msg);
asm volatile("sti");
crlf();
printf(prompt);
//char tux[] = "Linux Sucks";
//tuxsay(tux);
}
void combine_tokens(char* tokens[], int token_count, char* message) {
for (int i = 1; i < token_count; i++) {
append_string(message, tokens[i]);
if (i < token_count - 1) {
append_string(message, " "); // Add space between words
}
}
}
void execute_command(char* input) {
char* tokens[MAX_TOKENS]; // Make sure MAX_TOKENS is defined in strings.h
int token_count = 0;
split_string(input, ' ', tokens, &token_count);
//Convert 1st token to uppercase to remove case sensitivity
capitalize_string(tokens[0]);
if (compare_string(tokens[0], "ECHO") ==0) {
// Combine all tokens after ECHO
char message[256] = "";
combine_tokens(tokens, token_count, message);
crlf();
printf(message);
}
else if (compare_string(tokens[0], "COWSAY") ==0) {
//char msg[] = "\nCowsay\n";
//printf(msg);
// Combine all tokens after COWSAY
char message[256] = "";
combine_tokens(tokens, token_count, message);
crlf();
cowsay(message);
}
else if (compare_string(tokens[0], "TUXSAY") ==0) {
//char msg[] = "\nTuxsay\n";
//printf(msg);
// Combine all tokens after TUXSAY
char message[256] = "";
combine_tokens(tokens, token_count, message);
crlf();
tuxsay(message);
}
else if (compare_string(tokens[0], "HWINFO") == 0) {
print_hardware_info();
}
else if (compare_string(input, "HELP") == 0) {
char message[] = "\nECHO: prints to the terminal the string used as a parameter"
"\nCOWSAY: Makes a cow say the string used as a parameter"
"\nTUXSAY: Makes Tux say the string used as a parameter"
"\nHWINFO: Give Specs"
"\nCLEAR: Clear screen"
"\nVERSION: BustOS Version"
"\nEXIT: Leave BustOS\n";
printf(message);
}
else if (compare_string(input, "CLEAR") == 0) {
clear_screen();
}
else if (compare_string(input, "VERSION") == 0) {
printf("\nBustOS Version ");
printf(OSVER);
crlf();
}
else if (compare_string(input, "EXIT") == 0) {
char msg[] = "\nExit\n";
printf(msg);
asm volatile("hlt"); // halt cpu
}
else if (compare_string(input, "") == 0) {
}
else {
char msg[] = ": command not found\n";
crlf();
printf(input);
printf(msg);
}
//Debug Info
//char msg[] = "\ncommand: ";
//printf(msg);
//printf(input);
crlf();
printf(prompt);
}
void _start() {
kernel();
}