klconflib.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #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>
  15. char brick_types[MAX_BRICK_TYPES + 1] = "cri.xdpn%#=vo^kjbf890123456789...";
  16. /*
  17. * Format a module id for printing.
  18. *
  19. * There are three possible formats:
  20. *
  21. * MODULE_FORMAT_BRIEF is the brief 6-character format, including
  22. * the actual brick-type as recorded in the
  23. * moduleid_t, eg. 002c15 for a C-brick, or
  24. * 101#17 for a PX-brick.
  25. *
  26. * MODULE_FORMAT_LONG is the hwgraph format, eg. rack/002/bay/15
  27. * of rack/101/bay/17 (note that the brick
  28. * type does not appear in this format).
  29. *
  30. * MODULE_FORMAT_LCD is like MODULE_FORMAT_BRIEF, except that it
  31. * ensures that the module id provided appears
  32. * exactly as it would on the LCD display of
  33. * the corresponding brick, eg. still 002c15
  34. * for a C-brick, but 101p17 for a PX-brick.
  35. *
  36. * maule (9/13/04): Removed top-level check for (fmt == MODULE_FORMAT_LCD)
  37. * making MODULE_FORMAT_LCD equivalent to MODULE_FORMAT_BRIEF. It was
  38. * decided that all callers should assume the returned string should be what
  39. * is displayed on the brick L1 LCD.
  40. */
  41. void
  42. format_module_id(char *buffer, moduleid_t m, int fmt)
  43. {
  44. int rack, position;
  45. unsigned char brickchar;
  46. rack = MODULE_GET_RACK(m);
  47. brickchar = MODULE_GET_BTCHAR(m);
  48. /* Be sure we use the same brick type character as displayed
  49. * on the brick's LCD
  50. */
  51. switch (brickchar)
  52. {
  53. case L1_BRICKTYPE_GA:
  54. case L1_BRICKTYPE_OPUS_TIO:
  55. brickchar = L1_BRICKTYPE_C;
  56. break;
  57. case L1_BRICKTYPE_PX:
  58. case L1_BRICKTYPE_PE:
  59. case L1_BRICKTYPE_PA:
  60. case L1_BRICKTYPE_SA: /* we can move this to the "I's" later
  61. * if that makes more sense
  62. */
  63. brickchar = L1_BRICKTYPE_P;
  64. break;
  65. case L1_BRICKTYPE_IX:
  66. case L1_BRICKTYPE_IA:
  67. brickchar = L1_BRICKTYPE_I;
  68. break;
  69. }
  70. position = MODULE_GET_BPOS(m);
  71. if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
  72. /* Brief module number format, eg. 002c15 */
  73. /* Decompress the rack number */
  74. *buffer++ = '0' + RACK_GET_CLASS(rack);
  75. *buffer++ = '0' + RACK_GET_GROUP(rack);
  76. *buffer++ = '0' + RACK_GET_NUM(rack);
  77. /* Add the brick type */
  78. *buffer++ = brickchar;
  79. }
  80. else if (fmt == MODULE_FORMAT_LONG) {
  81. /* Fuller hwgraph format, eg. rack/002/bay/15 */
  82. strcpy(buffer, "rack" "/"); buffer += strlen(buffer);
  83. *buffer++ = '0' + RACK_GET_CLASS(rack);
  84. *buffer++ = '0' + RACK_GET_GROUP(rack);
  85. *buffer++ = '0' + RACK_GET_NUM(rack);
  86. strcpy(buffer, "/" "bay" "/"); buffer += strlen(buffer);
  87. }
  88. /* Add the bay position, using at least two digits */
  89. if (position < 10)
  90. *buffer++ = '0';
  91. sprintf(buffer, "%d", position);
  92. }