kernel: replace all sem_* to nxsem_*: in kernel space

syscall cannot be called from kernel space

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-10-25 11:23:17 +08:00 committed by Xiang Xiao
parent 3cadf6642a
commit 2b06142232
4 changed files with 18 additions and 16 deletions

View File

@ -27,6 +27,7 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/mutex.h> #include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
#include <nuttx/signal.h> #include <nuttx/signal.h>
#include <nuttx/mm/mm.h> #include <nuttx/mm/mm.h>
@ -119,7 +120,7 @@ void nrf_waiting_free(struct nrf91_modem_os_waiting_s *w)
{ {
nxmutex_lock(&g_nrf91_modem_os.waiting_lock); nxmutex_lock(&g_nrf91_modem_os.waiting_lock);
sem_destroy(&w->sem); nxsem_destroy(&w->sem);
w->context = 0; w->context = 0;
w->waiting = false; w->waiting = false;
@ -176,7 +177,7 @@ void nrf_modem_os_shutdown(void)
waiting = &g_nrf91_modem_os.waiting[i]; waiting = &g_nrf91_modem_os.waiting[i];
if (waiting->waiting == true) if (waiting->waiting == true)
{ {
sem_post(&waiting->sem); nxsem_post(&waiting->sem);
} }
} }
@ -298,7 +299,7 @@ int32_t nrf_modem_os_timedwait(uint32_t context, int32_t *timeout)
{ {
/* Wait for event */ /* Wait for event */
sem_wait(&waiting->sem); nxsem_wait(&waiting->sem);
ret = OK; ret = OK;
} }
else else
@ -308,7 +309,7 @@ int32_t nrf_modem_os_timedwait(uint32_t context, int32_t *timeout)
abstime.tv_sec = *timeout / 1000; abstime.tv_sec = *timeout / 1000;
abstime.tv_nsec = (*timeout % 1000) * 1000000; abstime.tv_nsec = (*timeout % 1000) * 1000000;
sem_timedwait(&waiting->sem, &abstime); nxsem_timedwait(&waiting->sem, &abstime);
} }
/* Free a waiting slot */ /* Free a waiting slot */
@ -368,7 +369,7 @@ void nrf_modem_os_event_notify(uint32_t context)
{ {
if (waiting->context == context || context == 0) if (waiting->context == context || context == 0)
{ {
sem_post(&waiting->sem); nxsem_post(&waiting->sem);
} }
} }
} }
@ -433,7 +434,7 @@ int nrf_modem_os_sem_init(void **sem, unsigned int initial_count,
UNUSED(limit); UNUSED(limit);
DEBUGASSERT(g_nrf91_modem_os.sem_cntr < NRF_MODEM_OS_NUM_SEM_REQUIRED); DEBUGASSERT(g_nrf91_modem_os.sem_cntr < NRF_MODEM_OS_NUM_SEM_REQUIRED);
ret = sem_init(modemsem, 0, initial_count); ret = nxsem_init(modemsem, 0, initial_count);
g_nrf91_modem_os.sem_cntr++; g_nrf91_modem_os.sem_cntr++;
*sem = (void *)modemsem; *sem = (void *)modemsem;
@ -451,7 +452,7 @@ int nrf_modem_os_sem_init(void **sem, unsigned int initial_count,
void nrf_modem_os_sem_give(void *sem) void nrf_modem_os_sem_give(void *sem)
{ {
sem_post((sem_t *)sem); nxsem_post((sem_t *)sem);
} }
/**************************************************************************** /****************************************************************************
@ -469,7 +470,7 @@ int nrf_modem_os_sem_take(void *sem, int timeout)
if (timeout == -1) if (timeout == -1)
{ {
ret = sem_wait(s); ret = nxsem_wait(s);
} }
else else
{ {
@ -478,7 +479,7 @@ int nrf_modem_os_sem_take(void *sem, int timeout)
abstime.tv_sec = timeout / 1000; abstime.tv_sec = timeout / 1000;
abstime.tv_nsec = (timeout % 1000) * 1000000; abstime.tv_nsec = (timeout % 1000) * 1000000;
ret = sem_timedwait(s, &abstime); ret = nxsem_timedwait(s, &abstime);
} }
return ret; return ret;
@ -496,7 +497,7 @@ unsigned int nrf_modem_os_sem_count_get(void *sem)
{ {
int sval = 0; int sval = 0;
sem_getvalue((sem_t *)sem, &sval); nxsem_get_value((sem_t *)sem, &sval);
return sval; return sval;
} }

View File

@ -935,7 +935,7 @@ static void *semphr_create_wrapper(uint32_t max, uint32_t init)
static void semphr_delete_wrapper(void *semphr) static void semphr_delete_wrapper(void *semphr)
{ {
struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr; struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
sem_destroy(&bt_sem->sem); nxsem_destroy(&bt_sem->sem);
kmm_free(bt_sem); kmm_free(bt_sem);
} }

View File

@ -179,7 +179,7 @@ static int ramlog_readnotify(FAR struct ramlog_dev_s *priv)
{ {
int semcount = 0; int semcount = 0;
sem_getvalue(&priv->rl_waitsem, &semcount); nxsem_get_value(&priv->rl_waitsem, &semcount);
if (semcount >= 0) if (semcount >= 0)
{ {
break; break;

View File

@ -25,6 +25,7 @@
#include <debug.h> #include <debug.h>
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/semaphore.h>
#include <nuttx/video/fb.h> #include <nuttx/video/fb.h>
#include <nuttx/virtio/virtio.h> #include <nuttx/virtio/virtio.h>
@ -145,17 +146,17 @@ static int virtio_gpu_send_cmd(FAR struct virtqueue *vq,
sem_t sem; sem_t sem;
struct virtio_gpu_cookie_s cookie; struct virtio_gpu_cookie_s cookie;
sem_init(&sem, 0, 0); nxsem_init(&sem, 0, 0);
cookie.blocking = true; cookie.blocking = true;
cookie.p = &sem; cookie.p = &sem;
ret = virtqueue_add_buffer(vq, buf_list, readable, writable, &cookie); ret = virtqueue_add_buffer(vq, buf_list, readable, writable, &cookie);
if (ret >= 0) if (ret >= 0)
{ {
virtqueue_kick(vq); virtqueue_kick(vq);
sem_wait(&sem); nxsem_wait(&sem);
} }
sem_destroy(&sem); nxsem_destroy(&sem);
} }
else else
{ {
@ -200,7 +201,7 @@ static void virtio_gpu_done(FAR struct virtqueue *vq)
{ {
if (cookie->blocking) if (cookie->blocking)
{ {
sem_post((FAR sem_t *)cookie->p); nxsem_post((FAR sem_t *)cookie->p);
} }
else else
{ {