blob: eaeb5a8380577b0e47461ee50d3f89c5216304ea (
plain)
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
|
#include <cpu.h>
#include <cpu/atomic/swap.h>
#include <util/mutex.h>
#include <util/lock.h>
// TODO: Improve locking for system
// 1. Return code rather than hang?
// 2. Specific core PID rather than CORE0
void lock(struct Lock* l)
{
unsigned long mode = getmode() & 0x1F;
if (mode == 0x10) {
sys1(SYS_LOCK, l);
} else {
atm_lock(CORE0_PID, (unsigned long*)l);
}
}
void unlock(struct Lock* l)
{
unsigned long mode = getmode() & 0x1F;
if (mode == 0x10) {
sys1(SYS_UNLOCK, l);
} else {
atm_release((unsigned long*)l);
}
}
|