Compare commits

...

13 Commits

Author SHA1 Message Date
郭宇翔
9aa36a0f96 Merge pull request #26 from LJS08/patch-1
Fix: 翻译不完全04_day/asmhead.nas
2024-04-01 16:14:55 +08:00
LJS80
9bb71ea5ce Update asmhead.nas 2023-06-19 23:06:13 +08:00
郭宇翔
f8b2930281 Merge pull request #9 from sky5454/patch-2
Update README.md
2020-08-10 15:07:34 +08:00
郭宇翔
c462063e0b Update ipl10.nas
Fixed #10
2020-08-10 09:40:14 +08:00
郭宇翔
dade193e1f Update README.md 2020-08-10 09:36:42 +08:00
sky5454
670d454b4e Update README.md
Add HELP
2019-05-27 22:13:46 +08:00
郭宇翔
6ee187a190 Merge pull request #8 from sky5454/patch-1
Update helloos.nas
2019-05-26 23:29:22 +08:00
sky5454
7d59920a37 Update helloos.nas
修正:“必??”改为“必须是”,"字?"改为"字节"
不知道是不是仓库主人误操作,还是git的bug?
2019-05-26 21:48:38 +08:00
郭宇翔
b308a9e295 fix imgout BPB data error
fixed #3
2018-08-08 00:26:36 +08:00
Yourtion
a28136d3de bug fix 2016-05-31 18:13:22 +08:00
Yourtion
438eeb5135 Update README 2016-05-21 00:37:05 +08:00
Yourtion
d9d034cf43 update 2016-05-21 00:31:13 +08:00
Yourtion
c8be7ff36f update README 2016-05-21 00:30:29 +08:00
7 changed files with 112 additions and 98 deletions

View File

@@ -12,15 +12,15 @@
DW 224 ; 根目录大小一般为224项 DW 224 ; 根目录大小一般为224项
DW 2880 ; 该磁盘大小必须为2880扇区1440*1024/512 DW 2880 ; 该磁盘大小必须为2880扇区1440*1024/512
DB 0xf0 ; 磁盘类型必须为0xf0 DB 0xf0 ; 磁盘类型必须为0xf0
DW 9 ; FAT的长度??9扇区 DW 9 ; FAT的长度须是9扇区
DW 18 ; 一个磁道track有几个扇区必须为18 DW 18 ; 一个磁道track有几个扇区必须为18
DW 2 ; 磁头数(必??2 DW 2 ; 磁头数(必须是2
DD 0 ; 不使用分区必须是0 DD 0 ; 不使用分区必须是0
DD 2880 ; 重写一次磁盘大小 DD 2880 ; 重写一次磁盘大小
DB 0,0,0x29 ; 意义不明(固定) DB 0,0,0x29 ; 意义不明(固定)
DD 0xffffffff ; (可能是)卷标号码 DD 0xffffffff ; (可能是)卷标号码
DB "HELLO-OS " ; 磁盘的名称必须为11字?,不足填空格) DB "HELLO-OS " ; 磁盘的名称必须为11字,不足填空格)
DB "FAT12 " ; 磁盘格式名称(必??8字?,不足填空格) DB "FAT12 " ; 磁盘格式名称(必须是8字,不足填空格)
RESB 18 ; 先空出18字节 RESB 18 ; 先空出18字节
; 程序主体 ; 程序主体
@@ -47,4 +47,4 @@
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 4600 RESB 4600
DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 DB 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
RESB 1469432 RESB 1469432

View File

@@ -6,7 +6,7 @@
; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code ; 标准FAT12格式软盘专用的代码 Stand FAT12 format floppy code
JMP entry JMP entry
DB 0xeb, 0x4e, 0x90 DB 0x90
DB "HELLOIPL" ; 启动扇区名称8字节 DB "HELLOIPL" ; 启动扇区名称8字节
DW 512 ; 每个扇区sector大小必须512字节 DW 512 ; 每个扇区sector大小必须512字节
DB 1 ; 簇cluster大小必须为1个扇区 DB 1 ; 簇cluster大小必须为1个扇区

View File

@@ -53,7 +53,7 @@ retry:
MOV BX,0 MOV BX,0
MOV DL,0x00 ; A驱动器 MOV DL,0x00 ; A驱动器
INT 0x13 ; 调用磁盘BIOS INT 0x13 ; 调用磁盘BIOS
JNC next ; 没出错则跳转到fin JNC next ; 没出错则跳转到next
ADD SI,1 ; 往SI加1 ADD SI,1 ; 往SI加1
CMP SI,5 ; 比较SI与5 CMP SI,5 ; 比较SI与5
JAE error ; SI >= 5 跳转到error JAE error ; SI >= 5 跳转到error

View File

@@ -15,7 +15,7 @@ VRAM EQU 0x0ff8 ; 图像缓冲区的起始地址
ORG 0xc200 ; 这个的程序要被装载的内存地址 ORG 0xc200 ; 这个的程序要被装载的内存地址
; 画面モードを設定 ; 设置画面模式
MOV AL,0x13 ; VGA显卡320x200x8bit MOV AL,0x13 ; VGA显卡320x200x8bit
MOV AH,0x00 MOV AH,0x00

