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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [calmrisc16/] [ceb/] [current/] [src/] [hal_diag.c] - Blame information for rev 834

Go to most recent revision | 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:        1998-03-02
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
}
76
 
77
externC void diag_write_string (const char*);
78
 
79
#ifdef CYG_KERNEL_DIAG_SERIAL
80
extern void cyg_hal_plf_comms_init(void);
81
extern void cyg_hal_plf_serial_putc(void*, cyg_uint8);
82
extern cyg_uint8 cyg_hal_plf_serial_getc(void*);
83
#endif
84
 
85
void hal_diag_init(void)
86
{
87
#if defined(CYGSEM_HAL_ROM_MONITOR) && !defined(CYG_KERNEL_DIAG_SERIAL)
88
  // It's handy to have the LCD initialized at reset when using it
89
  // for debugging output.
90
  // The serial port likely doesn't work yet.  Let's wait.
91
  diag_write_string ("eCos ROM   " __TIME__ "\n");
92
  diag_write_string (__DATE__ "\n");
93
#endif
94
 
95
#if defined(CYG_KERNEL_DIAG_SERIAL)
96
  cyg_hal_plf_comms_init();
97
#endif
98
}
99
 
100
#if defined(CYG_KERNEL_DIAG_LCD)
101
static void hal_diag_clear_lcd(void)
102
{
103
  volatile int i = 0x20000;
104
  while (--i) ;
105
 
106
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, ' ');
107
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, ' ');
108
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, ' ');
109
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, ' ');
110
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, ' ');
111
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, ' ');
112
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, ' ');
113
  HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
114
}
115
#endif /* defined(CYG_KERNEL_DIAG_LCD) */
116
 
117
void hal_diag_write_char(char c)
118
{
119
#if defined(CYG_KERNEL_DIAG_LCD)
120
  static volatile CYG_WORD* reg = HAL_DISPLAY_ASCIIPOS0;
121
#endif
122
 
123
  unsigned long __state;
124
 
125
  HAL_DISABLE_INTERRUPTS(__state);
126
 
127
  if(c == '\n')
128
    {
129
#if defined(CYG_KERNEL_DIAG_LCD)
130
      reg = HAL_DISPLAY_ASCIIPOS0;
131
      hal_diag_clear_lcd();
132
#endif
133
#if defined (CYG_KERNEL_DIAG_SERIAL)
134
      cyg_hal_plf_serial_putc(NULL, '\r');
135
      cyg_hal_plf_serial_putc(NULL, '\n');
136
#endif
137
    }
138
  else if (c == '\r')
139
    {
140
      // Ignore '\r'
141
    }
142
  else
143
    {
144
#if defined(CYG_KERNEL_DIAG_LCD)
145
      if (reg == HAL_DISPLAY_ASCIIPOS0)
146
        hal_diag_clear_lcd();
147
 
148
      HAL_WRITE_UINT32(reg, c);
149
 
150
      // Advance to next LED position.
151
      if (reg == HAL_DISPLAY_ASCIIPOS0)
152
        reg = HAL_DISPLAY_ASCIIPOS1;
153
      else if (reg == HAL_DISPLAY_ASCIIPOS1)
154
        reg = HAL_DISPLAY_ASCIIPOS2;
155
      else if (reg == HAL_DISPLAY_ASCIIPOS2)
156
        reg = HAL_DISPLAY_ASCIIPOS3;
157
      else if (reg == HAL_DISPLAY_ASCIIPOS3)
158
        reg = HAL_DISPLAY_ASCIIPOS4;
159
      else if (reg == HAL_DISPLAY_ASCIIPOS4)
160
        reg = HAL_DISPLAY_ASCIIPOS5;
161
      else if (reg == HAL_DISPLAY_ASCIIPOS5)
162
        reg = HAL_DISPLAY_ASCIIPOS6;
163
      else if (reg == HAL_DISPLAY_ASCIIPOS6)
164
        reg = HAL_DISPLAY_ASCIIPOS7;
165
      else // reg == HAL_DISPLAY_ASCIIPOS7 or UNKNOWN
166
        reg = HAL_DISPLAY_ASCIIPOS0;
167
#endif
168
#if defined(CYG_KERNEL_DIAG_SERIAL)
169
      cyg_hal_plf_serial_putc(NULL, c);
170
#endif
171
    }
172
 
173
  HAL_RESTORE_INTERRUPTS(__state);
174
}
175
 
176
void hal_diag_read_char(char* c)
177
{
178
  *c = cyg_hal_plf_serial_getc(NULL);
179
}
180
 
181
/*---------------------------------------------------------------------------*/
182
/* End of hal_diag.c */

powered by: WebSVN 2.1.0

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