source: trunk/src/os2ahci/os2ahci.h

Last change on this file was 211, checked in by David Azarewicz, 2 years ago

Added workaround to help with VirtualBox issues.
Improved diagnostic messages.
Changed how timeouts are reset and how ctx hooks are triggered.
Added quirk for devices with issues executing some standard commands.
Changed to make /N the default.

File size: 24.0 KB
RevLine 
[205]1/**
[20]2 * os2ahci.h - main header file for os2ahci driver
3 *
[87]4 * Copyright (c) 2011 thi.guten Software Development
5 * Copyright (c) 2011 Mensys B.V.
[211]6 * Copyright (c) 2013-2023 David Azarewicz <david@88watts.net>
[20]7 *
[87]8 * Authors: Christian Mueller, Markus Thielen
9 *
10 * Parts copied from/inspired by the Linux AHCI driver;
11 * those parts are (c) Linux AHCI/ATA maintainers
12 *
[20]13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27
28/* IMPORTANT NOTE: The DDK headers require tight structure packing and this
[144]29 * is controlled via compiler parameters. Thus, all stuctures in os2ahci.add
[20]30 * are expected to be byte-aligned without the need of explicit pragma pack()
[145]31 * directives. Where possible, the structures are laid out such that words
[20]32 * and dwords are aligned at least on 2-byte boundaries.
33 */
34
[161]35/* Global feature defines
36 * DEBUG = enable debug logging routines to be compled in.
37 * LEGACY_APM = enable the legacy APM interface to be compiled in.
38 * Legacy APM support is not needed on eCS systems with ACPI and is more reliable without it enabled.
39 */
40//#define LEGACY_APM
[182]41//#define DAZ_NEW_CODE
[161]42
[178]43#include "Dev32lib.h"
44#include "Dev32rmcalls.h"
45#include <Dev32iorb.h>
[20]46#include "ahci.h"
[133]47#include "ahci-idc.h"
[20]48
[178]49#define MAX_AD 8 /* maximum number of adapters */
[20]50
[178]51#define TIMER_COUNT 128
[20]52
53/* default command timeout (can be overwritten in the IORB) */
[178]54#define DEFAULT_TIMEOUT 30000
[20]55
[121]56/* Maximum number of retries for commands in the restart/reset context hooks.
57 *
58 * Please note that the corresponding variable in the ADD workspace is a bit
59 * field, thus increasing this value means increasing the size of the bit
60 * field. At the time of writing this comment the 'retries' variable was 2
61 * bits wide (i.e. a maximum number of 3 retries) and there was exactly one
62 * bit left before the ADD workspace structure would become too large...
63 */
[178]64#define MAX_RETRIES 3
[121]65
[209]66#define DBG_ALWAYS 0x0000
67#define DBG_FUNCBEG 0x0001
68#define DBG_FUNCEND 0x0002
69#define DBG_ATTACH 0x0004
70#define DBG_DETAILED 0x0008
71#define DBG_INIT 0x0010
72#define DBG_SPECIAL 0x0020
73#define DBG_VERBOSE 0x0100
74#define DBG_ERROR_ALL 0x800000ff
75
76#define DBG_PREFIX "AHCI: "__func__
77
[20]78/* debug output macros */
[160]79#ifdef DEBUG
[178]80#define DPRINTF(a,b,...) dprintf(a, b, ##__VA_ARGS__)
81#define DHEXDUMP(a,b,c,d,...) dHexDump(a, b, c, d, ##__VA_ARGS__)
[209]82#define DUMP_HOST_REGS(l,a,b) {if (D32g_DbgLevel&l) ahci_dump_host_regs(a,b);}
83#define DUMP_PORT_REGS(l,a,b) {if (D32g_DbgLevel&l) ahci_dump_port_regs(a,b);}
[160]84#else
[178]85#define DPRINTF(a,b,...)
86#define DHEXDUMP(a,b,c,d,...)
[184]87#define DUMP_HOST_REGS(l,a,b)
[178]88#define DUMP_PORT_REGS(l,a,b)
[160]89#endif
[20]90
91/* adapter number from AD_INFO pointer; mainly for dprintf() purposes */
[178]92#define ad_no(ai) ( ( (u32)ai - (u32)ad_infos ) / sizeof(*ai))
[20]93
[178]94#define MakeNear16PtrFromDiff(Base16, Base32, New32) \
95 ( ( CastFar16ToULONG(Base16) + ( (ULONG)(New32) - (ULONG)(Base32) ) ) & 0xffff)
96
97#define MakeFar16PtrFromDiff(Base16, Base32, New32) \
98 CastULONGToFar16(CastFar16ToULONG(Base16) + ((ULONG)(New32) - (ULONG)(Base32))))
99
100/* Takes the selector from the first parameter, and the offset specified
101 * in the second parameter, and returns a flat pointer
[20]102 */
[178]103extern void *MakeFlatFromNear16(void __far16 *, USHORT);
104#pragma aux MakeFlatFromNear16 = \
105 "mov ax, bx" \
106 "call Far16ToFlat" \
107 parm nomemory [eax] [bx] value [eax] modify nomemory exact [eax];
[20]108
[211]109ULONG LockInc(ULONG *ulCounter);
110#pragma aux LockInc = \
111 "mov eax, 1" \
112 "lock xadd [ebx],eax" \
113 parm [ebx] value [eax] modify exact [eax];
114
115ULONG LockDec(ULONG *ulCounter);
116#pragma aux LockDec = \
117 "mov eax, -1" \
118 "lock xadd [ebx],eax" \
119 "dec eax" \
120 parm [ebx] value [eax] modify exact [eax];
121
[178]122/* stdarg.h macros with explicit far pointers */
123typedef char *va_list;
[20]124#define va_start(va, last) va = (va_list) (&last + 1)
[178]125#define va_arg(va, type) ((type *) (va += sizeof(type)))[-1]
[20]126#define va_end(va) va = 0
127
128/* shortcut macros */
[178]129#define spin_lock(sl) KernAcquireSpinLock(&sl)
130#define spin_unlock(sl) KernReleaseSpinLock(&sl)
[20]131
[178]132/* Get AHCI port MMIO base from AD_INFO and port number. */
133#define port_base(ai, p) ((u8 *) (ai)->mmio + 0x100 + (p) * 0x80)
[183]134#define port_dma_base(ai, p) ((AHCI_PORT_DMA *) ((ai)->ports[(p)].dma_buf))
135#define port_dma_base_phys(ai, p) ((ai)->ports[p].dma_buf_phys)
[20]136
137/* Convert an SATA adapter/port/device address into a 16-bit IORB unit handle
138 * (and the other way round). The mapping looks like this:
139 *
140 * mapping comment
141 * -----------------------------------------------------------------------
[25]142 * 4 bits for the adapter current max is 8 adapters
[20]143 * 4 bits for the port AHCI spec defines up to 32 ports
144 * 4 bits for the device SATA spec defines up to 15 devices behind PMP
145 */
146#define iorb_unit(a, p, d) ((((u16) (a) & 0x0fU) << 8) | \
147 (((u16) (p) & 0x0fU) << 4) | \
148 (((u16) (d) & 0x0fU)))
[178]149#define iorb_unit_adapter(iorb) (((iorb)->UnitHandle >> 8) & 0x07)
150#define iorb_unit_port(iorb) (((iorb)->UnitHandle >> 4) & 0x0f)
151#define iorb_unit_device(iorb) ((iorb)->UnitHandle & 0x0f)
[20]152
153/*******************************************************************************
154 * Convenience macros for IORB processing functions
155 */
156/* is this IORB on driver or port level? */
157#define iorb_driver_level(iorb) ((iorb)->CommandCode == IOCC_CONFIGURATION)
158
159/* is this IORB to be inserted at the beginnig of the IORB queue? */
160#define iorb_priority(iorb) ((iorb)->CommandCode == IOCC_DEVICE_CONTROL && \
161 (iorb)->CommandModifier == IOCM_ABORT))
162
163/* access IORB ADD workspace */
[178]164#define add_workspace(iorb) ((ADD_WORKSPACE *) &(iorb)->ADDWorkSpace)
[20]165
166
[75]167
[20]168/******************************************************************************
169 * PCI generic IDs and macros
170 */
171#define PCI_ANY_ID 0xffffU
172#define PCI_VDEVICE(vendor, device) PCI_VENDOR_ID_##vendor, (device), \
173 PCI_ANY_ID, PCI_ANY_ID, 0, 0
174
175/******************************************************************************
176 * PCI vendor IDs for AHCI adapters known to this driver (copied from Linux
177 * pci_ids.h)
178 */
179#define PCI_VENDOR_ID_AL 0x10b9
180#define PCI_VENDOR_ID_AMD 0x1022
181#define PCI_VENDOR_ID_AT 0x1259
182#define PCI_VENDOR_ID_ATI 0x1002
183#define PCI_VENDOR_ID_ATT 0x11c1
184#define PCI_VENDOR_ID_CMD 0x1095
185#define PCI_VENDOR_ID_CT 0x102c
186#define PCI_VENDOR_ID_INTEL 0x8086
[31]187#define PCI_VENDOR_ID_INITIO 0x1101
[20]188#define PCI_VENDOR_ID_JMICRON 0x197B
189#define PCI_VENDOR_ID_MARVELL 0x11ab
190#define PCI_VENDOR_ID_NVIDIA 0x10de
191#define PCI_VENDOR_ID_PROMISE 0x105a
192#define PCI_VENDOR_ID_SI 0x1039
193#define PCI_VENDOR_ID_VIA 0x1106
194
195/******************************************************************************
196 * PCI class IDs we're interested in (copied from Linux pci_ids.h)
197 */
198#define PCI_BASE_CLASS_STORAGE 0x01
199#define PCI_CLASS_STORAGE_SCSI 0x0100
200#define PCI_CLASS_STORAGE_IDE 0x0101
201#define PCI_CLASS_STORAGE_FLOPPY 0x0102
202#define PCI_CLASS_STORAGE_IPI 0x0103
203#define PCI_CLASS_STORAGE_RAID 0x0104
204#define PCI_CLASS_STORAGE_SATA 0x0106
205#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601
206#define PCI_CLASS_STORAGE_SAS 0x0107
207#define PCI_CLASS_STORAGE_OTHER 0x0180
208
[33]209/******************************************************************************
210 * ANSI color code constants
211 */
212#define ANSI_CLR_BRIGHT "\x1b[1m"
213#define ANSI_CLR_RED "\x1b[31m"
214#define ANSI_CLR_GREEN "\x1b[32m"
215#define ANSI_CLR_BLUE "\x1b[34m"
216#define ANSI_CLR_CYAN "\x1b[36m"
217#define ANSI_CLR_WHITE "\x1b[37m"
218#define ANSI_RESET "\x1b[0m"
219
[111]220
[20]221/* ------------------------ typedefs and structures ------------------------ */
222
223/* PCI device information structure; this is used both for scanning and for
224 * identification purposes in 'AD_INFO'; based on the Linux pci_device_id
225 * structure but hard-wired to use board_* constants for 'driver_data'
226 */
227typedef struct {
228 u16 vendor; /* PCI device vendor/manufacturer */
229 u16 device; /* PCI device ID inside vendor scope */
230 u16 subvendor; /* subsystem vendor (unused so far) */
231 u16 subdevice; /* subsystem device (unused so far) */
232 u32 class; /* PCI device class */
233 u32 class_mask; /* bits to match when scanning for 'class' */
[211]234 char *pChipName; /* human readable chip ID string */
235 u32 quirks; /* AHCI controller quirks */
[20]236} PCI_ID;
237
238/* IORB queue; since IORB queues are updated at interrupt time, the
239 * corresponding pointers (not the data they point to) need to be volatile.
240 */
241typedef struct {
[178]242 IORBH FAR16DATA *volatile vRoot; /* root of request list */
243 IORBH FAR16DATA *volatile vTail; /* tail of request list */
[20]244} IORB_QUEUE;
245
[162]246typedef struct {
[209]247 ULONG ulCylinders;
248 USHORT usHeadsPerCylinder;
249 USHORT usSectorsPerTrack;
250 ULONGLONG ullTotalSectors;
251 char *pMethod;
[162]252} DEV_INFO;
253
[20]254/* port information structure */
255typedef struct {
[185]256 IORB_QUEUE iorb_queue; /* 00 IORB queue for this port */
257 unsigned dev_max : 4; /* 08 maximum device number on this port (0..AHCI_MAX_DEVS-1) */
258 unsigned cmd_slot : 5; /* current command slot index (using round-
259 * robin indexes to prevent starvation) */
[20]260
[185]261 volatile u32 ncq_cmds; /* 0c bitmap for NCQ commands issued */
262 volatile u32 reg_cmds; /* 10 bitmap for regular commands issued */
263 u32 dma_buf_phys; /* 14 physical address of DMA scratch buffer */
264 u8 *dma_buf; /* 18 DMA scatch buffers */
[207]265 u32 unaligned_read_count;
266 u32 error_count;
267 u32 ulResetCount; /* added in 2.07 */
[20]268
[185]269 struct { /* 1c */
[178]270 unsigned allocated :1; /* if != 0, device is allocated */
271 unsigned present :1; /* if != 0, device is present */
272 unsigned lba48 :1; /* if != 0, device supports 48-bit LBA */
273 unsigned atapi :1; /* if != 0, this is an ATAPI device */
274 unsigned atapi_16 :1; /* if != 0, device suports 16-byte cmds */
275 unsigned removable :1; /* if != 0, device has removable media */
276 unsigned dev_type :5; /* device type (UIB_TYPE_* in iorb.h) */
277 unsigned ncq_max :5; /* maximum tag number for queued commands */
[202]278 unsigned ignored :1; /* if != 0, device is not MBR added in 2.06 */
[178]279 UNITINFO *unit_info; /* pointer to modified unit info */
280 DEV_INFO dev_info;
[185]281 char dev_name[AHCI_DEV_NAME_LEN];
[162]282 } devs[AHCI_MAX_DEVS];
[20]283} P_INFO;
284
285/* adapter information structure */
286typedef struct {
[211]287 u16 BusDevFunc; /* 00 PCI bus number PCI device and function number */
288 u16 PciVendor; /* 02 */
289 u16 PciDevice; /* 04 */
290 u8 irq; /* 06 interrupt number */
291 u8 irq_pin; /* 07 irq pin */
[20]292
[211]293 u32 cap; /* 08 working copy of CAP register */
294 u32 cap2; /* 0c working copy of CAP2 register */
295 HRESOURCE rm_bars[6]; /* 10 resource handle for MMIO and I/O BARs */
296 HRESOURCE rm_adh; /* 28 resource handle for adapter */
297 char *pChipName; /* 2c pointer to chip name */
298 u32 quirks; /* 30 adapter quirks */
299
300 unsigned port_max : 5; /* 34 maximum port number (0..AHCI_MAX_PORTS-1) */
[185]301 unsigned cmd_max : 5; /* maximum cmd slot number (0-31) */
302 unsigned port_scan_done : 1; /* if != 0, port scan already done */
303 unsigned busy : 1; /* if != 0, adapter is busy */
304 unsigned hw_ports : 6; /* number of ports as reported by the hardware */
[211]305 unsigned int_set:1; /* interrupt has been set */
[20]306
[211]307 u32 port_map; /* 38 bitmap of active ports */
[169]308
[20]309 /* initial adapter configuration from BIOS */
[211]310 u32 bios_config[HOST_CAP2 / sizeof(u32) + 1]; /* 3c 0x24 / 4 + 1 = 0x0a dwords = 0x28 bytes*/
[20]311
[211]312 u32 mmio_phys; /* 64 physical address of MMIO region */
313 u32 mmio_size; /* 68 size of MMIO region */
314 u8 *mmio; /* 6c pointer to this adapter's MMIO region */
[20]315
[211]316 P_INFO ports[AHCI_MAX_PORTS]; /* 70 SATA ports on this adapter */
[20]317} AD_INFO;
318
319/* ADD workspace in IORB (must not exceed 16 bytes) */
320typedef struct {
[178]321 void (*ppfunc)(IORBH FAR16DATA *vIorb, IORBH *pIorb); /* 00 post-processing function */
322 void *buf; /* 04 response buffer (e.g. for identify cmds) */
323 ULONG timer; /* 08 timer for timeout procesing */
324 USHORT blocks; /* 0c number of blocks to be transferred */
325 unsigned short processing :1; /* 0e IORB is being processd */
326 unsigned short idempotent :1; /* IORB is idempotent (can be retried) */
[207]327 unsigned short fIs64bit :1; /* Transaction is a 64 bit operation */
[178]328 unsigned short queued_hw :1; /* IORB has been queued to hardware */
329 unsigned short no_ncq :1; /* must not use native command queuing */
330 unsigned short is_ncq :1; /* should use native command queueing */
331 unsigned short complete :1; /* IORB has completed processing */
332 unsigned short unaligned :1; /* unaligned S/G; need to use transfer buffer */
333 unsigned short retries :2; /* number of retries for this command */
334 unsigned short cmd_slot :5; /* AHCI command slot for this IORB */
335} ADD_WORKSPACE; /* 10 */
[20]336
[110]337/* sg_memcpy() direction */
338typedef enum {
339 SG_TO_BUF, /* copy from S/G list to buffer */
340 BUF_TO_SG /* copy from buffer to S/G list */
[144]341} SG_MEMCPY_DIRECTION;
[110]342
[154]343/* Define the size of a disk name. Disk Names are user defined names given to physical disk drives in the system. */
344#define DLA_TABLE_SIGNATURE1 0x424D5202L
345#define DLA_TABLE_SIGNATURE2 0x44464D50L
346#define DISK_NAME_SIZE 20
347
348typedef struct _DLA_Table_Sector { /* DTS */
349 ULONG DLA_Signature1; /* The magic signature (part 1) of a Drive Letter Assignment Table. */
350 ULONG DLA_Signature2; /* The magic signature (part 2) of a Drive Letter Assignment Table. */
351 ULONG DLA_CRC; /* The 32 bit CRC for this sector. Calculated assuming that this field and all unused space in the sector is 0. */
352 ULONG Disk_Serial_Number; /* The serial number assigned to this disk. */
353 ULONG Boot_Disk_Serial_Number;/* The serial number of the disk used to boot the system. This is for conflict resolution when multiple volumes
354 want the same drive letter. Since LVM.EXE will not let this situation happen, the only way to get this situation
355 is for the disk to have been altered by something other than LVM.EXE, or if a disk drive has been moved from one
356 machine to another. If the drive has been moved, then it should have a different Boot_Disk_Serial_Number. Thus,
357 we can tell which disk drive is the "foreign" drive and therefore reject its claim for the drive letter in question.
358 If we find that all of the claimaints have the same Boot_Disk_Serial_Number, then we must assign drive letters on
359 a first come, first serve basis. */
360 ULONG Install_Flags; /* Used by the Install program. */
361 ULONG Cylinders;
362 ULONG Heads_Per_Cylinder;
363 ULONG Sectors_Per_Track;
364 char Disk_Name[DISK_NAME_SIZE]; /* The name assigned to the disk containing this sector. */
365 UCHAR Reboot; /* For use by Install. Used to keep track of reboots initiated by install. */
366 BYTE Reserved[3]; /* Alignment. */
367 /* These are the four entries which correspond to the entries in the partition table. */
368} DLA_Table_Sector, *PDLA_Table_Sector;
369
[207]370typedef struct _ahcistats_
371{
372 ULONG ulSize;
373 ULONG ulVersion;
[211]374 ULONG ulHardErrorCount;
375 ULONG ulSoftErrorCount;
[207]376 ULONG ulTestCount1;
377} AHCISTATS;
378
[178]379static inline unsigned long readl(void *a)
380{
381 return *(volatile unsigned long*)a;
382}
[20]383
[178]384static inline void writel(void *a, unsigned long v)
385{
386 *(volatile unsigned long*)a = v;
387}
388
389extern void shutdown_driver(void);
390
[20]391/* os2ahci.c */
[178]392extern USHORT init_drv(REQPACKET *req);
393extern USHORT gen_ioctl(REQPACKET *ioctl);
394extern USHORT char_dev_input(REQPACKET *rwrb);
395extern USHORT exit_drv(int func);
396extern USHORT sr_drv(int func);
397extern void add_entry(IORBH FAR16DATA *vIorb);
398extern void trigger_engine(void);
399extern int trigger_engine_1(void);
400extern void send_iorb(IORBH FAR16DATA *vIorb, IORBH *pIorb);
401extern void iocc_configuration (IORBH FAR16DATA *vIorb, IORBH *pIorb);
402extern void iocc_device_control(IORBH FAR16DATA *vIorb, IORBH *pIorb);
403extern void iocc_unit_control(IORBH FAR16DATA *vIorb, IORBH *pIorb);
404extern void iocm_device_table(IORBH FAR16DATA *vIorb, IORBH *pIorb);
405extern void iocc_geometry(IORBH FAR16DATA *vIorb, IORBH *pIorb);
406extern void iocc_execute_io(IORBH FAR16DATA *vIorb, IORBH *pIorb);
407extern void iocc_unit_status(IORBH FAR16DATA *vIorb, IORBH *pIorb);
408extern void iocc_adapter_passthru(IORBH FAR16DATA *vIorb, IORBH *pIorb);
409extern void iorb_queue_add(IORB_QUEUE *queue, IORBH FAR16DATA *vIorb, IORBH *pIorb);
410extern int iorb_queue_del(IORB_QUEUE *queue, IORBH FAR16DATA *vIorb);
411extern void iorb_seterr(IORBH *pIorb, USHORT error_code);
412extern void iorb_done(IORBH FAR16DATA *vIorb, IORBH *pIorb);
413extern void iorb_complete(IORBH FAR16DATA *vIorb, IORBH *pIorb);
414extern void iorb_requeue(IORBH *pIorb);
415extern void aws_free(ADD_WORKSPACE *aws);
416extern void lock_adapter(AD_INFO *ai);
417extern void unlock_adapter(AD_INFO *ai);
418extern void __syscall timeout_callback(ULONG timer_handle, ULONG p1);
[211]419extern void __syscall WatchdogTimer(ULONG timer_handle, ULONG p1);
[20]420
421/* ahci.c */
[182]422extern int ahci_config_caps(AD_INFO *ai);
[178]423extern int ahci_save_bios_config(AD_INFO *ai);
424extern int ahci_restore_bios_config(AD_INFO *ai);
425extern int ahci_restore_initial_config(AD_INFO *ai);
426extern AHCI_PORT_CFG *ahci_save_port_config(AD_INFO *ai, int p);
427extern void ahci_restore_port_config(AD_INFO *ai, int p, AHCI_PORT_CFG *pc);
428extern int ahci_enable_ahci(AD_INFO *ai);
429extern int ahci_scan_ports(AD_INFO *ai);
430extern int ahci_complete_init(AD_INFO *ai);
431extern int ahci_reset_port(AD_INFO *ai, int p, int ei);
432extern int ahci_start_port(AD_INFO *ai, int p, int ei);
433extern void ahci_start_fis_rx(AD_INFO *ai, int p);
434extern void ahci_start_engine(AD_INFO *ai, int p);
435extern int ahci_stop_port(AD_INFO *ai, int p);
436extern int ahci_stop_fis_rx(AD_INFO *ai, int p);
437extern int ahci_stop_engine(AD_INFO *ai, int p);
438extern int ahci_port_busy(AD_INFO *ai, int p);
439extern void ahci_exec_iorb(IORBH FAR16DATA *vIorb, IORBH *pIorb, int ncq_capable, int (*func)(IORBH FAR16DATA *, IORBH *pIorb, int));
440extern void ahci_exec_polled_iorb(IORBH FAR16DATA *vIorb, IORBH *pIorb, int (*func)(IORBH FAR16DATA *, IORBH *pIorb, int), ULONG timeout);
441extern int ahci_exec_polled_cmd(AD_INFO *ai, int p, int d, int timeout, int cmd, ...);
442extern int ahci_set_dev_idle(AD_INFO *ai, int p, int d, int idle);
443extern int ahci_flush_cache(AD_INFO *ai, int p, int d);
[20]444
[190]445extern int ahci_intr(u32 irq);
[178]446extern void ahci_port_intr(AD_INFO *ai, int p);
447extern void ahci_error_intr(AD_INFO *ai, int p, u32 irq_stat);
[20]448
[178]449extern void ahci_get_geometry(IORBH FAR16DATA *vIorb, IORBH *pIorb);
450extern void ahci_unit_ready(IORBH FAR16DATA *vIorb, IORBH *pIorb);
451extern void ahci_read(IORBH FAR16DATA *vIorb, IORBH *pIorb);
452extern void ahci_verify(IORBH FAR16DATA *vIorb, IORBH *pIorb);
453extern void ahci_write(IORBH FAR16DATA *vIorb, IORBH *pIorb);
454extern void ahci_execute_cdb(IORBH FAR16DATA *vIorb, IORBH *pIorb);
455extern void ahci_execute_ata(IORBH FAR16DATA *vIorb, IORBH *pIorb);
[161]456extern void ahci_dump_host_regs(AD_INFO *ai, int bios_regs);
457extern void ahci_dump_port_regs(AD_INFO *ai, int p);
458extern int ahci_reset_controller(AD_INFO *ai);
[20]459
[178]460extern void sg_memcpy(SCATGATENTRY *sg_list, USHORT sg_cnt, ULONG sg_off, void *buf, USHORT len, SG_MEMCPY_DIRECTION dir);
461extern void panic(char *msg);
[20]462
[112]463/* trace.c */
[178]464extern void build_user_info(void);
[112]465
[20]466/* pci.c */
[178]467extern int add_pci_id(u16 vendor, u16 device);
468extern void scan_pci_bus(void);
469extern void pci_hack_virtualbox(void);
470extern char *vendor_from_id(u16 vendor);
[20]471
472/* ctxhook.c */
[211]473extern void _Syscall RestartCtxHook(ULONG parm);
474extern void _Syscall ResetCtxHook(ULONG parm);
[178]475extern void _Syscall engine_ctxhook(ULONG parm);
[211]476extern void SafeArmCtxHook(ULONG ulHandle, ULONG armData);
[20]477
[76]478/* apm.c */
[178]479extern void apm_init(void);
480extern void suspend(void);
481extern void resume(void);
[76]482
483/* ioctl.c */
[178]484extern USHORT ioctl_get_devlist(REQPACKET *ioctl);
485extern USHORT ioctl_passthrough(REQPACKET *ioctl);
[211]486extern USHORT ioctl_debug(REQPACKET *ioctl);
[178]487extern USHORT ioctl_gen_dsk(REQPACKET *ioctl);
488extern USHORT ioctl_smart(REQPACKET *ioctl);
[76]489
[111]490
[178]491extern int thorough_scan; /* if != 0, perform thorough PCI scan */
492extern int init_reset; /* if != 0, reset ports during init */
493extern int force_write_cache; /* if != 0, force write cache */
[209]494extern int iVerbose; /* if != 0, show some info during boot */
[198]495extern int use_mbr_test;
[20]496
[178]497extern HDRIVER rm_drvh; /* resource manager driver handle */
498extern USHORT add_handle; /* adapter device driver handle */
499extern char drv_name[]; /* driver name as string ("OS2AHCI") */
[20]500
[178]501extern PCI_ID pci_ids[]; /* SATA adapter PCI IDs */
502extern SpinLock_t drv_lock; /* driver-level spinlock */
503extern ULONG com_lock; /* debug log spinlock */
504extern IORB_QUEUE driver_queue; /* driver-level IORB queue */
505extern AD_INFO ad_infos[]; /* adapter information list */
506extern int ad_info_cnt; /* number of entries in ad_infos[] */
507extern u16 ad_ignore; /* bitmap with adapters to be ignored */
508extern int init_complete; /* if != 0, initialization has completed */
509extern int suspended; /* indicates if the driver is suspended */
510extern int resume_sleep_flag;
[207]511extern AHCISTATS AhciStats;
[20]512
513/* port restart context hook and input data */
[211]514extern ULONG RestartCtxHook_h;
[178]515extern volatile u32 ports_to_restart[MAX_AD];
[20]516
517/* port reset context hook and input data */
[211]518extern ULONG ResetCtxHook_h;
519extern ULONG th_watchdog;
[178]520extern volatile u32 ports_to_reset[MAX_AD];
521extern IORB_QUEUE abort_queue;
[20]522
523/* trigger engine context hook and input data */
[178]524extern ULONG engine_ctxhook_h;
[20]525
526/* apapter/port-specific options saved when parsing the command line */
[178]527extern u8 emulate_scsi[MAX_AD][AHCI_MAX_PORTS];
528extern u8 enable_ncq[MAX_AD][AHCI_MAX_PORTS];
529extern u8 link_speed[MAX_AD][AHCI_MAX_PORTS];
530extern u8 link_power[MAX_AD][AHCI_MAX_PORTS];
531extern u8 track_size[MAX_AD][AHCI_MAX_PORTS];
532extern u8 port_ignore[MAX_AD][AHCI_MAX_PORTS];
[20]533
[178]534#ifdef DEBUG
[211]535extern void DumpIorb(IORBH *pIorb, IORBH FAR16DATA *vIorb);
[178]536#endif
537
Note: See TracBrowser for help on using the repository browser.