Added bus driver architecture.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@227 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent 54eb53c099
commit dadea18e33

@ -27,7 +27,7 @@ SUBDIRS = \
bin_PROGRAMS = jtag
jtag_SOURCES = jtag.c detect.c readmem.c detect.h pxa250.c pxa250.h sa1110.c sa1110.h flash.c
jtag_SOURCES = jtag.c detect.c readmem.c detect.h bus.h pxa250.c sa1110.c flash.c
jtag_DEPENDENCIES = tap/libtap.a part/libpart.a

@ -1,6 +1,7 @@
/*
* $Id$
*
* Bus driver interface
* Copyright (C) 2002 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
@ -22,17 +23,28 @@
*
*/
#ifndef PXA250_H
#define PXA250_H
#ifndef BUS_H
#define BUS_H
#include <stdint.h>
#include "part.h"
void pxa250_bus_read_start( parts *ps, uint32_t adr );
uint32_t pxa250_bus_read_next( parts *ps, uint32_t adr );
uint32_t pxa250_bus_read_end( parts *ps );
uint32_t pxa250_bus_read( parts *ps, uint32_t adr );
void pxa250_bus_write( parts *ps, uint32_t adr, uint32_t data );
typedef struct {
void (*bus_read_start)( parts *, uint32_t );
uint32_t (*bus_read_next)( parts *, uint32_t );
uint32_t (*bus_read_end)( parts * );
uint32_t (*bus_read)( parts *, uint32_t );
void (*bus_write)( parts *, uint32_t, uint32_t );
} bus_driver_t;
extern bus_driver_t *bus_driver;
#define bus_read_start bus_driver->bus_read_start
#define bus_read_next bus_driver->bus_read_next
#define bus_read_end bus_driver->bus_read_end
#define bus_read bus_driver->bus_read
#define bus_write bus_driver->bus_write
extern bus_driver_t sa1110_bus_driver;
extern bus_driver_t pxa250_bus_driver;
#endif /* PXA250_H */
#endif /* BUS_H */

@ -36,15 +36,7 @@
#include <flash/intel.h>
#include "part.h"
#include "sa1110.h"
#include "pxa250.h"
void (*bus_read_start)( parts *, uint32_t );
uint32_t (*bus_read_next)( parts *, uint32_t );
uint32_t (*bus_read_end)( parts * );
uint32_t (*bus_read)( parts *, uint32_t );
void (*bus_write)( parts *, uint32_t, uint32_t );
#include "bus.h"
int flash_erase_block( parts *ps, uint32_t adr );
int flash_unlock_block( parts *ps, uint32_t adr );
@ -67,20 +59,12 @@ flashmem( parts *ps, FILE *f )
if (strcmp( p->part, "SA1110" ) == 0) {
printf( "SA1110 detected\n" );
d = D_SA1110;
bus_read_start = sa1110_bus_read_start;
bus_read_next = sa1110_bus_read_next;
bus_read_end = sa1110_bus_read_end;
bus_read = sa1110_bus_read;
bus_write = sa1110_bus_write;
bus_driver = &sa1110_bus_driver;
}
if (strcmp( p->part, "PXA250" ) == 0) {
printf( "PXA250 detected\n" );
d = D_PXA250;
bus_read_start = pxa250_bus_read_start;
bus_read_next = pxa250_bus_read_next;
bus_read_end = pxa250_bus_read_end;
bus_read = pxa250_bus_read;
bus_write = pxa250_bus_write;
bus_driver = &pxa250_bus_driver;
}
if (!d) {

@ -25,8 +25,7 @@
#include <stdint.h>
#include "part.h"
#include "pxa250.h"
#include "bus.h"
/* PXA250 must be at position 0 in JTAG chain */
@ -170,3 +169,11 @@ pxa250_bus_write( parts *ps, uint32_t adr, uint32_t data )
part_set_signal( p, "nWE", 1, 1 );
parts_shift_data_registers( ps );
}
bus_driver_t pxa250_bus_driver = {
pxa250_bus_read_start,
pxa250_bus_read_next,
pxa250_bus_read_end,
pxa250_bus_read,
pxa250_bus_write
};

@ -38,15 +38,9 @@
#include <std/mic.h>
#include "part.h"
#include "bus.h"
#include "sa1110.h"
#include "pxa250.h"
void (*bus_read_start)( parts *, uint32_t );
uint32_t (*bus_read_next)( parts *, uint32_t );
uint32_t (*bus_read_end)( parts * );
uint32_t (*bus_read)( parts *, uint32_t );
void (*bus_write)( parts *, uint32_t, uint32_t );
bus_driver_t *bus_driver = NULL;
void
readmem( parts *ps )
@ -61,20 +55,12 @@ readmem( parts *ps )
if (strcmp( p->part, "SA1110" ) == 0) {
printf( "SA1110 detected\n" );
d = D_SA1110;
bus_read_start = sa1110_bus_read_start;
bus_read_next = sa1110_bus_read_next;
bus_read_end = sa1110_bus_read_end;
bus_read = sa1110_bus_read;
bus_write = sa1110_bus_write;
bus_driver = &sa1110_bus_driver;
}
if (strcmp( p->part, "PXA250" ) == 0) {
printf( "PXA250 detected\n" );
d = D_PXA250;
bus_read_start = pxa250_bus_read_start;
bus_read_next = pxa250_bus_read_next;
bus_read_end = pxa250_bus_read_end;
bus_read = pxa250_bus_read;
bus_write = pxa250_bus_write;
bus_driver = &pxa250_bus_driver;
}
if (!d) {

@ -25,8 +25,7 @@
#include <stdint.h>
#include "part.h"
#include "sa1110.h"
#include "bus.h"
/* SA1110 must be at position 0 in JTAG chain */
@ -168,3 +167,11 @@ sa1110_bus_write( parts *ps, uint32_t adr, uint32_t data )
part_set_signal( p, "nWE", 1, 1 );
parts_shift_data_registers( ps );
}
bus_driver_t sa1110_bus_driver = {
sa1110_bus_read_start,
sa1110_bus_read_next,
sa1110_bus_read_end,
sa1110_bus_read,
sa1110_bus_write
};

@ -1,38 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2002 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 Marcel Telka <marcel@telka.sk>, 2002.
*
*/
#ifndef SA1110_H
#define SA1110_H
#include <stdint.h>
#include "part.h"
void sa1110_bus_read_start( parts *ps, uint32_t adr );
uint32_t sa1110_bus_read_next( parts *ps, uint32_t adr );
uint32_t sa1110_bus_read_end( parts *ps );
uint32_t sa1110_bus_read( parts *ps, uint32_t adr );
void sa1110_bus_write( parts *ps, uint32_t adr, uint32_t data );
#endif /* SA1110_H */
Loading…
Cancel
Save