--- nono/vm/scsibus.cpp 2026/04/29 17:05:42 1.1.1.15 +++ nono/vm/scsibus.cpp 2026/04/29 17:05:50 1.1.1.16 @@ -95,14 +95,15 @@ #include "scsibus.h" #include "scsidev.h" #include "scsidomain.h" +#include "event.h" #include "scheduler.h" // time 時間後に呼び出すコールバックをセットする。 // func の書式が面倒なのを省略して書きたいため。 #define CallAfter(func_, name_, time_) do { \ - event.func = ToEventCallback(&SCSIBus::func_); \ - event.time = time_; \ - event.SetName(name_); \ + event->func = ToEventCallback(&SCSIBus::func_); \ + event->time = time_; \ + event->SetName(name_); \ scheduler->RestartEvent(event); \ } while (0) @@ -126,8 +127,9 @@ SCSIBus::Init() // イニシエータはこの時点では ID 未定なのでバスには繋がらない。 Refresh(); - event.SetName("SCSIBus"); // 複数出来たら名前どうするべか - scheduler->RegistEvent(event); + auto evman = GetEventManager(); + // 複数出来たら名前どうするべか + event = evman->Regist(this, NULL, "SCSIBus"); return true; } @@ -214,11 +216,11 @@ SCSIBus::AssertSEL(uint id) putlog(4, "%s(#%u)", __func__, id); // すでに上がってたら何もしない - if ((sel & (1 << id))) { + if ((sel & (1U << id))) { return; } - sel |= (1 << id); + sel |= (1U << id); if (GetPhase() == SCSI::Phase::BusFree) { // バスフリーフェーズなら、アービトレーションなしでセレクション @@ -301,11 +303,11 @@ SCSIBus::NegateSEL(uint id) putlog(4, "%s(#%u)", __func__, id); // すでに下りてたら何もしない - if ((sel & (1 << id)) == 0) { + if ((sel & (1U << id)) == 0) { return; } - sel &= ~(1 << id); + sel &= ~(1U << id); if (GetPhase() == SCSI::Phase::BusFree) { // バスフリーフェーズで SEL を下げる @@ -344,11 +346,11 @@ SCSIBus::AssertBSY(uint id) putlog(4, "%s(#%u)", __func__, id); // すでに上がってたら何もしない - if ((bsy & (1 << id))) { + if ((bsy & (1U << id))) { return; } - bsy |= (1 << id); + bsy |= (1U << id); if (GetPhase() == SCSI::Phase::BusFree) { // バスフリーフェーズだったらアービトレーション開始 @@ -390,11 +392,11 @@ SCSIBus::NegateBSY(uint id) putlog(4, "%s(#%u)", __func__, id); // すでに下りてたら何もしない - if ((bsy & (1 << id)) == 0) { + if ((bsy & (1U << id)) == 0) { return; } - bsy &= ~(1 << id); + bsy &= ~(1U << id); if (GetPhase() == SCSI::Phase::Transfer) { // 転送フェーズから BSY を下げたらバスフリーに移行。 @@ -467,7 +469,7 @@ SCSIBus::AssertREQ() // ターゲットが REQ を立てようとして所定時間経ったので REQ を立てて // イニシエータの OnTransferReq を呼び出すところ。 void -SCSIBus::TransferReq(Event& ev) +SCSIBus::TransferReq(Event *ev) { putlog(4, "AssertREQ"); req = true; @@ -587,7 +589,7 @@ SCSIBus::BusFree(uint id) // セレクションフェーズ開始。 void -SCSIBus::SelectionStart(Event& ev) +SCSIBus::SelectionStart(Event *ev) { // この時点でデータバスには自身の ID と相手の ID が立っているはず。 // 一方 sel は SEL 信号線を立てた人のビットを持っているので、 @@ -617,7 +619,7 @@ SCSIBus::SelectionStart(Event& ev) // SelectionStart() にてターゲットが選択されて規定時間経ったので // そろそろターゲットが BSY を立てる頃に呼ばれるコールバック。 void -SCSIBus::Selected(Event& ev) +SCSIBus::Selected(Event *ev) { // ターゲットに通知。ターゲットがいることは確定している。 assert(device[target_id]); @@ -627,7 +629,7 @@ SCSIBus::Selected(Event& ev) // ターゲットが BSY を立てて規定時間経ったので // そろそろイニシエータが SEL を下げる頃に呼ばれるコールバック。 void -SCSIBus::SelectionAck(Event& ev) +SCSIBus::SelectionAck(Event *ev) { // イニシエータに通知。 assert(device[init_id]); @@ -637,7 +639,7 @@ SCSIBus::SelectionAck(Event& ev) // 情報転送フェーズ開始を通知する。 // BSY を上げて情報転送フェーズに移行したところで呼ばれる。 void -SCSIBus::StartTransfer(Event& ev) +SCSIBus::StartTransfer(Event *ev) { SetPhase(SCSI::Phase::Transfer);