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

Update SYS to support ECMs single-file EDR and MS-DOS kernels #57

Closed
boeckmann opened this issue May 19, 2024 · 64 comments
Closed

Update SYS to support ECMs single-file EDR and MS-DOS kernels #57

boeckmann opened this issue May 19, 2024 · 64 comments
Assignees
Labels
enhancement New feature or request

Comments

@boeckmann
Copy link
Collaborator

Initial commit is https://github.com/boeckmann/kernel/commit/ee8c71e74be93d9beda0c4f31cb65539c2c06d59

EDR specifics were thrown out, because it works perfectly fine on a recent Enhanced DR-DOS system without it. Support and new OEM options for ECMs kernels were added.

The old Enhanced DR DOS Kernels released before 2023 are treated like the Digital Research DR DOS 5+ ones (IBMBIO.SYS, IBMDOS.SYS). Support for these is only compiled in if WITHOEMCOMPATBS is defined.

If compiled via default options SYS now supports FreeDOS kernel, the different recend EDR kernels and ECMs single-file MS-DOS kernels (untested)

@boeckmann boeckmann added the enhancement New feature or request label May 19, 2024
@boeckmann boeckmann self-assigned this May 19, 2024
@ecm-pushbx
Copy link

The help line /OEM:LMSPACK OSS MS-DOS (LMSPACK.SYS, lDOS) seems to be missing "drload" after "lDOS". Same for the status display "OSS MS-DOS mode (LMSPACK.SYS, lDOS)\n".

Also, "Enhanced DR-DOS (before 2023) mode" is a little confusing. This seems to be for the FreeDOS style (not OEM) loader but with IBM names. EDR-DOS has been using its own names for longer than 2023 though. I don't know exactly how the original OpenDOS release loaded, I'd have to study it. But some time between then and the latest (2011) original EDR-DOS it switched to its own names, which also avoided clashing the filenames with the MSDOS6 style of IBMDOS load.

@ecm-pushbx
Copy link

The old Enhanced DR DOS Kernels released before 2023 are treated like the Digital Research DR DOS 5+ ones (IBMBIO.SYS, IBMDOS.SYS). Support for these is only compiled in if WITHOEMCOMPATBS is defined.

You're mistaken in your message here. IBM names are always with .COM extensions (despite often not being valid DOS applications). Also, the WITHOEMCOMPATBS option used to indicate that the OEM loaders for FAT12/FAT16 should be included but your "old DR-DOS" option still uses the FreeDOS loaders.

@boeckmann
Copy link
Collaborator Author

I had a look at your archived versions. It seems the names changed with version 7.01.7. Was not sure if you call it drload for the MS-DOS kernels, so I left that out. I will change it accordingly.

@ecm-pushbx
Copy link

I had a look at your archived versions. It seems the names changed with version 7.01.7.

Yeah, and like I wrote not sure what load was used by prior EDR-DOS or the OpenDOS 7.01 releases.

Was not sure if you call it drload for the MS-DOS kernels, so I left that out. I will change it accordingly.

Yes, for now MS-DOS and EDR-DOS use the exact same set of stages: drload or "lDOS iniload (with second payload .exe image)", optional checkpl, optional inicomp, drkernpl, and the latter contains msbio/drbio plus msdos/drdos as payloads.

@boeckmann
Copy link
Collaborator Author

I will work through the available (E)DR kernels and try to get everything to boot :)

@boeckmann
Copy link
Collaborator Author

Ok, that turned out to be worse than expected :/. OEMBOOT hangs after outputting two dots (reading two sectors?!?). Have to investigate what is going on...

@ecm-pushbx
Copy link

What debugger are you using?

@boeckmann
Copy link
Collaborator Author

For the boot sector? Until now, my brain :D If I have to debug the OEMBOOT seriously I'll probably try doing it with lDebug if I can not detect obvious flaws by myself.

