OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparclite/] [sleb/] [current/] [tests/] [slebstak.c] - Blame information for rev 856

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*=================================================================
2
//
3
//        slebstak.c
4
//
5
//        SPARClite HAL exception and register manipulation test
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     dsm
43
// Contributors:    dsm, nickg
44
// Date:          1998-06-18
45
//####DESCRIPTIONEND####
46
*/
47
 
48
#include <pkgconf/system.h>
49
 
50
#include <pkgconf/hal.h>
51
 
52
#include <cyg/infra/cyg_type.h>
53
 
54
#include <cyg/infra/cyg_ass.h>
55
 
56
#include <cyg/infra/testcase.h>
57
 
58
#include <cyg/hal/hal_arch.h>
59
#include <cyg/hal/hal_intr.h>
60
#include <cyg/hal/hal_diag.h>
61
#include <cyg/hal/hal_clock.h>
62
 
63
#include <pkgconf/infra.h>
64
 
65
#include <cyg/infra/diag.h>
66
 
67
// -------------------------------------------------------------------------
68
 
69
cyg_uint32 fact( cyg_uint32 arg )
70
{
71
    cyg_uint32 ret = (arg < 2) ? 1 : (arg * fact( arg - 1 ));
72
    return ret;
73
}
74
 
75
 
76
// -------------------------------------------------------------------------
77
 
78
int i, j=0, bit;
79
int level[8];
80
#define led (*(volatile char *)(0x02000003))
81
int lval = 0;
82
 
83
int sequence[] = { 0, 0, 1, 1, 2, 3, 4, 5, 6, 6, 7, 7, 7, 7, 6, 6, 5, 4, 3, 2, 1, 1, 0, 0,
84
 };
85
 
86
int nseq=(sizeof(sequence)/sizeof(sequence[0])-1);
87
 
88
void set_leds( void ) // and decay them too
89
{
90
  int i, j;
91
  for (j=0; j<50; j++)
92
    {
93
      for (i=0; i<256; i++)
94
        {
95
          lval = 0;
96
          for (bit=0; bit<8; bit++)
97
            if (i >= level[bit])
98
              lval |= 1<<bit;
99
          led = lval;
100
        }
101
#define N 1
102
    for (i=0; i<8; i++)
103
      if (level[i] != 256)
104
        {
105
          if (level[i] > 0)
106
            level[i] -= N;
107
          else
108
            level[i] = 0;
109
        }
110
    }
111
}
112
 
113
void start( void )
114
{
115
    int op = 0;
116
    int bright = 255;
117
    cyg_uint32 f0;
118
 
119
#if 0
120
    while ( 1 ) {
121
#else
122
    int z;
123
    for ( z = 0; z < 100; z++ ) {
124
#endif
125
        f0 = 1;
126
        for (op=0; op<nseq; op++) {
127
            HAL_DIAG_WRITE_CHAR( 'A' + op );
128
            level[sequence[op]] = bright;
129
            set_leds();
130
            if ( op ) {
131
                int f1 = fact( op );
132
                f0 *= op;
133
                if ( f0 != f1 ) {
134
                    while ( 1 ) {
135
                        led = op;
136
                        CYG_TEST_FAIL_EXIT( "Factorial wrong" );
137
                    }
138
                }
139
            }
140
        }
141
        HAL_DIAG_WRITE_CHAR( '\n' );
142
        HAL_DIAG_WRITE_CHAR( '\r' );
143
 
144
        CYG_TEST_PASS( "Stack thrashed OK" );
145
    }
146
}
147
 
148
// -------------------------------------------------------------------------
149
 
150
externC void
151
#ifdef CYGPKG_KERNEL
152
cyg_user_start( void )
153
#else
154
cyg_start( void )
155
#endif
156
{
157
    CYG_TEST_INIT();
158
    CYG_TEST_INFO( "cyg_user_start()" );
159
    HAL_ENABLE_INTERRUPTS();
160
    start();
161
    CYG_TEST_EXIT( "LED bibbling and stack thrashing test" );
162
}
163
 
164
// -------------------------------------------------------------------------
165
 
166
/* EOF slebstak.c */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.