From a0c23d7d2aa8fd0797cec92e3fec0d8810e51792 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Thu, 18 Nov 2004 18:49:41 +0000 Subject: [PATCH] 2004-11-18 Marcel Telka * flash/jedec.c (jedec_detect): Added cfi_array allocation (patch 970946, Ian Campbell). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@621 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- libbrux/ChangeLog | 4 ++++ libbrux/NEWS | 1 + libbrux/THANKS | 1 + libbrux/flash/jedec.c | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/libbrux/ChangeLog b/libbrux/ChangeLog index 834a290a..99dca9f0 100644 --- a/libbrux/ChangeLog +++ b/libbrux/ChangeLog @@ -1,3 +1,7 @@ +2004-11-18 Marcel Telka + + * flash/jedec.c (jedec_detect): Added cfi_array allocation (patch 970946, Ian Campbell). + 2004-11-15 Marcel Telka * flash/intel.c (_intel_flash_print_info): Added support for Intel 28F256J3A (patch 1012140, Jerome Debard). diff --git a/libbrux/NEWS b/libbrux/NEWS index 5dc6c8c3..2fb06464 100644 --- a/libbrux/NEWS +++ b/libbrux/NEWS @@ -1,5 +1,6 @@ $Id$ +2004-11-18: Fixed segfault in jedec_detect() (patch 970946, Ian Campbell). 2004-11-15: Added support for Intel 28F256J3A (patch 1012140, Jerome Debard). 2003-11-03: Fixed compile error in jedec_detect (bug 828313, Márton Németh). 2003-11-02: Added support for detecting flashes (detectflash) in full address range. diff --git a/libbrux/THANKS b/libbrux/THANKS index f88cb861..91260743 100644 --- a/libbrux/THANKS +++ b/libbrux/THANKS @@ -1,5 +1,6 @@ $Id$ +Ian Campbell Jerome Debard Bradley D. LaRonde Andreas Mohr diff --git a/libbrux/flash/jedec.c b/libbrux/flash/jedec.c index 735e82b6..d3e1f43c 100644 --- a/libbrux/flash/jedec.c +++ b/libbrux/flash/jedec.c @@ -35,10 +35,32 @@ int jedec_detect( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ) { + unsigned int bw; /* bus width */ + int ba; /* bus width address multiplier */ + bus_area_t area; int mid; int did; cfi_query_structure_t *cfi; + if (!cfi_array || !bus) + return -1; /* invalid parameters */ + + *cfi_array = calloc( 1, sizeof (cfi_array_t) ); + if (!*cfi_array) + return -2; /* out of memory */ + + (*cfi_array)->bus = bus; + (*cfi_array)->address = adr; + if (bus_area( bus, adr, &area ) != 0) + return -8; /* bus width detection failed */ + bw = area.width; + if (bw != 8 && bw != 16 && bw != 32) + return -3; /* invalid bus width */ + (*cfi_array)->bus_width = ba = bw / 8; + (*cfi_array)->cfi_chips = calloc( ba, sizeof (cfi_chip_t *) ); + if (!(*cfi_array)->cfi_chips) + return -2; /* out of memory */ + /* Query flash. */ bus_write( bus, 0x0, 0xf0 ); bus_write( bus, 0xaaa, 0xaa );