bochs

bochs调试简单操作系统方法

假如想象 提交于 2020-01-19 21:15:42
我用的是bochs 2.6.11 首先进入bochs的调试模式使用的是 ,打开bochsdbg。同理他也会让你选择配置文件。 选择完了配置文件,弹出两个窗口,一个是调试命令行,一个是操作系统窗口 最初的时候,他会显示一些日志,然后注意: 显示了下一条指令的所在地和指令内容。我们观察因为实模式下 BIOS的引导代码实在 0xf000:0xfff0这里,也就是机器一加电后,cs和ip的初始化内容,我们可以看到他要跳转到 0xf000:e05b这里,这个时候才是我们真正的BIOS代码。 之后查看 0x7c00:0000这里,发现他的内容是0000,这个是正常的,毕竟我们的mbr是需要BIOS加载到对应位置的,这个时候BIOS还没有运行呢。 下面引入一下实模式的内存布局,方便没有了解过的小伙伴们学习。 接着引入bochs的调试方法 首先是xp命令 (提示:bochs下的一个字 是 四个字节) xp/ 这后面可以跟 b h w g 分别对应的是 字节 两个字节 一个字 两个字 之后跟内存地址 (注意上面指令指定了一次显示内存单元的大小之后再次查看内存单元就是以一个字节来访问的了, xp/4 0x7c00 xp之后跟数字就是连续查看几个单元,所以应该是查看4个字节) 之后是 u命令 用来将内存数据反汇编成指令 u后面加需要反汇编的指令数和起始地址,例如: u [num] [start]

使用汇编语言编写一个简单的X86 Boot loader

耗尽温柔 提交于 2020-01-11 01:57:52
真正一小步,编写属于你自己的X86 Boot loader 前言 参考资料 环境和工具 工具安装 编写Boot Loader 编写用户程序 运行 汇编 创建硬盘镜像 编写Bochs配置文件bochsrc 将Boot loader和用户程序写入磁盘映像 Bochs运行和调试 前言 笔者一直对操作系统非常感兴趣,一直希望能够编写一款属于自己的操作系统。不过各种事情让我一直抽不开身。现在大四了,终于有时间好好搞一搞自己喜欢的东西。 经过深思熟虑,我决定还是从Boot Loader做起。国内各种网站和博客关于这方面内容的东西不是特别多,我在编写Boot Loader的时候也是摸着石头过河。国内大部分博客所写的,如”编写一个最简单的操作系统“,”编写一个基本的Boot Loader“之类的内容绝大多数都只是完成了一个Boot sector,在裸机上啪啪打出一串字符就完了。 对于一个Boot Loader, 它的基本功能肯定是要从硬盘上读取出操作系统内核(或是用户程序),再将其搬运到内存中,最后跳转到操作系统内核。 本文中的Boot Loader是一个最简单的Boot Loader,能够从硬盘中读取到用户程序并将其放到内存中指定的位置。 参考资料 《x86汇编语言:从实模式到保护模式》:非常好的一本书,详细地介绍了X86汇编语言。在编写一个Boot loader之前所需了解的知识

Loading a kernel without a filesystem - osdev

萝らか妹 提交于 2020-01-05 04:57:35
问题 I built a bootloader to load my kernel onto the memory. The kernel code is lying on the sectors of the floppy. The 2 stage bootloader reads out raw bytes of memory from the floppy disk and places it on the memory and executes the kernel. This works good on the bochs emulator but fails on the qemu emulator. Some tutorials out there suggest keeping the kernel file on a file system (like FAT12) and then reading the file from it. So, I want to ask that would such a system actually work on a

PintOS, kernel panic with -v option bochs on ubuntu

旧时模样 提交于 2020-01-01 07:07:10
问题 when i do "pintos -- run alarm-multiple" in .../build/ everything seems fine. but when i do "make check" in .../build/ all 7 tests failed with the same "Run didn't start up properly: no "pintos booting" message" pintos -v -k -T 60 --bochs -- -q run alarm-single < /dev/null 2> tests/threads/alarm-single.errors > tests/threads/alarm-single.output perl -I../.. ../../tests/threads/alarm-single.ck tests/threads/alarm-single tests/threads/alarm-single.result FAIL tests/threads/alarm-single Run didn

