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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [xscale/] [iq80321/] [v2_0/] [src/] [diag/] [io_utils.c] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
//=============================================================================
2
//
3
//      io_utils.c - Cyclone Diagnostics
4
//
5
//=============================================================================
6
//####ECOSGPLCOPYRIGHTBEGIN####
7
// -------------------------------------------
8
// This file is part of eCos, the Embedded Configurable Operating System.
9
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
10
//
11
// eCos is free software; you can redistribute it and/or modify it under
12
// the terms of the GNU General Public License as published by the Free
13
// Software Foundation; either version 2 or (at your option) any later version.
14
//
15
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18
// for more details.
19
//
20
// You should have received a copy of the GNU General Public License along
21
// with eCos; if not, write to the Free Software Foundation, Inc.,
22
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23
//
24
// As a special exception, if other files instantiate templates or use macros
25
// or inline functions from this file, or you compile this file and link it
26
// with other works to produce a work based on this file, this file does not
27
// by itself cause the resulting work to be covered by the GNU General Public
28
// License. However the source code for this file must still be made available
29
// in accordance with section (3) of the GNU General Public License.
30
//
31
// This exception does not invalidate any other reasons why a work based on
32
// this file might be covered by the GNU General Public License.
33
//
34
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35
// at http://sources.redhat.com/ecos/ecos-license/
36
// -------------------------------------------
37
//####ECOSGPLCOPYRIGHTEND####
38
//=============================================================================
39
//#####DESCRIPTIONBEGIN####
40
//
41
// Author(s):   Scott Coulter, Jeff Frazier, Eric Breeden
42
// Contributors: Mark Salter
43
// Date:        2001-01-25
44
// Purpose:     
45
// Description: 
46
//
47
//####DESCRIPTIONEND####
48
//
49
//===========================================================================*/
50
 
51
/*
52
 * i/o routines for tests.  Greg Ames, 9/17/90.
53
 *
54
 * Version: @(#)test_io.c       1.2 8/26/93
55
 */
56
#include <redboot.h>
57
 
58
/* Returns true if theChar is a valid hex digit, false if not */
59
int
60
diag_ishex(char theChar)
61
{
62
    switch(theChar) {
63
      case '0':
64
      case '1':
65
      case '2':
66
      case '3':
67
      case '4':
68
      case '5':
69
      case '6':
70
      case '7':
71
      case '8':
72
      case '9':
73
      case 'A':
74
      case 'a':
75
      case 'B':
76
      case 'b':
77
      case 'C':
78
      case 'c':
79
      case 'D':
80
      case 'd':
81
      case 'E':
82
      case 'e':
83
      case 'F':
84
      case 'f':
85
        return 1;
86
      default:
87
        return 0;
88
    }
89
}
90
 
91
/* Convert ascii code of hex digit to number (0-15) */
92
int
93
diag_hex2dec(char hex)
94
{
95
    if ((hex >= '0') && (hex <= '9'))
96
        return hex - '0';
97
    else if ((hex >= 'a') && (hex <= 'f'))
98
        return hex - 'a' + 10;
99
    else
100
        return hex - 'A' + 10;
101
}
102
 
103
/* Input a number as (at most 8) hex digits - returns value entered */
104
CYG_ADDRWORD
105
hexIn(void)
106
{
107
    char input[40], *p;
108
    CYG_ADDRWORD num;
109
 
110
    while (_rb_gets(input, sizeof(input), 0) != _GETS_OK)
111
        ;
112
 
113
    for (num = 0, p = input; diag_ishex(*p); p++)
114
        num = num*16 + diag_hex2dec(*p);
115
 
116
    return num;
117
}
118
 
119
 
120
/* Input a number as decimal digits - returns value entered */
121
CYG_ADDRWORD
122
decIn(void)
123
{
124
    char input[40], *p;
125
    CYG_ADDRWORD num;
126
 
127
    while (_rb_gets(input, sizeof(input), 0) != _GETS_OK)
128
        ;
129
 
130
    for (num = 0, p = input; '0' <= *p && *p <= '9'; p++)
131
        num = num*10 + (*p - '0');
132
 
133
    return num;
134
}
135
 

powered by: WebSVN 2.1.0

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