Rev 2189 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2189 | Rev 2291 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2007 Michal Kebrt |
2 | * Copyright (c) 2007 Michal Kebrt |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup arm32 |
29 | /** @addtogroup arm32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <arch/cpu.h> |
35 | #include <arch/cpu.h> |
36 | #include <cpu.h> |
36 | #include <cpu.h> |
37 | #include <arch.h> |
37 | #include <arch.h> |
38 | #include <print.h> |
38 | #include <print.h> |
39 | 39 | ||
40 | 40 | ||
41 | /** Implementators (vendor) names */ |
41 | /** Implementators (vendor) names */ |
42 | static char * imp_data[] = { |
42 | static char * imp_data[] = { |
43 | "?", |
43 | "?", |
44 | "ARM Ltd", /* 0x41 */ |
44 | "ARM Ltd", /* 0x41 */ |
45 | "", /* 0x42 */ |
45 | "", /* 0x42 */ |
46 | "", /* 0x43 */ |
46 | "", /* 0x43 */ |
47 | "Digital Equipment Corporation", /* 0x44 */ |
47 | "Digital Equipment Corporation", /* 0x44 */ |
48 | "", "", "", "", "", "", "", "", "", "", "", /* 0x4f */ |
48 | "", "", "", "", "", "", "", "", "", "", "", /* 0x4f */ |
49 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */ |
49 | "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */ |
50 | "", "", "", "", "", "", "", "", "", /* 0x68 */ |
50 | "", "", "", "", "", "", "", "", "", /* 0x68 */ |
51 | "Intel Corporation" /* 0x69 */ |
51 | "Intel Corporation" /* 0x69 */ |
52 | }; |
52 | }; |
53 | 53 | ||
54 | /** Length of imp_data array */ |
54 | /** Length of imp_data array */ |
55 | static int imp_data_length = sizeof(imp_data)/sizeof(char *); |
55 | static int imp_data_length = sizeof(imp_data)/sizeof(char *); |
56 | 56 | ||
57 | /** Architecture names */ |
57 | /** Architecture names */ |
58 | static char * arch_data[] = { |
58 | static char * arch_data[] = { |
59 | "?", /* 0x0 */ |
59 | "?", /* 0x0 */ |
60 | "4", /* 0x1 */ |
60 | "4", /* 0x1 */ |
61 | "4T", /* 0x2 */ |
61 | "4T", /* 0x2 */ |
62 | "5", /* 0x3 */ |
62 | "5", /* 0x3 */ |
63 | "5T", /* 0x4 */ |
63 | "5T", /* 0x4 */ |
64 | "5TE", /* 0x5 */ |
64 | "5TE", /* 0x5 */ |
65 | "5TEJ", /* 0x6 */ |
65 | "5TEJ", /* 0x6 */ |
66 | "6" /* 0x7 */ |
66 | "6" /* 0x7 */ |
67 | }; |
67 | }; |
68 | 68 | ||
69 | /** Length of arch_data array */ |
69 | /** Length of arch_data array */ |
70 | static int arch_data_length = sizeof(arch_data)/sizeof(char *); |
70 | static int arch_data_length = sizeof(arch_data)/sizeof(char *); |
71 | 71 | ||
72 | 72 | ||
73 | 73 | ||
74 | void cpu_arch_init(void) |
74 | void cpu_arch_init(void) |
75 | { |
75 | { |
76 | /* TODO */ |
76 | /* TODO */ |
77 | } |
77 | } |
78 | 78 | ||
79 | /** |
79 | /** |
80 | * Retrieves processor identification from CP15 register 0. |
80 | * Retrieves processor identification from CP15 register 0. |
81 | * |
81 | * |
82 | * @param cpu structure for storing identification |
82 | * @param cpu structure for storing identification |
83 | */ |
83 | */ |
84 | static void arch_cpu_identify(cpu_arch_t * cpu) |
84 | static void arch_cpu_identify(cpu_arch_t * cpu) |
85 | { |
85 | { |
86 | uint32_t ident; |
86 | uint32_t ident; |
87 | asm volatile ( |
87 | asm volatile ( |
88 | "mrc p15, 0, %0, c0, c0, 0 \n" |
88 | "mrc p15, 0, %0, c0, c0, 0 \n" |
89 | : "=r" (ident) |
89 | : "=r" (ident) |
90 | ); |
90 | ); |
91 | 91 | ||
92 | cpu->imp_num = ident >> 24; |
92 | cpu->imp_num = ident >> 24; |
93 | cpu->variant_num = (ident << 8) >> 28; |
93 | cpu->variant_num = (ident << 8) >> 28; |
94 | cpu->arch_num = (ident << 12) >> 28; |
94 | cpu->arch_num = (ident << 12) >> 28; |
95 | cpu->prim_part_num = (ident << 16) >> 20; |
95 | cpu->prim_part_num = (ident << 16) >> 20; |
96 | cpu->rev_num = (ident << 28) >> 28; |
96 | cpu->rev_num = (ident << 28) >> 28; |
97 | } |
97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void cpu_identify(void) |
100 | void cpu_identify(void) |
101 | { |
101 | { |
102 | arch_cpu_identify(&CPU->arch); |
102 | arch_cpu_identify(&CPU->arch); |
103 | } |
103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void cpu_print_report(cpu_t *m) |
106 | void cpu_print_report(cpu_t *m) |
107 | { |
107 | { |
108 | char * vendor = imp_data[0]; |
108 | char * vendor = imp_data[0]; |
109 | char * architecture = arch_data[0]; |
109 | char * architecture = arch_data[0]; |
110 | cpu_arch_t * cpu_arch = &m->arch; |
110 | cpu_arch_t * cpu_arch = &m->arch; |
111 | 111 | ||
112 | if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + 0x40)) ) { |
112 | if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + 0x40)) ) { |
113 | vendor = imp_data[cpu_arch->imp_num - 0x40]; |
113 | vendor = imp_data[cpu_arch->imp_num - 0x40]; |
114 | } |
114 | } |
115 | 115 | ||
116 | if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) { |
116 | if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) { |
117 | architecture = arch_data[cpu_arch->arch_num]; |
117 | architecture = arch_data[cpu_arch->arch_num]; |
118 | } |
118 | } |
119 | 119 | ||
120 | printf("vendor: %s, architecture: ARM %s, part number: %x, variant: %x, revision: %x", |
120 | printf("vendor: %s, architecture: ARM %s, part number: %x, variant: %x, revision: %x\n", |
121 | vendor, architecture, cpu_arch->prim_part_num, cpu_arch->variant_num, cpu_arch->rev_num); |
121 | vendor, architecture, cpu_arch->prim_part_num, cpu_arch->variant_num, cpu_arch->rev_num); |
122 | 122 | ||
123 | } |
123 | } |
124 | 124 | ||
125 | /** @} |
125 | /** @} |
126 | */ |
126 | */ |
127 | 127 |