GPF after far jump to protected mode

别说谁变了你拦得住时间么 提交于 2019-12-22 23:22:20
问题 After several weeks of work using GRUB as my bootloader I decided that I should roll my own so I can understand how they work. I found Brokenthorn's tutorials on the internet (currently on http://www.brokenthorn.com/Resources/OSDev9.html). When I try to switch to protected mode the cpu hardware resets after the far jump. I'm running bochs v. 2.6. this is my second stage bootloader( almost a copy of the tutorial because i thought it would fix my problems - it doesn't) bits 16 ; Remember the

How can I use Bochs to run Assembly code?

心已入冬 提交于 2019-12-21 02:21:16
问题 I want to use Bochs as an 8086 emulator. Is there an easy way to do this? What I want is something like emu8086 (http://www.emu8086.com/). 回答1: If the initial part of your program fits in 512 bytes, and you don't mind restricting yourself to BIOS calls, in / out instructions, and writing to magic memory locations for I/O... Then yes! Assuming you're using NASM, here's a goofy example... (Warning: my 16-bit assembly skills are not very great and kind of rusty, so it might not be the best code.

boxuchsrc模板

五迷三道 提交于 2019-12-10 21:36:58
软盘镜像启动 真坑,用bxiamge制作出来的软盘,提示让在配置文件中加入 floppya: image=a.img, status=inserted 这句话 但是死活不对 网上让加入 floppya: 1_44=a.img, status=inserted 这句话 结果就对了,真的是,bochs这个软件真坑 megs: 32 romimage: file=/usr/local/share/bochs/BIOS-bochs-latest vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest floppya: 1_44=a.img, status=inserted boot: floppy log: bochsout.txt mouse: enabled=0 keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map 硬盘启动 需要注意的是在向硬盘写入二进制信息的时候,dd if=a.bin of=c.img count=1 bs=512 conv=notrunc 一定要加入 conv=notrunc 这句话,不然c.img文件的大小就会变成 count * bs的大小。 megs: 32 romimage: file=

Gcc inline assembly: what's wrong with the dynamic allocated register `r` in input operand?

泪湿孤枕 提交于 2019-12-06 09:19:17
问题 When I test the GCC inline-assembly, I use the test function to display a character on the screen with the BOCHS emulator. This code is running in 32-bit protected mode. The code is as follows: test() { char ch = 'B'; __asm__ ("mov $0x10, %%ax\n\t" "mov %%ax, %%es\n\t" "movl $0xb8000, %%ebx\n\t" "mov $0x04, %%ah\n\t" "mov %0, %%al\n\t" "mov %%ax, %%es: ((80 * 3 + 40) * 2)(%%ebx)\n\t" ::"r"(ch):); } The result I'm getting is: The red character on the screen isn't displaying B correctly.

Compiling Bochs on Mac os x Snow Leopard

老子叫甜甜 提交于 2019-12-04 09:25:28
问题 Was someone able to compile the Bochs simulator under Snow Leopard. Leopard worked fine for me but under Snow Leopard I get alot of problems related to the Carbon library... Ok, some more information was request. I compile with make on the shell; stanard build process coming with the bochs sources I was successfully able to compile against the 10.5 SDK. Unfortunatley, it was not running under Snow Leopard... always crashed then I installed the latest XCode from the SnowLeopard CD and compiled

Read a write a sector from hard drive with int 13h

纵饮孤独 提交于 2019-12-03 14:30:09
问题 I have a simple program. It must read first sector from hard drive (not mbr), and write it to the 0 sector (mbr). But it doesnt work. I think it is connected with wrong DAP. Thanks. [bits 16] [org 0x7c00] ;clear screen start: mov ax, 0x3 int 0x10 ;reset the hard drive xor ah, ah mov dl, 0x80 int 0x13 jnz error ;read the second sector mov si, DAP mov ah, 0x42 int 0x13 mov si, data call print_string jmp $ DAP: db 0x10 ;size of DAP db 0x0 ;zero db 0x1 ;number of sectors to read db 0x0 ;zero