fix build error
[platform/upstream/openblas.git] / cpuid_ia64.c
1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin.           */
3 /* All rights reserved.                                              */
4 /*                                                                   */
5 /* Redistribution and use in source and binary forms, with or        */
6 /* without modification, are permitted provided that the following   */
7 /* conditions are met:                                               */
8 /*                                                                   */
9 /*   1. Redistributions of source code must retain the above         */
10 /*      copyright notice, this list of conditions and the following  */
11 /*      disclaimer.                                                  */
12 /*                                                                   */
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.                              */
17 /*                                                                   */
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.                                    */
32 /*                                                                   */
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 /*********************************************************************/
38
39 #include <stdio.h>
40 #include <string.h>
41 #include <sys/sysinfo.h>
42 #include "cpuid.h"
43
44 #ifdef __ECC
45 #include <ia64intrin.h>
46 #endif
47
48 static inline unsigned long cpuid(unsigned long regnum){
49   unsigned long value;
50
51 #ifdef __ECC
52   value = __getIndReg(_IA64_REG_INDR_CPUID, regnum);
53 #else
54   asm ("mov %0=cpuid[%r1]" : "=r"(value) : "rO"(regnum));
55 #endif
56
57   return value;
58 }
59
60 int have_cpuid(void){ return 1;}
61
62 int get_vendor(void){
63   unsigned long cpuid0, cpuid1;
64   char vendor[18];
65
66   cpuid0 = cpuid(0);
67   cpuid1 = cpuid(1);
68
69   *(unsigned long *)(&vendor[0]) = cpuid0;
70   *(unsigned long *)(&vendor[8]) = cpuid1;
71   vendor[17] = (char)0;
72
73   if (!strcmp(vendor, "GenuineIntel")) return VENDOR_INTEL;
74
75   return VENDOR_UNKNOWN;
76 }
77
78 int get_cputype(int gettype){
79   unsigned long cpuid3;
80
81   cpuid3 = cpuid(3);
82
83   switch (gettype) {
84   case GET_ARCHREV :
85     return BITMASK(cpuid3, 32, 0xff);
86   case GET_FAMILY :
87     return BITMASK(cpuid3, 24, 0xff);
88   case GET_MODEL :
89     return BITMASK(cpuid3, 16, 0xff);
90   case GET_REVISION :
91     return BITMASK(cpuid3,  8, 0xff);
92   case GET_NUMBER :
93     return BITMASK(cpuid3,  0, 0xff);
94   }
95
96   return 0;
97 }
98
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";
103
104   return "UNKNOWN";
105 }
106
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;}
111
112   printf("UNKNOWN");
113
114   return NULL;
115 }
116
117 void get_architecture(void){
118   printf("IA64");
119 }
120
121 void get_subarchitecture(void){
122     printf("%s", get_cpunamechar());
123 }
124
125 void get_subdirname(void){
126     printf("ia64");
127 }
128
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");
137 }
138