revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-pc / hpet / allochpetunit.c
blobc33e13590db29eb64790cae3026c10f84f5f5ef6
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
8 #include "hpet_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/hpet.h>
15 AROS_LH1(ULONG, AllocHPETUnit,
17 /* SYNOPSIS */
18 AROS_LHA(const char *, user, A0),
20 /* LOCATION */
21 struct HPETBase *, base, 2, Hpet)
23 /* FUNCTION
24 Allocate a free HPET timer for use.
26 INPUTS
27 user - a string specifying the name of current user. Can not be NULL.
29 RESULT
30 A number of HPET timer unit allocated for exclusive use, or -1 if
31 there was no free HPET.
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 ******************************************************************************/
45 AROS_LIBFUNC_INIT
47 ULONG i;
49 ObtainSemaphore(&base->lock);
51 for (i = 0; i < base->unitCnt; i++)
53 if (!base->units[i].Owner)
55 base->units[i].Owner = user;
57 ReleaseSemaphore(&base->lock);
58 return i;
62 ReleaseSemaphore(&base->lock);
63 return -1;
65 AROS_LIBFUNC_EXIT