acrn-hypervisor/hypervisor/common/softirq.c
Shiqing Gao 0317cfb2b6 hv: fix 'No brackets to then/else'
- add missing brackets for 'if/else' statements based on MISRA-C
  requirements

v1 -> v2:
 * add brackets for each conditions in 'if' statements to improve
   the readability
 * modify 'ptdev_init' to make the logic clearer

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-10-11 16:48:11 +08:00

50 lines
903 B
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
#include <softirq.h>
static softirq_handler softirq_handlers[NR_SOFTIRQS];
void init_softirq(void)
{
}
/*
* @pre: nr will not equal or large than NR_SOFTIRQS
*/
void register_softirq(uint16_t nr, softirq_handler handler)
{
softirq_handlers[nr] = handler;
}
/*
* @pre: nr will not equal or large than NR_SOFTIRQS
*/
void fire_softirq(uint16_t nr)
{
bitmap_set_lock(nr, &per_cpu(softirq_pending, get_cpu_id()));
}
void do_softirq(void)
{
uint16_t nr;
uint16_t cpu_id = get_cpu_id();
volatile uint64_t *softirq_pending_bitmap =
&per_cpu(softirq_pending, cpu_id);
while (true) {
nr = ffs64(*softirq_pending_bitmap);
if (nr >= NR_SOFTIRQS) {
break;
}
bitmap_clear_lock(nr, softirq_pending_bitmap);
(*softirq_handlers[nr])(cpu_id);
}
}