Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
klconflib.c
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License. See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.
7  */
8 
9 #include <linux/types.h>
10 #include <linux/ctype.h>
11 #include <linux/string.h>
12 #include <linux/kernel.h>
13 #include <asm/sn/types.h>
14 #include <asm/sn/module.h>
15 #include <asm/sn/l1.h>
16 
17 char brick_types[MAX_BRICK_TYPES + 1] = "cri.xdpn%#=vo^kjbf890123456789...";
18 /*
19  * Format a module id for printing.
20  *
21  * There are three possible formats:
22  *
23  * MODULE_FORMAT_BRIEF is the brief 6-character format, including
24  * the actual brick-type as recorded in the
25  * moduleid_t, eg. 002c15 for a C-brick, or
26  * 101#17 for a PX-brick.
27  *
28  * MODULE_FORMAT_LONG is the hwgraph format, eg. rack/002/bay/15
29  * of rack/101/bay/17 (note that the brick
30  * type does not appear in this format).
31  *
32  * MODULE_FORMAT_LCD is like MODULE_FORMAT_BRIEF, except that it
33  * ensures that the module id provided appears
34  * exactly as it would on the LCD display of
35  * the corresponding brick, eg. still 002c15
36  * for a C-brick, but 101p17 for a PX-brick.
37  *
38  * maule (9/13/04): Removed top-level check for (fmt == MODULE_FORMAT_LCD)
39  * making MODULE_FORMAT_LCD equivalent to MODULE_FORMAT_BRIEF. It was
40  * decided that all callers should assume the returned string should be what
41  * is displayed on the brick L1 LCD.
42  */
43 void
45 {
46  int rack, position;
47  unsigned char brickchar;
48 
49  rack = MODULE_GET_RACK(m);
50  brickchar = MODULE_GET_BTCHAR(m);
51 
52  /* Be sure we use the same brick type character as displayed
53  * on the brick's LCD
54  */
55  switch (brickchar)
56  {
57  case L1_BRICKTYPE_GA:
59  brickchar = L1_BRICKTYPE_C;
60  break;
61 
62  case L1_BRICKTYPE_PX:
63  case L1_BRICKTYPE_PE:
64  case L1_BRICKTYPE_PA:
65  case L1_BRICKTYPE_SA: /* we can move this to the "I's" later
66  * if that makes more sense
67  */
68  brickchar = L1_BRICKTYPE_P;
69  break;
70 
71  case L1_BRICKTYPE_IX:
72  case L1_BRICKTYPE_IA:
73 
74  brickchar = L1_BRICKTYPE_I;
75  break;
76  }
77 
78  position = MODULE_GET_BPOS(m);
79 
80  if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
81  /* Brief module number format, eg. 002c15 */
82 
83  /* Decompress the rack number */
84  *buffer++ = '0' + RACK_GET_CLASS(rack);
85  *buffer++ = '0' + RACK_GET_GROUP(rack);
86  *buffer++ = '0' + RACK_GET_NUM(rack);
87 
88  /* Add the brick type */
89  *buffer++ = brickchar;
90  }
91  else if (fmt == MODULE_FORMAT_LONG) {
92  /* Fuller hwgraph format, eg. rack/002/bay/15 */
93 
94  strcpy(buffer, "rack" "/"); buffer += strlen(buffer);
95 
96  *buffer++ = '0' + RACK_GET_CLASS(rack);
97  *buffer++ = '0' + RACK_GET_GROUP(rack);
98  *buffer++ = '0' + RACK_GET_NUM(rack);
99 
100  strcpy(buffer, "/" "bay" "/"); buffer += strlen(buffer);
101  }
102 
103  /* Add the bay position, using at least two digits */
104  if (position < 10)
105  *buffer++ = '0';
106  sprintf(buffer, "%d", position);
107 }