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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [malta/] [current/] [src/] [hal_diag.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/*=============================================================================
2
//
3
//      hal_diag.c
4
//
5
//      HAL diagnostic output code
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):   nickg
43
// Contributors:nickg, dmoseley
44
// Date:        2001-03-20
45
// Purpose:     HAL diagnostic output
46
// Description: Implementations of HAL diagnostic output support.
47
//
48
//####DESCRIPTIONEND####
49
//
50
//===========================================================================*/
51
 
52
#include <pkgconf/hal.h>
53
 
54
#include <cyg/infra/cyg_type.h>         // base types
55
#include <cyg/infra/cyg_trac.h>         // tracing macros
56
#include <cyg/infra/cyg_ass.h>          // assertion macros
57
 
58
#include <cyg/hal/hal_arch.h>
59
#include <cyg/hal/hal_diag.h>
60
 
61
#include <cyg/hal/hal_intr.h>
62
 
63
#include <cyg/hal/hal_io.h>
64
 
65
//-----------------------------------------------------------------------------
66
// Select which diag channels to use
67
 
68
//#define CYG_KERNEL_DIAG_LCD
69
#define CYG_KERNEL_DIAG_SERIAL
70
 
71
/*---------------------------------------------------------------------------*/
72
 
73
void hal_diag_led(int x)
74
{
75
  HAL_WRITE_UINT32(HAL_DISPLAY_LEDBAR, x);
76
#if !defined(CYG_KERNEL_DIAG_LCD)
77
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIWORD, x);
78
#endif
79
}
80
 
81
externC void diag_write_string (const char*);
82
 
83
#ifdef CYG_KERNEL_DIAG_SERIAL
84
extern void cyg_hal_plf_comms_init(void);
85
extern void cyg_hal_plf_serial_putc(void*, cyg_uint8);
86
extern cyg_uint8 cyg_hal_plf_serial_getc(void*);
87
#endif
88
 
89
void hal_diag_init(void)
90
{
91
#if defined(CYGSEM_HAL_ROM_MONITOR) && !defined(CYG_KERNEL_DIAG_SERIAL)
92
  // It's handy to have the LCD initialized at reset when using it
93
  // for debugging output.
94
  // The serial port likely doesn't work yet.  Let's wait.
95
  diag_write_string ("eCos ROM   " __TIME__ "\n");
96
  diag_write_string (__DATE__ "\n");
97
#endif
98
 
99
#if defined(CYG_KERNEL_DIAG_SERIAL)
100
  cyg_hal_plf_comms_init();
101
#endif
102
}
103
 
104
#if defined(CYG_KERNEL_DIAG_LCD)
105
static void hal_diag_clear_lcd(void)
106
{
107
  volatile int i = 0x20000;
108
  while (--i) ;
109
 
110
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, ' ');
111
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, ' ');
112
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, ' ');
113
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, ' ');
114
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, ' ');
115
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, ' ');
116
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, ' ');
117
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
118
}
119
#endif /* defined(CYG_KERNEL_DIAG_LCD) */
120
 
121
void hal_diag_write_char(char c)
122
{
123
#if defined(CYG_KERNEL_DIAG_LCD)
124
  static volatile CYG_WORD* reg = HAL_DISPLAY_ASCIIPOS0;
125
#endif
126
 
127
  unsigned long __state;
128
 
129
  HAL_DISABLE_INTERRUPTS(__state);
130
 
131
  if(c == '\n')
132
    {
133
#if defined(CYG_KERNEL_DIAG_LCD)
134
      reg = HAL_DISPLAY_ASCIIPOS0;
135
      hal_diag_clear_lcd();
136
#endif
137
#if defined (CYG_KERNEL_DIAG_SERIAL)
138
      cyg_hal_plf_serial_putc(NULL, '\r');
139
      cyg_hal_plf_serial_putc(NULL, '\n');
140
#endif
141
    }
142
  else if (c == '\r')
143
    {
144
      // Ignore '\r'
145
    }
146
  else
147
    {
148
#if defined(CYG_KERNEL_DIAG_LCD)
149
      if (reg == HAL_DISPLAY_ASCIIPOS0)
150
        hal_diag_clear_lcd();
151
 
152
      HAL_WRITE_UINT32(reg, c);
153
 
154
      // Advance to next LED position.
155
      if (reg == HAL_DISPLAY_ASCIIPOS0)
156
        reg = HAL_DISPLAY_ASCIIPOS1;
157
      else if (reg == HAL_DISPLAY_ASCIIPOS1)
158
        reg = HAL_DISPLAY_ASCIIPOS2;
159
      else if (reg == HAL_DISPLAY_ASCIIPOS2)
160
        reg = HAL_DISPLAY_ASCIIPOS3;
161
      else if (reg == HAL_DISPLAY_ASCIIPOS3)
162
        reg = HAL_DISPLAY_ASCIIPOS4;
163
      else if (reg == HAL_DISPLAY_ASCIIPOS4)
164
        reg = HAL_DISPLAY_ASCIIPOS5;
165
      else if (reg == HAL_DISPLAY_ASCIIPOS5)
166
        reg = HAL_DISPLAY_ASCIIPOS6;
167
      else if (reg == HAL_DISPLAY_ASCIIPOS6)
168
        reg = HAL_DISPLAY_ASCIIPOS7;
169
      else // reg == HAL_DISPLAY_ASCIIPOS7 or UNKNOWN
170
        reg = HAL_DISPLAY_ASCIIPOS0;
171
#endif
172
#if defined(CYG_KERNEL_DIAG_SERIAL)
173
      cyg_hal_plf_serial_putc(NULL, c);
174
#endif
175
    }
176
 
177
  HAL_RESTORE_INTERRUPTS(__state);
178
}
179
 
180
void hal_diag_read_char(char* c)
181
{
182
  *c = cyg_hal_plf_serial_getc(NULL);
183
}
184
 
185
/*---------------------------------------------------------------------------*/
186
/* End of hal_diag.c */

powered by: WebSVN 2.1.0

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