I start to wonder if all the OEMBOOT stuff SYS provides ever worked. I see no adaption of OEMBOOT to the different kernels by SYS. Instead there are ifdefs in the OEMBOOT source, leading to hardcoded kernel names (from the view of SYS).

@ecm-pushbx
Copy link

In your last commit the "DR DOS 5" mode is actually redundant with the PC-DOS mode. https://github.com/boeckmann/kernel/commit/315d6968206c5fc08cd4b907155014731e728886

@ecm-pushbx
Copy link

For the boot sector? Until now, my brain :D If I have to debug the OEMBOOT seriously I'll probably try doing it with lDebug if I can not detect obvious flaws by myself.

Yes, that's advisable.

I start to wonder if all the OEMBOOT stuff SYS provides ever worked. I see no adaption of OEMBOOT to the different kernels by SYS. Instead there are ifdefs in the OEMBOOT source, leading to hardcoded kernel names (from the view of SYS).

The first kernel file's name is at the same magic offset in the sector as for the FreeDOS loaders: https://github.com/FDOS/kernel/blob/1ce349ef26e4dff322a2a9d67af4c34fe63c28d9/boot/oemboot.asm#L668

The load segment is assumed to be 70h, the offset to jump to is another magic offset: https://github.com/FDOS/kernel/blob/1ce349ef26e4dff322a2a9d67af4c34fe63c28d9/boot/oemboot.asm#L476

The root directory entries of IO/IBMBIO and MSDOS/IBMDOS are assumed to be consecutive and are copied to linear 00500h: https://github.com/FDOS/kernel/blob/1ce349ef26e4dff322a2a9d67af4c34fe63c28d9/boot/oemboot.asm#L370

From what I recall it works, except for not providing the original int 1Eh address in either of the expected ways. And being more fragile about the directory entries. (The original MS-DOS loaders also require the directory entries to be consecutive and may even require them to be the first two directory entries. But they check that this is true rather than just assuming.)

@ecm-pushbx
Copy link

Here's where SYS patches the (first) filename: https://github.com/FDOS/kernel/blob/1ce349ef26e4dff322a2a9d67af4c34fe63c28d9/sys/sys.c#L1765

This does work for the OEM loader too.

@boeckmann
Copy link
Collaborator Author

Ok so it's adapted like for the FreeDOS loaders. I tried it on a freshly formatted 500 MB partition. I'll try if the FAT12 version boots.

In your last commit the "DR DOS 5" mode is actually redundant with the PC-DOS mode. boeckmann/kernel@315d696

That's right and will probably be eliminated when I am thorugh testing the different DR kernels, after I got OEMBOOT to work.

@ecm-pushbx
Copy link

Ok so it's adapted like for the FreeDOS loaders. I tried it on a freshly formatted 500 MB partition. I'll try if the FAT12 version boots.

In your last commit the "DR DOS 5" mode is actually redundant with the PC-DOS mode. boeckmann/kernel@315d696

That's right and will probably be eliminated when I am thorugh testing the different DR kernels, after I got OEMBOOT to work.

The help is still missing "drload" for LMSPACK.

Other than that I tested running my MS-DOS fork both with /OEM:LMSPACK and /OEM:LMS and they both work. On a file system with 128 KiB/cluster the loader only emits three dots, one each for loading (the whole) root directory and FAT and one for the first cluster of the file.

@boeckmann
Copy link
Collaborator Author

OEMBOOT FAT-12 works fine with DR-DOS 5 and PC-DOS 6.1. Interestingly it does not work with PC-DOS 2000.

@boeckmann
Copy link
Collaborator Author

Novell DOS 7 works fine. Caldera DR-DOS 7.03 fails to load IBMDOS.COM after IBMBIO.COM has initialized fine.

@ecm-pushbx
Copy link

OEMBOOT FAT-12 works fine with DR-DOS 5 and PC-DOS 6.1. Interestingly it does not work with PC-DOS 2000.

Do those work with lDebug's boot protocol ibmdos then q?

@boeckmann
Copy link
Collaborator Author

