From patchwork Fri Sep 30 00:25:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 676823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3slXMv3rmGz9sBg for ; Fri, 30 Sep 2016 10:27:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b=XcyDPUQL; dkim-atps=neutral Received: from localhost ([::1]:40968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bplg8-0003Oy-7e for incoming@patchwork.ozlabs.org; Thu, 29 Sep 2016 20:27:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bplf8-0002SH-3q for qemu-devel@nongnu.org; Thu, 29 Sep 2016 20:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bplf3-0004K7-9h for qemu-devel@nongnu.org; Thu, 29 Sep 2016 20:26:49 -0400 Received: from mail-bn3nam01on0076.outbound.protection.outlook.com ([104.47.33.76]:13344 helo=NAM01-BN3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bplf3-0004Jy-0T for qemu-devel@nongnu.org; Thu, 29 Sep 2016 20:26:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9WQ/3g3WrIMdnJwwD8el7+WNBaBraxBrPKNOx1otmKs=; b=XcyDPUQLyWBt9sjlPMWYRcfNVgN4JBy3R28SlH72/pKDcUvukldr9R6mCyH4GhRivvIZEJ8zYn5A9ttarzhmlCrqIsoP9P+b+QkQGSwvjQtyj+dVZBXxjkqwVOdzMjXqLgoAeBVs2tdMLybbi/7tcVa70AFS3MIlNSRcOkZYw1g= Received: from BLUPR0201CA0039.namprd02.prod.outlook.com (10.163.116.49) by MWHPR02MB2893.namprd02.prod.outlook.com (10.175.50.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Fri, 30 Sep 2016 00:26:42 +0000 Received: from SN1NAM02FT022.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::209) by BLUPR0201CA0039.outlook.office365.com (2a01:111:e400:52e7::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5 via Frontend Transport; Fri, 30 Sep 2016 00:26:41 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=xilinx.com; Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Received: from xsj-tvapsmtpgw01 (149.199.60.96) by SN1NAM02FT022.mail.protection.outlook.com (10.152.72.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Fri, 30 Sep 2016 00:26:41 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:39417 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1bpley-0008Lt-Oh; Thu, 29 Sep 2016 17:26:40 -0700 Received: from [127.0.0.1] (port=36244 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1bpley-0008Tx-Mc; Thu, 29 Sep 2016 17:26:40 -0700 Received: from xsj-tvapsmtp02 (smtptest.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u8U0JUuV019972; Thu, 29 Sep 2016 17:19:30 -0700 Received: from [172.19.74.182] (port=35394 helo=xsjalistai50.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1bplex-0008Tt-VU; Thu, 29 Sep 2016 17:26:39 -0700 From: Alistair Francis To: , Date: Thu, 29 Sep 2016 17:25:25 -0700 Message-ID: <10f2a9dce5e5e11b6c6d959415b0ad6ee22bcba5.1475195078.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22606.005 X-TM-AS-Result: No--15.224-7.0-31-10 X-imss-scan-details: No--15.224-7.0-31-10 X-TMASE-MatchedRID: yzVmEYf2mM5YXTxImR5ZvCZm6wdY+F8KM3PBQtDBME+voBtU8+SlKXwL IuHX+Mpn2OsYla+9EV3bpuLIddUnr4rFHTmMFhb3o65WJt1k1O9imi8LvNfmr3e9QDr8+LTcekW kqRyavwBkyZ3+4Xs7mzCPVHUG/ZsZo2/hacPcLS7huXUWQoMQtxLDxzOohy92VAtGiF8H70RueM FwDJsv/I21Kobj+A4BTBQS8oxm+JWLCg+Q1EjNrGivjLE8DPtZESkTGKrLlVDI9EDAP/dptrCM3 XLwfevKGZX1yRBMIPJV1Wte5Zia4NDG8wuCcsrkneIQmu8UmaGuiRuR9mCauh1jWjAZHoEnqcTe K67rgVObN0ZWWSPqCrW7tsa7op1lPXdZx1sZHpD1RUeLAvHT8g8JAnaMw0RVOT6W+XN+xacGk2p TPAu+9wMGnXuQSmg4leDbGKYrxKTpVX2DTlxqpqIjfGE5qvnL6BV0G92YJFHagsZM0qVv17JVv1 3dZNfH0H9PqF5jU2HIYyYC6QTPrBgEuFFWa742NNHZMWDTEbdn+sA9+u1YLUUNHQAoZf5c9CbSN qDgqjlzO+Zpou7mRiWP/oYiQlFQHMuTzWfQQg28coKUcaOOvW0hObbBIfDgpagkuUYwXN1NboKg ffrvDRkvaUQZbD2TjUeYmW81wratuHmXLC26Q7rbxxduc6FPfS0Ip2eEHnz3IzXlXlpamPoLR4+ zsDTtAqYBE3k9Mpw= X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.96; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(4326007)(86362001)(105606002)(8936002)(47776003)(50986999)(5003940100001)(76176999)(77096005)(118296001)(48376002)(5001770100001)(586003)(7846002)(33646002)(92566002)(626004)(6666003)(9786002)(50466002)(19580405001)(11100500001)(19580395003)(189998001)(71366001)(87936001)(2950100002)(81166006)(36756003)(85426001)(81156014)(8676002)(2906002)(229853001)(106466001)(356003)(5660300001)(50226002)(305945005)(64026002)(41533002)(107986001)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR02MB2893; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; PTR:unknown-60-96.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT022; 1:o0xQs84fCAzWsY5zI2gGLIh9H+OrlVFgKv0hS3q1PPulbAB3xevB8PVQGcR6sx2gXcThfVgyqjJv09YSeUY2bsGypgJLog6sazYfAI8pbEsSqEZvsJ2EPARjM8Oi09+zMfgHxOMzfr65owb6dkRm2c8m35VbnryVkMQOQX3x3CtXD5mPuYuj+hSejEupvh5uHEExdZGnmfIT03xbJeyStypfz2cec9is6WN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m6wQc9MRZdWKSX2Ukclc6vy9eA/Kl3Wu5m7pv6Vrzh2acIvUQ+k X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592)(170618885588394)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(13023025)(13015025)(13017025)(13024025)(13018025)(10201501046)(3002001)(6055026); SRVR:MWHPR02MB2893; BCL:0; PCL:0; RULEID:; SRVR:MWHPR02MB2893; X-Microsoft-Exchange-Diagnostics: 1; MWHPR02MB2893; 4:n/AJHZsNrKXhikX1Pjl5N55AUJGrX2d+oshdChuYKNpVLjkbk0lpuQwgOGTUrIKNI0kTvYppBSAB27guxpTYiPFM5qPCWVYcCUGbMnRlsaYg3DhTolgrrMPIcEn1qbUjdalPgrqkvkce8O+wJ9FccZQjbVzCiOZXl1+B3vCnXC78dfZH+1vt1p82vS7vCzl0l334UKv+sk8+5goJnt3fr8Yk/h4mQvrH1xYYZphiHX3BLHUPwBJp2iB/W/v0cljs7YWnrXEnxk7XHLC3EiS4tfWgNA8EWZBnp05O4g+7AjRLAhF1kSQYtQHt3W5cxn2WDvo+ZvsywEO4YsKaJ4ohPxXGSeUNma5l4nluLmemweKHgfcD9PVpqEn1wNg2wDoPHky45iBxMgsm/v3MBMEtg40q0fYDp/MtuituNqJWFuU1NgikoVEOXnAEpbR1NKng5kJeba63qSpG9gB+5uaN6efag32+f7BPubPpH7Vm6lHyKGJ0/EzmBsl3SgC89AeFxO+Ou0I7y/r3FL9IvRHZm4LaewoOQ5TLpzsP4LXkj1HAHAqbZpGqtSF1pwKOhGUWxXO3cmIJqWUYgnbTdyncwgDuJD7gtIVtksaIIsTvQKc= X-Forefront-PRVS: 008184426E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR02MB2893; 23:6xWzRaXV9E+EKlGAI8Syd+e04vE6Ci0rS3BfRg7hj?= =?us-ascii?Q?HMpVILhmbrp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MKYH1ir94/LMfCyVuVQhWVoZ+m3nZ8JQZGfdq6QCMCxpBOWBiC9YTbaqaRwfo+wdUAeE1jSCgkdkAig5tGv3SnBg2iS4DkV1ts1WSs1FyfEexWtYoWBhzX1Br0PjRRrar8SeRiq3IyHdvHGMFj7MPfn3USBNt9sz9FUgAeLkqrwToK3hTw4/Ptlifyq6sFD7cjAjbsgd8ws5jdom5oVvyCRH+01O2DuCwPeXen3IpgxlBUxWtxOJumcVsV3PLedcJlhu6bsT8+odAR36qD3dyR5kZKUwbvM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2016 00:26:41.3082 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96]; Helo=[xsj-tvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2893 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.33.76 Subject: [Qemu-devel] [PATCH v13 1/2] generic-loader: Add a generic loader X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cov@codeaurora.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, armbru@redhat.com, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a generic loader to QEMU which can be used to load images or set memory values. Internally inside QEMU this is a device. It is a strange device that provides no hardware interface but allows QEMU to monkey patch memory specified when it is created. To be able to do this it has a reset callback that does the memory operations. This device allows the user to monkey patch memory. To be able to do this it needs a backend to manage the datas, the same as other memory-related devices. In this case as the backend is so trivial we have merged it with the frontend instead of creating and maintaining a seperate backend. Signed-off-by: Alistair Francis Reviewed-by: Peter Maydell Acked-by: Markus Armbruster --- V13: - Include the commit message in the c file. V12: - Update commit message to justify using -device V11: - Small corrections - Don't check for !data as writing a value of 0 is valid. V10: - Split out the PC setting and data loading V9: - Fix error messages - Updated some incorrect logic - Add address space loading support for all image types - Explain why the reset is manually registered V8: - Code corrections - Rebase V7: - Rebase V6: - Add error checking V5: - Rebase V4: - Allow the loader to work with every architecture - Move the file to hw/core - Increase the maximum number of CPUs - Make the CPU operations conditional - Convert the cpu option to cpu-num - Require the user to specify endianess V3: - Pass the ram_size to load_image_targphys() V2: - Add maintainers entry - Perform bounds checking - Register and unregister the reset in the realise/unrealise Changes since RFC: - Add BE support MAINTAINERS | 6 ++ hw/core/Makefile.objs | 2 + hw/core/generic-loader.c | 211 +++++++++++++++++++++++++++++++++++++++ include/hw/core/generic-loader.h | 46 +++++++++ 4 files changed, 265 insertions(+) create mode 100644 hw/core/generic-loader.c create mode 100644 include/hw/core/generic-loader.h diff --git a/MAINTAINERS b/MAINTAINERS index f3c1f7f..9ecaaa5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1013,6 +1013,12 @@ M: Dmitry Fleytman S: Maintained F: hw/net/e1000e* +Generic Loader +M: Alistair Francis +S: Maintained +F: hw/core/generic-loader.c +F: include/hw/core/generic-loader.h + Subsystems ---------- Audio diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index cfd4840..939c94e 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -17,3 +17,5 @@ common-obj-$(CONFIG_SOFTMMU) += loader.o common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o common-obj-$(CONFIG_SOFTMMU) += register.o common-obj-$(CONFIG_PLATFORM_BUS) += platform-bus.o + +obj-$(CONFIG_SOFTMMU) += generic-loader.o diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c new file mode 100644 index 0000000..79ab6df --- /dev/null +++ b/hw/core/generic-loader.c @@ -0,0 +1,211 @@ +/* + * Generic Loader + * + * Copyright (C) 2014 Li Guang + * Copyright (C) 2016 Xilinx Inc. + * Written by Li Guang + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + */ + +/* + * Internally inside QEMU this is a device. It is a strange device that + * provides no hardware interface but allows QEMU to monkey patch memory + * specified when it is created. To be able to do this it has a reset + * callback that does the memory operations. + + * This device allows the user to monkey patch memory. To be able to do + * this it needs a backend to manage the datas, the same as other + * memory-related devices. In this case as the backend is so trivial we + * have merged it with the frontend instead of creating and maintaining a + * seperate backend. + */ + +#include "qemu/osdep.h" +#include "qom/cpu.h" +#include "hw/sysbus.h" +#include "sysemu/dma.h" +#include "hw/loader.h" +#include "qapi/error.h" +#include "hw/core/generic-loader.h" + +#define CPU_NONE 0xFFFFFFFF + +static void generic_loader_reset(void *opaque) +{ + GenericLoaderState *s = GENERIC_LOADER(opaque); + + if (s->set_pc) { + CPUClass *cc = CPU_GET_CLASS(s->cpu); + cpu_reset(s->cpu); + if (cc) { + cc->set_pc(s->cpu, s->addr); + } + } + + if (s->data_len) { + assert(s->data_len < sizeof(s->data)); + dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len); + } +} + +static void generic_loader_realize(DeviceState *dev, Error **errp) +{ + GenericLoaderState *s = GENERIC_LOADER(dev); + hwaddr entry; + int big_endian; + int size = 0; + + s->set_pc = false; + + /* Perform some error checking on the user's options */ + if (s->data || s->data_len || s->data_be) { + /* User is loading memory values */ + if (s->file) { + error_setg(errp, "Specifying a file is not supported when loading " + "memory values"); + return; + } else if (s->force_raw) { + error_setg(errp, "Specifying force-raw is not supported when " + "loading memory values"); + return; + } else if (!s->data_len) { + /* We cant' check for !data here as a value of 0 is still valid. */ + error_setg(errp, "Both data and data-len must be specified"); + return; + } else if (s->data_len > 8) { + error_setg(errp, "data-len cannot be greater then 8 bytes"); + return; + } + } else if (s->file || s->force_raw) { + /* User is loading an image */ + if (s->data || s->data_len || s->data_be) { + error_setg(errp, "data can not be specified when loading an " + "image"); + return; + } + s->set_pc = true; + } else if (s->addr) { + /* User is setting the PC */ + if (s->data || s->data_len || s->data_be) { + error_setg(errp, "data can not be specified when setting a " + "program counter"); + return; + } else if (!s->cpu_num) { + error_setg(errp, "cpu_num must be specified when setting a " + "program counter"); + return; + } + s->set_pc = true; + } else { + /* Did the user specify anything? */ + error_setg(errp, "please include valid arguments"); + return; + } + + qemu_register_reset(generic_loader_reset, dev); + + if (s->cpu_num != CPU_NONE) { + s->cpu = qemu_get_cpu(s->cpu_num); + if (!s->cpu) { + error_setg(errp, "Specified boot CPU#%d is nonexistent", + s->cpu_num); + return; + } + } else { + s->cpu = first_cpu; + } + +#ifdef TARGET_WORDS_BIGENDIAN + big_endian = 1; +#else + big_endian = 0; +#endif + + if (s->file) { + if (!s->force_raw) { + size = load_elf_as(s->file, NULL, NULL, &entry, NULL, NULL, + big_endian, 0, 0, 0, s->cpu->as); + + if (size < 0) { + size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, + s->cpu->as); + } + } + + if (size < 0 || s->force_raw) { + /* Default to the maximum size being the machine's ram size */ + size = load_image_targphys_as(s->file, s->addr, ram_size, + s->cpu->as); + } else { + s->addr = entry; + } + + if (size < 0) { + error_setg(errp, "Cannot load specified image %s", s->file); + return; + } + } + + /* Convert the data endiannes */ + if (s->data_be) { + s->data = cpu_to_be64(s->data); + } else { + s->data = cpu_to_le64(s->data); + } +} + +static void generic_loader_unrealize(DeviceState *dev, Error **errp) +{ + qemu_unregister_reset(generic_loader_reset, dev); +} + +static Property generic_loader_props[] = { + DEFINE_PROP_UINT64("addr", GenericLoaderState, addr, 0), + DEFINE_PROP_UINT64("data", GenericLoaderState, data, 0), + DEFINE_PROP_UINT8("data-len", GenericLoaderState, data_len, 0), + DEFINE_PROP_BOOL("data-be", GenericLoaderState, data_be, false), + DEFINE_PROP_UINT32("cpu-num", GenericLoaderState, cpu_num, CPU_NONE), + DEFINE_PROP_BOOL("force-raw", GenericLoaderState, force_raw, false), + DEFINE_PROP_STRING("file", GenericLoaderState, file), + DEFINE_PROP_END_OF_LIST(), +}; + +static void generic_loader_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + /* The reset function is not registered here and is instead registered in + * the realize function to allow this device to be added via the device_add + * command in the QEMU monitor. + * TODO: Improve the device_add functionality to allow resets to be + * connected + */ + dc->realize = generic_loader_realize; + dc->unrealize = generic_loader_unrealize; + dc->props = generic_loader_props; + dc->desc = "Generic Loader"; +} + +static TypeInfo generic_loader_info = { + .name = TYPE_GENERIC_LOADER, + .parent = TYPE_DEVICE, + .instance_size = sizeof(GenericLoaderState), + .class_init = generic_loader_class_init, +}; + +static void generic_loader_register_type(void) +{ + type_register_static(&generic_loader_info); +} + +type_init(generic_loader_register_type) diff --git a/include/hw/core/generic-loader.h b/include/hw/core/generic-loader.h new file mode 100644 index 0000000..dd27c42 --- /dev/null +++ b/include/hw/core/generic-loader.h @@ -0,0 +1,46 @@ +/* + * Generic Loader + * + * Copyright (C) 2014 Li Guang + * Written by Li Guang + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef GENERIC_LOADER_H +#define GENERIC_LOADER_H + +#include "elf.h" + +typedef struct GenericLoaderState { + /* */ + DeviceState parent_obj; + + /* */ + CPUState *cpu; + + uint64_t addr; + uint64_t data; + uint8_t data_len; + uint32_t cpu_num; + + char *file; + + bool force_raw; + bool data_be; + bool set_pc; +} GenericLoaderState; + +#define TYPE_GENERIC_LOADER "loader" +#define GENERIC_LOADER(obj) OBJECT_CHECK(GenericLoaderState, (obj), \ + TYPE_GENERIC_LOADER) + +#endif