Search
lxdream.org :: lxdream/test/testregs.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/testregs.c
changeset 190:f7653df5e832
next196:3d3c761afbf4
author nkeynes
date Wed Aug 02 04:13:15 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Add many more TA test cases (a couple of corner cases aren't 100% correct
yet, TBA)
Add new test "testregs" to check register masks (currently just PVR registers)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testregs.c Wed Aug 02 04:13:15 2006 +0000
1.3 @@ -0,0 +1,109 @@
1.4 +/**
1.5 + * $Id: testregs.c,v 1.1 2006-08-02 04:13:15 nkeynes Exp $
1.6 + *
1.7 + * Register mask tests. These are simple "write value to register and check
1.8 + * that we read back what we expect" tests.
1.9 + *
1.10 + * Copyright (c) 2006 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 +#include "lib.h"
1.24 +#include <stdio.h>
1.25 +
1.26 +/**
1.27 + * Constant to mean "same as previous value". Can't be used otherwise.
1.28 + */
1.29 +#define UNCHANGED 0xDEADBEEF
1.30 +
1.31 +struct test {
1.32 + unsigned int reg;
1.33 + unsigned int write;
1.34 + unsigned int expect;
1.35 +};
1.36 +
1.37 +
1.38 +
1.39 +struct test test_cases[] = {
1.40 + { 0xA05F8000, 0xFFFFFFFF, 0x17FD11DB }, /* PVRID read-only */
1.41 + { 0xA05F8004, 0xFFFFFFFF, 0x00000011 }, /* PVRVER read-only */
1.42 + // { 0xA05F8014, 0xFFFFFFFF, 0x00000000 }, /* Render start */
1.43 + { 0xA05F8018, 0xFFFFFFFF, 0x000007FF }, /* ??? */
1.44 + { 0xA05F801C, 0xFFFFFFFF, 0x00000000 }, /* ??? */
1.45 + { 0xA05F8020, 0xFFFFFFFF, 0x00F00000 }, /* Render poly buffer address ??? */
1.46 + { 0xA05F8024, 0xFFFFFFFF, 0x00000000 }, /* ??? */
1.47 + { 0xA05F8028, 0xFFFFFFFF, 0x00000000 }, /* ??? */
1.48 + { 0xA05F802C, 0xFFFFFFFF, 0x00FFFFFC }, /* Render Tile buffer address */
1.49 + { 0xA05F8030, 0xFFFFFFFF, 0x00010101 }, /* Render TSP cache? */
1.50 + { 0xA05F8040, 0xFFFFFFFF, 0x01FFFFFF }, /* Display border colour */
1.51 + { 0xA05F8044, 0xFFFFFFFF, 0x00FFFF7F }, /* Display config */
1.52 + { 0xA05F8048, 0xFFFFFFFF, 0x00FFFF0F }, /* Render config */
1.53 + { 0xA05F804C, 0xFFFFFFFF, 0x000001FF }, /* Render size */
1.54 + { 0xA05F8050, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 1 */
1.55 + { 0xA05F8054, 0xFFFFFFFF, 0x00FFFFFC }, /* Display address 2 */
1.56 + { 0xA05F8058, 0xFFFFFFFF, 0x00000000 }, /* ??? */
1.57 + { 0xA05F805C, 0xFFFFFFFF, 0x3FFFFFFF }, /* Display size */
1.58 + { 0xA05F8060, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 1 */
1.59 + { 0xA05F8064, 0xFFFFFFFF, 0x01FFFFFC }, /* Render address 2 */
1.60 + { 0xA05F8068, 0xFFFFFFFF, 0x07FF07FF }, /* Render horizontal clip */
1.61 + { 0xA05F806C, 0xFFFFFFFF, 0x03FF03FF }, /* Render vertical clip */
1.62 + { 0xA05F8074, 0xFFFFFFFF, 0x000001FF }, /* Render shadow mode */
1.63 + { 0xA05F807C, 0xFFFFFFFF, 0x003FFFFF }, /* Render object config */
1.64 + { 0xA05F8084, 0xFFFFFFFF, 0x7FFFFFFF }, /* Render tsp clip */
1.65 + { 0xA05F808C, 0xFFFFFFFF, 0x1FFFFFFF }, /* Render background plane config */
1.66 + { 0xA05F8098, 0xFFFFFFFF, 0x00FFFFF9 }, /* ISP config? */
1.67 + { 0xA05F80C4, 0xFFFFFFFF, UNCHANGED }, /* Gun pos */
1.68 + { 0xA05F80C8, 0xFFFFFFFF, 0x03FF33FF }, /* Horizontal scanline irq */
1.69 + { 0xA05F80CC, 0xFFFFFFFF, 0x03FF03FF }, /* Vertical scanline irq */
1.70 + { 0xA05F8124, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix base */
1.71 + { 0xA05F8128, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon base */
1.72 + { 0xA05F812C, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile matrix end */
1.73 + { 0xA05F8130, 0xFFFFFFFF, 0x00FFFFFC }, /* TA Polygon end */
1.74 + { 0xA05F8134, 0xFFFFFFFF, UNCHANGED }, /* TA Tilelist posn */
1.75 + { 0xA05F8138, 0xFFFFFFFF, UNCHANGED }, /* TA polygon posn */
1.76 + { 0xA05F813C, 0xFFFFFFFF, 0x000F003F }, /* TA tile matrix size */
1.77 + { 0xA05F8140, 0xFFFFFFFF, 0x00133333 }, /* TA object config */
1.78 + { 0xA05F8144, 0xFFFFFFFF, 0x00000000 }, /* TA initialize */
1.79 + { 0xA05F8164, 0xFFFFFFFF, 0x00FFFFE0 }, /* TA Tile list start */
1.80 + { 0, 0, 0 } };
1.81 +
1.82 +int main( int argc, char *argv[] )
1.83 +{
1.84 + int i;
1.85 + int failures = 0;
1.86 + int tests = 0;
1.87 +
1.88 + for( i=0; test_cases[i].reg != 0; i++ ) {
1.89 + unsigned int oldval = long_read( test_cases[i].reg );
1.90 + unsigned int newval;
1.91 + long_write( test_cases[i].reg, test_cases[i].write );
1.92 + newval = long_read( test_cases[i].reg );
1.93 + if( test_cases[i].expect == UNCHANGED ) {
1.94 + if( newval != oldval ) {
1.95 + fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
1.96 + i+1, test_cases[i].reg, oldval, newval );
1.97 + failures++;
1.98 + }
1.99 + } else {
1.100 + if( newval != test_cases[i].expect ) {
1.101 + fprintf( stderr, "Test %d (%08X) failed. Expected %08X but was %08X\n",
1.102 + i+1, test_cases[i].reg, test_cases[i].expect, newval );
1.103 + failures++;
1.104 + }
1.105 + }
1.106 + long_write( test_cases[i].reg, oldval );
1.107 + tests++;
1.108 + }
1.109 +
1.110 + fprintf( stdout, "%d/%d test cases passed successfully\n", (tests-failures), tests );
1.111 + return failures;
1.112 +}
.