侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

自制操作系统1

2023-11-09 星期四 / 0 评论 / 0 点赞 / 56 阅读 / 8270 字

本系列是自制操作系统的环境准备篇 操作系统:CentOS6.8 开发环境:bochs2.6.2 下载地址:https://sourceforge.net/projects/bochs/files/bo

本系列是自制操作系统的环境准备篇

操作系统:CentOS6.8

开发环境:bochs2.6.2  下载地址:https://sourceforge.net/projects/bochs/files/bochs/2.6.2/

下载后的文件是bochs-2.6.2.tar.gz

解压缩文件到/data目录下

[root@makeOS tools]# tar xf bochs-2.6.2.tar.gz -C /data[root@makeOS data]# cd bochs-2.6.2/#然后开始configure/make/make install[root@makeOS bochs-2.6.2]# ./configure /> --prefix=/data/bochs /> --enable-debugger /> --enable-disasm /> --enable-iodebug /> --enable-x86-debugger /> --with-x /> --with-x11checking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuchecking if you are configuring for another platform... nochecking for standard CFLAGS on this platform... checking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/data/bochs-2.6.2':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details#这里发现没有gcc编译器,然后安装必要的软件包[root@makeOS bochs-2.6.2]# yum install tree telnet dos2unix sysstat lrzsz -y [root@makeOS bochs-2.6.2]# yum install gcc -y[root@makeOS bochs-2.6.2]# yum install glibc-headers gcc-c++ -y#然后执行[root@makeOS bochs-2.6.2]# ./configure /> --prefix=/data/bochs /> --enable-debugger /> --enable-disasm /> --enable-iodebug /> --enable-x86-debugger /> --with-x /> --with-x11#configure之后,我们就可以执行make && make install#报错#make[1]: *** [gtk_enh_dbg_osdep.o] Error 1#make[1]: Leaving directory `/data/bochs-2.6.2/gui'#make: *** [gui/libgui.a] Error 2#发现缺少这个包[root@makeOS bochs-2.6.2]# yum install gtk2-devel -y#继续编译[root@makeOS bochs-2.6.2]# ./configure /--prefix=/data/software/bochs /--enable-debugger /--enable-disasm /--enable-iodebug /--enable-x86-debugger /--with-x /--with-x11#这回make没有报错,然后make install[root@makeOS bochs]# pwd/data/software/bochs#安装成功后在bochs文件夹下有如下文件[root@makeOS bochs]# lsbin  share#接下来配置bochs,在安装目录下游样本文件bochsrc-sample.txt[root@makeOS bochs]# pwd/data/software/bochs/share/doc/bochs[root@makeOS bochs]# lsbochsrc-sample.txt  CHANGES  COPYING  LICENSE  README  TODO#    这里我们可以看到启动顺序#    531 #=======================================================================#    532 # BOOT:#    533 # This defines the boot sequence. Now you can specify up to 3 boot drives,#    534 # which can be 'floppy', 'disk', 'cdrom' or 'network' (boot ROM).#    535 # Legacy 'a' and 'c' are also supported.#    536 # Examples:#    537 #   boot: floppy#    538 #   boot: cdrom, disk#    539 #   boot: network, disk#    540 #   boot: cdrom, floppy, disk#    541 #=======================================================================#    542 #boot: floppy#    543 boot: disk#编写bochs配置文件[root@makeOS bochs]# cat -n bochsrc.disk      1  #Configuration file for Bochs     2  #1 set up memory example 32MB     3  megs: 32     4     5  #2 设置对应真是机器的BIOS和VGA BIOS     6  romimage: file=/data/software/bochs/share/bochs/BIOS-bochs-latest     7  vgaromimage: file=/data/software/bochs/share/bochs/VGABIOS-lgpl-latest     8     9  #3 设置Bochs所使用的磁盘,软盘关键字为floppy    10  #若只有一个软盘,则使用floppya即可,若有多个,则为floppya,floppyb    11  #floppya: 1_44=a.img, status=inserted    12    13  #4 选择启动盘符    14  #boot: floppy 默认为从软盘启动,这里改成从硬盘启动    15  boot: disk    16    17  #5 设置日志文件的输出    18  log: bochs.out    19    20  #6 开启或关闭某些功能    21  mouse: enabled=0    22  keyboard:keymap=/data/software/bochs/share/bochs/keymaps/x11-pc-us.map    23    24  #7硬盘设置    25  ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14#接下来,我们来运行bochs[root@makeOS bochs]# bin/bochs========================================================================                       Bochs x86 Emulator 2.6.2                Built from SVN snapshot on May 26, 2013                  Compiled on May 25 2017 at 21:59:04========================================================================------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [2] What is the configuration file name?To cancel, type 'none'. [none] bochsrc.disk#输入配置文件00000000000i[     ] reading configuration from bochsrc.disk------------------------------Bochs Configuration: Main Menu------------------------------This is the Bochs Configuration Interface, where you can describe themachine that you want to simulate.  Bochs has already searched for aconfiguration file (typically called bochsrc.txt) and loaded it if itcould be found.  When you are satisfied with the configuration, goahead and start the simulation.You can also start bochs with the -q option to skip these menus.1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6] #我们继续回车,启动后,我们看到启动的虚拟机屏幕卡在了那里#应该是缺少启动盘[root@makeOS bochs]# bin/bximage -hd -mode="flat" -size=60 -q hd60M.img========================================================================                                bximage                  Disk Image Creation Tool for Bochs          $Id: bximage.c 11315 2012-08-05 18:13:38Z vruppert $========================================================================I will create a 'flat' hard disk image with  cyl=121  heads=16  sectors per track=63  total sectors=121968  total size=59.55 megabytesWriting: [] Done.I wrote 62447616 bytes to hd60M.img.The following line should appear in your bochsrc:  ata0-master: type=disk, path="hd60M.img", mode=flat, cylinders=121, heads=16, spt=63#我们看到bochs提示我们,应该将上面的内容添加到配置文件中#于是现在的bochsrc.disk如下[root@makeOS bochs]# cat -n bochsrc.disk      1  #Configuration file for Bochs     2  #1 set up memory example 32MB     3  megs: 32     4     5  #2 设置对应真是机器的BIOS和VGA BIOS     6  romimage: file=/data/software/bochs/share/bochs/BIOS-bochs-latest     7  vgaromimage: file=/data/software/bochs/share/bochs/VGABIOS-lgpl-latest     8     9  #3 设置Bochs所使用的磁盘,软盘关键字为floppy    10  #若只有一个软盘,则使用floppya即可,若有多个,则为floppya,floppyb    11  #floppya: 1_44=a.img, status=inserted    12    13  #4 选择启动盘符    14  #boot: floppy 默认为从软盘启动,这里改成从硬盘启动    15  boot: disk    16    17  #5 设置日志文件的输出    18  log: bochs.out    19    20  #6 开启或关闭某些功能    21  mouse: enabled=0    22  keyboard:keymap=/data/software/bochs/share/bochs/keymaps/x11-pc-us.map    23    24  #7硬盘设置    25  ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14    26  ata0-master: type=disk, path="hd60M.img", mode=flat, cylinders=121, heads=16, spt=63#每次启动都通过选项来找到配置文件很麻烦,我们可以使用稍微简单一点的办法[root@makeOS bochs]# bin/bochs -f bochsrc.disk

到此,我们发现,加入了启动盘之后,依然没有成功启动,原因是,我们制作的启动盘上,还缺少东西,那么,什么才是真正的启动盘呢?我们下一将继续。

 

 

广告 广告

评论区