Skip to content

Improve IDE Controller - #1325

Closed
chschnell wants to merge 53 commits into
copy:masterfrom
chschnell:fix-cdrom-hda-boot
Closed

Improve IDE Controller#1325
chschnell wants to merge 53 commits into
copy:masterfrom
chschnell:fix-cdrom-hda-boot

Conversation

@chschnell

@chschnell chschnell commented May 10, 2025

Copy link
Copy Markdown
Contributor

This PR improves on PR #901 "Fix booting from cd while hda present, booting from hda while cd present", please see my comment there and also issue #1323 "ATA/ATAPI PCI adapter" for more details if you like.

SeaBIOS now properly boots with both a HDA and a CD-ROM device configured, the CD-ROM may or may not be empty. Tested under FreeDOS 1.3, FreeDOS 1.4, Debian 12, FreeBSD 12, Windows 3.1, Windows 95, Syllable-0.6.7-1 and more. A CD-ROM disk can be inserted after booting with an empty CD drive, and ejecting a disk mostly works.

Boch's BIOS shows the same problems with or without this PR, when booting FreeDOS fails to find or activate the NE2K network card, and Debian fails to find any IDE drive (neither HDA nor CD-ROM). However, it does boot with this dual IDE configuration (HD and CD) which it doesn't without this PR.

Technically, this implementation should support any combination of up to 4 ATA-HDD and/or ATAPI-CD-ROM devices (tested with three devices hda, hdb and cdrom), though this would cause some serious headache in the web UI setup.

Major fixes and improvements in this PR:

  • fixed PCI device layout of the IDE controller
  • fixed ATAPI responses for ejected media
  • added several ATA/ATAPI commands
  • improved ATA responses for missing IDE slave devices
  • improved code readabilty with named constants
  • improved debug log output

This code attempts to implement a sufficient subset of the latest revisions of the IDE-related standards (that is: ATA/ATAPI-8 and MMC-3). However, some deprecated commands from older revisions are also supported for guest OSes that make still use of them.

References that this IDE code is based on:

Other related reading material:

chschnell added 13 commits May 3, 2025 16:26
Merged all functionally relevant changes, omitted:

1. Left out almost all of the "dbg_log()" changes, they're like 90% of the original PR and make the essential changes in the diffs a bit hard to read, these can be added back in at a later point in time.
2. Also left out the "wants_cdrom" option and implemented its desired effect with "cdrom: { ejected: true }" as was suggested.
3. The test "tests/api/cdrom-insert-eject.js" is also left out, can be added later back in.

This patch should behave like the last changeset from JoeOsborn in 2023.
Implement a single PCI IDE device in Compatibility Mode for up to 4 drives.

Changes to ide.js:
- added new exported class IDEPCIAdapter, the root class for up to 4 drives
- introduced new config scheme for IDEPCIAdapter (see comment about adapter_config)
- moved PCI-device related members from IDEDevice to IDEPCIAdapter
- rewrote constructor of IDEDevice (no longer exported)
- fixed (?) write-access to ata_port registers 1-6 (see comment below)
- added missing declarations for BAR2 and BAR3 in pci_bars[]
- made definition of the PCI configuration space a bit more more verbose
- renamed "master_port" to "bus_master_port" to avoid confusion
- added a few comments here and there

Regarding write-access to ata_port registers 1-6: It is not clear why these 6
functions simultaneously modify master and slave attributes instead of just
modifying this.current_interface (as is the case everywhere else in the code).
This patch changes that to use this.current_interface, experimental until
there is some explanation.

Also changed cpu.js to now use IDEPCIAdapter instead of IDEDevice.

TODO:
1. clear up the matter around write-access to ata_port registers 1-6
2. in ide.js, a single-device channel needs to be better supported, currently
   the code reports a Hard-Disk device of size 0 for an unconnected slave drive,
   and there must be a better way to signal this case.
3. in cpu.js, this.devices.hda and this.devices.cdrom point to a IDEDevice, they
   should point to an IDEInterface for this.devices.hdb to make sense. This needs
   to be better understood and fixed for slave drives to work.
