Less-broken context switching, maybe? Also, run the terminal, type 'exit'

This commit is contained in:
Kevin Lange 2011-03-03 23:12:26 -06:00
parent 24ff0b84f2
commit 0b3ecfd4e4
4 changed files with 19 additions and 5 deletions

View File

@ -189,7 +189,10 @@ start_shell() {
int i = 0xFFFFFFFF;
int j = *(int *)i;
j = 0xDEADBEEF;
} else {
} else if (!strcmp(cmd, "exit")) {
kprintf("Good byte.\n");
break;
}else {
kprintf("Unrecognized command: %s\n", cmd);
}
}

View File

@ -3,6 +3,7 @@
* vim:noexpandtab
*/
#include <system.h>
#define KERNEL_STACK_SIZE 0x1000
__volatile__ task_t * current_task;
__volatile__ task_t * ready_queue;
@ -120,7 +121,7 @@ fork() {
new_task->ebp = 0;
new_task->eip = 0;
new_task->page_directory = directory;
new_task->next = 0;
new_task->next = NULL;
task_t * tmp_task = (task_t *)ready_queue;
while (tmp_task->next) {
tmp_task = tmp_task->next;
@ -156,7 +157,7 @@ switch_task() {
__asm__ __volatile__ ("mov %%esp, %0" : "=r" (esp));
__asm__ __volatile__ ("mov %%ebp, %0" : "=r" (ebp));
eip = read_eip();
if (eip == 0x12345) {
if (eip == 0x10000) {
return;
}
current_task->eip = eip;
@ -175,8 +176,9 @@ switch_task() {
"mov %1, %%esp\n"
"mov %2, %%ebp\n"
"mov %3, %%cr3\n"
"mov $0x12345, %%eax\n"
"mov $0x10000, %%eax\n"
"sti\n"
"jmp *%%ecx"
: : "r" (eip), "r" (esp), "r" (ebp), "r" (current_directory->physical_address));
switch_page_directory(current_task->page_directory);
}

View File

@ -156,6 +156,7 @@ typedef struct task {
uintptr_t eip;
page_directory_t * page_directory;
struct task *next;
uintptr_t kernel_stack;
} task_t;
extern void tasking_install();

View File

@ -116,7 +116,7 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
}
__asm__ __volatile__ ("sti");
//start_shell();
start_shell();
/*
* Aw man...
@ -124,6 +124,14 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
fork();
#if 0
if (child == 0) {
kprintf("Hello world.\n");
} else {
kprintf("child: %d\tme: %d\n", child, getpid());
}
#endif
while (1) {
putch(48 + getpid());
}