Search
lxdream.org :: lxdream/test/asic.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/asic.c
changeset 185:6755a04c447f
next193:31151fcc3cb7
author nkeynes
date Tue Jul 11 01:35:27 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change First commit of system test framework. 3 initial test cases (incomplete):
testide, testmath, and testta
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/asic.c Tue Jul 11 01:35:27 2006 +0000
1.3 @@ -0,0 +1,84 @@
1.4 +/**
1.5 + * $Id: asic.c,v 1.1 2006-07-11 01:35:23 nkeynes Exp $
1.6 + *
1.7 + * General ASIC support code
1.8 + *
1.9 + * Copyright (c) 2006 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include "lib.h"
1.23 +
1.24 +#define ASIC_BASE 0xA05F6000
1.25 +#define ASIC_PIRQ(n) (ASIC_BASE + 0x900 + (n<<2))
1.26 +#define ASIC_IRQA(n) (ASIC_BASE + 0x910 + (n<<2))
1.27 +#define ASIC_IRQB(n) (ASIC_BASE + 0x920 + (n<<2))
1.28 +#define ASIC_IRQC(n) (ASIC_BASE + 0x930 + (n<<2))
1.29 +#define TIMEOUT 10000000
1.30 +
1.31 +/**
1.32 + * Wait for an ASIC event.
1.33 + * @return 0 if the event occurred, otherwise -1 if the wait timed out.
1.34 + */
1.35 +int asic_wait( int event )
1.36 +{
1.37 + int n = event >> 5;
1.38 + unsigned int mask = (1<< (event&0x1f));
1.39 + int i;
1.40 + for( i=0; i<TIMEOUT; i++ ) {
1.41 + if( long_read(ASIC_PIRQ(n)) & mask ) {
1.42 + return 0;
1.43 + }
1.44 + }
1.45 + return -1; /* Timeout */
1.46 +}
1.47 +
1.48 +/**
1.49 + * Clear all asic events
1.50 + */
1.51 +void asic_clear()
1.52 +{
1.53 + long_write(ASIC_PIRQ(0), 0xFFFFFFFF);
1.54 + long_write(ASIC_PIRQ(1), 0xFFFFFFFF);
1.55 + long_write(ASIC_PIRQ(2), 0xFFFFFFFF);
1.56 +}
1.57 +
1.58 +void asic_mask_all()
1.59 +{
1.60 + long_write(ASIC_IRQA(0), 0);
1.61 + long_write(ASIC_IRQA(1), 0);
1.62 + long_write(ASIC_IRQA(2), 0);
1.63 + long_write(ASIC_IRQB(0), 0);
1.64 + long_write(ASIC_IRQB(1), 0);
1.65 + long_write(ASIC_IRQB(2), 0);
1.66 + long_write(ASIC_IRQC(0), 0);
1.67 + long_write(ASIC_IRQC(1), 0);
1.68 + long_write(ASIC_IRQC(2), 0);
1.69 +}
1.70 +
1.71 +/**
1.72 + * Print the contents of the ASIC event registers to the supplied FILE
1.73 + */
1.74 +void asic_dump( FILE *f )
1.75 +{
1.76 + int i,j;
1.77 + fprintf( f, "Events: " );
1.78 + for( i=0; i<3; i++ ) {
1.79 + uint32_t val = long_read(ASIC_PIRQ(i));
1.80 + for( j=0; j<32; j++ ) {
1.81 + if( val & (1<<j) ) {
1.82 + fprintf( f, "%d ", (i<<5)+j );
1.83 + }
1.84 + }
1.85 + }
1.86 + fprintf( f, "\n" );
1.87 +}
.