4. getting some very early output under SeaBIOS, but the screen clears so quickly
   that I cannot read it and it's also not printed to the serial console
…ased access to IDEDevice and IDEInterface objects
- immplemented Command and Status register requirements from the standard, ignored all others
- rearranged IDE register definitions, added a descriptive comment to each (standard lingo)
- fixed the EXECUTE DEVICE DIAGNOSTIC (90h) ATA command
In v86, the name "device" is already used in the context of PCI, and additionally, in the ATA/ATAPI standard the term "device" is used for disk drives.

The name used for this entity (IDEDevice) in the ATA/ATAPI standard is "channel", and since "channel" is not otherwise used in ide.js it seems right to rename IDEDevice to IDEChannel.
Merged and improved on the work from JoeOsborn in respect to formatting in dbg_log() output.
Used register names from the standard for better readability of the output, and added a few missing logs.
@chschnell

chschnell commented May 12, 2025

Copy link
Copy Markdown
Contributor Author

@copy, in order to continue comparing the code in ide.js with the ATA/ATAPI-6 standard I'd really like to rename a couple of members in class IDEInterface.

I'd like to align the standard ATA register names with their corresponding member variables.

Here the related names, (a) as in the ATA/ATAPI-6 standard, (b) as they currently are in IDEInterface, and (c) what I'd suggest instead:

Standard (a)   | Current (b)    | Suggested (c)
---------------+----------------+--------------------
Sector Count   | bytecount      | sector_count_reg
LBA Low        | sector         | lba_low_reg
LBA Mid        | cylinder_low   | lba_mid_reg
LBA High       | cylinder_high  | lba_high_reg
Device         | drive_head     | device_reg
Device Control | device_control | device_control_reg
Features       | lba_count      | features_reg

Before doing so I'd like to ask if that's ok with you, maybe there are good reasons for the member names as they are that I just don't know about.

I will also start to replace some of the many hard-coded literal register assignments with named constants. Too many magic numbers.

Renamed members that carry register values to better align with the actual wording in the ATA/ATAPI-6 standard.

Other changes in this commit include:

- added a bunch of named constants for ATA registers and their bits
- improved PCI configuration space setup
- renamed class IDEPCIAdapter to IDEController
@chschnell

chschnell commented May 13, 2025

Copy link
Copy Markdown
Contributor Author

Aside of lots of code cleanup, there are two issues left that will need some more time.

  1. Eject/insert CD mechanics
  2. The single-device case

Other than that, it works very well. Example: A few weeks ago, FreeDOS 1.4 was released, and I could not create an installation from their live CD onto a hard-disk under v86. With this PR, it works perfectly smooth and is a real joy.

Both issues are not critical, but I find them serious enough to continue working on them.

Regarding the first issue, currently you can boot with or without a CD inserted, and you can insert a CD later, works fine. However, you cannot eject it, and you cannot replace it, once you've inserted a CD that's it until you restart the VM. I have to learn about these mechanics in ATAPI, that means in SCSI, and that will need a bit of time.

The second issue is about configurations where only a single disk (instead of two) is connected to a channel (IDE controllers support two channels for a total of 4 disks). Physically, a Y-shaped cable was connected to an IDE channel and two disks could be connected to that cable, and disks had jumpers which had to be configured mutually exclusive to tell them apart (they were called "master" and "slave" disks, back in the days).

Now, the ATA/ATAPI-6 standard says that in this case, the master disk is supposed to answer as a proxy for requests aimed at the slave disk in case it doesn't exist, with very special rules. I'm still working on the meaning of this, I've implemented it but it fatally breaks Boch's ATAPI detection, but that might be due to ATAPI bugs in v86. I removed that implementation for now, but kept it for a future point in time.

I suppose this was specified this way to distinguish the single-disk case from the no-disk case.

I think the next thing to do is to get a better understanding of ATAPI, and specifically SCSI.

Does anyone happen to have any tips for reading material about SCSI?

