解决NetBSD-1.0在VMware 11.0上重启时报指令错误的问题
NetBSD-1.0 在 VMware 11.0 上重启时,总是会提示如下的错误:
但是NetBSD-1.3 在 VMware 11.0 上重启的时候并没有提示这个问题,所以参照 NetBSD-1.3 的重启代码,修改 NetBSD-1.0 的重启方式。
1) arch/i386/isa/ic/i8042.h 头文件增加宏定义:
#define KBC_PULSE0 0xfe /* pulse output bit 0 */ #define KBC_PULSE1 0xfd /* pulse output bit 1 */ #define KBC_PULSE2 0xfb /* pulse output bit 2 */ #define KBC_PULSE3 0xf7 /* pulse output bit 3 */
2) 修改 arch/i386/i386/vm_machdep.c 的 cpu_reset 函数为:
extern struct gate_descriptor idt[]; cpu_reset() { struct region_descriptor region; disable_intr(); /* * The keyboard controller has 4 random output pins, one of which is * connected to the RESET pin on the CPU in many PCs. We tell the * keyboard controller to pulse this line a couple of times. */ outb(KBCMDP, KBC_PULSE0); delay(100000); outb(KBCMDP, KBC_PULSE0); delay(100000); /* * Try to cause a triple fault and watchdog reset by making the IDT * invalid and causing a fault. */ bzero((caddr_t)idt, NIDT * sizeof(idt[0])); /* setregion(®ion, idt, NIDT * sizeof(idt[0]) - 1); */ region.rd_limit = (int)( NIDT * sizeof(idt[0]) - 1 ); region.rd_base = (int)idt; lidt(®ion); __asm __volatile("divl %0,%1" : : "q" (0), "a" (0)); #if 0 /* * Try to cause a triple fault and watchdog reset by unmapping the * entire address space and doing a TLB flush. */ bzero((caddr_t)PTD, NBPG); pmap_update(); #endif for (;;); }
在文件开头处还需要加上两个头文件:
#include <machine/pio.h>
#include <i386/isa/ic/i8042.h>
pio.h 定义了 outb , i8042.h 定义了 KBCMDP 和 KBC_PULSE0.
重新编译内核并更新之后,reboot 就不会再提示之前的错误了。