]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleCuda/AppleCuda.h
xnu-201.tar.gz
[apple/xnu.git] / iokit / Drivers / platform / drvAppleCuda / AppleCuda.h
1 /*
2 * Copyright (c) 1998-2000 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 * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
24 * All Rights Reserved
25 *
26 * Permission to use, copy, modify, and distribute this software and
27 * its documentation for any purpose and without fee is hereby granted,
28 * provided that the above copyright notice appears in all copies and
29 * that both the copyright notice and this permission notice appear in
30 * supporting documentation.
31 *
32 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
33 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE.
35 *
36 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
37 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
38 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
39 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
40 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41 *
42 */
43 /*
44 * Copyright 1996 1995 by Apple Computer, Inc. 1997 1996 1995 1994 1993 1992 1991
45 * All Rights Reserved
46 *
47 * Permission to use, copy, modify, and distribute this software and
48 * its documentation for any purpose and without fee is hereby granted,
49 * provided that the above copyright notice appears in all copies and
50 * that both the copyright notice and this permission notice appear in
51 * supporting documentation.
52 *
53 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
54 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
55 * FOR A PARTICULAR PURPOSE.
56 *
57 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
58 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
59 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
60 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
61 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
62 */
63 /*
64 * MKLINUX-1.0DR2
65 */
66
67 /* 1 April 1997 Simon Douglas:
68 * Stolen wholesale from MkLinux.
69 * Added nonblocking adb poll from interrupt level for the debugger.
70 * Acknowledge before response so polled mode can work from inside the adb handler.
71 *
72 * 18 June 1998 sdouglas
73 * Start IOKit version. Fix errors from kCudaSRQAssertMask. Use ool cmd & reply buffers,
74 * not fixed len in packet. Does queueing here.
75 *
76 * 20 Nov 1998 suurballe
77 * Port to C++
78 */
79
80 #ifndef APPLECUDA_H
81 #define APPLECUDA_H
82
83 #include <mach/mach_types.h>
84
85 #include <IOKit/IOService.h>
86
87 extern "C" {
88 #include <pexpert/pexpert.h>
89 }
90 #include <IOKit/IOLocks.h>
91 #include "AppleCudaCommands.h"
92 #include "AppleCudaHW.h"
93 #include <IOKit/adb/adb.h>
94 #include <IOKit/pwr_mgt/RootDomain.h>
95 #include <IOKit/IOTimerEventSource.h>
96
97 //
98 // CudaInterruptState - internal to CudaCore.c
99 //
100
101 enum CudaInterruptState
102 {
103 CUDA_STATE_INTERRUPT_LIMBO = -1, //
104 CUDA_STATE_IDLE = 0, //
105 CUDA_STATE_ATTN_EXPECTED = 1, //
106 CUDA_STATE_TRANSMIT_EXPECTED = 2, //
107 CUDA_STATE_RECEIVE_EXPECTED = 3 //
108 };
109
110 typedef enum CudaInterruptState CudaInterruptState;
111
112 //
113 // CudaTransactionFlag - internal to CudaCore.c
114 //
115
116 enum CudaTransactionFlag
117 {
118 CUDA_TS_NO_REQUEST = 0x0000,
119 CUDA_TS_SYNC_RESPONSE = 0x0001,
120 CUDA_TS_ASYNC_RESPONSE = 0x0002
121 };
122
123 typedef enum CudaTransactionFlag CudaTransactionFlag;
124
125 //typedef void (* ADB_input_func)(IOService * obj_id, UInt8 * buffer, UInt32 length, UInt8 command);
126
127 class IOCudaADBController;
128 class IOInterruptEventSource;
129 class IOWorkLoop;
130
131
132 class AppleCuda: public IOService
133 {
134 OSDeclareDefaultStructors(AppleCuda)
135
136 private:
137
138 IOService * cudaDevice;
139 IOWorkLoop * workLoop;
140 IOService * ADBid;
141 IOCudaADBController * ourADBinterface;
142 ADB_callback_func autopoll_handler;
143 UInt8 _cuda_power_state;
144 IOTimerEventSource * timerSrc;
145 bool _wakeup_from_sleep;
146 // callPlatformFunction symbols
147 const OSSymbol *cuda_check_any_interrupt;
148
149 // number of autopoll buffers between interrupt and thread
150 #define NUM_AP_BUFFERS (1<<3)
151 // max adb register size for autopoll
152 #define MAX_AP_RESPONSE (8)
153
154 unsigned char cuda_autopoll_buffers[ NUM_AP_BUFFERS ]
155 [ MAX_AP_RESPONSE ];
156 static void WakeupTimeoutHandler(OSObject *object, IOTimerEventSource *timer);
157
158 protected:
159
160 virtual void free( void );
161
162 public:
163
164 VIARegisterAddress cuda_via_regs;
165 bool cuda_polled_mode;
166 IOSimpleLock * cuda_request_lock;
167 volatile cuda_request_t * cuda_request; // head of todo queue
168 volatile cuda_request_t * cuda_last_request; // tail of todo queue
169 volatile CudaInterruptState cuda_interrupt_state;
170 volatile unsigned int inIndex;
171 volatile unsigned int outIndex;
172 volatile CudaTransactionFlag cuda_transaction_state;
173 cuda_packet_t cuda_unsolicited[ NUM_AP_BUFFERS ];
174 bool cuda_is_header_transfer;
175 int cuda_transfer_count;
176 IOInterruptEventSource * eventSrc;
177 cuda_packet_t * cuda_current_response;
178 bool cuda_is_packet_type;
179 AbsoluteTime cuda_state_transition_delay;
180 IOPMrootDomain * _rootDomain;
181
182 bool init ( OSDictionary * properties = 0 );
183 bool start ( IOService * );
184 virtual IOWorkLoop *getWorkLoop() const;
185 void serviceAutopolls ( void );
186 void registerForADBInterrupts ( ADB_callback_func handler, IOService * caller );
187 IOReturn doSyncRequest ( cuda_request_t * request );
188 IOReturn powerStateWillChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
189 IOReturn powerStateDidChangeTo ( IOPMPowerFlags, unsigned long, IOService*);
190 void setWakeTime(UInt32 waketime);
191 void setPowerOnTime(UInt32 newTime);
192 void setFileServerMode(bool fileServerModeON);
193 void demandSleepNow(void);
194 IOReturn newUserClient(task_t owningTask, void*, // Security id (?!)
195 UInt32 type, // Magic number
196 IOUserClient **handler);
197
198 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
199 bool waitForFunction,
200 void *param1, void *param2,
201 void *param3, void *param4);
202
203 };
204
205 #endif /* APPLECUDA_H */
206
207