@chschnell chschnell changed the title Improve IDE PCI Adapter Improve IDE Controller May 14, 2025
@chschnell

chschnell commented May 15, 2025

Copy link
Copy Markdown
Contributor Author

I'm pretty sure now that the subset of SCSI commands used with ATAPI in v86 is specified in SCSI Multimedia Commands – 3 (MMC-3), on the surface it matches the code in v86 (the implemented command set is documented in the standard). Its release date also almost matches the one of the ATA/ATAPI-6 standard.

There is another symptom which still exists since JoeOsborn's original PR, when running hwinfo --cdrom under Linux with ejected Compact Disk I get:

Details
root@debian-iscsi:~# hwinfo --cdrom
> block.5.1: /dev/sr0 cache[   78.371349] I/O error, dev sr0, sector 64 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
[   78.412349] I/O error, dev sr0, sector 64 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
[   78.412349] Buffer I/O error on dev sr0, logical block 16, async page read
[   78.448365] I/O error, dev sr0, sector 68 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
[   78.448369] Buffer I/O error on dev sr0, logical block 17, async page read 08: SCSI 100.0: 10602 CD-ROM

whereas hwinfo --disk runs without errors. While --cdrom uses the ATAPI interface, --disk uses ATA.
EDIT: this issue is fixed

So I'll focus on ATAPI now.

chschnell added 7 commits May 15, 2025 20:19
In the original code, status register bit DSC (Drive Seek Complete, 0x10) is always set when completing without error, but ATA/ATAPI-6 specifies this bit to be command dependent. This PR now sets the status register exactly like it was before, just using named constants instead of magic numbers.

Also replaced most of the remaining magic number assignments to the ATA status register.
In the context of ATAPI there's only a single linked document in ide.js: https://www.t10.org/ftp/x3t9.2/document.87/87-106r0.txt.

This link points to "PROPOSAL FOR CD-ROM IN SCSI-2" from 1987 (!) and its content matches the current code in v86, which the SCSI-3 documents did not at all (only the command codes matched, but otherwise SCSI-3 is very different from SCSI-2).
The SCSI Status field ("Status Key" and "Additional Status Code" aka. ASC) was incorrectly passed from the SCSI layer to the ATA register layer, and ATAPI command "TEST UNIT READY" was not implemented correctly.

