ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/Solaris/which_sparc
Revision: 1.1
Committed: 1999-10-21T13:19:26Z (25 years ago) by cebix
Branch: MAIN
Log Message:
- added fbdev video code and SPARC assembly optimizations

File Contents

# User Rev Content
1 cebix 1.1 #!/bin/sh
2    
3     # WHICH_SPARC
4     #
5     # This script generates a program that tests for a SPARC processor class
6     # Program returns:
7     # 0 unknown SPARC processor
8     # 8 SPARC V8 `compliant' processor (umul instruction is legal)
9     # 9 SPARC V9 `compliant' processor (popc instruction is legal)
10     #
11     # I hope this works for other machines and OS. Tested machines are:
12     # Sun Ultra 10 (Solaris 7), SPARC Station 5 (Solaris 2.5.1)
13     #
14     # Gwenole Beauchesne
15     # gb@dial.oleane.com
16    
17     CC=gcc
18     PROG=./conftest
19     SOURCE=./conftest.c
20    
21     if [ ! -x $PROG ]; then
22     echo "Compiling the test program"
23     cat > $SOURCE << EOF
24     #include <stdio.h>
25     #include <signal.h>
26    
27     typedef unsigned int uint32;
28     typedef uint32 (*sparc_code_func)(void);
29    
30     #define SPARC_UNKNOWN 0
31     #define SPARC_V8 8
32     #define SPARC_V9 9
33    
34     #define MAX_CODE_SIZE 16
35     struct sparc_code_struct {
36     int version;
37     uint32 code[MAX_CODE_SIZE];
38     struct sparc_code_struct * next;
39     };
40     typedef struct sparc_code_struct sparc_code_struct;
41    
42     static sparc_code_struct *current_test_code;
43    
44     static sparc_code_struct unknown_sparc_code =
45     {
46     SPARC_UNKNOWN,
47     {
48     0x81C3E008, /* retl */
49     0x01000000 /* nop */
50     }
51     };
52    
53     static sparc_code_struct sparc_v9_code =
54     {
55     SPARC_V9,
56     {
57     0x81C3E008, /* retl */
58     0x81702007 /* popc 7, %g0 */
59     }
60     };
61    
62     static sparc_code_struct sparc_v8_code =
63     {
64     SPARC_V8,
65     {
66     0x90102002, /* mov 2, %o0 */
67     0x81C3E008, /* retl */
68     0x90520008 /* umul %o0, %o0, %o0 */
69     }
70     };
71    
72     static void test_sparc_code(int unused_int)
73     {
74     sparc_code_struct *tested_code = current_test_code;
75    
76     if (current_test_code == NULL)
77     exit(SPARC_UNKNOWN);
78    
79     signal(SIGILL, test_sparc_code);
80     current_test_code = current_test_code->next;
81     (void) ((sparc_code_func)(tested_code->code))();
82     exit(tested_code->version);
83     }
84    
85     int main(void)
86     {
87     sparc_v9_code.next = &sparc_v8_code;
88     sparc_v8_code.next = &unknown_sparc_code;
89     unknown_sparc_code.next = NULL;
90    
91     signal(SIGILL, test_sparc_code);
92     current_test_code = &sparc_v9_code;
93     raise(SIGILL);
94    
95     return 0;
96     }
97     EOF
98    
99     $CC -o $PROG $SOURCE
100     if [ $? -ne 0 ]; then
101     echo "Error: could not compile the test program"
102     exit 1
103     fi
104    
105     fi
106    
107     $PROG
108     case $? in
109     0) echo "unknown SPARC architecture";;
110     8) echo "SPARC V8 compliant processor";;
111     9) echo "SPARC V9 compliant processor";;
112     esac
113    
114     rm -f $PROG
115     rm -f $SOURCE
116    
117     exit 0