mvOs.h revision 136849
1136849Sscottl/* 2136849Sscottl * Copyright (c) 2003-2004 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: head/sys/dev/hptmv/mvOs.h 136849 2004-10-24 05:37:23Z scottl $ 27136849Sscottl */ 28136849Sscottl#ifndef __INCmvOsBsdh 29136849Sscottl#define __INCmvOsBsdh 30136849Sscottl 31136849Sscottl#if DBG 32136849Sscottl#define MV_DEBUG_LOG 33136849Sscottl#endif 34136849Sscottl 35136849Sscottl#define ENABLE_READ_AHEAD 36136849Sscottl#define ENABLE_WRITE_CACHE 37136849Sscottl 38136849Sscottl/* Typedefs */ 39136849Sscottl#define HPTLIBAPI __attribute__((regparm(0))) 40136849Sscottl#define FAR 41136849Sscottl#ifdef FASTCALL 42136849Sscottl#undef FASTCALL 43136849Sscottl#endif 44136849Sscottl#define FASTCALL HPTLIBAPI 45136849Sscottl#define PASCAL HPTLIBAPI 46136849Sscottl 47136849Sscottltypedef u_short USHORT; 48136849Sscottltypedef u_char UCHAR; 49136849Sscottltypedef u_char *PUCHAR; 50136849Sscottltypedef u_short *PUSHORT; 51136849Sscottltypedef u_char BOOLEAN; 52136849Sscottltypedef u_short WORD; 53136849Sscottltypedef u_int UINT, BOOL; 54136849Sscottltypedef u_char BYTE; 55136849Sscottltypedef void *PVOID, *LPVOID; 56136849Sscottltypedef void *ADDRESS; 57136849Sscottl 58136849Sscottltypedef int LONG; 59136849Sscottltypedef unsigned int ULONG, *PULONG, LBA_T; 60136849Sscottltypedef unsigned int DWORD, *LPDWORD, *PDWORD; 61136849Sscottltypedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR; 62136849Sscottl 63136849Sscottltypedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN; 64136849Sscottl 65136849Sscottl#define FALSE 0 66136849Sscottl#define TRUE 1 67136849Sscottl 68136849Sscottl/* System dependant typedefs */ 69136849Sscottltypedef void MV_VOID; 70136849Sscottltypedef uint32_t MV_U32; 71136849Sscottltypedef uint16_t MV_U16; 72136849Sscottltypedef uint8_t MV_U8; 73136849Sscottltypedef void *MV_VOID_PTR; 74136849Sscottltypedef MV_U32 *MV_U32_PTR; 75136849Sscottltypedef MV_U16 *MV_U16_PTR; 76136849Sscottltypedef MV_U8 *MV_U8_PTR; 77136849Sscottltypedef char *MV_CHAR_PTR; 78136849Sscottltypedef void *MV_BUS_ADDR_T; 79136849Sscottl 80136849Sscottl/* System dependent macro for flushing CPU write cache */ 81136849Sscottl#define MV_CPU_WRITE_BUFFER_FLUSH() 82136849Sscottl 83136849Sscottl/* System dependent little endian from / to CPU conversions */ 84136849Sscottl#define MV_CPU_TO_LE16(x) (x) 85136849Sscottl#define MV_CPU_TO_LE32(x) (x) 86136849Sscottl 87136849Sscottl#define MV_LE16_TO_CPU(x) (x) 88136849Sscottl#define MV_LE32_TO_CPU(x) (x) 89136849Sscottl 90136849Sscottl/* System dependent register read / write in byte/word/dword variants */ 91136849Sscottlextern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, 92136849Sscottl MV_U8 val); 93136849Sscottlextern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, 94136849Sscottl MV_U16 val); 95136849Sscottlextern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, 96136849Sscottl MV_U32 val); 97136849Sscottlextern MV_U8 HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset); 98136849Sscottlextern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset); 99136849Sscottlextern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset); 100136849Sscottl 101136849Sscottl/* System dependent structure */ 102136849Sscottltypedef struct mvOsSemaphore 103136849Sscottl{ 104136849Sscottl int notused; 105136849Sscottl} MV_OS_SEMAPHORE; 106136849Sscottl 107136849Sscottl/* Functions (User implemented)*/ 108136849SscottlULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr); 109136849Sscottl 110136849Sscottl/* Semaphore init, take and release */ 111136849Sscottlstatic __inline int 112136849SscottlmvOsSemInit(MV_OS_SEMAPHORE *p) 113136849Sscottl{ 114136849Sscottl return (MV_TRUE); 115136849Sscottl} 116136849Sscottl 117136849Sscottlstatic __inline int 118136849SscottlmvOsSemTake(MV_OS_SEMAPHORE *p) 119136849Sscottl{ 120136849Sscottl return (MV_TRUE); 121136849Sscottl} 122136849Sscottl 123136849Sscottlstatic __inline int 124136849SscottlmvOsSemRelease(MV_OS_SEMAPHORE *p) 125136849Sscottl{ 126136849Sscottl return (MV_TRUE); 127136849Sscottl} 128136849Sscottl 129136849Sscottl#define MV_MAX_SEGMENTS 255 130136849Sscottl 131136849Sscottl/* Delay function in micro seconds resolution */ 132136849Sscottlvoid HPTLIBAPI mvMicroSecondsDelay(MV_U32); 133136849Sscottl 134136849Sscottl/* System logging function */ 135136849Sscottl#ifdef MV_DEBUG_LOG 136136849Sscottlint mvLogMsg(MV_U8, MV_CHAR_PTR, ...); 137136849Sscottl#define _mvLogMsg(x) mvLogMsg x 138136849Sscottl#else 139136849Sscottl#define mvLogMsg(x...) 140136849Sscottl#define _mvLogMsg(x) 141136849Sscottl#endif 142136849Sscottl 143136849Sscottl/************************************************************************* 144136849Sscottl * Debug support 145136849Sscottl *************************************************************************/ 146136849Sscottl#ifdef DEBUG 147136849Sscottl#define HPT_ASSERT(x) \ 148136849Sscottl KASSERT((x), ("ASSERT fail at %s line %d", __FILE__, __LINE__)) 149136849Sscottl 150136849Sscottlextern int hpt_dbg_level; 151136849Sscottl#define KdPrintI(_x_) do{ if (hpt_dbg_level>2) printf _x_; }while(0) 152136849Sscottl#define KdPrintW(_x_) do{ if (hpt_dbg_level>1) printf _x_; }while(0) 153136849Sscottl#define KdPrintE(_x_) do{ if (hpt_dbg_level>0) printf _x_; }while(0) 154136849Sscottl#define KdPrint(x) KdPrintI(x) 155136849Sscottl#else 156136849Sscottl#define HPT_ASSERT(x) 157136849Sscottl#define KdPrint(x) 158136849Sscottl#define KdPrintI(x) 159136849Sscottl#define KdPrintW(x) 160136849Sscottl#define KdPrintE(x) 161136849Sscottl#endif 162136849Sscottl 163136849Sscottl#endif /* __INCmvOsBsdh */ 164