From 81de361cc59256295c58699ef10d984b1c9c7ee3 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Tue, 3 Jun 2003 05:57:24 +0000 Subject: [PATCH] 2003-06-03 Marcel Telka * src/cmd/Makefile.am (libcmd_a_SOURCES): Added peekpoke.c (patch 747447, Matan Ziv-Av). * src/cmd/cmd.c (cmds): Added peek and poke commands (patch 747447, Matan Ziv-Av). * src/cmd/peekpoke.c: New file (patch 747447, Matan Ziv-Av). * po/POTFILES.in: Updated. * include/bus.h (bus_t): Declaration moved to include module (brux/bus.h). * include/cfi.h (cfi_chip_t, cfi_array_t, cfi_array_free, detect_cfi): Declarations moved to include module (brux/cfi.h). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@456 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 11 ++++ jtag/NEWS | 1 + jtag/include/bus.h | 23 +------ jtag/include/cfi.h | 20 +----- jtag/po/POTFILES.in | 3 +- jtag/src/cmd/Makefile.am | 1 + jtag/src/cmd/cmd.c | 4 ++ jtag/src/cmd/peekpoke.c | 127 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 148 insertions(+), 42 deletions(-) create mode 100644 jtag/src/cmd/peekpoke.c diff --git a/jtag/ChangeLog b/jtag/ChangeLog index aeca2f1b..b1c96f08 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,14 @@ +2003-06-03 Marcel Telka + + * src/cmd/Makefile.am (libcmd_a_SOURCES): Added peekpoke.c (patch 747447, Matan Ziv-Av). + * src/cmd/cmd.c (cmds): Added peek and poke commands (patch 747447, Matan Ziv-Av). + * src/cmd/peekpoke.c: New file (patch 747447, Matan Ziv-Av). + * po/POTFILES.in: Updated. + + * include/bus.h (bus_t): Declaration moved to include module (brux/bus.h). + * include/cfi.h (cfi_chip_t, cfi_array_t, cfi_array_free, detect_cfi): Declarations moved + to include module (brux/cfi.h). + 2003-06-02 Marcel Telka * Makefile.am (SUBDIRS): Added libbrux. diff --git a/jtag/NEWS b/jtag/NEWS index b8ab2331..3d9223dd 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -1,6 +1,7 @@ $Id$ * Fixed bug with SELECT, AUTOFD, and STROBE signals handling (bug 745824). + * Added new commands 'peek' and 'poke' (patch 747447, Matan Ziv-Av). jtag-0.4 (2003-05-29): diff --git a/jtag/include/bus.h b/jtag/include/bus.h index 011cbcac..d1c2b241 100644 --- a/jtag/include/bus.h +++ b/jtag/include/bus.h @@ -29,28 +29,7 @@ #include #include "chain.h" -typedef struct bus bus_t; - -struct bus { - void *params; - void (*prepare)( bus_t *bus ); - int (*width)( bus_t *bus, uint32_t adr ); - void (*read_start)( bus_t *bus, uint32_t adr ); - uint32_t (*read_next)( bus_t *bus, uint32_t adr ); - uint32_t (*read_end)( bus_t *bus ); - uint32_t (*read)( bus_t *bus, uint32_t adr ); - void (*write)( bus_t *bus, uint32_t adr, uint32_t data ); - void (*free)( bus_t *bus ); -}; - -#define bus_prepare(bus) bus->prepare(bus) -#define bus_width(bus,adr) bus->width(bus,adr) -#define bus_read_start(bus,adr) bus->read_start(bus,adr) -#define bus_read_next(bus,adr) bus->read_next(bus,adr) -#define bus_read_end(bus) bus->read_end(bus) -#define bus_read(bus,adr) bus->read(bus,adr) -#define bus_write(bus,adr,data) bus->write(bus,adr,data) -#define bus_free(bus) bus->free(bus) +#include bus_t *new_sa1110_bus( chain_t *chain, int pn ); bus_t *new_pxa250_bus( chain_t *chain, int pn ); diff --git a/jtag/include/cfi.h b/jtag/include/cfi.h index 58894764..42db3159 100644 --- a/jtag/include/cfi.h +++ b/jtag/include/cfi.h @@ -25,24 +25,8 @@ #ifndef CFI_H #define CFI_H -#include -#include +#include -#include "bus.h" - -typedef struct { - int width; /* 1 for 8 bits, 2 for 16 bits, 4 for 32 bits, etc. */ - cfi_query_structure_t cfi; -} cfi_chip_t; - -typedef struct { - bus_t *bus; - uint32_t address; - int bus_width; /* in cfi_chips, e.g. 4 for 32 bits */ - cfi_chip_t **cfi_chips; -} cfi_array_t; - -void cfi_array_free( cfi_array_t *cfi_array ); -int detect_cfi( bus_t *bus, uint32_t adr, cfi_array_t **cfi_array ); +#define detect_cfi cfi_detect #endif /* CFI_H */ diff --git a/jtag/po/POTFILES.in b/jtag/po/POTFILES.in index 6fc7e1b0..c6acd13e 100644 --- a/jtag/po/POTFILES.in +++ b/jtag/po/POTFILES.in @@ -16,6 +16,7 @@ src/cmd/frequency.c src/cmd/get.c src/cmd/help.c src/cmd/instruction.c +src/cmd/peekpoke.c src/cmd/print.c src/cmd/quit.c src/cmd/readmem.c @@ -24,9 +25,7 @@ src/cmd/set.c src/cmd/shift.c src/detect.c src/discovery.c -src/flash/amd.c src/flash.c -src/flash/intel.c src/jtag.c src/part/data_register.c src/part/instruction.c diff --git a/jtag/src/cmd/Makefile.am b/jtag/src/cmd/Makefile.am index 39306ab4..1b83e837 100644 --- a/jtag/src/cmd/Makefile.am +++ b/jtag/src/cmd/Makefile.am @@ -40,6 +40,7 @@ libcmd_a_SOURCES = \ get.c \ set.c \ endian.c \ + peekpoke.c \ readmem.c \ detectflash.c \ flashmem.c \ diff --git a/jtag/src/cmd/cmd.c b/jtag/src/cmd/cmd.c index 884fd3f6..d37a8b3c 100644 --- a/jtag/src/cmd/cmd.c +++ b/jtag/src/cmd/cmd.c @@ -44,6 +44,8 @@ extern cmd_t cmd_dr; extern cmd_t cmd_get; extern cmd_t cmd_set; extern cmd_t cmd_endian; +extern cmd_t cmd_peek; +extern cmd_t cmd_poke; extern cmd_t cmd_readmem; extern cmd_t cmd_detectflash; extern cmd_t cmd_flashmem; @@ -63,6 +65,8 @@ const cmd_t *cmds[] = { &cmd_get, &cmd_set, &cmd_endian, + &cmd_peek, + &cmd_poke, &cmd_readmem, &cmd_detectflash, &cmd_flashmem, diff --git a/jtag/src/cmd/peekpoke.c b/jtag/src/cmd/peekpoke.c new file mode 100644 index 00000000..0335fb77 --- /dev/null +++ b/jtag/src/cmd/peekpoke.c @@ -0,0 +1,127 @@ +/* + * $Id$ + * + * Copyright (C) 2003 ETC s.r.o. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Matan Ziv-Av , 2003. + * + */ + +#include + +#include +#include + +#include "jtag.h" + +#include "cmd.h" + +static int +cmd_peek_run( char *params[] ) +{ + uint32_t adr, val; + + if (cmd_params( params ) != 2) + return -1; + + if (!cmd_test_cable()) + return 1; + + if (!bus) { + printf( _("Error: Bus driver missing.\n") ); + return 1; + } + + if (cmd_get_number( params[1], &adr )) + return -1; + + bus_prepare( bus ); + val = bus_read( bus, adr ); + + printf( _("bus_read(0x%08x) = 0x%08X (%i)\n"), adr, val, val ); + + return 1; +} + +static void +cmd_peek_help( void ) +{ + printf( _( + "Usage: %s ADDR\n" + "Read a single word (bus width size).\n" + "\n" + "ADDR address to read from\n" + "\n" + "ADDR could be in decimal or hexadecimal (prefixed with 0x) form.\n" + "\n" + ), "peek" ); +} + +cmd_t cmd_peek = { + "peek", + N_("read a single word"), + cmd_peek_help, + cmd_peek_run +}; + +static int +cmd_poke_run( char *params[] ) +{ + uint32_t adr, val; + + if (cmd_params( params ) != 3) + return -1; + + if (!cmd_test_cable()) + return 1; + + if (!bus) { + printf( _("Error: Bus driver missing.\n") ); + return 1; + } + + if (cmd_get_number( params[1], &adr ) || cmd_get_number( params[2], &val )) + return -1; + + bus_prepare( bus ); + bus_write( bus, adr, val ); + + return 1; +} + +static void +cmd_poke_help( void ) +{ + printf( _( + "Usage: %s ADDR VAL\n" + "Write a single word (bus width size).\n" + "\n" + "ADDR address to write\n" + "VAL value to write\n" + "\n" + "ADDR and VAL could be in decimal or hexadecimal (prefixed with 0x) form.\n" + "\n" + ), "poke" ); +} + +cmd_t cmd_poke = { + "poke", + N_("write a single word"), + cmd_poke_help, + cmd_poke_run +};