Commit b29f171
ide: fix ATAPI CD in Win9x (UNIT ATTENTION root cause) without breaking OAKCDROM (MiSTer-devel#1224)
PR MiSTer-devel#1221 fixed the Win9x protected-mode "Code 10" on the ATAPI CD's IDE
controller by globally stripping the DSC/SERVICE status bit (0x10) for CD
drives. That approach had two problems:
1. It broke real-mode CD detection. OAKCDROM.SYS (the DOS / Win9x-setup ATAPI
driver) keys off an explicit status byte after the ATAPI DEVICE RESET to
detect the drive; the blanket strip clobbered it -> "No drives found".
2. The Code 10 it "fixed" was never a DSC problem. The strip only masked the
real bug.
Real root cause of the Code 10: a successful ATAPI INQUIRY was completing with
a spurious UNIT ATTENTION. INQUIRY / REQUEST SENSE are exempt from the
media-change gate so they deliver their data even with a pending media change,
but the WAIT_PKT_RD completion called cdrom_reply() with the default
unit_attention=true, stamping CHECK CONDITION / err=0x60 onto the finished
transfer. Win9x's ESDI_506 reads "INQUIRY returned its data AND failed" as a
dead controller and refuses to start the channel -> Device Manager Code 10.
Bochs and 86Box both return GOOD for INQUIRY.
Fixes:
- ide_set_regs: replace the global DSC strip with "auto-assert DSC for non-CD
drives only", letting each ATAPI command publish its own (DSC-free) status.
Satisfies both OAK and Win9x without any blanket bit-4 policy.
- ATAPI DEVICE RESET (cmd 0x08): present status 0x00 (no DRDY/DSC), matching
real ATAPI hardware, which routes OAKCDROM to its signature-detect path.
- WAIT_PKT_RD completion: pass unit_attention=false so a successful data phase
reports GOOD. The pending media-change UA is still delivered on the first
non-exempt command (TEST UNIT READY -> cdrom_nodisk).
- Post ATAPI diagnostic code 01h in the error register after a bus reset; a
stale ABRT was otherwise read by ESDI_506 as a failed power-on self-test.
Tested on DE10-Nano: Win98 SE enumerates "MiSTer CDROM" with both Standard
IDE/ESDI controllers clean (no Code 10), and real-mode OAKCDROM.SYS detects the
CD (MSCDEX assigns drive D:).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 105b013 commit b29f171
2 files changed
Lines changed: 14 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
171 | 168 | | |
172 | 169 | | |
173 | 170 | | |
| |||
1016 | 1013 | | |
1017 | 1014 | | |
1018 | 1015 | | |
1019 | | - | |
| 1016 | + | |
| 1017 | + | |
1020 | 1018 | | |
1021 | 1019 | | |
1022 | 1020 | | |
| |||
1049 | 1047 | | |
1050 | 1048 | | |
1051 | 1049 | | |
1052 | | - | |
| 1050 | + | |
| 1051 | + | |
1053 | 1052 | | |
1054 | 1053 | | |
1055 | 1054 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
| 1582 | + | |
| 1583 | + | |
1582 | 1584 | | |
1583 | | - | |
| 1585 | + | |
| 1586 | + | |
1584 | 1587 | | |
1585 | 1588 | | |
1586 | | - | |
| 1589 | + | |
1587 | 1590 | | |
1588 | 1591 | | |
1589 | 1592 | | |
| |||
0 commit comments