bochs下如何加载和调试jos内核的过程:

 

I.Bochs 下编译和运行Jos内核

http://pdos.lcs.mit.edu/6.828/2007/labs/lab1/lab1.tar.gz 下载Lab1所需内核

tar 解压

sudo ln -s /usr/bin/make /usr/bin/gmake   添加make别名gmake

gmake 编译Jos内核(Notice:it must be maked with the gcc-4.5.First,i use the Ubuntu11.10 with the gcc-4.6 ,it make a big error!!"  boot block too large:600 bytes (max 510)".Because the first section can only wirte the 512 bytes. Last ,i change the Ubuntu10.10 wiht gcc-4.4.5,it's all right!!)

 

http://grid.hust.edu.cn/zyshao/Teaching_Material/OSEngineering/lab1-helloworld.tar.gz  下载bochs启动配置文件

 change the bochs.img path which marked with red

 

bochsrc file:

cpu: count=1, ips=10000000

megs: 32

romimage: file=$BXSHARE/BIOS-bochs-latest

vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest

vga: extension=none

ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14

ata0-master: type=disk, mode=flat, path="./obj/kern/bochs.img", cylinders=100, heads=10, spt=10

boot: disk

clock: sync=realtime, time0=local

floppy_bootsig_check: disabled=0

log: bochs.log

panic: action=ask
error: action=report
info: action=ignore
debug: action=ignore

debugger_log: -

parport1: enabled=1, file="/dev/stdout"

vga_update_interval: 300000

keyboard_serial_delay: 250

keyboard_paste_delay: 100000

mouse: enabled=0

private_colormap: enabled=0

keyboard_mapping: enabled=0, map=

 

bochs -f bochsrc 启动内核

OK!! input c to continue,Now,you can see the message" Booting from Hard Disk.." Got it!!

 

II.Let's output the "hello world" in real mode

add the red code in boot.s

..........................

 
  # Set up the important data segment registers (DS, ES, SS).
  xorw    %ax,%ax             # Segment number zero
  movw    %ax,%ds             # -> Data Segment
  movw    %ax,%es             # -> Extra Segment
  movw    %ax,%ss             # -> Stack Segment


  movw    $0xb800,%ax
  movw    %ax,%es
  movw    $msg1,%si
  movw    $0xbe2,%di
  movw    $24,%cx
  rep     movsb

  movw    $str,%si
  movw    $0xc04,%di
  movw    $28,%cx
  rep     movsb               # print "hello world" in real mode

....................
gdtdesc:
  .word   0x17                            # sizeof(gdt) - 1
  .long   gdt                             # address gdt

#string to print
msg1:
  .byte 'i',0x7,'n',0x7,' ',0x7,'r',0x7,'e',0x7,'a',0x7,'l',0x7,' ',0x7,'m',0x7,'o',0x7,'d',0x7,'e',0x7
str:
  .byte ':',0xf,' ',0xc,' ',0xc,'h',0xc,'e',0xc,'l',0xc,'l',0xc,'o',0xc,' ',0xc,'w',0xc,'o',0xc,'r',0xc,'l',0xc,'d',0xc

Bit it! so cool!

 

 

III.JOS 启动过程

系统启动时是先把BIOS内的信息加载到物理内存中 ox000F0000(960K)到0x001000000(1M)处,并开始执行BIOS指令,

对系统进行初始化,比如像激活显卡、检查内存总量等。在完成这些初始化后,BIOS把Boot Loader加载到内存(0x7c00到0x7dff),

并将控制权交给Boot Loader程序。Boot Loader主要包含两个文件boot.s和main.c,boot.s主要完成实模式到保护模式的转换工作,

main.c 则负责将内核加载到内存,并将控制权交给内核entry.s,entry.s更新GDT表和初始化堆栈指针并调用init.c初始化控制台,

并将控制权交给一个简单的shell文件monitor.c,完成对用户的命令行响应。

  加载mon_backtrace()后的效果:


http://grid.hust.edu.cn/zyshao/teaching_operating_system_acm.htm

http://grid.hust.edu.cn/zyshao/OSEngineering.htm(实践)

http://www.cnblogs.com/lynnjyl/archive/2012/01/21/2328659.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值