Search
lxdream.org :: lxdream/test/testregs.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/testregs.c
changeset 190:f7653df5e832
next196:3d3c761afbf4
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")
file annotate diff log raw
nkeynes@190
     1
/**
nkeynes@190
     2
 * $Id: testregs.c,v 1.1 2006-08-02 04:13:15 nkeynes Exp $
nkeynes@190
     3
 * 
nkeynes@190
     4
 * Register mask tests. These are simple "write value to register and check
nkeynes@190
     5
 * that we read back what we expect" tests.
nkeynes@190
     6
 *
nkeynes@190
     7
 * Copyright (c) 2006 Nathan Keynes.
nkeynes@190
     8
 *
nkeynes@190
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@190
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@190
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@190
    12
 * (at your option) any later version.
nkeynes@190
    13
 *
nkeynes@190
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@190
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@190
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@190
    17
 * GNU General Public License for more details.
nkeynes@190
    18
 */
nkeynes@190
    19
nkeynes@190
    20
#include "lib.h"
nkeynes@190
    21
#include <stdio.h>
nkeynes@190
    22
nkeynes@190
    23
/**
nkeynes@190
    24
 * Constant to mean "same as previous value". Can't be used otherwise.
nkeynes@190
    25
 */
nkeynes@190
    26
#define UNCHANGED 0xDEADBEEF
nkeynes@190
    27
nkeynes@190
    28
struct test {
nkeynes@190
    29
    unsigned int reg;
nkeynes@190
    30
    unsigned int write;
nkeynes@190
    31
    unsigned int expect;
nkeynes@190
    32
};
nkeynes@190
    33
nkeynes@190
    34
nkeynes@190
    35
nkeynes@190
    36
