[sys] Special-case stdio for now, need to make these actual files later.

This commit is contained in:
Kevin Lange 2011-04-24 21:09:36 -05:00
parent ba82c63a34
commit a99fbf39a2
2 changed files with 21 additions and 0 deletions

View File

@ -177,6 +177,12 @@ start_shell() {
set_kbd(0,0,0); set_kbd(0,0,0);
} else if (!strcmp(cmd, "multiboot")) { } else if (!strcmp(cmd, "multiboot")) {
dump_multiboot(mboot_ptr); dump_multiboot(mboot_ptr);
} else if (!strcmp(cmd, "exec")) {
if (tokenid < 2) {
continue;
}
int ret = system(argv[1], tokenid - 1, &argv[1]);
kprintf("Returned %d\n", ret);
} else if (!strcmp(cmd, "test-alloc")) { } else if (!strcmp(cmd, "test-alloc")) {
kprintf("Testing the kernel allocator...\n"); kprintf("Testing the kernel allocator...\n");
uint32_t sizers[] = { 1, 4, 4, 32, 64, 256, 1024, 795, 2042, 6204, 2525 }; uint32_t sizers[] = { 1, 4, 4, 32, 64, 256, 1024, 795, 2042, 6204, 2525 };

View File

@ -5,6 +5,7 @@
#include <system.h> #include <system.h>
#include <syscall.h> #include <syscall.h>
#define SPECIAL_CASE_STDIO
/* /*
* System calls themselves * System calls themselves
@ -38,6 +39,12 @@ static int exit(int retval) {
} }
static int read(int fd, char * ptr, int len) { static int read(int fd, char * ptr, int len) {
#ifdef SPECIAL_CASE_STDIO
if (fd == 0) {
kgets(ptr, len);
return strlen(ptr);
}
#endif
if (fd >= current_task->next_fd || fd < 0) { if (fd >= current_task->next_fd || fd < 0) {
return -1; return -1;
} }
@ -49,6 +56,14 @@ static int read(int fd, char * ptr, int len) {
} }
static int write(int fd, char * ptr, int len) { static int write(int fd, char * ptr, int len) {
#ifdef SPECIAL_CASE_STDIO
if (fd == 1 || fd == 2) {
for (int i = 0; i < len; ++i) {
ansi_put(ptr[i]);
}
return len;
}
#endif
if (fd >= current_task->next_fd || fd < 0) { if (fd >= current_task->next_fd || fd < 0) {
return -1; return -1;
} }