zoukankan      html  css  js  c++  java
  • Ubuntu Bochs boot.asm 测试

    /*********************************************************************
     *                   Ubuntu Bochs boot.asm 测试
     * 说明:
     *     本文仅仅是在Ubuntu下通过Bochs验证《自己动手编写操作系统》中的
     * Boot Sector(引导区)的汇编代码,算是撘一个测试环境。
     *
     *                                   2016-7-22 深圳 南山平山村 曾剑锋
     ********************************************************************/
    
    一、参考文档:
        1. ubuntu下bochs安装使用
            http://blog.csdn.net/xnwyd/article/details/7421703
        2. bochs安装一系列问题 
            http://blog.chinaunix.net/uid-23817499-id-3418083.html
        3. 自己动手写操作系统之1:bochs初步使用
            http://blog.csdn.net/zhaodedong/article/details/51082128
    
    二、测试目录文件:
        aplex@aplex:~/os/system$ ls
        a.img  bochsout.txt  boot.asm  boot.bin
    
    三、cat boot.asm
            org 07c00h
            mov ax, cs
            mov ds, ax
            mov es, ax
            call DispStr
            jmp $
    
        DispStr:
            mov ax, BootMessage
            mov bp, ax
            mov cx, 16
            mov ax, 01301h
            mov bx, 000ch
            mov dl, 0
            int 10h
            ret
        BootMessage:    db "Hello, OS world!"
        times   510-($-$$)      db 0
        
        dw 0xaa55
    
    四、cat ~/.bochsrc
        ###############################################################
        # Configuration file for Bochs
        ###############################################################
        
        # how much memory the emulated machine will have
        megs: 32
        
        # filename of ROM images
        romimage: file=/usr/share/bochs/BIOS-bochs-latest
        vgaromimage: file=/usr/share/vgabios/vgabios.bin
        
        # what disk images will be used
        floppya: 1_44=a.img, status=inserted
        
        # choose the boot disk.
        boot: floppy
        
        # where do we send log messages?
        log: bochsout.txt
        
        # disable the mouse
        mouse: enabled=0
        
        # enable key mapping, using US layout as default.
        #keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
        
        display_library: sdl
    
    五、命令运行流程:
        aplex@aplex:~/os/system$ ls
        a.img  bochsout.txt  boot.asm  boot.bin
        aplex@aplex:~/os/system$ nasm boot.asm -o boot.bin 
        aplex@aplex:~/os/system$ bximage 
        ========================================================================
                                        bximage
                          Disk Image Creation Tool for Bochs
                $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $
        ========================================================================
        
        Do you want to create a floppy disk image or a hard disk image?
        Please type hd or fd. [hd] fd
        
        Choose the size of floppy disk image to create, in megabytes.
        Please type 0.16, 0.18, 0.32, 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88.
         [1.44] 1.44
        I will create a floppy image with
          cyl=80
          heads=2
          sectors per track=18
          total sectors=2880
          total bytes=1474560
        
        What should I name the image?
        [a.img] 
        
        The disk image 'a.img' already exists.  Are you sure you want to replace it?
        Please type yes or no. [no] yes
        
        Writing: [] Done.
        
        I wrote 1474560 bytes to a.img.
        
        The following line should appear in your bochsrc:
          floppya: image="a.img", status=inserted
        aplex@aplex:~/os/system$ dd if=boot.bin of=a.img
        记录了1+0 的读入
        记录了1+0 的写出
        512字节(512 B)已复制,0.00040927 秒,1.3 MB/秒
        aplex@aplex:~/os/system$ bochs
        ========================================================================
                               Bochs x86 Emulator 2.4.6
                     Build from CVS snapshot, on February 22, 2011
                           Compiled at Jun  8 2013, 05:16:04
        ========================================================================
        00000000000i[     ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
        00000000000i[     ] BXSHARE not set. using compile time default '/usr/share/bochs'
        00000000000i[     ] reading configuration from /home/aplex/.bochsrc
        00000000000i[     ] lt_dlhandle is 0x378ba30
        00000000000i[PLGIN] loaded plugin libbx_sdl.so
        00000000000i[     ] installing sdl module as the Bochs GUI
        00000000000i[     ] using log file bochsout.txt
        aplex@aplex:~/os/system$ 
    
    六、效果图:

  • 相关阅读:
    Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.
    DHCP "No subnet declaration for xxx (no IPv4 addresses)" 报错
    Centos安装前端开发常用软件
    kubernetes学习笔记之十:RBAC(二)
    k8s学习笔记之StorageClass+NFS
    k8s学习笔记之ConfigMap和Secret
    k8s笔记之chartmuseum搭建
    K8S集群集成harbor(1.9.3)服务并配置HTTPS
    Docker镜像仓库Harbor1.7.0搭建及配置
    Nginx自建SSL证书部署HTTPS网站
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5695173.html
Copyright © 2011-2022 走看看