]> git.saurik.com Git - apple/xnu.git/blame - iokit/Drivers/scsi/drvSymbios8xx/Sym8xxController.h
xnu-201.19.tar.gz
[apple/xnu.git] / iokit / Drivers / scsi / drvSymbios8xx / Sym8xxController.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/* Sym8xxController.h created by russb2 on Sat 30-May-1998 */
24
25#include <IOKit/IOMemoryCursor.h>
26#include <IOKit/pci/IOPCIDevice.h>
27#include <libkern/OSByteOrder.h>
28
29#include <IOKit/scsi/IOSCSIParallelInterface.h>
30
31#include "Sym8xxRegs.h"
32#include "Sym8xxInterface.h"
33#include "Sym8xxSRB.h"
34
35#include "Sym8xxScript.h"
36
37#define offsetof(type, field) ((int)&((type *)0)->field)
38
39class Sym8xxSCSIController : public IOSCSIParallelController
40{
41 OSDeclareDefaultStructors( Sym8xxSCSIController )
42
43private:
44
45 AdapterInterface *adapter;
46 AdapterInterface *adapterPhys;
47
48 UInt32 nexusArrayVirt[MAX_SCSI_TAG];
49
50 IOBigMemoryCursor *memoryCursor;
51
52 IOPCIDevice *provider;
53
54 IOInterruptEventSource *interruptEvent;
55
56 IOMemoryMap *ioMapRegs;
57 IOMemoryMap *ioMapRam;
58
59 UInt8 mailBoxIndex;
60
61 UInt32 initiatorID;
62
63 UInt8 istatReg;
64 UInt8 dstatReg;
65 u_int16_t sistReg;
66
67 UInt32 scriptRestartAddr;
68
69 UInt32 srbSeqNum;
70 UInt32 resetSeqNum;
71
72 SRB *resetSRB;
73 SRB *abortSRB;
74 SRB *abortCurrentSRB;
75 bool abortReqPending;
76 bool initialReset;
77
78 bool negotiateWDTRComplete;
79 bool negotiateSDTRComplete;
80
81 UInt32 transferPeriod;
82 UInt32 transferOffset;
83 UInt32 transferWidth;
84
85 UInt32 chipId;
86 UInt32 chipClockRate;
87
88 volatile UInt8 *chipBaseAddr;
89 UInt8 *chipBaseAddrPhys;
90
91 volatile UInt8 *chipRamAddr;
92 UInt8 *chipRamAddrPhys;
93
94public:
95 bool configure( IOService *forProvider, SCSIControllerInfo *controllerInfo );
96 void executeCommand( IOSCSIParallelCommand *scsiCommand );
97 void cancelCommand( IOSCSIParallelCommand *scsiCommand );
98 void resetCommand( IOSCSIParallelCommand *scsiCommand );
99
100private:
101 bool Sym8xxInit();
102 bool Sym8xxInitPCI();
103 bool Sym8xxInitVars();
104 bool Sym8xxInitScript();
105 void Sym8xxLoadScript( UInt32 *scriptPgm, UInt32 scriptWords );
106 bool Sym8xxInitChip();
107
108 void Sym8xxCalcMsgs( IOSCSIParallelCommand *scsiCommand );
109 void Sym8xxAbortCommand( IOSCSIParallelCommand *scsiCommand );
110
111 bool Sym8xxUpdateSGList( SRB *srb );
112 bool Sym8xxUpdateSGListVirt( SRB *srb );
113 bool Sym8xxUpdateSGListDesc( SRB *srb );
114
115 void Sym8xxStartSRB( SRB *srb );
116 void Sym8xxSignalScript( SRB *srb );
117 void interruptOccurred( IOInterruptEventSource *ies, int intCount );
118 void Sym8xxProcessIODone();
119 void Sym8xxCompleteSRB( SRB *srb );
120 void Sym8xxProcessInterrupt();
121 void Sym8xxAdjustDataPtrs( SRB *srb, Nexus *nexus );
122 UInt32 Sym8xxCheckFifo( SRB *srb, UInt32 *pfifoCnt );
123 void Sym8xxUpdateXferOffset( SRB *srb );
124 void Sym8xxProcessNoNexus();
125 void Sym8xxAbortCurrent( SRB *srb );
126 void Sym8xxClearFifo();
127 void Sym8xxNegotiateSDTR( SRB *srb, Nexus *nexus );
128 void Sym8xxNegotiateWDTR( SRB *srb, Nexus *nexus );
129 void Sym8xxSendMsgReject( SRB *srb );
130 void Sym8xxSCSIBusReset(SRB *srb );
131 void Sym8xxProcessSCSIBusReset();
132 void Sym8xxCheckRequestSense( SRB *srb );
133 void Sym8xxAbortBdr( SRB *srb );
134 bool Sym8xxCancelMailBox( Nexus *nexusCancel );
135 void Sym8xxCancelMailBox( UInt32 target, UInt32 lun, bool fReschedule );
136
137 void Sym8xxAbortScript();
138
139 UInt32 Sym8xxReadRegs( volatile UInt8 *chipRegs, UInt32 regOffset, UInt32 regSize );
140 void Sym8xxWriteRegs( volatile UInt8 *chipRegs, UInt32 regOffset, UInt32 regSize, UInt32 regValue );
141
142};
143