--- nono/vm/fdc.cpp 2026/04/29 17:04:28 1.1.1.1 +++ nono/vm/fdc.cpp 2026/04/29 17:04:35 1.1.1.4 @@ -1,10 +1,11 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #include "fdc.h" -#include "iocon.h" +#include "ioctlr.h" #include "scheduler.h" // コンストラクタ @@ -17,7 +18,7 @@ FDCDevice::FDCDevice() event.dev = this; event.func = (DeviceCallback_t)&FDCDevice::Callback; - event.name = "FDC"; + event.SetName("FDC"); } // デストラクタ @@ -33,37 +34,33 @@ FDCDevice::ResetHard() } uint64 -FDCDevice::Read8(uint32 addr) +FDCDevice::Read(uint32 addr) { - uint32 offset = addr - baseaddr; - switch (offset) { - case 1: + switch (addr) { + case 0: return ReadStatus(); - case 3: + case 1: return ReadData(); - case 5: + case 2: return ReadDriveStatus(); - default: - break; + case 3: + return 0xff; } - PANIC("not impl"); + __unreachable(); } uint64 -FDCDevice::Read16(uint32 addr) +FDCDevice::Write(uint32 addr, uint32 data) { - return 0xff00 | Read8(addr + 1); -} + switch (addr) { + case 0: + return 0; -uint64 -FDCDevice::Write8(uint32 addr, uint32 data) -{ - uint32 offset = addr - baseaddr; - switch (offset) { - case 3: + case 1: WriteCmd(data); return 0; - case 5: + + case 2: if ((data & 0x0f) != 0) { fdc.drivesel = data & 0x0f; putlog(1, "ドライブ選択%s%s%s%s", @@ -77,7 +74,7 @@ FDCDevice::Write8(uint32 addr, uint32 da } return 0; - case 7: + case 3: fdc.is2DD = ((data & 0x10) != 0); fdc.accdrive = data & 3; putlog(1, "アクセスドライブ %s #%d", @@ -90,23 +87,14 @@ FDCDevice::Write8(uint32 addr, uint32 da putlog(1, "ドライブ #%d モーターオフ", fdc.accdrive); } return 0; - - default: - break; } - PANIC("FDC 未実装書き込み $%06x <- $%02x", addr, data); - return 0; -} - -uint64 -FDCDevice::Write16(uint32 addr, uint32 data) -{ - return Write8(addr + 1, data); + __unreachable(); } uint64 -FDCDevice::Peek8(uint32 addr) +FDCDevice::Peek(uint32 addr) { + // XXX 未実装 return 0xff; } @@ -287,7 +275,7 @@ FDCDevice::exec_phase() // XXX ヘッドの位置という概念がまだない event.time = 0; event.code = FDC::CMD_RECALIBRATE; // XXX コマンドをメンバ変数にするとか - gScheduler->AddEvent(&event); + event.Start(); break; case FDC::CMD_SEEK: @@ -332,7 +320,7 @@ FDCDevice::Callback(int arg) void FDCDevice::Interrupt() { - gIOCon->IntFDC(); + gIOCtlr->IntFDC(); } // コマンド名