2024-07-28 10:11:15 -04:00
|
|
|
#include "../lib/strcmp.h"
|
|
|
|
|
|
|
|
void puts(const char *str) {
|
|
|
|
asm volatile (
|
|
|
|
"movl $1, %%eax\n\t"
|
|
|
|
"movl $1, %%edi\n\t"
|
|
|
|
"movl %0, %%esi\n\t"
|
|
|
|
"int $0x80"
|
|
|
|
:
|
|
|
|
: "r"(str)
|
|
|
|
: "%eax", "%edi", "%esi"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void read(int fd, void *buf, int size) {
|
|
|
|
asm volatile (
|
|
|
|
"movl $0, %%eax\n\t"
|
|
|
|
"int $0x80"
|
|
|
|
:
|
|
|
|
: "D"(fd), "d"(size), "S"(buf)
|
|
|
|
: "eax"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-29 19:43:44 -04:00
|
|
|
void reboot() {
|
|
|
|
asm volatile (
|
|
|
|
"movl $2, %%eax\n\t"
|
|
|
|
"int $0x80"
|
|
|
|
:
|
|
|
|
:
|
|
|
|
: "eax"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-28 10:11:15 -04:00
|
|
|
extern char *buf;
|
|
|
|
|
|
|
|
void _start() {
|
|
|
|
char buf1[256] = {0};
|
|
|
|
puts("Welcome to the Hazel user shell!\n");
|
|
|
|
while (1) {
|
|
|
|
puts("> ");
|
|
|
|
read(0, buf1, 256);
|
2024-07-29 19:43:44 -04:00
|
|
|
if (!strcmp(buf1, "SKIBIDI")) {
|
|
|
|
puts("dop dop yes yes!\n");
|
|
|
|
} else if (!strcmp(buf1, "REBOOT")) {
|
|
|
|
reboot();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
puts("unknown command!\n");
|
|
|
|
}
|
2024-07-28 10:11:15 -04:00
|
|
|
}
|
|
|
|
}
|