Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: add missed diskette geometry parsing #1312

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

ecm-pushbx
Copy link
Contributor

This was dropped in a6144ab
but should be preserved to allow specifying custom geometry.

Tested compilation and running the resulting dosemu2. No tests done on whether geometry is properly accepted.

Old dosemu references list these geometry specifiers, eg https://www.linuxjournal.com/article/1070 here:

floppy { heads 2 sectors 18 tracks 80 threeinch file /var/lib/dosemu/floppy }

This was dropped in a6144ab
but should be preserved to allow specifying custom geometry.
@ecm-pushbx
Copy link
Contributor Author

Needs more work. dosemu appears to override the manually entered geometry.

@ecm-pushbx
Copy link
Contributor Author

Test case, using:

$ (cd ../ldosboot; nasm boot.asm -I ../lmacros/ -D_USE_PART_INFO=0 -D_QUERY_GEOMETRY=1 -D_LBA=0 -D_LOAD_NAME="'LDEBUGU'" -D_FAT16=0 -D_MAP=boot12u.map -l boot12u.lst -o boot12u.bin) && nasm bootimg.asm -I ../lmacros/ -I ../ldosboot/ -o bootimgu.img -l bootimgu.lst -D_PAYLOADFILE="'../lDebug/build/bin/ldebugu.com'" -D_BOOTFILE="'boot12u.bin'" && dosemu -I "floppy { cylinders 80 heads 4 sectors 9 device bootimgu.img }" -A -dumb
boot.asm:1600: warning: FAT12: 77 bytes still available. [-w+user]
dosemu2 2.0pre8-20201012-2402-gd7c9be2c8 Configured: 2020-10-13 15:14:45 +0200
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/dosemu2/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, GPL v2 (or any later version) distribution conditions.


-boot
-p
AX=0000 BX=0000 CX=0000 DX=0000 SP=7C00 BP=07BE SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C49 NV UP DI PL ZR NA PE NC
0000:7C49 FA                cli
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7C00 BP=07BE SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C4A NV UP DI PL ZR NA PE NC
0000:7C4A FC                cld
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7C00 BP=07BE SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C4B NV UP DI PL ZR NA PE NC
0000:7C4B 31C9              xor     cx, cx
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7C00 BP=07BE SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C4D NV UP DI PL ZR NA PE NC
0000:7C4D BD007C            mov     bp, 7C00
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7C00 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C50 NV UP DI PL ZR NA PE NC
0000:7C50 8ED1              mov     ss, cx
0000:7C52 BCF07B            mov     sp, 7BF0
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C55 NV UP DI PL ZR NA PE NC
0000:7C55 885624            mov     [bp+24], dl                      SS:7C24=00
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C58 NV UP DI PL ZR NA PE NC
0000:7C58 8ED9              mov     ds, cx
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C5A NV UP DI PL ZR NA PE NC
0000:7C5A FB                sti
0000:7C5B B408              mov     ah, 08
-
AX=0000 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C5B NV UP EI PL ZR NA PE NC
0000:7C5B B408              mov     ah, 08
-
AX=0800 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C5D NV UP EI PL ZR NA PE NC
0000:7C5D F9                stc
-
AX=0800 BX=0000 CX=0000 DX=0000 SP=7BF0 BP=7C00 SI=07BE DI=0000
DS=0000 ES=0060 SS=0000 CS=0000 IP=7C5E NV UP EI PL ZR NA PE CY
0000:7C5E CD13              int     13
-
AX=0000 BX=0004 CX=4F12 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C60 NV UP EI PL ZR NA PE NC
0000:7C60 720E              jb      7C70                            not jumping
-
AX=0000 BX=0004 CX=4F12 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C62 NV UP EI PL ZR NA PE NC
0000:7C62 83E13F            and     cx, +3F
-
AX=0000 BX=0004 CX=0012 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C65 NV UP EI PL NZ NA PE NC
0000:7C65 7409              jz      7C70                            not jumping
-
AX=0000 BX=0004 CX=0012 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C67 NV UP EI PL NZ NA PE NC
0000:7C67 894E18            mov     [bp+18], cx                    SS:7C18=0012
-h cx
0012  decimal: 18
-p
AX=0000 BX=0004 CX=0012 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C6A NV UP EI PL NZ NA PE NC
0000:7C6A 88F1              mov     cl, dh
-
AX=0000 BX=0004 CX=0001 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C6C NV UP EI PL NZ NA PE NC
0000:7C6C 41                inc     cx
-
AX=0000 BX=0004 CX=0002 DX=0101 SP=7BF0 BP=7C00 SI=07BE DI=6FC7
DS=0000 ES=F800 SS=0000 CS=0000 IP=7C6D NV UP EI PL NZ NA PO NC
0000:7C6D 894E1A            mov     [bp+1A], cx                    SS:7C1A=0002
-h cx
0002  decimal: 2
-boot quit
$ 

Here we can find that dosemu still reports the boot diskette as sectors 18, heads 2. (Cylinders 80 is implied by the 18 sectors and 2 heads and 2880 total sectors.)

This passes all the literal values specified by using the
cylinders, heads, sectors keywords. Probably requires all
of the parameters to be set to work properly.
@ecm-pushbx
Copy link
Contributor Author

I found a way to fix it so dosemu will not select any other geometry. It is rather much of a hack though. Please review and suggest how to improve this.

@ecm-pushbx
Copy link
Contributor Author

ecm-pushbx commented Oct 13, 2020

Actual use case: I'm testing bootimg's FAT32 support by formatting a "super floppy" (unpartitioned medium with a single file system). It needs to be about 34 MiB at least, with 512 bytes per sector, to make all FAT32 detections succeed (needs > 64 Ki clusters). FreeDOS and dosemu seem not to like it when the diskette image exceeds a certain size. By forcefully specifying C, H, S geometry with this patch both FreeDOS and dosemu are happy about the large image and all the disk accesses work.

@@ -510,7 +510,8 @@ static void image_auto(struct disk *dp)
leavedos(19);
return;
}
if (!(set_floppy_chs_by_size(st.st_size, dp) ||
if (!(dp->default_cmos == CUSTOM_DISKETTE ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just check above (at line 499)
that chs already set (all values != 0)
and then return immediately?
Looks much simpler than adding another
keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want the dp->num_secs = line that comes later, to calculate the total (CHS-addressable) size though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So would you like to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will get around to it eventually. Still considering how to fix the HD image geometry specifiers too. They're also broken. For example, if we set cylinders X heads Y sectors Z (all specified) then in disk_reset2 the conditional is not taken, and thus num_secs is never initialised (stays zero) which makes read_sectors fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants