From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Xiaojuan Yang <yangxiaojuan@loongson.cn>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn
Subject: Re: [PATCH] hw/loongarch: Add cfi01 pflash device
Date: Tue, 15 Nov 2022 13:10:29 +0100 [thread overview]
Message-ID: <2f381d06-842f-ac8b-085c-0419675a4872@linaro.org> (raw)
In-Reply-To: <20221115115645.3372746-1-yangxiaojuan@loongson.cn>
On 15/11/22 12:56, Xiaojuan Yang wrote:
> Add cfi01 pflash device for LoongArch virt machine
So the subject prefix should be "hw/loongarch/virt:".
> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> ---
> hw/loongarch/Kconfig | 1 +
> hw/loongarch/acpi-build.c | 39 +++++++++++
> hw/loongarch/virt.c | 130 +++++++++++++++++++++++++++++++++---
> include/hw/loongarch/virt.h | 7 ++
> 4 files changed, 168 insertions(+), 9 deletions(-)
> static bool memhp_type_supported(DeviceState *dev)
> diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h
> index 45c383f5a7..4ec4a7b4fe 100644
> --- a/include/hw/loongarch/virt.h
> +++ b/include/hw/loongarch/virt.h
> @@ -12,6 +12,7 @@
> #include "hw/boards.h"
> #include "qemu/queue.h"
> #include "hw/intc/loongarch_ipi.h"
> +#include "hw/block/flash.h"
>
> #define LOONGARCH_MAX_VCPUS 4
>
> @@ -20,6 +21,11 @@
> #define VIRT_FWCFG_BASE 0x1e020000UL
> #define VIRT_BIOS_BASE 0x1c000000UL
> #define VIRT_BIOS_SIZE (4 * MiB)
> +#define VIRT_FLASH_SECTOR_SIZE (128 * KiB)
> +#define VIRT_FLASH0_BASE VIRT_BIOS_BASE
> +#define VIRT_FLASH0_SIZE (4 * MiB)
> +#define VIRT_FLASH1_BASE (VIRT_FLASH0_BASE + VIRT_FLASH0_SIZE)
> +#define VIRT_FLASH1_SIZE (4 * MiB)
>
> #define VIRT_LOWMEM_BASE 0
> #define VIRT_LOWMEM_SIZE 0x10000000
> @@ -48,6 +54,7 @@ struct LoongArchMachineState {
> int fdt_size;
> DeviceState *platform_bus_dev;
> PCIBus *pci_bus;
> + PFlashCFI01 *flash[2];
> };
Since you are starting a virtual machine from scratch, you should take
the opportunity to learn from other early mistakes. X86 ended that way
due to 1/ old firmwares back-compability and 2/ QEMU pflash block
protections not being implemented. IIUC if we were starting with a
UEFI firmware today, the layout design (still using QEMU) would be
to map the CODE area in a dumb ROM device, and the VARSTORE area
in a PFlash device. Since Virt machines don't need to use Capsule
update, having the CODE area in ROM drastically simplifies the design
and maintainance.
Regards,
Phil.
next prev parent reply other threads:[~2022-11-15 12:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 11:56 [PATCH] hw/loongarch: Add cfi01 pflash device Xiaojuan Yang
2022-11-15 12:10 ` Philippe Mathieu-Daudé [this message]
2022-11-18 2:22 ` yangxiaojuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2f381d06-842f-ac8b-085c-0419675a4872@linaro.org \
--to=philmd@linaro.org \
--cc=gaosong@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yangxiaojuan@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).