Files
acrn-hypervisor/hypervisor/common/softirq.c
hangliu1 41f04b4e7a HV: abstract percpu structure from x86 arch
Move x86 architecture dependent per cpu data into a
seperate structure and embeded it in per_cpu_region.
caller could access architecture dependent member by
using prefix 'arch.'.

v2->v3:
move whose_iwkey, profiling_info and tsc_suspend to x86
v1->v2:
rebased on latest repo

Tracked-On: #8801
Signed-off-by: hangliu1 <hang1.liu@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Reviewed-by: Liu, Yifan1 <yifan1.liu@intel.com>
Reviewed-by: Chen, Jian Jun<jian.jun.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2025-09-19 15:04:55 +08:00

66 lines
1.3 KiB
C

/*
* Copyright (C) 2018-2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <asm/lib/bits.h>
#include <asm/cpu.h>
#include <per_cpu.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_pcpu_id()));
}
static void do_softirq_internal(uint16_t cpu_id)
{
volatile uint64_t *softirq_pending_bitmap =
&per_cpu(softirq_pending, cpu_id);
uint16_t nr = ffs64(*softirq_pending_bitmap);
while (nr < NR_SOFTIRQS) {
bitmap_clear_lock(nr, softirq_pending_bitmap);
(*softirq_handlers[nr])(cpu_id);
nr = ffs64(*softirq_pending_bitmap);
}
}
/*
* @pre: this function will only be called with irq disabled
*/
void do_softirq(void)
{
uint16_t cpu_id = get_pcpu_id();
if (per_cpu(softirq_servicing, cpu_id) == 0U) {
per_cpu(softirq_servicing, cpu_id) = 1U;
CPU_IRQ_ENABLE_ON_CONFIG();
do_softirq_internal(cpu_id);
CPU_IRQ_DISABLE_ON_CONFIG();
do_softirq_internal(cpu_id);
per_cpu(softirq_servicing, cpu_id) = 0U;
}
}