From patchwork Fri Oct 4 16:21:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1992837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ytp0wzKT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XKv3C0z53z1xsn for ; Sat, 5 Oct 2024 02:22:47 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swl4K-0004CY-I1; Fri, 04 Oct 2024 12:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swl4F-00048v-6I for qemu-ppc@nongnu.org; Fri, 04 Oct 2024 12:22:11 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1swl4D-0004Jp-CG for qemu-ppc@nongnu.org; Fri, 04 Oct 2024 12:22:10 -0400 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2fada911953so32269661fa.0 for ; Fri, 04 Oct 2024 09:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728058927; x=1728663727; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ar5l4AIEpN89iIriQ1A0Rg6FdJgoGAMAWx9ArtF1/do=; b=Ytp0wzKTkW8NIPEum3ch5BKTIUseSEEti4EBj3Va0PjPyzOXXJoBPmz/aCffQCD0kA 9AUmpDDjj30sz3pDRGZWur0HZtaSt5J4HRvZZOvR+oog+v/tgvFbvdXKhi7N6/fA3W5B B32ke9DsYjLwb1GtCMDtnM08oo1cpf8xGqMRmgGicKna3Y6nWbzEpBGfePAT2wsECryq VsEmgIngAoDDO+dbUYA2WWBzT3GrLK8OnlZpctUYcZWmnkNq+eeUSNqUqWvt3J/g98I+ mXgHCcPOHMPgy114mnh6X/Wy1wBB10iKff14hQEw/46i2FQJZZUkyGeh81kMfIFjrwCb CYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728058927; x=1728663727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ar5l4AIEpN89iIriQ1A0Rg6FdJgoGAMAWx9ArtF1/do=; b=BHZYkVryxcZ6sJtUTa0Sf8QUL5+VWSGTYN2nM9OI9WHfXJVcAiAvTywHMLnqqYCuCP Rq9Zx8Larl7tfN5xAodlK6LE1X0PJIfWjPg7Gul6xsr6OCw43FnAT+RKFbLAWspg6xL/ s2gAvmMF7b+E7v5KZB9HXbtmFFT5cwiqg+Z74YDVESjG7e0rlu0dRRfc06gqSKIkk5+o vm0eWv5JiDusHkOgQRyyte9mIYRihxiQQmWe2lhAeUSbp2aGB05r8344nzXIvnEPJS7n wFixux2d5TTx0CIESjdRsXWbGM3wZubflxGUXCeO6PoiTFjgZyR6rFv95Ai/mfaZZ+EI Zolw== X-Forwarded-Encrypted: i=1; AJvYcCUXprXABPX5sCSjlMumKspqRl0fEyLZFN5pJcYQiKPvUkXdaDDWKu6bElvOBKt+IP7zEGx8S2SvMQ==@nongnu.org X-Gm-Message-State: AOJu0YyZafZnPF4Gj4Z/1UkJb1FzhXEnTJBwRCSf2ftnpTg1pSkdfZyT 6Z1aHtOiz4mWncZIKJdkWQIh0o18ZA0fURbQ3Im2W6Kr+5/rr6a3OmRexDIbzXY= X-Google-Smtp-Source: AGHT+IFsIuCQ7d+7+0RsX/Vd0YwJrvjoi0ry7R5LFTdLE2Ujg5gNPsFFkwQYYRLubJrzHEDme/ZBvA== X-Received: by 2002:a2e:b8c9:0:b0:2fa:cf2c:479a with SMTP id 38308e7fff4ca-2faf39f9266mr9732401fa.24.1728058927479; Fri, 04 Oct 2024 09:22:07 -0700 (PDT) Received: from localhost.localdomain ([91.223.100.208]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2faf9b33027sm161171fa.115.2024.10.04.09.21.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Oct 2024 09:22:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Eduardo Habkost , Yanan Wang , "Edgar E. Iglesias" , qemu-ppc@nongnu.org, Marcel Apfelbaum , Aleksandar Rikalo , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Nicholas Piggin , qemu-arm@nongnu.org, Zhao Liu , Peter Maydell , Jiaxun Yang Subject: [PATCH 2/8] hw/core/cpu: Introduce CPUClass::is_big_endian() handler Date: Fri, 4 Oct 2024 13:21:12 -0300 Message-ID: <20241004162118.84570-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241004162118.84570-1-philmd@linaro.org> References: <20241004162118.84570-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=philmd@linaro.org; helo=mail-lj1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce the CPUClass::is_big_endian() handler and its common default. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 3 ++- hw/core/cpu-common.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 04e9ad49968..22ef7a44e86 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -150,6 +150,7 @@ struct CPUClass { ObjectClass *(*class_by_name)(const char *cpu_model); void (*parse_features)(const char *typename, char *str, Error **errp); + bool (*is_big_endian)(CPUState *cpu); bool (*has_work)(CPUState *cpu); int (*mmu_index)(CPUState *cpu, bool ifetch); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, @@ -749,7 +750,7 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs); */ bool cpu_virtio_is_big_endian(CPUState *cpu); -#endif /* CONFIG_USER_ONLY */ +#endif /* !CONFIG_USER_ONLY */ /** * cpu_list_add: diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 7982ecd39a5..aa5ea9761e4 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -26,6 +26,7 @@ #include "qemu/main-loop.h" #include "exec/log.h" #include "exec/gdbstub.h" +#include "exec/tswap.h" #include "sysemu/tcg.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -138,6 +139,11 @@ static void cpu_common_reset_hold(Object *obj, ResetType type) cpu_exec_reset_hold(cpu); } +static bool cpu_common_is_big_endian(CPUState *cs) +{ + return target_words_bigendian(); +} + static bool cpu_common_has_work(CPUState *cs) { return false; @@ -306,6 +312,7 @@ static void cpu_common_class_init(ObjectClass *klass, void *data) k->parse_features = cpu_common_parse_features; k->get_arch_id = cpu_common_get_arch_id; + k->is_big_endian = cpu_common_is_big_endian; k->has_work = cpu_common_has_work; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register;