/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved.6*/78#include <linux/types.h>9#include <linux/ctype.h>10#include <linux/string.h>11#include <linux/kernel.h>12#include <asm/sn/types.h>13#include <asm/sn/module.h>14#include <asm/sn/l1.h>1516char brick_types[MAX_BRICK_TYPES + 1] = "cri.xdpn%#=vo^kjbf890123456789...";17/*18* Format a module id for printing.19*20* There are three possible formats:21*22* MODULE_FORMAT_BRIEF is the brief 6-character format, including23* the actual brick-type as recorded in the24* moduleid_t, eg. 002c15 for a C-brick, or25* 101#17 for a PX-brick.26*27* MODULE_FORMAT_LONG is the hwgraph format, eg. rack/002/bay/1528* of rack/101/bay/17 (note that the brick29* type does not appear in this format).30*31* MODULE_FORMAT_LCD is like MODULE_FORMAT_BRIEF, except that it32* ensures that the module id provided appears33* exactly as it would on the LCD display of34* the corresponding brick, eg. still 002c1535* for a C-brick, but 101p17 for a PX-brick.36*37* maule (9/13/04): Removed top-level check for (fmt == MODULE_FORMAT_LCD)38* making MODULE_FORMAT_LCD equivalent to MODULE_FORMAT_BRIEF. It was39* decided that all callers should assume the returned string should be what40* is displayed on the brick L1 LCD.41*/42void43format_module_id(char *buffer, moduleid_t m, int fmt)44{45int rack, position;46unsigned char brickchar;4748rack = MODULE_GET_RACK(m);49brickchar = MODULE_GET_BTCHAR(m);5051/* Be sure we use the same brick type character as displayed52* on the brick's LCD53*/54switch (brickchar)55{56case L1_BRICKTYPE_GA:57case L1_BRICKTYPE_OPUS_TIO:58brickchar = L1_BRICKTYPE_C;59break;6061case L1_BRICKTYPE_PX:62case L1_BRICKTYPE_PE:63case L1_BRICKTYPE_PA:64case L1_BRICKTYPE_SA: /* we can move this to the "I's" later65* if that makes more sense66*/67brickchar = L1_BRICKTYPE_P;68break;6970case L1_BRICKTYPE_IX:71case L1_BRICKTYPE_IA:7273brickchar = L1_BRICKTYPE_I;74break;75}7677position = MODULE_GET_BPOS(m);7879if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {80/* Brief module number format, eg. 002c15 */8182/* Decompress the rack number */83*buffer++ = '0' + RACK_GET_CLASS(rack);84*buffer++ = '0' + RACK_GET_GROUP(rack);85*buffer++ = '0' + RACK_GET_NUM(rack);8687/* Add the brick type */88*buffer++ = brickchar;89}90else if (fmt == MODULE_FORMAT_LONG) {91/* Fuller hwgraph format, eg. rack/002/bay/15 */9293strcpy(buffer, "rack" "/"); buffer += strlen(buffer);9495*buffer++ = '0' + RACK_GET_CLASS(rack);96*buffer++ = '0' + RACK_GET_GROUP(rack);97*buffer++ = '0' + RACK_GET_NUM(rack);9899strcpy(buffer, "/" "bay" "/"); buffer += strlen(buffer);100}101102/* Add the bay position, using at least two digits */103if (position < 10)104*buffer++ = '0';105sprintf(buffer, "%d", position);106}107108109