Skip to content

Commit 6a99bca

Browse files
committed
Merge branch 'master' of https://github.com/86Box/86Box
2 parents 99b2a7d + fa2efeb commit 6a99bca

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎src/floppy/fdc.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,9 +1522,13 @@ fdc_write(uint16_t addr, uint8_t val, void *priv)
15221522
if ((fdc->params[1] - fdc->pcn[fdc->params[0] & 3]) == 0) {
15231523
fdc_log("Failed seek\n");
15241524
fdc->st0 = 0x20 | (fdc->params[0] & 3);
1525-
/* Always use the PCjr code, so both 386BSD and 1B/V3 work. */
1525+
/* Default to polled completion for 386BSD and 1B/V3 compatibility. */
15261526
fdc->fintr = 1;
15271527
fdc->interrupt = -4;
1528+
if (fdc->flags & FDC_FLAG_IRQ_ON_NOOP_SEEK) {
1529+
fdc->interrupt = -3;
1530+
fdc_callback(fdc);
1531+
}
15281532
break;
15291533
}
15301534
if (fdc->params[1] > fdc->pcn[fdc->params[0] & 3])

‎src/include/86box/fdc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define FDC_FLAG_5550 0x200000 /* IBM Multistation 5550 */
6363
#define FDC_FLAG_NO_TDR 0x400000 /* Has no tape drive register */
6464
#define FDC_FLAG_PCJX 0x800000 /* IBM PC JX no-DMA adapter */
65+
#define FDC_FLAG_IRQ_ON_NOOP_SEEK 0x1000000 /* Interrupt on zero-step SEEK completion */
6566

6667
typedef struct sector_id_fields_t {
6768
uint8_t c;

‎tests/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Build `fdc_read_id_tests` with `BUILD_TESTING=ON`, then run `ctest --test-dir bu
2727

2828
The tests use the real FDC/FDD/IMG/D86F path to check immediate missing-head errors and normal bitstream Read ID completion in DMA and non-DMA modes. They adapt host timers, interrupts and file services; Read ID has no DMA payload, so this is not a DMA-transfer test. The fixture includes FDC/FDD as C-in-C++ for private device access, compiles IMG/D86F/FIFO/CRC as C, and uses portable filesystem temporary directories.
2929

30+
The same fixture checks zero-step SEEK completion with `FDC_FLAG_IRQ_ON_NOOP_SEEK` enabled and disabled, including the DOR interrupt gate and successful Sense Interrupt Status without head movement. The default retains the polled compatibility behavior introduced by commit `e140db7d1` for 386BSD and 1B/V3. The Convertible opts into interrupts because its BIOS power-on recovery waits for IRQ6 even when restoring cylinder zero.
31+
3032
# Cartridges
3133

3234
The cartridge tests compile `src/device/cartridge.c` as C and exercise raw and headered image loading, replacement/ejection, overlap and address bounds, and hard-reset reloads. They use real temporary image files with a small external-memory mapping adapter; they do not emulate CPU execution, RAM/BIOS arbitration, or the real memory mapping cache.

‎tests/floppy/fdc_read_id_test.cpp‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ extern "C" {
1919
}
2020

2121
namespace {
22+
uint16_t asserted_irqs;
23+
2224

2325
// Exercise the real FDC -> FDD -> IMG/D86F path. Only host services are adapted;
2426
// in particular, no adapter synthesizes a controller completion or media error.
@@ -182,6 +184,29 @@ TEST_F(FdcReadId, PresentHeadCompletesThroughRealBitstream)
182184
}
183185
}
184186

187+
TEST_F(FdcReadId, NoMovementSeekInterruptIsOptInAndRespectsDorGate)
188+
{
189+
for (bool enabled : { false, true }) {
190+
for (bool irq_gate : { false, true }) {
191+
SCOPED_TRACE(::testing::Message() << "option=" << enabled << " DOR IRQ gate=" << irq_gate);
192+
controller.flags = enabled ? FDC_FLAG_IRQ_ON_NOOP_SEEK : 0;
193+
controller.reset_stat = 0;
194+
fdc_write(0x3f2, irq_gate ? 0x1c : 0x14, &controller);
195+
asserted_irqs = 0;
196+
197+
command(0x0f, { 0, 0 });
198+
EXPECT_EQ(asserted_irqs & (1 << 6), enabled && irq_gate ? (1 << 6) : 0);
199+
EXPECT_EQ(fdc_read(0x3f4, &controller) & 0xf0, 0x80);
200+
command(0x08, {});
201+
const auto status = result();
202+
ASSERT_EQ(status.size(), 2u);
203+
EXPECT_EQ(status[0], 0x20);
204+
EXPECT_EQ(status[1], 0);
205+
EXPECT_EQ(fdd_current_track(0), 0);
206+
}
207+
}
208+
}
209+
185210
} // namespace
186211

187212
// Host adapters: deterministic clock, no PIC/DMA bus or UI/audio, ordinary files.
@@ -223,8 +248,9 @@ timer_add(pc_timer_t *timer, void (*callback)(void *), void *priv, int start)
223248
timer->flags = start ? TIMER_ENABLED : 0;
224249
}
225250
void
226-
picint_common(uint16_t, int, int, uint8_t *)
251+
picint_common(uint16_t mask, int, int, uint8_t *)
227252
{
253+
asserted_irqs |= mask;
228254
}
229255
void
230256
dma_set_drq(int, int)

0 commit comments

Comments
 (0)