Search
lxdream.org :: lxdream/test/asic.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/asic.c
changeset 193:31151fcc3cb7
prev185:6755a04c447f
next561:533f6b478071
author nkeynes
date Sat Aug 05 00:18:21 2006 +0000 (16 years ago)
permissions -rw-r--r--
last change Add error lines to tests with incomplete polys
Split clip tests to separate data file
Add tests for cmd bit 23 ("use list size field")
view annotate diff log raw
     1 /**
     2  * $Id: asic.c,v 1.2 2006-08-04 01:38:30 nkeynes Exp $
     3  * 
     4  * General ASIC support code
     5  *
     6  * Copyright (c) 2006 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #include "lib.h"
    21 #define ASIC_BASE 0xA05F6000
    22 #define ASIC_PIRQ(n) (ASIC_BASE + 0x900 + (n<<2))
    23 #define ASIC_IRQA(n) (ASIC_BASE + 0x910 + (n<<2))
    24 #define ASIC_IRQB(n) (ASIC_BASE + 0x920 + (n<<2))
    25 #define ASIC_IRQC(n) (ASIC_BASE + 0x930 + (n<<2))
    26 #define TIMEOUT 10000000
    28 /**
    29  * Wait for an ASIC event. 
    30  * @return 0 if the event occurred, otherwise -1 if the wait timed out.
    31  */
    32 int asic_wait( int event )
    33 {
    34     int n = event >> 5;
    35     unsigned int mask = (1<< (event&0x1f));
    36     int i;
    37     for( i=0; i<TIMEOUT; i++ ) {
    38 	if( long_read(ASIC_PIRQ(n)) & mask ) {
    39 	    return 0;
    40 	}
    41     }
    42     return -1; /* Timeout */
    43 }
    45 /**
    46  * Clear all asic events
    47  */
    48 void asic_clear()
    49 {
    50     long_write(ASIC_PIRQ(0), 0xFFFFFFFF);
    51     long_write(ASIC_PIRQ(1), 0xFFFFFFFF);
    52     long_write(ASIC_PIRQ(2), 0xFFFFFFFF);
    53 }
    55 int asic_check( int event ) 
    56 {
    57     int n = event >> 5;
    58     unsigned int mask = (1<< (event&0x1f));
    59     return (long_read(ASIC_PIRQ(n)) & mask) != 0;
    60 }
    62 void asic_mask_all()
    63 {
    64     long_write(ASIC_IRQA(0), 0);
    65     long_write(ASIC_IRQA(1), 0);
    66     long_write(ASIC_IRQA(2), 0);
    67     long_write(ASIC_IRQB(0), 0);
    68     long_write(ASIC_IRQB(1), 0);
    69     long_write(ASIC_IRQB(2), 0);
    70     long_write(ASIC_IRQC(0), 0);
    71     long_write(ASIC_IRQC(1), 0);
    72     long_write(ASIC_IRQC(2), 0);
    73 }
    75 /**
    76  * Print the contents of the ASIC event registers to the supplied FILE
    77  */
    78 void asic_dump( FILE *f )
    79 {
    80     int i,j;
    81     fprintf( f, "Events: " );
    82     for( i=0; i<3; i++ ) {
    83 	uint32_t val = long_read(ASIC_PIRQ(i));
    84 	for( j=0; j<32; j++ ) {
    85 	    if( val & (1<<j) ) {
    86 		fprintf( f, "%d ", (i<<5)+j );
    87 	    }
    88 	}
    89     }
    90     fprintf( f, "\n" );
    91 }
.