Update of /cvsroot/blob/blob/src/commands
In directory usw-pr-cvs1:/tmp/cvs-serv23725
Modified Files:
Makefile.am
Added Files:
call.c changebit.c chkmem.c cmddebug.h common.c common.h
dump.c memcpy.c peek.c poke.c regs-sa11x0.c
Log Message:
- added basic commands from diag and blob
- each command got its own source file, so blob/diag
size will not blown up when cherry-picking commands
- commands have to be removed from blob and diag in order
to take full advantage from this
--- NEW FILE: call.c ---
/*
* debug.c: Debugging command functions
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
* Copyright (C) 2001 Christopher Hoover <ch...@hp...>
*
* 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
*
*/
#ident "$Id: call.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/*********************************************************************
* Call
*
* AUTHOR: Christopher Hoover <ch...@hp...>
* REVISED: seletz
*
* Jumps to an arbitrary address.
*
*/
static int Call( int argc, char *argv[] )
{
int ret = 0;
u32 adr, a = 0, b = 0, c = 0, d = 0;
int (*called_fn)(u32, u32, u32, u32);
if ( argc < 2 || argc > 6 ) ERR( -EINVAL );
ret = strtou32( argv[1], &adr );
if ( ret < 0 ) ERR( -EINVAL );
if ( argc >= 3 ) {
ret = strtou32( argv[2], &a );
if ( ret < 0 ) ERR( -EINVAL );
}
if ( argc >= 4 ) {
ret = strtou32( argv[2], &b );
if ( ret < 0 ) ERR( -EINVAL );
}
if ( argc >= 5 ) {
ret = strtou32( argv[2], &c );
if ( ret < 0 ) ERR( -EINVAL );
}
if ( argc >= 6) {
ret = strtou32( argv[2], &d );
if ( ret < 0 ) ERR( -EINVAL );
}
printf( "Calling function at address 0x%08lx ...\n", adr );
serial_flush_output();
called_fn = (int (*)(u32, u32, u32, u32))adr;
ret = called_fn(a, b, c, d);
printf( "Return value: %d == 0x%04x\n", ret, ret );
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char callhelp[] = "call address [arg0 [arg1 [arg2 [arg3]]]]\n"
"Call function at <address> with optional arguments\n";
__commandlist(Call, "call", callhelp);
--- NEW FILE: changebit.c ---
/*
* debug.c: Debugging command functions
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: changebit.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
#define MEM( x ) (*((u32 *)x))
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/*********************************************************************
* ChangeBit
*
* AUTOR: SELETZ
* REVISED:
*
* Modifies bits of an given memory location
*
*/
static int ChangeBit( int argc, char *argv[] )
{
int ret = 0;
u32 adr = 0L;
u32 value = 0L;
if ( argc < 4 ) ERR( -EINVAL );
ret = strtou32( argv[1], &adr );
if ( ret < 0 ) ERR( -EINVAL );
ret = strtou32( argv[2], &value );
if ( ret < 0 ) ERR( -EINVAL );
/* check memory alignment */
if(adr &= 0x03)
ERR(-EALIGN);
printf( "0x%08lx", MEM( adr ) );
switch ( argv[3][0] & (~0x20) ) {
case 'A':
MEM( adr ) &= value;
break;
case 'S':
case 'O':
MEM( adr ) |= value;
break;
case 'X':
MEM( adr ) ^= value;
break;
case 'C':
MEM( adr ) &= ~value;
break;
default:
ERR( -EINVAL );
break;
}
printf( "-> 0x%08lx\n", MEM( adr ) );
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char chgbithelp[] = "chgbit address value {and|or|xor|set|clear}\n";
__commandlist(ChangeBit, "chgbit", chgbithelp );
--- NEW FILE: chkmem.c ---
/*
* chkmem.c: Utility to test memory integrity
*
* Charles Cazabon <me...@di...>
*
* Copyright © 1999 Simon Kirby.
* Version 2 Copyright © 1999 Charles Cazabon.
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: chkmem.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/arch.h>
#include <blob/command.h>
#include <blob/types.h>
#include <blob/serial.h>
#include <blob/time.h>
#include <blob/util.h>
#include <blob/memory.h>
/*********************************************************************/
/** DEFINES *********************************************************/
/*********************************************************************/
/* define this to 1 for debug */
#define CHKMEM_DEBUG 1
/* show every X bytes of memory during test */
#define CHKMEM_SHOWEVERY (1<<14)
/* more readable IMHO */
#define MEM( x ) (*((u32 *)x))
#define MAKE32FROM8(x) (u32) ((x) | ((x) << 8) | ((x) << 16) | ((x) << 24))
#define CHKMEM_ERR (-1)
#define CHKMEM_OK (0)
#if CHKMEM_DEBUG
# define SHOWFUNC() SerialOutputString("chkmem: method: "__FUNCTION__ "\n" ); \
SerialOutputString(" p1=0x"); \
SerialOutputHex((u32)bp1); \
SerialOutputString(" p2=0x"); \
SerialOutputHex((u32)bp2); \
SerialOutputString(" count=0x"); \
SerialOutputHex((u32)count); \
SerialOutputString("\n");
#else
# define SHOWFUNC() SerialOutputString("chkmem: method: "__FUNCTION__ "\n" );
#endif
#define SKIPBLOBMEM(x) if ((x) < BLOB_RAM_BASE + 0x00100000) x = BLOB_RAM_BASE + 0x00100000
#define CHKMEM_MAXERR 64
#define CHKMEM_PUSHERR( ADR ) { chkmem_errlist[ chkmem_errs % CHKMEM_MAXERR ] = ADR; \
chkmem_errs++; }
/*********************************************************************/
/** MODULE GLOBALS *************************************************/
/*********************************************************************/
static u32 showevery;
/* list of failed adresses */
static u32 chkmem_errlist[ CHKMEM_MAXERR ];
static int chkmem_errs;
/*********************************************************************/
/** TYPES *********************************************************/
/*********************************************************************/
typedef int (*memtestfunc_t)( u32, u32, u32, u32 *);
/*********************************************************************/
/** FORWARDS *******************************************************/
/*********************************************************************/
static int ChkMemErr( void );
static int ChkMemMovInv( u32 start, u32 end, u32 pattern, u32 *badadr );
static int ChkMemAdrTst( u32 start, u32 end, u32 pattern, u32 *badadr );
static int ChkMemHardcore( u32 start, u32 end, u32 pattern, u32 *badadr );
static void showrun( u32 run );
static void showadr( volatile u32 *adr );
/* Charles Cazabon test methods */
static int test_or_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_and_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_seqinc_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_checkerboard_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_solidbits_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_blockseq_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_walkbits_comparison (u32 *bp1, u32 *bp2, u32 count, int mode);
static int test_bitspread_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_bitflip_comparison (u32 *bp1, u32 *bp2, u32 count);
static int test_stuck_address (u32 *bp1, u32 *bp2, u32 count);
/*********************************************************************/
/** EXPORTED FUNCTIONS ***********************************************/
/*********************************************************************/
/*********************************************************************
* ChkMem
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Command entry, memory test method dispatcher
*
*/
int ChkMem( int argc, char *argv[] )
{
memtestfunc_t method;
int area;
u32 start = 0L;
u32 end = 0L;
u32 badaddr = 0L;
u32 repcount = 0L;
/* check args */
if ( argc < 2 ) {
SerialOutputString("*** not enough arguments\n");
return CHKMEM_ERR;
}
/* reset error counter */
chkmem_errs = 0;
/* get verbosity level */
showevery = CHKMEM_SHOWEVERY;
if ( argc > 2 ) {
if(strtou32(argv[2], &showevery) < 0) {
SerialOutputString("*** not a value\n");
return CHKMEM_ERR;
}
if ( showevery > 0 ) {
showevery = 1<<showevery;
} else {
/* never show address */
showevery = 0xffffffff;
}
}
/* get repeat count */
repcount = 1;
if ( argc > 3 ) {
if ( strtou32(argv[3], &repcount ) < 0 ) {
SerialOutputString("*** not a value\n");
return CHKMEM_ERR;
}
}
SerialOutputString(argv[0]);
SerialOutputString(": display every 0x");
SerialOutputHex(showevery);
SerialOutputString(" bytes\n");
/* set memory test method */
switch ( *argv[1] ) {
case '0':
method = ChkMemMovInv;
break;
case '1':
method = ChkMemAdrTst;
break;
case '2':
method = ChkMemHardcore;
break;
default:
SerialOutputString("*** unknown method\n");
return CHKMEM_ERR;
break;
}
while ( repcount-- ) {
/* test all known memory areas */
for (area = 0; area < NUM_MEM_AREAS; area++) {
if(memory_map[area].used) {
start = memory_map[area].start;
end = start + memory_map[area].len;
if ( method(start, end, 0x5555aaaa, &badaddr) != CHKMEM_OK ) {
CHKMEM_PUSHERR( badaddr );
}
}
}
}
if ( chkmem_errs == 0 ) {
SerialOutputString("\n*** no error found\n");
} else {
ChkMemErr();
}
return CHKMEM_OK;
}
static char chkmemhelp[] = "chkmem [method] {verbosity:1..F} {repeat-count}\n"
"method=0: move-inverse test\n"
"method=1: address test\n"
"method=2: hardcore test\n"
"verbosity: display every 2^n address during test\n";
__commandlist(ChkMem, "chkmem", chkmemhelp);
/*********************************************************************/
/** STATIC FUNCTIONS ************************************************/
/*********************************************************************/
/*********************************************************************
* showrun
*
* AUTOR: SELETZ
* REVISED:
*
* Shows current memory test run
*
*/
static void showrun( u32 run )
{
SerialOutputString( "\r\nrun " );
SerialOutputHex( run );
SerialOutputString( "\n" );
}
/*********************************************************************
* showadr
*
* AUTOR: SELETZ
* REVISED:
*
* display <adr> every <showevery> bytes.
*
*/
static void showadr( volatile u32 *adr )
{
if ( ((u32)adr) % showevery == 0 ) {
SerialOutputString("\r");
SerialOutputHex( (u32)adr );
}
}
/*********************************************************************
* ChkMemErr
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Reports memory check errors
*
*/
static int ChkMemErr( void )
{
int i;
SerialOutputString("\n*** memory errors:\n");
for ( i=0; i< chkmem_errs % CHKMEM_MAXERR; i++ ) {
SerialOutputHex( i );
SerialOutputString(": 0x");
SerialOutputHex(chkmem_errlist[i]);
SerialOutputString("\n");
}
return CHKMEM_OK;
}
/*********************************************************************
* ChkMemMovInv
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Moving-Inverse Memory Test
*
* Test method (from GNU/memtest86 utility):
* 1) Fill memory with a pattern
* 2) Starting at the lowest address
* 2a check that the pattern has not changed
* 2b write the patterns complement
* 2c increment the address
* repeat 2a - 2c
* 3) Starting at the highest address
* 3a check that the pattern has not changed
* 3b write the patterns complement
* 3c decrement the address
* repeat 3a - 3c
*
* returns 1 if memory failure, returns failed
* address in badadr
*
*/
static int ChkMemMovInv( u32 start, u32 end, u32 pattern, u32 *badadr )
{
int ret = 1;
register u32 p;
register u32 tst;
SerialOutputString("\nchkmem: move-inverse method\n");
SKIPBLOBMEM( start );
#if CHKMEM_DEBUG
SerialOutputString("ChkMem: start(0x");
SerialOutputHex(start);
SerialOutputString(") - end(0x");
SerialOutputHex(end);
SerialOutputString(")\n");
#endif
#if CHKMEM_DEBUG
SerialOutputString("ChkMem: fillup\n");
#endif
/* fill mem with pattern */
p=start;
while ( p<end ) {
MEM( p ) = pattern;
barrier();
p += 4;
}
#if CHKMEM_DEBUG
SerialOutputString("\rChkMem: bottom-up\n");
#endif
/* bottom-up test */
p=start;
while ( p<end ) {
showadr( (u32*)p );
tst = MEM( p );
if ( tst != pattern ) {
goto DONE;
}
MEM( p ) = ~pattern;
barrier();
p += 4;
}
pattern = ~pattern;
#if CHKMEM_DEBUG
SerialOutputString("\rChkMem: top-down\n");
#endif
/* top-down test */
p=end-4;
while ( p>=start ) {
showadr( (u32*)p );
tst = MEM( p );
if ( tst != pattern ) {
goto DONE;
}
MEM( p ) = ~pattern;
barrier();
p -= 4;
}
/* no error if we reach this point */
ret = 0;
DONE:
if ( ret != 0 && badadr ) {
*badadr = p;
}
return ret;
}
/*********************************************************************
* ChkMemAdrTst
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Writes every memory location with its adress, then checks address
*
* returns 1 if memory failure, returns failed
* address in badadr
*
*/
static int ChkMemAdrTst( u32 start, u32 end, u32 pattern, u32 *badadr )
{
int ret = 1;
register u32 p;
register u32 tst;
SerialOutputString("\nchkmem: address test method\n");
SKIPBLOBMEM( start );
#if CHKMEM_DEBUG
SerialOutputString("ChkMem: start(0x");
SerialOutputHex(start);
SerialOutputString(") - end(0x");
SerialOutputHex(end);
SerialOutputString(")\n");
#endif
#if CHKMEM_DEBUG
SerialOutputString("ChkMem: fillup\n");
#endif
/* fill mem with pattern */
p=start;
while ( p<end ) {
MEM( p ) = p;
barrier();
p += 4;
}
#if CHKMEM_DEBUG
SerialOutputString("\rChkMem: bottom-up\n");
#endif
/* bottom-up test */
p=start;
while ( p<end ) {
showadr( (u32*)p );
tst = MEM( p );
if ( tst != p ) {
goto DONE;
}
p += 4;
}
/* no error if we reach this point */
ret = 0;
DONE:
if ( ret != 0 && badadr ) {
*badadr = p;
}
return ret;
}
/*********************************************************************
* ChkMemHardcore
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Hardcore memory test. Test methods based on memtest
* by Charles Cazabon <me...@di...>
*
* returns 1 if memory failure, returns failed
* address in badadr
*
*/
static int ChkMemHardcore( u32 start, u32 end, u32 pattern, u32 *badadr )
{
register u32 count;
SerialOutputString("\nchkmem: hardcore test method\n");
SKIPBLOBMEM( start );
#if CHKMEM_DEBUG
SerialOutputString("ChkMem: start(0x");
SerialOutputHex(start);
SerialOutputString(") - end(0x");
SerialOutputHex(end);
SerialOutputString(")\n");
#endif
count = end - start;
SerialOutputHex(count);
SerialOutputString("\n");
count = (count >> 1);
SerialOutputHex(count);
SerialOutputString("\n");
test_or_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_and_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_seqinc_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_checkerboard_comparison ((u32 *)start, (u32 *)(start+count), count>>2);
test_solidbits_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_blockseq_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_walkbits_comparison((u32 *)start, (u32 *)(start+count), count>>2, 0);
test_walkbits_comparison((u32 *)start, (u32 *)(start+count), count>>2, 1);
test_bitspread_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_bitflip_comparison((u32 *)start, (u32 *)(start+count), count>>2);
test_stuck_address((u32 *)start, (u32 *)(start+count), count>>2);
/* no error if we reach this point */
if ( badadr ) {
*badadr = 0L;
}
return 0;
}
/*********************************************************************/
/** MEMTESTER FUNCTIONS *********************************************/
/*********************************************************************/
/**********************************************************************
* Original Authors of following memory test functions:
*
* Charles Cazabon <me...@di...>
*
* Copyright © 1999 Simon Kirby.
* Version 2 Copyright © 1999 Charles Cazabon.
*
*/
int
test_verify_success (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i;
for (i = 0; i < count; i++, p1++, p2++)
{
if ( MEM( p1 ) != MEM( p2 ) )
{
SerialOutputString("\nchkmem: contents differ:\n");
SerialOutputHex((u32)p1);
SerialOutputString("\n");
SerialOutputHex((u32)p2);
SerialOutputString("\n");
CHKMEM_PUSHERR( (u32)p1 );
CHKMEM_PUSHERR( (u32)p2 );
}
}
return (CHKMEM_OK);
}
int
test_or_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i;
u32 q = 0xdeadbeef;
SHOWFUNC();
for (i = 0; i < count; i++)
{
showadr( p2 );
MEM( p1++ ) |= q;
barrier();
MEM( p2++ ) |= q;
barrier();
}
return (test_verify_success (bp1, bp2, count));
}
int
test_and_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i;
u32 q = 0xdeadbeef;
SHOWFUNC();
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) &= q;
barrier();
MEM( p2++ ) &= q;
barrier();
}
return (test_verify_success (bp1, bp2, count));
}
int
test_seqinc_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i;
u32 q = 0xdeadbeef;
SHOWFUNC();
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = (i + q);
barrier();
}
return (test_verify_success (bp1, bp2, count));
}
int
test_solidbits_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 q, i, j;
SHOWFUNC();
for (j = 0; j < 64; j++)
{
showrun( j );
q = (j % 2) == 0 ? 0xFFFFFFFF : 0x00000000;
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = (i % 2) == 0 ? q : ~q;
barrier();
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
return (CHKMEM_OK);
}
int
test_checkerboard_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 q, i, j;
SHOWFUNC();
for (j = 0; j < 64; j++)
{
showrun( j );
q = (j % 2) == 0 ? 0x55555555 : 0xAAAAAAAA;
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = (i % 2) == 0 ? q : ~q;
barrier();
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
return (CHKMEM_OK);
}
int
test_blockseq_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i, j;
SHOWFUNC();
for (j = 0; j < 256; j++)
{
showrun( j );
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = MAKE32FROM8 (j);
barrier();
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
return (CHKMEM_OK);
}
int
test_walkbits_comparison (u32 *bp1, u32 *bp2, u32 count, int m)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i, j;
SHOWFUNC();
for (j = 0; j < 64; j++)
{
showrun( j );
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
if (j < 32) /* Walk it up. */
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = (m == 0) ? 0x00000001 << j :
0xFFFFFFFF ^ (0x00000001 << j);
barrier();
}
else /* Walk it back down. */
{
MEM( p1++ ) = MEM( p2++ ) = (m == 0)
? 0x00000001 << (64 - j - 1)
: 0xFFFFFFFF ^ (0x00000001 << (64 - j - 1));
barrier();
}
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
return (CHKMEM_OK);
}
int
test_bitspread_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i, j;
SHOWFUNC();
for (j = 0; j < 64; j++)
{
showrun( j );
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
showadr( p1 );
if (j < 32) /* Walk it up. */
{
MEM( p1++ ) = MEM( p2++ ) = (i % 2 == 0)
? (0x00000001 << j) | (0x00000001 << (j + 2))
: 0xFFFFFFFF ^ ((0x00000001 << j)
| (0x00000001 << (j + 2)));
barrier();
}
else /* Walk it back down. */
{
MEM( p1++ ) = MEM( p2++ ) = (i % 2 == 0)
? (0x00000001 << (63 - j)) | (0x00000001 << (65 - j))
: 0xFFFFFFFF ^ (0x00000001 << (63 - j)
| (0x00000001 << (65 - j)));
barrier();
}
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
return (CHKMEM_OK);
}
int
test_bitflip_comparison (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1 = (volatile u32 *) bp1;
volatile u32 *p2 = (volatile u32 *) bp2;
u32 i, j, k;
u32 q;
SHOWFUNC();
for (k = 0; k < 32; k++)
{
showrun( k*8 );
q = 0x00000001 << k;
for (j = 0; j < 8; j++)
{
q = ~q;
p1 = (volatile u32 *) bp1;
p2 = (volatile u32 *) bp2;
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = MEM( p2++ ) = (i % 2) == 0 ? q : ~q;
barrier();
}
if (test_verify_success (bp1, bp2, count) == CHKMEM_ERR)
{
return (CHKMEM_ERR);
}
}
}
return (CHKMEM_OK);
}
int
test_stuck_address (u32 *bp1, u32 *bp2, u32 count)
{
volatile u32 *p1;
/* second argument is not used; just gives it a compatible signature. */
u32 i, j;
SHOWFUNC();
count <<= 1;
for (j = 0; j < 16; j++)
{
showrun( j );
p1 = (volatile u32 *) bp1;
for (i = 0; i < count; i++)
{
showadr( p1 );
MEM( p1++ ) = ((j + i) % 2) == 0 ? (u32) p1 : ~((u32) p1);
barrier();
}
p1 = (volatile u32 *) bp1;
for (i = 0; i < count; i++, p1++)
{
showadr( p1 );
if (*p1 != (((j + i) % 2) == 0 ? (u32) p1 : ~((u32) p1)))
{
return (CHKMEM_ERR);
}
}
}
return (CHKMEM_OK);
}
--- NEW FILE: cmddebug.h ---
#ifndef _CMD_DEBUG_H
#define _CMD_DEBUG_H 1
#if DEBUG
# define _DBG( flag, ... ) if ( flag ) printf( ##args )
#else
# define _DBG( flag, ... )
#endif
#endif
--- NEW FILE: common.c ---
/*
* common.c: common helper functions used by all commands
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: common.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
/**********************************************************************
* defines
*/
/**********************************************************************
* a perror() lookalike
*/
void perror( int errno, char *func )
{
printerrprefix();
if ( errno < 0 )
errno = -errno;
if ( func != NULL) {
printf( "%s: ", func );
}
printf( "%s\n", strerror(errno) );
}
--- NEW FILE: common.h ---
#ifndef _CMD_COMMON_H
#define _CMD_COMMON_H 1
/* a perror-lookalike */
void perror( int, char * );
#endif
--- NEW FILE: dump.c ---
/*
* dump.c: hextump command
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
* Copyright (C) 2001 Tim Riker
*
* 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
*
*/
#ident "$Id: dump.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/*********************************************************************
* dump
*
* AUTHOR: Tim Riker
* REVISED: seletz
*
* dumps memory
*
*/
static int dump( int argc, char *argv[] )
{
int ret = 0;
u32 address;
u32 endaddress;
u32 tmpaddress;
u32 value;
if ( argc < 2 )
ERR( -EINVAL );
ret = strtou32(argv[1], &address);
if ( ret < 0 )
ERR( -EINVAL );
if ( argc == 3 ) {
ret = strtou32(argv[2], &endaddress);
if ( ret < 0 )
ERR( -EINVAL );
} else
endaddress = address + 0x80;
/* check alignment of address and endaddress */
if((address & 0x03) || (endaddress & 0x03))
ERR(-EALIGN);
/* print it */
for ( ; address < endaddress; address += 0x10) {
printf( "0x%08lx: ", address );
for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress += 4) {
value = (*((u32 *)tmpaddress));
printf( "0x%08lx ", value );
}
for (tmpaddress = address; tmpaddress < address + 0x10; tmpaddress++) {
value = (*((u8 *)tmpaddress)) & 0xff;
if ((value >= ' ') && (value <= '~'))
serial_write(value);
else
serial_write('.');
}
serial_write('\n');
}
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char dumphelp[] = "dump address [endAddress]\n";
__commandlist(dump, "dump", dumphelp );
--- NEW FILE: memcpy.c ---
/*
* memcpy.c: copy memory command
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: memcpy.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/**********************************************************************
* prototypes
*/
/*********************************************************************
* CmdMemcpy
*
* AUTOR: SELETZ
* REVISED:
*
* Command wrapper for memcpy utility function.
*
*/
static int CmdMemcpy( int argc, char *argv[] )
{
int ret = 0;
u32 src = 0L;
u32 dest = 0L;
u32 len = 0L;
if ( argc < 4 ) ERR( -EINVAL );
ret = strtou32( argv[1], &src );
if ( ret < 0 ) ERR( -EINVAL );
ret = strtou32( argv[2], &dest );
if ( ret < 0 ) ERR( -EINVAL );
ret = strtou32( argv[3], &len );
if ( ret < 0 ) ERR( -EINVAL );
/* check alignment of src and dest */
if((src & 0x03) || (dest & 0x03))
ERR(-EALIGN);
/* counted in words */
if ( len & 0x00000003 ) {
len = ( len >> 2 ) + 1;
} else {
len = len >> 2;
}
_DBG( dbg, "memcpy: src=0x%08lx, dest=0x%08lx, %d words\n",
src, sest, len );
MyMemCpy( (u32 *)dest, (const u32 *)src, len);
printf("%d words copied.\n", len );
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char memcpyhelp[] = "memcpy src dst len\n"
"copy len bytes from src to dst\n";
__commandlist(CmdMemcpy, "memcpy", memcpyhelp);
--- NEW FILE: peek.c ---
/*
* debug.c: Debugging command functions
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: peek.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/*********************************************************************
* Peek
*
* AUTHOR: Stefan Eletzhofer
* REVISED:
*
* Peeks values from memory
*
*/
static int Peek( int argc, char *argv[] )
{
int ret = 0;
u32 address;
u32 value;
char type = 'w';
if ( argc < 2 ) ERR( -EINVAL );
ret = strtou32(argv[1], &address);
if ( ret < 0 ) ERR( -EINVAL );
if ( argc >= 2 ) {
type = argv[2][0];
}
_DBG( dbg, "peek: adr=0x%08lx, type=%c\n", address, type );
/* check memory alignment */
switch(type | 0x20) {
case 'b':
/* bytes don't have alignment restrictions */
break;
case 'h':
/* half word accesses should be aligned on half words */
if(address & 0x01)
ERR(-EALIGN);
break;
case 'w':
/* word accesses should be aligned on word boundaries */
if(address & 0x03)
ERR(-EALIGN);
break;
default:
/* hmm, invalid type */
ERR( -EINVAL );
break;
}
/* read value from memory */
switch( type | 0x20 ) {
case 'b':
value = (*((u8 *)address)) & 0xff;
break;
case 'h':
value = (*((u16 *)address))& 0xffff;
break;
case 'w':
value = (*((u32 *)address));
break;
default:
/* this should not happen */
ERR(-EINVAL);
break;
}
printf( "%c 0x%08lx\n", type, value );
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char peekhelp[] = "peek address [b|h|w]\n"
"b = byte, h = half word, w = word (default is w)\n";
__commandlist(Peek, "peek", peekhelp );
--- NEW FILE: poke.c ---
/*
* poke.c: poke command
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* 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
*
*/
#ident "$Id: poke.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* Includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/errno.h>
#include <blob/error.h>
#include <blob/types.h>
#include <blob/util.h>
#include <blob/serial.h>
#include <blob/command.h>
#include "cmddebug.h"
#include "common.h"
/**********************************************************************
* defines
*/
/* this will send a cold shiver through erik's spine ... */
#define ERR( x ) { ret = x; goto DONE; }
/**********************************************************************
* statics
*/
#if DEBUG
static int dbg = 1;
#else
static int dbg = 0;
#endif
/**********************************************************************
* prototypes
*/
/*********************************************************************
* Poke
*
* AUTOR: Stefan Eletzhofer
* REVISED:
*
* Poke values to memory
*
*/
static int Poke( int argc, char *argv[] )
{
int ret = 0;
u32 address;
u32 value;
char type = 'w';
if ( argc < 3 ) ERR( -EINVAL );
ret = strtou32(argv[1], &address);
if ( ret < 0 ) ERR( -EINVAL );
ret = strtou32(argv[2], &value);
if ( ret < 0 ) ERR( -EINVAL );
if ( argc >= 3 ) {
type = argv[3][0];
}
_DBG( dbg, "poke: adr=0x%08lx, val=0x%08lx, type=%c\n",
address, value, type );
/* check memory alignment */
switch(type | 0x20) {
case 'b':
/* bytes don't have alignment restrictions */
break;
case 'h':
/* half word accesses should be aligned on half words */
if(address & 0x01)
ERR(-EALIGN);
break;
case 'w':
/* word accesses should be aligned on word boundaries */
if(address & 0x03)
ERR(-EALIGN);
break;
default:
/* hmm, invalid type */
ERR( -EINVAL );
break;
}
/* write the value to memory */
switch( type | 0x20 ) {
case 'b':
*((u8 *)address) = (u8)(value & 0xff);
break;
case 'h':
*((u16 *)address) = (u16)(value & 0xffff);
break;
case 'w':
*((u32 *)address) = value;
break;
default:
/* this should not happen */
ERR( -EINVAL );
break;
}
ret = 0;
DONE:
if ( ret != 0 ) {
perror( ret, __FUNCTION__ );
}
return ret;
}
static char pokehelp[] = "poke address value [b|h|w]\n"
"b = byte, h = half word, w = word (default is w)\n";
__commandlist(Poke, "poke", pokehelp );
--- NEW FILE: regs-sa11x0.c ---
/*
* regs-sa11x0.c: command to nicely debug register contents
*
* Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...>
*
* $Id: regs-sa11x0.c,v 1.1 2002/02/12 12:54:59 seletz Exp $
*
* 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
*
*/
#ident "$Id: regs-sa11x0.c,v 1.1 2002/02/12 12:54:59 seletz Exp $"
/**********************************************************************
* includes
*/
#ifdef HAVE_CONFIG_H
# include <blob/config.h>
#endif
#include <blob/types.h>
#include <blob/errno.h>
#include <blob/util.h>
#include <blob/command.h>
#include <blob/init.h>
#include <blob/serial.h>
#include <blob/time.h>
#include <blob/sa1100.h>
/**********************************************************************
* defines
*/
#define MEM(adr) (*((u32*)adr))
#define SET(reg,bit) ((reg) |= (1<<(bit)))
#define CLR(reg,bit) ((reg) &= ~(1<<(bit)))
/**********************************************************************
* types
*/
/* a type to hold register infos */
typedef struct _reg {
char *name; /* reg name */
u32 adr; /* reg address */
char *desc; /* description */
} register_t;
/* a set of registers */
typedef struct _reg_set {
char *name; /* name of register set */
register_t *set; /* register set */
} reg_set_t;
/**********************************************************************
* module globals
*/
/* NOTE: the following register definitions are directly taken from
* linux/include/asm-arm/arch-sa1100/SA-1100.h
* and should therefore be correct.*/
/* Serial IF */
static register_t regs_uart[] = {
{ "Ser0UDCCR", (0x80000000), " Ser. port 0 UDC Control Reg. " },
{ "Ser0UDCAR", (0x80000004), " Ser. port 0 UDC Address Reg. " },
{ "Ser0UDCOMP", (0x80000008), " Ser. port 0 UDC Output Maximum Packet size reg. " },
{ "Ser0UDCIMP", (0x8000000C), " Ser. port 0 UDC Input Maximum Packet size reg. " },
{ "Ser0UDCCS0", (0x80000010), " Ser. port 0 UDC Control/Status reg. end-point 0 " },
{ "Ser0UDCCS1", (0x80000014), " Ser. port 0 UDC Control/Status reg. end-point 1 (output) " },
{ "Ser0UDCCS2", (0x80000018), " Ser. port 0 UDC Control/Status reg. end-point 2 (input) " },
{ "Ser0UDCD0", (0x8000001C), " Ser. port 0 UDC Data reg. end-point 0 " },
{ "Ser0UDCWC", (0x80000020), " Ser. port 0 UDC Write Count reg. end-point 0 " },
{ "Ser0UDCDR", (0x80000028), " Ser. port 0 UDC Data Reg. " },
{ "Ser0UDCSR", (0x80000030), " Ser. port 0 UDC Status Reg. " },
{ "_UTCR01", (0x80010000 + ((1) - 1)*0x00020000), " UART Control Reg. 0 [1..3] " },
{ "_UTCR02", (0x80010000 + ((2) - 1)*0x00020000), " UART Control Reg. 0 [1..3] " },
{ "_UTCR03", (0x80010000 + ((3) - 1)*0x00020000), " UART Control Reg. 0 [1..3] " },
{ "_UTCR11", (0x80010004 + ((1) - 1)*0x00020000), " UART Control Reg. 1 [1..3] " },
{ "_UTCR22", (0x80010008 + ((2) - 1)*0x00020000), " UART Control Reg. 2 [1..3] " },
{ "_UTCR33", (0x8001000C + ((3) - 1)*0x00020000), " UART Control Reg. 3 [1..3] " },
{ "_UTCR42", (0x80010010 + ((2) - 1)*0x00020000), " UART Control Reg. 4 [2] " },
{ "_UTDR1", (0x80010014 + ((1) - 1)*0x00020000), " UART Data Reg. [1..3] " },
{ "_UTDR2", (0x80010014 + ((2) - 1)*0x00020000), " UART Data Reg. [1..3] " },
{ "_UTDR3", (0x80010014 + ((3) - 1)*0x00020000), " UART Data Reg. [1..3] " },
{ "_UTSR01", (0x8001001C + ((1) - 1)*0x00020000), " UART Status Reg. 0 [1..3] " },
{ "_UTSR02", (0x8001001C + ((2) - 1)*0x00020000), " UART Status Reg. 0 [1..3] " },
{ "_UTSR03", (0x8001001C + ((3) - 1)*0x00020000), " UART Status Reg. 0 [1..3] " },
{ "_UTSR11", (0x80010020 + ((1) - 1)*0x00020000), " UART Status Reg. 1 [1..3] " },
{ "_UTSR12", (0x80010020 + ((2) - 1)*0x00020000), " UART Status Reg. 1 [1..3] " },
{ "_UTSR13", (0x80010020 + ((3) - 1)*0x00020000), " UART Status Reg. 1 [1..3] " },
{ "Ser1SDCR0", (0x80020060), " Ser. port 1 SDLC Control Reg. 0 " },
{ "Ser1SDCR1", (0x80020064), " Ser. port 1 SDLC Control Reg. 1 " },
{ "Ser1SDCR2", (0x80020068), " Ser. port 1 SDLC Control Reg. 2 " },
{ "Ser1SDCR3", (0x8002006C), " Ser. port 1 SDLC Control Reg. 3 " },
{ "Ser1SDCR4", (0x80020070), " Ser. port 1 SDLC Control Reg. 4 " },
{ "Ser1SDDR", (0x80020078), " Ser. port 1 SDLC Data Reg. " },
{ "Ser1SDSR0", (0x80020080), " Ser. port 1 SDLC Status Reg. 0 " },
{ "Ser1SDSR1", (0x80020084), " Ser. port 1 SDLC Status Reg. 1 " },
{ "Ser2HSCR0", (0x80040060), " Ser. port 2 HSSP Control Reg. 0 " },
{ "Ser2HSCR1", (0x80040064), " Ser. port 2 HSSP Control Reg. 1 " },
{ "Ser2HSDR", (0x8004006C), " Ser. port 2 HSSP Data Reg. " },
{ "Ser2HSSR0", (0x80040074), " Ser. port 2 HSSP Status Reg. 0 " },
{ "Ser2HSSR1", (0x80040078), " Ser. port 2 HSSP Status Reg. 1 " },
{ "Ser2HSCR2", (0x90060028), " Ser. port 2 HSSP Control Reg. 2 " },
{ "Ser4MCCR0", (0x80060000), " Ser. port 4 MCP Control Reg. 0 " },
{ "Ser4MCDR0", (0x80060008), " Ser. port 4 MCP Data Reg. 0 (audio) " },
{ "Ser4MCDR1", (0x8006000C), " Ser. port 4 MCP Data Reg. 1 (telecom) " },
{ "Ser4MCDR2", (0x80060010), " Ser. port 4 MCP Data Reg. 2 (CODEC reg.) " },
{ "Ser4MCSR", (0x80060018), " Ser. port 4 MCP Status Reg. " },
{ "Ser4MCCR1", (0x90060030), " Ser. port 4 MCP Control Reg. 1 " },
{ "Ser4SSCR0", (0x80070060), " Ser. port 4 SSP Control Reg. 0 " },
{ "Ser4SSCR1", (0x80070064), " Ser. port 4 SSP Control Reg. 1 " },
{ "Ser4SSDR", (0x8007006C), " Ser. port 4 SSP Data Reg. " },
{ "Ser4SSSR", (0x80070074), " Ser. port 4 SSP Status Reg. " },
{ NULL, 0 }
};
/* Timer */
static register_t regs_timer[] = {
{ "OSMR0", (0x90000000), " OS timer Match Reg. 0 " },
{ "OSMR1", (0x90000004), " OS timer Match Reg. 1 " },
{ "OSMR2", (0x90000008), " OS timer Match Reg. 2 " },
{ "OSMR3", (0x9000000c), " OS timer Match Reg. 3 " },
{ "OSCR", (0x90000010), " OS timer Counter Reg. " },
{ "OSSR", (0x90000014), " OS timer Status Reg. " },
{ "OWER", (0x90000018), " OS timer Watch-dog Enable Reg. " },
{ "OIER", (0x9000001C), " OS timer Interrupt Enable Reg. " },
{ NULL, 0 }
};
/* RTC and Power Mgmt */
static register_t regs_rtc[] = {
{ "RTAR", (0x90010000), " RTC Alarm Reg. " },
{ "RCNR", (0x90010004), " RTC CouNt Reg. " },
{ "RTTR", (0x90010008), " RTC Trim Reg. " },
{ "RTSR", (0x90010010), " RTC Status Reg. " },
{ "PMCR", (0x90020000), " PM Control Reg. " },
{ "PSSR", (0x90020004), " PM Sleep Status Reg. " },
{ "PSPR", (0x90020008), " PM Scratch-Pad Reg. " },
{ "PWER", (0x9002000C), " PM Wake-up Enable Reg. " },
{ "PCFR", (0x90020010), " PM general ConFiguration Reg. " },
{ "PPCR", (0x90020014), " PM PLL Configuration Reg. " },
{ "PGSR", (0x90020018), " PM GPIO Sleep state Reg. " },
{ "POSR", (0x9002001C), " PM Oscillator Status Reg. " },
{ "RSRR", (0x90030000), " RC Software Reset Reg. " },
{ "RCSR", (0x90030004), " RC Status Reg. " },
{ "TUCR", (0x90030008), " Test Unit Control Reg. " },
{ NULL, 0 }
};
/* GPIO / IRQ */
static register_t regs_gpio[] = {
{ "GPLR", (0x90040000), " GPIO Pin Level Reg. " },
{ "GPDR", (0x90040004), " GPIO Pin Direction Reg. " },
{ "GPSR", (0x90040008), " GPIO Pin output Set Reg. " },
{ "GPCR", (0x9004000C), " GPIO Pin output Clear Reg. " },
{ "GRER", (0x90040010), " GPIO Rising-Edge detect Reg. " },
{ "GFER", (0x90040014), " GPIO Falling-Edge detect Reg. " },
{ "GEDR", (0x90040018), " GPIO Edge Detect status Reg. " },
{ "GAFR", (0x9004001C), " GPIO Alternate Function Reg. " },
{ "ICIP", (0x90050000), " IC IRQ Pending reg. " },
{ "ICMR", (0x90050004), " IC Mask Reg. " },
{ "ICLR", (0x90050008), " IC Level Reg. " },
{ "ICCR", (0x9005000C), " IC Control Reg. " },
{ "ICFP", (0x90050010), " IC FIQ Pending reg. " },
{ "ICPR", (0x90050020), " IC Pending Reg. " },
{ "PPDR", (0x90060000), " PPC Pin Direction Reg. " },
{ "PPSR", (0x90060004), " PPC Pin State Reg. " },
{ "PPAR", (0x90060008), " PPC Pin Assignment Reg. " },
{ "PSDR", (0x9006000C), " PPC Sleep-mode pin Direction Reg. " },
{ "PPFR", (0x90060010), " PPC Pin Flag Reg. " },
{ NULL, 0 }
};
/* MEMORY */
static register_t regs_memory[] = {
{ "MDCNFG", (0xA0000000), " DRAM CoNFiGuration reg. " },
{ "MDCAS0", (0xA0000004), " DRAM CAS shift reg. 0 " },
{ "MDCAS1", (0xA0000008), " DRAM CAS shift reg. 1 " },
{ "MDCAS2", (0xA000000c), " DRAM CAS shift reg. 2 " },
{ "MSC0", (0xa0000010), " Static memory Control reg. 0 " },
{ "MSC1", (0xa0000014), " Static memory Control reg. 1 " },
{ "MSC2", (0xa000002c), " Static memory Control reg. 2, not contiguous " },
{ "MECR", (0xA0000018), " Expansion memory bus (PCMCIA) Configuration Reg. " },
{ "MDREFR", (0xA000001C), " (SA1110 only) DRAM Refresh Control Register" },
{ NULL, 0 }
};
/* LCD */
static register_t regs_lcd[] = {
{ "LCCR0", (0xB0100000), " LCD Control Reg. 0 " },
{ "LCSR", (0xB0100004), " LCD Status Reg. " },
{ "DBAR1", (0xB0100010), " LCD DMA Base Address Reg. channel 1 " },
{ "DCAR1", (0xB0100014), " LCD DMA Current Address Reg. channel 1 " },
{ "DBAR2", (0xB0100018), " LCD DMA Base Address Reg. channel 2 " },
{ "DCAR2", (0xB010001C), " LCD DMA Current Address Reg. channel 2 " },
{ "LCCR1", (0xB0100020), " LCD Control Reg. 1 " },
{ "LCCR2", (0xB0100024), " LCD Control Reg. 2 " },
{ "LCCR3", (0xB0100028), " LCD Control Reg. 3 " },
{ NULL, 0 }
};
/* TODO: add SA1111 companion chip registers */
/* finally the available register sets */
static reg_set_t reg_sets[] = {
{ "uart", regs_uart },
{ "timer", regs_timer },
{ "rtc", regs_rtc },
{ "gpio", regs_gpio },
{ "memory", regs_memory },
{ "lcd", regs_lcd },
{ NULL, NULL }
};
/**********************************************************************/
/**********************************************************************/
/**********************************************************************/
/**********************************************************************
* regs_show()
*
* AUTHOR: seletz
* REVISED:
*
* Display register contents
*
*/
static int regs_show( int argc, char *argv[] )
{
int i = 0;
int set = 0;
register_t *registers = NULL;
/* TODO: allow user to select a specific register set to
* print instead of simply print all sets. */
set = 0;
while ( reg_sets[set].name ) {
i = 0;
registers = reg_sets[set].set;
printf( "%s\n", reg_sets[set].name );
printf( "--------------------------------\n" );
while ( registers && registers[i].name ) {
printf( "%s= 0x%08lx %s\n", registers[i].name, MEM( registers[i].adr ),
registers[i].desc?registers[i].desc:"" );
i++;
}
set++;
serial_write( '\n' );
}
return 0;
}
static char regshelp[] = "print register info\n";
__commandlist(regs_show, "regs", regshelp);
Index: Makefile.am
===================================================================
RCS file: /cvsroot/blob/blob/src/commands/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 29 Jan 2002 17:47:23 -0000 1.1
+++ Makefile.am 12 Feb 2002 12:54:59 -0000 1.2
@@ -26,6 +26,14 @@
libcommands_a_SOURCES = \
+ common.c \
+ poke.c \
+ peek.c \
+ regs-sa11x0.c \
+ call.c \
+ changebit.c \
+ dump.c \
+ chkmem.c \
dummy.c
|