2 Copyright (C) 2019, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 /* We want all other bases obtained from our base */
11 #include <proto/utility.h>
13 #include <hidd/storage.h>
14 #include <hidd/scsi.h>
15 #include <hidd/hidd.h>
17 #include <utility/tagitem.h>
21 const char scsi_DevName
[] = "SCSI Controller";
23 OOP_Object
*SCSI__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
25 struct scsiBase
*SCSIBase
= cl
->UserData
;
27 OOP_Object
*scsiController
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
30 struct scsi_Controller
*data
= OOP_INST_DATA(cl
, scsiController
);
32 /*register the controller in ata.device */
33 D(bug ("[SCSI:Controller] Root__New: Controller Entry @ 0x%p\n", data
);)
36 data
->sc_Object
= scsiController
;
38 AddTail(&SCSIBase
->scsi_Controllers
, &data
->sc_Node
);
40 return scsiController
;
43 VOID
SCSI__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
45 struct scsiBase
*SCSIBase
= cl
->UserData
;
46 struct scsi_Controller
*scsiNode
, *tmpNode
;
48 D(bug ("[SCSI:Controller] Root__Dispose(0x%p)\n", o
);)
50 ForeachNodeSafe (&SCSIBase
->scsi_Controllers
, scsiNode
, tmpNode
)
52 if (scsiNode
->sc_Object
== o
)
54 D(bug ("[SCSI:Controller] Root__Dispose: Destroying Controller Entry @ 0x%p\n", scsiNode
);)
55 Remove(&scsiNode
->sc_Node
);
56 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
62 void SCSI__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
65 struct scsi_Controller
*data
= OOP_INST_DATA(cl
, o
);
68 if (IS_SCSI_ATTR(msg
->attrID
, idx
))
73 *msg
->storage
= (IPTR
)data
->yyyy
;
78 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
81 BOOL
SCSI__Hidd_StorageController__RemoveBus(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_StorageController_RemoveBus
*msg
)
83 D(bug ("[SCSI:Controller] Hidd_StorageController__RemoveBus(0x%p)\n", msg
->busObject
);)
85 * Currently we don't support unloading SCSI bus drivers.
86 * This is a very-very big TODO.
91 BOOL
SCSI__Hidd_StorageController__SetUpBus(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_StorageController_SetUpBus
*msg
)
93 struct scsiBase
*SCSIBase
= cl
->UserData
;
95 D(bug ("[SCSI:Controller] Hidd_StorageController__SetUpBus(0x%p)\n", msg
->busObject
);)
99 * Instantiate interfaces. PIO is mandatory, DMA is not.
100 * We don't keep interface pointers here because our bus class
101 * stores them itself.
102 * We do this in SetUpBus because the object must be fully
103 * created in order for this stuff to work.
105 if (!HIDD_SCSIBus_GetPIOInterface(msg
->busObject
))
108 D(bug ("[SCSI:Controller] Hidd_StorageController__SetUpBus: PIO Interfaces obtained\n");)
110 if (!SCSIBase
->scsi_NoDMA
)
111 HIDD_SCSIBus_GetDMAInterface(msg
->busObject
);
113 D(bug ("[SCSI:Controller] Hidd_StorageController__SetUpBus: Starting Bus...\n");)
116 /* Add the bus to the device and start service */
117 return Hidd_SCSIBus_Start(msg
->busObject
, SCSIBase
);
120 void SCSI__Hidd_StorageController__CleanUpBus(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_StorageController_CleanUpBus
*msg
)
122 D(bug ("[SCSI:Controller] Hidd_StorageController__CleanUpBus(0x%p)\n", msg
->busObject
);)
123 /* By default we have nothing to do here */