码迷,mamicode.com
首页 > Web开发 > 详细

解决NetBSD-1.0在VMware 11.0上重启时报指令错误的问题

时间:2015-03-06 00:56:04      阅读:147      评论:0      收藏: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 就不会再提示之前的错误了。 

解决NetBSD-1.0在VMware 11.0上重启时报指令错误的问题

标签:

原文地址:http://www.cnblogs.com/StupidTortoise/p/4317019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!