# os **Repository Path**: Yan-Bin1101/os ## Basic Information - **Project Name**: os - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-28 - **Last Updated**: 2021-12-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 一个操作系统的实现 #### 介绍 《Orange's一个操作系统的实现》的实践 #### 软件架构 软件架构说明 #### 安装教程 # 在 ubuntu 上构建实验环境 本人用的操作系统是 ubuntu,所以所有的实验都是在 ubuntu 系统进行的,下面介绍 一下如何在 ubuntu 系统上构建实验环境。 操作系统的版本是 16.04.4,需要用到的软件有: 1. nasm。汇编器 2. bochs。虚拟计算机 3. freedos。 ## 安装 nasm ```bash sudo apt install nasm ``` 安装好后会提供 `nasm` 命令和 `ndisasm` 命令,用来编译和反编译。 ## 安装 bochs ``` sudo apt install bochs bochs-x ``` ## 安装 freedos 在 bochs 官网下载,解压后在解压目录执行 `bochs` 即可。 下载地址:[http://bochs.sourceforge.net/guestos/freedos-img.tar.gz](http://bochs.sourceforge.net/guestos/freedos-img.tar.gz) ### 第一章操作 以上三个软件的安装应该比较简单,但是书上的演示说明太简洁了,没有参考性,因此重新对一些操作进行说明。 新建一个文件夹 **创建一个软盘** ``` yanbin@ubuntu:~/os/c1$ bximage ======================================================================== bximage Disk Image Creation Tool for Bochs $Id: bximage.c 11315 2012-08-05 18:13:38Z vruppert $ ======================================================================== 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] 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] os.img I wrote 1474560 bytes to os.img. The following line should appear in your bochsrc: floppya: image="os.img", status=inserted yanbin@ubuntu:~/os/c1$ ``` 其他文件如文件夹c1所示 NASM编译源文件 ``` yanbin@ubuntu:~/os/c1$ nasm boot.asm -o boot.bin yanbin@ubuntu:~/os/c1$ dd if=boot.bin of=os.img bs=512 count=1 1+0 records in 1+0 records out 512 bytes copied, 0.000238654 s, 2.1 MB/s ``` **执行bochs** ``` yanbin@ubuntu:~/os/c1$ bochs ======================================================================== Bochs x86 Emulator 2.6 Built from SVN snapshot on September 2nd, 2012 ======================================================================== 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[ ] lt_dlhandle is 0x366c4d0 00000000000i[PLGIN] loaded plugin libbx_unmapped.so 00000000000i[ ] lt_dlhandle is 0x366d130 00000000000i[PLGIN] loaded plugin libbx_biosdev.so 00000000000i[ ] lt_dlhandle is 0x366dab0 00000000000i[PLGIN] loaded plugin libbx_speaker.so 00000000000i[ ] lt_dlhandle is 0x366de60 00000000000i[PLGIN] loaded plugin libbx_extfpuirq.so 00000000000i[ ] lt_dlhandle is 0x366f9c0 00000000000i[PLGIN] loaded plugin libbx_parallel.so 00000000000i[ ] lt_dlhandle is 0x3671670 00000000000i[PLGIN] loaded plugin libbx_serial.so 00000000000i[ ] lt_dlhandle is 0x3675250 00000000000i[PLGIN] loaded plugin libbx_gameport.so 00000000000i[ ] lt_dlhandle is 0x3675cf0 00000000000i[PLGIN] loaded plugin libbx_iodebug.so 00000000000i[ ] reading configuration from bochsrc 00000000000i[ ] lt_dlhandle is 0x3676550 00000000000i[PLGIN] loaded plugin libbx_x.so 00000000000i[ ] installing x module as the Bochs GUI 00000000000i[ ] using log file bochsout.txt Next at t=0 (0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0 c ``` 应该可以看到Hello,OS world!了 注:只有关掉终端才能结束:) ### 第三章 第三章可以直接说明六步的操作 FreeDos已经有了可以自取,生成软盘映像也不再赘述,修改后的bochsrc可自取文件夹c3/c3.b **第四步** 启动bochs 并输入c继续后会启动Bochs 1111 ![输入图片说明](c3/c3.b/image.png) 然后你需要再开启一个终端输入命令 ``` yanbin@ubuntu:~/os/c3/c3.b$ sudo mount -o loop pm.img /mnt/floppy [sudo] password for yanbin: yanbin@ubuntu:~/os/c3/c3.b$ sudo cp pmtest2.com /mnt/floppy/ yanbin@ubuntu:~/os/c3/c3.b$ sudo umount /mnt/floppy ``` ps:可能要去自己安装一下mount命令 **最后到Bochs里执行命令** ![输入图片说明](c3/c3.b/image.png) ps:这是第三章第二个实验,与第一个没有太大差别,这六步有点恶心,