gpt4 book ai didi

mcopy says "Cannot initialize '::'" for no aparent reason(MCopy无缘无故地说“无法初始化‘::’”)

转载 作者:bug小助手 更新时间:2023-10-27 21:06:27 27 4
gpt4 key购买 nike




I have this makefile:

我有这个Makefile:


ASM = nasm

.PHONY: floppyimage kernel bootloader everything

goldos: everything
qemu-system-i386 -fda build/goldos.img

norun: everything

everything: floppyimage kernel bootloader build

floppyimage: build/goldos.img

build/goldos.img: build bootloader kernel
dd if=/dev/zero of=build/goldos.img bs=512 count=2880
mkfs.fat -F 12 -n "GOLDOS" build/goldos.img
dd if=build/bootloader.bin of=build/goldos.img conv=notrunc
mcopy -i build/goldos.img build/kernel.bin "::kernel.bin"

bootloader: build/bootloader.bin

build/bootloader.bin: build bootloader/bootloader.asm
$(ASM) bootloader/bootloader.asm -fbin -obuild/bootloader.bin

kernel: build/kernel.bin

build/kernel.bin: build kernel/kernel.asm
$(ASM) kernel/kernel.asm -fbin -obuild/kernel.bin

clean:
rm -r build

build:
mkdir -p build

For some stupid reason, it started saying:

出于某种愚蠢的原因,它开始说:


dd if=/dev/zero of=build/goldos.img bs=512 count=2880
2880+0 records in
2880+0 records out
1474560 bytes (1.5 MB, 1.4 MiB) copied, 0.00605087 s, 244 MB/s
mkfs.fat -F 12 -n "GOLDOS" build/goldos.img
mkfs.fat 4.2 (2021-01-31)
dd if=build/bootloader.bin of=build/goldos.img conv=notrunc
1+0 records in
1+0 records out
512 bytes copied, 5.852e-05 s, 8.7 MB/s
mcopy -i build/goldos.img build/kernel.bin "::kernel.bin"
init :: non DOS media (here, the parentesis are not part of the output)
Cannot initialize '::'
::kernel.bin: Success
make: *** [makefile:18: build/goldos.img] Error 1

bootloader.asm (on github due to over 300 lines)

i cannot run this anymore, couldn't find any info online, kernel.asm has nothing,

mcopy started acting out when I added something to that file, but i removed it.
Already tried deleting the output files, but same error.

在GitHub上,由于超过300行代码,我再也不能运行这个程序了,在网上找不到任何信息,kernel.asm没有任何东西,当我向该文件添加了一些东西时,mCopy开始运行,但我删除了它。已尝试删除输出文件,但出现相同错误。


更多回答

Show bootloader.asm source.

显示bootloader.asm源。

Replace jmp setup by jmp strict short setup followed by nop

将JMP设置替换为JMP Strong Short Setup,然后是NOP

Because there are 3 bytes that are needed before the data in the BPB. Your current jump is 2 bytes long, the nop is a 3rd byte to ensure the BPB is in the right place. Adding the nop shouldn't change the size of your bootloader.

因为在BPB中的数据之前需要3个字节。您当前的跳转长度为2个字节,NOP为3个字节,以确保BPB位于正确的位置。添加NOP不应该改变引导加载程序的大小。

The BPB contents must start at offset 11, and the OEM ID at offset 3. Otherwise the superblock structure doesn't match what everyone else expects. If you have no space for this single added byte you will have to re-order or optimise something. For instance, replace mov ax, 0 by xor ax, ax. And mov si, ferror_kernel_jump_failed is never reached so you can just drop this part.

BPB内容必须从偏移量11开始,OEM ID必须从偏移量3开始。否则,超级块结构与其他所有人的预期不符。如果没有空间容纳这个单独添加的字节,您将不得不重新排序或优化某些内容。例如,将mov ax,0替换为xor ax,ax。而mov si,FERROR_KERRINE_JUMP_FAILED永远不会到达,因此您可以直接删除此部分。

When you do int 13h in disk_read you do a pusha to save all the registers before int 13h and if there is no disk error you don't do a corresponding popa. Your popa should be done right after int 13h not further down before the call disk_reset. As a result if the disk read was successful the stack is unbalanced when the ret is done and it goes off into memory executing memory you didn't intend.

当您在DISK_READ中执行int13h时,您在int13h之前执行了一次Pusha以保存所有寄存器,如果没有磁盘错误,则不会执行相应的POPA。您的POPA应该在int 13小时之后完成,而不是在调用DISK_RESET之前再往下。因此,如果磁盘读取成功,则当ret完成时,堆栈就会不平衡,它会进入内存,执行您不想要的内存。

优秀答案推荐

Replaced jmp start to jmp strict short start and added nop after that.
the BIOS expects 3 bytes before the header, and those operations are 3 bytes.

I was able to get more space by adding a call to talk inside the fatal_reboot, label, since every reference ran talk before fatal_reboot.

Thanks @ecm.

将jmp start替换为jmp strict short start,并在此之后添加nop。BIOS期望在报头之前有3个字节,并且那些操作是3个字节。我可以通过在fatal_reboot,label中添加一个talk调用来获得更多的空间,因为每个引用都在fatal_reboot之前运行talk。谢谢@ecm。


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com