1 /* $NetBSD: systeminfo.c,v 1.3 2000/01/16 03:07:33 takemura Exp $ */
2 
3 /*
4  * Copyright (c) 1999, by UCHIYAMA Yasushi
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. The name of the developer may NOT be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 #include <pbsdboot.h>
29 #include <machine/platid_mask.h>
30 #if 0
31 #define PROCESSOR_LEVEL_R4000 4
32 #define PROCESSOR_LEVEL_R3000 3
33 #define PROCESSOR_REVMAJOR_VR41XX 0x0c
34 #define PROCESSOR_REVMAJOR_TX39XX 0x22
35 #endif
36 
37 struct system_info system_info;
38 
39 static void dump_archinfo(SYSTEM_INFO*);
40 
41 int
set_system_info(platid_t * platid)42 set_system_info(platid_t *platid)
43 {
44           SYSTEM_INFO info;
45           /*
46            * Set machine dependent information.
47            */
48           GetSystemInfo(&info);
49           if (platid_match(platid, &platid_mask_CPU_MIPS)) {
50                     if (platid_match(platid, &platid_mask_CPU_MIPS_VR_41XX)) {
51                               vr41xx_init(&info);
52                     } else
53                     if (platid_match(platid, &platid_mask_CPU_MIPS_TX)) {
54                               tx39xx_init(&info);
55                     } else {
56                               dump_archinfo(&info);
57                               return 0;
58                     }
59           } else {
60                     dump_archinfo(&info);
61                     return 0;
62           }
63 
64 #if 0
65           switch (info.wProcessorArchitecture) {
66           default:
67                     dump_archinfo(&info);
68                     return 0;
69                     break;
70           case PROCESSOR_ARCHITECTURE_MIPS:
71                     switch (info.wProcessorLevel) {
72                     default:
73                               dump_archinfo(&info);
74                               return 0;
75                               break;
76                     case PROCESSOR_LEVEL_R4000:
77                               switch (info.wProcessorRevision >> 8) {
78                               default:
79                                         dump_archinfo(&info);
80                                         return 0;
81                                         break;
82                               case PROCESSOR_REVMAJOR_VR41XX:
83                                         vr41xx_init(&info);
84                                         break;
85                               }
86                               break;
87                     case PROCESSOR_LEVEL_R3000:
88                               switch (info.wProcessorRevision >> 8) {
89                               default:
90                                         dump_archinfo(&info);
91                                         return 0;
92                                         break;
93                               case PROCESSOR_REVMAJOR_TX39XX:
94                                         tx39xx_init(&info);
95                                         break;
96                               }
97                               break;
98                     }
99                     break;
100           case PROCESSOR_ARCHITECTURE_SHx:
101                     dump_archinfo(&info);
102                     return 0;
103                     break;
104           case PROCESSOR_ARCHITECTURE_ARM:
105                     dump_archinfo(&info);
106                     return 0;
107                     break;
108           }
109 #endif
110 
111           if (system_info.si_asmcodelen > (signed)system_info.si_pagesize) {
112                     msg_printf(MSG_ERROR, whoami,
113                                  TEXT("asmcodelen=%d > pagesize=%d\n"),
114                                  system_info.si_asmcodelen,
115                                  system_info.si_pagesize);
116                     return 0;
117           }
118 
119           return 1;
120 }
121 
122 static void
dump_archinfo(SYSTEM_INFO * info)123 dump_archinfo(SYSTEM_INFO *info)
124 {
125           msg_printf(MSG_ERROR, whoami, TEXT("Unsupported CPU\n"));
126 #if 0
127           msg_printf(MSG_ERROR, whoami,
128                        TEXT("Unknown machine ARCHITECTURE %#x, LEVEL %#x REVISION %#x.\n LCD(%dx%d)\n"),
129                        info->wProcessorArchitecture, info->wProcessorLevel,
130                        info->wProcessorRevision,
131                        GetSystemMetrics(SM_CXSCREEN),
132                        GetSystemMetrics(SM_CYSCREEN));
133 #endif
134 }
135