Search
lxdream.org :: lxdream/test/testregs.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/testregs.c
changeset 196:3d3c761afbf4
prev190:f7653df5e832
next332:4c1b31e646ef
author nkeynes
date Fri Dec 29 00:24:43 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Limit number of sectors read at once (linux driver seems to throw a hissy
fit if you request too many at a time)
view annotate diff log raw
     1 /**
     2  * $Id: testregs.c,v 1.2 2006-08-06 02:46:09 nkeynes Exp $
     3  * 
     4  * Register mask tests. These are simple "write value to register and check
     5  * that we read back what we expect" tests.
     6  *
     7  * Copyright (c) 2006 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #include "lib.h"
    21 #include <stdio.h>
    23 /**
    24  * Constant to mean "same as previous value". Can't be used otherwise.
    25  */
    26 #define UNCHANGED 0xDEADBEEF
    28 struct test {
    29     unsigned int reg;
    30     unsigned int write;
    31     unsigned int expect;
    32 };
    36 struct test test_cases[] = {
    37     { 0xA05F8000, 0xFFFFFFFF, 0x17FD11DB }, /* PVRID read-only */
    38     { 0xA05F8004, 0xFFFFFFFF, 0x00000011 }, /* PVRVER read-only */
    39     { 0xA05F8008, 0xFFFFFFFF, 0x00000007 }, /* Reset */
    40     { 0xA05F8010, 0xFFFFFFFF, 0 },
    41     //    { 0xA05F8014, 0xFFFFFFFF, 0x00000000 }, /* Render start */
    42     { 0xA05F8018, 0xFFFFFFFF, 0x000007FF }, /* ??? */   
    43     { 0xA05F801C, 0xFFFFFFFF, 0x00000000 }, /* ??? */   
    44     { 0xA05F8020, 0xFFFFFFFF, 0x00F00000 }, /* Render poly buffer address ??? */
    45     { 0xA05F8024, 0xFFFFFFFF, 0x00000000 }, /* ??? */
    46     { 0xA05F8028, 0xFFFFFFFF, 0x00000000 }, /* ??? */   
    47     { 0xA05F802C, 0xFFFFFFFF, 0x00FFFFFC }, /* Render Tile buffer address */
    48     { 0xA05F8030, 0xFFFFFFFF, 0x00010101 }, /* Render TSP cache? */   
    49     { 0xA05F8034, 0xFFFFFFFF, 0 },
    50     { 0xA05F8038, 0xFFFFFFFF, 0 },
    51     { 0xA05F803C, 0xFFFFFFFF, 0 },
    52     { 0xA05F8040, 0xFFFFFFFF, 0x01FFFFFF }, /* Display border colour */   
    53     { 0xA05F8044, 0xFFFFFFFF, 0x00FFFF7F }, /* Display config */   
    54     { 0xA05F8048, 0xFFFFFFFF, 0x00FFFF0F }, /* Render config */
    55     { 0xA05F804C, 0xFFFFFFFF, 0x000001FF }, /* Render size */
    56     { 0xA05F8050, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 1 */ 
    57     { 0xA05F8054, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 2 */
    58     { 0xA05F8058, 0xFFFFFFFF, 0x00000000 }, /* ??? */
    59     { 0xA05F805C, 0xFFFFFFFF, 0x3FFFFFFF }, /* Display size */
    60     { 0xA05F8060, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 1 */
    61     { 0xA05F8064, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 2 */
    62     { 0xA05F8068, 0xFFFFFFFF, 0x07FF07FF }, /* Render horizontal clip */
    63     { 0xA05F806C, 0xFFFFFFFF, 0x03FF03FF }, /* Render vertical clip */
    64     { 0xA05F8070, 0xFFFFFFFF, 0 },
    65     { 0xA05F8074, 0xFFFFFFFF, 0x000001FF }, /* Render shadow mode */
    66     { 0xA05F8078, 0xFFFFFFFF, 0x7FFFFFFF }, /* Near z clip */
    67     { 0xA05F807C, 0xFFFFFFFF, 0x003FFFFF }, /* Render object config */
    68     { 0xA05F8080, 0xFFFFFFFF, 0x00000007 }, /* ??? */
    69     { 0xA05F8084, 0xFFFFFFFF, 0x7FFFFFFF }, /* Render tsp clip */
    70     { 0xA05F8088, 0xFFFFFFFF, 0xFFFFFFF0 }, /* Far z clip */
    71     { 0xA05F808C, 0xFFFFFFFF, 0x1FFFFFFF }, /* Render background plane config */
    72     { 0xA05F8090, 0xFFFFFFFF, 0 },
    73     { 0xA05F8094, 0xFFFFFFFF, 0 },
    74     { 0xA05F8098, 0xFFFFFFFF, 0x00FFFFF9 }, /* ISP config? */
    75     { 0xA05F809C, 0xFFFFFFFF, 0 },
    76     { 0xA05F80A0, 0xFFFFFFFF, 0x000000FF }, /* Vram cfg1? */
    77     { 0xA05F80A4, 0xFFFFFFFF, 0x003FFFFF },
    78     { 0xA05F80A8, 0xFFFFFFFF, 0x1FFFFFFF },
    79     { 0xA05F80AC, 0xFFFFFFFF, 0 },
    80     { 0xA05F80B0, 0xFFFFFFFF, 0x00FFFFFF },
    81     { 0xA05F80B4, 0xFFFFFFFF, 0x00FFFFFF },
    82     { 0xA05F80B8, 0xFFFFFFFF, 0x0000FFFF },
    83     { 0xA05F80BC, 0xFFFFFFFF, 0xFFFFFFFF },
    84     { 0xA05F80C0, 0xFFFFFFFF, 0xFFFFFFFF },
    85     { 0xA05F80C4, 0xFFFFFFFF, UNCHANGED },  /* Gun pos */
    86     { 0xA05F80C8, 0xFFFFFFFF, 0x03FF33FF }, /* Horizontal scanline irq */
    87     { 0xA05F80CC, 0xFFFFFFFF, 0x03FF03FF }, /* Vertical scanline irq */
    88     { 0xA05F80D0, 0xFFFFFFFF, 0x000003FF },
    89     { 0xA05F80D4, 0xFFFFFFFF, 0x03FF03FF },
    90     { 0xA05F80D8, 0xFFFFFFFF, 0x03FF03FF },
    91     { 0xA05F80DC, 0xFFFFFFFF, 0x03FF03FF },
    92     { 0xA05F80E0, 0xFFFFFFFF, 0xFFFFFF7F },
    93     { 0xA05F80E4, 0xFFFFFFFF, 0x00031F1F },
    94     { 0xA05F80E8, 0xFFFFFFFF, 0x003F01FF },
    95     { 0xA05F80EC, 0xFFFFFFFF, 0x000003FF },
    96     { 0xA05F80F0, 0xFFFFFFFF, 0x03FF03FF },
    97     { 0xA05F80F4, 0xFFFFFFFF, 0x0007FFFF },
    98     { 0xA05F80F8, 0xFFFFFFFF, 0 },
    99     { 0xA05F80FC, 0xFFFFFFFF, 0 },
   100     { 0xA05F8100, 0xFFFFFFFF, 0 },
   101     { 0xA05F8104, 0xFFFFFFFF, 0 },
   102     { 0xA05F8108, 0xFFFFFFFF, 0x00000003 },
   103     { 0xA05F810C, 0xFFFFFFFF, UNCHANGED },
   104     { 0xA05F8110, 0xFFFFFFFF, 0x000FFF3F },
   105     { 0xA05F8114, 0xFFFFFFFF, UNCHANGED },
   106     { 0xA05F8118, 0xFFFFFFFF, 0x0000FFFF },
   107     { 0xA05F811C, 0xFFFFFFFF, 0x000000FF },
   108     { 0xA05F8120, 0xFFFFFFFF, 0 },
   109     { 0xA05F8124, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix base */
   110     { 0xA05F8128, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon base */
   111     { 0xA05F812C, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix end */
   112     { 0xA05F8130, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon end */
   113     { 0xA05F8134, 0xFFFFFFFF, UNCHANGED  }, /* TA Tilelist posn */
   114     { 0xA05F8138, 0xFFFFFFFF, UNCHANGED  }, /* TA polygon posn */
   115     { 0xA05F813C, 0xFFFFFFFF, 0x000F003F }, /* TA tile matrix size */
   116     { 0xA05F8140, 0xFFFFFFFF, 0x00133333 }, /* TA object config */
   117     { 0xA05F8144, 0xFFFFFFFF, 0x00000000 }, /* TA initialize */
   118     { 0xA05F8148, 0xFFFFFFFF, 0x00FFFFF8 },
   119     { 0xA05F814C, 0xFFFFFFFF, 0x01013F3F },
   120     { 0xA05F8150, 0xFFFFFFFF, 0 },
   121     { 0xA05F8154, 0xFFFFFFFF, 0 },
   122     { 0xA05F8158, 0xFFFFFFFF, 0 },
   123     { 0xA05F815C, 0xFFFFFFFF, 0 },
   124     { 0xA05F8160, 0xFFFFFFFF, 0 },
   125     { 0xA05F8164, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile list start */
   126     { 0xA05F8168, 0xFFFFFFFF, 0 },
   127     { 0xA05F816C, 0xFFFFFFFF, 0 },
   128     { 0xA05F8170, 0xFFFFFFFF, 0 },
   129     { 0xA05F8174, 0xFFFFFFFF, 0 },
   130     { 0xA05F8178, 0xFFFFFFFF, 0 },
   131     { 0xA05F817C, 0xFFFFFFFF, 0 },
   132     { 0xA05F8180, 0xFFFFFFFF, 0 },
   133     { 0xA05F8184, 0xFFFFFFFF, 0 },
   134     { 0xA05F8188, 0xFFFFFFFF, 0 },
   135     { 0xA05F818C, 0xFFFFFFFF, 0 },
   136     { 0xA05F8190, 0xFFFFFFFF, 0 },
   137     { 0xA05F8194, 0xFFFFFFFF, 0 },
   138     { 0xA05F8198, 0xFFFFFFFF, 0 },
   139     { 0xA05F819C, 0xFFFFFFFF, 0 },
   140     { 0xA05F81A0, 0xFFFFFFFF, 0 },
   141     { 0xA05F81A4, 0xFFFFFFFF, 0 },
   142     { 0xA05F81A8, 0xFFFFFFFF, 0x00000001 },
   143     { 0xA05F81A8, 0x00000000, 0x00000000 },    	
   144     { 0xA05F81AC, 0xFFFFFFFF, 0 },
   145     { 0xA05F81B0, 0xFFFFFFFF, 0 },
   146     { 0xA05F81B4, 0xFFFFFFFF, 0 },
   147     { 0xA05F81B8, 0xFFFFFFFF, 0 },
   148     { 0xA05F81BC, 0xFFFFFFFF, 0 },
   149     { 0xA05F81C0, 0xFFFFFFFF, 0 },
   150     { 0xA05F81C4, 0xFFFFFFFF, 0 },
   151     { 0xA05F81C8, 0xFFFFFFFF, 0 },
   152     { 0xA05F81CC, 0xFFFFFFFF, 0 },
   153     { 0xA05F81D0, 0xFFFFFFFF, 0 },
   154     { 0xA05F81D4, 0xFFFFFFFF, 0 },
   155     { 0xA05F81D8, 0xFFFFFFFF, 0 },
   156     { 0xA05F81DC, 0xFFFFFFFF, 0 },
   157     { 0xA05F81E0, 0xFFFFFFFF, 0 },
   158     { 0xA05F81E4, 0xFFFFFFFF, 0 },
   159     { 0xA05F81E8, 0xFFFFFFFF, 0 },
   160     { 0xA05F81EC, 0xFFFFFFFF, 0 },
   161     { 0xA05F81F0, 0xFFFFFFFF, 0 },
   162     { 0xA05F81F4, 0xFFFFFFFF, 0 },
   163     { 0xA05F81F8, 0xFFFFFFFF, 0 },
   164     { 0xA05F81FC, 0xFFFFFFFF, 0 },
   165     { 0, 0, 0 } };
   167 int main( int argc, char *argv[] )
   168 {
   169     int i;
   170     int failures = 0;
   171     int tests = 0;
   173     for( i=0; test_cases[i].reg != 0; i++ ) {
   174     	unsigned int oldval = long_read( test_cases[i].reg );
   175     	unsigned int newval;
   176 	long_write( test_cases[i].reg, test_cases[i].write );
   177 	newval = long_read( test_cases[i].reg );
   178 	if( test_cases[i].expect == UNCHANGED ) {
   179 	    if( newval != oldval ) {
   180 		fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
   181 		  	 i+1, test_cases[i].reg, oldval, newval );
   182 		failures++;
   183 	    }
   184 	} else {
   185 	    if( newval != test_cases[i].expect ) {
   186 		fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
   187 		  	 i+1, test_cases[i].reg, test_cases[i].expect, newval );
   188 		failures++;
   189 	    }
   190 	}
   191 	long_write( test_cases[i].reg, oldval );
   192 	tests++;
   193     }
   195     fprintf( stdout, "%d/%d test cases passed successfully\n", (tests-failures), tests );
   196     return failures;
   197 }
.