1149871Sscottl/* 2149871Sscottl * Copyright (c) 2004-2005 HighPoint Technologies, Inc. 3136849Sscottl * All rights reserved. 4136849Sscottl * 5136849Sscottl * Redistribution and use in source and binary forms, with or without 6136849Sscottl * modification, are permitted provided that the following conditions 7136849Sscottl * are met: 8136849Sscottl * 1. Redistributions of source code must retain the above copyright 9136849Sscottl * notice, this list of conditions and the following disclaimer. 10136849Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11136849Sscottl * notice, this list of conditions and the following disclaimer in the 12136849Sscottl * documentation and/or other materials provided with the distribution. 13136849Sscottl * 14136849Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15136849Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16136849Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17136849Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18136849Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19136849Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20136849Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21136849Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22136849Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23136849Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24136849Sscottl * SUCH DAMAGE. 25136849Sscottl * 26136849Sscottl * $FreeBSD$ 27136849Sscottl */ 28136849Sscottl#ifndef _GLOBAL_H_ 29136849Sscottl#define _GLOBAL_H_ 30136849Sscottl 31136849Sscottl#include <dev/hptmv/mvOs.h> 32143039Sscottl#include <dev/hptmv/mvSata.h> 33143039Sscottl#include <dev/hptmv/mvStorageDev.h> 34136849Sscottl 35149871Sscottl#define COMPANY "HighPoint Technologies, Inc." 36190809Sdelphij#define COPYRIGHT "(c) 2000-2007. HighPoint Technologies, Inc." 37190809Sdelphij#define DRIVER_NAME "RocketRAID 18xx SATA Controller driver" 38190809Sdelphij#define CONTROLLER_NAME "RocketRAID 18xx SATA Controller" 39149871Sscottl#define PROC_DIR_NAME hptmv 40136849Sscottl 41190809Sdelphij#define HPT_INTERFACE_VERSION 0x01010000 42136849Sscottl#define SUPPORT_48BIT_LBA 43136849Sscottl#define SUPPORT_ARRAY 44136849Sscottl#define SUPPORT_RAID5 1 45136849Sscottl#define _RAID5N_ 46136849Sscottl#define MAX_QUEUE_COMM 32 47136849Sscottl#define MAX_SG_DESCRIPTORS 17 48149871Sscottl#define MAX_VBUS 2 /*one vbus per adapter in mv linux driver, 49149871Sscottl MAX_VBUS is defined for share code and can not be 1*/ 50136849Sscottl 51136849Sscottl#define SET_VBUS_FOR_EACH_CONTROLLER 52136849Sscottl#define MAX_MEMBERS 8 53136849Sscottl#define MAX_ARRAY_NAME 16 54136849Sscottl#define MAX_VDEVICE_PER_VBUS 8 55136849Sscottl#define MAX_ARRAY_DEVICE MAX_ARRAY_PER_VBUS 56136849Sscottl#define MAX_CHIP_IN_VBUS 1 57136849Sscottl 58136849Sscottl#define SUPPORT_IOCTL 59136849Sscottl#define SUPPORT_FAIL_LED 60136849Sscottl 61136849Sscottltypedef void * PChipInstance; 62136849Sscottltypedef void * PChannel; 63136849Sscottltypedef struct _VDevice *PVDevice; 64136849Sscottltypedef struct _VBus *PVBus; 65136849Sscottltypedef struct _ArrayDescript *PArrayDescript; 66136849Sscottltypedef struct _ArrayDescriptV2 *PArrayDescriptV2; 67136849Sscottltypedef struct _Command *PCommand; 68136849Sscottl 69136849Sscottltypedef struct _Device { 70136849Sscottl UCHAR df_on_line; 71136849Sscottl UCHAR df_atapi; 72136849Sscottl UCHAR df_removable_drive; 73136849Sscottl UCHAR busyCount; 74136849Sscottl 75136849Sscottl UCHAR df_tcq_set: 1; 76149871Sscottl UCHAR df_tcq: 1; /* enable TCQ */ 77136849Sscottl UCHAR df_ncq_set: 1; 78149871Sscottl UCHAR df_ncq: 1; /* enable NCQ */ 79136849Sscottl UCHAR df_write_cache_set: 1; 80149871Sscottl UCHAR df_write_cache: 1; /* enable write cache */ 81136849Sscottl UCHAR df_read_ahead_set: 1; 82149871Sscottl UCHAR df_read_ahead: 1; /* enable read ahead */ 83149871Sscottl 84136849Sscottl UCHAR retryCount; 85136849Sscottl UCHAR resetCount; 86136849Sscottl UCHAR pad1; 87149871Sscottl 88136849Sscottl UCHAR df_user_mode_set; 89149871Sscottl UCHAR bDeModeSetting; /* Current Data Transfer mode: 0-4 PIO 0-4 */ 90149871Sscottl UCHAR bDeUsable_Mode; /* actual maximum data transfer mode */ 91136849Sscottl UCHAR bDeUserSelectMode; 92149871Sscottl 93136849Sscottl PVBus pVBus; 94136849Sscottl ULONG dDeRealCapacity; 95136849Sscottl ULONG dDeHiddenLba; 96136849Sscottl ULONG HeadPosition; 97136849Sscottl ULONG QueueLength; 98136849Sscottl MV_SATA_CHANNEL *mv; 99149871Sscottl} 100149871SscottlDevice, *PDevice; 101136849Sscottl 102149871Sscottltypedef struct _SCAT_GATH 103149871Sscottl{ 104149871Sscottl ULONG_PTR dSgAddress; 105149871Sscottl USHORT wSgSize; 106149871Sscottl USHORT wSgFlag; 107136849Sscottl} SCAT_GATH, FAR *FPSCAT_GATH; 108136849Sscottl 109136849Sscottl#define OS_VDEV_EXT 110149871Sscottltypedef struct _VDevice_Ext 111149871Sscottl{ 112136849Sscottl UCHAR gui_locked; /* the device is locked by GUI */ 113136849Sscottl UCHAR reserve[3]; 114136849Sscottl} VDevice_Ext, *PVDevice_Ext; 115136849Sscottl 116136849Sscottl 117136849Sscottl#define SG_FLAG_SKIP 0x4000 118136849Sscottl#define SG_FLAG_EOT 0x8000 119136849Sscottl 120136849Sscottl#define _VBUS_ARG0 PVBus _vbus_p 121136849Sscottl#define _VBUS_ARG PVBus _vbus_p, 122136849Sscottl#define _VBUS_P _vbus_p, 123136849Sscottl#define _VBUS_P0 _vbus_p 124136849Sscottl#define _VBUS_INST(x) PVBus _vbus_p = x; 125136849Sscottl#define _vbus_(x) (_vbus_p->x) 126136849Sscottl 127136849Sscottl/************************************************************************* 128136849Sscottl * arithmetic functions 129136849Sscottl *************************************************************************/ 130136849Sscottl#define LongRShift(x, y) (x >> y) 131136849Sscottl#define LongLShift(x, y) (x << y) 132136849Sscottl#define LongDiv(x, y) (x / (UINT)(y)) 133136849Sscottl#define LongRem(x, y) (x % (UINT)(y)) 134136849Sscottl#define LongMul(x, y) (x * y) 135136849Sscottl/* Minimum and maximum macros */ 136136849Sscottl#if (__FreeBSD_version < 501000) 137136849Sscottl#define MAX(a, b) (((a) > (b)) ? (a) : (b)) 138136849Sscottl#define MIN(a, b) (((a) < (b)) ? (a) : (b)) 139136849Sscottl#endif 140136849Sscottl 141136849Sscottl/************************************************************************* 142136849Sscottl * C library 143136849Sscottl *************************************************************************/ 144136849Sscottlint HPTLIBAPI os_memcmp(const void *cs, const void *ct, unsigned len); 145136849Sscottlvoid HPTLIBAPI os_memcpy(void *to, const void *from, unsigned len); 146136849Sscottlvoid HPTLIBAPI os_memset(void *s, char c, unsigned len); 147136849Sscottlunsigned HPTLIBAPI os_strlen(const char *s); 148149871Sscottl 149136849Sscottl#ifdef NO_LIBC 150136849Sscottl#define memcmp os_memcmp 151136849Sscottl#define memcpy os_memcpy 152136849Sscottl#define memset os_memset 153136849Sscottl#define strlen os_strlen 154136849Sscottl#elif (__FreeBSD_version <= 410000) 155149871Sscottl#define memcpy(d, s, len) bcopy((s),(d),(len)) 156149871Sscottl#define memset(d, s, len) bzero((d),(len)) 157136849Sscottl#endif 158136849Sscottl#define ZeroMemory(a, b) memset((char *)a, 0, b) 159136849Sscottl#define MemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)(c)) 160149871Sscottl#define farMemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)c) 161136849Sscottl#define StrLen strlen 162136849Sscottl 163136849Sscottl/* 164136849Sscottl * we don't want whole hptintf.h in shared code... 165136849Sscottl * some constants must match that in hptintf.h! 166136849Sscottl */ 167149871Sscottlenum _driver_events_t 168149871Sscottl{ 169136849Sscottl ET_DEVICE=0, 170149871Sscottl ET_DEVICE_REMOVED, 171149871Sscottl ET_DEVICE_PLUGGED, 172149871Sscottl ET_DEVICE_ERROR, 173149871Sscottl ET_REBUILD_STARTED, 174149871Sscottl ET_REBUILD_ABORTED, 175149871Sscottl ET_REBUILD_FINISHED, 176149871Sscottl ET_SPARE_TOOK_OVER, 177149871Sscottl ET_REBUILD_FAILED, 178136849Sscottl ET_VERIFY_STARTED, 179136849Sscottl ET_VERIFY_ABORTED, 180136849Sscottl ET_VERIFY_FAILED, 181136849Sscottl ET_VERIFY_FINISHED, 182136849Sscottl ET_INITIALIZE_STARTED, 183136849Sscottl ET_INITIALIZE_ABORTED, 184136849Sscottl ET_INITIALIZE_FAILED, 185136849Sscottl ET_INITIALIZE_FINISHED, 186136849Sscottl ET_VERIFY_DATA_ERROR, 187136849Sscottl}; 188136849Sscottl 189149871Sscottl#define StallExec(x) mvMicroSecondsDelay(x) 190136849Sscottlextern void HPTLIBAPI ioctl_ReportEvent(UCHAR event, PVOID param); 191149871Sscottl#define fNotifyGUI(WhatHappen, pVDevice) ioctl_ReportEvent(WhatHappen, pVDevice) 192149871Sscottl#define DECLARE_BUFFER(type, ptr) UCHAR ptr##__buf[512]; type ptr=(type)ptr##__buf 193136849Sscottl 194149871Sscottlint HPTLIBAPI fDeReadWrite(PDevice pDev, ULONG Lba, UCHAR Cmd, void *tmpBuffer); 195149871Sscottlvoid HPTLIBAPI fDeSelectMode(PDevice pDev, UCHAR NewMode); 196190809Sdelphijint HPTLIBAPI fDeSetTCQ(PDevice pDev, int enable, int depth); 197190809Sdelphijint HPTLIBAPI fDeSetNCQ(PDevice pDev, int enable, int depth); 198190809Sdelphijint HPTLIBAPI fDeSetWriteCache(PDevice pDev, int enable); 199190809Sdelphijint HPTLIBAPI fDeSetReadAhead(PDevice pDev, int enable); 200149871Sscottl 201143039Sscottl#include <dev/hptmv/atapi.h> 202143039Sscottl#include <dev/hptmv/command.h> 203143039Sscottl#include <dev/hptmv/array.h> 204143039Sscottl#include <dev/hptmv/raid5n.h> 205143039Sscottl#include <dev/hptmv/vdevice.h> 206136849Sscottl 207149871Sscottl#if defined(__FreeBSD__) && defined(HPTLIBAPI) 208149871Sscottl#undef HPTLIBAPI 209149871Sscottl#define HPTLIBAPI 210149871Sscottl#endif 211136849Sscottl 212136849Sscottl#ifdef SUPPORT_ARRAY 213136849Sscottl#define ArrayTables(i) ((PVDevice)&_vbus_(_ArrayTables)[i*ARRAY_VDEV_SIZE]) 214136849Sscottl#endif 215136849Sscottl 216136849Sscottl#endif 217