xref: /haiku/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h (revision 2beda3bb5be8191b672688bed7ddcadd2b17dc41)
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 *node,
16 								pci_device_module_info *pciModule,
17 								pci_device *pciDevice);
18 							~AHCIController();
19 
20 			status_t		Init();
21 			void			Uninit();
22 
23 			void			ExecuteRequest(scsi_ccb *request);
24 			uchar			AbortRequest(scsi_ccb *request);
25 			uchar			TerminateRequest(scsi_ccb *request);
26 			uchar			ResetDevice(uchar targetID, uchar targetLUN);
27 			void			GetRestrictions(uchar targetID, bool *isATAPI,
28 								bool *noAutoSense, uint32 *maxBlocks);
29 
30 			device_node *	DeviceNode() { return fNode; }
31 
32 private:
33 			bool			IsDevicePresent(uint device);
34 			status_t		ResetController();
35 			void			FlushPostedWrites();
36 
37 	static	int32			Interrupt(void *data);
38 
39 	friend class AHCIPort;
40 
41 private:
42 	device_node *			fNode;
43 	pci_device_module_info *fPCI;
44 	pci_device *			fPCIDevice;
45 	uint16					fPCIVendorID;
46 	uint16					fPCIDeviceID;
47 	uint32					fFlags;
48 
49 	volatile ahci_hba *		fRegs;
50 	area_id					fRegsArea;
51 	int						fCommandSlotCount;
52 	int						fPortCount;
53 	uint32					fPortImplementedMask;
54 	uint8					fIRQ;
55 	AHCIPort *				fPort[32];
56 
57 // --- Instance check workaround begin
58 	port_id fInstanceCheck;
59 // --- Instance check workaround end
60 
61 };
62 
63 
64 inline void
65 AHCIController::FlushPostedWrites()
66 {
67 	volatile uint32 dummy = fRegs->ghc;
68 	dummy = dummy;
69 }
70 
71 #endif	// _AHCI_CONTROLLER_H
72