From d3c480487f5b57f4a3326b4a2bc4c6aec1669f98 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Thu, 28 Aug 2003 07:26:03 +0000 Subject: [PATCH] 2003-08-28 Marcel Telka * src/readmem.c (readmem): Replaced bus_width macro with new bus_area. * src/bus/bcm1250.c (bcm1250_bus_width): Function removed. (bcm1250_bus_area): New function. * src/bus/ixp425.c (ixp425_bus_width): Function removed. (ixp425_bus_area): New function. * src/bus/pxa2x0.c (pxa250_bus_width): Function removed. (pxa2x0_bus_area): New function. * src/bus/s3c4510x.c (s3c4510_bus_width): Function removed. (s3c4510_bus_area): New function. * src/bus/sa1110.c (sa1110_bus_width: Function removed. (sa1110_bus_area): New function. * src/bus/sh7727.c (sh7727_bus_width): Function removed. (sh7727_bus_area): New function. * src/bus/sh7750r.c (sh7750r_bus_width): Function removed. (sh7750r_bus_area): New function. * src/bus/sh7751r.c (sh7751r_bus_width): Function removed. (sh7751r_bus_area): New function. * src/cmd/print.c (cmd_print_run): Added bus area printing. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@551 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 23 ++++++++++++++- jtag/src/bus/bcm1250.c | 13 ++++++--- jtag/src/bus/ixp425.c | 13 ++++++--- jtag/src/bus/pxa2x0.c | 62 ++++++++++++++++++++++++++--------------- jtag/src/bus/s3c4510x.c | 50 ++++++++++++++++++++++++--------- jtag/src/bus/sa1110.c | 13 ++++++--- jtag/src/bus/sh7727.c | 22 ++++++++++----- jtag/src/bus/sh7750r.c | 13 ++++++--- jtag/src/bus/sh7751r.c | 13 ++++++--- jtag/src/cmd/print.c | 30 ++++++++++++++++++-- jtag/src/readmem.c | 7 ++++- 11 files changed, 192 insertions(+), 67 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index d7215d9f..bc4f4069 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,4 +1,25 @@ -2003-08-26 Marcel Telka +2003-08-28 Marcel Telka + + * src/readmem.c (readmem): Replaced bus_width macro with new bus_area. + * src/bus/bcm1250.c (bcm1250_bus_width): Function removed. + (bcm1250_bus_area): New function. + * src/bus/ixp425.c (ixp425_bus_width): Function removed. + (ixp425_bus_area): New function. + * src/bus/pxa2x0.c (pxa250_bus_width): Function removed. + (pxa2x0_bus_area): New function. + * src/bus/s3c4510x.c (s3c4510_bus_width): Function removed. + (s3c4510_bus_area): New function. + * src/bus/sa1110.c (sa1110_bus_width: Function removed. + (sa1110_bus_area): New function. + * src/bus/sh7727.c (sh7727_bus_width): Function removed. + (sh7727_bus_area): New function. + * src/bus/sh7750r.c (sh7750r_bus_width): Function removed. + (sh7750r_bus_area): New function. + * src/bus/sh7751r.c (sh7751r_bus_width): Function removed. + (sh7751r_bus_area): New function. + * src/cmd/print.c (cmd_print_run): Added bus area printing. + +2003-08-27 Marcel Telka * include/flash.h: Removed CFI_INTEL_ERROR_* macros. diff --git a/jtag/src/bus/bcm1250.c b/jtag/src/bus/bcm1250.c index bf44f41e..7db7305f 100644 --- a/jtag/src/bus/bcm1250.c +++ b/jtag/src/bus/bcm1250.c @@ -241,10 +241,15 @@ bcm1250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) { #endif -static unsigned int -bcm1250_bus_width( bus_t *bus, uint32_t addr) +static int +bcm1250_bus_area( bus_t *bus, uint32_t addr, bus_area_t *area ) { - return 8; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 8; + + return 0; } static void @@ -265,7 +270,7 @@ static const bus_t bcm1250_bus = { NULL, bcm1250_bus_printinfo, bcm1250_bus_prepare, - bcm1250_bus_width, + bcm1250_bus_area, bcm1250_bus_read_start, bcm1250_bus_read_next, bcm1250_bus_read_end, diff --git a/jtag/src/bus/ixp425.c b/jtag/src/bus/ixp425.c index 5fc57fb5..c772d3e4 100644 --- a/jtag/src/bus/ixp425.c +++ b/jtag/src/bus/ixp425.c @@ -211,10 +211,15 @@ ixp425_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -ixp425_bus_width( bus_t *bus, uint32_t adr ) +static int +ixp425_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - return 16; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; } static void @@ -229,7 +234,7 @@ static const bus_t ixp425_bus = { NULL, ixp425_bus_printinfo, ixp425_bus_prepare, - ixp425_bus_width, + ixp425_bus_area, ixp425_bus_read_start, ixp425_bus_read_next, ixp425_bus_read_end, diff --git a/jtag/src/bus/pxa2x0.c b/jtag/src/bus/pxa2x0.c index 8a521d3a..0386a406 100644 --- a/jtag/src/bus/pxa2x0.c +++ b/jtag/src/bus/pxa2x0.c @@ -230,30 +230,46 @@ pxa250_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -pxa250_bus_width( bus_t *bus, uint32_t adr ) +static int +pxa2x0_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - if (adr >= 0x04000000) - return 32; - - /* see Table 6-36. in [1] */ - switch (get_BOOT_DEF_BOOT_SEL(BOOT_DEF)) { - case 0: - return 32; - case 1: - return 16; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - printf( "TODO - BOOT_SEL: %d\n", get_BOOT_DEF_BOOT_SEL(BOOT_DEF) ); - return 0; - default: - printf( "BUG in code, file %s, line %d.\n", __FILE__, __LINE__ ); - return 0; + /* Static Chip Select 0 (64 MB) */ + if (adr < UINT32_C(0x04000000)) { + area->description = N_("Static Chip Select 0"); + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x04000000); + + /* see Table 6-36. in [1] */ + switch (get_BOOT_DEF_BOOT_SEL(BOOT_DEF)) { + case 0: + area->width = 32; + break; + case 1: + area->width = 16; + break; + case 2: + case 3: + area->width = 0; + break; + case 4: + case 5: + case 6: + case 7: + printf( "TODO - BOOT_SEL: %d\n", get_BOOT_DEF_BOOT_SEL(BOOT_DEF) ); + return -1; + default: + printf( "BUG in the code, file %s, line %d.\n", __FILE__, __LINE__ ); + return -1; + } + return 0; } + + area->description = NULL; + area->start = UINT32_C(0x04000000); + area->length = UINT64_C(0xFC000000); + area->width = 0; + + return 0; } static void @@ -267,7 +283,7 @@ static const bus_t pxa250_bus = { NULL, pxa2x0_bus_printinfo, pxa250_bus_prepare, - pxa250_bus_width, + pxa2x0_bus_area, pxa250_bus_read_start, pxa250_bus_read_next, pxa250_bus_read_end, diff --git a/jtag/src/bus/s3c4510x.c b/jtag/src/bus/s3c4510x.c index 59123687..549ad9ce 100644 --- a/jtag/src/bus/s3c4510x.c +++ b/jtag/src/bus/s3c4510x.c @@ -36,7 +36,7 @@ ** - This bus driver is coded basing on S3C4510B. ** However, Samsung do NOT giving a special JTAG ID-Code for this chip. ** - Data Bus width is detected by B0SIZE[0:1]; -** the bus parameter is defined as 32-bis, but actually controlled by +** the bus parameter is defined as 32-bit, but actually controlled by ** @ref dbus_width. Make sure that B0SIZE[0:1] is welded correct. ** Otherwise, you must modify @ref s3c4510_bus_width(). ** - ROM/Flash is selected by nRCS[5:0], now suppose only nRCS0. @@ -253,29 +253,31 @@ s3c4510_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) } static int -s3c4510_bus_width( bus_t *bus, uint32_t adr ) +s3c4510_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { int b0size0, b0size1; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + b0size0 = part_get_signal( PART, part_find_signal( PART, "B0SIZE0" )); b0size1 = part_get_signal( PART, part_find_signal( PART, "B0SIZE1" )); switch ((b0size1 << 1) | b0size0) { case 1: - printf( "B0SIZE[1:0]: 01, 8 bits\n" ); - dbus_width = 8; - return 8; + area->width = dbus_width = 8; + return 0; case 2: - printf( "B0SIZE[1:0]: 10, 16 bits\n" ); - dbus_width = 16; - return 16; + area->width = dbus_width = 16; + return 0; case 3: - printf( "B0SIZE[1:0]: 11, 32 bits\n" ); - dbus_width = 32; - return 32; + area->width = dbus_width = 32; + return 0; default: printf( "B0SIZE[1:0]: Unknown\n" ); - return 0; + area->width = 0; + return -1; } } @@ -290,7 +292,7 @@ static const bus_t s3c4510_bus = { NULL, s3c4510_bus_printinfo, s3c4510_bus_prepare, - s3c4510_bus_width, + s3c4510_bus_area, s3c4510_bus_read_start, s3c4510_bus_read_next, s3c4510_bus_read_end, @@ -381,6 +383,28 @@ new_s3c4510_bus( chain_t *chain, int pn ) ** ** CVS Log ** $Log$ +** Revision 1.3 2003/08/28 07:26:02 telka +** 2003-08-28 Marcel Telka +** +** * src/readmem.c (readmem): Replaced bus_width macro with new bus_area. +** * src/bus/bcm1250.c (bcm1250_bus_width): Function removed. +** (bcm1250_bus_area): New function. +** * src/bus/ixp425.c (ixp425_bus_width): Function removed. +** (ixp425_bus_area): New function. +** * src/bus/pxa2x0.c (pxa250_bus_width): Function removed. +** (pxa2x0_bus_area): New function. +** * src/bus/s3c4510x.c (s3c4510_bus_width): Function removed. +** (s3c4510_bus_area): New function. +** * src/bus/sa1110.c (sa1110_bus_width: Function removed. +** (sa1110_bus_area): New function. +** * src/bus/sh7727.c (sh7727_bus_width): Function removed. +** (sh7727_bus_area): New function. +** * src/bus/sh7750r.c (sh7750r_bus_width): Function removed. +** (sh7750r_bus_area): New function. +** * src/bus/sh7751r.c (sh7751r_bus_width): Function removed. +** (sh7751r_bus_area): New function. +** * src/cmd/print.c (cmd_print_run): Added bus area printing. +** ** Revision 1.2 2003/08/19 09:59:26 telka ** 2003-08-19 Marcel Telka ** diff --git a/jtag/src/bus/sa1110.c b/jtag/src/bus/sa1110.c index f69eeec4..60784b1d 100644 --- a/jtag/src/bus/sa1110.c +++ b/jtag/src/bus/sa1110.c @@ -211,10 +211,15 @@ sa1110_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -sa1110_bus_width( bus_t *bus, uint32_t adr ) +static int +sa1110_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - return part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = part_get_signal( PART, part_find_signal( PART, "ROM_SEL" ) ) ? 32 : 16; + + return 0; } static void @@ -228,7 +233,7 @@ static const bus_t sa1110_bus = { NULL, sa1110_bus_printinfo, sa1110_bus_prepare, - sa1110_bus_width, + sa1110_bus_area, sa1110_bus_read_start, sa1110_bus_read_next, sa1110_bus_read_end, diff --git a/jtag/src/bus/sh7727.c b/jtag/src/bus/sh7727.c index 8e90eea1..3c241dfc 100644 --- a/jtag/src/bus/sh7727.c +++ b/jtag/src/bus/sh7727.c @@ -228,21 +228,29 @@ sh7727_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -sh7727_bus_width( bus_t *bus, uint32_t adr ) +static int +sh7727_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { part_t *p = PART; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + switch (part_get_signal( p, MD4 ) << 1 | part_get_signal( p, MD3 )) { case 1: - return 8; + area->width = 8; + return 0; case 2: - return 16; + area->width = 16; + return 0; case 3: - return 32; + area->width = 32; + return 0; default: printf( _("Error: Invalid bus width (MD3 = MD4 = 0)!\n") ); - return 0; + area->width = 0; + return -1; } } @@ -257,7 +265,7 @@ static const bus_t sh7727_bus = { NULL, sh7727_bus_printinfo, sh7727_bus_prepare, - sh7727_bus_width, + sh7727_bus_area, sh7727_bus_read_start, sh7727_bus_read_next, sh7727_bus_read_end, diff --git a/jtag/src/bus/sh7750r.c b/jtag/src/bus/sh7750r.c index 68675b73..e7ad330d 100644 --- a/jtag/src/bus/sh7750r.c +++ b/jtag/src/bus/sh7750r.c @@ -239,10 +239,15 @@ sh7750r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -sh7750r_bus_width( bus_t *bus, uint32_t adr ) +static int +sh7750r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - return 32; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 32; + + return 0; } static void @@ -256,7 +261,7 @@ static const bus_t sh7750r_bus = { NULL, sh7750r_bus_printinfo, sh7750r_bus_prepare, - sh7750r_bus_width, + sh7750r_bus_area, sh7750r_bus_read_start, sh7750r_bus_read_next, sh7750r_bus_read_end, diff --git a/jtag/src/bus/sh7751r.c b/jtag/src/bus/sh7751r.c index 211c490f..8a95960d 100644 --- a/jtag/src/bus/sh7751r.c +++ b/jtag/src/bus/sh7751r.c @@ -232,10 +232,15 @@ sh7751r_bus_write( bus_t *bus, uint32_t adr, uint32_t data ) chain_shift_data_registers( chain, 0 ); } -static unsigned int -sh7751r_bus_width( bus_t *bus, uint32_t adr ) +static int +sh7751r_bus_area( bus_t *bus, uint32_t adr, bus_area_t *area ) { - return 16; + area->description = NULL; + area->start = UINT32_C(0x00000000); + area->length = UINT64_C(0x100000000); + area->width = 16; + + return 0; } static void @@ -249,7 +254,7 @@ static const bus_t sh7751r_bus = { NULL, sh7751r_bus_printinfo, sh7751r_bus_prepare, - sh7751r_bus_width, + sh7751r_bus_area, sh7751r_bus_read_start, sh7751r_bus_read_next, sh7751r_bus_read_end, diff --git a/jtag/src/cmd/print.c b/jtag/src/cmd/print.c index 8d685fe6..57eadbaa 100644 --- a/jtag/src/cmd/print.c +++ b/jtag/src/cmd/print.c @@ -82,6 +82,31 @@ cmd_print_run( char *params[] ) printf( _(" %3d "), chain->active_part ); part_print( chain->parts->parts[chain->active_part] ); } + if (bus != NULL) { + int i; + uint64_t a; + bus_area_t area; + + for (i = 0; i < buses.len; i++) + if (buses.buses[i] == bus) + break; + printf( _("\nActive bus:\n*%d: "), i ); + bus_printinfo( bus ); + + for (a = 0; a < UINT64_C(0x100000000); a = area.start + area.length) { + if (bus_area( bus, a, &area ) != 0) { + printf( _("Error in bus area discovery at 0x%08llX\n"), a ); + break; + } + if (area.width != 0) { + if (area.description != NULL) + printf( _("\tstart: 0x%08X, length: 0x%08llX, data width: %d bit, (%s)\n"), area.start, area.length, area.width, _(area.description) ); + else + printf( _("\tstart: 0x%08X, length: 0x%08llX, data width: %d bit\n"), area.start, area.length, area.width ); + } + } + } + return 1; } @@ -92,8 +117,9 @@ cmd_print_run( char *params[] ) for (i = 0; i < buses.len; i++) { if (buses.buses[i] == bus) - printf( _("*") ); - printf( _("%d: "), i ); + printf( _("*%d: "), i ); + else + printf( _("%d: "), i ); bus_printinfo( buses.buses[i] ); } diff --git a/jtag/src/readmem.c b/jtag/src/readmem.c index fa055e8b..7fce7f3b 100644 --- a/jtag/src/readmem.c +++ b/jtag/src/readmem.c @@ -48,6 +48,7 @@ readmem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len ) int bc = 0; #define BSIZE 4096 uint8_t b[BSIZE]; + bus_area_t area; if (!bus) { printf( _("Error: Missing bus driver!\n") ); @@ -56,7 +57,11 @@ readmem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len ) bus_prepare( bus ); - step = bus_width( bus, 0 ) / 8; + if (bus_area( bus, 0, &area ) != 0) { + printf( _("Error: Bus width detection failed\n") ); + return; + } + step = area.width / 8; if (step == 0) { printf( _("Unknown bus width!\n") );