3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
7 * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/slab.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/io.h>
14 #include <asm/sn/iograph.h>
15 #include <asm/sn/invent.h>
16 #include <asm/sn/hcl.h>
17 #include <asm/sn/hcl_util.h>
18 #include <asm/sn/labelcl.h>
19 #include <asm/sn/router.h>
20 #include <asm/sn/module.h>
21 #include <asm/sn/ksys/l1.h>
22 #include <asm/sn/nodepda.h>
23 #include <asm/sn/clksupport.h>
24 #include <asm/sn/sn_cpuid.h>
25 #include <asm/sn/sn_sal.h>
26 #include <linux/ctype.h>
28 /* elsc_display_line writes up to 12 characters to either the top or bottom
29 * line of the L1 display. line points to a buffer containing the message
30 * to be displayed. The zero-based line number is specified by lnum (so
31 * lnum == 0 specifies the top line and lnum == 1 specifies the bottom).
32 * Lines longer than 12 characters, or line numbers not less than
33 * L1_DISPLAY_LINES, cause elsc_display_line to return an error.
35 int elsc_display_line(nasid_t nasid, char *line, int lnum)
45 /* iobrick_rack_bay_type_get fills in the three int * arguments with the
46 * rack number, bay number and brick type of the L1 being addressed. Note
47 * that if the L1 operation fails and this function returns an error value,
48 * garbage may be written to brick_type.
52 int iobrick_rack_bay_type_get( nasid_t nasid, uint *rack,
53 uint *bay, uint *brick_type )
57 if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
58 return( ELSC_ERROR_CMD_SEND );
60 *rack = (result & MODULE_RACK_MASK) >> MODULE_RACK_SHFT;
61 *bay = (result & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT;
62 *brick_type = (result & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
63 *brick_type = toupper(*brick_type);
69 int iomoduleid_get(nasid_t nasid)
73 if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
74 return( ELSC_ERROR_CMD_SEND );
79 int iobrick_module_get(nasid_t nasid)
81 uint rnum, rack, bay, brick_type, t;
84 /* construct module ID from rack and slot info */
86 if ((ret = iobrick_rack_bay_type_get(nasid, &rnum, &bay, &brick_type)) < 0)
89 if (bay > MODULE_BPOS_MASK >> MODULE_BPOS_SHFT)
90 return ELSC_ERROR_MODULE;
92 /* Build a moduleid_t-compatible rack number */
95 t = rnum / 100; /* rack class (CPU/IO) */
96 if (t > RACK_CLASS_MASK(rack) >> RACK_CLASS_SHFT(rack))
97 return ELSC_ERROR_MODULE;
98 RACK_ADD_CLASS(rack, t);
101 t = rnum / 10; /* rack group */
102 if (t > RACK_GROUP_MASK(rack) >> RACK_GROUP_SHFT(rack))
103 return ELSC_ERROR_MODULE;
104 RACK_ADD_GROUP(rack, t);
106 t = rnum % 10; /* rack number (one-based) */
107 if (t-1 > RACK_NUM_MASK(rack) >> RACK_NUM_SHFT(rack))
108 return ELSC_ERROR_MODULE;
109 RACK_ADD_NUM(rack, t);
111 switch( brick_type ) {
112 case L1_BRICKTYPE_IX:
113 brick_type = MODULE_IXBRICK; break;
114 case L1_BRICKTYPE_PX:
115 brick_type = MODULE_PXBRICK; break;
117 brick_type = MODULE_IBRICK; break;
119 brick_type = MODULE_PBRICK; break;
121 brick_type = MODULE_XBRICK; break;
124 ret = RBT_TO_MODULE(rack, bay, brick_type);
130 * iobrick_module_get_nasid() returns a module_id which has the brick
131 * type encoded in bits 15-12, but this is not the true brick type...
132 * The module_id returned by iobrick_module_get_nasid() is modified
133 * to make a PEBRICKs & PXBRICKs look like a PBRICK. So this routine
134 * iobrick_type_get_nasid() returns the true unmodified brick type.
137 iobrick_type_get_nasid(nasid_t nasid)
139 uint rack, bay, type;
141 extern char brick_types[];
143 if ((ret = iobrick_rack_bay_type_get(nasid, &rack, &bay, &type)) < 0) {
147 /* convert brick_type to lower case */
148 if ((type >= 'A') && (type <= 'Z'))
149 type = type - 'A' + 'a';
151 /* convert to a module.h brick type */
152 for( t = 0; t < MAX_BRICK_TYPES; t++ ) {
153 if( brick_types[t] == type ) {
158 return -1; /* unknown brick */
161 int iobrick_module_get_nasid(nasid_t nasid)
165 io_moduleid = iobrick_module_get(nasid);
170 * given a L1 bricktype, return a bricktype string. This string is the
171 * string that will be used in the hwpath for I/O bricks
174 iobrick_L1bricktype_to_name(int type)
190 case L1_BRICKTYPE_PX:
193 case L1_BRICKTYPE_IX: