1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/openLuat-luatos-soc-air101

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
bitops.h 2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Wendal Chen Отправлено 3 лет назад d72653d
#ifndef BITOPS_H
#define BITOPS_H
#include "wm_osal.h"
/*
* These functions are the basis of our bit ops.
*
* First, the atomic bitops. These use native endian.
*/
static __inline void set_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
*p |= mask;
tls_os_release_critical(cpu_sr);
}
static __inline void clear_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
*p &= ~mask;
tls_os_release_critical(cpu_sr);
}
static __inline void change_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
*p ^= mask;
tls_os_release_critical(cpu_sr);
}
static __inline int
test_and_set_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned int res;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
res = *p;
*p = res | mask;
tls_os_release_critical(cpu_sr);
return res & mask;
}
static __inline int
test_and_clear_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned int res;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
res = *p;
*p = res & ~mask;
tls_os_release_critical(cpu_sr);
return res & mask;
}
static __inline int
test_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned int res;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
res = *p;
tls_os_release_critical(cpu_sr);
return res & mask;
}
static __inline int
test_and_change_bit(unsigned int bit, volatile unsigned long *p)
{
u32 cpu_sr;
unsigned int res;
unsigned long mask = 1 << (bit & 31);
p += bit >> 5;
cpu_sr = tls_os_set_critical();
res = *p;
*p = res ^ mask;
tls_os_release_critical(cpu_sr);
return res & mask;
}
#endif /* BITOPS_H */

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/openLuat-luatos-soc-air101.git
git@gitlife.ru:oschina-mirror/openLuat-luatos-soc-air101.git
oschina-mirror
openLuat-luatos-soc-air101
openLuat-luatos-soc-air101
master