summaryrefslogtreecommitdiffstats
path: root/cpukit/libdrvmgr/drvmgr_lock.c
blob: b5181c18a389f0739636f8ed2c52908204a42912 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Driver Manager Internal locking implementation
 *
 * COPYRIGHT (c) 2009 Cobham Gaisler AB.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <rtems.h>
#include <drvmgr/drvmgr.h>
#include "drvmgr_internal.h"

void _DRV_Manager_Lock(void)
{
	rtems_semaphore_obtain(drv_mgr.lock, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
}

void _DRV_Manager_Unlock(void)
{
	rtems_semaphore_release(drv_mgr.lock);
}

int _DRV_Manager_Init_Lock(void)
{
	int rc;

	rc = rtems_semaphore_create(
		rtems_build_name('D', 'R', 'V', 'M'),
		1,
		RTEMS_DEFAULT_ATTRIBUTES,
		0,
		&drv_mgr.lock);
	if (rc != RTEMS_SUCCESSFUL)
		return -1;
	return 0;
}