Do those work with lDebug's boot protocol ibmdos then q?

This is what I tested: I installed lDebug via INSTSECT onto a floppy. After booting from floppy, at lDebug prompt I entered your commands. That is the right way to do it? After entering the boot protocol line it takes some time. Then at least for Novell DOS 7 system hangs after entering "q". But I'll try the other ones.

@boeckmann
Copy link
Collaborator Author

boeckmann commented May 19, 2024

IBM PC-DOS 6.1 and 2000 both work.

@boeckmann
Copy link
Collaborator Author

DR DOS 5 does not work with boot protocol ibmdos.

@boeckmann
Copy link
Collaborator Author

Same effect as with Novell DOS 7. System is inresponsive and nothing is displayed.

@ecm-pushbx
Copy link

Do those work with lDebug's boot protocol ibmdos then q?

This is what I tested: I installed lDebug via INSTSECT onto a floppy. After booting from floppy, at lDebug prompt I entered your commands. That is the right way to do it?

Yes, if the files are stored on the same file system that lDebug loaded from (ldp). If they're on another file system you can use eg boot protocol ibmdos hda1

After entering the boot protocol line it takes some time. Then at least for Novell DOS 7 system hangs after entering "q". But I'll try the other ones.

How large is ibmbio.com for the cases that don't work?

You can try boot protocol ibmdos maxpara=0 to load more of the first kernel file, though there seems to be a < 26 KiB limit with that command that I don't fully understand yet. Seems related to ldLoadTop as written from around here: https://hg.pushbx.org/ecm/ldebug/file/ae0fc115317e/source/boot.asm#l2027

You can try boot protocol ibmdos maxpara=-1 bpb=-1:7C00 but this one will place the BPB at another spot than expected. To allow the maximum size of a kernel loaded below 07C00h you should use the following commands:

boot protocol ibmdos maxpara=-1 bpb=-1:7C00
m ss:bp - 4 length 200 + 4 0:7C00 - 4
r ssbp = 0000_7C00
r sp = 7C00 - 4

This will overlap the trail of the BIO file with the stack and the BPB if the file is larger than fits. The plus/minus fours are to preserve the data start variable which probably isn't needed. Using these commands but with ldp/io.sys /msdos.sys trailing in the boot command I can load a (non lDOS single-file load) MS-DOS kernel.

@boeckmann
Copy link
Collaborator Author

Caldera OpenDOS 7.01 works with the NON-OEM boot sector. DR-DOS 7.03 does not find its IBMDOS.COM.

@boeckmann
Copy link
Collaborator Author

DR DOS 5 IBMBIO.COM is reasonably small with around 17K. But both DR DOS 5 and Novell DOS 7 are working now from lDebug with the maxpara=0 argument.

@boeckmann
Copy link
Collaborator Author

Well, Novell hangs after displaying "Starting DOS..." I was too fast... Its size is 27K!

@boeckmann
Copy link
Collaborator Author

Novell 7 works with

boot protocol ibmdos maxpara=-1 bpb=-1:7C00
m ss:bp - 4 length 200 + 4 0:7C00 - 4
r ssbp = 0000_7C00
r sp = 7C00 - 4

@boeckmann
Copy link
Collaborator Author

boeckmann commented May 19, 2024

Conclusion: Everything works except IBM PC-DOS 2000 with SYS OEM bootloader and the DR-DOS 7.0x kernels with standard boot loader.

@boeckmann
Copy link
Collaborator Author

And there is a flaw that breaks OEMBOOT Fat-16 for me.

@ecm-pushbx
Copy link

And there is a flaw that breaks OEMBOOT Fat-16 for me.

How large is the FAT for that file system?

@boeckmann
Copy link
Collaborator Author

At least they gave it a .144 ending indicating its 1440K in size.

Nice finding. The original image runs fine in 86box. I copied the DR-DOS 7.03 files to another image for testing the OEMBOOT, which gave me the "Can't load kernel file" message. So the truncation sadly does not explain why the boot fails for me.

