mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
If you type a filename into the shell, it will print out the file (even .bin files)
This commit is contained in:
+47
-7
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#define PROMPT "#> "
|
#define PROMPT "#> "
|
||||||
|
|
||||||
|
char filetable[512];
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Interrupts
|
// Interrupts
|
||||||
setupIdt();
|
setupIdt();
|
||||||
@@ -25,9 +27,10 @@ void main() {
|
|||||||
clear(0x0f);
|
clear(0x0f);
|
||||||
print("kern.\n\n", 0x0f);
|
print("kern.\n\n", 0x0f);
|
||||||
|
|
||||||
|
diskRead(1, 1, filetable); // Read the filetable and store it in memory
|
||||||
|
|
||||||
// Run Interactive Shell Program
|
// Run Interactive Shell Program
|
||||||
// TODO: Make it in another file
|
// TODO: Make it in another file
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
print(PROMPT, 0x0a);
|
print(PROMPT, 0x0a);
|
||||||
char* input = read('\n', 0x0f);
|
char* input = read('\n', 0x0f);
|
||||||
@@ -115,9 +118,7 @@ void main() {
|
|||||||
// TODO: print(" reboot | Reboots the system\n", 0x0f);
|
// TODO: print(" reboot | Reboots the system\n", 0x0f);
|
||||||
print(" test | Performs tests\n", 0x0f);
|
print(" test | Performs tests\n", 0x0f);
|
||||||
} else if (strcmp(input, "ls") == 0) {
|
} else if (strcmp(input, "ls") == 0) {
|
||||||
char filetab[512];
|
char* ft = filetable;
|
||||||
char* ft = filetab;
|
|
||||||
diskRead(1, 1, filetab);
|
|
||||||
|
|
||||||
while (*ft != '\0') {
|
while (*ft != '\0') {
|
||||||
char filename[15] = { 0 };
|
char filename[15] = { 0 };
|
||||||
@@ -177,9 +178,48 @@ void main() {
|
|||||||
}
|
}
|
||||||
print("Tests Finished!\n", 0x0f);
|
print("Tests Finished!\n", 0x0f);
|
||||||
} else {
|
} else {
|
||||||
print("Command not found: ", 0x0c);
|
char* ft = filetable;
|
||||||
print(input, 0x0c);
|
uint8_t found = 0;
|
||||||
putc('\n', 0x0f);
|
|
||||||
|
while (*ft != '\0') {
|
||||||
|
char filename[15] = { 0 };
|
||||||
|
uint8_t offset = 0;
|
||||||
|
for (uint8_t i = 0; i < 14; i++) {
|
||||||
|
if (i == 9) {
|
||||||
|
filename[offset++] = '.';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*ft != '\0') { filename[offset++] = *ft; }
|
||||||
|
ft++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(input, filename) == 0) {
|
||||||
|
ft++; // RESERVED
|
||||||
|
uint8_t sector = *ft++;
|
||||||
|
uint8_t size = *ft++;
|
||||||
|
|
||||||
|
char buf[size * 512];
|
||||||
|
diskRead(sector, size, buf);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size * 512; i++) {
|
||||||
|
if (buf[i] != '\0') {
|
||||||
|
putc(buf[i], 0x0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
putc('\n', 0x0f);
|
||||||
|
|
||||||
|
found++; // Set found to 1
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ft += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
print("Command not found: ", 0x0c);
|
||||||
|
print(input, 0x0c);
|
||||||
|
putc('\n', 0x0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user