View File

@@ -9,8 +9,8 @@ void console_task(struct SHEET *sheet, int memtotal)
struct TASK *task = task_now(); struct TASK *task = task_now();
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
int i, *fat = (int *) memman_alloc_4k(memman, 4 * 2880); int i, *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
struct CONSOLE cons;
struct FILEHANDLE fhandle[8]; struct FILEHANDLE fhandle[8];
struct CONSOLE cons;
char cmdline[30]; char cmdline[30];
unsigned char *nihongo = (char *) *((int *) 0x0fe8); unsigned char *nihongo = (char *) *((int *) 0x0fe8);
@@ -133,19 +133,19 @@ void cons_putchar(struct CONSOLE *cons, int chr, char move)
cons_newline(cons); cons_newline(cons);
} }
if (((cons->cur_x - 8) & 0x1f) == 0) { if (((cons->cur_x - 8) & 0x1f) == 0) {
break; /* 32<EFBFBD>Ŋ<EFBFBD><EFBFBD><EFBFBD>؂ꂽ<EFBFBD><EFBFBD>break */ break; /*32整除则break*/
} }
} }
} else if (s[0] == 0x0a) { /* <20><><EFBFBD>s */ } else if (s[0] == 0x0a) { /*换行*/
cons_newline(cons); cons_newline(cons);
} else if (s[0] == 0x0d) { /* <20><><EFBFBD>A */ } else if (s[0] == 0x0d) { /*回车*/
/* <20>Ƃ肠<C682><E882A0><EFBFBD><EFBFBD><EFBFBD>Ȃɂ<C882><C982><EFBFBD><EFBFBD>Ȃ<EFBFBD> */ /*先不做任何操作*/
} else { /* <20><><EFBFBD>ʂ̕<CA82><CC95><EFBFBD> */ } else { /*一般字符*/
if (cons->sht != 0) { if (cons->sht != 0) {
putfonts8_asc_sht(cons->sht, cons->cur_x, cons->cur_y, COL8_FFFFFF, COL8_000000, s, 1); putfonts8_asc_sht(cons->sht, cons->cur_x, cons->cur_y, COL8_FFFFFF, COL8_000000, s, 1);
} }
if (move != 0) { if (move != 0) {
/* move<EFBFBD><EFBFBD>0<EFBFBD>̂Ƃ<EFBFBD><EFBFBD>̓J<EFBFBD>[<5B>\<5C><><EFBFBD><EFBFBD>i<EFBFBD>߂Ȃ<DF82> */ /* move为0时光标不后移*/
cons->cur_x += 8; cons->cur_x += 8;
if (cons->cur_x == 8 + 240) { if (cons->cur_x == 8 + 240) {
cons_newline(cons); cons_newline(cons);
@@ -161,9 +161,9 @@ void cons_newline(struct CONSOLE *cons)
struct SHEET *sheet = cons->sht; struct SHEET *sheet = cons->sht;
struct TASK *task = task_now(); struct TASK *task = task_now();
if (cons->cur_y < 28 + 112) { if (cons->cur_y < 28 + 112) {
cons->cur_y += 16; /* <20><><EFBFBD>̍s<CC8D><73> */ cons->cur_y += 16; /*到下一行*/
} else { } else {
/* <20>X<EFBFBD>N<EFBFBD><4E><EFBFBD>[<5B><> */ /*滚动*/
if (sheet != 0) { if (sheet != 0) {
for (y = 28; y < 28 + 112; y++) { for (y = 28; y < 28 + 112; y++) {
for (x = 8; x < 8 + 240; x++) { for (x = 8; x < 8 + 240; x++) {
@@ -180,7 +180,7 @@ void cons_newline(struct CONSOLE *cons)
} }
cons->cur_x = 8; cons->cur_x = 8;
if (task->langmode == 1 && task->langbyte1 != 0) { if (task->langmode == 1 && task->langbyte1 != 0) {
cons->cur_x = 16; cons->cur_x += 8;
} }
return; return;
} }
@@ -208,7 +208,7 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal)
cmd_mem(cons, memtotal); cmd_mem(cons, memtotal);
} else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) { } else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) {
cmd_cls(cons); cmd_cls(cons);
} else if (strcmp(cmdline, "dir") == 0 && cons->sht != 0) { } else if ((strcmp(cmdline, "dir") == 0 || strcmp(cmdline, "ls") == 0) && cons->sht != 0) {
cmd_dir(cons); cmd_dir(cons);
} else if (strcmp(cmdline, "exit") == 0) { } else if (strcmp(cmdline, "exit") == 0) {
cmd_exit(cons, fat); cmd_exit(cons, fat);
@@ -218,9 +218,9 @@ void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, int memtotal)
cmd_ncst(cons, cmdline, memtotal); cmd_ncst(cons, cmdline, memtotal);
} else if (strncmp(cmdline, "langmode ", 9) == 0) { } else if (strncmp(cmdline, "langmode ", 9) == 0) {
cmd_langmode(cons, cmdline); cmd_langmode(cons, cmdline);
} else if (cmdline[0] != 0) { }else if (cmdline[0] != 0) {
if (cmd_app(cons, fat, cmdline) == 0) { if (cmd_app(cons, fat, cmdline) == 0) {
/* <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD>ł͂Ȃ<CD82><C882>A<EFBFBD>A<EFBFBD>v<EFBFBD><76><EFBFBD>ł<EFBFBD><C582>Ȃ<EFBFBD><C882>A<EFBFBD><41><EFBFBD><EFBFBD>ɋ<EFBFBD>s<EFBFBD>ł<EFBFBD><C582>Ȃ<EFBFBD> */ /*不是命令,不是应用程序,也不是空行*/
cons_putstr0(cons, "Bad command.\n\n"); cons_putstr0(cons, "Bad command.\n\n");
} }
} }
@@ -288,9 +288,9 @@ void cmd_exit(struct CONSOLE *cons, int *fat)
memman_free_4k(memman, (int) fat, 4 * 2880); memman_free_4k(memman, (int) fat, 4 * 2880);
io_cli(); io_cli();
if (cons->sht != 0) { if (cons->sht != 0) {
fifo32_put(fifo, cons->sht - shtctl->sheets0 + 768); /* 768<EFBFBD>`1023 */ fifo32_put(fifo, cons->sht - shtctl->sheets0 + 768); /* 7681023 */
} else { } else {
fifo32_put(fifo, task - taskctl->tasks0 + 1024); /* 1024<EFBFBD>`2023 */ fifo32_put(fifo, task - taskctl->tasks0 + 1024); /*10242023*/
} }
io_sti(); io_sti();
for (;;) { for (;;) {
@@ -306,11 +306,11 @@ void cmd_start(struct CONSOLE *cons, char *cmdline, int memtotal)
int i; int i;
sheet_slide(sht, 32, 4); sheet_slide(sht, 32, 4);
sheet_updown(sht, shtctl->top); sheet_updown(sht, shtctl->top);
/* <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD><68><EFBFBD>C<EFBFBD><43><EFBFBD>ɓ<EFBFBD><C993>͂<EFBFBD><CD82><EFBFBD><EA82BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EA95B6><EFBFBD><EFBFBD><EFBFBD>V<C290><56><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>\<5C>[<5B><><EFBFBD>ɓ<EFBFBD><C993><EFBFBD> */ /*将命令行输入的字符串逐字复制到新的命令行窗口中*/
for (i = 6; cmdline[i] != 0; i++) { for (i = 6; cmdline[i] != 0; i++) {
fifo32_put(fifo, cmdline[i] + 256); fifo32_put(fifo, cmdline[i] + 256);
} }
fifo32_put(fifo, 10 + 256); /* Enter */ fifo32_put(fifo, 10 + 256); /*回车键*/
cons_newline(cons); cons_newline(cons);
return; return;
} }
@@ -320,11 +320,12 @@ void cmd_ncst(struct CONSOLE *cons, char *cmdline, int memtotal)
struct TASK *task = open_constask(0, memtotal); struct TASK *task = open_constask(0, memtotal);
struct FIFO32 *fifo = &task->fifo; struct FIFO32 *fifo = &task->fifo;
int i; int i;
/* <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD><68><EFBFBD>C<EFBFBD><43><EFBFBD>ɓ<EFBFBD><C993>͂<EFBFBD><CD82><EFBFBD><EA82BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EA95B6><EFBFBD><EFBFBD><EFBFBD>V<C290><56><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>\<5C>[<5B><><EFBFBD>ɓ<EFBFBD><C993><EFBFBD> */
/*将命令行输入的字符串逐字复制到新的命令行窗口中*/
for (i = 5; cmdline[i] != 0; i++) { for (i = 5; cmdline[i] != 0; i++) {
fifo32_put(fifo, cmdline[i] + 256); fifo32_put(fifo, cmdline[i] + 256);
} }
fifo32_put(fifo, 10 + 256); /* Enter */ fifo32_put(fifo, 10 + 256); /*回车键*/
cons_newline(cons); cons_newline(cons);
return; return;
} }
@@ -352,19 +353,19 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
struct SHTCTL *shtctl; struct SHTCTL *shtctl;
struct SHEET *sht; struct SHEET *sht;
/* <20>R<EFBFBD>}<7D><><EFBFBD>h<EFBFBD><68><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>𐶐<EFBFBD> */ /*根据命令行生成文件名*/
for (i = 0; i < 13; i++) { for (i = 0; i < 13; i++) {
if (cmdline[i] <= ' ') { if (cmdline[i] <= ' ') {
break; break;
} }
name[i] = cmdline[i]; name[i] = cmdline[i];
} }
name[i] = 0; /* <20>Ƃ肠<C682><E882A0><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>̌<EFBFBD><CC8C><EFBFBD>0<EFBFBD>ɂ<EFBFBD><C982><EFBFBD> */ name[i] = 0; /*暂且将文件名的后面置为0*/
/* <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD>T<EFBFBD><54> */ /*寻找文件 */
finfo = file_search(name, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224); finfo = file_search(name, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
if (finfo == 0 && name[i - 1] != '.') { if (finfo == 0 && name[i - 1] != '.') {
/* <20><><EFBFBD>‚<EFBFBD><C282><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ō<CC82><C58C><EFBFBD>".HRB"<22><><EFBFBD>‚<EFBFBD><C282>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD>T<EFBFBD><54><EFBFBD>Ă݂<C482> */ /*由于找不到文件,故在文件名后面加上“.hrb”后重新寻找*/
name[i ] = '.'; name[i ] = '.';
name[i + 1] = 'H'; name[i + 1] = 'H';
name[i + 2] = 'R'; name[i + 2] = 'R';
@@ -374,7 +375,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
} }
if (finfo != 0) { if (finfo != 0) {
/* <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/ /*如果找到文件*/
appsiz = finfo->size; appsiz = finfo->size;
p = file_loadfile2(finfo->clustno, &appsiz, fat); p = file_loadfile2(finfo->clustno, &appsiz, fat);
if (appsiz >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) { if (appsiz >= 36 && strncmp(p + 4, "Hari", 4) == 0 && *p == 0x00) {
@@ -384,8 +385,8 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
dathrb = *((int *) (p + 0x0014)); dathrb = *((int *) (p + 0x0014));
q = (char *) memman_alloc_4k(memman, segsiz); q = (char *) memman_alloc_4k(memman, segsiz);
task->ds_base = (int) q; task->ds_base = (int) q;
set_segmdesc(task->ldt + 0, appsiz - 1, (int) p, AR_CODE32_ER + 0x60); set_segmdesc(task->ldt + 0, finfo->size - 1, (int) p, AR_CODE32_ER + 0x60);
set_segmdesc(task->ldt + 1, segsiz - 1, (int) q, AR_DATA32_RW + 0x60); set_segmdesc(task->ldt + 1, segsiz - 1, (int) q, AR_DATA32_RW + 0x60);
for (i = 0; i < datsiz; i++) { for (i = 0; i < datsiz; i++) {
q[esp + i] = p[dathrb + i]; q[esp + i] = p[dathrb + i];
} }
@@ -394,11 +395,11 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
for (i = 0; i < MAX_SHEETS; i++) { for (i = 0; i < MAX_SHEETS; i++) {
sht = &(shtctl->sheets0[i]); sht = &(shtctl->sheets0[i]);
if ((sht->flags & 0x11) == 0x11 && sht->task == task) { if ((sht->flags & 0x11) == 0x11 && sht->task == task) {
/* <20>A<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>ςȂ<CF82><C882>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>𔭌<EFBFBD> */ /*找到被应用程序遗留的窗口*/
sheet_free(sht); /* <20>‚<EFBFBD><C282><EFBFBD> */ sheet_free(sht); /*关闭*/
} }
} }
for (i = 0; i < 8; i++) { /* <20>N<EFBFBD><4E><EFBFBD>[<5B>Y<EFBFBD><59><EFBFBD>ĂȂ<C482><C882>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD>[<5B>Y */ for (i = 0; i < 8; i++) { /*将未关闭的文件关闭*/
if (task->fhandle[i].buf != 0) { if (task->fhandle[i].buf != 0) {
memman_free_4k(memman, (int) task->fhandle[i].buf, task->fhandle[i].size); memman_free_4k(memman, (int) task->fhandle[i].buf, task->fhandle[i].size);
task->fhandle[i].buf = 0; task->fhandle[i].buf = 0;
@@ -414,7 +415,7 @@ int cmd_app(struct CONSOLE *cons, int *fat, char *cmdline)
cons_newline(cons); cons_newline(cons);
return 1; return 1;
} }
/* <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/ /*没有找到文件的情况*/
return 0; return 0;
} }
@@ -426,8 +427,8 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4);
struct SHEET *sht; struct SHEET *sht;
struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec); struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec);
int *reg = &eax + 1; /* eax<EFBFBD>̎<EFBFBD><EFBFBD>̔Ԓn */ int *reg = &eax + 1; /* eax后面的地址*/
/* <20>ۑ<EFBFBD><DB91>̂<EFBFBD><CC82>߂<EFBFBD>PUSHAD<41><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */ /*强行改写通过PUSHAD保存的值*/
/* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */ /* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */
/* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */ /* reg[4] : EBX, reg[5] : EDX, reg[6] : ECX, reg[7] : EAX */
int i; int i;
@@ -450,7 +451,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax); sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax);
make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0); make_window8((char *) ebx + ds_base, esi, edi, (char *) ecx + ds_base, 0);
sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2); sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2);
sheet_updown(sht, shtctl->top); /* <20><><EFBFBD>̃}<7D>E<EFBFBD>X<EFBFBD>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂȂ<C982><EFBFBD>Ɏw<C98E><77>F <20>}<7D>E<EFBFBD>X<EFBFBD>͂<EFBFBD><CD82>̏<EFBFBD>ɂȂ<C982> */ sheet_updown(sht, shtctl->top); /*将窗口图层高度指定为当前鼠标所在图层的高度,鼠标移到上层*/
reg[7] = (int) sht; reg[7] = (int) sht;
} else if (edx == 6) { } else if (edx == 6) {
sht = (struct SHEET *) (ebx & 0xfffffffe); sht = (struct SHEET *) (ebx & 0xfffffffe);
@@ -466,13 +467,13 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
} }
} else if (edx == 8) { } else if (edx == 8) {
memman_init((struct MEMMAN *) (ebx + ds_base)); memman_init((struct MEMMAN *) (ebx + ds_base));
ecx &= 0xfffffff0; /* 16<EFBFBD>o<EFBFBD>C<EFBFBD>g<EFBFBD>P<EFBFBD>ʂ<EFBFBD> */ ecx &= 0xfffffff0; /*16字节为单位*/
memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx);
} else if (edx == 9) { } else if (edx == 9) {
ecx = (ecx + 0x0f) & 0xfffffff0; /* 16<EFBFBD>o<EFBFBD>C<EFBFBD>g<EFBFBD>P<EFBFBD>ʂɐ؂<EFBFBD>*/ ecx = (ecx + 0x0f) & 0xfffffff0; /*16字节为单位进位取整*/
reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx); reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx);
} else if (edx == 10) { } else if (edx == 10) {
ecx = (ecx + 0x0f) & 0xfffffff0; /* 16<EFBFBD>o<EFBFBD>C<EFBFBD>g<EFBFBD>P<EFBFBD>ʂɐ؂<EFBFBD>*/ ecx = (ecx + 0x0f) & 0xfffffff0; /*16字节为单位进位取整*/
memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx);
} else if (edx == 11) { } else if (edx == 11) {
sht = (struct SHEET *) (ebx & 0xfffffffe); sht = (struct SHEET *) (ebx & 0xfffffffe);
@@ -506,7 +507,7 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
io_cli(); io_cli();
if (fifo32_status(&task->fifo) == 0) { if (fifo32_status(&task->fifo) == 0) {
if (eax != 0) { if (eax != 0) {
task_sleep(task); /* FIFO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ̂ŐQ<EFBFBD>đ҂<EFBFBD> */ task_sleep(task); /* FIFO为空,休眠并等待*/
} else { } else {
io_sti(); io_sti();
reg[7] = -1; reg[7] = -1;
@@ -515,32 +516,32 @@ int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int
} }
i = fifo32_get(&task->fifo); i = fifo32_get(&task->fifo);
io_sti(); io_sti();
if (i <= 1 && cons->sht != 0) { /* <20>J<EFBFBD>[<5B>\<5C><><EFBFBD>p<EFBFBD>^<5E>C<EFBFBD>} */ if (i <= 1) { /*光标用定时器*/
/* <20>A<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73><EFBFBD>̓J<CD83>[<5B>\<5C><><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>Ȃ<EFBFBD><C882>̂ŁA<C581><41><EFBFBD>‚<EFBFBD><C282><EFBFBD><EFBFBD>͕\<5C><><EFBFBD>p<EFBFBD><70>1<EFBFBD>𒍕<EFBFBD><F0928D95><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD> */ /*应用程序运行时不需要显示光标因此总是将下次显示用的值置为1*/
timer_init(cons->timer, &task->fifo, 1); /* <20><><EFBFBD><EFBFBD>1<EFBFBD><31> */ timer_init(cons->timer, &task->fifo, 1); /*下次置为1*/
timer_settime(cons->timer, 50); timer_settime(cons->timer, 50);
} }
if (i == 2) { /* <20>J<EFBFBD>[<5B>\<5C><>ON */ if (i == 2) { /*光标ON */
cons->cur_c = COL8_FFFFFF; cons->cur_c = COL8_FFFFFF;
} }
if (i == 3) { /* <20>J<EFBFBD>[<5B>\<5C><>OFF */ if (i == 3) { /*光标OFF */
cons->cur_c = -1; cons->cur_c = -1;
} }
if (i == 4) { /* <20>R<EFBFBD><52><EFBFBD>\<5C>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD> */ if (i == 4) { /*只关闭命令行窗口*/
timer_cancel(cons->timer); timer_cancel(cons->timer);
io_cli(); io_cli();
fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024<EFBFBD>`2279 */ fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /*20242279*/
cons->sht = 0; cons->sht = 0;
io_sti(); io_sti();
} }
if (i >= 256) { /* <20>L<EFBFBD>[<5B>{<7B>[<5B>h<EFBFBD>f<EFBFBD>[<5B>^<5E>i<EFBFBD>^<5E>X<EFBFBD>NA<4E>o<EFBFBD>R<EFBFBD>j<EFBFBD>Ȃ<EFBFBD> */ if (i >= 256) { /*键盘数据通过任务A*/
reg[7] = i - 256; reg[7] = i - 256;
return 0; return 0;
} }
} }
} else if (edx == 16) { } else if (edx == 16) {
reg[7] = (int) timer_alloc(); reg[7] = (int) timer_alloc();
((struct TIMER *) reg[7])->flags2 = 1; /* <20><><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A><EFBFBD>L<EFBFBD><4C> */ ((struct TIMER *) reg[7])->flags2 = 1; /*允许自动取消*/
} else if (edx == 17) { } else if (edx == 17) {
timer_init((struct TIMER *) ebx, &task->fifo, eax + 256); timer_init((struct TIMER *) ebx, &task->fifo, eax + 256);
} else if (edx == 18) { } else if (edx == 18) {
@@ -642,7 +643,7 @@ int *inthandler0c(int *esp)
cons_putstr0(cons, "\nINT 0C :\n Stack Exception.\n"); cons_putstr0(cons, "\nINT 0C :\n Stack Exception.\n");
sprintf(s, "EIP = %08X\n", esp[11]); sprintf(s, "EIP = %08X\n", esp[11]);
cons_putstr0(cons, s); cons_putstr0(cons, s);
return &(task->tss.esp0); /* <20>ُ<EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */ return &(task->tss.esp0); /*强制结束程序*/
} }
int *inthandler0d(int *esp) int *inthandler0d(int *esp)
@@ -653,7 +654,7 @@ int *inthandler0d(int *esp)
cons_putstr0(cons, "\nINT 0D :\n General Protected Exception.\n"); cons_putstr0(cons, "\nINT 0D :\n General Protected Exception.\n");
sprintf(s, "EIP = %08X\n", esp[11]); sprintf(s, "EIP = %08X\n", esp[11]);
cons_putstr0(cons, s); cons_putstr0(cons, s);
return &(task->tss.esp0); /* <20>ُ<EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */ return &(task->tss.esp0); /*强制结束程序*/
} }
void hrb_api_linewin(struct SHEET *sht, int x0, int y0, int x1, int y1, int col) void hrb_api_linewin(struct SHEET *sht, int x0, int y0, int x1, int y1, int col)

View File

@@ -1,4 +1,4 @@
/* <EFBFBD>}<7D><><EFBFBD>`<60>^<5E>X<EFBFBD>N<EFBFBD>֌W */ /* 多任务管理 */
#include "bootpack.h" #include "bootpack.h"
@@ -16,7 +16,7 @@ void task_add(struct TASK *task)
struct TASKLEVEL *tl = &taskctl->level[task->level]; struct TASKLEVEL *tl = &taskctl->level[task->level];
tl->tasks[tl->running] = task; tl->tasks[tl->running] = task;
tl->running++; tl->running++;
task->flags = 2; /* <20><><EFBFBD>*/ task->flags = 2; /*活动中*/
return; return;
} }
@@ -25,39 +25,38 @@ void task_remove(struct TASK *task)
int i; int i;
struct TASKLEVEL *tl = &taskctl->level[task->level]; struct TASKLEVEL *tl = &taskctl->level[task->level];
/* task<EFBFBD><EFBFBD><EFBFBD>ǂ<EFBFBD><EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><EFBFBD> */ /*寻找task所在的位置*/
for (i = 0; i < tl->running; i++) { for (i = 0; i < tl->running; i++) {
if (tl->tasks[i] == task) { if (tl->tasks[i] == task) {
/* <20><><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD> */ /*在这里 */
break; break;
} }
} }
tl->running--; tl->running--;
if (i < tl->now) { if (i < tl->now) {
tl->now--; /* <20><><EFBFBD><EFBFBD><EFBFBD>̂ŁA<C581><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD> */ tl->now--; /*需要移动成员,要相应地处理 */
} }
if (tl->now >= tl->running) { if (tl->now >= tl->running) {
/* now<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȓl<EFBFBD>ɂȂ<EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */ /*如果now的值出现异常,则进行修正*/
tl->now = 0; tl->now = 0;
} }
task->flags = 1; /* <EFBFBD>X<EFBFBD><EFBFBD><EFBFBD>[<5B>v<EFBFBD><76> */ task->flags = 1; /* 休眠中 */
/* <EFBFBD><EFBFBD><EFBFBD> */ /* 移动 */
for (; i < tl->running; i++) { for (; i < tl->running; i++) {
tl->tasks[i] = tl->tasks[i + 1]; tl->tasks[i] = tl->tasks[i + 1];
} }
return; return;
} }
void task_switchsub(void) void task_switchsub(void)
{ {
int i; int i;
/* <20><>ԏ<EFBFBD>̃<EFBFBD><CC83>x<EFBFBD><78><EFBFBD><EFBFBD>T<EFBFBD><54> */ /*寻找最上层的LEVEL */
for (i = 0; i < MAX_TASKLEVELS; i++) { for (i = 0; i < MAX_TASKLEVELS; i++) {
if (taskctl->level[i].running > 0) { if (taskctl->level[i].running > 0) {
break; /* <20><><EFBFBD>‚<EFBFBD><C282><EFBFBD><EFBFBD><EFBFBD> */ break; /*找到了*/
} }
} }
taskctl->now_lv = i; taskctl->now_lv = i;
@@ -78,6 +77,7 @@ struct TASK *task_init(struct MEMMAN *memman)
struct TASK *task, *idle; struct TASK *task, *idle;
struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT; struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT;
taskctl = (struct TASKCTL *) memman_alloc_4k(memman, sizeof (struct TASKCTL)); taskctl = (struct TASKCTL *) memman_alloc_4k(memman, sizeof (struct TASKCTL));
for (i = 0; i < MAX_TASKS; i++) { for (i = 0; i < MAX_TASKS; i++) {
taskctl->tasks0[i].flags = 0; taskctl->tasks0[i].flags = 0;
@@ -92,11 +92,11 @@ struct TASK *task_init(struct MEMMAN *memman)
} }
task = task_alloc(); task = task_alloc();
task->flags = 2; /* <20><><EFBFBD><EFBFBD>}<7D>[<5B>N */ task->flags = 2; /*活动中标志*/
task->priority = 2; /* 0.02<EFBFBD>b */ task->priority = 2; /* 0.02*/
task->level = 0; /* <20>ō<EFBFBD><C58D><EFBFBD><EFBFBD>x<EFBFBD><78> */ task->level = 0; /*最高LEVEL */
task_add(task); task_add(task);
task_switchsub(); /* <EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>ݒ<EFBFBD> */ task_switchsub(); /* LEVEL 设置*/
load_tr(task->sel); load_tr(task->sel);
task_timer = timer_alloc(); task_timer = timer_alloc();
timer_settime(task_timer, task->priority); timer_settime(task_timer, task->priority);
@@ -151,8 +151,7 @@ void task_run(struct TASK *task, int level, int priority)
if (priority > 0) { if (priority > 0) {
task->priority = priority; task->priority = priority;
} }
if (task->flags == 2 && task->level != level) {
if (task->flags == 2 && task->level != level) {
/*改变活动中的LEVEL */ /*改变活动中的LEVEL */
task_remove(task); /*这里执行之后flag的值会变为1于是下面的if语句块也会被执行*/ task_remove(task); /*这里执行之后flag的值会变为1于是下面的if语句块也会被执行*/
} }
@@ -161,7 +160,6 @@ void task_run(struct TASK *task, int level, int priority)
task->level = level; task->level = level;
task_add(task); task_add(task);
} }
taskctl->lv_change = 1; /*下次任务切换时检查LEVEL */ taskctl->lv_change = 1; /*下次任务切换时检查LEVEL */
return; return;
} }
@@ -183,6 +181,7 @@ void task_sleep(struct TASK *task)
return; return;
} }
void task_switch(void) void task_switch(void)
{ {
struct TASKLEVEL *tl = &taskctl->level[taskctl->now_lv]; struct TASKLEVEL *tl = &taskctl->level[taskctl->now_lv];

View File

@@ -1,13 +1,11 @@
30dayMakeOS —— OSASK # 《30天自制操作系统》中文源码 —— OSASK
===========
《30天自制操作系统》源码中文版。自己制作一个操作系统的过程 自己制作一个操作系统的过程,阅读过程会一边汉化源码,一边执行还有根据一些相关的内容进行代码的书写,欢迎大家交流。
阅读过程会一边汉化源码,一边执行还有根据一些相关的内容进行代码的书写,欢迎大家交流。
运行方法,在 `tolset` 中新建一个 `run` 文件夹,把代码拷贝进去,然后根据系统版本运行 `!cons_**.bat` 运行方法,在 `tolset` 中新建一个 `run` 文件夹,把代码拷贝进去,然后根据系统版本运行 `!cons_**.bat`
一般都是使用 `make run` 运行代码27天开始使用 `make run_full`。可以直接看书。 一般都是使用 `make run` 运行代码27天开始使用 `make run_full`。可以直接看书。
又或者把tolset里的`z_tools目录` 复制到 本项目目录`30dayMakeOS`下。
## 完成效果 ## 完成效果
@@ -27,6 +25,14 @@
渡过这个痛苦的时期,第一周就该结束了。 渡过这个痛苦的时期,第一周就该结束了。
- [第1天从计算机结构到汇编程序入门](https://github.com/yourtion/30dayMakeOS/releases/tag/Day01)
- [第2天汇编语言学习与Makefile入门](https://github.com/yourtion/30dayMakeOS/releases/tag/Day02)
- [第3天进入32位模式并导入C语言](https://github.com/yourtion/30dayMakeOS/releases/tag/Day03)
- [第4天C语言与画面显示的练习](https://github.com/yourtion/30dayMakeOS/releases/tag/Day04)
- [第5天结构体、文字显示与GDT/IDT初始化](https://github.com/yourtion/30dayMakeOS/releases/tag/Day05)
- [第6天分割编译与中断处理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day06)
- [第7天FIFO与鼠标控制](https://github.com/yourtion/30dayMakeOS/releases/tag/Day07)
### 第二周第8天第14天 ### 第二周第8天第14天
一周的苦战还是很有意义的回头一看我们就会发现自己还是斩获颇丰的。这时我们已经基本掌握了C语言的语法连汇编语言的水平也能达到本书的要求了。 一周的苦战还是很有意义的回头一看我们就会发现自己还是斩获颇丰的。这时我们已经基本掌握了C语言的语法连汇编语言的水平也能达到本书的要求了。
@@ -35,12 +41,28 @@
所以这一周我们就边学习算法边慢慢地开发操作系统。不过到了这一阶段,我们就能感觉到基本上不会再受技术问题限制了。 所以这一周我们就边学习算法边慢慢地开发操作系统。不过到了这一阶段,我们就能感觉到基本上不会再受技术问题限制了。
- [第8天鼠标控制与32位模式切换](https://github.com/yourtion/30dayMakeOS/releases/tag/Day08)
- [第9天内存管理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day09)
- [第10天叠加处理](https://github.com/yourtion/30dayMakeOS/releases/tag/Day10)
- [第11天制作窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day11)
- [第12天定时器1](https://github.com/yourtion/30dayMakeOS/releases/tag/Day12)
- [第13天定时器2](https://github.com/yourtion/30dayMakeOS/releases/tag/Day13)
- [第14天高分辨率及键盘输入](https://github.com/yourtion/30dayMakeOS/releases/tag/Day14)
### 第三周第15天第21天 ### 第三周第15天第21天
现在我们的技术已经相当厉害了,可以随心所欲地开发自己的操作系统了。首先是要支持多任务,然后是开发命令行窗口,之后就可以着手开发应用程序了。 现在我们的技术已经相当厉害了,可以随心所欲地开发自己的操作系统了。首先是要支持多任务,然后是开发命令行窗口,之后就可以着手开发应用程序了。
到本周结束时,就算还不够完备,我们也能拿出一个可以称之为操作系统的软件了。 到本周结束时,就算还不够完备,我们也能拿出一个可以称之为操作系统的软件了。
- [第15天多任务1](https://github.com/yourtion/30dayMakeOS/releases/tag/Day15)
- [第16天多任务2](https://github.com/yourtion/30dayMakeOS/releases/tag/Day16)
- [第17天命令行窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day17)
- [第18天dir命令](https://github.com/yourtion/30dayMakeOS/releases/tag/Day18)
- [第19天应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day19)
- [第20天API](https://github.com/yourtion/30dayMakeOS/releases/tag/Day20)
- [第21天保护操作系统](https://github.com/yourtion/30dayMakeOS/releases/tag/Day21)
### 第四周第22天第28天 ### 第四周第22天第28天
在这个阶段,我们可以尽情地给操作系统增加各种各样的功能,同时还可以开发出大量像模像样的应用程序来。 在这个阶段,我们可以尽情地给操作系统增加各种各样的功能,同时还可以开发出大量像模像样的应用程序来。
@@ -49,26 +71,18 @@
对了,说起文字才想起来,正好在这个时期可以让我们的操作系统显示文字了。 对了,说起文字才想起来,正好在这个时期可以让我们的操作系统显示文字了。
- [第22天用C语言编写应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day22)
- [第23天图形处理相关](https://github.com/yourtion/30dayMakeOS/releases/tag/Day23)
- [第24天窗口操作](https://github.com/yourtion/30dayMakeOS/releases/tag/Day24)
- [第25天增加命令行窗口](https://github.com/yourtion/30dayMakeOS/releases/tag/Day25)
- [第26天为窗口移动提速](https://github.com/yourtion/30dayMakeOS/releases/tag/Day26)
- [第27天LDT与库](https://github.com/yourtion/30dayMakeOS/releases/tag/Day27)
- [第28天文件操作与文字显示](https://github.com/yourtion/30dayMakeOS/releases/tag/Day28)
### 免费赠送两天第29天第30天 ### 免费赠送两天第29天第30天
剩下的两天用来润色加工。这两天我们来做一些之前没来得及做,但做起来既简单又有趣的内容。 剩下的两天用来润色加工。这两天我们来做一些之前没来得及做,但做起来既简单又有趣的内容。
### Links - [第29天压缩与简单的应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day29)
- [第30天高级的应用程序](https://github.com/yourtion/30dayMakeOS/releases/tag/Day30)
[川合堂](http://www.imasy.org/~mone/kawaido/)
[kawai](http://www.imasy.org/~kawai/)
[豆瓣图书链接](http://book.douban.com/subject/11530329/)
[OSASK计划](http://http://osask.net/)
[OSASK wiki](http://ja.wikipedia.org/wiki/OSASK)
[source code at sourceforge](http://zh.sourceforge.jp/projects/osask/releases/?package_id=10517)
### 工具软件使用
[GNU GPL协议](http://www.gnu.org/licenses/gpl-3.0.html)
[GNU LGPL协议](http://www.gnu.org/licenses/lgpl-3.0.html)