vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / accelerants / skeleton / EngineManagement.c
blob3078796c9ffc4751316075e784f90e4650ca272f
1 /*
2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
5 other authors:
6 Mark Watson
7 Rudolf Cornelissen 3/2004
8 */
10 #define MODULE_BIT 0x10000000
12 #include "acc_std.h"
15 static engine_token eng_engine_token = { 1, B_2D_ACCELERATION, NULL };
17 uint32 ACCELERANT_ENGINE_COUNT(void)
19 /* we have one acceleration engine */
20 return 1;
23 status_t ACQUIRE_ENGINE(uint32 capabilities, uint32 max_wait, sync_token *st, engine_token **et)
25 /* acquire the shared benaphore */
26 AQUIRE_BEN(si->engine.lock)
27 /* sync if required */
28 if (st) SYNC_TO_TOKEN(st);
30 /* return an engine token */
31 *et = &eng_engine_token;
32 return B_OK;
35 status_t RELEASE_ENGINE(engine_token *et, sync_token *st)
37 /* update the sync token, if any */
38 if (st) GET_SYNC_TOKEN(et,st);
40 /* release the shared benaphore */
41 RELEASE_BEN(si->engine.lock)
42 return B_OK;
45 void WAIT_ENGINE_IDLE(void)
47 /*wait for the engine to be totally idle*/
48 eng_acc_wait_idle();
51 status_t GET_SYNC_TOKEN(engine_token *et, sync_token *st)
53 /* engine count will always be zero: we don't support syncing to token (yet) */
54 st->engine_id = et->engine_id;
55 st->counter = si->engine.count;
56 return B_OK;
59 status_t SYNC_TO_TOKEN(sync_token *st)
61 /* wait until the engine is totally idle: we don't support syncing to token (yet) */
62 /* note:
63 * AFAIK in order to be able to setup sync_to_token, we'd need a circular fifo
64 * buffer in (main) memory instead of directly programming the GPU fifo so we
65 * can tell (via a hardware maintained pointer into this circular fifo) where
66 * the acc engine is with executing commands! */
67 WAIT_ENGINE_IDLE();
69 return B_OK;