xref: /haiku/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h (revision 83447512ed157f2fbe0165c57a924aad1de14c43)
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:
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);
313d416484SMarcus Overhagen 	status_t	ResetController();
3222cf14cfSMarcus Overhagen 	void		FlushPostedWrites();
3321255d1fSMarcus Overhagen 
344f733fe9SMarcus Overhagen static int32	Interrupt(void *data);
354f733fe9SMarcus Overhagen 
3625f926d8SMarcus Overhagen 	friend class AHCIPort;
3725f926d8SMarcus Overhagen 
3821255d1fSMarcus Overhagen private:
3921255d1fSMarcus Overhagen 	device_node_handle 			fNode;
404f6fa362SAxel Dörfler 	pci_device_info*			fPCIDevice;
413d416484SMarcus Overhagen 	uint16						fPCIVendorID;
423d416484SMarcus Overhagen 	uint16						fPCIDeviceID;
43*83447512SMarcus Overhagen 	uint32						fFlags;
44036a8857SMarcus Overhagen 
453d416484SMarcus Overhagen 	volatile ahci_hba *			fRegs;
46093a713dSMarcus Overhagen 	area_id						fRegsArea;
47105f6223SMarcus Overhagen 	int							fCommandSlotCount;
489382f576SMarcus Overhagen 	int							fPortCountMax;
499382f576SMarcus Overhagen 	int							fPortCountAvail;
504f733fe9SMarcus Overhagen 	uint8						fIRQ;
5125f926d8SMarcus Overhagen 	AHCIPort *					fPort[32];
52093a713dSMarcus Overhagen 
53036a8857SMarcus Overhagen // --- Instance check workaround begin
54036a8857SMarcus Overhagen 	port_id fInstanceCheck;
55036a8857SMarcus Overhagen // --- Instance check workaround end
56036a8857SMarcus Overhagen 
5721255d1fSMarcus Overhagen };
5821255d1fSMarcus Overhagen 
5921255d1fSMarcus Overhagen 
603d416484SMarcus Overhagen inline void
6122cf14cfSMarcus Overhagen AHCIController::FlushPostedWrites()
623d416484SMarcus Overhagen {
633d416484SMarcus Overhagen 	volatile uint32 dummy = fRegs->ghc;
643d416484SMarcus Overhagen 	dummy = dummy;
653d416484SMarcus Overhagen }
663d416484SMarcus Overhagen 
674f6fa362SAxel Dörfler #endif	// _AHCI_CONTROLLER_H
68