From: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org
Cc: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
Subject: [RFC PATCH 53/75] hw/core: add fallthrough pseudo-keyword
Date: Fri, 13 Oct 2023 10:48:13 +0300 [thread overview]
Message-ID: <2b1f19fcb93c79a455e09985d68d5f6b122e3b65.1697034504.git.manos.pitsidianakis@linaro.org> (raw)
In-Reply-To: <cover.1697034504.git.manos.pitsidianakis@linaro.org>
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
---
hw/core/loader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 4dd5a71fb7..559d63a1e2 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -625,138 +625,138 @@ toosmall:
/* Load a U-Boot image. */
static ssize_t load_uboot_image(const char *filename, hwaddr *ep,
hwaddr *loadaddr, int *is_linux,
uint8_t image_type,
uint64_t (*translate_fn)(void *, uint64_t),
void *translate_opaque, AddressSpace *as)
{
int fd;
ssize_t size;
hwaddr address;
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
int ret = -1;
int do_uncompress = 0;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
return -1;
size = read(fd, hdr, sizeof(uboot_image_header_t));
if (size < sizeof(uboot_image_header_t)) {
goto out;
}
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
goto out;
if (hdr->ih_type != image_type) {
if (!(image_type == IH_TYPE_KERNEL &&
hdr->ih_type == IH_TYPE_KERNEL_NOLOAD)) {
fprintf(stderr, "Wrong image type %d, expected %d\n", hdr->ih_type,
image_type);
goto out;
}
}
/* TODO: Implement other image types. */
switch (hdr->ih_type) {
case IH_TYPE_KERNEL_NOLOAD:
if (!loadaddr || *loadaddr == LOAD_UIMAGE_LOADADDR_INVALID) {
fprintf(stderr, "this image format (kernel_noload) cannot be "
"loaded on this machine type");
goto out;
}
hdr->ih_load = *loadaddr + sizeof(*hdr);
hdr->ih_ep += hdr->ih_load;
- /* fall through */
+ fallthrough;
case IH_TYPE_KERNEL:
address = hdr->ih_load;
if (translate_fn) {
address = translate_fn(translate_opaque, address);
}
if (loadaddr) {
*loadaddr = hdr->ih_load;
}
switch (hdr->ih_comp) {
case IH_COMP_NONE:
break;
case IH_COMP_GZIP:
do_uncompress = 1;
break;
default:
fprintf(stderr,
"Unable to load u-boot images with compression type %d\n",
hdr->ih_comp);
goto out;
}
if (ep) {
*ep = hdr->ih_ep;
}
/* TODO: Check CPU type. */
if (is_linux) {
if (hdr->ih_os == IH_OS_LINUX) {
*is_linux = 1;
} else if (hdr->ih_os == IH_OS_VXWORKS) {
/*
* VxWorks 7 uses the same boot interface as the Linux kernel
* on Arm (64-bit only), PowerPC and RISC-V architectures.
*/
switch (hdr->ih_arch) {
case IH_ARCH_ARM64:
case IH_ARCH_PPC:
case IH_ARCH_RISCV:
*is_linux = 1;
break;
default:
*is_linux = 0;
break;
}
} else {
*is_linux = 0;
}
}
break;
case IH_TYPE_RAMDISK:
address = *loadaddr;
break;
default:
fprintf(stderr, "Unsupported u-boot image type %d\n", hdr->ih_type);
goto out;
}
data = g_malloc(hdr->ih_size);
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
goto out;
}
if (do_uncompress) {
uint8_t *compressed_data;
size_t max_bytes;
ssize_t bytes;
compressed_data = data;
max_bytes = UBOOT_MAX_GUNZIP_BYTES;
data = g_malloc(max_bytes);
bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
g_free(compressed_data);
if (bytes < 0) {
fprintf(stderr, "Unable to decompress gzipped image!\n");
goto out;
}
hdr->ih_size = bytes;
}
rom_add_blob_fixed_as(filename, data, hdr->ih_size, address, as);
ret = hdr->ih_size;
--
2.39.2
next prev parent reply other threads:[~2023-10-13 8:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1697034504.git.manos.pitsidianakis@linaro.org>
2023-10-13 7:47 ` [RFC PATCH 37/75] system/rtc.c: add fallthrough pseudo-keyword Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 38/75] hw/scsi: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 39/75] hw/sd/sdhci.c: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 40/75] linux-user: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 41/75] hw/i386: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 42/75] hw/misc: " Emmanouil Pitsidianakis
2023-10-13 8:11 ` Cédric Le Goater
2023-10-13 7:47 ` [RFC PATCH 43/75] hw/m68k/mcf_intc.c: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 44/75] hw/dma: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 45/75] disas: " Emmanouil Pitsidianakis
2023-10-13 7:47 ` [RFC PATCH 46/75] contrib/rdmacm-mux: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 47/75] contrib/vhost-user-scsi: " Emmanouil Pitsidianakis
2023-10-23 9:31 ` Raphael Norwitz
2023-10-13 7:48 ` [RFC PATCH 48/75] hw/arm: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 49/75] hw/audio: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 50/75] chardev: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 51/75] hw/char: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 52/75] nbd: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` Emmanouil Pitsidianakis [this message]
2023-10-13 7:48 ` [RFC PATCH 54/75] hw/display: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 55/75] hw/input: " Emmanouil Pitsidianakis
2023-10-13 7:48 ` [RFC PATCH 56/75] hw/net: " Emmanouil Pitsidianakis
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=2b1f19fcb93c79a455e09985d68d5f6b122e3b65.1697034504.git.manos.pitsidianakis@linaro.org \
--to=manos.pitsidianakis@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).