Orange's动手写操作系统-----------第一篇:nasm,bochs环境配置(学习笔记1)

找完工作,开始学习orange's自己动手写操作系统,希望能够坚持,现在的目标就是好好学习,加油~~~

1:安装nasm汇编编译器:网站下载:http://sourceforge.net/projects/nasm,目前最新版本是,nasm-2.06.tar.gz

    源码安装:

    ~$./configure

    ~$make

    ~$sudo make install

    查看安装版本的:

    :~$ nasm -version
    NASM version 2.06 compiled on Nov 15 2012

2:安装bochs虚拟环境

    1)  先安装vgabios,至于为什么,不太清楚,貌似这个和bochs之间有一定的依赖关系吧

          ~ $sudo apt-get  install     vgabios

    2)下载bochs源文件 http://bochs.sourceforge.net/  本篇文章下载的版本是:bochs-2.6.tar.gz

           开始编译bochs源文件

          ~$ tar vxzf bochs-2.6.tar.gz

          ~$  cd bochs-2.6                        //进去解压后的bochs目录中

          ~$./configure   --enable-debugger    --enable-disasm                 //后边带的参数是为了便于以后调试,在bochs-2.6解压后的文件夹中进行的

          ~$make                                 //同样在bochs-2.6文件夹中进行

          ~$sudo make install    

    3) 创建软盘映像

         在bochs安装好之后,执行

         ~$ bximage                  //出现界面如下,划线部分是是需要自己输入的,某些部分也可以采用默认值

        

        .bochsrc的配置文件稍后附上

3:要编译的代码boot.asm如下:

      

4:编译代码

       ~$ nasm boot.asm   -o    boot.bin                  //boot.bin为生成的文件名

5:引导扇写入软盘:

       ~$ dd    if=boot.bin  of=a.img  bs=512  count=1  conv=notrunc

6:相关.bochsrc的配置文件稍后附加上,切记要先进行。bochsrc文件的配置,才能启动

7:bochs启动

      ~$ bochs  出现界面

      

    我们选择2,出现界面如下:

   

   再选择6。出现界面如下:

  终端如下:

 

虚拟bochs

懒得截图了:

终端如下:

<bochs:4> x /64xb 0x7c00
[bochs]:
0x00007c00 <bogus+       0>:    0x8c    0xc8    0x8e    0xd8    0x8e    0xc0    0xe8    0x03
0x00007c08 <bogus+       8>:    0x00    0xe9    0xfd    0xff    0xb8    0x1f    0x7c    0x89
0x00007c10 <bogus+      16>:    0xc5    0xb9    0x10    0x00    0xb8    0x01    0x13    0xbb
0x00007c18 <bogus+      24>:    0x0c    0x00    0xb2    0x00    0xcd    0x10    0xc3    0x48
0x00007c20 <bogus+      32>:    0x65    0x6c    0x6c    0x6f    0x2c    0x20    0x4f    0x53
0x00007c28 <bogus+      40>:    0x20    0x77    0x6f    0x72    0x6c    0x64    0x00    0x00
0x00007c30 <bogus+      48>:    0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
0x00007c38 <bogus+      56>:    0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
<bochs:5> trace-reg on
Register-Tracing enabled for CPU0
<bochs:6> c

bochs界面


基本就这样了,中间出现的错误及其解决稍后加上o(∩∩)o...哈哈

附加:.bochsrc配置文件内容

# You may now use double quotes around pathnames, in case
# your pathname includes spaces.

#=======================================================================
# PLUGIN_CTRL:
# Controls the presence of optional device plugins. These plugins are loaded
# directly with this option and some of them install a config option that is
# only available when the plugin device is loaded. The value "1" means to load
# the plugin and "0" will unload it (if loaded before).
#
# These plugins will be loaded by default (if present): 'biosdev', 'extfpuirq',
# 'gameport', 'iodebug','parallel', 'serial', 'speaker' and 'unmapped'.
#
# These plugins are also supported, but they are usually loaded directly with
# their bochsrc option: 'e1000', 'es1370', 'ne2k', 'pcidev', 'pcipnic', 'sb16',
# 'usb_ohci', 'usb_uhci' and 'usb_xhci'.
#=======================================================================
#plugin_ctrl: unmapped=0, e1000=1 # unload 'unmapped' and load 'e1000'

