aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/sn/io/sn2/l1_command.c
blob: 280d2bb2ad02b31bd4ce94caf3ae913f1e413c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* $Id$
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
 */ 

#include <linux/types.h>
#include <linux/slab.h>
#include <asm/sn/sgi.h>
#include <asm/sn/io.h>
#include <asm/sn/iograph.h>
#include <asm/sn/invent.h>
#include <asm/sn/hcl.h>
#include <asm/sn/hcl_util.h>
#include <asm/sn/labelcl.h>
#include <asm/sn/router.h>
#include <asm/sn/module.h>
#include <asm/sn/ksys/l1.h>
#include <asm/sn/nodepda.h>
#include <asm/sn/clksupport.h>
#include <asm/sn/sn_cpuid.h>
#include <asm/sn/sn_sal.h>
#include <linux/ctype.h>

/* elsc_display_line writes up to 12 characters to either the top or bottom
 * line of the L1 display.  line points to a buffer containing the message
 * to be displayed.  The zero-based line number is specified by lnum (so
 * lnum == 0 specifies the top line and lnum == 1 specifies the bottom).
 * Lines longer than 12 characters, or line numbers not less than
 * L1_DISPLAY_LINES, cause elsc_display_line to return an error.
 */
int elsc_display_line(nasid_t nasid, char *line, int lnum)
{
    return 0;
}


/*
 * iobrick routines
 */

/* iobrick_rack_bay_type_get fills in the three int * arguments with the
 * rack number, bay number and brick type of the L1 being addressed.  Note
 * that if the L1 operation fails and this function returns an error value, 
 * garbage may be written to brick_type.
 */


int iobrick_rack_bay_type_get( nasid_t nasid, uint *rack, 
			       uint *bay, uint *brick_type )
{
	int result = 0;

	if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
		return( ELSC_ERROR_CMD_SEND );

	*rack = (result & MODULE_RACK_MASK) >> MODULE_RACK_SHFT;
	*bay = (result & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT;
	*brick_type = (result & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
	*brick_type = toupper(*brick_type);

	return 0;
}


int iomoduleid_get(nasid_t nasid)
{
	int result = 0;

	if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
		return( ELSC_ERROR_CMD_SEND );

	return result;
}

int iobrick_module_get(nasid_t nasid)
{
    uint rnum, rack, bay, brick_type, t;
    int ret;

    /* construct module ID from rack and slot info */

    if ((ret = iobrick_rack_bay_type_get(nasid, &rnum, &bay, &brick_type)) < 0)
        return ret;

    if (bay > MODULE_BPOS_MASK >> MODULE_BPOS_SHFT)
        return ELSC_ERROR_MODULE;

    /* Build a moduleid_t-compatible rack number */

    rack = 0;           
    t = rnum / 100;             /* rack class (CPU/IO) */
    if (t > RACK_CLASS_MASK(rack) >> RACK_CLASS_SHFT(rack))
        return ELSC_ERROR_MODULE;
    RACK_ADD_CLASS(rack, t);
    rnum %= 100;

    t = rnum / 10;              /* rack group */
    if (t > RACK_GROUP_MASK(rack) >> RACK_GROUP_SHFT(rack))
        return ELSC_ERROR_MODULE;
    RACK_ADD_GROUP(rack, t);

    t = rnum % 10;              /* rack number (one-based) */
    if (t-1 > RACK_NUM_MASK(rack) >> RACK_NUM_SHFT(rack))
        return ELSC_ERROR_MODULE;
    RACK_ADD_NUM(rack, t);

    switch( brick_type ) {
      case L1_BRICKTYPE_IX: 
	brick_type = MODULE_IXBRICK; break;
      case L1_BRICKTYPE_PX: 
	brick_type = MODULE_PXBRICK; break;
      case L1_BRICKTYPE_I: 
	brick_type = MODULE_IBRICK; break;
      case L1_BRICKTYPE_P:
	brick_type = MODULE_PBRICK; break;
      case L1_BRICKTYPE_X:
	brick_type = MODULE_XBRICK; break;
    }

    ret = RBT_TO_MODULE(rack, bay, brick_type);

    return ret;
}

/*
 * iobrick_module_get_nasid() returns a module_id which has the brick
 * type encoded in bits 15-12, but this is not the true brick type...
 * The module_id returned by iobrick_module_get_nasid() is modified
 * to make a PEBRICKs & PXBRICKs look like a PBRICK.  So this routine
 * iobrick_type_get_nasid() returns the true unmodified brick type.
 */
int
iobrick_type_get_nasid(nasid_t nasid)
{
    uint rack, bay, type;
    int t, ret;
    extern char brick_types[];

    if ((ret = iobrick_rack_bay_type_get(nasid, &rack, &bay, &type)) < 0) {
        return ret;
    }

    /* convert brick_type to lower case */
    if ((type >= 'A') && (type <= 'Z'))
        type = type - 'A' + 'a';

    /* convert to a module.h brick type */
    for( t = 0; t < MAX_BRICK_TYPES; t++ ) {
        if( brick_types[t] == type ) {
            return t;
	}
    }

    return -1;    /* unknown brick */
}

int iobrick_module_get_nasid(nasid_t nasid)
{
    int io_moduleid;

    io_moduleid = iobrick_module_get(nasid);
    return io_moduleid;
}

/*
 * given a L1 bricktype, return a bricktype string.  This string is the
 * string that will be used in the hwpath for I/O bricks
 */
char *
iobrick_L1bricktype_to_name(int type)
{
    switch (type)
    {
    default:
        return("Unknown");

    case L1_BRICKTYPE_X:
        return("Xbrick");

    case L1_BRICKTYPE_I:
        return("Ibrick");

    case L1_BRICKTYPE_P:
        return("Pbrick");

    case L1_BRICKTYPE_PX:
        return("PXbrick");

    case L1_BRICKTYPE_IX:
        return("IXbrick");

    case L1_BRICKTYPE_C:
        return("Cbrick");

    case L1_BRICKTYPE_R:
        return("Rbrick");
    }
}