当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 5 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 【bochs启动img文件】问题解决了,给大家当教程吧
帖子发表于 : 2012-04-24 15:42 
头像

注册: 2010-11-19 22:55
帖子: 413
送出感谢: 10
接收感谢: 1
刚才解决了,感觉网上的教程好少啊,这就当个教程吧,功能是在屏幕上显示一行文本,Hello OS,写入U盘并从U盘启动,可以看到这行字,说明程序没问题,刚才也从bochs中启动开了
首先给大家看看启动时用的system.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!"
times 510-($-$$) db 0

dw 0xaa55

使用命令
代码:
nasm system.asm -o system.bin

生成了system.bin文件,使用bochs带的bximage创建img映像:
代码:
bximage
========================================================================
                                bximage
                  Disk Image Creation Tool for Bochs
          $Id: bximage.c 10933 2012-01-04 19:34:08Z 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] 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]

Writing: [] Done.

I wrote 1474560 bytes to a.img.

The following line should appear in your bochsrc:
  floppya: image="a.img", status=inserted

然后用dd命令将system.bin的文件内容写入a.img:
代码:
dd if=system.bin of=a.img count=1 bs=512 conv=notrunc

用ghex2查看a.img,发现文件已写入
然后将a.img放到$HOME/system/中,然后在主目录下创建.bochsrc文件,内容如下:
代码:
###############################################################
# bochsrc.txt file for DLX Linux disk image.
###############################################################

# 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/bochs/VGABIOS-elpin-2.40

# what disk images will be used
floppya: 1_44=$HOME/a.img, status=inserted

# hard disk
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
#ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17

# choose the boot disk.
boot: floppy

# default config interface is textconfig.
#config_interface: textconfig
#config_interface: wx

#display_library: x
# other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga

# where do we send log messages?
log: bochsout

# disable the mouse, since DLX is text only
mouse: enabled=0

# enable key mapping, using US layout as default.
#
# NOTE: In Bochs 1.4, keyboard mapping is only 100% implemented on X windows.
# However, the key mapping tables are used in the paste function, so
# in the DLX Linux example I'm enabling keyboard_mapping so that paste
# will work. Cut&Paste is currently implemented on win32 and X windows only.

keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map
#keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-fr.map
#keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-de.map
#keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-es.map

然后在$HOME/system文件夹下,执行命令bochs,启动虚拟机,按6开始模拟,弹出一个窗口,原来的窗口还带一个命令行,在命令行下输入c,开始运行,显示红色的Hello OS! 终于成功了,搞了两个下午!肯定有后人需要,给大家做个参考吧


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 【bochs启动img文件】问题解决了,给大家当教程吧
帖子发表于 : 2012-04-24 15:52 
头像

注册: 2010-11-19 22:55
帖子: 413
送出感谢: 10
接收感谢: 1
刚才试了一下,直接从system.bin中也能启动


页首
 用户资料  
 
3 楼 
 文章标题 : Re: 【bochs启动img文件】问题解决了,给大家当教程吧
帖子发表于 : 2012-04-24 16:30 
头像

注册: 2008-04-26 12:41
帖子: 11000
送出感谢: 11
接收感谢: 38
:em06


_________________
[新手必读]wubi安装常见问题(FAQ)
[分享]装双系统的同学必看——Windows与Linux系统共享交换分区的方法
kde下唯美的暗黑内透主题(无需编译)
无穷老机上的Trinity Desktop Environment


页首
 用户资料  
 
4 楼 
 文章标题 : Re: 【bochs启动img文件】问题解决了,给大家当教程吧
帖子发表于 : 2013-09-01 22:01 

注册: 2013-08-26 15:33
帖子: 1
系统: win7
送出感谢: 0 次
接收感谢: 0 次
想问下LZ,这个bochs是安装在win上的还是linux上的啊?你也是用的于渊的那本书吗?
我的安装在win7上的,在D盘上,没有看hone/system文件夹啊.


页首
 用户资料  
 
5 楼 
 文章标题 : Re: 【bochs启动img文件】问题解决了,给大家当教程吧
帖子发表于 : 2013-09-02 7:45 
头像

注册: 2007-09-16 8:29
帖子: 14253
送出感谢: 172
接收感谢: 272
:em06


_________________
闻到死太贵, 麦克价更高。 有了笨笨兔, 二者皆可抛。
+ 我的六轮折腾
+ 折腾6轮的结果(对40余种WM的测试和分析,多种DE和WM并存的方案)
+ 折腾的中间成果:可以独立运行的一个Wharf(图标化的启动菜单)
+ 强烈推荐----折腾的终极成果:一个自己开发的DE环境
+ 签名空闲链接位置招租


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 5 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:Google Feedfetcher 和 2 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译