d3d: Windows miniport driver portability fixes.

This commit is contained in:
José Fonseca 2008-05-01 00:59:12 +09:00
parent c9acd439b1
commit cafb545721
5 changed files with 55 additions and 37 deletions

View File

@ -104,7 +104,7 @@ void _debug_break(void)
__asm("int3"); __asm("int3");
#elif (defined(__i386__) || defined(__386__)) && defined(__MSC__) #elif (defined(__i386__) || defined(__386__)) && defined(__MSC__)
_asm {int 3}; _asm {int 3};
#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE) #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
EngDebugBreak(); EngDebugBreak();
#else #else
abort(); abort();

View File

@ -34,9 +34,11 @@
#include "pipe/p_config.h" #include "pipe/p_config.h"
#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY #if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h> #include <windows.h>
#include <winddi.h> #include <winddi.h>
#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
#include <wdm.h>
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -52,6 +54,9 @@
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE) #if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
#define real_malloc(_size) EngAllocMem(0, _size, 'D3AG') #define real_malloc(_size) EngAllocMem(0, _size, 'D3AG')
#define real_free(_ptr) EngFreeMem(_ptr) #define real_free(_ptr) EngFreeMem(_ptr)
#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
#define real_malloc(_size) ExAllocatePool(0, _size)
#define real_free(_ptr) ExFreePool(_ptr)
#else #else
#define real_malloc(_size) malloc(_size) #define real_malloc(_size) malloc(_size)
#define real_free(_ptr) free(_ptr) #define real_free(_ptr) free(_ptr)

View File

@ -37,11 +37,11 @@
#if defined(PIPE_OS_LINUX) #if defined(PIPE_OS_LINUX)
#include <sys/time.h> #include <sys/time.h>
#elif defined(PIPE_OS_WINDOWS) #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h> #include <windows.h>
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <winddi.h> #include <winddi.h>
#endif #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
#include <windows.h>
#else #else
#error Unsupported OS #error Unsupported OS
#endif #endif

View File

@ -106,7 +106,16 @@
#if defined(PIPE_SUBSYSTEM_KERNEL) #if defined(PIPE_SUBSYSTEM_KERNEL)
#define PIPE_SUBSYSTEM_WINDOWS_DISPLAY #define PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#endif #endif
#if 0 /* FIXME */
#define PIPE_SUBSYSTEM_WINDOWS_MINIPORT
#endif #endif
#if 0 /* FIXME */
#define PIPE_SUBSYSTEM_WINDOWS_CE
#endif
#if defined(PIPE_SUBSYSTEM_USER)
#define PIPE_SUBSYSTEM_WINDOWS_USER
#endif
#endif /* PIPE_OS_WINDOWS */
#endif /* P_CONFIG_H_ */ #endif /* P_CONFIG_H_ */

View File

@ -41,7 +41,9 @@ extern "C" {
#endif #endif
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG) /* memory debugging */ #if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
/* memory debugging */
#include "p_debug.h" #include "p_debug.h"
@ -54,9 +56,7 @@ extern "C" {
#define REALLOC( _ptr, _old_size, _size ) \ #define REALLOC( _ptr, _old_size, _size ) \
debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size ) debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size )
#else #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
void * __stdcall void * __stdcall
EngAllocMem( EngAllocMem(
@ -68,17 +68,33 @@ void __stdcall
EngFreeMem( EngFreeMem(
void *Mem ); void *Mem );
static INLINE void * #define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
MALLOC( unsigned size ) #define _FREE( _ptr ) EngFreeMem( _ptr )
{
#ifdef WINCE
/* TODO: Need to abstract this */
return malloc( size );
#else
return EngAllocMem( 0, size, 'D3AG' );
#endif
}
#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
void *
ExAllocatePool(
unsigned long PoolType,
size_t NumberOfBytes);
void
ExFreePool(void *P);
#define MALLOC(_size) ExAllocatePool(0, _size)
#define _FREE(_ptr) ExFreePool(_ptr)
#else
#define MALLOC( SIZE ) malloc( SIZE )
#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
#define FREE( PTR ) free( PTR )
#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
#endif
#ifndef CALLOC
static INLINE void * static INLINE void *
CALLOC( unsigned count, unsigned size ) CALLOC( unsigned count, unsigned size )
{ {
@ -88,20 +104,19 @@ CALLOC( unsigned count, unsigned size )
} }
return ptr; return ptr;
} }
#endif /* !CALLOC */
#ifndef FREE
static INLINE void static INLINE void
FREE( void *ptr ) FREE( void *ptr )
{ {
if( ptr ) { if( ptr ) {
#ifdef WINCE _FREE( ptr );
/* TODO: Need to abstract this */
free( ptr );
#else
EngFreeMem( ptr );
#endif
} }
} }
#endif /* !FREE */
#ifndef REALLOC
static INLINE void * static INLINE void *
REALLOC( void *old_ptr, unsigned old_size, unsigned new_size ) REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
{ {
@ -118,19 +133,8 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
FREE( old_ptr ); FREE( old_ptr );
return new_ptr; return new_ptr;
} }
#endif /* !REALLOC */
#else /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
#define MALLOC( SIZE ) malloc( SIZE )
#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
#define FREE( PTR ) free( PTR )
#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
#endif /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
#endif /* !DEBUG */
#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T)) #define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))