1331722Seadler/*
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 __INCmvOsBsdh
29136849Sscottl#define __INCmvOsBsdh
30136849Sscottl
31190809Sdelphij#ifdef DEBUG
32136849Sscottl#define MV_DEBUG_LOG
33136849Sscottl#endif
34136849Sscottl
35136849Sscottl#define ENABLE_READ_AHEAD
36136849Sscottl#define ENABLE_WRITE_CACHE
37136849Sscottl
38136849Sscottl/* Typedefs    */
39149871Sscottl/*#define HPTLIBAPI __attribute__((regparm(0))) */
40149871Sscottl#define HPTLIBAPI
41136849Sscottl#define FAR
42149871Sscottl#define SS_SEG
43136849Sscottl#ifdef FASTCALL
44136849Sscottl#undef FASTCALL
45136849Sscottl#endif
46136849Sscottl#define FASTCALL HPTLIBAPI
47136849Sscottl#define PASCAL HPTLIBAPI
48136849Sscottl
49149871Sscottltypedef unsigned short USHORT;
50149871Sscottltypedef unsigned char  UCHAR;
51149871Sscottltypedef unsigned char *PUCHAR;
52149871Sscottltypedef unsigned short *PUSHORT;
53149871Sscottltypedef unsigned char  BOOLEAN;
54149871Sscottltypedef unsigned short WORD;
55149871Sscottltypedef unsigned int   UINT, BOOL;
56149871Sscottltypedef unsigned char  BYTE;
57136849Sscottltypedef void *PVOID, *LPVOID;
58136849Sscottltypedef void *ADDRESS;
59136849Sscottl
60136849Sscottltypedef int  LONG;
61190809Sdelphijtypedef unsigned int ULONG, *PULONG;
62136849Sscottltypedef unsigned int DWORD, *LPDWORD, *PDWORD;
63136849Sscottltypedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR;
64190809Sdelphijtypedef unsigned long long HPT_U64, LBA_T;
65136849Sscottl
66136849Sscottltypedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN;
67136849Sscottl
68136849Sscottl#define FALSE 0
69136849Sscottl#define TRUE  1
70136849Sscottl
71149871Sscottl#ifndef NULL
72149871Sscottl#define NULL  0
73149871Sscottl#endif
74149871Sscottl
75298955Spfg/* System dependent typedefs */
76149871Sscottltypedef void			MV_VOID;
77149871Sscottltypedef unsigned int 	MV_U32;
78149871Sscottltypedef unsigned short	MV_U16;
79149871Sscottltypedef unsigned char	MV_U8;
80149871Sscottltypedef void			*MV_VOID_PTR;
81149871Sscottltypedef MV_U32			*MV_U32_PTR;
82149871Sscottltypedef MV_U16 			*MV_U16_PTR;
83149871Sscottltypedef MV_U8			*MV_U8_PTR;
84149871Sscottltypedef char			*MV_CHAR_PTR;
85149871Sscottltypedef void			*MV_BUS_ADDR_T;
86136849Sscottl
87136849Sscottl/* System dependent macro for flushing CPU write cache */
88136849Sscottl#define MV_CPU_WRITE_BUFFER_FLUSH()
89136849Sscottl
90136849Sscottl/* System dependent little endian from / to CPU conversions */
91136849Sscottl#define MV_CPU_TO_LE16(x)	(x)
92136849Sscottl#define MV_CPU_TO_LE32(x)	(x)
93136849Sscottl
94136849Sscottl#define MV_LE16_TO_CPU(x)	(x)
95136849Sscottl#define MV_LE32_TO_CPU(x)	(x)
96136849Sscottl
97136849Sscottl/* System dependent register read / write in byte/word/dword variants */
98149871Sscottlextern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val);
99149871Sscottlextern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val);
100149871Sscottlextern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val);
101136849Sscottlextern MV_U8  HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset);
102136849Sscottlextern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset);
103136849Sscottlextern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset);
104136849Sscottl
105136849Sscottl/* System dependent structure */
106136849Sscottltypedef struct mvOsSemaphore
107136849Sscottl{
108136849Sscottl	int notused;
109136849Sscottl} MV_OS_SEMAPHORE;
110136849Sscottl
111136849Sscottl/* Functions (User implemented)*/
112136849SscottlULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr);
113136849Sscottl
114136849Sscottl/* Semaphore init, take and release */
115149871Sscottl#define mvOsSemInit(p)		(MV_TRUE)
116149871Sscottl#define mvOsSemTake(p)		(MV_TRUE)
117149871Sscottl#define mvOsSemRelease(p)	(MV_TRUE)
118136849Sscottl
119136849Sscottl/* Delay function in micro seconds resolution */
120136849Sscottlvoid HPTLIBAPI mvMicroSecondsDelay(MV_U32);
121136849Sscottl
122136849Sscottl/* System logging function */
123136849Sscottl#ifdef MV_DEBUG_LOG
124136849Sscottlint mvLogMsg(MV_U8, MV_CHAR_PTR, ...);
125136849Sscottl#define _mvLogMsg(x) mvLogMsg x
126149871Sscottl#else
127136849Sscottl#define mvLogMsg(x...)
128136849Sscottl#define _mvLogMsg(x)
129136849Sscottl#endif
130136849Sscottl
131136849Sscottl/*************************************************************************
132136849Sscottl * Debug support
133136849Sscottl *************************************************************************/
134153072Sru#ifdef DEBUG
135149871Sscottl#define HPT_ASSERT(x) do { if (!(x)) { \
136149871Sscottl						printf("ASSERT fail at %s line %d", __FILE__, __LINE__); \
137149871Sscottl						while (1); \
138149871Sscottl					  }} while (0)
139136849Sscottlextern int hpt_dbg_level;
140136849Sscottl#define KdPrintI(_x_) do{ if (hpt_dbg_level>2) printf _x_; }while(0)
141136849Sscottl#define KdPrintW(_x_) do{ if (hpt_dbg_level>1) printf _x_; }while(0)
142136849Sscottl#define KdPrintE(_x_) do{ if (hpt_dbg_level>0) printf _x_; }while(0)
143136849Sscottl#define KdPrint(x) KdPrintI(x)
144149871Sscottl#else
145136849Sscottl#define HPT_ASSERT(x)
146136849Sscottl#define KdPrint(x)
147136849Sscottl#define KdPrintI(x)
148136849Sscottl#define KdPrintW(x)
149136849Sscottl#define KdPrintE(x)
150136849Sscottl#endif
151136849Sscottl
152149871Sscottl#endif
153