#include "spinlock.h"
int atomic_read(const atomic_t *v){
return v->val;
}
int atomic_dec_and_test(atomic_t *v){
if(v->val > 0){
v->val--;
return v->val == 0;
}
return 0;
}
void atomic_inc(atomic_t *v){
v->val++;
}
void atomic_set(atomic_t *v, int x){
v->val = x;
}
void spin_lock_init(spinlock_t *lock){
*lock = (spinlock_t){};
}
unsigned long _spin_lock_irqsave(spinlock_t *lock){
lock->val++;
return 0;
}
void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags){
lock->val--;
}
unsigned long _read_lock_irqsave(rwlock_t *lock){
lock->val++;
return 0;
}
void read_unlock_irqrestore(rwlock_t *lock, unsigned long flags){
lock->val--;
}
unsigned long _write_lock_irqsave(rwlock_t *lock){
lock->val++;
return 0;
}
void write_unlock_irqrestore(rwlock_t *lock, unsigned long flags){
lock->val--;
}
void init_MUTEX(struct semaphore *sem){
*sem = (struct semaphore){ .count = 1 };
}
void down(struct semaphore *sem){
sem->count--;
}
void up(struct semaphore *sem){
sem->count++;
}
lass='sub'>[no description]
blob: 226314fc0ed4dd9a3f5e9bb1cdb74484be2a25d0 (
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
28
29
30
31
32
33
|
/*
Copyright 2014 Robin Haberkorn <robin.haberkorn@googlemail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SERIAL_MOUSE_H
#define SERIAL_MOUSE_H
#include <stdint.h>
#include "serial.h"
static inline uint8_t serial_mouse_init(void)
{
serial_init();
return 0;
}
void serial_mouse_task(void);
#endif
|