From c512f3e3913a44f28aaaef12d128e1c675a52a78 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Fri, 13 May 2016 11:08:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=EF=BC=882=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 25_day/bootpack.h | 2 ++ 25_day/console.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/25_day/bootpack.h b/25_day/bootpack.h index bc14ac9..5f6554d 100644 --- a/25_day/bootpack.h +++ b/25_day/bootpack.h @@ -212,6 +212,8 @@ struct TASK { int level, priority; /* 优先级 */ struct FIFO32 fifo; struct TSS32 tss; + struct CONSOLE *cons; + int ds_base; }; struct TASKLEVEL { int running; /*正在运行的任务数量*/ diff --git a/25_day/console.c b/25_day/console.c index 30017c8..1af41a8 100644 --- a/25_day/console.c +++ b/25_day/console.c @@ -16,7 +16,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal) cons.cur_x = 8; cons.cur_y = 28; cons.cur_c = -1; - *((int *) 0x0fec) = (int) &cons; + task->cons = &cons; fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); @@ -293,7 +293,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline) datsiz = *((int *) (p + 0x0010)); dathrb = *((int *) (p + 0x0014)); q = (char *) memman_alloc_4k(memman, segsiz); - *((int *) 0xfe8) = (int) q; + task->ds_base = (int) q; set_segmdesc(gdt + 1003, finfo->size - 1, (int) p, AR_CODE32_ER + 0x60); set_segmdesc(gdt + 1004, segsiz - 1, (int) q, AR_DATA32_RW + 0x60); for (i = 0; i < datsiz; i++) { @@ -323,9 +323,9 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline) int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax) { - int ds_base = *((int *) 0xfe8); struct TASK *task = task_now(); - struct CONSOLE *cons = (struct CONSOLE *) *((int *) 0x0fec); + int ds_base = task->ds_base; + struct CONSOLE *cons = task->cons; struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHEET *sht; int *reg = &eax + 1; /* eax后面的地址*/ @@ -435,8 +435,8 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int int *inthandler0c(int *esp) { - struct CONSOLE *cons = (struct CONSOLE *) *((int *) 0x0fec); struct TASK *task = task_now(); + struct CONSOLE *cons = task->cons; char s[30]; cons_putstr0(cons, "\nINT 0C :\n Stack Exception.\n"); sprintf(s, "EIP = %08X\n", esp[11]); @@ -446,8 +446,8 @@ int *inthandler0c(int *esp) int *inthandler0d(int *esp) { - struct CONSOLE *cons = (struct CONSOLE *) *((int *) 0x0fec); struct TASK *task = task_now(); + struct CONSOLE *cons = task->cons; char s[30]; cons_putstr0(cons, "\nINT 0D :\n General Protected Exception.\n"); sprintf(s, "EIP = %08X\n", esp[11]);