@boeckmann
Copy link
Collaborator Author

I meant the standard BOOT. Will have to compare what the register values are when the kernel is booted between lDebug and the BOOT.ASM.

@ecm-pushbx
Copy link

OEMBOOT (sys A: /bootonly /verbose /oem:pc) and FreeDOS/EDR-DOS BOOT (sys A: /bootonly /verbose /oem:edr /k ibmbio.com) loads DR-DOS v7.03 fine for me. Had to fix a bug in the gcc SYS though to make it work, as the int 25h handler zeroes DI in this DOS version.

ecm-pushbx added a commit to ecm-pushbx/fdkernel that referenced this issue May 19, 2024
Running on DR-DOS v7.03, the int 25h call zeroes di leading to a crash
here when di is expected to preserve the stack pointer. So push di twice
and pop it twice. The second pop always gets the saved sp, regardless of
whether int 21h or int 25h/26h are used.

Refer to SvarDOS/edrdos#57 (comment)
@ecm-pushbx
Copy link

Just for fun here's the scriptlet I created to trace into DR-DOS (from the archive.org link) while qemu did the 2880 KiB CHS geometry which made it fail:

test/20240519$ cat util.sld
install serial
r v1E = dword [0:1E]
boot protocol edrdos fda/ibmbio.com /ibmdos.com
tp aaaaaa while cs == 70
g 1070:DA
tp aaaaaaa while ! value from linear 0:1*4 length 3*4 in writing silent 1
ttest=3911
g 70:41F1
bp at 6C96:4234
g
bp at ptr ri13p

ecm-pushbx added a commit to ecm-pushbx/fdkernel that referenced this issue May 19, 2024
Running on DR-DOS v7.03, the int 25h call zeroes di leading to a crash
here when di is expected to preserve the stack pointer. So push di twice
and pop it twice. The second pop always gets the saved sp, regardless of
whether int 21h or int 25h/26h are used.

Refer to SvarDOS/edrdos#57 (comment)
@boeckmann
Copy link
Collaborator Author

Can you upload an image with your working DR 7.03? Than I can compare if it has something to do with how I created the floppy image.

@ecm-pushbx
Copy link

It's at https://pushbx.org/ecm/test/20240519/ - dr703.img is the working image. I emptied autoexec.bat because the install program didn't seem to load far enough for me to close it. I also truncated the file to exactly 1440 KiB as mentioned. The loader is replaced as for sys A: /bootonly /verbose /oem:edr /k ibmbio.com

https://pushbx.org/ecm/test/20240519/bdiff.txt has the output of bdiff -381 dr703.img DISK01.144.

PerditionC pushed a commit to FDOS/kernel that referenced this issue May 19, 2024
Running on DR-DOS v7.03, the int 25h call zeroes di leading to a crash
here when di is expected to preserve the stack pointer. So push di twice
and pop it twice. The second pop always gets the saved sp, regardless of
whether int 21h or int 25h/26h are used.

Refer to SvarDOS/edrdos#57 (comment)
@boeckmann
Copy link
Collaborator Author

Yours also does not boot in my 86box 4.1.1, emulated Super Socket 7 ASUS P5A with Pentium 90. With the happy feeling that it was not my fault, I can now go to bed :)

@boeckmann
Copy link
Collaborator Author

merged by the FreeDOS repo FDOS/kernel#160

@ecm-pushbx
Copy link

I added a "DRDOS" protocol to lDebug now. This is the same as IBMDOS except maxpara=-1 (in conjunction with a change to limit the stack below the BPB to 256 or 512 Bytes). Checked with DR-DOS v5.00, v7.00 (Novell DOS), and v7.03 (Caldera DR-DOS).

Changeset is at https://hg.pushbx.org/ecm/ldebug/rev/b36cd27f8433

msg.asm: add load settings DRDOS (IBMDOS with maxpara=-1)

