From patchwork Wed May 4 11:51:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Huber X-Patchwork-Id: 618388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r0GfM24Jpz9sCY for ; Wed, 4 May 2016 21:54:03 +1000 (AEST) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1axvMA-0006pj-NK; Wed, 04 May 2016 13:52:42 +0200 Received: from a.mx.secunet.com ([62.96.220.36]) by mail.coreboot.org with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.86_2) (envelope-from ) id 1axvLh-0006jz-Us for flashrom@flashrom.org; Wed, 04 May 2016 13:52:32 +0200 Received: from localhost (alg1 [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id B2BA11A0748 for ; Wed, 4 May 2016 13:52:05 +0200 (CEST) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id o0CqEdZf9sfD for ; Wed, 4 May 2016 13:52:04 +0200 (CEST) Received: from mail-essen-01.secunet.de (unknown [10.53.40.204]) by a.mx.secunet.com (Postfix) with ESMTP id A44EF1A05E2 for ; Wed, 4 May 2016 13:52:00 +0200 (CEST) Received: from schawa.localdomain (10.182.9.137) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 4 May 2016 13:52:01 +0200 From: Nico Huber To: Date: Wed, 4 May 2016 13:51:42 +0200 Message-ID: <1462362706-31216-11-git-send-email-nico.huber@secunet.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1462362706-31216-1-git-send-email-nico.huber@secunet.com> References: <1462362706-31216-1-git-send-email-nico.huber@secunet.com> MIME-Version: 1.0 X-Originating-IP: [10.182.9.137] X-G-Data-MailSecurity-for-Exchange-SpamLevel: 0 X-G-Data-MailSecurity-for-Exchange-SpamFilter: 0; 1; str=0001.0A0C0204.5729E261.019E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 32 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: 9BD69E27-FA92-48CD-8D3F-E27DDB1D22AC X-Spam-Score: -3.5 (---) Subject: [flashrom] [PATCH 10/14] Make read_ich_descriptors_from_dump() available in flashrom X-BeenThere: flashrom@flashrom.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: flashrom discussion and development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: flashrom-bounces@flashrom.org Sender: "flashrom" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff I didn't really know what I was doing and hope removing the #ifdefs doesn't have negative side effects. The idea is to make the functions generally available for external flashing (e.g. you might want to flash an Intel machine using an ARM device as programmer). Beware of big endian trouble, I guess. :-P Signed-off-by: Nico Huber --- ich_descriptors.c | 23 ++++++++--------------- ich_descriptors.h | 11 ----------- util/ich_descriptors_tool/Makefile | 2 +- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/ich_descriptors.c b/ich_descriptors.c index 90f70ee..c9e82eb 100644 --- a/ich_descriptors.c +++ b/ich_descriptors.c @@ -19,14 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(__i386__) || defined(__x86_64__) - #include "ich_descriptors.h" -#ifdef ICH_DESCRIPTORS_FROM_DUMP - +#ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY #include #define print(t, ...) printf(__VA_ARGS__) +#endif + #define DESCRIPTOR_MODE_SIGNATURE 0x0ff0a55a /* The upper map is located in the word before the 256B-long OEM section at the * end of the 4kB-long flash descriptor. @@ -34,13 +33,10 @@ #define UPPER_MAP_OFFSET (4096 - 256 - 4) #define getVTBA(flumap) (((flumap)->FLUMAP1 << 4) & 0x00000ff0) -#else /* ICH_DESCRIPTORS_FROM_DUMP */ - +#include #include "flash.h" /* for msg_* */ #include "programmer.h" -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ - #ifndef min #define min(a, b) (a < b) ? a : b #endif @@ -69,12 +65,12 @@ void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descripto prettyprint_ich_descriptor_component(cs, desc); prettyprint_ich_descriptor_region(desc); prettyprint_ich_descriptor_master(&desc->master); -#ifdef ICH_DESCRIPTORS_FROM_DUMP +#ifdef ICH_DESCRIPTORS_FROM_DUMP_ONLY if (cs >= CHIPSET_ICH8) { prettyprint_ich_descriptor_upper_map(&desc->upper); prettyprint_ich_descriptor_straps(cs, desc); } -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ +#endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */ } void prettyprint_ich_descriptor_content(const struct ich_desc_content *cont) @@ -301,8 +297,6 @@ void prettyprint_ich_descriptor_master(const struct ich_desc_master *mstr) msg_pdbg2("\n"); } -#ifdef ICH_DESCRIPTORS_FROM_DUMP - void prettyprint_ich_descriptor_straps_ich8(const struct ich_descriptors *desc) { static const char * const str_GPIO12[4] = { @@ -792,7 +786,7 @@ int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struc return ICH_RET_OK; } -#else /* ICH_DESCRIPTORS_FROM_DUMP */ +#ifndef ICH_DESCRIPTORS_FROM_DUMP_ONLY /** Returns the integer representation of the component density with index \em idx in bytes or -1 if the correct size can not be determined. */ @@ -922,5 +916,4 @@ int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc) msg_pdbg2(" done.\n"); return ICH_RET_OK; } -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ -#endif /* defined(__i386__) || defined(__x86_64__) */ +#endif /* ICH_DESCRIPTORS_FROM_DUMP_ONLY */ diff --git a/ich_descriptors.h b/ich_descriptors.h index 2c21598..e355e54 100644 --- a/ich_descriptors.h +++ b/ich_descriptors.h @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(__i386__) || defined(__x86_64__) #ifndef __ICH_DESCRIPTORS_H__ #define __ICH_DESCRIPTORS_H__ 1 @@ -250,7 +249,6 @@ struct ich_desc_master { }; }; -#ifdef ICH_DESCRIPTORS_FROM_DUMP struct ich_desc_north_strap { union { uint32_t STRPs[1]; /* current maximum: ich8 */ @@ -561,18 +559,15 @@ struct ich_desc_upper_map { }; } vscc_table[128]; }; -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ struct ich_descriptors { struct ich_desc_content content; struct ich_desc_component component; struct ich_desc_region region; struct ich_desc_master master; -#ifdef ICH_DESCRIPTORS_FROM_DUMP struct ich_desc_north_strap north; struct ich_desc_south_strap south; struct ich_desc_upper_map upper; -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ }; void prettyprint_ich_descriptors(enum ich_chipset cs, const struct ich_descriptors *desc); @@ -582,17 +577,11 @@ void prettyprint_ich_descriptor_component(enum ich_chipset cs, const struct ich_ void prettyprint_ich_descriptor_region(const struct ich_descriptors *desc); void prettyprint_ich_descriptor_master(const struct ich_desc_master *master); -#ifdef ICH_DESCRIPTORS_FROM_DUMP - void prettyprint_ich_descriptor_upper_map(const struct ich_desc_upper_map *umap); void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_descriptors *desc); int read_ich_descriptors_from_dump(const uint32_t *dump, unsigned int len, struct ich_descriptors *desc); -#else /* ICH_DESCRIPTORS_FROM_DUMP */ - int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc); int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors *desc, uint8_t idx); -#endif /* ICH_DESCRIPTORS_FROM_DUMP */ #endif /* __ICH_DESCRIPTORS_H__ */ -#endif /* defined(__i386__) || defined(__x86_64__) */ diff --git a/util/ich_descriptors_tool/Makefile b/util/ich_descriptors_tool/Makefile index 9cbc150..e312996 100644 --- a/util/ich_descriptors_tool/Makefile +++ b/util/ich_descriptors_tool/Makefile @@ -32,7 +32,7 @@ endif FLASHROM_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d # enables functions that populate the descriptor structs from plain binary dumps -FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP +FLASHROM_CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP_ONLY FLASHROM_CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) OBJ = $(OBJATH)/$(SRC:%.c=%.o)