From 51e4e0664800eaca89269c62c2c860d78893988b Mon Sep 17 00:00:00 2001 From: Yourtion Date: Fri, 29 Apr 2016 13:04:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 19_day/Makefile | 6 +++- 19_day/console.c | 84 +++++++++++++++++++++++++++++++++++------------- 19_day/hlt.nas | 5 +++ 3 files changed, 72 insertions(+), 23 deletions(-) create mode 100644 19_day/hlt.nas diff --git a/19_day/Makefile b/19_day/Makefile index bec5953..4e019c9 100644 --- a/19_day/Makefile +++ b/19_day/Makefile @@ -46,7 +46,10 @@ bootpack.bim : $(OBJS_BOOTPACK) Makefile bootpack.hrb : bootpack.bim Makefile $(BIM2HRB) bootpack.bim bootpack.hrb 0 -haribote.sys : asmhead.bin bootpack.hrb Makefile +hlt.hrb : hlt.nas Makefile + $(NASK) hlt.nas hlt.hrb hlt.lst + +haribote.sys : asmhead.bin bootpack.hrb hlt.hrb Makefile copy /B asmhead.bin+bootpack.hrb haribote.sys haribote.img : ipl10.bin haribote.sys Makefile @@ -55,6 +58,7 @@ haribote.img : ipl10.bin haribote.sys Makefile copy from:haribote.sys to:@: \ copy from:ipl10.nas to:@: \ copy from:make.bat to:@: \ + copy from:hlt.hrb to:@: \ imgout:haribote.img # 其他指令 diff --git a/19_day/console.c b/19_day/console.c index 4001293..b77b299 100644 --- a/19_day/console.c +++ b/19_day/console.c @@ -4,28 +4,6 @@ #include #include -int cons_newline(int cursor_y, struct SHEET *sheet) -{ - int x, y; - if (cursor_y < 28 + 112) { - cursor_y += 16; /*换行*/ - } else { - /*滚动*/ - for (y = 28; y < 28 + 112; y++) { - for (x = 8; x < 8 + 240; x++) { - sheet->buf[x + y * sheet->bxsize] = sheet->buf[x + (y + 16) * sheet->bxsize]; - } - } - for (y = 28 + 112; y < 28 + 128; y++) { - for (x = 8; x < 8 + 240; x++) { - sheet->buf[x + y * sheet->bxsize] = COL8_000000; - } - } - sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128); - } - return cursor_y; -} - void console_task(struct SHEET *sheet, unsigned int memtotal) { struct TIMER *timer; @@ -36,6 +14,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal) int x, y; struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600); int *fat = (int *) memman_alloc_4k(memman, 4 * 2880); + struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT; fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); @@ -207,6 +186,45 @@ void console_task(struct SHEET *sheet, unsigned int memtotal) cursor_y = cons_newline(cursor_y, sheet); } cursor_y = cons_newline(cursor_y, sheet); + } else if (strcmp(cmdline, "hlt") == 0) { + /*启动应用程序hlt.hrb */ + for (y = 0; y < 11; y++) { + s[y] = ' '; + } + s[0] = 'H'; + s[1] = 'L'; + s[2] = 'T'; + s[8] = 'H'; + s[9] = 'R'; + s[10] = 'B'; + for (x = 0; x < 224; ) { + if (finfo[x].name[0] == 0x00) { + break; + } + if ((finfo[x].type & 0x18) == 0) { + for (y = 0; y < 11; y++) { + if (finfo[x].name[y] != s[y]) { + goto hlt_next_file; + } + } + break; /*找到文件*/ + } + hlt_next_file: + x++; + } + if (x < 224 && finfo[x].name[0] != 0x00) { + /*找到文件的情况*/ + p = (char *) memman_alloc_4k(memman, finfo[x].size); + file_loadfile(finfo[x].clustno, finfo[x].size, p, fat, (char *) (ADR_DISKIMG + 0x003e00)); + set_segmdesc(gdt + 1003, finfo[x].size - 1, (int) p, AR_CODE32_ER); + farjmp(0, 1003 * 8); + memman_free_4k(memman, (int) p, finfo[x].size); + } else { + /*没有找到文件的情况*/ + putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15); + cursor_y = cons_newline(cursor_y, sheet); + } + cursor_y = cons_newline(cursor_y, sheet); } else if (cmdline[0] != 0) { /*不是命令,也不是空行 */ putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12); @@ -236,3 +254,25 @@ void console_task(struct SHEET *sheet, unsigned int memtotal) } } } + +int cons_newline(int cursor_y, struct SHEET *sheet) +{ + int x, y; + if (cursor_y < 28 + 112) { + cursor_y += 16; /*换行*/ + } else { + /*滚动*/ + for (y = 28; y < 28 + 112; y++) { + for (x = 8; x < 8 + 240; x++) { + sheet->buf[x + y * sheet->bxsize] = sheet->buf[x + (y + 16) * sheet->bxsize]; + } + } + for (y = 28 + 112; y < 28 + 128; y++) { + for (x = 8; x < 8 + 240; x++) { + sheet->buf[x + y * sheet->bxsize] = COL8_000000; + } + } + sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128); + } + return cursor_y; +} diff --git a/19_day/hlt.nas b/19_day/hlt.nas new file mode 100644 index 0000000..487d545 --- /dev/null +++ b/19_day/hlt.nas @@ -0,0 +1,5 @@ +[BITS 32] + CLI +fin: + HLT + JMP fin \ No newline at end of file