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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sparclite/] [sleb/] [v2_0/] [tests/] [slebstak.c] - Blame information for rev 214

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

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

powered by: WebSVN 2.1.0

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