BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / drivers / audio / echo / generic / OsSupportBeOS.h
blob9556f3366aa74e4e1fd54d3a82981ec916e60783
1 // ****************************************************************************
2 //
3 // OsSupportBeOS.H
4 //
5 // Set editor tabs to 3 for your viewing pleasure.
6 //
7 // ----------------------------------------------------------------------------
8 //
9 // This file is part of Echo Digital Audio's generic driver library.
10 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
11 // All rights reserved
12 // www.echoaudio.com
14 // This library is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Lesser General Public
16 // License as published by the Free Software Foundation; either
17 // version 2.1 of the License, or (at your option) any later version.
19 // This library is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 // Lesser General Public License for more details.
24 // You should have received a copy of the GNU Lesser General Public
25 // License along with this library; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // ****************************************************************************
30 // Prevent problems with multiple includes
31 #ifndef _ECHOOSSUPPORTBEOS_
32 #define _ECHOOSSUPPORTBEOS_
34 #include <KernelExport.h>
35 #include <SupportDefs.h>
36 #include <ByteOrder.h>
37 #include "queue.h"
38 #include "debug.h"
40 #include <stdio.h>
41 #include <string.h>
42 #include "util/kernel_cpp.h"
44 #if DEBUG > 0
45 // BeOS debug printf macro
46 #define ECHO_DEBUGPRINTF( strings ) TRACE(strings)
47 #define ECHO_DEBUGBREAK() kernel_debugger("echo driver debug break");
48 #define ECHO_DEBUG
50 #else
52 #define ECHO_DEBUGPRINTF( strings )
53 #define ECHO_DEBUGBREAK()
55 #endif
58 // Assert macro
60 //#define ECHO_ASSERT(exp) ASSERT(exp)
61 #define ECHO_ASSERT(exp)
64 // Specify OS specific types
66 typedef char *PCHAR ;
67 typedef uint8 BYTE;
68 typedef uint8 *PBYTE;
69 typedef uint16 WORD;
70 typedef uint16 *PWORD;
71 typedef uint32 DWORD;
72 typedef unsigned long ULONG;
73 typedef unsigned long NUINT;
74 typedef long NINT;
75 typedef void *PVOID;
76 typedef DWORD *PDWORD;
77 #define VOID void
78 typedef bool BOOL;
79 typedef bool BOOLEAN;
80 typedef char *PTCHAR;
81 typedef char TCHAR;
82 typedef char CHAR;
83 typedef char* LPSTR;
84 //typedef SInt32 INT;
85 typedef int32 INT32;
86 typedef int32 *PINT;
87 typedef int8 INT8;
88 typedef long HANDLE;
89 typedef long LONG;
90 typedef int64 LONGLONG;
91 typedef uint64 ULONGLONG ;
92 typedef uint64 *PULONGLONG ;
93 typedef long *PKEVENT ;
94 #undef NULL
95 #define NULL 0
96 #define CALLBACK
98 #define CONST const
99 typedef void ** PPVOID;
101 #ifndef PAGE_SIZE
102 #define PAGE_SIZE B_PAGE_SIZE
103 #endif
105 #define WideToSInt64(x) (*((int64*)(&x)))
106 #define WideToUInt64(x) (*((uint64*)(&x)))
109 // Return Status Values
111 typedef unsigned long ECHOSTATUS;
115 // Define our platform specific things here.
117 typedef struct _echo_mem {
118 LIST_ENTRY(_echo_mem) next;
119 void *log_base;
120 phys_addr_t phy_base;
121 area_id area;
122 size_t size;
123 } echo_mem;
126 // Define generic byte swapping functions
128 #define SWAP(x)B_HOST_TO_LENDIAN_INT32(x)
131 // Define what a physical address is on this OS
133 typedef phys_addr_t PHYS_ADDR; // Define physical addr type
134 typedef phys_addr_t* PPHYS_ADDR; // Define physical addr pointer type
136 typedef echo_mem* PPAGE_BLOCK;
140 // Version information.
141 // In NT, we want to get this from a resource
143 #define APPVERSION OsGetVersion()
144 #define APPREVISION OsGetRevision()
145 #define APPRELEASE OsGetRelease()
147 BYTE OsGetVersion();
148 BYTE OsGetRevision();
149 BYTE OsGetRelease();
152 // Global Memory Management Functions
156 // This tag is used to mark all memory allocated by EchoGals.
157 // Due to the way PoolMon displays things, we spell Echo backwards
158 // so it displays correctly.
160 #define ECHO_POOL_TAG 'OHCE'
164 // OsAllocateInit - Set up memory tracking. Call this once - not
165 // once per PCI card, just one time.
167 void OsAllocateInit();
170 // Allocate locked, non-pageable block of memory. Does not have to be
171 // physically contiguous. Primarily used to implement the overloaded
172 // new operator for classes that must remain memory resident.
174 ECHOSTATUS OsAllocateNonPaged
176 DWORD dwByteCt,
177 PPVOID ppMemAddr
182 // Unlock and free, non-pageable block of memory.
184 ECHOSTATUS OsFreeNonPaged
186 PVOID pMemAddr
191 // Copy memory
193 //!!! Anything faster we can use?
194 #define OsCopyMemory(pDest, pSrc, dwBytes) memcpy(pDest, pSrc, dwBytes)
197 // Set memory to zero
199 #define OsZeroMemory(pDest, dwBytes) memset(pDest, 0, dwBytes)
203 // This class is uniquely defined for each OS. It provides
204 // information that other components may require.
205 // For example, in Windows NT it contains a device object used by various
206 // memory management methods.
207 // Since static variables are used in place of globals, an instance must
208 // be constructed and initialized by the OS Interface object prior to
209 // constructing the CEchoGals derived object. The CEchoGals and
210 // CDspCommObject classes must have access to it during their respective
211 // construction times.
213 class COsSupport
215 public:
217 // Construction/destruction
219 COsSupport
221 WORD wDeviceId, // PCI bus device id
222 WORD wCardRev // Hardware revision number
225 ~COsSupport();
228 // Timer Methods
232 // Return the system time in microseconds.
233 // Return error status if the OS doesn't support this function.
235 ECHOSTATUS OsGetSystemTime
237 PULONGLONG pullTime
242 // Stall execution for dwTime microseconds.
243 // Return error status if the OS doesn't support this function.
245 ECHOSTATUS OsSnooze
247 DWORD dwTime // Duration in micro seconds
252 // Memory Management Methods
256 // Allocate a block of physical memory pages
258 ECHOSTATUS AllocPhysPageBlock
260 DWORD dwBytes,
261 PPAGE_BLOCK &pPageBlock
265 // Free a block of physical memory
267 ECHOSTATUS FreePhysPageBlock
269 DWORD dwBytes,
270 PPAGE_BLOCK pPageBlock
274 // Get the virtual address for a page block
276 PVOID GetPageBlockVirtAddress
278 PPAGE_BLOCK pPageBlock
282 // Get the physical address for a segment of a page block
284 ECHOSTATUS GetPageBlockPhysSegment
286 PPAGE_BLOCK pPageBlock, // pass in a previously allocated block
287 DWORD dwOffset, // pass in the offset into the block
288 PHYS_ADDR &PhysAddr, // returns the physical address
289 DWORD &dwSegmentSize // and the length of the segment
294 // Add additional methods here
298 // Display and/or log an error message w/title
300 void EchoErrorMsg
302 PCHAR pszMsg,
303 PCHAR pszTitle
307 // Return PCI card device ID
309 WORD GetDeviceId()
310 { return( m_wDeviceId ); }
313 // Return the hardware revision number
315 WORD GetCardRev()
317 return m_wCardRev;
321 // Get the current timestamp for MIDI input data
323 LONGLONG GetMidiInTimestamp()
325 return system_time();
329 // Overload new & delete so memory for this object is allocated
330 // from non-paged memory.
332 PVOID operator new( size_t Size );
333 VOID operator delete( PVOID pVoid );
335 protected:
337 private:
338 WORD m_wDeviceId; // PCI Device ID
339 WORD m_wCardRev; // Hardware revision
342 // Define data here.
344 #ifdef ECHO_DEBUG
345 DWORD m_dwPageBlockCount;
346 #endif
348 }; // class COsSupport
350 typedef COsSupport * PCOsSupport;
352 #endif // _ECHOOSSUPPORTBEOS_