1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
13 /* 2. Redistributions in binary form must reproduce the above */
14 /* copyright notice, this list of conditions and the following */
15 /* disclaimer in the documentation and/or other materials */
16 /* provided with the distribution. */
18 /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19 /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23 /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27 /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30 /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31 /* POSSIBILITY OF SUCH DAMAGE. */
33 /* The views and conclusions contained in the software and */
34 /* documentation are those of the authors and should not be */
35 /* interpreted as representing official policies, either expressed */
36 /* or implied, of The University of Texas at Austin. */
37 /*********************************************************************/
41 #include <sys/sysinfo.h>
45 #include <ia64intrin.h>
48 static inline unsigned long cpuid(unsigned long regnum){
52 value = __getIndReg(_IA64_REG_INDR_CPUID, regnum);
54 asm ("mov %0=cpuid[%r1]" : "=r"(value) : "rO"(regnum));
60 int have_cpuid(void){ return 1;}
63 unsigned long cpuid0, cpuid1;
69 *(unsigned long *)(&vendor[0]) = cpuid0;
70 *(unsigned long *)(&vendor[8]) = cpuid1;
73 if (!strcmp(vendor, "GenuineIntel")) return VENDOR_INTEL;
75 return VENDOR_UNKNOWN;
78 int get_cputype(int gettype){
85 return BITMASK(cpuid3, 32, 0xff);
87 return BITMASK(cpuid3, 24, 0xff);
89 return BITMASK(cpuid3, 16, 0xff);
91 return BITMASK(cpuid3, 8, 0xff);
93 return BITMASK(cpuid3, 0, 0xff);
99 char *get_cpunamechar(void){
100 if (get_cputype(GET_FAMILY) == 0x07) return "ITANIUM";
101 if (get_cputype(GET_FAMILY) == 0x1f) return "ITANIUM2";
102 if (get_cputype(GET_FAMILY) == 0x20) return "ITANIUM2";
107 char *get_libname(void){
108 if (get_cputype(GET_FAMILY) == 0x07) { printf("itanium"); return NULL;}
109 if (get_cputype(GET_FAMILY) == 0x1f) { printf("itanium2"); return NULL;}
110 if (get_cputype(GET_FAMILY) == 0x20) { printf("itanium2"); return NULL;}
117 void get_architecture(void){
121 void get_subarchitecture(void){
122 printf("%s", get_cpunamechar());
125 void get_subdirname(void){
129 void get_cpuconfig(void){
130 printf("#define %s\n", get_cpunamechar());
131 printf("#define L1_DATA_SIZE 262144\n");
132 printf("#define L1_DATA_LINESIZE 128\n");
133 printf("#define L2_SIZE 1572864\n");
134 printf("#define L2_LINESIZE 128\n");
135 printf("#define DTB_SIZE 16384\n");
136 printf("#define DTB_DEFAULT_ENTRIES 128\n");