mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-16 22:33:00 +00:00
Extract common interface to include/lib/bits.h, and invoke the variant implementation of arch. Re-implement unlocked functions as C in common library. Rename bitmap*lock() to bitmap*(), bitmap*nolock() to bitmap*non_atomic(). Tracked-On: #8803 Signed-off-by: Haoyu Tang <haoyu.tang@intel.com> Reviewed-by: Yifan Liu <yifan1.liu@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
50 lines
809 B
C
50 lines
809 B
C
/*
|
|
* Copyright (C) 2025 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
#include <cpu.h>
|
|
#include <bits.h>
|
|
|
|
|
|
static volatile uint64_t pcpu_active_bitmap = 0UL;
|
|
|
|
/*
|
|
* @post return <= MAX_PCPU_NUM
|
|
*/
|
|
uint16_t get_pcpu_nums(void)
|
|
{
|
|
return arch_get_pcpu_num();
|
|
}
|
|
|
|
bool is_pcpu_active(uint16_t pcpu_id)
|
|
{
|
|
return bitmap_test(pcpu_id, &pcpu_active_bitmap);
|
|
}
|
|
|
|
void set_pcpu_active(uint16_t pcpu_id)
|
|
{
|
|
bitmap_set(pcpu_id, &pcpu_active_bitmap);
|
|
}
|
|
|
|
void clear_pcpu_active(uint16_t pcpu_id)
|
|
{
|
|
|
|
bitmap_clear(pcpu_id, &pcpu_active_bitmap);
|
|
}
|
|
|
|
bool check_pcpus_active(uint64_t mask)
|
|
{
|
|
return ((pcpu_active_bitmap & mask) == mask);
|
|
}
|
|
|
|
bool check_pcpus_inactive(uint64_t mask)
|
|
{
|
|
return ((pcpu_active_bitmap & mask) != 0UL);
|
|
}
|
|
|
|
uint64_t get_active_pcpu_bitmap(void)
|
|
{
|
|
return pcpu_active_bitmap;
|
|
}
|