btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / add-ons / kernel / busses / scsi / ahci / ahci_port.h
blob0b8c8029054fc48ed4852a673b03a032e6fb4594
1 /*
2 * Copyright 2007-2008, Marcus Overhagen. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _AHCI_PORT_H
6 #define _AHCI_PORT_H
9 #include <ATAInfoBlock.h>
11 #include "ahci_defs.h"
14 class AHCIController;
15 class sata_request;
17 class AHCIPort {
18 public:
19 AHCIPort(AHCIController *controller, int index);
20 ~AHCIPort();
22 status_t Init1();
23 status_t Init2();
24 void Uninit();
26 void Interrupt();
27 void InterruptErrorHandler(uint32 is);
30 void ScsiExecuteRequest(scsi_ccb *request);
31 uchar ScsiAbortRequest(scsi_ccb *request);
32 uchar ScsiTerminateRequest(scsi_ccb *request);
33 uchar ScsiResetDevice();
34 void ScsiGetRestrictions(bool *isATAPI, bool *noAutoSense, uint32 *maxBlocks);
36 private:
37 void ScsiTestUnitReady(scsi_ccb *request);
38 void ScsiInquiry(scsi_ccb *request);
39 void ScsiVPDInquiry(scsi_ccb* request, ata_device_infoblock* ataData);
41 void ScsiReadCapacity(scsi_ccb *request);
42 void ScsiReadCapacity16(scsi_ccb *request);
43 void ScsiReadWrite(scsi_ccb *request, uint64 lba, size_t sectorCount, bool isWrite);
44 void ScsiSynchronizeCache(scsi_ccb *request);
45 void ScsiUnmap(scsi_ccb* request,
46 struct scsi_unmap_parameter_list* unmapBlocks);
48 void ExecuteSataRequest(sata_request *request, bool isWrite = false);
50 void ResetDevice();
51 status_t PortReset();
52 status_t Probe();
54 bool Enable();
55 bool Disable();
57 void FlushPostedWrites();
58 void DumpD2HFis();
59 void DumpHBAState();
61 void StartTransfer();
62 status_t WaitForTransfer(int *tfd, bigtime_t timeout);
63 void FinishTransfer();
65 inline void _ClearErrorRegister();
67 // uint8 * SetCommandFis(volatile command_list_entry *cmd, volatile fis *fis, const void *data, size_t dataSize);
68 status_t FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize);
69 status_t FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize);
71 private:
72 AHCIController* fController;
73 int fIndex;
74 volatile ahci_port * fRegs;
75 area_id fArea;
76 spinlock fSpinlock;
77 volatile uint32 fCommandsActive;
78 sem_id fRequestSem;
79 sem_id fResponseSem;
80 bool fDevicePresent;
81 bool fUse48BitCommands;
82 uint32 fSectorSize;
83 uint64 fSectorCount;
84 bool fIsATAPI;
85 bool fTestUnitReadyActive;
86 bool fPortReset;
87 bool fError;
88 bool fTrimSupported;
89 uint32 fMaxTrimRangeBlocks;
91 volatile fis * fFIS;
92 volatile command_list_entry * fCommandList;
93 volatile command_table * fCommandTable;
94 volatile prd * fPRDTable;
98 inline void
99 AHCIPort::FlushPostedWrites()
101 volatile uint32 dummy = fRegs->cmd;
102 dummy = dummy;
106 #endif // _AHCI_PORT_H