FreeBSD/Linux Kernel Cross Reference
sys/dev/hptmv/mvOs.h
1 /*
2 * Copyright (c) 2003-2004 HighPoint Technologies, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
13 *
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
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: releng/5.3/sys/dev/hptmv/mvOs.h 136856 2004-10-24 08:38:29Z scottl $
27 */
28 #ifndef __INCmvOsBsdh
29 #define __INCmvOsBsdh
30
31 /* Taken out of the Makefile magic */
32 #define __KERNEL__ 1
33 #define KERNEL 1
34 #define _KERNEL 1
35 #define _FREEBSD_ 1
36
37 /*
38 * This binary object core for this driver is only for x86, so this constant
39 * will not change.
40 */
41 #define BITS_PER_LONG 32
42 #define DRIVER_VERSION "1.1"
43
44 #if DBG
45 #define MV_DEBUG_LOG
46 #endif
47
48 #define ENABLE_READ_AHEAD
49 #define ENABLE_WRITE_CACHE
50
51 /* Typedefs */
52 #define HPTLIBAPI __attribute__((regparm(0)))
53 #define FAR
54 #ifdef FASTCALL
55 #undef FASTCALL
56 #endif
57 #define FASTCALL HPTLIBAPI
58 #define PASCAL HPTLIBAPI
59
60 typedef u_short USHORT;
61 typedef u_char UCHAR;
62 typedef u_char *PUCHAR;
63 typedef u_short *PUSHORT;
64 typedef u_char BOOLEAN;
65 typedef u_short WORD;
66 typedef u_int UINT, BOOL;
67 typedef u_char BYTE;
68 typedef void *PVOID, *LPVOID;
69 typedef void *ADDRESS;
70
71 typedef int LONG;
72 typedef unsigned int ULONG, *PULONG, LBA_T;
73 typedef unsigned int DWORD, *LPDWORD, *PDWORD;
74 typedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR;
75
76 typedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN;
77
78 #define FALSE 0
79 #define TRUE 1
80
81 /* System dependant typedefs */
82 typedef void MV_VOID;
83 typedef uint32_t MV_U32;
84 typedef uint16_t MV_U16;
85 typedef uint8_t MV_U8;
86 typedef void *MV_VOID_PTR;
87 typedef MV_U32 *MV_U32_PTR;
88 typedef MV_U16 *MV_U16_PTR;
89 typedef MV_U8 *MV_U8_PTR;
90 typedef char *MV_CHAR_PTR;
91 typedef void *MV_BUS_ADDR_T;
92
93 /* System dependent macro for flushing CPU write cache */
94 #define MV_CPU_WRITE_BUFFER_FLUSH()
95
96 /* System dependent little endian from / to CPU conversions */
97 #define MV_CPU_TO_LE16(x) (x)
98 #define MV_CPU_TO_LE32(x) (x)
99
100 #define MV_LE16_TO_CPU(x) (x)
101 #define MV_LE32_TO_CPU(x) (x)
102
103 /* System dependent register read / write in byte/word/dword variants */
104 extern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset,
105 MV_U8 val);
106 extern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset,
107 MV_U16 val);
108 extern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset,
109 MV_U32 val);
110 extern MV_U8 HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset);
111 extern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset);
112 extern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset);
113
114 /* System dependent structure */
115 typedef struct mvOsSemaphore
116 {
117 int notused;
118 } MV_OS_SEMAPHORE;
119
120 /* Functions (User implemented)*/
121 ULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr);
122
123 /* Semaphore init, take and release */
124 static __inline int
125 mvOsSemInit(MV_OS_SEMAPHORE *p)
126 {
127 return (MV_TRUE);
128 }
129
130 static __inline int
131 mvOsSemTake(MV_OS_SEMAPHORE *p)
132 {
133 return (MV_TRUE);
134 }
135
136 static __inline int
137 mvOsSemRelease(MV_OS_SEMAPHORE *p)
138 {
139 return (MV_TRUE);
140 }
141
142 #define MV_MAX_SEGMENTS 255
143
144 /* Delay function in micro seconds resolution */
145 void HPTLIBAPI mvMicroSecondsDelay(MV_U32);
146
147 /* System logging function */
148 #ifdef MV_DEBUG_LOG
149 int mvLogMsg(MV_U8, MV_CHAR_PTR, ...);
150 #define _mvLogMsg(x) mvLogMsg x
151 #else
152 #define mvLogMsg(x...)
153 #define _mvLogMsg(x)
154 #endif
155
156 /*************************************************************************
157 * Debug support
158 *************************************************************************/
159 #ifdef DEBUG
160 #define HPT_ASSERT(x) \
161 KASSERT((x), ("ASSERT fail at %s line %d", __FILE__, __LINE__))
162
163 extern int hpt_dbg_level;
164 #define KdPrintI(_x_) do{ if (hpt_dbg_level>2) printf _x_; }while(0)
165 #define KdPrintW(_x_) do{ if (hpt_dbg_level>1) printf _x_; }while(0)
166 #define KdPrintE(_x_) do{ if (hpt_dbg_level>0) printf _x_; }while(0)
167 #define KdPrint(x) KdPrintI(x)
168 #else
169 #define HPT_ASSERT(x)
170 #define KdPrint(x)
171 #define KdPrintI(x)
172 #define KdPrintW(x)
173 #define KdPrintE(x)
174 #endif
175
176 #endif /* __INCmvOsBsdh */
Cache object: ff1034b96983a090187bf2aea12aa399
|