xref: /haiku/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h (revision cda5b8808fd0262f0fac472f6cfa809f846a83cf)
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 	void		GetRestrictions(uchar targetID, bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks);
27 
28 	device_node_handle DeviceNode() { return fNode; }
29 
30 private:
31 	bool		IsDevicePresent(uint device);
32 	status_t	ResetController();
33 	void		FlushPostedWrites();
34 
35 static int32	Interrupt(void *data);
36 
37 	friend class AHCIPort;
38 
39 private:
40 	device_node_handle 			fNode;
41 	pci_device_info*			fPCIDevice;
42 	uint16						fPCIVendorID;
43 	uint16						fPCIDeviceID;
44 	uint32						fFlags;
45 
46 	volatile ahci_hba *			fRegs;
47 	area_id						fRegsArea;
48 	int							fCommandSlotCount;
49 	int							fPortCountMax;
50 	int							fPortCountAvail;
51 	uint32						fPortImplementedMask;
52 	uint8						fIRQ;
53 	AHCIPort *					fPort[32];
54 
55 // --- Instance check workaround begin
56 	port_id fInstanceCheck;
57 // --- Instance check workaround end
58 
59 };
60 
61 
62 inline void
63 AHCIController::FlushPostedWrites()
64 {
65 	volatile uint32 dummy = fRegs->ghc;
66 	dummy = dummy;
67 }
68 
69 #endif	// _AHCI_CONTROLLER_H
70