struct test test_cases[] = {
nkeynes@190
    37
    { 0xA05F8000, 0xFFFFFFFF, 0x17FD11DB }, /* PVRID read-only */
nkeynes@190
    38
    { 0xA05F8004, 0xFFFFFFFF, 0x00000011 }, /* PVRVER read-only */
nkeynes@190
    39
    //    { 0xA05F8014, 0xFFFFFFFF, 0x00000000 }, /* Render start */
nkeynes@190
    40
    { 0xA05F8018, 0xFFFFFFFF, 0x000007FF }, /* ??? */   
nkeynes@190
    41
    { 0xA05F801C, 0xFFFFFFFF, 0x00000000 }, /* ??? */   
nkeynes@190
    42
    { 0xA05F8020, 0xFFFFFFFF, 0x00F00000 }, /* Render poly buffer address ??? */
nkeynes@190
    43
    { 0xA05F8024, 0xFFFFFFFF, 0x00000000 }, /* ??? */
nkeynes@190
    44
    { 0xA05F8028, 0xFFFFFFFF, 0x00000000 }, /* ??? */   
nkeynes@190
    45
    { 0xA05F802C, 0xFFFFFFFF, 0x00FFFFFC }, /* Render Tile buffer address */
nkeynes@190
    46
    { 0xA05F8030, 0xFFFFFFFF, 0x00010101 }, /* Render TSP cache? */   
nkeynes@190
    47
    { 0xA05F8040, 0xFFFFFFFF, 0x01FFFFFF }, /* Display border colour */   
nkeynes@190
    48
    { 0xA05F8044, 0xFFFFFFFF, 0x00FFFF7F }, /* Display config */   
nkeynes@190
    49
    { 0xA05F8048, 0xFFFFFFFF, 0x00FFFF0F }, /* Render config */
nkeynes@190
    50
    { 0xA05F804C, 0xFFFFFFFF, 0x000001FF }, /* Render size */
nkeynes@190
    51
    { 0xA05F8050, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 1 */ 
nkeynes@190
    52
    { 0xA05F8054, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 2 */
nkeynes@190
    53
    { 0xA05F8058, 0xFFFFFFFF, 0x00000000 }, /* ??? */
nkeynes@190
    54
    { 0xA05F805C, 0xFFFFFFFF, 0x3FFFFFFF }, /* Display size */
nkeynes@190
    55
    { 0xA05F8060, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 1 */
nkeynes@190
    56
    { 0xA05F8064, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 2 */
nkeynes@190
    57
    { 0xA05F8068, 0xFFFFFFFF, 0x07FF07FF }, /* Render horizontal clip */
nkeynes@190
    58
    { 0xA05F806C, 0xFFFFFFFF, 0x03FF03FF }, /* Render vertical clip */
nkeynes@190
    59
    { 0xA05F8074, 0xFFFFFFFF, 0x000001FF }, /* Render shadow mode */
nkeynes@190
    60
    { 0xA05F807C, 0xFFFFFFFF, 0x003FFFFF }, /* Render object config */
nkeynes@190
    61
    { 0xA05F8084, 0xFFFFFFFF, 0x7FFFFFFF }, /* Render tsp clip */
nkeynes@190
    62
    { 0xA05F808C, 0xFFFFFFFF, 0x1FFFFFFF }, /* Render background plane config */
nkeynes@190
    63
    { 0xA05F8098, 0xFFFFFFFF, 0x00FFFFF9 }, /* ISP config? */
nkeynes@190
    64
    { 0xA05F80C4, 0xFFFFFFFF, UNCHANGED },  /* Gun pos */
nkeynes@190
    65
    { 0xA05F80C8, 0xFFFFFFFF, 0x03FF33FF }, /* Horizontal scanline irq */
nkeynes@190
    66
    { 0xA05F80CC, 0xFFFFFFFF, 0x03FF03FF }, /* Vertical scanline irq */
nkeynes@190
    67
    { 0xA05F8124, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix base */
nkeynes@190
    68
    { 0xA05F8128, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon base */
nkeynes@190
    69
    { 0xA05F812C, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix end */
nkeynes@190
    70
    { 0xA05F8130, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon end */
nkeynes@190
    71
    { 0xA05F8134, 0xFFFFFFFF, UNCHANGED  }, /* TA Tilelist posn */
nkeynes@190
    72
    { 0xA05F8138, 0xFFFFFFFF, UNCHANGED  }, /* TA polygon posn */
nkeynes@190
    73
    { 0xA05F813C, 0xFFFFFFFF, 0x000F003F }, /* TA tile matrix size */
nkeynes@190
    74
    { 0xA05F8140, 0xFFFFFFFF, 0x00133333 }, /* TA object config */
nkeynes@190
    75
    { 0xA05F8144, 0xFFFFFFFF, 0x00000000 }, /* TA initialize */
nkeynes@190
    76
    { 0xA05F8164, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile list start */
nkeynes@190
    77
    { 0, 0, 0 } };
nkeynes@190
    78
    
nkeynes@190
    79
int main( int argc, char *argv[] )
nkeynes@190
    80
{
nkeynes@190
    81
    int i;
nkeynes@190
    82
    int failures = 0;
nkeynes@190
    83
    int tests = 0;
nkeynes@190
    84
    
nkeynes@190
    85
    for( i=0; test_cases[i].reg != 0; i++ ) {
nkeynes@190
    86
    	unsigned int oldval = long_read( test_cases[i].reg );
nkeynes@190
    87
    	unsigned int newval;
nkeynes@190
    88
	long_write( test_cases[i].reg, test_cases[i].write );
nkeynes@190
    89
	newval = long_read( test_cases[i].reg );
nkeynes@190
    90
	if( test_cases[i].expect == UNCHANGED ) {
nkeynes@190
    91
	    if( newval != oldval ) {
nkeynes@190
    92
		fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
nkeynes@190
    93
		  	 i+1, test_cases[i].reg, oldval, newval );
nkeynes@190
    94
		failures++;
nkeynes@190
    95
	    }
nkeynes@190
    96
	} else {
nkeynes@190
    97
	    if( newval != test_cases[i].expect ) {
nkeynes@190
    98
		fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
nkeynes@190
    99
		  	 i+1, test_cases[i].reg, test_cases[i].expect, newval );
nkeynes@190
   100
		failures++;
nkeynes@190
   101
	    }
nkeynes@190
   102
	}
nkeynes@190
   103
	long_write( test_cases[i].reg, oldval );
nkeynes@190
   104
	tests++;
nkeynes@190
   105
    }
nkeynes@190
   106
nkeynes@190
   107
    fprintf( stdout, "%d/%d test cases passed successfully\n", (tests-failures), tests );
nkeynes@190
   108
    return failures;
nkeynes@190
   109
}
.