#=======================================================================
# CONFIG_INTERFACE
#
# The configuration interface is a series of menus or dialog boxes that
# allows you to change all the settings that control Bochs's behavior.
# Depending on the platform there are up to 3 choices of configuration
# interface: a text mode version called "textconfig" and two graphical versions
# called "win32config" and "wx". The text mode version uses stdin/stdout and
# is always compiled in, unless Bochs is compiled for wx only. The choice
# "win32config" is only available on win32 and it is the default there.
# The choice "wx" is only available when you use "--with-wx" on the configure
# command. If you do not write a config_interface line, Bochs will
# choose a default for you.
#
# NOTE: if you use the "wx" configuration interface, you must also use
# the "wx" display library.
#=======================================================================
#config_interface: textconfig
#config_interface: win32config
#config_interface: wx

#=======================================================================
# DISPLAY_LIBRARY
#
# The display library is the code that displays the Bochs VGA screen. Bochs
# has a selection of about 10 different display library implementations for
# different platforms. If you run configure with multiple --with-* options,
# the display_library command lets you choose which one you want to run with.
# If you do not write a display_library line, Bochs will choose a default for
# you.
#
# The choices are:
# x use X windows interface, cross platform
# win32 use native win32 libraries
# carbon use Carbon library (for MacOS X)
# macintosh use MacOS pre-10
# amigaos use native AmigaOS libraries
# sdl use SDL library, cross platform
# svga use SVGALIB library for Linux, allows graphics without X11
# term text only, uses curses/ncurses library, cross platform
# rfb provides an interface to AT&T's VNC viewer, cross platform
# wx use wxWidgets library, cross platform
# nogui no display at all
#
# NOTE: if you use the "wx" configuration interface, you must also use
# the "wx" display library.
#
# Specific options:
# Some display libraries now support specific options to control their
# behaviour. These options are supported by more than one display library:
#
# "gui_debug" - use GTK debugger gui (sdl, x) / Win32 debugger gui (sdl, win32)
# "hideIPS" - disable IPS output in status bar (rfb, sdl, win32, wx, x)
# "nokeyrepeat" - turn off host keyboard repeat (sdl, win32, x)
#
# See the examples below for other currently supported options.
#=======================================================================
#display_library: amigaos
#display_library: carbon
#display_library: macintosh
#display_library: nogui
#display_library: rfb, options="timeout=60" # time to wait for client
#display_library: sdl, options="fullscreen" # startup in fullscreen mode
#display_library: term
#display_library: win32
#display_library: wx
#display_library: x

#=======================================================================
# ROMIMAGE:
# The ROM BIOS controls what the PC does when it first powers on.
# Normally, you can use a precompiled BIOS in the source or binary
# distribution called BIOS-bochs-latest. The ROM BIOS is usually loaded
# starting at address 0xf0000, and it is exactly 64k long. Another option
# is 128k BIOS which is loaded at address 0xe0000.
# You can also use the environment variable $BXSHARE to specify the
# location of the BIOS.
# The usage of external large BIOS images (up to 512k) at memory top is
# now supported, but we still recommend to use the BIOS distributed with
# Bochs. The start address optional, since it can be calculated from image size.
#=======================================================================
romimage: file=$BXSHARE/BIOS-bochs-latest
#romimage: file=bios/seabios-1.6.3.bin
#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory top

