| Commit | Line | Data |
|---|---|---|
| 35878b55 SW |
1 | /* |
| 2 | * Copyright (c) 2004-2005 HighPoint Technologies, Inc. | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: | |
| 8 | * 1. Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 | * notice, this list of conditions and the following disclaimer in the | |
| 12 | * documentation and/or other materials provided with the distribution. | |
| 13 | * | |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
| 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
| 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 24 | * SUCH DAMAGE. | |
| 25 | * | |
| 26 | * $FreeBSD: src/sys/dev/hptmv/global.h,v 1.5 2009/04/07 16:38:25 delphij Exp $ | |
| 27 | */ | |
| 28 | #ifndef _GLOBAL_H_ | |
| 29 | #define _GLOBAL_H_ | |
| 30 | ||
| 31 | #include <dev/raid/hptmv/mvOs.h> | |
| 32 | #include <dev/raid/hptmv/mvSata.h> | |
| 33 | #include <dev/raid/hptmv/mvStorageDev.h> | |
| 34 | ||
| 35 | #define COMPANY "HighPoint Technologies, Inc." | |
| 36 | #define COPYRIGHT "(c) 2000-2007. HighPoint Technologies, Inc." | |
| 37 | #define DRIVER_NAME "RocketRAID 18xx SATA Controller driver" | |
| 38 | #define CONTROLLER_NAME "RocketRAID 18xx SATA Controller" | |
| 39 | #define PROC_DIR_NAME hptmv | |
| 40 | ||
| 41 | #define HPT_INTERFACE_VERSION 0x01010000 | |
| 42 | #define SUPPORT_48BIT_LBA | |
| 43 | #define SUPPORT_ARRAY | |
| 44 | #define SUPPORT_RAID5 1 | |
| 45 | #define _RAID5N_ | |
| 46 | #define MAX_QUEUE_COMM 32 | |
| 47 | #define MAX_SG_DESCRIPTORS 17 | |
| 48 | #define MAX_VBUS 2 /*one vbus per adapter in mv linux driver, | |
| 49 | MAX_VBUS is defined for share code and can not be 1*/ | |
| 50 | ||
| 51 | #define SET_VBUS_FOR_EACH_CONTROLLER | |
| 52 | #define MAX_MEMBERS 8 | |
| 53 | #define MAX_ARRAY_NAME 16 | |
| 54 | #define MAX_VDEVICE_PER_VBUS 8 | |
| 55 | #define MAX_ARRAY_DEVICE MAX_ARRAY_PER_VBUS | |
| 56 | #define MAX_CHIP_IN_VBUS 1 | |
| 57 | ||
| 5597f4e1 | 58 | #define HPTMV_DFLTPHYS (64 * 1024) |
| 35878b55 SW |
59 | #define SUPPORT_IOCTL |
| 60 | #define SUPPORT_FAIL_LED | |
| 61 | ||
| 62 | typedef void * PChipInstance; | |
| 63 | typedef void * PChannel; | |
| 64 | typedef struct _VDevice *PVDevice; | |
| 65 | typedef struct _VBus *PVBus; | |
| 66 | typedef struct _ArrayDescript *PArrayDescript; | |
| 67 | typedef struct _ArrayDescriptV2 *PArrayDescriptV2; | |
| 68 | typedef struct _Command *PCommand; | |
| 69 | ||
| 70 | typedef struct _Device { | |
| 71 | UCHAR df_on_line; | |
| 72 | UCHAR df_atapi; | |
| 73 | UCHAR df_removable_drive; | |
| 74 | UCHAR busyCount; | |
| 75 | ||
| 76 | UCHAR df_tcq_set: 1; | |
| 77 | UCHAR df_tcq: 1; /* enable TCQ */ | |
| 78 | UCHAR df_ncq_set: 1; | |
| 79 | UCHAR df_ncq: 1; /* enable NCQ */ | |
| 80 | UCHAR df_write_cache_set: 1; | |
| 81 | UCHAR df_write_cache: 1; /* enable write cache */ | |
| 82 | UCHAR df_read_ahead_set: 1; | |
| 83 | UCHAR df_read_ahead: 1; /* enable read ahead */ | |
| 84 | ||
| 85 | UCHAR retryCount; | |
| 86 | UCHAR resetCount; | |
| 87 | UCHAR pad1; | |
| 88 | ||
| 89 | UCHAR df_user_mode_set; | |
| 90 | UCHAR bDeModeSetting; /* Current Data Transfer mode: 0-4 PIO 0-4 */ | |
| 91 | UCHAR bDeUsable_Mode; /* actual maximum data transfer mode */ | |
| 92 | UCHAR bDeUserSelectMode; | |
| 93 | ||
| 94 | PVBus pVBus; | |
| 95 | ULONG dDeRealCapacity; | |
| 96 | ULONG dDeHiddenLba; | |
| 97 | ULONG HeadPosition; | |
| 98 | ULONG QueueLength; | |
| 99 | MV_SATA_CHANNEL *mv; | |
| 100 | } | |
| 101 | Device, *PDevice; | |
| 102 | ||
| 103 | typedef struct _SCAT_GATH | |
| 104 | { | |
| 105 | ULONG_PTR dSgAddress; | |
| 106 | USHORT wSgSize; | |
| 107 | USHORT wSgFlag; | |
| 108 | } SCAT_GATH, FAR *FPSCAT_GATH; | |
| 109 | ||
| 110 | #define OS_VDEV_EXT | |
| 111 | typedef struct _VDevice_Ext | |
| 112 | { | |
| 113 | UCHAR gui_locked; /* the device is locked by GUI */ | |
| 114 | UCHAR reserve[3]; | |
| 115 | } VDevice_Ext, *PVDevice_Ext; | |
| 116 | ||
| 117 | ||
| 118 | #define SG_FLAG_SKIP 0x4000 | |
| 119 | #define SG_FLAG_EOT 0x8000 | |
| 120 | ||
| 121 | #define _VBUS_ARG0 PVBus _vbus_p | |
| 122 | #define _VBUS_ARG PVBus _vbus_p, | |
| 123 | #define _VBUS_P _vbus_p, | |
| 124 | #define _VBUS_P0 _vbus_p | |
| 125 | #define _VBUS_INST(x) PVBus _vbus_p = x; | |
| 126 | #define _vbus_(x) (_vbus_p->x) | |
| 127 | ||
| 128 | /************************************************************************* | |
| 129 | * arithmetic functions | |
| 130 | *************************************************************************/ | |
| 131 | #define LongRShift(x, y) (x >> y) | |
| 132 | #define LongLShift(x, y) (x << y) | |
| 133 | #define LongDiv(x, y) (x / (UINT)(y)) | |
| 134 | #define LongRem(x, y) (x % (UINT)(y)) | |
| 135 | #define LongMul(x, y) (x * y) | |
| 136 | ||
| 137 | /************************************************************************* | |
| 138 | * C library | |
| 139 | *************************************************************************/ | |
| 140 | int HPTLIBAPI os_memcmp(const void *cs, const void *ct, unsigned len); | |
| 141 | void HPTLIBAPI os_memcpy(void *to, const void *from, unsigned len); | |
| 142 | void HPTLIBAPI os_memset(void *s, char c, unsigned len); | |
| 143 | unsigned HPTLIBAPI os_strlen(const char *s); | |
| 144 | ||
| 145 | #define ZeroMemory(a, b) memset((char *)a, 0, b) | |
| 146 | #define MemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)(c)) | |
| 147 | #define farMemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)c) | |
| 148 | #define StrLen strlen | |
| 149 | ||
| 150 | /* | |
| 151 | * we don't want whole hptintf.h in shared code... | |
| 152 | * some constants must match that in hptintf.h! | |
| 153 | */ | |
| 154 | enum _driver_events_t | |
| 155 | { | |
| 156 | ET_DEVICE=0, | |
| 157 | ET_DEVICE_REMOVED, | |
| 158 | ET_DEVICE_PLUGGED, | |
| 159 | ET_DEVICE_ERROR, | |
| 160 | ET_REBUILD_STARTED, | |
| 161 | ET_REBUILD_ABORTED, | |
| 162 | ET_REBUILD_FINISHED, | |
| 163 | ET_SPARE_TOOK_OVER, | |
| 164 | ET_REBUILD_FAILED, | |
| 165 | ET_VERIFY_STARTED, | |
| 166 | ET_VERIFY_ABORTED, | |
| 167 | ET_VERIFY_FAILED, | |
| 168 | ET_VERIFY_FINISHED, | |
| 169 | ET_INITIALIZE_STARTED, | |
| 170 | ET_INITIALIZE_ABORTED, | |
| 171 | ET_INITIALIZE_FAILED, | |
| 172 | ET_INITIALIZE_FINISHED, | |
| 173 | ET_VERIFY_DATA_ERROR, | |
| 174 | }; | |
| 175 | ||
| 176 | #define StallExec(x) mvMicroSecondsDelay(x) | |
| 177 | extern void HPTLIBAPI ioctl_ReportEvent(UCHAR event, PVOID param); | |
| 178 | #define fNotifyGUI(WhatHappen, pVDevice) ioctl_ReportEvent(WhatHappen, pVDevice) | |
| 179 | #define DECLARE_BUFFER(type, ptr) UCHAR ptr##__buf[512]; type ptr=(type)ptr##__buf | |
| 180 | ||
| 181 | int HPTLIBAPI fDeReadWrite(PDevice pDev, ULONG Lba, UCHAR Cmd, void *tmpBuffer); | |
| 182 | void HPTLIBAPI fDeSelectMode(PDevice pDev, UCHAR NewMode); | |
| 183 | int HPTLIBAPI fDeSetTCQ(PDevice pDev, int enable, int depth); | |
| 184 | int HPTLIBAPI fDeSetNCQ(PDevice pDev, int enable, int depth); | |
| 185 | int HPTLIBAPI fDeSetWriteCache(PDevice pDev, int enable); | |
| 186 | int HPTLIBAPI fDeSetReadAhead(PDevice pDev, int enable); | |
| 187 | ||
| 188 | #include <dev/raid/hptmv/atapi.h> | |
| 189 | #include <dev/raid/hptmv/command.h> | |
| 190 | #include <dev/raid/hptmv/array.h> | |
| 191 | #include <dev/raid/hptmv/raid5n.h> | |
| 192 | #include <dev/raid/hptmv/vdevice.h> | |
| 193 | ||
| 194 | #if defined(__FreeBSD__) && defined(HPTLIBAPI) | |
| 195 | #undef HPTLIBAPI | |
| 196 | #define HPTLIBAPI | |
| 197 | #endif | |
| 198 | ||
| 199 | #ifdef SUPPORT_ARRAY | |
| 200 | #define ArrayTables(i) ((PVDevice)&_vbus_(_ArrayTables)[i*ARRAY_VDEV_SIZE]) | |
| 201 | #endif | |
| 202 | ||
| 203 | #endif |