Subversion Repositories HelenOS

Rev

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

Rev 2131 Rev 2189
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2003-2004 Jakub Jermar
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:
Line 30... Line 30...
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
-
 
35
#include <arch/cpu.h>
35
#include <cpu.h>
36
#include <cpu.h>
-
 
37
#include <arch.h>
36
#include <print.h>  
38
#include <print.h>  
37
 
39
 
-
 
40
 
-
 
41
/** Implementators (vendor) names */
-
 
42
static char * imp_data[] = {
-
 
43
    "?",
-
 
44
    "ARM Ltd",                           /* 0x41 */
-
 
45
    "",                                  /* 0x42 */
-
 
46
    "",                                  /* 0x43 */
-
 
47
    "Digital Equipment Corporation",     /* 0x44 */
-
 
48
    "", "", "", "", "", "", "", "", "", "", "",                     /* 0x4f */
-
 
49
    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0x5f */
-
 
50
    "", "", "", "", "", "", "", "", "",  /* 0x68 */
-
 
51
    "Intel Corporation"                  /* 0x69 */
-
 
52
};
-
 
53
 
-
 
54
/** Length of imp_data array */
-
 
55
static int imp_data_length = sizeof(imp_data)/sizeof(char *);
-
 
56
 
-
 
57
/** Architecture names */
-
 
58
static char * arch_data[] = {
-
 
59
    "?",       /* 0x0 */
-
 
60
    "4",       /* 0x1 */
-
 
61
    "4T",      /* 0x2 */
-
 
62
    "5",       /* 0x3 */
-
 
63
    "5T",      /* 0x4 */
-
 
64
    "5TE",     /* 0x5 */
-
 
65
    "5TEJ",    /* 0x6 */
-
 
66
    "6"        /* 0x7 */
-
 
67
};
-
 
68
 
-
 
69
/** Length of arch_data array */
-
 
70
static int arch_data_length = sizeof(arch_data)/sizeof(char *);
-
 
71
 
-
 
72
 
-
 
73
 
38
void cpu_arch_init(void)
74
void cpu_arch_init(void)
39
{
75
{
-
 
76
    /* TODO */
40
}
77
}
41
 
78
 
-
 
79
/**
-
 
80
 * Retrieves processor identification from CP15 register 0.
-
 
81
 *
-
 
82
 * @param cpu   structure for storing identification
-
 
83
 */
42
void cpu_identify(void)
84
static void arch_cpu_identify(cpu_arch_t * cpu)
43
{
85
{
-
 
86
    uint32_t ident;
-
 
87
    asm volatile (
-
 
88
        "mrc p15, 0, %0, c0, c0, 0  \n"
44
    /* TODO */
89
        : "=r" (ident)
-
 
90
    );
-
 
91
 
-
 
92
    cpu->imp_num = ident >> 24;
-
 
93
    cpu->variant_num = (ident << 8) >> 28;
-
 
94
    cpu->arch_num = (ident << 12) >> 28;
-
 
95
    cpu->prim_part_num = (ident << 16) >> 20;
-
 
96
    cpu->rev_num = (ident << 28) >> 28;
45
}
97
}
46
 
98
 
-
 
99
 
-
 
100
void cpu_identify(void)
-
 
101
{
-
 
102
    arch_cpu_identify(&CPU->arch);
-
 
103
}
-
 
104
 
-
 
105
 
47
void cpu_print_report(cpu_t *m)
106
void cpu_print_report(cpu_t *m)
48
{
107
{
49
    /* TODO */
108
    char * vendor = imp_data[0];
-
 
109
    char * architecture = arch_data[0];
-
 
110
    cpu_arch_t * cpu_arch = &m->arch;
-
 
111
 
-
 
112
    if ( (cpu_arch->imp_num) > 0 && (cpu_arch->imp_num < (imp_data_length + 0x40)) ) {
-
 
113
        vendor = imp_data[cpu_arch->imp_num - 0x40];
-
 
114
    }
-
 
115
 
-
 
116
    if ( (cpu_arch->arch_num) > 0 && (cpu_arch->arch_num < arch_data_length) ) {
-
 
117
        architecture = arch_data[cpu_arch->arch_num];
-
 
118
    }
-
 
119
 
-
 
120
    printf("vendor: %s, architecture: ARM %s, part number: %x, variant: %x, revision: %x",
-
 
121
        vendor, architecture, cpu_arch->prim_part_num, cpu_arch->variant_num, cpu_arch->rev_num);
-
 
122
 
50
}
123
}
51
 
124
 
52
/** @}
125
/** @}
53
 */
126
 */