This should work for older DR-DOS (v5 or v6), Novell DOS v7, Caldera OpenDOS v7.01, Enhanced DR-DOS up to v7.01.06, and Caldera DR-DOS v7.03. It requires that the BIO file is no larger than 29696 Bytes (29 KiB).

I checked the files in https://pushbx.org/ecm/download/edrdos/ and (exactly) up to v7.01.06 the BIO file (IBMBIO.COM or DRBIO.SYS) is smaller than 29 KiB:

  • .01: 27848
  • .02: 28232
  • .03: 28312
  • .04: 28968
  • .05: same
  • .06: 26616
  • .07: (first DRBIO.SYS) 31915
  • .08 WIP 2011-07-21: 35556

@ecm-pushbx
Copy link

ecm-pushbx commented May 20, 2024

For the 360 KiB image of DR-DOS v5.00 qemu's BIOS incorrectly reported 15 CHS Sectors on query geometry (int 13h function 08h) but the access only actually worked when calculating with 9 CHS Sectors, otherwise yielding an error 20h from int 13h. Reading the root directory worked fine because of where it is located but running boot protocol drdos fda failed with this error.

I booted lDebug off a hard disk image and then ran r bootunitfl0 or= 4 to have the debugger properly access the diskette image. This flag causes the debugger to use the CHS Heads and CHS Sectors saved in the BPB which were correct in this case.

@ecm-pushbx
Copy link

Interestingly, it appears that as late as v3.31 the MS-DOS/PC-DOS boot sector loader loaded the entire file size of the BIO file, assuming it to be completely unfragmented. This matches the expectation for the DR-DOS v5.00 to v7.03 and EDR-DOS up to v7.01.06 load protocols. But at the latest for v4.00 MS-DOS changed to load only IBMLOADSIZE equ 3 sectors from the beginning of the file, still assumed to be unfragmented. This is the stage called IBMLOAD or MSLOAD, equivalent to lDOS iniload and just like iniload it's responsible for finishing the file system booting by loading the remainder of the first (MSBIO) file then transferring control to MSBIO.

It's interesting to me they note that "Currently we estimate that IBMLOAD module will not be more than 3 sectors." This remained as is until v7.00 which changed to 4 sectors instead. There is basically no good reason they couldn't have chosen a larger number to begin with, like 4 or 6. Would have made iniload easier to write. (iniload is optimised to allow loading off of FAT12, FAT16, or FAT32, CHS or LBA, 8086-clean, from just 1536 Bytes loaded. But it is a close call.)

@ecm-pushbx
Copy link

Oh, in this revision they still assume that data start = start of the BIO file's data. Huh.

@boeckmann
Copy link
Collaborator Author

Interesting. In which file is this "IBMLOAD" implemented? Is it part of the BIOS itself or is it combined with the BIOS while building? I yesterday had a quick look at the PTS-DOS 6.51 volume boot code, to see if SYS eventually can support it. This thing has a DOS4 BPB. Not something you see that often. Will have another look at it when I have more time...

@ecm-pushbx
Copy link

Interesting. In which file is this "IBMLOAD" implemented? Is it part of the BIOS itself or is it combined with the BIOS while building?

They were combined using copy /b as seen in the changeset where I switched to the single-file load. The stage is called the "Non-Contiguous IBMBIO Loader (MSLOAD)" and you can see some more of it in the changeset where I dropped it.

Originally MSLOAD wasn't even aligned to end on a word or paragraph boundary, so MSBIO (the next stage) could even be stored on an odd address in the file.

MSBIO is also loaded to address 00700h and entered at 70h:0. Likely it used to be the stage that was directly loaded by the boot sector loader. The protocol is documented in another part I updated.

I yesterday had a quick look at the PTS-DOS 6.51 volume boot code, to see if SYS eventually can support it. This thing has a DOS4 BPB. Not something you see that often. Will have another look at it when I have more time...

What do you mean by "DOS4 BPB"?

@ecm-pushbx
Copy link

