自己动手写操作系统之第一部分笔记

    为了跟书本的内容一致,特意选择了Debian和bochs2.3.5版本进行实践,但是在实践过程中还是出现了很多问题,我觉得这些问题是在用本书进行实践过程中极有可能出现的,但是作者却没有提及,只能靠自己寻找资料,解决问题。

  遇到的第一个问题是,解压后执行./configure命令无法正常生成makefile文件,这是由于缺少一些关键依赖软件未安装,缺少什么软件一般会在最后一行进行提示,只要使用apt-get安装相应的软件包即可。

  第二个问题则非常吐血了,提示错误如下:

........   

symbols.cc:173: error: ‘map’ was not declared in this scope       

make[1]: *** [symbols.o] Error 1        

make: *** [bx_debug/libdebug.a] Error 2

解决方法需要修改源代码,WTF!修改方法如下:

bx_debug/symbols.cc97 行之后加上一些代码,加后如下所示:

using namespace std;

 

#ifdef __GNUC__  (新加的,注意前后都是两个下划线)

 

using namespace __gnu_cxx; (新加的,注意前面是两个下划线)

 

#endif  (新加的)

 

struct symbol_entry_t;

 

之后即可正常地进行编译了,编译完成后,需要注意的是,配置文件的路径一定要跟本机上的路径一致,本机的配置文件如下:

 

# memory megs:32
# file of rom images romimage: file=/usr/local/share/bochs/BIOS-bochs-latest vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest
# disk will be used floppya: 1_44=a.img, status=inserted
# boot disk boot:floppy
# log messages log:bochsout.log
# disable the mouse mouse:enabled=0
#enable key mapping keyboard_mapping:enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map

 

注意,romimagevgaromimage 的路径,跟书上说的有点不同

 

把上面编写的bochsrca.img 放在同一个目录下,在这个目录下输入bochs命令( 什么参数也没带) ,一个回车:

 

========================================================================                        Bochs x86 Emulator 2.3.5             Build from CVS snapshot, on September 16, 2007 ======================================================================== 00000000000i[     ] reading configuration from bochsrc ------------------------------ Bochs Configuration: Main Menu ------------------------------
This is the Bochs Configuration Interface, where you can describe the machine that you want to simulate.  Bochs has already searched for a configuration file (typically called bochsrc.txt) and loaded it if it could be found.  When you are satisfied with the configuration, go ahead and start the simulation.
You can also start bochs with the -q option to skip these menus.
1. Restore factory default configuration 2. Read options from... 3. Edit options 4. Save options to... 5. Restore the Bochs state from... 6. Begin simulation 7. Quit now
Please choose one: [6] 
 
再输入回车:

 

 

Please choose one: [6] 00000000000i[     ] installing x module as the Bochs GUI 00000000000i[     ] using log file bochsout.log Next at t=0 (0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0 <bochs:1> c   回车:(注意输入了c)

 

 

如果用不带调试功能的Bochs2.4.5,那么在

 

Please choose one: [6] 回车之后,马上就可以看到上面的效果了。

 

注意:当用户输入bochs命令时,可能出现Message:ata0-0:could not open hard drive image file '30M.sample',此时说明不是从软盘启动的,那么用户应该输入完整的命令:bochs -f bochsrc,这样就可以了。

 

现在大家应该可以看到自己的小型操作系统了吧,在这里非常感谢《orange's一个操作系统的实现》的作者于渊,我非常佩服作者的耐心和能力,作者的一句话令我很有启发:只要用心,就没有学不会的东西!!!

 

 

 

 

posted @ 2014-03-22 21:21  晨曦语晴  阅读(1344)  评论(0编辑  收藏  举报