bochs 里玩 linux-0.11

来源:互联网 发布:碎片化时间 知乎 编辑:程序博客网 时间:2024/04/28 08:54


安装 bochs

......


编译 linux-0.11 内核


下载内核 linux-0.11-081030.tar.gz, 这个内核是经过别人修改的,应该在他的机器上可以编译,但是在ubuntu上有一下问题,搜索解决方法如下,我按下面修改后可以编译通过。

linux 0.11源码文件在linux-0.11-081030.tar.gz中,进入目录解压后的目录linux-0.11中
1. 
 
ubuntu  8.04 gcc 版本为4.2.4,但是GCC4.x 默认检查stack安全,会导致出现__stack_chk_fail错误,所以在编译之前应先修改Makefile: 
    linux-0.11/Makefile
    linux-0.11/
 
kernel /Makefile
    linux-0.11/kernel/chr_dev/Makefile
    linux-0.11/kernel/blk_dev/Makefile
    linux-0.11/fs/Makefile
    在 CFLAGS参数中加入-fno-stack-protector


产生 Image, 拷贝 hdc-0.11-new.img 到当前目录(含有Image的目录),建立一个bochsrc.bxrc文件,内容如下:

  1 romimage: file=$BXSHARE/BIOS-bochs-latest                                                    
  2 megs: 16
  3 vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
  4 vga: extension=vbe
  5 floppya: 1_44="Image", status=inserted
  6 floppyb: 1_44=diska.img, status=inserted
  7 ata0-master: type=disk, path="hdc-0.11-new.img", mode=flat,cylinders=410, heads=16, spt=38
  8 boot: a
  9 log: bochsout.txt
 10 parport1: enable=0
 11 vga_update_interval: 300000
 12 keyboard_serial_delay: 200
 13 #floppy_command_delay: 50000
 14 #ips: 4000000
 15 mouse: enabled=0
 16 private_colormap: enabled=0
 17 fullscreen: enabled=0
 18 screenmode: name="sample"  

  

在 bochs 里运行 linux-0.11


  执行# bochs -f bochsrc.bxrc,信息如下:


  1 Plex86/Bochs VGABios (PCI) 0.7a 30 Oct 2011                                 EGAc             
  2 This VGA/VBE Bios is released under the GNU LGPL
  3  
  4 Please visit :
  5  . http://bochs.sourceforge.net
  6  . http://www.nongnu.org/vgabios
  7  
  8 Bochs VBE Display Adapter enabled
  9  
 10 Bochs BIOS - build: 08/21/12
 11 $Revision: 11318 $ $Date: 2012-08-06 19:59:54 +0200 (Mo, 06. Aug 2012) $
 12 Options: apmbios pcibios pnpbios eltorito rombios32
 13  
 14 ata0 master: Generic 1234 ATA-6 Hard-Disk ( 121 MBytes)
 15  
 16 Press F12 for boot menu.
 17  
 18 Booting from Floppy...
 19  
 20 Loading system ...


不动了,在网上搜索了一哥们的解决方法如下:


  1 Only in linux-0.11: bochsout.txt                                                                                                                          

  2 diff -r linux-0.11/init/main.c linux/init/main.c
  3 10c10             
  4 <                 
  5 ---               
  6 > #include  <string.h>
  7 111c111,113       
  8 <   drive_info = DRIVE_INFO;
  9 ---               
 10 >     //modify by wangcong02345
 11 >     // drive_info = DRIVE_INFO;
 12 >     memcpy((void*)&drive_info, (void*)&DRIVE_INFO, sizeof(struct drive_info)); 
 13 diff -r linux-0.11/kernel/fork.c linux/kernel/fork.c
 14 12a13             
 15 > #include <string.h>
 16 82c83,86          
 17 <   *p = *current;  /* NOTE! this doesn't copy the supervisor stack */
 18 ---               
 19 >                 
 20 >   memcpy(p, current, sizeof(struct task_struct)); 
 21 >                 
 22 >                 
 23 diff -r linux-0.11/kernel/Makefile linux/kernel/Makefile
 24 14c14             
 25 < CFLAGS    =-Wall -O -fstrength-reduce -fomit-frame-pointer -fno-stack-protector\
 26 ---               
 27 > CFLAGS    =-Wall  -fstrength-reduce -fomit-frame-pointer -fno-stack-protector\
 28 diff -r linux-0.11/tools/build.c linux/tools/build.c
 29 39,40c39,40       
 30 < #define DEFAULT_MAJOR_ROOT 2
 31 < #define DEFAULT_MINOR_ROOT 0x1d
 32 ---               
 33 > #define DEFAULT_MAJOR_ROOT 03
 34 > #define DEFAULT_MINOR_ROOT 0x01


按上面修改后,重新编译内核,


执行# bochs -f bochsrc.bxrc,启动成功,信息如下

  1 Please visit :                                                                               

  2  . http://bochs.sourceforge.net
  3  . http://www.nongnu.org/vgabios
  4  
  5 Bochs VBE Display Adapter enabled
  6  
  7 Bochs BIOS - build: 08/21/12
  8 $Revision: 11318 $ $Date: 2012-08-06 19:59:54 +0200 (Mo, 06. Aug 2012) $
  9 Options: apmbios pcibios pnpbios eltorito rombios32
 10  
 11 ata0 master: Generic 1234 ATA-6 Hard-Disk ( 121 MBytes)
 12  
 13 Press F12 for boot menu.
 14  
 15 Booting from Floppy...
 16  
 17 Loading system ...
 18  
 19 Partition table ok.
 20 42862/62000 free blocks
 21 19717/20666 free inodes
 22 113 buffers = 21992 bytes buffer space
 23 Free mem: 113 bytes
 24  Ok.
 25 [/usr/root]#


终于启动起来的,弄了好长时间,其实都是网上弄过的人的经验总结,自己收集记录了一下,主要参考了以下链接:

http://cache.baidu.com/c?m=9d78d513d9931cfe02ac837e7c488a354f0fdc362bd7a1543495d51fcc735a31506694ac26520704a4d27d1716af3e4beb802172401421c78cc8ff5ddccb8528589c60742e13dc0754910eaeb85b388465d54de9d844b9ecae69cfe998c4df230e8a061827dea6d5015c538072b44f66a6e0c308420c46aded4727a51b6028eb651be050f896316f0280f1&p=8636da16d9c04af918bd9b7d0e14802c&newp=99678e5f88904eac53bd9b7d0e14962e5c5bc13451d4d6167a&user=baidu&fm=sc&query=bochs+loading+system%2E%2E%2E%2E%2E%2E&qid=9c74a1b43b5fd9cd&p1=15

http://blog.csdn.net/ljl1603/article/details/5873980

http://hi.baidu.com/419836321/item/c848904a0eab97086dc2f0c7


其实当初还搜索了好多链接,现在记不起来了,在这个一并表示感谢......