#=======================================================================
# CPU:
# This defines cpu-related parameters inside Bochs:
#
# MODEL:
# Selects CPU configuration to emulate from pre-defined list of all
# supported configurations. When this option is used, the CPUID option
# has no effect anymore.
#
# CPU configurations that can be selected:
# -----------------------------------------------------------------
# pentium_mmx Intel Pentium MMX
# amd_k6_2_chomper AMD-K6(tm) 3D processor (Chomper)
# p2_klamath Intel Pentium II (Klamath)
# p3_katmai Intel Pentium III (Katmai)
# p4_willamette Intel(R) Pentium(R) 4 (Willamette)
# core_duo_t2400_yonah Intel(R) Core(TM) Duo CPU T2400 (Yonah)
# atom_n270 Intel(R) Atom(TM) CPU N270
# athlon64_clawhammer AMD Athlon(tm) 64 Processor 2800+ (Clawhammer)
# athlon64_venice AMD Athlon(tm) 64 Processor 3000+ (Venice)
# turion64_tyler AMD Turion(tm) 64 X2 Mobile TL-60 (Tyler)
# phenom_8650_toliman AMD Phenom X3 8650 (Toliman)
# p4_prescott_celeron_336 Intel(R) Celeron(R) 336 (Prescott)
# core2_penryn_t9600 Intel Mobile Core 2 Duo T9600 (Penryn)
# corei5_lynnfield_750 Intel(R) Core(TM) i5 750 (Lynnfield)
# corei5_arrandale_m520 Intel(R) Core(TM) i5 M 520 (Arrandale)
# corei7_sandy_bridge_2600k Intel(R) Core(TM) i7-2600K (Sandy Bridge)
# corei7_ivy_bridge_3770k Intel(R) Core(TM) i7-3770K CPU (Ivy Bridge)
#
# COUNT:
# Set the number of processors:cores per processor:threads per core
# when Bochs is compiled for SMP emulation.
# Bochs currently supports up to 8 threads running simultaniosly.
# If Bochs is compiled without SMP support, it won't accept values
# different from 1.
#
# QUANTUM:
# Maximum amount of instructions allowed to execute by processor before
# returning control to another cpu. This option exists only in Bochs
# binary compiled with SMP support.
#
# RESET_ON_TRIPLE_FAULT:
# Reset the CPU when triple fault occur (highly recommended) rather than
# PANIC. Remember that if you trying to continue after triple fault the
# simulation will be completely bogus !
#
# CPUID_LIMIT_WINNT:
# Determine whether to limit maximum CPUID function to 2. This mode is
# required to workaround WinNT installation and boot issues.
#
# MSRS:
# Define path to user CPU Model Specific Registers (MSRs) specification.
# See example in msrs.def.
#
# IGNORE_BAD_MSRS:
# Ignore MSR references that Bochs does not understand; print a warning
# message instead of generating #GP exception. This option is enabled
# by default but will not be avaiable if configurable MSRs are enabled.
#
# MWAIT_IS_NOP:
# When this option is enabled MWAIT will not put the CPU into a sleep state.
# This option exists only if Bochs compiled with --enable-monitor-mwait.
#
# IPS:
# Emulated Instructions Per Second. This is the number of IPS that bochs
# is capable of running on your machine. You can recompile Bochs with
# --enable-show-ips option enabled, to find your host's capability.
# Measured IPS value will then be logged into your log file or shown
# in the status bar (if supported by the gui).
#
# IPS is used to calibrate many time-dependent events within the bochs
# simulation. For example, changing IPS affects the frequency of VGA
# updates, the duration of time before a key starts to autorepeat, and
# the measurement of BogoMips and other benchmarks.
#
# Examples:
#
# Bochs Machine/Compiler Mips
# ______________________________________________________________________
# 2.4.6 3.4Ghz Intel Core i7 2600 with Win7x64/g++ 4.5.2 85 to 95 Mips
# 2.3.7 3.2Ghz Intel Core 2 Q9770 with WinXP/g++ 3.4 50 to 55 Mips
# 2.3.7 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 38 to 43 Mips
# 2.2.6 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 21 to 25 Mips
# 2.2.6 2.1Ghz Athlon XP with Linux 2.6/g++ 3.4 12 to 15 Mips
#=======================================================================
cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
cpu: cpuid_limit_winnt=0

#=======================================================================
# CPUID:
#
# This defines features and functionality supported by Bochs emulated CPU.
# The option has no offect if CPU model was selected in CPU option.
#
# MMX:
# Select MMX instruction set support.
# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5.
#
# APIC:
# Select APIC configuration (LEGACY/XAPIC/XAPIC_EXT/X2APIC).
# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5.
#
# SEP:
# Select SYSENTER/SYSEXIT instruction set support.
# This option exists only if Bochs compiled wi

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值