Subversion Repositories HelenOS

Rev

Rev 2291 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2128 jermar 1
/*
2189 kebrt 2
 * Copyright (c) 2007 Michal Kebrt
2128 jermar 3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
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
15
 *   derived from this software without specific prior written permission.
16
 *
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
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
/** @addtogroup arm32
30
 * @{
31
 */
32
/** @file
33
 */
34
 
2189 kebrt 35
#include <arch/cpu.h>
2128 jermar 36
#include <cpu.h>
2189 kebrt 37
#include <arch.h>
2128 jermar 38
#include <print.h>  
39
 
2189 kebrt 40
 
2329 kebrt 41
/** Number of indexes left out in the #imp_data array */
42
#define IMP_DATA_START_OFFSET 0x40
43
 
2189 kebrt 44
/** Implementators (vendor) names */
45
static char * imp_data[] = {
2329 kebrt 46
    "?",                                 /* IMP_DATA_START_OFFSET */
2189 kebrt 47
    "ARM Ltd",                           /* 0x41 */
48
    "",                                  /* 0x42 */
49
    "",                                  /* 0x43 */
50
    "Digital Equipment Corporation",     /* 0x44 */
51
    "", "", "", "", "", "", "", "", "", "", "",                     /* 0x4f */
52
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */
53
    "", "", "", "", "", "", "", "", "",  /* 0x68 */
54
    "Intel Corporation"                  /* 0x69 */
55
};
56
 
2329 kebrt 57
/** Length of the #imp_data array */
2189 kebrt 58
static int imp_data_length = sizeof(imp_data)/sizeof(char *);
59
 
60
/** Architecture names */
61
static char * arch_data[] = {
62
    "?",       /* 0x0 */
63
    "4",       /* 0x1 */
64
    "4T",      /* 0x2 */
65
    "5",       /* 0x3 */
66
    "5T",      /* 0x4 */
67
    "5TE",     /* 0x5 */
68
    "5TEJ",    /* 0x6 */
69
    "6"        /* 0x7 */
70
};
71
 
2329 kebrt 72
/** Length of the #arch_data array */
2189 kebrt 73
static int arch_data_length = sizeof(arch_data)/sizeof(char *);
74
 
75
 
2329 kebrt 76
/** Retrieves processor identification from CP15 register 0.
2189 kebrt 77
 *
2329 kebrt 78
 * @param cpu Structure for storing CPU identification.
2189 kebrt 79
 */
80
static void arch_cpu_identify(cpu_arch_t * cpu)
2128 jermar 81
{
2189 kebrt 82
    uint32_t ident;
83
    asm volatile (
84
        "mrc p15, 0, %0, c0, c0, 0  \n"
85
        : "=r" (ident)
86
    );
87
 
88
    cpu->imp_num = ident >> 24;
89
    cpu->variant_num = (ident << 8) >> 28;
90
    cpu->arch_num = (ident << 12) >> 28;
91
    cpu->prim_part_num = (ident << 16) >> 20;
92
    cpu->rev_num = (ident << 28) >> 28;
2128 jermar 93
}
94
 
2189 kebrt 95
 
2329 kebrt 96
void cpu_arch_init(void)
97
{
98
}
99
 
100
 
2189 kebrt 101
void cpu_identify(void)
102
{
103
    arch_cpu_identify(&CPU->arch);
104
}
105
 
106
 
2128 jermar 107
void cpu_print_report(cpu_t *m)
108
{
2189 kebrt 109
    char * vendor = imp_data[0];
110
    char * architecture = arch_data[0];
111
    cpu_arch_t * cpu_arch = &m->arch;
112
 
2329 kebrt 113
    if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + IMP_DATA_START_OFFSET)) ) {
114
        vendor = imp_data[cpu_arch->imp_num - IMP_DATA_START_OFFSET];
2189 kebrt 115
    }
116
 
117
    if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) {
118
        architecture = arch_data[cpu_arch->arch_num];
119
    }
120
 
2291 kebrt 121
    printf("vendor: %s, architecture: ARM %s, part number: %x, variant: %x, revision: %x\n",
2189 kebrt 122
        vendor, architecture, cpu_arch->prim_part_num, cpu_arch->variant_num, cpu_arch->rev_num);
2128 jermar 123
}
124
 
125
/** @}
126
 */