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" 103d416484SMarcus Overhagen #include "ahci_port.h" 1121255d1fSMarcus Overhagen 1221255d1fSMarcus Overhagen 134f6fa362SAxel Dörfler class AHCIController { 144f6fa362SAxel Dörfler public: 151a4dcbd8SAxel Dörfler AHCIController(device_node *node, 161a4dcbd8SAxel Dörfler pci_device_module_info *pciModule, 171a4dcbd8SAxel Dörfler pci_device *pciDevice); 184f6fa362SAxel Dörfler ~AHCIController(); 1921255d1fSMarcus Overhagen 20036a8857SMarcus Overhagen status_t Init(); 21036a8857SMarcus Overhagen void Uninit(); 22036a8857SMarcus Overhagen 2321255d1fSMarcus Overhagen void ExecuteRequest(scsi_ccb *request); 2421255d1fSMarcus Overhagen uchar AbortRequest(scsi_ccb *request); 2521255d1fSMarcus Overhagen uchar TerminateRequest(scsi_ccb *request); 2621255d1fSMarcus Overhagen uchar ResetDevice(uchar targetID, uchar targetLUN); 271a4dcbd8SAxel Dörfler void GetRestrictions(uchar targetID, bool *isATAPI, 281a4dcbd8SAxel Dörfler bool *noAutoSense, uint32 *maxBlocks); 2921255d1fSMarcus Overhagen DeviceNode()30368167edSAxel Dörfler device_node * DeviceNode() { return fNode; } 3121255d1fSMarcus Overhagen 3221255d1fSMarcus Overhagen private: 3321255d1fSMarcus Overhagen bool IsDevicePresent(uint device); 343d416484SMarcus Overhagen status_t ResetController(); 3522cf14cfSMarcus Overhagen void FlushPostedWrites(); 3621255d1fSMarcus Overhagen 374f733fe9SMarcus Overhagen static int32 Interrupt(void *data); 384f733fe9SMarcus Overhagen 3925f926d8SMarcus Overhagen friend class AHCIPort; 4025f926d8SMarcus Overhagen 4121255d1fSMarcus Overhagen private: 42368167edSAxel Dörfler device_node * fNode; 431a4dcbd8SAxel Dörfler pci_device_module_info *fPCI; 44368167edSAxel Dörfler pci_device * fPCIDevice; 453d416484SMarcus Overhagen uint16 fPCIVendorID; 463d416484SMarcus Overhagen uint16 fPCIDeviceID; 4783447512SMarcus Overhagen uint32 fFlags; 48036a8857SMarcus Overhagen 493d416484SMarcus Overhagen volatile ahci_hba * fRegs; 50093a713dSMarcus Overhagen area_id fRegsArea; 51105f6223SMarcus Overhagen int fCommandSlotCount; 522f0f9d87SMarcus Overhagen int fPortCount; 5327367cc3SMarcus Overhagen uint32 fPortImplementedMask; 54*629f071bSX512 uint32 fIRQ; 55c01fadcaSJerome Duval bool fUseMSI; 5625f926d8SMarcus Overhagen AHCIPort * fPort[32]; 57093a713dSMarcus Overhagen 58036a8857SMarcus Overhagen // --- Instance check workaround begin 59036a8857SMarcus Overhagen port_id fInstanceCheck; 60036a8857SMarcus Overhagen // --- Instance check workaround end 61036a8857SMarcus Overhagen 6221255d1fSMarcus Overhagen }; 6321255d1fSMarcus Overhagen 6421255d1fSMarcus Overhagen 653d416484SMarcus Overhagen inline void FlushPostedWrites()6622cf14cfSMarcus OverhagenAHCIController::FlushPostedWrites() 673d416484SMarcus Overhagen { 683d416484SMarcus Overhagen volatile uint32 dummy = fRegs->ghc; 693d416484SMarcus Overhagen dummy = dummy; 703d416484SMarcus Overhagen } 713d416484SMarcus Overhagen 724f6fa362SAxel Dörfler #endif // _AHCI_CONTROLLER_H 73