1240116Smarcel/* 2240116Smarcel * Copyright (c) 2004-2005 HighPoint Technologies, Inc. 3240116Smarcel * All rights reserved. 4240116Smarcel * 5240116Smarcel * Redistribution and use in source and binary forms, with or without 6240116Smarcel * modification, are permitted provided that the following conditions 7240116Smarcel * are met: 8240116Smarcel * 1. Redistributions of source code must retain the above copyright 9240116Smarcel * notice, this list of conditions and the following disclaimer. 10240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11240116Smarcel * notice, this list of conditions and the following disclaimer in the 12240116Smarcel * documentation and/or other materials provided with the distribution. 13240116Smarcel * 14240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15240116Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16240116Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17240116Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18240116Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19240116Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20240116Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21240116Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22240116Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23240116Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24240116Smarcel * SUCH DAMAGE. 25240116Smarcel * 26240116Smarcel * $FreeBSD$ 27240116Smarcel */ 28240116Smarcel#ifndef __INCmvOsBsdh 29240116Smarcel#define __INCmvOsBsdh 30240116Smarcel 31240116Smarcel#ifdef DEBUG 32240116Smarcel#define MV_DEBUG_LOG 33240116Smarcel#endif 34240116Smarcel 35240116Smarcel#define ENABLE_READ_AHEAD 36240116Smarcel#define ENABLE_WRITE_CACHE 37240116Smarcel 38240116Smarcel/* Typedefs */ 39240116Smarcel/*#define HPTLIBAPI __attribute__((regparm(0))) */ 40240116Smarcel#define HPTLIBAPI 41240116Smarcel#define FAR 42240116Smarcel#define SS_SEG 43240116Smarcel#ifdef FASTCALL 44240116Smarcel#undef FASTCALL 45240116Smarcel#endif 46240116Smarcel#define FASTCALL HPTLIBAPI 47240116Smarcel#define PASCAL HPTLIBAPI 48240116Smarcel 49240116Smarceltypedef unsigned short USHORT; 50typedef unsigned char UCHAR; 51typedef unsigned char *PUCHAR; 52typedef unsigned short *PUSHORT; 53typedef unsigned char BOOLEAN; 54typedef unsigned short WORD; 55typedef unsigned int UINT, BOOL; 56typedef unsigned char BYTE; 57typedef void *PVOID, *LPVOID; 58typedef void *ADDRESS; 59 60typedef int LONG; 61typedef unsigned int ULONG, *PULONG; 62typedef unsigned int DWORD, *LPDWORD, *PDWORD; 63typedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR; 64typedef unsigned long long HPT_U64, LBA_T; 65 66typedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN; 67 68#define FALSE 0 69#define TRUE 1 70 71#ifndef NULL 72#define NULL 0 73#endif 74 75/* System dependant typedefs */ 76typedef void MV_VOID; 77typedef unsigned int MV_U32; 78typedef unsigned short MV_U16; 79typedef unsigned char MV_U8; 80typedef void *MV_VOID_PTR; 81typedef MV_U32 *MV_U32_PTR; 82typedef MV_U16 *MV_U16_PTR; 83typedef MV_U8 *MV_U8_PTR; 84typedef char *MV_CHAR_PTR; 85typedef void *MV_BUS_ADDR_T; 86 87/* System dependent macro for flushing CPU write cache */ 88#define MV_CPU_WRITE_BUFFER_FLUSH() 89 90/* System dependent little endian from / to CPU conversions */ 91#define MV_CPU_TO_LE16(x) (x) 92#define MV_CPU_TO_LE32(x) (x) 93 94#define MV_LE16_TO_CPU(x) (x) 95#define MV_LE32_TO_CPU(x) (x) 96 97/* System dependent register read / write in byte/word/dword variants */ 98extern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val); 99extern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val); 100extern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val); 101extern MV_U8 HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset); 102extern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset); 103extern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset); 104 105/* System dependent structure */ 106typedef struct mvOsSemaphore 107{ 108 int notused; 109} MV_OS_SEMAPHORE; 110 111/* Functions (User implemented)*/ 112ULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr); 113 114/* Semaphore init, take and release */ 115#define mvOsSemInit(p) (MV_TRUE) 116#define mvOsSemTake(p) (MV_TRUE) 117#define mvOsSemRelease(p) (MV_TRUE) 118 119/* Delay function in micro seconds resolution */ 120void HPTLIBAPI mvMicroSecondsDelay(MV_U32); 121 122/* System logging function */ 123#ifdef MV_DEBUG_LOG 124int mvLogMsg(MV_U8, MV_CHAR_PTR, ...); 125#define _mvLogMsg(x) mvLogMsg x 126#else 127#define mvLogMsg(x...) 128#define _mvLogMsg(x) 129#endif 130 131/************************************************************************* 132 * Debug support 133 *************************************************************************/ 134#ifdef DEBUG 135#define HPT_ASSERT(x) do { if (!(x)) { \ 136 printf("ASSERT fail at %s line %d", __FILE__, __LINE__); \ 137 while (1); \ 138 }} while (0) 139extern int hpt_dbg_level; 140#define KdPrintI(_x_) do{ if (hpt_dbg_level>2) printf _x_; }while(0) 141#define KdPrintW(_x_) do{ if (hpt_dbg_level>1) printf _x_; }while(0) 142#define KdPrintE(_x_) do{ if (hpt_dbg_level>0) printf _x_; }while(0) 143#define KdPrint(x) KdPrintI(x) 144#else 145#define HPT_ASSERT(x) 146#define KdPrint(x) 147#define KdPrintI(x) 148#define KdPrintW(x) 149#define KdPrintE(x) 150#endif 151 152#endif 153