vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / accelerants / intel_810 / engine.cpp
blobdf2735a6af917cbe4333d0ccedc4995d57ad59cc
1 /*
2 * Copyright 2007-2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Gerald Zajac
7 */
10 #include "accelerant.h"
11 #include "i810_regs.h"
14 static engine_token sEngineToken = { 1, B_2D_ACCELERATION, NULL };
17 uint32
18 AccelerantEngineCount(void)
20 return 1;
24 status_t
25 AcquireEngine(uint32 capabilities, uint32 maxWait,
26 sync_token* syncToken, engine_token** engineToken)
28 (void)capabilities; // avoid compiler warning for unused arg
29 (void)maxWait; // avoid compiler warning for unused arg
31 if (gInfo.sharedInfo->engineLock.Acquire() != B_OK)
32 return B_ERROR;
34 if (syncToken)
35 SyncToToken(syncToken);
37 *engineToken = &sEngineToken;
38 return B_OK;
42 status_t
43 ReleaseEngine(engine_token* engineToken, sync_token* syncToken)
45 if (syncToken)
46 GetSyncToken(engineToken, syncToken);
48 gInfo.sharedInfo->engineLock.Release();
49 return B_OK;
53 void
54 WaitEngineIdle(void)
56 // Wait until engine is idle.
58 int k = 10000000;
60 while ((INREG16(INST_DONE) & 0x7B) != 0x7B && k > 0)
61 k--;
65 status_t
66 GetSyncToken(engine_token* engineToken, sync_token* syncToken)
68 syncToken->engine_id = engineToken->engine_id;
69 syncToken->counter = 0;
70 return B_OK;
74 status_t
75 SyncToToken(sync_token* syncToken)
77 (void)syncToken;
78 // avoid compiler warning for unused arg
80 WaitEngineIdle();
81 return B_OK;