解决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(&region, idt, NIDT * sizeof(idt[0]) - 1); */
    
    region.rd_limit = (int)( NIDT * sizeof(idt[0]) - 1 );
    region.rd_base  = (int)idt;
    
    lidt(&region);
    __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 就不会再提示之前的错误了。 

转载于:https://www.cnblogs.com/StupidTortoise/p/4317019.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值