Subversion Repositories HelenOS-historic

Rev

Rev 610 | Rev 1705 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (C) 2003-2004 Jakub Jermar
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29.  /** @addtogroup mips32cpu mips32
  30.  * @ingroup cpu
  31.  * @{
  32.  */
  33. /** @file
  34.  */
  35.  
  36. #include <arch/cpu.h>
  37. #include <cpu.h>
  38.  
  39. #include <arch.h>
  40.  
  41. #include <arch/cp0.h>
  42.  
  43. #include <typedefs.h>
  44. #include <print.h> 
  45.  
  46. struct data_t {
  47.     char *vendor;
  48.     char *model;
  49. };
  50.  
  51. static struct data_t imp_data[] = {
  52.     { "Invalid", "Invalid" },   /* 0x00 */
  53.     { "MIPS", "R2000" },        /* 0x01 */
  54.     { "MIPS", "R3000" },        /* 0x02 */
  55.     { "MIPS", "R6000" },        /* 0x03 */
  56.     { "MIPS", " R4000/R4400" },     /* 0x04 */
  57.     { "LSI Logic", "R3000" },   /* 0x05 */
  58.     { "MIPS", "R6000A" },       /* 0x06 */
  59.     { "IDT", "3051/3052" },     /* 0x07 */
  60.     { "Invalid", "Invalid" },   /* 0x08 */
  61.     { "MIPS", "R10000/T5" },    /* 0x09 */
  62.     { "MIPS", "R4200" },        /* 0x0a */
  63.     { "Unknown", "Unknown" },   /* 0x0b */
  64.     { "Unknown", "Unknown" },   /* 0x0c */
  65.     { "Invalid", "Invalid" },   /* 0x0d */
  66.     { "Invalid", "Invalid" },   /* 0x0e */
  67.     { "Invalid", "Invalid" },   /* 0x0f */
  68.     { "MIPS", "R8000" },        /* 0x10 */
  69.     { "Invalid", "Invalid" },   /* 0x11 */
  70.     { "Invalid", "Invalid" },   /* 0x12 */
  71.     { "Invalid", "Invalid" },   /* 0x13 */
  72.     { "Invalid", "Invalid" },   /* 0x14 */
  73.     { "Invalid", "Invalid" },   /* 0x15 */
  74.     { "Invalid", "Invalid" },   /* 0x16 */
  75.     { "Invalid", "Invalid" },   /* 0x17 */
  76.     { "Invalid", "Invalid" },   /* 0x18 */
  77.     { "Invalid", "Invalid" },   /* 0x19 */
  78.     { "Invalid", "Invalid" },   /* 0x1a */
  79.     { "Invalid", "Invalid" },   /* 0x1b */
  80.     { "Invalid", "Invalid" },   /* 0x1c */
  81.     { "Invalid", "Invalid" },   /* 0x1d */
  82.     { "Invalid", "Invalid" },   /* 0x1e */
  83.     { "Invalid", "Invalid" },   /* 0x1f */
  84.     { "QED", "R4600" },     /* 0x20 */
  85.     { "Sony", "R3000" },        /* 0x21 */
  86.     { "Toshiba", "R3000" },     /* 0x22 */
  87.     { "NKK", "R3000" },     /* 0x23 */
  88.     { NULL, NULL }
  89. };
  90.  
  91. static struct data_t imp_data80[] = {
  92.     { "MIPS", "4Kc" },  /* 0x80 */
  93.     {"Invalid","Invalid"}, /* 0x81 */
  94.     {"Invalid","Invalid"}, /* 0x82 */
  95.     {"MIPS","4Km & 4Kp"}, /* 0x83 */
  96.     { NULL, NULL}
  97. };
  98.  
  99. void cpu_arch_init(void)
  100. {
  101. }
  102.  
  103. void cpu_identify(void)
  104. {
  105.     CPU->arch.rev_num = cp0_prid_read() & 0xff;
  106.     CPU->arch.imp_num = (cp0_prid_read() >> 8) & 0xff;
  107. }
  108.  
  109. void cpu_print_report(cpu_t *m)
  110. {
  111.     struct data_t *data;
  112.     int i;
  113.  
  114.     if (m->arch.imp_num & 0x80) {
  115.         /* Count records */
  116.         for (i=0;imp_data80[i].vendor;i++)
  117.             ;
  118.         if ((m->arch.imp_num & 0x7f) >= i) {
  119.             printf("imp=%d\n",m->arch.imp_num);
  120.             return;
  121.         }
  122.         data = &imp_data80[m->arch.imp_num & 0x7f];
  123.     } else {
  124.         for (i=0;imp_data[i].vendor;i++)
  125.             ;
  126.         if (m->arch.imp_num >= i) {
  127.             printf("imp=%d\n",m->arch.imp_num);
  128.             return;
  129.         }
  130.         data = &imp_data[m->arch.imp_num];
  131.     }
  132.  
  133.     printf("cpu%d: %s %s (rev=%d.%d, imp=%d)\n",
  134.         m->id, data->vendor, data->model, m->arch.rev_num >> 4,
  135.            m->arch.rev_num & 0xf, m->arch.imp_num);
  136. }
  137.  
  138.  /** @}
  139.  */
  140.  
  141.