2 * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
26 * $FreeBSD: src/sys/dev/hptmv/mvOs.h,v 1.6 2009/04/07 16:38:25 delphij Exp $
35 #define ENABLE_READ_AHEAD
36 #define ENABLE_WRITE_CACHE
39 /*#define HPTLIBAPI __attribute__((regparm(0))) */
46 #define FASTCALL HPTLIBAPI
47 #define PASCAL HPTLIBAPI
49 typedef unsigned short USHORT;
50 typedef unsigned char UCHAR;
51 typedef unsigned char *PUCHAR;
52 typedef unsigned short *PUSHORT;
53 typedef unsigned char BOOLEAN;
54 typedef unsigned short WORD;
55 typedef unsigned int UINT, BOOL;
56 typedef unsigned char BYTE;
57 typedef void *PVOID, *LPVOID;
58 typedef void *ADDRESS;
61 typedef unsigned int ULONG, *PULONG;
62 typedef unsigned int DWORD, *LPDWORD, *PDWORD;
63 typedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR;
64 typedef unsigned long long HPT_U64, LBA_T;
66 typedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN;
75 /* System dependant typedefs */
77 typedef unsigned int MV_U32;
78 typedef unsigned short MV_U16;
79 typedef unsigned char MV_U8;
80 typedef void *MV_VOID_PTR;
81 typedef MV_U32 *MV_U32_PTR;
82 typedef MV_U16 *MV_U16_PTR;
83 typedef MV_U8 *MV_U8_PTR;
84 typedef char *MV_CHAR_PTR;
85 typedef void *MV_BUS_ADDR_T;
87 /* System dependent macro for flushing CPU write cache */
88 #define MV_CPU_WRITE_BUFFER_FLUSH()
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)
94 #define MV_LE16_TO_CPU(x) (x)
95 #define MV_LE32_TO_CPU(x) (x)
97 /* System dependent register read / write in byte/word/dword variants */
98 extern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val);
99 extern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val);
100 extern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val);
101 extern MV_U8 HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset);
102 extern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset);
103 extern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset);
105 /* System dependent structure */
106 typedef struct mvOsSemaphore
111 /* Functions (User implemented)*/
112 ULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr);
114 /* Semaphore init, take and release */
115 #define mvOsSemInit(p) (MV_TRUE)
116 #define mvOsSemTake(p) (MV_TRUE)
117 #define mvOsSemRelease(p) (MV_TRUE)
119 /* Delay function in micro seconds resolution */
120 void HPTLIBAPI mvMicroSecondsDelay(MV_U32);
122 /* System logging function */
124 int mvLogMsg(MV_U8, MV_CHAR_PTR, ...);
125 #define _mvLogMsg(x) mvLogMsg x
127 #define mvLogMsg(x...)
131 /*************************************************************************
133 *************************************************************************/
135 #define HPT_ASSERT(x) do { if (!(x)) { \
136 kprintf("ASSERT fail at %s line %d", __FILE__, __LINE__); \
139 extern int hpt_dbg_level;
140 #define KdPrintI(_x_) do{ if (hpt_dbg_level>2) kprintf _x_; }while(0)
141 #define KdPrintW(_x_) do{ if (hpt_dbg_level>1) kprintf _x_; }while(0)
142 #define KdPrintE(_x_) do{ if (hpt_dbg_level>0) kprintf _x_; }while(0)
143 #define KdPrint(x) KdPrintI(x)
145 #define HPT_ASSERT(x)