mvOs.h revision 190809
1216232Sjhb/*
2216232Sjhb * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
3216232Sjhb * All rights reserved.
4216232Sjhb *
5216232Sjhb * Redistribution and use in source and binary forms, with or without
6216232Sjhb * modification, are permitted provided that the following conditions
7216232Sjhb * are met:
8216232Sjhb * 1. Redistributions of source code must retain the above copyright
9216232Sjhb *    notice, this list of conditions and the following disclaimer.
10216232Sjhb * 2. Redistributions in binary form must reproduce the above copyright
11216232Sjhb *    notice, this list of conditions and the following disclaimer in the
12216232Sjhb *    documentation and/or other materials provided with the distribution.
13216232Sjhb *
14216232Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15216232Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16216232Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17216232Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18216232Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19216232Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20216232Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21216232Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22216232Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23216232Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24216232Sjhb * SUCH DAMAGE.
25216232Sjhb *
26216232Sjhb * $FreeBSD: head/sys/dev/hptmv/mvOs.h 190809 2009-04-07 16:38:25Z delphij $
27216232Sjhb */
28216232Sjhb#ifndef __INCmvOsBsdh
29216232Sjhb#define __INCmvOsBsdh
30216232Sjhb
31216232Sjhb#ifdef DEBUG
32233648Seadler#define MV_DEBUG_LOG
33216232Sjhb#endif
34216232Sjhb
35216232Sjhb#define ENABLE_READ_AHEAD
36216232Sjhb#define ENABLE_WRITE_CACHE
37216232Sjhb
38216232Sjhb/* Typedefs    */
39216232Sjhb/*#define HPTLIBAPI __attribute__((regparm(0))) */
40216232Sjhb#define HPTLIBAPI
41216232Sjhb#define FAR
42216232Sjhb#define SS_SEG
43216232Sjhb#ifdef FASTCALL
44216232Sjhb#undef FASTCALL
45216232Sjhb#endif
46216232Sjhb#define FASTCALL HPTLIBAPI
47216232Sjhb#define PASCAL HPTLIBAPI
48216232Sjhb
49216232Sjhbtypedef unsigned short USHORT;
50216232Sjhbtypedef unsigned char  UCHAR;
51216232Sjhbtypedef unsigned char *PUCHAR;
52216232Sjhbtypedef unsigned short *PUSHORT;
53216232Sjhbtypedef unsigned char  BOOLEAN;
54216232Sjhbtypedef unsigned short WORD;
55216232Sjhbtypedef unsigned int   UINT, BOOL;
56216232Sjhbtypedef unsigned char  BYTE;
57216232Sjhbtypedef void *PVOID, *LPVOID;
58216232Sjhbtypedef void *ADDRESS;
59216232Sjhb
60216232Sjhbtypedef int  LONG;
61216232Sjhbtypedef unsigned int ULONG, *PULONG;
62216232Sjhbtypedef unsigned int DWORD, *LPDWORD, *PDWORD;
63216232Sjhbtypedef unsigned long ULONG_PTR, UINT_PTR, BUS_ADDR;
64216232Sjhbtypedef unsigned long long HPT_U64, LBA_T;
65216232Sjhb
66216232Sjhbtypedef enum mvBoolean{MV_FALSE, MV_TRUE} MV_BOOLEAN;
67216232Sjhb
68216232Sjhb#define FALSE 0
69216232Sjhb#define TRUE  1
70216232Sjhb
71216232Sjhb#ifndef NULL
72216232Sjhb#define NULL  0
73216232Sjhb#endif
74216232Sjhb
75216232Sjhb/* System dependant typedefs */
76216232Sjhbtypedef void			MV_VOID;
77216232Sjhbtypedef unsigned int 	MV_U32;
78216232Sjhbtypedef unsigned short	MV_U16;
79216232Sjhbtypedef unsigned char	MV_U8;
80216232Sjhbtypedef void			*MV_VOID_PTR;
81216232Sjhbtypedef MV_U32			*MV_U32_PTR;
82216232Sjhbtypedef MV_U16 			*MV_U16_PTR;
83216232Sjhbtypedef MV_U8			*MV_U8_PTR;
84216232Sjhbtypedef char			*MV_CHAR_PTR;
85216232Sjhbtypedef void			*MV_BUS_ADDR_T;
86216232Sjhb
87216232Sjhb/* System dependent macro for flushing CPU write cache */
88216232Sjhb#define MV_CPU_WRITE_BUFFER_FLUSH()
89216232Sjhb
90216232Sjhb/* System dependent little endian from / to CPU conversions */
91216232Sjhb#define MV_CPU_TO_LE16(x)	(x)
92216232Sjhb#define MV_CPU_TO_LE32(x)	(x)
93216232Sjhb
94216232Sjhb#define MV_LE16_TO_CPU(x)	(x)
95216232Sjhb#define MV_LE32_TO_CPU(x)	(x)
96216232Sjhb
97216232Sjhb/* System dependent register read / write in byte/word/dword variants */
98216232Sjhbextern void HPTLIBAPI MV_REG_WRITE_BYTE(MV_BUS_ADDR_T base, MV_U32 offset, MV_U8 val);
99216232Sjhbextern void HPTLIBAPI MV_REG_WRITE_WORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U16 val);
100216232Sjhbextern void HPTLIBAPI MV_REG_WRITE_DWORD(MV_BUS_ADDR_T base, MV_U32 offset, MV_U32 val);
101216232Sjhbextern MV_U8  HPTLIBAPI MV_REG_READ_BYTE(MV_BUS_ADDR_T base, MV_U32 offset);
102216232Sjhbextern MV_U16 HPTLIBAPI MV_REG_READ_WORD(MV_BUS_ADDR_T base, MV_U32 offset);
103216232Sjhbextern MV_U32 HPTLIBAPI MV_REG_READ_DWORD(MV_BUS_ADDR_T base, MV_U32 offset);
104216232Sjhb
105216232Sjhb/* System dependent structure */
106216232Sjhbtypedef struct mvOsSemaphore
107216232Sjhb{
108216232Sjhb	int notused;
109216232Sjhb} MV_OS_SEMAPHORE;
110216232Sjhb
111216232Sjhb/* Functions (User implemented)*/
112216232SjhbULONG_PTR HPTLIBAPI fOsPhysicalAddress(void *addr);
113216232Sjhb
114216232Sjhb/* Semaphore init, take and release */
115216232Sjhb#define mvOsSemInit(p)		(MV_TRUE)
116216232Sjhb#define mvOsSemTake(p)		(MV_TRUE)
117216232Sjhb#define mvOsSemRelease(p)	(MV_TRUE)
118216232Sjhb
119216232Sjhb/* Delay function in micro seconds resolution */
120216232Sjhbvoid HPTLIBAPI mvMicroSecondsDelay(MV_U32);
121216232Sjhb
122216232Sjhb/* System logging function */
123216232Sjhb#ifdef MV_DEBUG_LOG
124216232Sjhbint mvLogMsg(MV_U8, MV_CHAR_PTR, ...);
125216232Sjhb#define _mvLogMsg(x) mvLogMsg x
126216232Sjhb#else
127216232Sjhb#define mvLogMsg(x...)
128216232Sjhb#define _mvLogMsg(x)
129216232Sjhb#endif
130216232Sjhb
131216232Sjhb/*************************************************************************
132216232Sjhb * Debug support
133216232Sjhb *************************************************************************/
134216232Sjhb#ifdef DEBUG
135216232Sjhb#define HPT_ASSERT(x) do { if (!(x)) { \
136216232Sjhb						printf("ASSERT fail at %s line %d", __FILE__, __LINE__); \
137216232Sjhb						while (1); \
138216232Sjhb					  }} while (0)
139216232Sjhbextern int hpt_dbg_level;
140216232Sjhb#define KdPrintI(_x_) do{ if (hpt_dbg_level>2) printf _x_; }while(0)
141216232Sjhb#define KdPrintW(_x_) do{ if (hpt_dbg_level>1) printf _x_; }while(0)
142216232Sjhb#define KdPrintE(_x_) do{ if (hpt_dbg_level>0) printf _x_; }while(0)
143216232Sjhb#define KdPrint(x) KdPrintI(x)
144216232Sjhb#else
145216232Sjhb#define HPT_ASSERT(x)
146216232Sjhb#define KdPrint(x)
147216232Sjhb#define KdPrintI(x)
148216232Sjhb#define KdPrintW(x)
149216232Sjhb#define KdPrintE(x)
150216232Sjhb#endif
151216232Sjhb
152216232Sjhb#endif
153216232Sjhb