summaryrefslogtreecommitdiff
path: root/firmware/kernel/include/corelock.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/kernel/include/corelock.h')
-rw-r--r--firmware/kernel/include/corelock.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/firmware/kernel/include/corelock.h b/firmware/kernel/include/corelock.h
new file mode 100644
index 0000000000..79302e0e3c
--- /dev/null
+++ b/firmware/kernel/include/corelock.h
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Ulf Ralberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef CORELOCK_H
24#define CORELOCK_H
25
26#include "config.h"
27
28#ifndef HAVE_CORELOCK_OBJECT
29
30/* No atomic corelock op needed or just none defined */
31#define corelock_init(cl)
32#define corelock_lock(cl)
33#define corelock_try_lock(cl)
34#define corelock_unlock(cl)
35
36#else
37
38/* No reliable atomic instruction available - use Peterson's algorithm */
39struct corelock
40{
41 volatile unsigned char myl[NUM_CORES];
42 volatile unsigned char turn;
43} __attribute__((packed));
44
45/* Too big to inline everywhere */
46extern void corelock_init(struct corelock *cl);
47extern void corelock_lock(struct corelock *cl);
48extern int corelock_try_lock(struct corelock *cl);
49extern void corelock_unlock(struct corelock *cl);
50
51#endif /* HAVE_CORELOCK_OBJECT */
52
53#endif /* CORELOCK_H */