mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 01:07:57 +00:00
dm: acpi: retrieve physical APIC IDs and use them to fill in the ACPI MADT table
Two utility functions are copied and adapted from hyerpervisor: ffs64 bitmap_clear_nolock Two public functions are provided for future use (such as for RTCTv2) pcpuid_from_vcpuid lapicid_from_pcpuid Tracked-On: #6020 Reviewed-by: Wang, Yu1 <yu1.wang@intel.com> Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#ifndef _ACPI_H_
|
||||
#define _ACPI_H_
|
||||
|
||||
#include "vhm_ioctl_defs.h"
|
||||
|
||||
#define SCI_INT 9
|
||||
|
||||
#define SMI_CMD 0xb2
|
||||
@@ -83,4 +85,7 @@ void inject_power_button_event(struct vmctx *ctx);
|
||||
void power_button_init(struct vmctx *ctx);
|
||||
void power_button_deinit(struct vmctx *ctx);
|
||||
|
||||
int pcpuid_from_vcpuid(uint64_t guest_pcpu_bitmask, int vcpu_id);
|
||||
int lapicid_from_pcpuid(struct platform_info *plat_info, int pcpu_id);
|
||||
|
||||
#endif /* _ACPI_H_ */
|
||||
|
@@ -97,6 +97,34 @@ bitmap_weight(uint64_t bits)
|
||||
|
||||
}
|
||||
|
||||
#define build_bitmap_clear(name, op_len, op_type, lock) \
|
||||
static inline void name(uint16_t nr_arg, volatile op_type *addr) \
|
||||
{ \
|
||||
uint16_t nr; \
|
||||
nr = nr_arg & ((8U * sizeof(op_type)) - 1U); \
|
||||
asm volatile(lock "and" op_len " %1,%0" \
|
||||
: "+m" (*addr) \
|
||||
: "r" ((op_type)(~(1UL<<(nr)))) \
|
||||
: "cc", "memory"); \
|
||||
}
|
||||
build_bitmap_clear(bitmap_clear_nolock, "q", uint64_t, "")
|
||||
|
||||
/*
|
||||
* ffs64 - Find the first (least significant) bit set of value
|
||||
* and return the index of that bit.
|
||||
*
|
||||
* @return value: zero-based bit index, or if value is zero, returns INVALID_BIT_INDEX
|
||||
*/
|
||||
#define INVALID_BIT_INDEX 0xffffU
|
||||
static inline uint16_t ffs64(uint64_t value)
|
||||
{
|
||||
/*
|
||||
* __builtin_ffsl: returns one plus the index of the least significant 1-bit of value,
|
||||
* or if value is zero, returns zero.
|
||||
*/
|
||||
return value ? (uint16_t)__builtin_ffsl(value) - 1U: INVALID_BIT_INDEX;
|
||||
}
|
||||
|
||||
/* memory barrier */
|
||||
#define mb() ({ asm volatile("mfence" ::: "memory"); (void)0; })
|
||||
|
||||
|
Reference in New Issue
Block a user