我最近在学习操作系统,但是我不能让bootloader工作
软盘:

#configuration file generated by Bochs
plugin_ctrl: biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1 ,unmapped=0
config_interface: textconfig
display_library: x
memory: host=2048, guest=2048
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest"
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest"
boot: floppy
floppy_bootsig_check: disabled=0
floppya: type=1_44, 1_44="boot.img", status=inserted, write_protected=0
#no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=none
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5
cpu: count=1:1:1, ips=4000000, quantum=16, model=corei7_ivy_bridge_3770k, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0, msrs="msrs.def"
cpuid: x86_64=1,level=6, mmx=1, sep=1,  aes=1, movbe=1, xsave=1,apic=x2apic,sha=1,movbe=1,adx=1,xsaveopt=1,avx_f16c=1,avx_fma=1,bmi=bmi2,1g_pages=1,pcid=1,fsgsbase=1,smep=1,smap=1,mwait=1
cpuid: family=6, model=0x1a, stepping=5, vendor_string="GenuineIntel", brand_string="Intel(R) Core(TM) i7-3770 CPU (Haswell)"
print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
speaker: enabled=1, mode=system
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0
megs: 148

然后有两个asm文件boot.asm和loader.asm
运行.sh:
nasm boot.asm -o boot.bin
nasm loader.asm -o loader.bin
dd if=boot.bin of=boot.img bs=512 count=1 conv=notrunc

if [ ! -e tmp ];then
             mkdir tmp
fi

mount -t vfat -o loop boot.img tmp/

cp loader.bin tmp/
sync
umount tmp/

rmdir tmp
if [ -e /usr/bin/bochs ];then
    /usr/bin/bochs -qf bochsrc.floppy
else
    echo "Please check your bochs environment!!!"
    exit 1
fi

执行cp命令时:
cp: cannot create regular file 'tmp/loader.bin': No space left on device

最后,bochs中的这个错误
从0000:7c00启动
软盘映像上的[floppy]read()返回0
有人能告诉我怎么了吗?

最佳答案

在最初的项目中,他们的run.sh文件包含一组关键的行,这些行创建磁盘映像boot.img,因此它的大小相当于1.44mb软盘。您需要将它们添加到run.sh的顶部:

if [ -e boot.img ];then
    echo "find boot.img !"
else
    echo "no boot.img! generating..."
    echo -e  "1\nfd\n\nboot.img\n" | bximage
fi

这些行检查是否已经存在一个cc文件。如果boot.img已经存在,则使用现有的一个,否则创建一个新的。您还可以替换:
echo -e  "1\nfd\n\nboot.img\n" | bximage

使用:
dd if=/dev/zero of=boot.img bs=1024 count=1440

重要提示:您需要删除大小不正确的旧boot.img文件,以便由上面的代码生成大小正确的新文件。

关于linux - bochs从软盘启动FLOPPY:软盘镜像上的read()返回0,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52207463/

10-09 07:47