Subversion Repositories HelenOS

Rev

Rev 2291 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2291 Rev 2329
Line 36... Line 36...
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
/** Number of indexes left out in the #imp_data array */
-
 
42
#define IMP_DATA_START_OFFSET 0x40
-
 
43
 
41
/** Implementators (vendor) names */
44
/** Implementators (vendor) names */
42
static char * imp_data[] = {
45
static char * imp_data[] = {
43
    "?",
-
 
-
 
46
    "?",                                 /* IMP_DATA_START_OFFSET */
44
    "ARM Ltd",                           /* 0x41 */
47
    "ARM Ltd",                           /* 0x41 */
45
    "",                                  /* 0x42 */
48
    "",                                  /* 0x42 */
46
    "",                                  /* 0x43 */
49
    "",                                  /* 0x43 */
47
    "Digital Equipment Corporation",     /* 0x44 */
50
    "Digital Equipment Corporation",     /* 0x44 */
48
    "", "", "", "", "", "", "", "", "", "", "",                     /* 0x4f */
51
    "", "", "", "", "", "", "", "", "", "", "",                     /* 0x4f */
49
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */
52
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */
50
    "", "", "", "", "", "", "", "", "",  /* 0x68 */
53
    "", "", "", "", "", "", "", "", "",  /* 0x68 */
51
    "Intel Corporation"                  /* 0x69 */
54
    "Intel Corporation"                  /* 0x69 */
52
};
55
};
53
 
56
 
54
/** Length of imp_data array */
57
/** Length of the #imp_data array */
55
static int imp_data_length = sizeof(imp_data)/sizeof(char *);
58
static int imp_data_length = sizeof(imp_data)/sizeof(char *);
56
 
59
 
57
/** Architecture names */
60
/** Architecture names */
58
static char * arch_data[] = {
61
static char * arch_data[] = {
59
    "?",       /* 0x0 */
62
    "?",       /* 0x0 */
Line 64... Line 67...
64
    "5TE",     /* 0x5 */
67
    "5TE",     /* 0x5 */
65
    "5TEJ",    /* 0x6 */
68
    "5TEJ",    /* 0x6 */
66
    "6"        /* 0x7 */
69
    "6"        /* 0x7 */
67
};
70
};
68
 
71
 
69
/** Length of arch_data array */
72
/** Length of the #arch_data array */
70
static int arch_data_length = sizeof(arch_data)/sizeof(char *);
73
static int arch_data_length = sizeof(arch_data)/sizeof(char *);
71
 
74
 
72
 
75
 
73
 
-
 
74
void cpu_arch_init(void)
-
 
75
{
-
 
76
    /* TODO */
-
 
77
}
-
 
78
 
-
 
79
/**
-
 
80
 * Retrieves processor identification from CP15 register 0.
76
/** Retrieves processor identification from CP15 register 0.
81
 *
77
 *
82
 * @param cpu   structure for storing identification
78
 * @param cpu Structure for storing CPU identification.
83
 */
79
 */
84
static void arch_cpu_identify(cpu_arch_t * cpu)
80
static void arch_cpu_identify(cpu_arch_t * cpu)
85
{
81
{
86
    uint32_t ident;
82
    uint32_t ident;
87
    asm volatile (
83
    asm volatile (
Line 95... Line 91...
95
    cpu->prim_part_num = (ident << 16) >> 20;
91
    cpu->prim_part_num = (ident << 16) >> 20;
96
    cpu->rev_num = (ident << 28) >> 28;
92
    cpu->rev_num = (ident << 28) >> 28;
97
}
93
}
98
 
94
 
99
 
95
 
-
 
96
void cpu_arch_init(void)
-
 
97
{
-
 
98
}
-
 
99
 
-
 
100
 
100
void cpu_identify(void)
101
void cpu_identify(void)
101
{
102
{
102
    arch_cpu_identify(&CPU->arch);
103
    arch_cpu_identify(&CPU->arch);
103
}
104
}
104
 
105
 
Line 107... Line 108...
107
{
108
{
108
    char * vendor = imp_data[0];
109
    char * vendor = imp_data[0];
109
    char * architecture = arch_data[0];
110
    char * architecture = arch_data[0];
110
    cpu_arch_t * cpu_arch = &m->arch;
111
    cpu_arch_t * cpu_arch = &m->arch;
111
 
112
 
112
    if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + 0x40)) ) {
113
    if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + IMP_DATA_START_OFFSET)) ) {
113
        vendor = imp_data[cpu_arch->imp_num - 0x40];
114
        vendor = imp_data[cpu_arch->imp_num - IMP_DATA_START_OFFSET];
114
    }
115
    }
115
 
116
 
116
    if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) {
117
    if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) {
117
        architecture = arch_data[cpu_arch->arch_num];
118
        architecture = arch_data[cpu_arch->arch_num];
118
    }
119
    }
119
 
120
 
120
    printf("vendor: %s, architecture: ARM %s, part number: %x, variant: %x, revision: %x\n",
121
    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);
122
        vendor, architecture, cpu_arch->prim_part_num, cpu_arch->variant_num, cpu_arch->rev_num);
122
 
-
 
123
}
123
}
124
 
124
 
125
/** @}
125
/** @}
126
 */
126
 */