Files
mkrtos-real/mkrtos_knl/knl/cpulock.c

54 lines
682 B
C
Raw Normal View History

2023-09-29 01:03:19 +08:00
/**
* @file cpulock.c
* @author ATShining (1358745329@qq.com)
2023-09-29 01:03:19 +08:00
* @brief
* @version 0.1
* @date 2023-09-29
*
* @copyright Copyright (c) 2023
*
*/
2023-08-20 20:52:23 +08:00
#include "types.h"
#include "arch.h"
2023-12-05 21:16:00 +08:00
/**
* @brief cpu
*
* @return umword_t
*/
2023-08-20 20:52:23 +08:00
umword_t cpulock_lock(void)
{
umword_t res;
res = intr_status();
2024-04-01 16:10:59 +00:00
cli();
2023-08-20 20:52:23 +08:00
return res;
}
2023-12-05 21:16:00 +08:00
/**
* @brief cpu锁的状态
*
* @return umword_t
*/
2023-08-20 20:52:23 +08:00
umword_t cpulock_get_status(void)
{
umword_t res;
res = intr_status();
return res;
}
2023-12-05 21:16:00 +08:00
/**
* @brief cpu锁的状态
*
* @param s
*/
2023-08-20 20:52:23 +08:00
void cpulock_set(umword_t s)
{
if (s)
{
2024-04-01 16:10:59 +00:00
cli();
2023-08-20 20:52:23 +08:00
}
else
{
2024-04-01 16:10:59 +00:00
sti();
2023-08-20 20:52:23 +08:00
}
}