From patchwork Wed Sep 28 22:45:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 676457 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 3sktH54Whcz9ryv for ; Thu, 29 Sep 2016 08:51:29 +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=tLSjmBYj; dkim-atps=neutral Received: from localhost ([::1]:33669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpNhG-00026J-LP for incoming@patchwork.ozlabs.org; Wed, 28 Sep 2016 18:51:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpNd3-00070N-Sc for qemu-devel@nongnu.org; Wed, 28 Sep 2016 18:47:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpNd0-00039w-Ea for qemu-devel@nongnu.org; Wed, 28 Sep 2016 18:47:05 -0400 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:6127 helo=NAM02-BL2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpNd0-00039p-9W for qemu-devel@nongnu.org; Wed, 28 Sep 2016 18:47:02 -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=G3GpINV4nxhvf+vWzARYpg/NXoS1Ipjgwa6dGX+jElQ=; b=tLSjmBYjvWE1AyL2C8WyasCkGNRZdssYoiCtUZ1X/tVU7ILXQKmoHXOOhYlHdDf3DlmHo8yWVdPrhWCmkPSrcv369yRy2YRCEl8o0i7UppFuMepToxCE2l8UHO8A0liXxIdPKqRc9FqBEFuGtTbq7uQIU8aY79BkqHEizgulwzE= Received: from CY4PR02CA0031.namprd02.prod.outlook.com (10.175.57.145) by DM5PR02MB2892.namprd02.prod.outlook.com (10.175.86.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Wed, 28 Sep 2016 22:47:00 +0000 Received: from BL2NAM02FT043.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by CY4PR02CA0031.outlook.office365.com (2603:10b6:903:117::17) 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; Wed, 28 Sep 2016 22:47:00 +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 BL2NAM02FT043.mail.protection.outlook.com (10.152.77.95) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Wed, 28 Sep 2016 22:46:57 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:38590 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1bpNcu-0006Fn-6q; Wed, 28 Sep 2016 15:46:56 -0700 Received: from [127.0.0.1] (port=35416 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1bpNcu-0000pc-52; Wed, 28 Sep 2016 15:46:56 -0700 Received: from xsj-tvapsmtp02 (xsj-tvapsmtp02.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u8SMdjCN014948; Wed, 28 Sep 2016 15:39:45 -0700 Received: from [172.19.74.182] (port=47888 helo=xsjalistai50.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1bpNct-0000pU-9M; Wed, 28 Sep 2016 15:46:55 -0700 From: Alistair Francis To: , Date: Wed, 28 Sep 2016 15:45:43 -0700 Message-ID: <5fb4c81eca6d12f304e0798ea569742b6860caa4.1475102513.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-22604.005 X-TM-AS-Result: No--14.957-7.0-31-10 X-imss-scan-details: No--14.957-7.0-31-10 X-TMASE-MatchedRID: HO2R4ZbKXxNYXTxImR5ZvCZm6wdY+F8KM3PBQtDBME+voBtU8+SlKXwL IuHX+Mpn2OsYla+9EV3bpuLIddUnr4rFHTmMFhb3o65WJt1k1O9imi8LvNfmr3e9QDr8+LTcekW kqRyavwBkyZ3+4Xs7m0jKd8AzLWpr9nJMOjYhnpRbfKKl6z2u8k59yCzaXDrv1bSmSk9HUNodsc tPcFdCI0Y31ryE1SaMC14OfQgNPMEBM5SnKo8xnGwjJ4TFeU1uXs5nqGvDCfMsX4dJC/gI/v+4Z Hmr4Mk/g4BSUQlYa3R5CAC6ph0xvXmVnpZCEhlXkDpLRKO9xhRB+8LAeeOOMBS11FlOYRoh3v2i x4ONJ0K2XO6LyR+n36AY5nebYtjnMjRTNF2tbaiVOwZbcOalS7yT3xKKS5DsZ5yuplze9pt+FDg UHX2Sat6Cfj541Hz9YNAHANh/seDwUUVGpn4XjMobDTV7SlvB1kqyrcMalqX9k2xa9AhjgxHEWt 1zOSXkabUjCj7vCI4avgb7rqAynGPlX7LITICtogGd8wIUGIK7nrAU9KQxUY4nB4UHTTHhZ6Lf1 krpLFH6c9dUqnQkTcXIHRgHx+FSePGAeSn124KzLD5kmcW6ZAdj8dD1pxq7ar//kCjXDy729Hrp AfPGC+mYHK3tx8QF/V/n5y58pcjs8TWiNgS9oZ4CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyH4gKq4 2LRYkg9kB9fGwmZIHH2npm2BaoiPPYiygakDvR3Jnfkb1lqh+3BndfXUhXQ== 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)(5003940100001)(105606002)(33646002)(4326007)(8676002)(118296001)(2906002)(64026002)(50226002)(9786002)(229853001)(11100500001)(586003)(36756003)(76176999)(2950100002)(50986999)(71366001)(85426001)(626004)(77096005)(47776003)(8936002)(356003)(5001770100001)(106466001)(50466002)(189998001)(87936001)(92566002)(81166006)(81156014)(305945005)(19580395003)(5660300001)(86362001)(19580405001)(7846002)(48376002)(6666003)(41533002)(2004002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR02MB2892; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; PTR:unknown-60-96.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2NAM02FT043; 1:xTYwWrQ1gXwwz6vYjpO1Kd31PZ50/r8f6wE+9QkNFTYU8gVFI48WqCFWMZhGQsqK3MaPR3e80nMo5iGzzbqijchIXngj+/P289NjgiBeRY37x9XfCkwT6cuayMw3Kir+a+NfW3KBs33bJaHSfk+3Wmy6EFaReJIjou4l8wH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WCtf6MwaXEZHaXE+6Fnz+arrKTMYK8Y/MYrHwDY6KBTJKivQhVdgJUldln+N4/+lwsKO9y6kHr77eR4v6Of+7xv3Bb2ZMFiT4/4YxlHFhgnCzIWb+zVP+8+Q1Zx 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)(13024025)(5005006)(8121501046)(13018025)(13023025)(13017025)(13015025)(10201501046)(3002001)(6055026); SRVR:DM5PR02MB2892; BCL:0; PCL:0; RULEID:; SRVR:DM5PR02MB2892; X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB2892; 4:d8xS/LBIzBkPwOQRQMyhAO8XQNIULdLRa5OIrRsa8j53t4p0UGhOHXi69EWpXIjZK+W0gw5DSW1uVw+XZJahv0c4SD0G3Owsjgr2w88FuepQmWNp5ZGoAaRFloK3qd3FNP3Gpgv7oKnqdpM+82VyvZHBj1c5QFwz9OJbp/ka0UHtijbeH3n8fVZj+bXperPMoGx2HeEYMq/58a/uO8BLor1nCWwCu25E9HVWIHGgQY3cDwRMk27xxzlTKp++MZxNQWbhjZibDkk7w+6/yfD7daiHWDgk2Wa094m8LHjmX5eV/m3RV8LWGlFBvjk2uT4zHvKyAd7b0FIcK1nqvD3/rSJWXU7toZzmftN5BNocOQwREMjj39U9dP1Fo6KvOTv3Mcit8KdOHzrE1TZJzYGY7qWCUCq3ib/OXqhkEI0KI250aO2A/lJVgkfg4xfuoVrZksdhVU5NXyrA9HEYmkikCj+79/Ixna3KI2xDJndUaJb2cWzgvtxauwkCGcvtV+kYLO8BxeA7QMH1lmXXGRb+juzbNHQBJ771SMTKe5ye1eMgMJkKtOk/lQsKNcmmKnz7ON7YHig2l9sfsEGKiePhHcLBEcN1xhMSRrN1+leCXtU= X-Forefront-PRVS: 0079056367 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR02MB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h5HNwrtxIvlcidfP5Pi9TVKRqLZQKt6PUm8kY=; 7:phTP2ltiD8/hJno+kCzf+TwN29VxwzteqnAurK6CQ7UjrvNETs4caj3ZosYelyYbkBqkBVRjEcwENr7ucQUJwcMA8NjDUrC051UpnEW6+DK0/dqDgiRTJnsNEIX3KKlRetem7fvkClc/WSLyEsZgGxmxvGt0WDFNNTfTxIJboR+sDSCEC2L9ny5EAq+3gE3EpGzwoJSYDFCZzazO2TYT0BDnAyGFnSabpjLB54NFys5pTwxKRLKzAJM7njgJmy3m8sqxEoiueoRtKSBcptEdKcngy9+4wrY1zxWjoHR5Ktzau3ueT8G63xBEG8RsViNF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2016 22:46:57.4395 (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: DM5PR02MB2892 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.81 Subject: [Qemu-devel] [PATCH v12 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 --- 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 | 197 +++++++++++++++++++++++++++++++++++++++ include/hw/core/generic-loader.h | 46 +++++++++ 4 files changed, 251 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..fc2fea7 --- /dev/null +++ b/hw/core/generic-loader.c @@ -0,0 +1,197 @@ +/* + * 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. + */ + +#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