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 | #include "cr_error.h"
|
---|
8 | #include "cr_mem.h"
|
---|
9 | #include "packer.h"
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 | #ifdef CHROMIUM_THREADSAFE
|
---|
13 | CRtsd _PackerTSD;
|
---|
14 | int cr_packer_globals; /* dummy - for the sake of packer.def */
|
---|
15 | #else
|
---|
16 | int _PackerTSD; /* dummy - for the sake of packer.def */ /* drm1 */
|
---|
17 | DLLDATA(CRPackContext) cr_packer_globals;
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | uint32_t cr_packer_cmd_blocks_enabled = 0;
|
---|
21 |
|
---|
22 | CRPackContext *crPackNewContext( int swapping )
|
---|
23 | {
|
---|
24 | #ifdef CHROMIUM_THREADSAFE
|
---|
25 | CRPackContext *pc = crCalloc(sizeof(CRPackContext));
|
---|
26 | if (!pc)
|
---|
27 | return NULL;
|
---|
28 | crInitMutex(&pc->mutex);
|
---|
29 | #else
|
---|
30 | GET_PACKER_CONTEXT(pc);
|
---|
31 | crMemZero( pc, sizeof(CRPackContext));
|
---|
32 | #endif
|
---|
33 | pc->u32CmdBlockState = 0;
|
---|
34 | pc->swapping = swapping;
|
---|
35 | pc->Flush = NULL;
|
---|
36 | pc->SendHuge = NULL;
|
---|
37 | pc->updateBBOX = 0;
|
---|
38 | return pc;
|
---|
39 | }
|
---|
40 |
|
---|
41 | void crPackDeleteContext(CRPackContext *pc)
|
---|
42 | {
|
---|
43 | #ifdef CHROMIUM_THREADSAFE
|
---|
44 | crFreeMutex(&pc->mutex);
|
---|
45 | crFree(pc);
|
---|
46 | #endif
|
---|
47 | }
|
---|
48 |
|
---|
49 | /* Set packing context for the calling thread */
|
---|
50 | void crPackSetContext( CRPackContext *pc )
|
---|
51 | {
|
---|
52 | #ifdef CHROMIUM_THREADSAFE
|
---|
53 | crSetTSD( &_PackerTSD, pc );
|
---|
54 | #else
|
---|
55 | CRASSERT( pc == &cr_packer_globals );
|
---|
56 | (void)pc;
|
---|
57 | #endif
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | /* Return packing context for the calling thread */
|
---|
62 | CRPackContext *crPackGetContext( void )
|
---|
63 | {
|
---|
64 | #ifdef CHROMIUM_THREADSAFE
|
---|
65 | return (CRPackContext *) crGetTSD( &_PackerTSD );
|
---|
66 | #else
|
---|
67 | return &cr_packer_globals;
|
---|
68 | #endif
|
---|
69 | }
|
---|
70 |
|
---|
71 | void crPackCapsSet(uint32_t u32Caps)
|
---|
72 | {
|
---|
73 | cr_packer_cmd_blocks_enabled = (u32Caps & (CR_VBOX_CAP_CMDBLOCKS_FLUSH | CR_VBOX_CAP_CMDBLOCKS));
|
---|
74 | }
|
---|