This led to Linux not properly detecting when no CD was inserted into the CD-ROM device, which led to error output in "hwinfo" like (it attempted to read a disk that's no inserted):

> root@debian-iscsi:~# hwinfo --cdrom
> > block.5.1: /dev/sr0 cache[   78.371349] I/O error, dev sr0, sector 64 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
> [   78.412349] I/O error, dev sr0, sector 64 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
> [   78.412349] Buffer I/O error on dev sr0, logical block 16, async page read
> [   78.448365] I/O error, dev sr0, sector 68 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
> [   78.448369] Buffer I/O error on dev sr0, logical block 17, async page read 08: SCSI 100.0: 10602 CD-ROM

This commit fixes that problem by now properly returning SCSI Sense and Additional Sense responses to the ATAPI host.
@chschnell

chschnell commented May 18, 2025

Copy link
Copy Markdown
Contributor Author

Understood and fixed a rather important bug that sat between the ATA/ATAPI and the SCSI layer.

This fix makes the CD-ROM device to work without errors under Linux now!

Debian bash log about CD-ROM with comments
# NOTE: booted with ejected CD-ROM disk

Debian GNU/Linux 12 debian-iscsi tty1

debian-iscsi login: root
Password:

# run hwinfo. NOTE: no more errors with "hwinfo" as before here, and see "Drive status"

root@debian-iscsi:~# hwinfo --cdrom
08: SCSI 100.0: 10602 CD-ROM
  [Created at block.259]
  Unique ID: KD9E.cJjDrst78LF
  Parent ID: BUZT.bgG9RSCjJU8
  SysFS ID: /class/block/sr0
  SysFS BusID: 1:0:0:0
  SysFS Device Link: /devices/pci0000:00/0000:00:1f.0/ata2/host1/target1:0:0/1:0:0:0
  Hardware Class: cdrom
  Model: "SONY CD-ROM CDU-1000"
  Vendor: "SONY"
  Device: "CD-ROM CDU-1000"
  Revision: "1.1a"
  Driver: "ata_piix", "sr"
  Driver Modules: "ata_piix", "sr_mod"
  Device File: /dev/sr0 (/dev/sg1)
  Device Files: /dev/sr0, /dev/disk/by-path/pci-0000:00:1f.0-ata-2, /dev/cdrom,/dev/disk/by-path/pci-0000:00:1f.0-ata-2.0, /dev/disk/by-diskseq/2
  Device Number: block 11:0 (char 21:1)
  Drive status: no medium
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #4 (IDE interface)
  Drive Speed: 1

# attempt to mount CD-ROM with still ejected disk (NOTE: error message is correct)

root@debian-iscsi:~# mount -t iso9660 -o ro /dev/sr0 /mnt/
mount: /mnt: no medium found on /dev/sr0.
       dmesg(1) may have more information after failed mount system call.

# [external: load image "FD14LIVE.iso" into v86 cdrom device via v86 API]

root@debian-iscsi:~# mount -t iso9660 -o ro /dev/sr0 /mnt/
root@debian-iscsi:~# ls /mnt/
CHANGES.LOG  devel       fdconfig.sys  freedos  isolinux    net       setup.bat
COMMAND.COM  fdauto.bat  FDOS-x86      games    KERNEL.SYS  packages

# ok, unmount CD-ROM

root@debian-iscsi:~# umount /mnt

# [external: unload image from v86 cdrom device via v86 API]

# attempt to mount CD-ROM with ejected disk to check the disk is really gone

root@debian-iscsi:~# mount -t iso9660 -o ro /dev/sr0 /mnt/
mount: /mnt: no medium found on /dev/sr0.
       dmesg(1) may have more information after failed mount system call.

# [external: load image "dsl-4.11.rc2.iso" into v86 cdrom device via v86 API]

root@debian-iscsi:~# mount -t iso9660 -o ro /dev/sr0 /mnt
root@debian-iscsi:~# ls /mnt/
boot  index.html  KNOPPIX

# run hwinfo with inserted disk

root@debian-iscsi:~# hwinfo --cdrom
08: SCSI 100.0: 10602 CD-ROM
  [Created at block.259]
  Unique ID: KD9E.cJjDrst78LF
  Parent ID: BUZT.bgG9RSCjJU8
  SysFS ID: /class/block/sr0
  SysFS BusID: 1:0:0:0
  SysFS Device Link: /devices/pci0000:00/0000:00:1f.0/ata2/host1/target1:0:0/1:0:0:0
  Hardware Class: cdrom
  Model: "SONY CD-ROM CDU-1000"
  Vendor: "SONY"
  Device: "CD-ROM CDU-1000"
  Revision: "1.1a"
  Driver: "ata_piix", "sr"
  Driver Modules: "ata_piix", "sr_mod"
  Device File: /dev/sr0 (/dev/sg1)
  Device Files: /dev/sr0, /dev/disk/by-path/pci-0000:00:1f.0-ata-2.0, /dev/disk/by-path/pci-0000:00:1f.0-ata-2, /dev/cdrom, /dev/disk/by-diskseq/15, /dev/disk/by-label/KNOPPIX, /dev/disk/by-uuid/2012-09-26-14-40-23-00
  Device Number: block 11:0 (char 21:1)
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #4 (IDE interface)
  Drive Speed: 1
  Volume ID: "KNOPPIX"
  Application: "MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING"
  Creation date: "2012092614402300"
  El Torito info: platform 0, bootable
    Boot Catalog: at sector 0x0026
    Media: none starting at sector 0x0027
    Load: 2048 bytes

FreeDOS on the other hand still doesn't notice when I eject the Compact Disk, but that's not unexpected.

Another glitch I noticed in the Linux boot log:

Debian boot log about drive diagnostics failures
Mai 18 17:38:43 debian-iscsi kernel: ata1.00: ATA-6: v86 HD, , max MWDMA2
Mai 18 17:38:43 debian-iscsi kernel: ata1.00: 2097152 sectors, multi 0: LBA48 
Mai 18 17:38:43 debian-iscsi kernel: ata1.00: Drive reports diagnostics failure. This may indicate a drive
Mai 18 17:38:43 debian-iscsi kernel: ata1.00: fault or invalid emulation. Contact drive vendor for information.
Mai 18 17:38:43 debian-iscsi kernel: scsi 0:0:0:0: Direct-Access     ATA      v86 HD           n/a  PQ: 0 ANSI: 5
Mai 18 17:38:43 debian-iscsi kernel: ata2.00: ATAPI: v86 HD, , max MWDMA2
Mai 18 17:38:43 debian-iscsi kernel: ata2.00: Drive reports diagnostics failure. This may indicate a drive
Mai 18 17:38:43 debian-iscsi kernel: ata2.00: fault or invalid emulation. Contact drive vendor for information.
Mai 18 17:38:43 debian-iscsi kernel: scsi 1:0:0:0: CD-ROM            SONY     CD-ROM CDU-1000  1.1a PQ: 0 ANSI: 1 CCS
Mai 18 17:38:43 debian-iscsi kernel: virtio_net virtio0 enp0s10: renamed from eth0
Mai 18 17:38:43 debian-iscsi kernel: sr 1:0:0:0: [sr0] scsi-1 drive

I suspect that that is a bug in ATA command "EXECUTE DEVICE DIAGNOSTIC", doesn't seem important but maybe I take a look at this when other things are done.
EDIT: this issue is fixed, so it all works now without any errors or warnings under Linux!

The only significant problem with this PR left now is the single-device case.

@chschnell

chschnell commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

In the ATA/ATAPI-8 spec I stumbled upon this sentence, well possible that I overlooked it in earlier revisions:

For ATAPI devices, the IDENTIFY DEVICE command (see 7.12) and the READ SECTOR(S) command (see 7.28) are command aborted and return the ATAPI device signature (see table 206).

I checked and found it missing in our code, added it, and now the CD-ROM device runs flawlessly under Windows 95:

win95-oakcdrom-2

Note that unlike earlier:

  • The Device Manager now correctly categorizes and presents the CD-ROM device (v86 literally declares the CD-ROM to be a "SONY CD-ROM CDU-1000").
  • Insert/eject CD works, Windows also nicely responds by replacing the "D:" label (in "My Computer" window at the top right) with the actual disk label ("FD14-LiveCD" here) when I insert a disk, and removes it if I eject it again. I can repeat swapping CDs.
  • The disk size is displayed correctly now.

Eject/reinsert under FreeDOS is unfortunately still scuffed, though.

chschnell added 3 commits May 29, 2025 13:11
The minor change from yesterday changed Win95's behaviour such that it now issues an ATAPI command ("PAUSE") that wasn't implemented yet which led to Win95 crashing in v86 Debug mode. Added that command and now it works again.
A few ATAPI commands did not return an error (CD Not Ready condition) with ejected medium as specified in MMC-3 (https://www.t10.org/ftp/t10/document.97/97-108r0.pdf).

Adding these to our subset of ATAPI commands improved the FreeDOS 1.4 situation around eject/insert a bit (the problem really is eject, insert always works given the medium is ejected). Waiting around 20-30 sec after eject seems to work reliably.
Adds support to eject a CD from within Windows 95 through the context menu of the CD icon.

Before this commit eject was only supported externally through the v86 API.
@chschnell

chschnell commented May 30, 2025

Copy link
Copy Markdown
Contributor Author

Ejecting a disk from within the guest OS works well across different OSes:

  • Under Debian 12, install apt package eject and then use console command eject.
  • Under FreeDOS 1.4, install package CDROM2UI from the bonus CD using its package manager fdimples, then use console command cdrom eject d:.
  • Under Windows 95, right-click on the CD-ROM device symbol and select Eject.

When ejecting from outside using the v86 API it works well under Windows 95, and under FreeDOS 1.4 you have to wait 15-20 seconds to let it "click".

@chschnell

chschnell commented May 31, 2025

Copy link
Copy Markdown
Contributor Author

I setup my local v86 with a second hard-disk hdb and ran some tests with three IDE drives.

SeaBIOS 1.16.2

SeaBIOS detects all three drives fine, from its debug output:

ata0-0: v86 ATA HD ATA-0 Hard-Disk (20 MiBytes)
ata0-1: v86 ATA HD ATA-0 Hard-Disk (26 MiBytes)
DVD/CD [ata1-0: v86 ATAPI CD-ROM ATAPI-0 DVD/CD]

Guest OS: Debian 12

Works using a 26M blank file for hdb. Partitioned and formatted hdb using the command line from within the guest:

root@debian:~# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
    sda      8:0    0    2G  0 disk
    └─sda1   8:1    0    2G  0 part /
    sdb      8:16   0   26M  0 disk
    sr0     11:0    1 1024M  0 rom

root@debian:~# cfdisk /dev/sdb

root@debian:~# mkfs.ext4 -L mysdb1 /dev/sdb1

root@debian:~# mount /dev/sdb1 /mnt

root@debian:~# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
    sda      8:0    0    2G  0 disk
    └─sda1   8:1    0    2G  0 part /
    sdb      8:16   0   26M  0 disk
    └─sdb1   8:17   0   24M  0 part /mnt
    sr0     11:0    1 1024M  0 rom

root@debian:~# ls /mnt
    lost+found

Guest OS: FreeDOS 1.4

Works using the same 26M blank file for hdb as before. Partitioned and formatted hdb using the command line from within the guest: fdisk with FAT-16, reboot and format D:. Then I had drives C:, D: and E: (CD-ROM).

Guest OS: Windows 95

Works using a preformatted 8M image file (FAT-16, labelled MYDISK, non-bootable) for hdb:

win95-oakcdrom-3

Detail: Linux commands used to create the 8M FAT-16 image file for Windows 95
# create 8M empty file
dd if=/dev/zero of=empty_8M_FAT16.img bs=1M count=8

# use partition TYPE "FAT16<32M", do not mark bootable
sudo cfdisk empty_8M_FAT16.img

# format using FAT
sudo losetup -f empty_8M_FAT16.img
sudo partx -a /dev/loop0
sudo mkfs.fat -n MYDISK /dev/loop0p1
sudo partx -d /dev/loop0
sudo losetup -d /dev/loop0

So this works really well :)

There was an overlap in the PCI space register declarations of the Floppy and the IDE controller. Since the conflicting registers were used exclusively by the two controllers this was fine, but 9front prints out this boot warning message:

    ioalloc: 3f0 - 3f5 floppy: clashes with: 3f4 - 3f5 PCI.0.31.0

Note that "PCI.0.31.0" is our IDE controller (with pci_id 0x1f).

Problem: IDE actually uses only register address 0x3f6, but declared BAR1 for address range 0x3f4-0x3f7 which overlaps with the Floppy controller (the same with BAR3 and its address range of 0x374-0x377, but there was no overlap with other devices here).

Fix:
- changed BAR1 base address from 0x3f4 to 0x3f6 and its size from 4 to 1
- changed BAR3 base address from 0x374 to 0x376 and its size from 4 to 1

This commit fixes that problem and the 9front boot message from above.
@chschnell

chschnell commented Jun 2, 2025

Copy link
Copy Markdown
Contributor Author

I made another attempt to make the 9front ISO image boot and succeeded this time, but it's just so weird. Here's a screenshot of the 9front desktop:

9front-boot-3

Aside from enabling ACPI and using SeaBIOS in Release mode you need to mount the 9front ISO9660 image on hda, not cdrom (more about this at the end of this post). Weird, huh? I found that out by accident.

You can download the zst-compressed image here: 9front-7781.38dcaeaa222c.386.iso.zst and run it using the v86 web UI, just make sure to enable ACPI.

Boot procedure

You'll be prompted for 5 boot parameters during the boot process, you can accept their given defaults by simply pressing ENTER each time.

The first 4 boot parameters (bootargs, user, vgasize and monitor) are prompted on the text console, output at the 4th parameter:

/dev/sdC0: v86 ATA HD
/dev/sdC0/data   9660
/dev/sdC0/esp    dos
bootargs is (tcp, tls, il, local!device)[local!/dev/sdC0/data]
user[glenda]:

init: starting /bin/rc
cirno Jun  2 17:32:04 starting dns resolver on /net
vgasize is (text, 640x480x8, 1024x768x16, ...) [1024x768x16]
monitor is (vesa, xga, lcd, ...) [vesa]

Next, 9front will switch to the graphical desktop and prompt for the 5th parameter (at the bottom), press ENTER to accept the mouse port default of ps2:

9front-boot-2

Wait a few seconds and you should see the normal 9front desktop.

ISO image on hda

Note that 9front accepts the ATA HD with an ISO image. I didn't even know this was possible.

Here once more 9front's output related to detected disks under v86 (note the unusual mix of an ISO partition on an ATA HD):

/dev/sdC0: v86 ATA HD
/dev/sdC0/data   9660
/dev/sdC0/esp    dos

I ran the 9front image through QEMU using qemu-system-i386 9front-7781.38dcaeaa222c.386.iso to compare QEMU's output to ours:

9front-qemu

Note that even though 9front detects QEMU's CD-ROM device, 9front AGAIN (!) shows the ISO image at the hard disk device ("QEMU HARDDISK"), and also with identical path /dev/sdC0.

Not sure what's going on here, 9front is definitely the weirdest one, so far.

@SuperMaxusa

Copy link
Copy Markdown
Contributor

Note that 9front accepts the ATA HD with an ISO image. I didn't even know this was possible.

The 9front ISO starts with System Area that contains MBR bootloader, just like in raw hard drive images:

iso-system-area

According to the El Torito specs (https://fossies.org/linux/libisofs/doc/boot_sectors.txt, see lines 157 - 167), the boot media emulation is disabled:

el-torito

(i.e. if it is to simulate real hard disk, the byte 0x0000A021 should be 0x04, or I missed something)

So it reads sectors directly from a CD (and from a HDD too?) with ISO9660 filesystem.

Here once more 9front's output related to detected disks under v86 (note the unusual mix of an ISO partition on an ATA HD)

That DOS (FAT) partition on /dev/sdC0/esp is for UEFI bootloader: https://en.wikipedia.org/wiki/EFI_system_partition.

@chschnell

Copy link
Copy Markdown
Contributor Author

@copy: I think we're good, I don't see this as WIP any more (meaning I don't see any serious issues left).

@copy

copy commented Jun 7, 2025

Copy link
Copy Markdown
Owner

I think we're good, I don't see this as WIP any more (meaning I don't see any serious issues left).

Agreed. The remaining puzzle piece was making this compatible with old state images, which I pushed in #1345

@copy

copy commented Jun 7, 2025

Copy link
Copy Markdown
Owner

Merged in #1345, thanks a lot!

@copy copy closed this Jun 7, 2025
@chschnell
chschnell deleted the fix-cdrom-hda-boot branch June 7, 2025 14:57
@SuperMaxusa

Copy link
Copy Markdown
Contributor

Hurray, can we close #54 and #900?

@chschnell

Copy link
Copy Markdown
Contributor Author

Hurray, can we close #54 and #900?

Also #225, #463, #480 and #707, I believe.

@chschnell

Copy link
Copy Markdown
Contributor Author

Hurray, can we close #54 and #900?

@SuperMaxusa: I think we should just go ahead and close these 6 issues, they can be reopened anytime in case. I'm usually a bit hesitant to close other people's issues, that's why I haven't done it on my own yet.

@copy: Ok?

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.

4 participants