mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* rust: miscellaneous changes * target/i386: small code generation improvements * target/i386: various cleanups and fixes * cpu: remove env->nr_cores # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmeBoIgUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroOD2gf+NK7U1EhNIrsbBsbtu2i7+tnbRKIB # MTu+Mxb2wz4C7//pxq+vva4bgT3iOuL9RF19PRe/63CMD65xMiwyyNrEWX2HbRIJ # 5dytLLLdef3yMhHh2x1uZfm54g12Ppvn9kulMCbPawrlqWgg1sZbkUBrRtFzS45c # NeYjGWWSpBDe7LtsrgSRYLPnz6wWEiy3tDpu2VoDtjrE86UVDXwyzpbtBk9Y8jPi # CKdvLyQeO9xDE5OoXMjJMlJeQq3D9iwYEprXUqy+RUZtpW7YmqMCf2JQ4dAjVCad # 07v/kITF4brGCVnzDcDA6W7LqHpBu1w+Hn23yLw3HEDDBt11o9JjQCl9qA== # =xIQ4 # -----END PGP SIGNATURE----- # gpg: Signature made Fri 10 Jan 2025 17:34:48 EST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (38 commits) i386/cpu: Set and track CPUID_EXT3_CMP_LEG in env->features[FEAT_8000_0001_ECX] i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid() cpu: Remove nr_cores from struct CPUState i386/cpu: Hoist check of CPUID_EXT3_TOPOEXT against threads_per_core i386/cpu: Track a X86CPUTopoInfo directly in CPUX86State i386/topology: Introduce helpers for various topology info of different level i386/topology: Update the comment of x86_apicid_from_topo_ids() i386/cpu: Drop cores_per_pkg in cpu_x86_cpuid() i386/cpu: Drop the variable smp_cores and smp_threads in x86_cpu_pre_plug() i386/cpu: Extract a common fucntion to setup value of MSR_CORE_THREAD_COUNT target/i386/kvm: Replace ARRAY_SIZE(msr_handlers) with KVM_MSR_FILTER_MAX_RANGES target/i386/kvm: Clean up error handling in kvm_arch_init() target/i386/kvm: Return -1 when kvm_msr_energy_thread_init() fails target/i386/kvm: Clean up return values of MSR filter related functions target/i386/confidential-guest: Fix comment of x86_confidential_guest_kvm_type() target/i386/kvm: Drop workaround for KVM_X86_DISABLE_EXITS_HTL typo target/i386/kvm: Only save/load kvmclock MSRs when kvmclock enabled target/i386/kvm: Remove local MSR_KVM_WALL_CLOCK and MSR_KVM_SYSTEM_TIME definitions target/i386/kvm: Add feature bit definitions for KVM CPUID i386/cpu: Mark avx10_version filtered when prefix is NULL ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -243,7 +243,6 @@ static void cpu_common_initfn(Object *obj)
|
||||
cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX;
|
||||
/* user-mode doesn't have configurable SMP topology */
|
||||
/* the default value is changed by qemu_init_vcpu() for system-mode */
|
||||
cpu->nr_cores = 1;
|
||||
cpu->nr_threads = 1;
|
||||
cpu->cflags_next_tb = -1;
|
||||
|
||||
|
||||
+2
-3
@@ -27,7 +27,6 @@
|
||||
#include "qapi/error.h"
|
||||
|
||||
#include <linux/kvm.h>
|
||||
#include "standard-headers/asm-x86/kvm_para.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_KVM_CLOCK "kvmclock"
|
||||
@@ -333,8 +332,8 @@ void kvmclock_create(bool create_always)
|
||||
|
||||
assert(kvm_enabled());
|
||||
if (create_always ||
|
||||
cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
|
||||
(1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
|
||||
cpu->env.features[FEAT_KVM] & (CPUID_KVM_CLOCK |
|
||||
CPUID_KVM_CLOCK2)) {
|
||||
sysbus_create_simple(TYPE_KVM_CLOCK, -1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-13
@@ -248,9 +248,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
CPUX86State *env = &cpu->env;
|
||||
MachineState *ms = MACHINE(hotplug_dev);
|
||||
X86MachineState *x86ms = X86_MACHINE(hotplug_dev);
|
||||
unsigned int smp_cores = ms->smp.cores;
|
||||
unsigned int smp_threads = ms->smp.threads;
|
||||
X86CPUTopoInfo topo_info;
|
||||
X86CPUTopoInfo *topo_info = &env->topo_info;
|
||||
|
||||
if (!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) {
|
||||
error_setg(errp, "Invalid CPU type, expected cpu type: '%s'",
|
||||
@@ -269,15 +267,13 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
}
|
||||
}
|
||||
|
||||
init_topo_info(&topo_info, x86ms);
|
||||
init_topo_info(topo_info, x86ms);
|
||||
|
||||
if (ms->smp.modules > 1) {
|
||||
env->nr_modules = ms->smp.modules;
|
||||
set_bit(CPU_TOPOLOGY_LEVEL_MODULE, env->avail_cpu_topo);
|
||||
}
|
||||
|
||||
if (ms->smp.dies > 1) {
|
||||
env->nr_dies = ms->smp.dies;
|
||||
set_bit(CPU_TOPOLOGY_LEVEL_DIE, env->avail_cpu_topo);
|
||||
}
|
||||
|
||||
@@ -329,17 +325,17 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
if (cpu->core_id < 0) {
|
||||
error_setg(errp, "CPU core-id is not set");
|
||||
return;
|
||||
} else if (cpu->core_id > (smp_cores - 1)) {
|
||||
} else if (cpu->core_id > (ms->smp.cores - 1)) {
|
||||
error_setg(errp, "Invalid CPU core-id: %u must be in range 0:%u",
|
||||
cpu->core_id, smp_cores - 1);
|
||||
cpu->core_id, ms->smp.cores - 1);
|
||||
return;
|
||||
}
|
||||
if (cpu->thread_id < 0) {
|
||||
error_setg(errp, "CPU thread-id is not set");
|
||||
return;
|
||||
} else if (cpu->thread_id > (smp_threads - 1)) {
|
||||
} else if (cpu->thread_id > (ms->smp.threads - 1)) {
|
||||
error_setg(errp, "Invalid CPU thread-id: %u must be in range 0:%u",
|
||||
cpu->thread_id, smp_threads - 1);
|
||||
cpu->thread_id, ms->smp.threads - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -348,12 +344,12 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
topo_ids.module_id = cpu->module_id;
|
||||
topo_ids.core_id = cpu->core_id;
|
||||
topo_ids.smt_id = cpu->thread_id;
|
||||
cpu->apic_id = x86_apicid_from_topo_ids(&topo_info, &topo_ids);
|
||||
cpu->apic_id = x86_apicid_from_topo_ids(topo_info, &topo_ids);
|
||||
}
|
||||
|
||||
cpu_slot = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx);
|
||||
if (!cpu_slot) {
|
||||
x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids);
|
||||
x86_topo_ids_from_apicid(cpu->apic_id, topo_info, &topo_ids);
|
||||
|
||||
error_setg(errp,
|
||||
"Invalid CPU [socket: %u, die: %u, module: %u, core: %u, thread: %u]"
|
||||
@@ -376,7 +372,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
/* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn()
|
||||
* once -smp refactoring is complete and there will be CPU private
|
||||
* CPUState::nr_cores and CPUState::nr_threads fields instead of globals */
|
||||
x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids);
|
||||
x86_topo_ids_from_apicid(cpu->apic_id, topo_info, &topo_ids);
|
||||
if (cpu->socket_id != -1 && cpu->socket_id != topo_ids.pkg_id) {
|
||||
error_setg(errp, "property socket-id: %u doesn't match set apic-id:"
|
||||
" 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id,
|
||||
|
||||
@@ -407,7 +407,6 @@ struct qemu_work_item;
|
||||
* Under TCG this value is propagated to @tcg_cflags.
|
||||
* See TranslationBlock::TCG CF_CLUSTER_MASK.
|
||||
* @tcg_cflags: Pre-computed cflags for this cpu.
|
||||
* @nr_cores: Number of cores within this CPU package.
|
||||
* @nr_threads: Number of threads within this CPU core.
|
||||
* @thread: Host thread details, only live once @created is #true
|
||||
* @sem: WIN32 only semaphore used only for qtest
|
||||
@@ -466,7 +465,6 @@ struct CPUState {
|
||||
CPUClass *cc;
|
||||
/*< public >*/
|
||||
|
||||
int nr_cores;
|
||||
int nr_threads;
|
||||
|
||||
struct QemuThread *thread;
|
||||
|
||||
@@ -121,9 +121,10 @@ static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info)
|
||||
}
|
||||
|
||||
/*
|
||||
* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID
|
||||
* Make APIC ID for the CPU based on topology and IDs of each topology level.
|
||||
*
|
||||
* The caller must make sure core_id < nr_cores and smt_id < nr_threads.
|
||||
* The caller must make sure the ID of each level doesn't exceed the width of
|
||||
* the level.
|
||||
*/
|
||||
static inline apic_id_t x86_apicid_from_topo_ids(X86CPUTopoInfo *topo_info,
|
||||
const X86CPUTopoIDs *topo_ids)
|
||||
@@ -202,4 +203,29 @@ static inline bool x86_has_extended_topo(unsigned long *topo_bitmap)
|
||||
test_bit(CPU_TOPOLOGY_LEVEL_DIE, topo_bitmap);
|
||||
}
|
||||
|
||||
static inline unsigned x86_module_per_pkg(X86CPUTopoInfo *topo_info)
|
||||
{
|
||||
return topo_info->modules_per_die * topo_info->dies_per_pkg;
|
||||
}
|
||||
|
||||
static inline unsigned x86_cores_per_pkg(X86CPUTopoInfo *topo_info)
|
||||
{
|
||||
return topo_info->cores_per_module * x86_module_per_pkg(topo_info);
|
||||
}
|
||||
|
||||
static inline unsigned x86_threads_per_pkg(X86CPUTopoInfo *topo_info)
|
||||
{
|
||||
return topo_info->threads_per_core * x86_cores_per_pkg(topo_info);
|
||||
}
|
||||
|
||||
static inline unsigned x86_threads_per_module(X86CPUTopoInfo *topo_info)
|
||||
{
|
||||
return topo_info->threads_per_core * topo_info->cores_per_module;
|
||||
}
|
||||
|
||||
static inline unsigned x86_threads_per_die(X86CPUTopoInfo *topo_info)
|
||||
{
|
||||
return x86_threads_per_module(topo_info) * topo_info->modules_per_die;
|
||||
}
|
||||
|
||||
#endif /* HW_I386_TOPOLOGY_H */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use core::ptr::{addr_of_mut, NonNull};
|
||||
use std::{
|
||||
ffi::CStr,
|
||||
os::raw::{c_int, c_uchar, c_uint, c_void},
|
||||
os::raw::{c_int, c_uint, c_void},
|
||||
};
|
||||
|
||||
use qemu_api::{
|
||||
@@ -14,7 +14,7 @@ use qemu_api::{
|
||||
irq::InterruptSource,
|
||||
prelude::*,
|
||||
qdev::DeviceImpl,
|
||||
qom::ObjectImpl,
|
||||
qom::{ClassInitImpl, ObjectImpl, ParentField},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -33,27 +33,20 @@ const FBRD_MASK: u32 = 0x3f;
|
||||
/// QEMU sourced constant.
|
||||
pub const PL011_FIFO_DEPTH: u32 = 16;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum DeviceId {
|
||||
#[allow(dead_code)]
|
||||
Arm = 0,
|
||||
Luminary,
|
||||
}
|
||||
#[derive(Clone, Copy)]
|
||||
struct DeviceId(&'static [u8; 8]);
|
||||
|
||||
impl std::ops::Index<hwaddr> for DeviceId {
|
||||
type Output = c_uchar;
|
||||
type Output = u8;
|
||||
|
||||
fn index(&self, idx: hwaddr) -> &Self::Output {
|
||||
match self {
|
||||
Self::Arm => &Self::PL011_ID_ARM[idx as usize],
|
||||
Self::Luminary => &Self::PL011_ID_LUMINARY[idx as usize],
|
||||
}
|
||||
&self.0[idx as usize]
|
||||
}
|
||||
}
|
||||
|
||||
impl DeviceId {
|
||||
const PL011_ID_ARM: [c_uchar; 8] = [0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1];
|
||||
const PL011_ID_LUMINARY: [c_uchar; 8] = [0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1];
|
||||
const ARM: Self = Self(&[0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1]);
|
||||
const LUMINARY: Self = Self(&[0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1]);
|
||||
}
|
||||
|
||||
// FIFOs use 32-bit indices instead of usize, for compatibility with
|
||||
@@ -86,7 +79,7 @@ impl std::ops::Index<u32> for Fifo {
|
||||
#[derive(Debug, qemu_api_macros::Object, qemu_api_macros::offsets)]
|
||||
/// PL011 Device Model in QEMU
|
||||
pub struct PL011State {
|
||||
pub parent_obj: SysBusDevice,
|
||||
pub parent_obj: ParentField<SysBusDevice>,
|
||||
pub iomem: MemoryRegion,
|
||||
#[doc(alias = "fr")]
|
||||
pub flags: registers::Flags,
|
||||
@@ -126,21 +119,33 @@ pub struct PL011State {
|
||||
pub clock: NonNull<Clock>,
|
||||
#[doc(alias = "migrate_clk")]
|
||||
pub migrate_clock: bool,
|
||||
/// The byte string that identifies the device.
|
||||
device_id: DeviceId,
|
||||
}
|
||||
|
||||
qom_isa!(PL011State : SysBusDevice, DeviceState, Object);
|
||||
|
||||
pub struct PL011Class {
|
||||
parent_class: <SysBusDevice as ObjectType>::Class,
|
||||
/// The byte string that identifies the device.
|
||||
device_id: DeviceId,
|
||||
}
|
||||
|
||||
unsafe impl ObjectType for PL011State {
|
||||
type Class = <SysBusDevice as ObjectType>::Class;
|
||||
type Class = PL011Class;
|
||||
const TYPE_NAME: &'static CStr = crate::TYPE_PL011;
|
||||
}
|
||||
|
||||
impl ClassInitImpl<PL011Class> for PL011State {
|
||||
fn class_init(klass: &mut PL011Class) {
|
||||
klass.device_id = DeviceId::ARM;
|
||||
<Self as ClassInitImpl<SysBusDeviceClass>>::class_init(&mut klass.parent_class);
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for PL011State {
|
||||
type ParentType = SysBusDevice;
|
||||
|
||||
const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init);
|
||||
const INSTANCE_POST_INIT: Option<fn(&Self)> = Some(Self::post_init);
|
||||
}
|
||||
|
||||
impl DeviceImpl for PL011State {
|
||||
@@ -179,14 +184,6 @@ impl PL011State {
|
||||
Self::TYPE_NAME.as_ptr(),
|
||||
0x1000,
|
||||
);
|
||||
|
||||
let sbd: &mut SysBusDevice = self.upcast_mut();
|
||||
sysbus_init_mmio(sbd, addr_of_mut!(self.iomem));
|
||||
}
|
||||
|
||||
for irq in self.interrupts.iter() {
|
||||
let sbd: &SysBusDevice = self.upcast();
|
||||
sbd.init_irq(irq);
|
||||
}
|
||||
|
||||
// SAFETY:
|
||||
@@ -209,12 +206,20 @@ impl PL011State {
|
||||
}
|
||||
}
|
||||
|
||||
fn post_init(&self) {
|
||||
self.init_mmio(&self.iomem);
|
||||
for irq in self.interrupts.iter() {
|
||||
self.init_irq(irq);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read(&mut self, offset: hwaddr, _size: c_uint) -> std::ops::ControlFlow<u64, u64> {
|
||||
use RegisterOffset::*;
|
||||
|
||||
let value = match RegisterOffset::try_from(offset) {
|
||||
Err(v) if (0x3f8..0x400).contains(&(v >> 2)) => {
|
||||
u32::from(self.device_id[(offset - 0xfe0) >> 2])
|
||||
let device_id = self.get_class().device_id;
|
||||
u32::from(device_id[(offset - 0xfe0) >> 2])
|
||||
}
|
||||
Err(_) => {
|
||||
// qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset 0x%x\n", (int)offset);
|
||||
@@ -645,19 +650,13 @@ pub unsafe extern "C" fn pl011_create(
|
||||
#[derive(Debug, qemu_api_macros::Object)]
|
||||
/// PL011 Luminary device model.
|
||||
pub struct PL011Luminary {
|
||||
parent_obj: PL011State,
|
||||
parent_obj: ParentField<PL011State>,
|
||||
}
|
||||
|
||||
impl PL011Luminary {
|
||||
/// Initializes a pre-allocated, unitialized instance of `PL011Luminary`.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// We expect the FFI user of this function to pass a valid pointer, that
|
||||
/// has the same size as [`PL011Luminary`]. We also expect the device is
|
||||
/// readable/writeable from one thread at any time.
|
||||
unsafe fn init(&mut self) {
|
||||
self.parent_obj.device_id = DeviceId::Luminary;
|
||||
impl ClassInitImpl<PL011Class> for PL011Luminary {
|
||||
fn class_init(klass: &mut PL011Class) {
|
||||
klass.device_id = DeviceId::LUMINARY;
|
||||
<Self as ClassInitImpl<SysBusDeviceClass>>::class_init(&mut klass.parent_class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,8 +669,6 @@ unsafe impl ObjectType for PL011Luminary {
|
||||
|
||||
impl ObjectImpl for PL011Luminary {
|
||||
type ParentType = PL011State;
|
||||
|
||||
const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init);
|
||||
}
|
||||
|
||||
impl DeviceImpl for PL011Luminary {}
|
||||
|
||||
@@ -45,7 +45,7 @@ pub const TYPE_PL011_LUMINARY: &::std::ffi::CStr = c_str!("pl011_luminary");
|
||||
#[doc(alias = "offset")]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(u64)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, qemu_api_macros::TryInto)]
|
||||
pub enum RegisterOffset {
|
||||
/// Data Register
|
||||
///
|
||||
@@ -102,32 +102,6 @@ pub enum RegisterOffset {
|
||||
//Reserved = 0x04C,
|
||||
}
|
||||
|
||||
impl core::convert::TryFrom<u64> for RegisterOffset {
|
||||
type Error = u64;
|
||||
|
||||
fn try_from(value: u64) -> Result<Self, Self::Error> {
|
||||
macro_rules! case {
|
||||
($($discriminant:ident),*$(,)*) => {
|
||||
/* check that matching on all macro arguments compiles, which means we are not
|
||||
* missing any enum value; if the type definition ever changes this will stop
|
||||
* compiling.
|
||||
*/
|
||||
const fn _assert_exhaustive(val: RegisterOffset) {
|
||||
match val {
|
||||
$(RegisterOffset::$discriminant => (),)*
|
||||
}
|
||||
}
|
||||
|
||||
match value {
|
||||
$(x if x == Self::$discriminant as u64 => Ok(Self::$discriminant),)*
|
||||
_ => Err(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
case! { DR, RSR, FR, FBRD, ILPR, IBRD, LCR_H, CR, FLS, IMSC, RIS, MIS, ICR, DMACR }
|
||||
}
|
||||
}
|
||||
|
||||
pub mod registers {
|
||||
//! Device registers exposed as typed structs which are backed by arbitrary
|
||||
//! integer bitmaps. [`Data`], [`Control`], [`LineControl`], etc.
|
||||
|
||||
+113
-37
@@ -3,75 +3,81 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::Span;
|
||||
use quote::{quote, quote_spanned};
|
||||
use quote::quote;
|
||||
use syn::{
|
||||
parse_macro_input, parse_quote, punctuated::Punctuated, token::Comma, Data, DeriveInput, Field,
|
||||
Fields, Ident, Type, Visibility,
|
||||
parse_macro_input, parse_quote, punctuated::Punctuated, spanned::Spanned, token::Comma, Data,
|
||||
DeriveInput, Field, Fields, Ident, Meta, Path, Token, Type, Variant, Visibility,
|
||||
};
|
||||
|
||||
struct CompileError(String, Span);
|
||||
mod utils;
|
||||
use utils::MacroError;
|
||||
|
||||
impl From<CompileError> for proc_macro2::TokenStream {
|
||||
fn from(err: CompileError) -> Self {
|
||||
let CompileError(msg, span) = err;
|
||||
quote_spanned! { span => compile_error!(#msg); }
|
||||
fn get_fields<'a>(
|
||||
input: &'a DeriveInput,
|
||||
msg: &str,
|
||||
) -> Result<&'a Punctuated<Field, Comma>, MacroError> {
|
||||
if let Data::Struct(s) = &input.data {
|
||||
if let Fields::Named(fs) = &s.fields {
|
||||
Ok(&fs.named)
|
||||
} else {
|
||||
Err(MacroError::Message(
|
||||
format!("Named fields required for {}", msg),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Err(MacroError::Message(
|
||||
format!("Struct required for {}", msg),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn is_c_repr(input: &DeriveInput, msg: &str) -> Result<(), CompileError> {
|
||||
fn is_c_repr(input: &DeriveInput, msg: &str) -> Result<(), MacroError> {
|
||||
let expected = parse_quote! { #[repr(C)] };
|
||||
|
||||
if input.attrs.iter().any(|attr| attr == &expected) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(CompileError(
|
||||
Err(MacroError::Message(
|
||||
format!("#[repr(C)] required for {}", msg),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Object)]
|
||||
pub fn derive_object(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let name = input.ident;
|
||||
fn derive_object_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream, MacroError> {
|
||||
is_c_repr(&input, "#[derive(Object)]")?;
|
||||
|
||||
let name = &input.ident;
|
||||
let parent = &get_fields(&input, "#[derive(Object)]")?[0].ident;
|
||||
|
||||
Ok(quote! {
|
||||
::qemu_api::assert_field_type!(#name, #parent,
|
||||
::qemu_api::qom::ParentField<<#name as ::qemu_api::qom::ObjectImpl>::ParentType>);
|
||||
|
||||
let expanded = quote! {
|
||||
::qemu_api::module_init! {
|
||||
MODULE_INIT_QOM => unsafe {
|
||||
::qemu_api::bindings::type_register_static(&<#name as ::qemu_api::qom::ObjectImpl>::TYPE_INFO);
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Object)]
|
||||
pub fn derive_object(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let expanded = derive_object_or_error(input).unwrap_or_else(Into::into);
|
||||
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
||||
fn get_fields(input: &DeriveInput) -> Result<&Punctuated<Field, Comma>, CompileError> {
|
||||
if let Data::Struct(s) = &input.data {
|
||||
if let Fields::Named(fs) = &s.fields {
|
||||
Ok(&fs.named)
|
||||
} else {
|
||||
Err(CompileError(
|
||||
"Cannot generate offsets for unnamed fields.".to_string(),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Err(CompileError(
|
||||
"Cannot generate offsets for union or enum.".to_string(),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip::macros(quote)]
|
||||
fn derive_offsets_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream, CompileError> {
|
||||
fn derive_offsets_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream, MacroError> {
|
||||
is_c_repr(&input, "#[derive(offsets)]")?;
|
||||
|
||||
let name = &input.ident;
|
||||
let fields = get_fields(&input)?;
|
||||
let fields = get_fields(&input, "#[derive(offsets)]")?;
|
||||
let field_names: Vec<&Ident> = fields.iter().map(|f| f.ident.as_ref().unwrap()).collect();
|
||||
let field_types: Vec<&Type> = fields.iter().map(|f| &f.ty).collect();
|
||||
let field_vis: Vec<&Visibility> = fields.iter().map(|f| &f.vis).collect();
|
||||
@@ -92,3 +98,73 @@ pub fn derive_offsets(input: TokenStream) -> TokenStream {
|
||||
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
fn get_repr_uN(input: &DeriveInput, msg: &str) -> Result<Path, MacroError> {
|
||||
let repr = input.attrs.iter().find(|attr| attr.path().is_ident("repr"));
|
||||
if let Some(repr) = repr {
|
||||
let nested = repr.parse_args_with(Punctuated::<Meta, Token![,]>::parse_terminated)?;
|
||||
for meta in nested {
|
||||
match meta {
|
||||
Meta::Path(path) if path.is_ident("u8") => return Ok(path),
|
||||
Meta::Path(path) if path.is_ident("u16") => return Ok(path),
|
||||
Meta::Path(path) if path.is_ident("u32") => return Ok(path),
|
||||
Meta::Path(path) if path.is_ident("u64") => return Ok(path),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(MacroError::Message(
|
||||
format!("#[repr(u8/u16/u32/u64) required for {}", msg),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
|
||||
fn get_variants(input: &DeriveInput) -> Result<&Punctuated<Variant, Comma>, MacroError> {
|
||||
if let Data::Enum(e) = &input.data {
|
||||
if let Some(v) = e.variants.iter().find(|v| v.fields != Fields::Unit) {
|
||||
return Err(MacroError::Message(
|
||||
"Cannot derive TryInto for enum with non-unit variants.".to_string(),
|
||||
v.fields.span(),
|
||||
));
|
||||
}
|
||||
Ok(&e.variants)
|
||||
} else {
|
||||
Err(MacroError::Message(
|
||||
"Cannot derive TryInto for union or struct.".to_string(),
|
||||
input.ident.span(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip::macros(quote)]
|
||||
fn derive_tryinto_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream, MacroError> {
|
||||
let repr = get_repr_uN(&input, "#[derive(TryInto)]")?;
|
||||
|
||||
let name = &input.ident;
|
||||
let variants = get_variants(&input)?;
|
||||
let discriminants: Vec<&Ident> = variants.iter().map(|f| &f.ident).collect();
|
||||
|
||||
Ok(quote! {
|
||||
impl core::convert::TryFrom<#repr> for #name {
|
||||
type Error = #repr;
|
||||
|
||||
fn try_from(value: #repr) -> Result<Self, Self::Error> {
|
||||
#(const #discriminants: #repr = #name::#discriminants as #repr;)*;
|
||||
match value {
|
||||
#(#discriminants => Ok(Self::#discriminants),)*
|
||||
_ => Err(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[proc_macro_derive(TryInto)]
|
||||
pub fn derive_tryinto(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let expanded = derive_tryinto_or_error(input).unwrap_or_else(Into::into);
|
||||
|
||||
TokenStream::from(expanded)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Procedural macro utilities.
|
||||
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
use proc_macro2::Span;
|
||||
use quote::quote_spanned;
|
||||
|
||||
pub enum MacroError {
|
||||
Message(String, Span),
|
||||
ParseError(syn::Error),
|
||||
}
|
||||
|
||||
impl From<syn::Error> for MacroError {
|
||||
fn from(err: syn::Error) -> Self {
|
||||
MacroError::ParseError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MacroError> for proc_macro2::TokenStream {
|
||||
fn from(err: MacroError) -> Self {
|
||||
match err {
|
||||
MacroError::Message(msg, span) => quote_spanned! { span => compile_error!(#msg); },
|
||||
MacroError::ParseError(err) => err.into_compile_error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ if rustc.version().version_compare('>=1.77.0')
|
||||
_qemu_api_cfg += ['--cfg', 'has_offset_of']
|
||||
endif
|
||||
if get_option('debug_mutex')
|
||||
_qemu_api_cfg += ['--feature', 'debug_cell']
|
||||
_qemu_api_cfg += ['--cfg', 'feature="debug_cell"']
|
||||
endif
|
||||
|
||||
_qemu_api_rs = static_library(
|
||||
@@ -15,6 +15,7 @@ _qemu_api_rs = static_library(
|
||||
structured_sources(
|
||||
[
|
||||
'src/lib.rs',
|
||||
'src/assertions.rs',
|
||||
'src/bindings.rs',
|
||||
'src/bitops.rs',
|
||||
'src/callbacks.rs',
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright 2024, Red Hat Inc.
|
||||
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
//! This module provides macros to check the equality of types and
|
||||
//! the type of `struct` fields. This can be useful to ensure that
|
||||
//! types match the expectations of C code.
|
||||
|
||||
// Based on https://stackoverflow.com/questions/64251852/x/70978292#70978292
|
||||
// (stackoverflow answers are released under MIT license).
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait EqType {
|
||||
type Itself;
|
||||
}
|
||||
|
||||
impl<T> EqType for T {
|
||||
type Itself = T;
|
||||
}
|
||||
|
||||
/// Assert that two types are the same.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use qemu_api::assert_same_type;
|
||||
/// # use std::ops::Deref;
|
||||
/// assert_same_type!(u32, u32);
|
||||
/// assert_same_type!(<Box<u32> as Deref>::Target, u32);
|
||||
/// ```
|
||||
///
|
||||
/// Different types will cause a compile failure
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// # use qemu_api::assert_same_type;
|
||||
/// assert_same_type!(&Box<u32>, &u32);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! assert_same_type {
|
||||
($t1:ty, $t2:ty) => {
|
||||
const _: () = {
|
||||
#[allow(unused)]
|
||||
fn assert_same_type(v: $t1) {
|
||||
fn types_must_be_equal<T, U>(_: T)
|
||||
where
|
||||
T: $crate::assertions::EqType<Itself = U>,
|
||||
{
|
||||
}
|
||||
types_must_be_equal::<_, $t2>(v);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/// Assert that a field of a struct has the given type.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use qemu_api::assert_field_type;
|
||||
/// pub struct A {
|
||||
/// field1: u32,
|
||||
/// }
|
||||
///
|
||||
/// assert_field_type!(A, field1, u32);
|
||||
/// ```
|
||||
///
|
||||
/// Different types will cause a compile failure
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// # use qemu_api::assert_field_type;
|
||||
/// # pub struct A { field1: u32 }
|
||||
/// assert_field_type!(A, field1, i32);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! assert_field_type {
|
||||
($t:ty, $i:tt, $ti:ty) => {
|
||||
const _: () = {
|
||||
#[allow(unused)]
|
||||
fn assert_field_type(v: $t) {
|
||||
fn types_must_be_equal<T, U>(_: T)
|
||||
where
|
||||
T: $crate::assertions::EqType<Itself = U>,
|
||||
{
|
||||
}
|
||||
types_must_be_equal::<_, $ti>(v.$i);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -24,8 +24,7 @@ use crate::{
|
||||
///
|
||||
/// Interrupts are implemented as a pointer to the interrupt "sink", which has
|
||||
/// type [`IRQState`]. A device exposes its source as a QOM link property using
|
||||
/// a function such as
|
||||
/// [`SysBusDevice::init_irq`](crate::sysbus::SysBusDevice::init_irq), and
|
||||
/// a function such as [`SysBusDeviceMethods::init_irq`], and
|
||||
/// initially leaves the pointer to a NULL value, representing an unconnected
|
||||
/// interrupt. To connect it, whoever creates the device fills the pointer with
|
||||
/// the sink's `IRQState *`, for example using `sysbus_connect_irq`. Because
|
||||
|
||||
@@ -12,6 +12,7 @@ pub mod bindings;
|
||||
#[rustfmt::skip]
|
||||
pub mod prelude;
|
||||
|
||||
pub mod assertions;
|
||||
pub mod bitops;
|
||||
pub mod c_str;
|
||||
pub mod callbacks;
|
||||
|
||||
@@ -16,3 +16,5 @@ pub use crate::qom::ObjectMethods;
|
||||
pub use crate::qom::ObjectType;
|
||||
|
||||
pub use crate::qom_isa;
|
||||
|
||||
pub use crate::sysbus::SysBusDeviceMethods;
|
||||
|
||||
+71
-14
@@ -55,6 +55,7 @@
|
||||
|
||||
use std::{
|
||||
ffi::CStr,
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
os::raw::c_void,
|
||||
};
|
||||
@@ -105,6 +106,52 @@ macro_rules! qom_isa {
|
||||
};
|
||||
}
|
||||
|
||||
/// This is the same as [`ManuallyDrop<T>`](std::mem::ManuallyDrop), though
|
||||
/// it hides the standard methods of `ManuallyDrop`.
|
||||
///
|
||||
/// The first field of an `ObjectType` must be of type `ParentField<T>`.
|
||||
/// (Technically, this is only necessary if there is at least one Rust
|
||||
/// superclass in the hierarchy). This is to ensure that the parent field is
|
||||
/// dropped after the subclass; this drop order is enforced by the C
|
||||
/// `object_deinit` function.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```ignore
|
||||
/// #[repr(C)]
|
||||
/// #[derive(qemu_api_macros::Object)]
|
||||
/// pub struct MyDevice {
|
||||
/// parent: ParentField<DeviceState>,
|
||||
/// ...
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
#[repr(transparent)]
|
||||
pub struct ParentField<T: ObjectType>(std::mem::ManuallyDrop<T>);
|
||||
|
||||
impl<T: ObjectType> Deref for ParentField<T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline(always)]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ObjectType> DerefMut for ParentField<T> {
|
||||
#[inline(always)]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Display + ObjectType> fmt::Display for ParentField<T> {
|
||||
#[inline(always)]
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rust_instance_init<T: ObjectImpl>(obj: *mut Object) {
|
||||
// SAFETY: obj is an instance of T, since rust_instance_init<T>
|
||||
// is called from QOM core as the instance_init function
|
||||
@@ -116,11 +163,7 @@ unsafe extern "C" fn rust_instance_post_init<T: ObjectImpl>(obj: *mut Object) {
|
||||
// SAFETY: obj is an instance of T, since rust_instance_post_init<T>
|
||||
// is called from QOM core as the instance_post_init function
|
||||
// for class T
|
||||
//
|
||||
// FIXME: it's not really guaranteed that there are no backpointers to
|
||||
// obj; it's quite possible that they have been created by instance_init().
|
||||
// The receiver should be &self, not &mut self.
|
||||
T::INSTANCE_POST_INIT.unwrap()(unsafe { &mut *obj.cast::<T>() })
|
||||
T::INSTANCE_POST_INIT.unwrap()(unsafe { &*obj.cast::<T>() })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rust_class_init<T: ObjectType + ClassInitImpl<T::Class>>(
|
||||
@@ -133,6 +176,16 @@ unsafe extern "C" fn rust_class_init<T: ObjectType + ClassInitImpl<T::Class>>(
|
||||
T::class_init(unsafe { &mut *klass.cast::<T::Class>() })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn drop_object<T: ObjectImpl>(obj: *mut Object) {
|
||||
// SAFETY: obj is an instance of T, since drop_object<T> is called
|
||||
// from the QOM core function object_deinit() as the instance_finalize
|
||||
// function for class T. Note that while object_deinit() will drop the
|
||||
// superclass field separately after this function returns, `T` must
|
||||
// implement the unsafe trait ObjectType; the safety rules for the
|
||||
// trait mandate that the parent field is manually dropped.
|
||||
unsafe { std::ptr::drop_in_place(obj.cast::<T>()) }
|
||||
}
|
||||
|
||||
/// Trait exposed by all structs corresponding to QOM objects.
|
||||
///
|
||||
/// # Safety
|
||||
@@ -151,11 +204,16 @@ unsafe extern "C" fn rust_class_init<T: ObjectType + ClassInitImpl<T::Class>>(
|
||||
///
|
||||
/// - the struct must be `#[repr(C)]`;
|
||||
///
|
||||
/// - the first field of the struct must be of the instance struct corresponding
|
||||
/// to the superclass, which is `ObjectImpl::ParentType`
|
||||
/// - the first field of the struct must be of type
|
||||
/// [`ParentField<T>`](ParentField), where `T` is the parent type
|
||||
/// [`ObjectImpl::ParentType`]
|
||||
///
|
||||
/// - likewise, the first field of the `Class` must be of the class struct
|
||||
/// corresponding to the superclass, which is `ObjectImpl::ParentType::Class`.
|
||||
/// - the first field of the `Class` must be of the class struct corresponding
|
||||
/// to the superclass, which is `ObjectImpl::ParentType::Class`. `ParentField`
|
||||
/// is not needed here.
|
||||
///
|
||||
/// In both cases, having a separate class type is not necessary if the subclass
|
||||
/// does not add any field.
|
||||
pub unsafe trait ObjectType: Sized {
|
||||
/// The QOM class object corresponding to this struct. This is used
|
||||
/// to automatically generate a `class_init` method.
|
||||
@@ -384,13 +442,12 @@ impl<T: ObjectType> ObjectCastMut for &mut T {}
|
||||
|
||||
/// Trait a type must implement to be registered with QEMU.
|
||||
pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> {
|
||||
/// The parent of the type. This should match the first field of
|
||||
/// the struct that implements `ObjectImpl`:
|
||||
/// The parent of the type. This should match the first field of the
|
||||
/// struct that implements `ObjectImpl`, minus the `ParentField<_>` wrapper.
|
||||
type ParentType: ObjectType;
|
||||
|
||||
/// Whether the object can be instantiated
|
||||
const ABSTRACT: bool = false;
|
||||
const INSTANCE_FINALIZE: Option<unsafe extern "C" fn(obj: *mut Object)> = None;
|
||||
|
||||
/// Function that is called to initialize an object. The parent class will
|
||||
/// have already been initialized so the type is only responsible for
|
||||
@@ -402,7 +459,7 @@ pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> {
|
||||
|
||||
/// Function that is called to finish initialization of an object, once
|
||||
/// `INSTANCE_INIT` functions have been called.
|
||||
const INSTANCE_POST_INIT: Option<fn(&mut Self)> = None;
|
||||
const INSTANCE_POST_INIT: Option<fn(&Self)> = None;
|
||||
|
||||
/// Called on descendent classes after all parent class initialization
|
||||
/// has occurred, but before the class itself is initialized. This
|
||||
@@ -426,7 +483,7 @@ pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> {
|
||||
None => None,
|
||||
Some(_) => Some(rust_instance_post_init::<Self>),
|
||||
},
|
||||
instance_finalize: Self::INSTANCE_FINALIZE,
|
||||
instance_finalize: Some(drop_object::<Self>),
|
||||
abstract_: Self::ABSTRACT,
|
||||
class_size: core::mem::size_of::<Self::Class>(),
|
||||
class_init: Some(rust_class_init::<Self>),
|
||||
|
||||
@@ -32,20 +32,33 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl SysBusDevice {
|
||||
/// Return `self` cast to a mutable pointer, for use in calls to C code.
|
||||
const fn as_mut_ptr(&self) -> *mut SysBusDevice {
|
||||
addr_of!(*self) as *mut _
|
||||
/// Trait for methods of [`SysBusDevice`] and its subclasses.
|
||||
pub trait SysBusDeviceMethods: ObjectDeref
|
||||
where
|
||||
Self::Target: IsA<SysBusDevice>,
|
||||
{
|
||||
/// Expose a memory region to the board so that it can give it an address
|
||||
/// in guest memory. Note that the ordering of calls to `init_mmio` is
|
||||
/// important, since whoever creates the sysbus device will refer to the
|
||||
/// region with a number that corresponds to the order of calls to
|
||||
/// `init_mmio`.
|
||||
fn init_mmio(&self, iomem: &bindings::MemoryRegion) {
|
||||
assert!(bql_locked());
|
||||
unsafe {
|
||||
bindings::sysbus_init_mmio(self.as_mut_ptr(), addr_of!(*iomem) as *mut _);
|
||||
}
|
||||
}
|
||||
|
||||
/// Expose an interrupt source outside the device as a qdev GPIO output.
|
||||
/// Note that the ordering of calls to `init_irq` is important, since
|
||||
/// whoever creates the sysbus device will refer to the interrupts with
|
||||
/// a number that corresponds to the order of calls to `init_irq`.
|
||||
pub fn init_irq(&self, irq: &InterruptSource) {
|
||||
fn init_irq(&self, irq: &InterruptSource) {
|
||||
assert!(bql_locked());
|
||||
unsafe {
|
||||
bindings::sysbus_init_irq(self.as_mut_ptr(), irq.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: ObjectDeref> SysBusDeviceMethods for R where R::Target: IsA<SysBusDevice> {}
|
||||
|
||||
@@ -15,7 +15,7 @@ use qemu_api::{
|
||||
declare_properties, define_property,
|
||||
prelude::*,
|
||||
qdev::{DeviceImpl, DeviceState, Property},
|
||||
qom::ObjectImpl,
|
||||
qom::{ObjectImpl, ParentField},
|
||||
vmstate::VMStateDescription,
|
||||
zeroable::Zeroable,
|
||||
};
|
||||
@@ -31,7 +31,7 @@ pub static VMSTATE: VMStateDescription = VMStateDescription {
|
||||
#[repr(C)]
|
||||
#[derive(qemu_api_macros::Object)]
|
||||
pub struct DummyState {
|
||||
parent: DeviceState,
|
||||
parent: ParentField<DeviceState>,
|
||||
migrate_clock: bool,
|
||||
}
|
||||
|
||||
|
||||
+30
-1
@@ -10,6 +10,27 @@
|
||||
# This work is licensed under the terms of the GNU GPLv2 or later.
|
||||
# See the COPYING file in the top-level directory.
|
||||
|
||||
function subproject_dir() {
|
||||
if test ! -f "subprojects/$1.wrap"; then
|
||||
error "scripts/archive-source.sh should only process wrap subprojects"
|
||||
fi
|
||||
|
||||
# Print the directory key of the wrap file, defaulting to the
|
||||
# subproject name. The wrap file is in ini format and should
|
||||
# have a single section only. There should be only one section
|
||||
# named "[wrap-*]", which helps keeping the script simple.
|
||||
local dir
|
||||
dir=$(sed -n \
|
||||
-e '/^\[wrap-[a-z][a-z]*\]$/,/^\[/{' \
|
||||
-e '/^directory *= */!b' \
|
||||
-e 's///p' \
|
||||
-e 'q' \
|
||||
-e '}' \
|
||||
"subprojects/$1.wrap")
|
||||
|
||||
echo "${dir:-$1}"
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage:"
|
||||
echo " $0 gitrepo version"
|
||||
@@ -51,5 +72,13 @@ meson subprojects download $SUBPROJECTS
|
||||
CryptoPkg/Library/OpensslLib/openssl \
|
||||
MdeModulePkg/Library/BrotliCustomDecompressLib/brotli)
|
||||
popd
|
||||
tar --exclude=.git -cJf ${destination}.tar.xz ${destination}
|
||||
|
||||
exclude=(--exclude=.git)
|
||||
# include the tarballs in subprojects/packagecache but not their expansion
|
||||
for sp in $SUBPROJECTS; do
|
||||
if grep -xqF "[wrap-file]" subprojects/$sp.wrap; then
|
||||
exclude+=(--exclude=subprojects/"$(subproject_dir $sp)")
|
||||
fi
|
||||
done
|
||||
tar "${exclude[@]}" -cJf ${destination}.tar.xz ${destination}
|
||||
rm -rf ${destination}
|
||||
|
||||
@@ -215,6 +215,8 @@ def main() -> None:
|
||||
|
||||
if rustc_version >= (1, 80):
|
||||
if args.lints:
|
||||
print("--check-cfg")
|
||||
print("cfg(test)")
|
||||
for cfg in sorted(cargo_toml.check_cfg):
|
||||
print("--check-cfg")
|
||||
print(cfg)
|
||||
|
||||
@@ -5,3 +5,6 @@ source_filename = arbitrary-int-1.2.7.tar.gz
|
||||
source_hash = c84fc003e338a6f69fbd4f7fe9f92b535ff13e9af8997f3b14b6ddff8b1df46d
|
||||
#method = cargo
|
||||
patch_directory = arbitrary-int-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
# v2
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user