VOGONS


First post, by alexanrs

User metadata
Rank l33t
Rank
l33t

Hi everyone!
This weekend I decided to try and make a bootable floppy that loads an option ROM into the RAM. I want to do that so my XT clone won't sit semi-useless on my computing area until I sort out a way to put the XTIDE ROM properly into a mapped EEPROM/EPROM (the empty ROM socket doesn't play nice with my pin-compatible EEPROM, and seems to overlap the BIOS anyway). Then I downloaded PCEm and followed this tutorial to learn programming a floppy boot loader. I used their later example (mainly because handling FAT12 enough to locate a file in the root directory was already implemented) as a starting point and coded my modified version that does the following:

  • Saves the original SS/ES
  • As the original example, loads the FAT and the root directory to predefined segments
  • Looks for IDE_XT.BIN and loads it into a segment calculated as Max. Conventional memory in KB - IMAGE_KB)<<6, where IMAGE_KB is currently set to 12
  • Subtracts IMAGE_KB from 0000h:0413h (=40h:0013h, where the BIOS stores how much conventional memory the PC has)
  • Makes a far call to the IDE_XT segment:0003h
  • Prints a message and waits for a key
  • Restores the original SS/ES
  • Issues an int 19h (to call the bootloader)

Now, this sounds fine in theory, and it is ALMOST working in PCEm - both set as a Generic XT clone or a DTK XT clone. The option ROM loads and gets executed, and I get to XTIDE's boot screen, but it freezes while detecting IDE drives. I know the ROM itself is good (if I copy it to PCEm's ROMS folder, the system finds the virtual HDD and boots from it just fine). I've attached the screenshot to the post. If I comment out the call to int 19h, the system boots just fine to a DOS floppy and I can see the memory has been successfully "stolen" (software reports the total conventional memory as 628KB). I'm using WinImage to set the bootsector to the one I'm compiling.

I'm somewhat stumped: PCEm doesn't have any debugging capabilities and Bochs -which has a fine debugger - is mostly useless trying to emulate anything pre-Pentium. Does anyone have any ideas of what I'm doing wrong or tips of an emulator that emulates a XT-class PC as well as PCEm, but with better debugging support? I've attached the source code (NASM) of the bootsector below (for a 720KB floppy image).

EDIT: ASM not allowed - renamed to TXT

Attachments

  • Filename
    BOOT12.TXT
    File size
    14.36 KiB
    Downloads
    252 downloads
    File license
    Fair use/fair dealing exception
  • screenshot.png
    Filename
    screenshot.png
    File size
    10.9 KiB
    Views
    2036 views
    File license
    Fair use/fair dealing exception

Reply 2 of 9, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

IIRC when IDE was introduced, the primary master channel used the same ports as the old MFM/RLL interface. This would normally not be a problem, since most people (then) would be unlikely to have both controller types in the same system.

What hardware are you emulating? Is there an MFM/RLL or IDE controller in the emulated system? I'm just wondering whether the wrong controller type might confuse the XTIDE firmware. For that matter I don't even know whether XTIDE appears to the system like a "real" IDE controller, or whether it's a completely different interface, relying on the firmware to provide access to the devices. In that case it's possible the firmware would misbehave if the XTIDE hardware itself was missing.

However the fact that you've got it to come up during boot suggests that everything is working fine as far as your ROM-in-RAM method goes. I didn't know you could do that - very interesting!

On an unrelated note, I've often thought about designing an ISA card you could slot in to a PC to use as a debugger, but I didn't think there'd be much interest in it. Looks like this is one situation where it could come in handy though (assuming it doesn't work in the real PC - doesn't sound like you've tried yet?)

Reply 3 of 9, by alexanrs

User metadata
Rank l33t
Rank
l33t

PCEm, when configured as a PC/XT-class machine, presents a normal 8-bit IDE interface (I did look at its source code) at port 300h. The XT-IDE board is just that - a regular ISA IDE interface which can be configured to listen to different ports, defaulting to 300h. I know this ROM works because, if I copy the file to the "roms" subfolder, PCEm loads it as an option ROM and it boots from HDDs normally. I suspect it is a difference of context: something is different either in the IVT or registers or even memory, but I've inspected XTIDE's source code and it does zero out the memory it uses at segment 030h for its variables, and it doesn't look like it assumes anything about the registers. If only I could set a breakpoint and dump both memory and registers I might be able to tell the difference, but PCEm doesn't do that, and Bochs, which does allow that, does not emulate a pre-Pentium machine, and doesn't even execute a XT-class BIOS image without throwing errors.

