1 // ****************************************************************************
5 // Set editor tabs to 3 for your viewing pleasure.
7 // ----------------------------------------------------------------------------
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
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>
42 #include "util/kernel_cpp.h"
45 // BeOS debug printf macro
46 #define ECHO_DEBUGPRINTF( strings ) TRACE(strings)
47 #define ECHO_DEBUGBREAK() kernel_debugger("echo driver debug break");
52 #define ECHO_DEBUGPRINTF( strings )
53 #define ECHO_DEBUGBREAK()
60 //#define ECHO_ASSERT(exp) ASSERT(exp)
61 #define ECHO_ASSERT(exp)
64 // Specify OS specific types
70 typedef uint16
*PWORD
;
72 typedef unsigned long ULONG
;
73 typedef unsigned long NUINT
;
76 typedef DWORD
*PDWORD
;
90 typedef int64 LONGLONG
;
91 typedef uint64 ULONGLONG
;
92 typedef uint64
*PULONGLONG
;
93 typedef long *PKEVENT
;
99 typedef void ** PPVOID
;
102 #define PAGE_SIZE B_PAGE_SIZE
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
;
120 phys_addr_t phy_base
;
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()
148 BYTE
OsGetRevision();
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
182 // Unlock and free, non-pageable block of memory.
184 ECHOSTATUS OsFreeNonPaged
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.
217 // Construction/destruction
221 WORD wDeviceId
, // PCI bus device id
222 WORD wCardRev
// Hardware revision number
232 // Return the system time in microseconds.
233 // Return error status if the OS doesn't support this function.
235 ECHOSTATUS OsGetSystemTime
242 // Stall execution for dwTime microseconds.
243 // Return error status if the OS doesn't support this function.
247 DWORD dwTime
// Duration in micro seconds
252 // Memory Management Methods
256 // Allocate a block of physical memory pages
258 ECHOSTATUS AllocPhysPageBlock
261 PPAGE_BLOCK
&pPageBlock
265 // Free a block of physical memory
267 ECHOSTATUS FreePhysPageBlock
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
307 // Return PCI card device ID
310 { return( m_wDeviceId
); }
313 // Return the hardware revision number
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
);
338 WORD m_wDeviceId
; // PCI Device ID
339 WORD m_wCardRev
; // Hardware revision
345 DWORD m_dwPageBlockCount
;
348 }; // class COsSupport
350 typedef COsSupport
* PCOsSupport
;
352 #endif // _ECHOOSSUPPORTBEOS_