#include "console.h" #include "process.h" #include "unistd.h" #include "stdlib.h" // kludge... these are allocated statically in kernel memory for now struct process_item print_a, print_b; void print_a_entry() { printf("Process %d starting!\n", cur_proc->pid); int *i = valloc_page(); printf("%d got 0x%x\n", cur_proc->pid, i); *i = 0; printf("%d has %d\n", cur_proc->pid, *i); // for (;;); for (;;) { putchar(*i + 'A'); } } void print_b_entry() { printf("Process %d starting!\n", cur_proc->pid); int *i = valloc_page(); printf("%d got 0x%x\n", cur_proc->pid, i); *i = 1; printf("%d has %d\n", cur_proc->pid, *i); // for (;;); for (;;) { putchar(*i + 'A'); } } void *omalloc(int n) { void *p = malloc(n); printf("Got %x\n", p); return p; } void ofree(void *p) { printf("Freeing %x\n", p); free(p); } void init() { printf(" - init process started\n"); process_init(&print_a, (unsigned int)&print_a_entry); process_init(&print_b, (unsigned int)&print_b_entry); char buf[21]; fd_t kbb = open("/dev/kebab", 0); read(kbb, (char *)buf, 20); buf[20] = '\0'; printf(buf); printf("Opening the keyboard\n"); fd_t kbd = open("/dev/kbd", 0); printf("Done\n"); printf("Opening the tty\n"); fd_t tty = open("/dev/tty", 0); printf("Done\n"); char *message = "THIS! IS! WRITE()!!!\n"; write(tty, message, strlen(message)); printf("Let's try reading the keyboard a bit"); // start_process(&print_a); // start_process(&print_b); for(;;) { char c; read(kbd, &c, 1); printf("0x%x ", c); } // dumpheap(); /* void *foo = omalloc(1024); omalloc(10); dumpheap(); ofree(foo); omalloc(128); omalloc(256); omalloc(1024 * 12);*/ dumpheap(); // hax: we don't really need time cur_proc->timeslice = 1; printf(" - init loops forever now\n"); for (;;) ; }