source: trunk/src/os2ahci/os2ahci.h@ 156

Last change on this file since 156 was 156, checked in by David Azarewicz, 12 years ago

debugging updates

File size: 29.0 KB
Line 
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.add
31 * are expected to be byte-aligned without the need of explicit pragma pack()
32 * directives. Where possible, the structures are laid 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/* NOTE: (Rousseau)
52 * The regular dhcalls.h from $(DDK)\base\h also works.
53 * The devhelp.h from $(DDK)\base\h produces inline assembler errors.
54 * The modified devhelp.h from ..\include works OK and is used because it
55 * generates a slightly smaller driver image.
56 */
57#ifdef __WATCOMC__
58/* include WATCOM specific DEVHELP stubs */
59#include <devhelp.h>
60#else
61#include <dhcalls.h>
62#endif
63
64#include <addcalls.h>
65#include <rmcalls.h>
66#include <devclass.h>
67#include <devcmd.h>
68#include <rmbase.h>
69
70#include "ahci.h"
71#include "ahci-idc.h"
72
73/* -------------------------- macros and constants ------------------------- */
74
75#define MAX_AD 8 /* maximum number of adapters */
76
77/* Timer pool size. In theory, we need one timer per outstanding command plus
78 * a few miscellaneous timers but it's unlikely we'll ever have outstanding
79 * commands on all devices on all ports on all apapters -- this would be
80 * 8 * 32 * 32 = 8192 outstanding commands on a maximum of 8 * 32 * 15 = 3840
81 * devices and that's a bit of an exaggeration. It should be more than enough
82 * to have 128 timers.
83 */
84#define TIMER_COUNT 128
85#define TIMER_POOL_SIZE (sizeof(ADD_TIMER_POOL) + \
86 TIMER_COUNT * sizeof(ADD_TIMER_DATA))
87
88/* default command timeout (can be overwritten in the IORB) */
89#define DEFAULT_TIMEOUT 30000
90
91/* Maximum number of retries for commands in the restart/reset context hooks.
92 *
93 * Please note that the corresponding variable in the ADD workspace is a bit
94 * field, thus increasing this value means increasing the size of the bit
95 * field. At the time of writing this comment the 'retries' variable was 2
96 * bits wide (i.e. a maximum number of 3 retries) and there was exactly one
97 * bit left before the ADD workspace structure would become too large...
98 */
99#define MAX_RETRIES 3
100
101/* max/min macros */
102#define max(a, b) (a) > (b) ? (a) : (b)
103#define min(a, b) (a) < (b) ? (a) : (b)
104
105/* debug output macros */
106#define dprintf if (debug > 0) printf
107#define dphex if (debug > 0) phex
108#define ddprintf if (debug > 1) printf
109#define ddphex if (debug > 1) phex
110#define dddprintf if (debug > 2) printf
111#define dddphex if (debug > 2) phex
112
113/* verbosity console print macros
114 * (we use 'i' in ciprintf here to avoid name clash
115 * with vprintf-like funcs)
116 */
117#define ciprintf if (verbosity > 0) cprintf
118#define ciiprintf if (verbosity > 1) cprintf
119
120/* TRACE macros (for our internal ring buffer trace) */
121#define AHCI_TRACE_BUF_SIZE 0x8000U /* 32k */
122#define AHCI_INFO_BUF_SIZE 0x1000U /* 4k */
123#define TRACE_ACTIVE (debug > 0 && com_base == 0)
124
125/* adapter number from AD_INFO pointer; mainly for dprintf() purposes */
126#define ad_no(ai) (((u16) ai - (u16) ad_infos) / sizeof(*ai))
127
128/* Convert far function address into NPFN (the DDK needs this all over the
129 * place and just casting to NPFN will produce a "segment lost in conversion"
130 * warning. Since casting to a u32 is a bit nasty for function pointers and
131 * might have to be revised for different compilers, we'll use a central
132 * macro for this crap.
133 */
134#define mk_NPFN(func) (NPFN) (u32) (func)
135
136/* stdarg.h macros with explicit far pointers
137 *
138 * NOTE: The compiler pushes fixed arguments with 16 bits minimum, thus
139 * the last fixed argument (i.e. the one passed to va_start) must
140 * have at least 16 bits. Otherwise, the address calculation in
141 * va_start() will fail.
142 */
143typedef char _far *va_list;
144#define va_start(va, last) va = (va_list) (&last + 1)
145#define va_arg(va, type) ((type _far *) (va += sizeof(type)))[-1]
146#define va_end(va) va = 0
147
148/* ctype macros */
149#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
150#define tolower(ch) (isupper(ch) ? (ch) + ('a' - 'A') : (ch))
151
152/* stddef macros */
153#define offsetof(s, e) ((u16) &((s *) 0)->e)
154
155/* SMP spinlock compatibility macros for older DDKs using CLI/STI */
156#ifndef OS2AHCI_SMP
157#define DevHelp_CreateSpinLock(p_sph) *(p_sph) = 0
158#define DevHelp_FreeSpinLock(sph) 0
159
160#define DevHelp_AcquireSpinLock(sph) if ((sph) != 0) \
161 panic("recursive spinlock"); \
162 (sph) = disable()
163
164#define DevHelp_ReleaseSpinLock(sph) if (sph) { \
165 (sph) = 0; \
166 enable(); \
167 }
168#endif
169
170/* shortcut macros */
171#define spin_lock(sl) DevHelp_AcquireSpinLock(sl)
172#define spin_unlock(sl) DevHelp_ReleaseSpinLock(sl)
173
174/* Get AHCI port MMIO base from AD_INFO and port number. For the time being,
175 * MMIO addresses are assumed to be valid 16:16 pointers which implies
176 * that one GDT selector is allocated per adapter.
177 */
178#define port_base(ai, p) ((u8 _far *) (ai)->mmio + 0x100 + (p) * 0x80)
179
180/* Get address of port-specific DMA scratch buffer. The total size of all DMA
181 * buffers required for 32 ports exceeds 65536 bytes, thus we need multiple
182 * GDT selectors to access all port DMA scratch buffers and some logic to map
183 * a port number to the corresponding DMA scratch buffer address.
184 */
185#define PORT_DMA_BUFS_PER_SEG ((size_t) (65536UL / AHCI_PORT_PRIV_DMA_SZ))
186#define PORT_DMA_BUF_SEGS ((AHCI_MAX_PORTS + PORT_DMA_BUFS_PER_SEG - 1) \
187 / PORT_DMA_BUFS_PER_SEG)
188#define PORT_DMA_SEG_SIZE ((u32) PORT_DMA_BUFS_PER_SEG * \
189 (u32) AHCI_PORT_PRIV_DMA_SZ)
190
191#define port_dma_base(ai, p) \
192 ((AHCI_PORT_DMA _far *) ((ai)->dma_buf[(p) / PORT_DMA_BUFS_PER_SEG] + \
193 ((p) % PORT_DMA_BUFS_PER_SEG) * AHCI_PORT_PRIV_DMA_SZ))
194
195#define port_dma_base_phys(ai, p) \
196 ((ai)->dma_buf_phys + (u32) (p) * AHCI_PORT_PRIV_DMA_SZ)
197
198/* Convert an SATA adapter/port/device address into a 16-bit IORB unit handle
199 * (and the other way round). The mapping looks like this:
200 *
201 * mapping comment
202 * -----------------------------------------------------------------------
203 * 4 bits for the adapter current max is 8 adapters
204 * 4 bits for the port AHCI spec defines up to 32 ports
205 * 4 bits for the device SATA spec defines up to 15 devices behind PMP
206 */
207#define iorb_unit(a, p, d) ((((u16) (a) & 0x0fU) << 8) | \
208 (((u16) (p) & 0x0fU) << 4) | \
209 (((u16) (d) & 0x0fU)))
210#define iorb_unit_adapter(iorb) (((u16) (iorb)->UnitHandle >> 8) & 0x07U)
211#define iorb_unit_port(iorb) (((u16) (iorb)->UnitHandle >> 4) & 0x0fU)
212#define iorb_unit_device(iorb) ((u16) (iorb)->UnitHandle & 0x0fU)
213
214/*******************************************************************************
215 * Convenience macros for IORB processing functions
216 */
217/* is this IORB on driver or port level? */
218#define iorb_driver_level(iorb) ((iorb)->CommandCode == IOCC_CONFIGURATION)
219
220/* is this IORB to be inserted at the beginnig of the IORB queue? */
221#define iorb_priority(iorb) ((iorb)->CommandCode == IOCC_DEVICE_CONTROL && \
222 (iorb)->CommandModifier == IOCM_ABORT))
223
224/* access IORB ADD workspace */
225#define add_workspace(iorb) ((ADD_WORKSPACE _far *) &(iorb)->ADDWorkSpace)
226
227
228
229/******************************************************************************
230 * PCI generic IDs and macros
231 */
232#define PCI_ANY_ID 0xffffU
233#define PCI_VDEVICE(vendor, device) PCI_VENDOR_ID_##vendor, (device), \
234 PCI_ANY_ID, PCI_ANY_ID, 0, 0
235
236/******************************************************************************
237 * PCI vendor IDs for AHCI adapters known to this driver (copied from Linux
238 * pci_ids.h)
239 */
240#define PCI_VENDOR_ID_AL 0x10b9
241#define PCI_VENDOR_ID_AMD 0x1022
242#define PCI_VENDOR_ID_AT 0x1259
243#define PCI_VENDOR_ID_ATI 0x1002
244#define PCI_VENDOR_ID_ATT 0x11c1
245#define PCI_VENDOR_ID_CMD 0x1095
246#define PCI_VENDOR_ID_CT 0x102c
247#define PCI_VENDOR_ID_INTEL 0x8086
248#define PCI_VENDOR_ID_INITIO 0x1101
249#define PCI_VENDOR_ID_JMICRON 0x197B
250#define PCI_VENDOR_ID_MARVELL 0x11ab
251#define PCI_VENDOR_ID_NVIDIA 0x10de
252#define PCI_VENDOR_ID_PROMISE 0x105a
253#define PCI_VENDOR_ID_SI 0x1039
254#define PCI_VENDOR_ID_VIA 0x1106
255
256/******************************************************************************
257 * PCI class IDs we're interested in (copied from Linux pci_ids.h)
258 */
259#define PCI_BASE_CLASS_STORAGE 0x01
260#define PCI_CLASS_STORAGE_SCSI 0x0100
261#define PCI_CLASS_STORAGE_IDE 0x0101
262#define PCI_CLASS_STORAGE_FLOPPY 0x0102
263#define PCI_CLASS_STORAGE_IPI 0x0103
264#define PCI_CLASS_STORAGE_RAID 0x0104
265#define PCI_CLASS_STORAGE_SATA 0x0106
266#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601
267#define PCI_CLASS_STORAGE_SAS 0x0107
268#define PCI_CLASS_STORAGE_OTHER 0x0180
269
270/******************************************************************************
271 * ANSI color code constants
272 */
273#define ANSI_CLR_BRIGHT "\x1b[1m"
274#define ANSI_CLR_RED "\x1b[31m"
275#define ANSI_CLR_GREEN "\x1b[32m"
276#define ANSI_CLR_BLUE "\x1b[34m"
277#define ANSI_CLR_CYAN "\x1b[36m"
278#define ANSI_CLR_WHITE "\x1b[37m"
279#define ANSI_RESET "\x1b[0m"
280
281
282/* ------------------------ typedefs and structures ------------------------ */
283
284typedef unsigned int size_t;
285
286/* PCI device information structure; this is used both for scanning and for
287 * identification purposes in 'AD_INFO'; based on the Linux pci_device_id
288 * structure but hard-wired to use board_* constants for 'driver_data'
289 */
290typedef struct {
291 u16 vendor; /* PCI device vendor/manufacturer */
292 u16 device; /* PCI device ID inside vendor scope */
293 u16 subvendor; /* subsystem vendor (unused so far) */
294 u16 subdevice; /* subsystem device (unused so far) */
295 u32 class; /* PCI device class */
296 u32 class_mask; /* bits to match when scanning for 'class' */
297 u32 board; /* AHCI controller board type (board_* constants) */
298 char *chipname; /* human readable chip ID string */
299} PCI_ID;
300
301/* IORB queue; since IORB queues are updated at interrupt time, the
302 * corresponding pointers (not the data they point to) need to be volatile.
303 */
304typedef struct {
305 IORBH _far *volatile root; /* root of request list */
306 IORBH _far *volatile tail; /* tail of request list */
307} IORB_QUEUE;
308
309/* port information structure */
310typedef struct {
311 IORB_QUEUE iorb_queue; /* IORB queue for this port */
312 unsigned dev_max : 4; /* maximum device number on this port (0-15) */
313 unsigned cmd_slot : 5; /* current command slot index (using round-
314 * robin indexes to prevent starvation) */
315
316 volatile u32 ncq_cmds; /* bitmap for NCQ commands issued */
317 volatile u32 reg_cmds; /* bitmap for regular commands issued */
318
319 struct {
320 unsigned allocated : 1; /* if != 0, device is allocated */
321 unsigned present : 1; /* if != 0, device is present */
322 unsigned lba48 : 1; /* if != 0, device supports 48-bit LBA */
323 unsigned atapi : 1; /* if != 0, this is an ATAPI device */
324 unsigned atapi_16 : 1; /* if != 0, device suports 16-byte cmds */
325 unsigned removable : 1; /* if != 0, device has removable media */
326 unsigned dev_type : 5; /* device type (UIB_TYPE_* in iorb.h) */
327 unsigned ncq_max : 5; /* maximum tag number for queued commands */
328 UNITINFO _far *unit_info; /* pointer to modified unit info */
329 } devs[15];
330} P_INFO;
331
332/* adapter information structure */
333typedef struct {
334 PCI_ID *pci; /* pointer to corresponding PCI ID */
335
336 unsigned port_max : 5; /* maximum port number (0-31) */
337 unsigned cmd_max : 5; /* maximum cmd slot number (0-31) */
338 unsigned port_scan_done : 1; /* if != 0, port scan already done */
339 unsigned busy : 1; /* if != 0, adapter is busy */
340
341 u32 port_map; /* bitmap of active ports */
342
343 /* initial adapter configuration from BIOS */
344 u32 bios_config[HOST_CAP2 / sizeof(u32) + 1];
345
346 u32 cap; /* working copy of CAP register */
347 u32 cap2; /* working copy of CAP2 register */
348 u32 flags; /* adapter flags */
349
350 HRESOURCE rm_adh; /* resource handle for adapter */
351 HRESOURCE rm_bars[6]; /* resource handle for MMIO and I/O BARs */
352 HRESOURCE rm_irq; /* resource handle for IRQ */
353
354 u8 bus; /* PCI bus number */
355 u8 dev_func; /* PCI device and function number */
356 u16 irq; /* interrupt number */
357
358 u32 mmio_phys; /* physical address of MMIO region */
359 u32 mmio_size; /* size of MMIO region */
360 u8 _far *mmio; /* pointer to this adapter's MMIO region */
361
362 u32 dma_buf_phys; /* physical address of DMA scratch buffer */
363 u8 _far *dma_buf[PORT_DMA_BUF_SEGS]; /* DMA scatch buffer */
364
365 P_INFO ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */
366} AD_INFO;
367
368/* ADD workspace in IORB (must not exceed 16 bytes) */
369typedef struct {
370 void (*ppfunc)(IORBH _far *iorb); /* post-processing function */
371 void *buf; /* response buffer (e.g. for identify cmds) */
372 ULONG timer; /* timer for timeout procesing */
373 USHORT blocks; /* number of blocks to be transferred */
374 unsigned processing : 1; /* IORB is being processd */
375 unsigned idempotent : 1; /* IORB is idempotent (can be retried) */
376 unsigned queued_hw : 1; /* IORB has been queued to hardware */
377 unsigned no_ncq : 1; /* must not use native command queuing */
378 unsigned is_ncq : 1; /* should use native command queueing */
379 unsigned complete : 1; /* IORB has completed processing */
380 unsigned unaligned : 1; /* unaligned S/G; need to use transfer buffer */
381 unsigned retries : 2; /* number of retries for this command */
382 unsigned cmd_slot : 5; /* AHCI command slot for this IORB */
383} ADD_WORKSPACE;
384
385/* sg_memcpy() direction */
386typedef enum {
387 SG_TO_BUF, /* copy from S/G list to buffer */
388 BUF_TO_SG /* copy from buffer to S/G list */
389} SG_MEMCPY_DIRECTION;
390
391/* Define the size of a disk name. Disk Names are user defined names given to physical disk drives in the system. */
392#define DLA_TABLE_SIGNATURE1 0x424D5202L
393#define DLA_TABLE_SIGNATURE2 0x44464D50L
394#define DISK_NAME_SIZE 20
395
396typedef struct _DLA_Table_Sector { /* DTS */
397 ULONG DLA_Signature1; /* The magic signature (part 1) of a Drive Letter Assignment Table. */
398 ULONG DLA_Signature2; /* The magic signature (part 2) of a Drive Letter Assignment Table. */
399 ULONG DLA_CRC; /* The 32 bit CRC for this sector. Calculated assuming that this field and all unused space in the sector is 0. */
400 ULONG Disk_Serial_Number; /* The serial number assigned to this disk. */
401 ULONG Boot_Disk_Serial_Number;/* The serial number of the disk used to boot the system. This is for conflict resolution when multiple volumes
402 want the same drive letter. Since LVM.EXE will not let this situation happen, the only way to get this situation
403 is for the disk to have been altered by something other than LVM.EXE, or if a disk drive has been moved from one
404 machine to another. If the drive has been moved, then it should have a different Boot_Disk_Serial_Number. Thus,
405 we can tell which disk drive is the "foreign" drive and therefore reject its claim for the drive letter in question.
406 If we find that all of the claimaints have the same Boot_Disk_Serial_Number, then we must assign drive letters on
407 a first come, first serve basis. */
408 ULONG Install_Flags; /* Used by the Install program. */
409 ULONG Cylinders;
410 ULONG Heads_Per_Cylinder;
411 ULONG Sectors_Per_Track;
412 char Disk_Name[DISK_NAME_SIZE]; /* The name assigned to the disk containing this sector. */
413 UCHAR Reboot; /* For use by Install. Used to keep track of reboots initiated by install. */
414 BYTE Reserved[3]; /* Alignment. */
415 /* These are the four entries which correspond to the entries in the partition table. */
416} DLA_Table_Sector, *PDLA_Table_Sector;
417
418/* -------------------------- function prototypes -------------------------- */
419
420/* init.asm */
421extern u32 _cdecl readl (void _far *addr);
422extern u32 _cdecl writel (void _far *addr, u32 val);
423extern void _far * _cdecl memcpy (void _far *v_dst, void _far *v_src, int len);
424extern void _far * _cdecl memset (void _far *p, int ch, size_t len);
425extern void _cdecl _far restart_hook (void);
426extern void _cdecl _far reset_hook (void);
427extern void _cdecl _far engine_hook (void);
428extern void _cdecl _far asm_krnl_exit (void);
429
430/* os2ahci.c */
431extern USHORT init_drv (RPINITIN _far *req);
432extern USHORT gen_ioctl (RP_GENIOCTL _far *ioctl);
433extern USHORT char_dev_input (RP_RWV _far *rwrb);
434extern USHORT exit_drv (int func);
435extern USHORT sr_drv (int func);
436extern void _cdecl _far _loadds add_entry (IORBH _far *iorb);
437extern void trigger_engine (void);
438extern int trigger_engine_1 (void);
439extern void send_iorb (IORBH _far *iorb);
440extern void iocc_configuration (IORBH _far *iorb);
441extern void iocc_device_control (IORBH _far *iorb);
442extern void iocc_unit_control (IORBH _far *iorb);
443extern void iocm_device_table (IORBH _far *iorb);
444extern void iocc_geometry (IORBH _far *iorb);
445extern void iocc_execute_io (IORBH _far *iorb);
446extern void iocc_unit_status (IORBH _far *iorb);
447extern void iocc_adapter_passthru (IORBH _far *iorb);
448extern void iorb_queue_add (IORB_QUEUE _far *queue, IORBH _far *iorb);
449extern int iorb_queue_del (IORB_QUEUE _far *queue, IORBH _far *iorb);
450extern void iorb_seterr (IORBH _far *iorb, USHORT error_code);
451extern void iorb_done (IORBH _far *iorb);
452extern void iorb_complete (IORBH _far *iorb);
453extern void iorb_requeue (IORBH _far *iorb);
454extern void aws_free (ADD_WORKSPACE _far *aws);
455extern void lock_adapter (AD_INFO *ai);
456extern void unlock_adapter (AD_INFO *ai);
457extern void _cdecl _far timeout_callback (ULONG timer_handle, ULONG p1, ULONG p2);
458extern void _cdecl _far reset_watchdog (ULONG timer_handle, ULONG p1, ULONG p2);
459
460/* ahci.c */
461extern int ahci_save_bios_config (AD_INFO *ai);
462extern int ahci_restore_bios_config (AD_INFO *ai);
463extern int ahci_restore_initial_config (AD_INFO *ai);
464extern AHCI_PORT_CFG *ahci_save_port_config (AD_INFO *ai, int p);
465extern void ahci_restore_port_config (AD_INFO *ai, int p,
466 AHCI_PORT_CFG *pc);
467extern int ahci_enable_ahci (AD_INFO *ai);
468extern int ahci_scan_ports (AD_INFO *ai);
469extern int ahci_complete_init (AD_INFO *ai);
470extern int ahci_reset_port (AD_INFO *ai, int p, int ei);
471extern int ahci_start_port (AD_INFO *ai, int p, int ei);
472extern void ahci_start_fis_rx (AD_INFO *ai, int p);
473extern void ahci_start_engine (AD_INFO *ai, int p);
474extern int ahci_stop_port (AD_INFO *ai, int p);
475extern int ahci_stop_fis_rx (AD_INFO *ai, int p);
476extern int ahci_stop_engine (AD_INFO *ai, int p);
477extern int ahci_port_busy (AD_INFO *ai, int p);
478extern void ahci_exec_iorb (IORBH _far *iorb, int ncq_capable,
479 int (*func)(IORBH _far *, int));
480extern void ahci_exec_polled_iorb (IORBH _far *iorb,
481 int (*func)(IORBH _far *, int),
482 ULONG timeout);
483extern int ahci_exec_polled_cmd (AD_INFO *ai, int p, int d,
484 int timeout, int cmd, ...);
485extern int ahci_set_dev_idle (AD_INFO *ai, int p, int d, int idle);
486extern int ahci_flush_cache (AD_INFO *ai, int p, int d);
487
488extern int ahci_intr (u16 irq);
489extern void ahci_port_intr (AD_INFO *ai, int p);
490extern void ahci_error_intr (AD_INFO *ai, int p, u32 irq_stat);
491
492extern void ahci_get_geometry (IORBH _far *iorb);
493extern void ahci_unit_ready (IORBH _far *iorb);
494extern void ahci_read (IORBH _far *iorb);
495extern void ahci_verify (IORBH _far *iorb);
496extern void ahci_write (IORBH _far *iorb);
497extern void ahci_execute_cdb (IORBH _far *iorb);
498extern void ahci_execute_ata (IORBH _far *iorb);
499
500/* libc.c */
501extern void init_libc (void);
502extern void init_com (long BaudRate);
503extern int vsprintf (char _far *buf, const char *fmt, va_list va);
504extern int sprintf (char _far *buf, const char *fmt, ...);
505extern void vfprintf (const char *fmt, va_list va);
506extern void _cdecl printf (const char *fmt, ...);
507extern void _cdecl printf_nts (const char *fmt, ...);
508extern void cprintf (const char *fmt, ...);
509extern void phex (const void _far *p, int len, const char *fmt, ...);
510extern size_t strlen (const char _far *s);
511extern char _far *strcpy (char _far *dst, const char _far *src);
512extern int memcmp (void _far *p1, void _far *p2, size_t len);
513extern void sg_memcpy (SCATGATENTRY _far *sg_list, USHORT sg_cnt,
514 ULONG sg_off, void _far *buf, USHORT len,
515 SG_MEMCPY_DIRECTION dir);
516extern long strtol (const char _far *buf,
517 const char _far * _far *ep, int base);
518extern void *malloc (size_t len);
519extern void free (void *ptr);
520extern ULONG virt_to_phys (void _far *ptr);
521extern void mdelay_cal (void);
522extern void mdelay (u32 millies);
523extern void msleep (u32 millies);
524extern void panic (char *msg);
525extern int disable (void);
526extern void enable (void);
527
528/* trace.c */
529extern void trace_init (u16);
530extern void trace_exit (void);
531extern void trace_write (u8 _far *s, int len);
532extern u16 trace_read (u8 _far *buf, u16 cb_buf);
533extern u16 trace_char_dev(RP_RWV _far *rwrb);
534extern void build_user_info(void);
535
536/* pci.c */
537extern int add_pci_id (u16 vendor, u16 device);
538extern void scan_pci_bus (void);
539extern int pci_enable_int (UCHAR bus, UCHAR dev_func);
540extern void pci_hack_virtualbox(void);
541extern char *vendor_from_id (u16 vendor);
542extern char *device_from_id (u16 device);
543UCHAR pci_read_conf (UCHAR bus, UCHAR dev_func, UCHAR indx,
544 UCHAR size, ULONG _far *val);
545UCHAR pci_write_conf (UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size,
546 ULONG val);
547
548/* ctxhook.c */
549extern void _cdecl restart_ctxhook (ULONG parm);
550extern void _cdecl reset_ctxhook (ULONG parm);
551extern void _cdecl engine_ctxhook (ULONG parm);
552
553/* apm.c */
554extern void apm_init (void);
555extern void apm_suspend (void);
556extern void apm_resume (void);
557
558/* ioctl.c */
559extern USHORT ioctl_get_devlist (RP_GENIOCTL _far *ioctl);
560extern USHORT ioctl_passthrough (RP_GENIOCTL _far *ioctl);
561extern USHORT ioctl_gen_dsk (RP_GENIOCTL _far *ioctl);
562extern USHORT ioctl_smart (RP_GENIOCTL _far *ioctl);
563
564
565/* ---------------------------- global variables --------------------------- */
566
567extern char _cdecl end_of_data; /* label at the end of all data segments */
568extern void _cdecl _near end_of_code(); /* label at the end of all code segments */
569
570extern int debug; /* if != 0, print debug messages to COM1 */
571extern int thorough_scan; /* if != 0, perform thorough PCI scan */
572extern int init_reset; /* if != 0, reset ports during init */
573extern int force_write_cache; /* if != 0, force write cache */
574extern int verbosity; /* if != 0, show some info during boot */
575extern int use_lvm_info;
576extern int wrap_trace_buffer;
577
578extern HDRIVER rm_drvh; /* resource manager driver handle */
579extern USHORT add_handle; /* adapter device driver handle */
580extern UCHAR timer_pool[]; /* timer pool */
581extern char drv_name[]; /* driver name as string ("OS2AHCI") */
582
583extern PCI_ID pci_ids[]; /* SATA adapter PCI IDs */
584extern ULONG drv_lock; /* driver-level spinlock */
585extern ULONG com_lock; /* debug log spinlock */
586extern IORB_QUEUE driver_queue; /* driver-level IORB queue */
587extern AD_INFO ad_infos[]; /* adapter information list */
588extern int ad_info_cnt; /* number of entries in ad_infos[] */
589extern u16 ad_ignore; /* bitmap with adapters to be ignored */
590extern int init_complete; /* if != 0, initialization has completed */
591extern int suspended; /* indicates if the driver is suspended */
592
593extern u16 com_base; /* debug COM port base address */
594
595/* port restart context hook and input data */
596extern ULONG restart_ctxhook_h;
597extern volatile u32 ports_to_restart[MAX_AD];
598
599/* port reset context hook and input data */
600extern ULONG reset_ctxhook_h;
601extern ULONG th_reset_watchdog;
602extern volatile u32 ports_to_reset[MAX_AD];
603extern IORB_QUEUE abort_queue;
604
605/* trigger engine context hook and input data */
606extern ULONG engine_ctxhook_h;
607
608/* apapter/port-specific options saved when parsing the command line */
609extern u8 emulate_scsi[MAX_AD][AHCI_MAX_PORTS];
610extern u8 enable_ncq[MAX_AD][AHCI_MAX_PORTS];
611extern u8 link_speed[MAX_AD][AHCI_MAX_PORTS];
612extern u8 link_power[MAX_AD][AHCI_MAX_PORTS];
613extern u8 track_size[MAX_AD][AHCI_MAX_PORTS];
614
Note: See TracBrowser for help on using the repository browser.