1 | /******************************************************************************
|
---|
2 | * os2ahci.h - main header file for os2ahci driver
|
---|
3 | *
|
---|
4 | * Copyright (c) 2011 thi.guten Software Development
|
---|
5 | * Copyright (c) 2011 Mensys B.V.
|
---|
6 | *
|
---|
7 | * Authors: Christian Mueller, Markus Thielen
|
---|
8 | *
|
---|
9 | * Parts copied from/inspired by the Linux AHCI driver;
|
---|
10 | * those parts are (c) Linux AHCI/ATA maintainers
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | */
|
---|
26 |
|
---|
27 | /* ----------------------------- include files ----------------------------- */
|
---|
28 |
|
---|
29 | /* IMPORTANT NOTE: The DDK headers require tight structure packing and this
|
---|
30 | * is controlled via compiler parameters. Thus, all stuctures in os2ahci.sys
|
---|
31 | * are expected to be byte-aligned without the need of explicit pragma pack()
|
---|
32 | * directives. Where possible, the structures are layed out such that words
|
---|
33 | * and dwords are aligned at least on 2-byte boundaries.
|
---|
34 | */
|
---|
35 |
|
---|
36 | #define INCL_NOPMAPI
|
---|
37 | #define INCL_DOSINFOSEG
|
---|
38 | #define INCL_NO_SCB
|
---|
39 | #define INCL_DOSERRORS
|
---|
40 | #include <os2.h>
|
---|
41 | #include <dos.h>
|
---|
42 | #include <bseerr.h>
|
---|
43 | #include <dskinit.h>
|
---|
44 | #include <scb.h>
|
---|
45 |
|
---|
46 | #include <devhdr.h>
|
---|
47 | #include <iorb.h>
|
---|
48 | #include <strat2.h>
|
---|
49 | #include <reqpkt.h>
|
---|
50 |
|
---|
51 | #ifdef __WATCOMC__
|
---|
52 | /* include WATCOM specific DEVHELP stubs */
|
---|
53 | #include <devhelp.h>
|
---|
54 | #else
|
---|
55 | #include <dhcalls.h>
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #include <addcalls.h>
|
---|
59 | #include <rmcalls.h>
|
---|
60 | #include <devclass.h>
|
---|
61 | #include <devcmd.h>
|
---|
62 | #include <rmbase.h>
|
---|
63 |
|
---|
64 | #include "ahci.h"
|
---|
65 | #include "version.h"
|
---|
66 |
|
---|
67 | /* -------------------------- macros and constants ------------------------- */
|
---|
68 |
|
---|
69 | #define MAX_AD 8 /* maximum number of adapters */
|
---|
70 |
|
---|
71 | /* Timer pool size. In theory, we need one timer per outstanding command plus
|
---|
72 | * a few miscellaneous timers but it's unlikely we'll ever have outstanding
|
---|
73 | * commands on all devices on all ports on all apapters -- this would be
|
---|
74 | * 8 * 32 * 32 = 8192 outstanding commands on a maximum of 8 * 32 * 15 = 3840
|
---|
75 | * devices and that's a bit of an exaggeration. It should be more than enough
|
---|
76 | * to have 128 timers.
|
---|
77 | */
|
---|
78 | #define TIMER_COUNT 128
|
---|
79 | #define TIMER_POOL_SIZE (sizeof(ADD_TIMER_POOL) + \
|
---|
80 | TIMER_COUNT * sizeof(ADD_TIMER_DATA))
|
---|
81 |
|
---|
82 | /* default command timeout (can be overwritten in the IORB) */
|
---|
83 | #define DEFAULT_TIMEOUT 30000
|
---|
84 |
|
---|
85 | /* Maximum number of retries for commands in the restart/reset context hooks.
|
---|
86 | *
|
---|
87 | * Please note that the corresponding variable in the ADD workspace is a bit
|
---|
88 | * field, thus increasing this value means increasing the size of the bit
|
---|
89 | * field. At the time of writing this comment the 'retries' variable was 2
|
---|
90 | * bits wide (i.e. a maximum number of 3 retries) and there was exactly one
|
---|
91 | * bit left before the ADD workspace structure would become too large...
|
---|
92 | */
|
---|
93 | #define MAX_RETRIES 3
|
---|
94 |
|
---|
95 | /* max/min macros */
|
---|
96 | #define max(a, b) (a) > (b) ? (a) : (b)
|
---|
97 | #define min(a, b) (a) < (b) ? (a) : (b)
|
---|
98 |
|
---|
99 | /* debug output macros */
|
---|
100 | #define dprintf if (debug > 0) printf
|
---|
101 | #define dphex if (debug > 0) phex
|
---|
102 | #define ddprintf if (debug > 1) printf
|
---|
103 | #define ddphex if (debug > 1) phex
|
---|
104 | #define dddprintf if (debug > 2) printf
|
---|
105 | #define dddphex if (debug > 2) phex
|
---|
106 |
|
---|
107 | /* TRACE macros (for our internal ring buffer trace) */
|
---|
108 | #define TRACE_ACTIVE (debug > 0 && com_base == 0)
|
---|
109 |
|
---|
110 | /* adapter number from AD_INFO pointer; mainly for dprintf() purposes */
|
---|
111 | #define ad_no(ai) (((u16) ai - (u16) ad_infos) / sizeof(*ai))
|
---|
112 |
|
---|
113 | /* Convert far function address into NPFN (the DDK needs this all over the
|
---|
114 | * place and just casting to NPFN will produce a "segment lost in conversion"
|
---|
115 | * warning. Since casting to a u32 is a bit nasty for function pointers and
|
---|
116 | * might have to be revised for different compilers, we'll use a central
|
---|
117 | * macro for this crap.
|
---|
118 | */
|
---|
119 | #define mk_NPFN(func) (NPFN) (u32) (func)
|
---|
120 |
|
---|
121 | /* stdarg.h macros with explicit far pointers
|
---|
122 | *
|
---|
123 | * NOTE: The compiler pushes fixed arguments with 16 bits minimum, thus
|
---|
124 | * the last fixed argument (i.e. the one passed to va_start) must
|
---|
125 | * have at least 16 bits. Otherwise, the address calculation in
|
---|
126 | * va_start() will fail.
|
---|
127 | */
|
---|
128 | typedef char _far *va_list;
|
---|
129 | #define va_start(va, last) va = (va_list) (&last + 1)
|
---|
130 | #define va_arg(va, type) ((type _far *) (va += sizeof(type)))[-1]
|
---|
131 | #define va_end(va) va = 0
|
---|
132 |
|
---|
133 | /* ctype macros */
|
---|
134 | #define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
|
---|
135 | #define tolower(ch) (isupper(ch) ? (ch) + ('a' - 'A') : (ch))
|
---|
136 |
|
---|
137 | /* stddef macros */
|
---|
138 | #define offsetof(s, e) ((u16) &((s *) 0)->e)
|
---|
139 |
|
---|
140 | /* SMP spinlock compatibility macros for older DDKs using CLI/STI */
|
---|
141 | #ifndef OS2AHCI_SMP
|
---|
142 | #define DevHelp_CreateSpinLock(p_sph) *(p_sph) = 0
|
---|
143 | #define DevHelp_FreeSpinLock(sph) 0
|
---|
144 |
|
---|
145 | #define DevHelp_AquireSpinLock(sph) if ((sph) != 0) \
|
---|
146 | panic("recursive spinlock"); \
|
---|
147 | (sph) = disable()
|
---|
148 |
|
---|
149 | #define DevHelp_ReleaseSpinLock(sph) if (sph) { \
|
---|
150 | (sph) = 0; \
|
---|
151 | enable(); \
|
---|
152 | }
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | /* shortcut macros */
|
---|
156 | #define spin_lock(sl) DevHelp_AquireSpinLock(sl)
|
---|
157 | #define spin_unlock(sl) DevHelp_ReleaseSpinLock(sl)
|
---|
158 |
|
---|
159 | /* Get AHCI port MMIO base from AD_INFO and port number. For the time being,
|
---|
160 | * MMIO addresses are assumed to be valid 16:16 pointers which implies
|
---|
161 | * that one GDT selector is allocated per adapter.
|
---|
162 | */
|
---|
163 | #define port_base(ai, p) ((u8 _far *) (ai)->mmio + 0x100 + (p) * 0x80)
|
---|
164 |
|
---|
165 | /* Get address of port-specific DMA scratch buffer. The total size of all DMA
|
---|
166 | * buffers required for 32 ports exceeds 65536 bytes, thus we need multiple
|
---|
167 | * GDT selectors to access all port DMA scratch buffers and some logic to map
|
---|
168 | * a port number to the corresponding DMA scratch buffer address.
|
---|
169 | */
|
---|
170 | #define PORT_DMA_BUFS_PER_SEG ((size_t) (65536UL / AHCI_PORT_PRIV_DMA_SZ))
|
---|
171 | #define PORT_DMA_BUF_SEGS ((AHCI_MAX_PORTS + PORT_DMA_BUFS_PER_SEG - 1) \
|
---|
172 | / PORT_DMA_BUFS_PER_SEG)
|
---|
173 | #define PORT_DMA_SEG_SIZE ((u32) PORT_DMA_BUFS_PER_SEG * \
|
---|
174 | (u32) AHCI_PORT_PRIV_DMA_SZ)
|
---|
175 |
|
---|
176 | #define port_dma_base(ai, p) \
|
---|
177 | ((AHCI_PORT_DMA _far *) ((ai)->dma_buf[(p) / PORT_DMA_BUFS_PER_SEG] + \
|
---|
178 | ((p) % PORT_DMA_BUFS_PER_SEG) * AHCI_PORT_PRIV_DMA_SZ))
|
---|
179 |
|
---|
180 | #define port_dma_base_phys(ai, p) \
|
---|
181 | ((ai)->dma_buf_phys + (u32) (p) * AHCI_PORT_PRIV_DMA_SZ)
|
---|
182 |
|
---|
183 | /* Convert an SATA adapter/port/device address into a 16-bit IORB unit handle
|
---|
184 | * (and the other way round). The mapping looks like this:
|
---|
185 | *
|
---|
186 | * mapping comment
|
---|
187 | * -----------------------------------------------------------------------
|
---|
188 | * 4 bits for the adapter current max is 8 adapters
|
---|
189 | * 4 bits for the port AHCI spec defines up to 32 ports
|
---|
190 | * 4 bits for the device SATA spec defines up to 15 devices behind PMP
|
---|
191 | */
|
---|
192 | #define iorb_unit(a, p, d) ((((u16) (a) & 0x0fU) << 8) | \
|
---|
193 | (((u16) (p) & 0x0fU) << 4) | \
|
---|
194 | (((u16) (d) & 0x0fU)))
|
---|
195 | #define iorb_unit_adapter(iorb) (((u16) (iorb)->UnitHandle >> 8) & 0x07U)
|
---|
196 | #define iorb_unit_port(iorb) (((u16) (iorb)->UnitHandle >> 4) & 0x0fU)
|
---|
197 | #define iorb_unit_device(iorb) ((u16) (iorb)->UnitHandle & 0x0fU)
|
---|
198 |
|
---|
199 | /*******************************************************************************
|
---|
200 | * Convenience macros for IORB processing functions
|
---|
201 | */
|
---|
202 | /* is this IORB on driver or port level? */
|
---|
203 | #define iorb_driver_level(iorb) ((iorb)->CommandCode == IOCC_CONFIGURATION)
|
---|
204 |
|
---|
205 | /* is this IORB to be inserted at the beginnig of the IORB queue? */
|
---|
206 | #define iorb_priority(iorb) ((iorb)->CommandCode == IOCC_DEVICE_CONTROL && \
|
---|
207 | (iorb)->CommandModifier == IOCM_ABORT))
|
---|
208 |
|
---|
209 | /* access IORB ADD workspace */
|
---|
210 | #define add_workspace(iorb) ((ADD_WORKSPACE _far *) &(iorb)->ADDWorkSpace)
|
---|
211 |
|
---|
212 |
|
---|
213 |
|
---|
214 | /******************************************************************************
|
---|
215 | * PCI generic IDs and macros
|
---|
216 | */
|
---|
217 | #define PCI_ANY_ID 0xffffU
|
---|
218 | #define PCI_VDEVICE(vendor, device) PCI_VENDOR_ID_##vendor, (device), \
|
---|
219 | PCI_ANY_ID, PCI_ANY_ID, 0, 0
|
---|
220 |
|
---|
221 | /******************************************************************************
|
---|
222 | * PCI vendor IDs for AHCI adapters known to this driver (copied from Linux
|
---|
223 | * pci_ids.h)
|
---|
224 | */
|
---|
225 | #define PCI_VENDOR_ID_AL 0x10b9
|
---|
226 | #define PCI_VENDOR_ID_AMD 0x1022
|
---|
227 | #define PCI_VENDOR_ID_AT 0x1259
|
---|
228 | #define PCI_VENDOR_ID_ATI 0x1002
|
---|
229 | #define PCI_VENDOR_ID_ATT 0x11c1
|
---|
230 | #define PCI_VENDOR_ID_CMD 0x1095
|
---|
231 | #define PCI_VENDOR_ID_CT 0x102c
|
---|
232 | #define PCI_VENDOR_ID_INTEL 0x8086
|
---|
233 | #define PCI_VENDOR_ID_INITIO 0x1101
|
---|
234 | #define PCI_VENDOR_ID_JMICRON 0x197B
|
---|
235 | #define PCI_VENDOR_ID_MARVELL 0x11ab
|
---|
236 | #define PCI_VENDOR_ID_NVIDIA 0x10de
|
---|
237 | #define PCI_VENDOR_ID_PROMISE 0x105a
|
---|
238 | #define PCI_VENDOR_ID_SI 0x1039
|
---|
239 | #define PCI_VENDOR_ID_VIA 0x1106
|
---|
240 |
|
---|
241 | /******************************************************************************
|
---|
242 | * PCI class IDs we're interested in (copied from Linux pci_ids.h)
|
---|
243 | */
|
---|
244 | #define PCI_BASE_CLASS_STORAGE 0x01
|
---|
245 | #define PCI_CLASS_STORAGE_SCSI 0x0100
|
---|
246 | #define PCI_CLASS_STORAGE_IDE 0x0101
|
---|
247 | #define PCI_CLASS_STORAGE_FLOPPY 0x0102
|
---|
248 | #define PCI_CLASS_STORAGE_IPI 0x0103
|
---|
249 | #define PCI_CLASS_STORAGE_RAID 0x0104
|
---|
250 | #define PCI_CLASS_STORAGE_SATA 0x0106
|
---|
251 | #define PCI_CLASS_STORAGE_SATA_AHCI 0x010601
|
---|
252 | #define PCI_CLASS_STORAGE_SAS 0x0107
|
---|
253 | #define PCI_CLASS_STORAGE_OTHER 0x0180
|
---|
254 |
|
---|
255 | /******************************************************************************
|
---|
256 | * ANSI color code constants
|
---|
257 | */
|
---|
258 | #define ANSI_CLR_BRIGHT "\x1b[1m"
|
---|
259 | #define ANSI_CLR_RED "\x1b[31m"
|
---|
260 | #define ANSI_CLR_GREEN "\x1b[32m"
|
---|
261 | #define ANSI_CLR_BLUE "\x1b[34m"
|
---|
262 | #define ANSI_CLR_CYAN "\x1b[36m"
|
---|
263 | #define ANSI_CLR_WHITE "\x1b[37m"
|
---|
264 | #define ANSI_RESET "\x1b[0m"
|
---|
265 |
|
---|
266 |
|
---|
267 | /* ------------------------ typedefs and structures ------------------------ */
|
---|
268 |
|
---|
269 | typedef unsigned int size_t;
|
---|
270 |
|
---|
271 | /* PCI device information structure; this is used both for scanning and for
|
---|
272 | * identification purposes in 'AD_INFO'; based on the Linux pci_device_id
|
---|
273 | * structure but hard-wired to use board_* constants for 'driver_data'
|
---|
274 | */
|
---|
275 | typedef struct {
|
---|
276 | u16 vendor; /* PCI device vendor/manufacturer */
|
---|
277 | u16 device; /* PCI device ID inside vendor scope */
|
---|
278 | u16 subvendor; /* subsystem vendor (unused so far) */
|
---|
279 | u16 subdevice; /* subsystem device (unused so far) */
|
---|
280 | u32 class; /* PCI device class */
|
---|
281 | u32 class_mask; /* bits to match when scanning for 'class' */
|
---|
282 | u32 board; /* AHCI controller board type (board_* constants) */
|
---|
283 | char *chipname; /* human readable chip ID string */
|
---|
284 | } PCI_ID;
|
---|
285 |
|
---|
286 | /* IORB queue; since IORB queues are updated at interrupt time, the
|
---|
287 | * corresponding pointers (not the data they point to) need to be volatile.
|
---|
288 | */
|
---|
289 | typedef struct {
|
---|
290 | IORBH _far *volatile root; /* root of request list */
|
---|
291 | IORBH _far *volatile tail; /* tail of request list */
|
---|
292 | } IORB_QUEUE;
|
---|
293 |
|
---|
294 | /* port information structure */
|
---|
295 | typedef struct {
|
---|
296 | IORB_QUEUE iorb_queue; /* IORB queue for this port */
|
---|
297 | unsigned dev_max : 4; /* maximum device number on this port (0-15) */
|
---|
298 | unsigned cmd_slot : 5; /* current command slot index (using round-
|
---|
299 | * robin indexes to prevent starvation) */
|
---|
300 |
|
---|
301 | volatile u32 ncq_cmds; /* bitmap for NCQ commands issued */
|
---|
302 | volatile u32 reg_cmds; /* bitmap for regular commands issued */
|
---|
303 |
|
---|
304 | struct {
|
---|
305 | unsigned allocated : 1; /* if != 0, device is allocated */
|
---|
306 | unsigned present : 1; /* if != 0, device is present */
|
---|
307 | unsigned lba48 : 1; /* if != 0, device supports 48-bit LBA */
|
---|
308 | unsigned atapi : 1; /* if != 0, this is an ATAPI device */
|
---|
309 | unsigned atapi_16 : 1; /* if != 0, device suports 16-byte cmds */
|
---|
310 | unsigned removable : 1; /* if != 0, device has removable media */
|
---|
311 | unsigned dev_type : 5; /* device type (UIB_TYPE_* in iorb.h) */
|
---|
312 | unsigned ncq_max : 5; /* maximum tag number for queued commands */
|
---|
313 | UNITINFO _far *unit_info; /* pointer to modified unit info */
|
---|
314 | } devs[15];
|
---|
315 | } P_INFO;
|
---|
316 |
|
---|
317 | /* adapter information structure */
|
---|
318 | typedef struct {
|
---|
319 | PCI_ID *pci; /* pointer to corresponding PCI ID */
|
---|
320 |
|
---|
321 | unsigned port_max : 5; /* maximum port number (0-31) */
|
---|
322 | unsigned cmd_max : 5; /* maximum cmd slot number (0-31) */
|
---|
323 | unsigned port_scan_done : 1; /* if != 0, port scan already done */
|
---|
324 | unsigned busy : 1; /* if != 0, adapter is busy */
|
---|
325 |
|
---|
326 | u32 port_map; /* bitmap of active ports */
|
---|
327 |
|
---|
328 | /* initial adapter configuration from BIOS */
|
---|
329 | u32 bios_config[HOST_CAP2 / sizeof(u32) + 1];
|
---|
330 |
|
---|
331 | u32 cap; /* working copy of CAP register */
|
---|
332 | u32 cap2; /* working copy of CAP2 register */
|
---|
333 | u32 flags; /* adapter flags */
|
---|
334 |
|
---|
335 | HRESOURCE rm_adh; /* resource handle for adapter */
|
---|
336 | HRESOURCE rm_bars[6]; /* resource handle for MMIO and I/O BARs */
|
---|
337 | HRESOURCE rm_irq; /* resource handle for IRQ */
|
---|
338 |
|
---|
339 | u8 bus; /* PCI bus number */
|
---|
340 | u8 dev_func; /* PCI device and function number */
|
---|
341 | u16 irq; /* interrupt number */
|
---|
342 |
|
---|
343 | u32 mmio_phys; /* physical address of MMIO region */
|
---|
344 | u32 mmio_size; /* size of MMIO region */
|
---|
345 | u8 _far *mmio; /* pointer to this adapter's MMIO region */
|
---|
346 |
|
---|
347 | u32 dma_buf_phys; /* physical address of DMA scratch buffer */
|
---|
348 | u8 _far *dma_buf[PORT_DMA_BUF_SEGS]; /* DMA scatch buffer */
|
---|
349 |
|
---|
350 | P_INFO ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */
|
---|
351 | } AD_INFO;
|
---|
352 |
|
---|
353 | /* ADD workspace in IORB (must not exceed 16 bytes) */
|
---|
354 | typedef struct {
|
---|
355 | void (*ppfunc)(IORBH _far *iorb); /* post-processing function */
|
---|
356 | void *buf; /* response buffer (e.g. for identify cmds) */
|
---|
357 | ULONG timer; /* timer for timeout procesing */
|
---|
358 | USHORT blocks; /* number of blocks to be transferred */
|
---|
359 | unsigned processing : 1; /* IORB is being processd */
|
---|
360 | unsigned idempotent : 1; /* IORB is idempotent (can be retried) */
|
---|
361 | unsigned queued_hw : 1; /* IORB has been queued to hardware */
|
---|
362 | unsigned no_ncq : 1; /* must not use native command queuing */
|
---|
363 | unsigned is_ncq : 1; /* should use native command queueing */
|
---|
364 | unsigned complete : 1; /* IORB has completed processing */
|
---|
365 | unsigned unaligned : 1; /* unaligned S/G; need to use transfer buffer */
|
---|
366 | unsigned retries : 2; /* number of retries for this command */
|
---|
367 | unsigned cmd_slot : 5; /* AHCI command slot for this IORB */
|
---|
368 | } ADD_WORKSPACE;
|
---|
369 |
|
---|
370 | /* sg_memcpy() direction */
|
---|
371 | typedef enum {
|
---|
372 | SG_TO_BUF, /* copy from S/G list to buffer */
|
---|
373 | BUF_TO_SG /* copy from buffer to S/G list */
|
---|
374 | } SG_MEMCPY_DIRECTION;
|
---|
375 |
|
---|
376 | /* -------------------------- function prototypes -------------------------- */
|
---|
377 |
|
---|
378 | /* init.asm */
|
---|
379 | extern u32 _cdecl readl (void _far *addr);
|
---|
380 | extern u32 _cdecl writel (void _far *addr, u32 val);
|
---|
381 | extern void _far * _cdecl memcpy (void _far *v_dst, void _far *v_src, int len);
|
---|
382 | extern void _far * _cdecl memset (void _far *p, int ch, size_t len);
|
---|
383 | extern void _cdecl _far restart_hook (void);
|
---|
384 | extern void _cdecl _far reset_hook (void);
|
---|
385 | extern void _cdecl _far engine_hook (void);
|
---|
386 |
|
---|
387 | /* os2ahci.c */
|
---|
388 | extern USHORT init_drv (RPINITIN _far *req);
|
---|
389 | extern USHORT gen_ioctl (RP_GENIOCTL _far *ioctl);
|
---|
390 | extern USHORT char_dev_input (RP_RWV _far *rwrb);
|
---|
391 | extern USHORT exit_drv (int func);
|
---|
392 | extern void _cdecl _far _loadds add_entry (IORBH _far *iorb);
|
---|
393 | extern void trigger_engine (void);
|
---|
394 | extern int trigger_engine_1 (void);
|
---|
395 | extern void send_iorb (IORBH _far *iorb);
|
---|
396 | extern void iocc_configuration (IORBH _far *iorb);
|
---|
397 | extern void iocc_device_control (IORBH _far *iorb);
|
---|
398 | extern void iocc_unit_control (IORBH _far *iorb);
|
---|
399 | extern void iocm_device_table (IORBH _far *iorb);
|
---|
400 | extern void iocc_geometry (IORBH _far *iorb);
|
---|
401 | extern void iocc_execute_io (IORBH _far *iorb);
|
---|
402 | extern void iocc_unit_status (IORBH _far *iorb);
|
---|
403 | extern void iocc_adapter_passthru (IORBH _far *iorb);
|
---|
404 | extern void iorb_queue_add (IORB_QUEUE _far *queue, IORBH _far *iorb);
|
---|
405 | extern int iorb_queue_del (IORB_QUEUE _far *queue, IORBH _far *iorb);
|
---|
406 | extern void iorb_seterr (IORBH _far *iorb, USHORT error_code);
|
---|
407 | extern void iorb_done (IORBH _far *iorb);
|
---|
408 | extern void iorb_complete (IORBH _far *iorb);
|
---|
409 | extern void iorb_requeue (IORBH _far *iorb);
|
---|
410 | extern void aws_free (ADD_WORKSPACE _far *aws);
|
---|
411 | extern void lock_adapter (AD_INFO *ai);
|
---|
412 | extern void unlock_adapter (AD_INFO *ai);
|
---|
413 | extern void _cdecl _far timeout_callback (ULONG timer_handle, ULONG p1, ULONG p2);
|
---|
414 | extern void _cdecl _far reset_watchdog (ULONG timer_handle, ULONG p1, ULONG p2);
|
---|
415 |
|
---|
416 | /* ahci.c */
|
---|
417 | extern int ahci_save_bios_config (AD_INFO *ai);
|
---|
418 | extern int ahci_restore_bios_config (AD_INFO *ai);
|
---|
419 | extern int ahci_restore_initial_config (AD_INFO *ai);
|
---|
420 | extern AHCI_PORT_CFG *ahci_save_port_config (AD_INFO *ai, int p);
|
---|
421 | extern void ahci_restore_port_config (AD_INFO *ai, int p,
|
---|
422 | AHCI_PORT_CFG *pc);
|
---|
423 | extern int ahci_enable_ahci (AD_INFO *ai);
|
---|
424 | extern int ahci_scan_ports (AD_INFO *ai);
|
---|
425 | extern int ahci_complete_init (AD_INFO *ai);
|
---|
426 | extern int ahci_reset_port (AD_INFO *ai, int p, int ei);
|
---|
427 | extern int ahci_start_port (AD_INFO *ai, int p, int ei);
|
---|
428 | extern void ahci_start_fis_rx (AD_INFO *ai, int p);
|
---|
429 | extern void ahci_start_engine (AD_INFO *ai, int p);
|
---|
430 | extern int ahci_stop_port (AD_INFO *ai, int p);
|
---|
431 | extern int ahci_stop_fis_rx (AD_INFO *ai, int p);
|
---|
432 | extern int ahci_stop_engine (AD_INFO *ai, int p);
|
---|
433 | extern int ahci_port_busy (AD_INFO *ai, int p);
|
---|
434 | extern void ahci_exec_iorb (IORBH _far *iorb, int ncq_capable,
|
---|
435 | int (*func)(IORBH _far *, int));
|
---|
436 | extern void ahci_exec_polled_iorb (IORBH _far *iorb,
|
---|
437 | int (*func)(IORBH _far *, int),
|
---|
438 | ULONG timeout);
|
---|
439 | extern int ahci_exec_polled_cmd (AD_INFO *ai, int p, int d,
|
---|
440 | int timeout, int cmd, ...);
|
---|
441 | extern int ahci_set_dev_idle (AD_INFO *ai, int p, int d, int idle);
|
---|
442 | extern int ahci_flush_cache (AD_INFO *ai, int p, int d);
|
---|
443 |
|
---|
444 | extern int ahci_intr (u16 irq);
|
---|
445 | extern void ahci_port_intr (AD_INFO *ai, int p);
|
---|
446 | extern void ahci_error_intr (AD_INFO *ai, int p, u32 irq_stat);
|
---|
447 |
|
---|
448 | extern void ahci_get_geometry (IORBH _far *iorb);
|
---|
449 | extern void ahci_unit_ready (IORBH _far *iorb);
|
---|
450 | extern void ahci_read (IORBH _far *iorb);
|
---|
451 | extern void ahci_verify (IORBH _far *iorb);
|
---|
452 | extern void ahci_write (IORBH _far *iorb);
|
---|
453 | extern void ahci_execute_cdb (IORBH _far *iorb);
|
---|
454 | extern void ahci_execute_ata (IORBH _far *iorb);
|
---|
455 |
|
---|
456 | /* libc.c */
|
---|
457 | extern void init_libc (void);
|
---|
458 | extern void init_com (void);
|
---|
459 | extern int vsprintf (char _far *buf, const char *fmt, va_list va);
|
---|
460 | extern int sprintf (char _far *buf, const char *fmt, ...);
|
---|
461 | extern void vfprintf (const char *fmt, va_list va);
|
---|
462 | extern void _cdecl printf (const char *fmt, ...);
|
---|
463 | extern void cprintf (const char *fmt, ...);
|
---|
464 | extern void phex (const void _far *p, int len, const char *fmt, ...);
|
---|
465 | extern size_t strlen (const char _far *s);
|
---|
466 | extern char _far *strcpy (char _far *dst, const char _far *src);
|
---|
467 | extern int memcmp (void _far *p1, void _far *p2, size_t len);
|
---|
468 | extern void sg_memcpy (SCATGATENTRY _far *sg_list, USHORT sg_cnt,
|
---|
469 | ULONG sg_off, void _far *buf, USHORT len,
|
---|
470 | SG_MEMCPY_DIRECTION dir);
|
---|
471 | extern long strtol (const char _far *buf,
|
---|
472 | const char _far * _far *ep, int base);
|
---|
473 | extern void *malloc (size_t len);
|
---|
474 | extern void free (void *ptr);
|
---|
475 | extern ULONG virt_to_phys (void _far *ptr);
|
---|
476 | extern void mdelay_cal (void);
|
---|
477 | extern void mdelay (u32 millies);
|
---|
478 | extern void msleep (u32 millies);
|
---|
479 | extern void panic (char *msg);
|
---|
480 | extern int disable (void);
|
---|
481 | extern void enable (void);
|
---|
482 |
|
---|
483 | /* trace.c */
|
---|
484 | extern void trace_init (void);
|
---|
485 | extern void trace_exit (void);
|
---|
486 | extern void trace_write (u8 _far *s, int len);
|
---|
487 | extern u16 trace_read (void _far *buf, u16 cb_buf);
|
---|
488 | extern u16 trace_bytes_avail(void);
|
---|
489 | extern u16 trace_char_dev(RP_RWV _far *rwrb);
|
---|
490 |
|
---|
491 | /* pci.c */
|
---|
492 | extern int add_pci_id (u16 vendor, u16 device);
|
---|
493 | extern void scan_pci_bus (void);
|
---|
494 | extern int pci_enable_int (UCHAR bus, UCHAR dev_func);
|
---|
495 | extern void pci_hack_virtualbox(void);
|
---|
496 | extern char *vendor_from_id (u16 vendor);
|
---|
497 | extern char *device_from_id (u16 device);
|
---|
498 |
|
---|
499 | /* ctxhook.c */
|
---|
500 | extern void _cdecl restart_ctxhook (ULONG parm);
|
---|
501 | extern void _cdecl reset_ctxhook (ULONG parm);
|
---|
502 | extern void _cdecl engine_ctxhook (ULONG parm);
|
---|
503 |
|
---|
504 | /* apm.c */
|
---|
505 | extern void apm_init (void);
|
---|
506 | extern void apm_suspend (void);
|
---|
507 | extern void apm_resume (void);
|
---|
508 |
|
---|
509 | /* ioctl.c */
|
---|
510 | extern USHORT ioctl_get_devlist (RP_GENIOCTL _far *ioctl);
|
---|
511 | extern USHORT ioctl_passthrough (RP_GENIOCTL _far *ioctl);
|
---|
512 |
|
---|
513 |
|
---|
514 | /* ---------------------------- global variables --------------------------- */
|
---|
515 |
|
---|
516 | extern char _cdecl end_of_data; /* label at the end of all data segments */
|
---|
517 | extern void _cdecl _near end_of_code(); /* label at the end of all code segments */
|
---|
518 |
|
---|
519 | extern int debug; /* if != 0, print debug messages to COM1 */
|
---|
520 | extern int thorough_scan; /* if != 0, perform thorough PCI scan */
|
---|
521 | extern int init_reset; /* if != 0, reset ports during init */
|
---|
522 | extern int verbosity; /* if != 0, show some info during boot */
|
---|
523 |
|
---|
524 | extern HDRIVER rm_drvh; /* resource manager driver handle */
|
---|
525 | extern USHORT add_handle; /* adapter device driver handle */
|
---|
526 | extern UCHAR timer_pool[]; /* timer pool */
|
---|
527 |
|
---|
528 | extern PCI_ID pci_ids[]; /* SATA adapter PCI IDs */
|
---|
529 | extern ULONG drv_lock; /* driver-level spinlock */
|
---|
530 | extern ULONG com_lock; /* debug log spinlock */
|
---|
531 | extern IORB_QUEUE driver_queue; /* driver-level IORB queue */
|
---|
532 | extern AD_INFO ad_infos[]; /* adapter information list */
|
---|
533 | extern int ad_info_cnt; /* number of entries in ad_infos[] */
|
---|
534 | extern u16 ad_ignore; /* bitmap with adapters to be ignored */
|
---|
535 | extern int init_complete; /* if != 0, initialization has completed */
|
---|
536 |
|
---|
537 | extern u16 com_base; /* debug COM port base address */
|
---|
538 |
|
---|
539 | /* port restart context hook and input data */
|
---|
540 | extern ULONG restart_ctxhook_h;
|
---|
541 | extern volatile u32 ports_to_restart[MAX_AD];
|
---|
542 |
|
---|
543 | /* port reset context hook and input data */
|
---|
544 | extern ULONG reset_ctxhook_h;
|
---|
545 | extern ULONG th_reset_watchdog;
|
---|
546 | extern volatile u32 ports_to_reset[MAX_AD];
|
---|
547 | extern IORB_QUEUE abort_queue;
|
---|
548 |
|
---|
549 | /* trigger engine context hook and input data */
|
---|
550 | extern ULONG engine_ctxhook_h;
|
---|
551 |
|
---|
552 | /* apapter/port-specific options saved when parsing the command line */
|
---|
553 | extern u8 emulate_scsi[MAX_AD][AHCI_MAX_PORTS];
|
---|
554 | extern u8 enable_ncq[MAX_AD][AHCI_MAX_PORTS];
|
---|
555 | extern u8 link_speed[MAX_AD][AHCI_MAX_PORTS];
|
---|
556 | extern u8 link_power[MAX_AD][AHCI_MAX_PORTS];
|
---|
557 | extern u8 track_size[MAX_AD][AHCI_MAX_PORTS];
|
---|
558 |
|
---|