cpu.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2004 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #include <arch/cpu.h>
00036 #include <cpu.h>
00037 
00038 #include <arch.h>
00039 
00040 #include <arch/cp0.h>
00041 
00042 #include <typedefs.h>
00043 #include <print.h>      
00044 
00045 struct data_t {
00046         char *vendor;
00047         char *model;
00048 };
00049 
00050 static struct data_t imp_data[] = {
00051         { "Invalid", "Invalid" },       /* 0x00 */
00052         { "MIPS", "R2000" },            /* 0x01 */
00053         { "MIPS", "R3000" },            /* 0x02 */
00054         { "MIPS", "R6000" },            /* 0x03 */
00055         { "MIPS", " R4000/R4400" },     /* 0x04 */
00056         { "LSI Logic", "R3000" },       /* 0x05 */
00057         { "MIPS", "R6000A" },           /* 0x06 */
00058         { "IDT", "3051/3052" },         /* 0x07 */
00059         { "Invalid", "Invalid" },       /* 0x08 */
00060         { "MIPS", "R10000/T5" },        /* 0x09 */
00061         { "MIPS", "R4200" },            /* 0x0a */
00062         { "Unknown", "Unknown" },       /* 0x0b */
00063         { "Unknown", "Unknown" },       /* 0x0c */
00064         { "Invalid", "Invalid" },       /* 0x0d */
00065         { "Invalid", "Invalid" },       /* 0x0e */
00066         { "Invalid", "Invalid" },       /* 0x0f */
00067         { "MIPS", "R8000" },            /* 0x10 */
00068         { "Invalid", "Invalid" },       /* 0x11 */
00069         { "Invalid", "Invalid" },       /* 0x12 */
00070         { "Invalid", "Invalid" },       /* 0x13 */
00071         { "Invalid", "Invalid" },       /* 0x14 */
00072         { "Invalid", "Invalid" },       /* 0x15 */
00073         { "Invalid", "Invalid" },       /* 0x16 */
00074         { "Invalid", "Invalid" },       /* 0x17 */
00075         { "Invalid", "Invalid" },       /* 0x18 */
00076         { "Invalid", "Invalid" },       /* 0x19 */
00077         { "Invalid", "Invalid" },       /* 0x1a */
00078         { "Invalid", "Invalid" },       /* 0x1b */
00079         { "Invalid", "Invalid" },       /* 0x1c */
00080         { "Invalid", "Invalid" },       /* 0x1d */
00081         { "Invalid", "Invalid" },       /* 0x1e */
00082         { "Invalid", "Invalid" },       /* 0x1f */
00083         { "QED", "R4600" },             /* 0x20 */
00084         { "Sony", "R3000" },            /* 0x21 */
00085         { "Toshiba", "R3000" },         /* 0x22 */
00086         { "NKK", "R3000" },             /* 0x23 */
00087         { NULL, NULL }
00088 };
00089 
00090 static struct data_t imp_data80[] = {
00091         { "MIPS", "4Kc" },  /* 0x80 */
00092         {"Invalid","Invalid"}, /* 0x81 */
00093         {"Invalid","Invalid"}, /* 0x82 */
00094         {"MIPS","4Km & 4Kp"}, /* 0x83 */
00095         { NULL, NULL}
00096 };
00097 
00098 void cpu_arch_init(void)
00099 {
00100 }
00101 
00102 void cpu_identify(void)
00103 {
00104         CPU->arch.rev_num = cp0_prid_read() & 0xff;
00105         CPU->arch.imp_num = (cp0_prid_read() >> 8) & 0xff;
00106 }
00107 
00108 void cpu_print_report(cpu_t *m)
00109 {
00110         struct data_t *data;
00111         int i;
00112 
00113         if (m->arch.imp_num & 0x80) {
00114                 /* Count records */
00115                 for (i=0;imp_data80[i].vendor;i++)
00116                         ;
00117                 if ((m->arch.imp_num & 0x7f) >= i) {
00118                         printf("imp=%d\n",m->arch.imp_num);
00119                         return;
00120                 }
00121                 data = &imp_data80[m->arch.imp_num & 0x7f];
00122         } else {
00123                 for (i=0;imp_data[i].vendor;i++)
00124                         ;
00125                 if (m->arch.imp_num >= i) {
00126                         printf("imp=%d\n",m->arch.imp_num);
00127                         return;
00128                 }
00129                 data = &imp_data[m->arch.imp_num];
00130         }
00131 
00132         printf("cpu%d: %s %s (rev=%d.%d, imp=%d)\n",
00133                 m->id, data->vendor, data->model, m->arch.rev_num >> 4, 
00134                m->arch.rev_num & 0xf, m->arch.imp_num);
00135 }
00136 

Generated on Sun Jun 18 17:01:58 2006 for HelenOS Kernel (mips32) by  doxygen 1.4.6