121255d1fSMarcus Overhagen /* 221255d1fSMarcus Overhagen * Copyright 2007, Marcus Overhagen. All rights reserved. 321255d1fSMarcus Overhagen * Distributed under the terms of the MIT License. 421255d1fSMarcus Overhagen */ 521255d1fSMarcus Overhagen #ifndef _AHCI_CONTROLLER_H 621255d1fSMarcus Overhagen #define _AHCI_CONTROLLER_H 721255d1fSMarcus Overhagen 821255d1fSMarcus Overhagen 921255d1fSMarcus Overhagen #include "ahci_defs.h" 10*3d416484SMarcus Overhagen #include "ahci_port.h" 1121255d1fSMarcus Overhagen 1221255d1fSMarcus Overhagen 134f6fa362SAxel Dörfler class AHCIController { 144f6fa362SAxel Dörfler public: 154f6fa362SAxel Dörfler AHCIController(device_node_handle node, 164f6fa362SAxel Dörfler pci_device_info *pciDevice); 174f6fa362SAxel Dörfler ~AHCIController(); 1821255d1fSMarcus Overhagen 19036a8857SMarcus Overhagen status_t Init(); 20036a8857SMarcus Overhagen void Uninit(); 21036a8857SMarcus Overhagen 2221255d1fSMarcus Overhagen void ExecuteRequest(scsi_ccb *request); 2321255d1fSMarcus Overhagen uchar AbortRequest(scsi_ccb *request); 2421255d1fSMarcus Overhagen uchar TerminateRequest(scsi_ccb *request); 2521255d1fSMarcus Overhagen uchar ResetDevice(uchar targetID, uchar targetLUN); 2621255d1fSMarcus Overhagen 274f6fa362SAxel Dörfler device_node_handle DeviceNode() { return fNode; } 2821255d1fSMarcus Overhagen 2921255d1fSMarcus Overhagen private: 3021255d1fSMarcus Overhagen bool IsDevicePresent(uint device); 31*3d416484SMarcus Overhagen status_t ResetController(); 32*3d416484SMarcus Overhagen void RegsFlush(); 3321255d1fSMarcus Overhagen 3421255d1fSMarcus Overhagen private: 3521255d1fSMarcus Overhagen device_node_handle fNode; 364f6fa362SAxel Dörfler pci_device_info* fPCIDevice; 3721255d1fSMarcus Overhagen uint32 fDevicePresentMask; 38*3d416484SMarcus Overhagen uint16 fPCIVendorID; 39*3d416484SMarcus Overhagen uint16 fPCIDeviceID; 40036a8857SMarcus Overhagen 41*3d416484SMarcus Overhagen volatile ahci_hba * fRegs; 42093a713dSMarcus Overhagen area_id fRegsArea; 43105f6223SMarcus Overhagen int fCommandSlotCount; 44105f6223SMarcus Overhagen int fPortCount; 45*3d416484SMarcus Overhagen int fPortMax; 46*3d416484SMarcus Overhagen AHCIPort * fPorts[32]; 47093a713dSMarcus Overhagen 48036a8857SMarcus Overhagen 49036a8857SMarcus Overhagen // --- Instance check workaround begin 50036a8857SMarcus Overhagen port_id fInstanceCheck; 51036a8857SMarcus Overhagen // --- Instance check workaround end 52036a8857SMarcus Overhagen 5321255d1fSMarcus Overhagen }; 5421255d1fSMarcus Overhagen 5521255d1fSMarcus Overhagen 5621255d1fSMarcus Overhagen inline bool 5721255d1fSMarcus Overhagen AHCIController::IsDevicePresent(uint device) 5821255d1fSMarcus Overhagen { 5921255d1fSMarcus Overhagen return fDevicePresentMask & (1 << device); 6021255d1fSMarcus Overhagen } 6121255d1fSMarcus Overhagen 6221255d1fSMarcus Overhagen 63*3d416484SMarcus Overhagen inline void 64*3d416484SMarcus Overhagen AHCIController::RegsFlush() 65*3d416484SMarcus Overhagen { 66*3d416484SMarcus Overhagen volatile uint32 dummy = fRegs->ghc; 67*3d416484SMarcus Overhagen dummy = dummy; 68*3d416484SMarcus Overhagen } 69*3d416484SMarcus Overhagen 70*3d416484SMarcus Overhagen 714f6fa362SAxel Dörfler #endif // _AHCI_CONTROLLER_H 72