1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef CR_UNPACK_H
|
---|
8 | #define CR_UNPACK_H
|
---|
9 |
|
---|
10 | #include "cr_compiler.h"
|
---|
11 | #include "cr_spu.h"
|
---|
12 | #include "cr_protocol.h"
|
---|
13 | #include "cr_mem.h"
|
---|
14 | #include "cr_opcodes.h"
|
---|
15 |
|
---|
16 | #include <iprt/types.h>
|
---|
17 |
|
---|
18 | #ifdef __cplusplus
|
---|
19 | extern "C" {
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | extern SPUDispatchTable cr_unpackDispatch;
|
---|
23 | /*extern DLLDATA(const unsigned char *) cr_unpackData;*/
|
---|
24 | extern DECLEXPORT(const unsigned char *) cr_unpackData;
|
---|
25 |
|
---|
26 | DECLEXPORT(void) crUnpackSetReturnPointer( CRNetworkPointer *ptr );
|
---|
27 | DECLEXPORT(void) crUnpackSetWritebackPointer( CRNetworkPointer *ptr );
|
---|
28 | DECLEXPORT(void) crUnpack( const void *data, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table );
|
---|
29 | DECLEXPORT(void) crUnpackPush(void);
|
---|
30 | DECLEXPORT(void) crUnpackPop(void);
|
---|
31 |
|
---|
32 | typedef enum
|
---|
33 | {
|
---|
34 | CR_UNPACK_BUFFER_TYPE_GENERIC = 0,
|
---|
35 | CR_UNPACK_BUFFER_TYPE_CMDBLOCK_BEGIN,
|
---|
36 | CR_UNPACK_BUFFER_TYPE_CMDBLOCK_FLUSH,
|
---|
37 | CR_UNPACK_BUFFER_TYPE_CMDBLOCK_END
|
---|
38 | } CR_UNPACK_BUFFER_TYPE;
|
---|
39 |
|
---|
40 | DECLEXPORT(CR_UNPACK_BUFFER_TYPE) crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes);
|
---|
41 |
|
---|
42 | extern CRNetworkPointer * return_ptr;
|
---|
43 | extern CRNetworkPointer * writeback_ptr;
|
---|
44 |
|
---|
45 | #if defined(LINUX) || defined(WINDOWS)
|
---|
46 | #define CR_UNALIGNED_ACCESS_OKAY
|
---|
47 | #else
|
---|
48 | #undef CR_UNALIGNED_ACCESS_OKAY
|
---|
49 | #endif
|
---|
50 | DECLEXPORT(double) crReadUnalignedDouble( const void *buffer );
|
---|
51 |
|
---|
52 | #define READ_DATA( offset, type ) \
|
---|
53 | *( (const type *) (cr_unpackData + (offset)))
|
---|
54 |
|
---|
55 | #ifdef CR_UNALIGNED_ACCESS_OKAY
|
---|
56 | #define READ_DOUBLE( offset ) \
|
---|
57 | READ_DATA( offset, GLdouble )
|
---|
58 | #else
|
---|
59 | #define READ_DOUBLE( offset ) \
|
---|
60 | crReadUnalignedDouble( cr_unpackData + (offset) )
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #define READ_NETWORK_POINTER( offset ) \
|
---|
64 | ( cr_unpackData + (offset) )
|
---|
65 |
|
---|
66 | /* XXX make this const */
|
---|
67 | #define DATA_POINTER( offset, type ) \
|
---|
68 | ( (type *) (cr_unpackData + (offset)) )
|
---|
69 |
|
---|
70 | #define INCR_DATA_PTR( delta ) \
|
---|
71 | cr_unpackData += (delta)
|
---|
72 |
|
---|
73 | #define INCR_DATA_PTR_NO_ARGS() \
|
---|
74 | INCR_DATA_PTR( 4 )
|
---|
75 |
|
---|
76 | #define INCR_VAR_PTR() \
|
---|
77 | INCR_DATA_PTR( *((int *) cr_unpackData ) )
|
---|
78 |
|
---|
79 | #define SET_RETURN_PTR( offset ) do { \
|
---|
80 | CRDBGPTR_CHECKZ(return_ptr); \
|
---|
81 | crMemcpy( return_ptr, cr_unpackData + (offset), sizeof( *return_ptr ) ); \
|
---|
82 | } while (0);
|
---|
83 |
|
---|
84 |
|
---|
85 | #define SET_WRITEBACK_PTR( offset ) do { \
|
---|
86 | CRDBGPTR_CHECKZ(writeback_ptr); \
|
---|
87 | crMemcpy( writeback_ptr, cr_unpackData + (offset), sizeof( *writeback_ptr ) ); \
|
---|
88 | } while (0);
|
---|
89 |
|
---|
90 | #ifdef __cplusplus
|
---|
91 | }
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | #endif /* CR_UNPACK_H */
|
---|