I added an option that allows to shrink the stack size used by the lDOS boot sector loaders: https://hg.pushbx.org/ecm/ldosboot/rev/428ce9f88237

Setting _LOAD_STACK to 256 (or smaller) is required to gain the full 29 KiB usable space for the load file loaded to linear 00700h (7C00h - 100h - 700h = 7400h = 7 * 4 KiB + 1 KiB = 29 KiB). I'd have to enumerate the largest DR-DOS BIO file we've seen, if it really needs 29 KiB or if 28.5 KiB (which is still > 29 kB) is enough.

There is a problem with large cluster sizes though; the lDOS boot sector loaders detect EOF purely from having finished loading the entire last cluster. So you'd have to enable _MEMORY_CONTINUE to have the full 29 KiB supported if the cluster size is >= 2 KiB. But that wouldn't fail correctly if the byte-granular size of the file is too large to load.

@ecm-pushbx
Copy link

boot protocol drdos fda works even if I run f 0:500 l 40 CC before running the kernel. Tested on DR-DOS v5.00, v7.00, and v7.03. So these kernels all do not use the directory entries stored there, and consequently the BIO files must include a directory scanner to find their respective DOS files.

@ecm-pushbx
Copy link

IBMBIO file sizes:

  • v5.00: 17547
  • v7.00: 27880
  • v7.03: 24810

@boeckmann
Copy link
Collaborator Author

MSBIO is also loaded to address 00700h and entered at 70h:0.

The first three sectors of PTS-DOS PTSBIO.SYS are loaded to 280:0. No clue why they choose that address. Have to find out what exactly gets passed to PTSBIO via registers (and memory), probably on weekend.

What do you mean by "DOS4 BPB"?

The FAT-16 extended BPBs established by DOS 4. But they seem rather common even on floppy disks. Was confused by the signature byte being at a different place than the FAT-32 BPBs.

@pts
Copy link

pts commented Jan 4, 2025

Where is this source code of sys.com discussed here (i.e. with the support of /OEM:LEDRPACK)? I can't find it on Google.

@boeckmann
Copy link
Collaborator Author

@ecm-pushbx
Copy link

@pts
Copy link

pts commented Jan 4, 2025

Thank you for the link. First I've found https://github.com/FDOS/sys , which is something much older.

It was also very confusing for me that I tried to find the link to the FreeDOS sources on https://freedos.org/: https://freedos.org/about/devel/ has the FreeDOS sources link point to https://gitlab.com/FreeDOS, which doesn't contain the source of sys.com. In retrospect (obviously??), I should have clicked on the Kernel sources link instead. (But for me, the kernel is kernel.sys, and sys.com isn't part of the kernel.)

@ecm-pushbx
Copy link

Thank you for the link. First I've found https://github.com/FDOS/sys , which is something much older.

It was also very confusing for me that I tried to find the link to the FreeDOS sources on https://freedos.org/: https://freedos.org/about/devel/ has the FreeDOS sources link point to https://gitlab.com/FreeDOS, which doesn't contain the source of sys.com. In retrospect (obviously??), I should have clicked on the Kernel sources link instead. (But for me, the kernel is kernel.sys, and sys.com isn't part of the kernel.)

Both sys and the boot sector loaders are part of the kernel sources, yes. I believe the country file and the sharer are included as git submodules in the kernel repo, but have their own repos that they're being maintained in. Arguably the sharer is fairly specific to the kernel so I can see why it would be linked.

I do agree that it isn't super obvious where to find things.

@andrewbird
Copy link

Yes I think we discussed making sys a submodule here FDOS/sys#3, however from what I see for sys to be buildable outside of the kernel it has to duplicate some kernel header files. That's not ideal, and to me that just feels like it's not a true standalone.

@PerditionC
Copy link

for now the sys in kernel is best place for patches, but eventually that will be a git submodule of the other. I haven't had time to update it. I may move sys development to doscore project since I want it to support multiple DOSes and not be so tied to FreeDOS

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

No branches or pull requests

5 participants