<操作系统设计与实现第二版> 随书所附的minix2.0 无法安装到Mircosoft Virtual PC 中,如果你尝试安装会得到"file system panic: Cannot open root device"的错误消息。喜欢这本书的结构清晰明了,实在是学习操作系统的良师益友,居家必备,呵呵, 当然这得感谢作者Tanenbaum老先生。
Minix2.0不能安装是因为检测软驱状态有问题。以至于mount安装软盘失败。造成问题的原因或许是因为访问软驱的规格发生变化,再或者是minix本身bug。不得而知了
修复这个bug可以按照如下方式 打开 src/kernel/floppy.c 行 1094
1067: /*==========================================================================*
1068: * read_id *
1069: *==========================================================================*/
1070: PRIVATE int read_id(fp)
1071: struct floppy *fp; /* pointer to the drive struct */
1072: {
1073: /* Determine current cylinder and sector. */
1074:
1075: int result;
1076:
1077: /* Never attempt a read id if the drive is uncalibrated or motor is off. */
1078: if (fp->fl_calibration == UNCALIBRATED) return(ERR_READ_ID);
1079: if ((motor_status & (1 << f_drive)) == 0) return(ERR_READ_ID);
1080:
1081: /* The command is issued by outputting 2 bytes to the controller chip. */
1082: fdc_out(FDC_READ_ID); /* issue the read id command */
1083: fdc_out( (f_fp->fl_head << 2) | f_drive);
1084:
1085: /* Block, waiting for disk interrupt. */
1086: if (need_reset) return(ERR_READ_ID); /* if controller is sick, abort op */
1087:
1088: if (f_intr_wait() != OK) return(ERR_TIMEOUT);
1089:
1090: /* Get controller status and check for errors. */
1091: result = fdc_results();
1092: if (result != OK) return(result);
1093:
1094: if ((f_results[ST0] & ST0_BITS) != TRANS_ST0) return(ERR_READ_ID);
1095: if (f_results[ST1] | f_results[ST2]) return(ERR_READ_ID);
1096:
1097: /* The next sector is next for I/O: */
1098: f_fp->fl_sector = f_results[ST_SEC] + 1;
1099: return(OK);
1100: }
其中行 1094
if ((f_results[ST0] & ST0_BITS) != TRANS_ST0) return(ERR_READ_ID);
为检测软驱状态标志是否有错误。其中包含软驱 seek end flag. 但这个时候并不需要检测 seek end flag. 这就是有问题的地方我们将其改为不检测 seek end flag 就可以了,也就是不检测状态位第6位,ST0_BITS 为0xF8, 改为0xD8, 象这样
if ((f_results[ST0] & 0xD8 ) != TRANS_ST0) return(ERR_READ_ID);
然后重新编译并复制到安装软盘中就可以安装minix2.0了,并在VPC 中欢快滴跑起来。如果你没有编译环境可以到我的资源里下载minix2.0 用于启动的安装的第一张软盘.
Enjoy :)
21:13 2008-4-1 于重庆 Treeyan