What I might try doing is loading an HDD floppy option ROM and test if it works fine. But besides editing XT-IDE's code itself and dumping debug info on the screen, I'm out of ideas.

Reply 4 of 9, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Are you loading the option ROM into the same address space? It's not something like it has to be loaded at x000 rather than xD00 as in the screenshot above?

Is there any way you can skip the disk detection and finish the boot process with the ROM loaded into RAM, so you can dump the memory with debug or similar to confirm that the image is intact? You said you've done this with skipping int19, but maybe int19 changes the memory in some way?

Can you make the ROM take up more memory (say a full 64kB and put it at 9000) in case the boot process tries to write to that part of memory for some reason? (Perhaps something writes there to see if the system has 640kB RAM, instead of checking the BIOS value.)

These are just random suggestions, I don't claim to have any great insight 😀

Reply 5 of 9, by alexanrs

User metadata
Rank l33t
Rank
l33t
Malvineous wrote:
Are you loading the option ROM into the same address space? It's not something like it has to be loaded at x000 rather than xD0 […]
Show full quote

Are you loading the option ROM into the same address space? It's not something like it has to be loaded at x000 rather than xD00 as in the screenshot above?

Malvineous wrote:

Can you make the ROM take up more memory (say a full 64kB and put it at 9000) in case the boot process tries to write to that part of memory for some reason? (Perhaps something writes there to see if the system has 640kB RAM, instead of checking the BIOS value.)

I've tried several different values to no avail before even posting here, even 64kb. Makes no difference (unless I use a value that is too small, then things just go boom)

Malvineous wrote:

Is there any way you can skip the disk detection and finish the boot process with the ROM loaded into RAM, so you can dump the memory with debug or similar to confirm that the image is intact? You said you've done this with skipping int19, but maybe int19 changes the memory in some way?

Will try that, thanks for the suggestion.

Btw, I replaced XT-IDE with an HD floppy ROM, and same thing happens (freezes when trying to boot after the firmware is loaded).

Reply 6 of 9, by Stiletto

User metadata
Rank l33t++
Rank
l33t++

You could try it in MAME (which merged with MESS), which has an awesome debugger, and I've heard the pre-386 system support is pretty good. 😀

"I see a little silhouette-o of a man, Scaramouche, Scaramouche, will you
do the Fandango!" - Queen

Stiletto

Reply 7 of 9, by alexanrs

User metadata
Rank l33t
Rank
l33t

Color me impressed... it actually boots fine on my XT clone. Only god knows what went wrong on PCEm. Well, I stil have to see if it is working 100%. FDISK from Compaq DOS 3.31 is taking its sweet time... It is on the screen to create a primary partition, and already returned that the total disk space is 1023 cilinders.... but it is reading this old 700MB HDD like crazy as if it were trying to read something else. Is it normal for it to take so long? If this goes on long enough I might try MS-DOS 6.22.

Reply 8 of 9, by alexanrs

User metadata
Rank l33t
Rank
l33t

IT LIVES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
My 700MB HDD doesn't play nice with my 16-bit multi-IO card (probably doesn't support 8-bit mode), but my CF card boots fine! I did not even format it, I just plugged it in and the existing MS-DOS 6.22 install booted fine! Sure, I'll have to sort this out since 12KB of RAM is nothing to be sneezed at when your machine has only got 512, but alas! It works!!!!!
I'll update the first post when I get around to properly commenting my modifications to the original version. As situational as this might be, I'm proud of this little 1KB binary fine. By the end of the day I feel I learned a few more things about PCs, and that is fine by me.

Btw, what DOS version do you guys feel is best for a XT-class machine. It will soon have the full 640KB, but unless I get around to adding UMBs to this machine, would DOS 3.3 be better than 6.22 due to lower memory usage? Its default shell is garbage, but 4DOS runs fine on anything above 2.0.

Reply 9 of 9, by Alex_C

User metadata
Rank Newbie
Rank
Newbie

I just wanted to say thanks for this. I'd been trying to do something similar when I found your post. I've created a step-by-step guide in this thread on the VCFed site: http://www.vcfed.org/forum/showthread.php?525 … nstead-of-EPROM