1 /* 2 * Copyright 2007, Marcus Overhagen. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _AHCI_CONTROLLER_H 6 #define _AHCI_CONTROLLER_H 7 8 9 #include "ahci_defs.h" 10 #include "ahci_port.h" 11 12 13 class AHCIController { 14 public: 15 AHCIController(device_node_handle node, 16 pci_device_info *pciDevice); 17 ~AHCIController(); 18 19 status_t Init(); 20 void Uninit(); 21 22 void ExecuteRequest(scsi_ccb *request); 23 uchar AbortRequest(scsi_ccb *request); 24 uchar TerminateRequest(scsi_ccb *request); 25 uchar ResetDevice(uchar targetID, uchar targetLUN); 26 27 device_node_handle DeviceNode() { return fNode; } 28 29 private: 30 bool IsDevicePresent(uint device); 31 status_t ResetController(); 32 void FlushPostedWrites(); 33 34 static int32 Interrupt(void *data); 35 36 friend class AHCIPort; 37 38 private: 39 device_node_handle fNode; 40 pci_device_info* fPCIDevice; 41 uint16 fPCIVendorID; 42 uint16 fPCIDeviceID; 43 uint32 fFlags; 44 45 volatile ahci_hba * fRegs; 46 area_id fRegsArea; 47 int fCommandSlotCount; 48 int fPortCountMax; 49 int fPortCountAvail; 50 uint8 fIRQ; 51 AHCIPort * fPort[32]; 52 53 // --- Instance check workaround begin 54 port_id fInstanceCheck; 55 // --- Instance check workaround end 56 57 }; 58 59 60 inline void 61 AHCIController::FlushPostedWrites() 62 { 63 volatile uint32 dummy = fRegs->ghc; 64 dummy = dummy; 65 } 66 67 #endif // _AHCI_CONTROLLER_H 68