Subversion Repositories HelenOS

Rev

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

Rev 3742 Rev 3743
Line 54... Line 54...
54
    char *timestamp = "\nBuilt on " TIMESTAMP;
54
    char *timestamp = "\nBuilt on " TIMESTAMP;
55
#else
55
#else
56
    char *timestamp = "";
56
    char *timestamp = "";
57
#endif
57
#endif
58
 
58
 
59
/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
59
/** UltraSPARC subarchitecture - 1 for US, 3 for US3, 0 for other */
60
uint8_t subarchitecture;
60
uint8_t subarchitecture = 0;
61
 
61
 
62
/**
62
/**
63
 * mask of the MID field inside the ICBUS_CONFIG register shifted by
63
 * mask of the MID field inside the ICBUS_CONFIG register shifted by
64
 * MID_SHIFT bits to the right
64
 * MID_SHIFT bits to the right
65
 */
65
 */
Line 80... Line 80...
80
#define LAST_US3_CPU    0x19
80
#define LAST_US3_CPU    0x19
81
 
81
 
82
/* UltraSPARC IIIi processor implementation code */
82
/* UltraSPARC IIIi processor implementation code */
83
#define US_IIIi_CODE    0x15
83
#define US_IIIi_CODE    0x15
84
 
84
 
-
 
85
/* max. length of the "compatible" property of the root node */
-
 
86
#define COMPATIBLE_PROP_MAXLEN  64
-
 
87
 
-
 
88
/*
-
 
89
 * HelenOS bootloader will use these constants to distinguish particular
-
 
90
 * UltraSPARC architectures
-
 
91
 */
-
 
92
#define COMPATIBLE_SUN4U    10
-
 
93
#define COMPATIBLE_SUN4V    20
-
 
94
 
-
 
95
/** US architecture. COMPATIBLE_SUN4U for sun4v, COMPATIBLE_SUN4V for sun4u */
-
 
96
static uint8_t architecture;
-
 
97
 
85
/**
98
/**
-
 
99
 * Detects the UltraSPARC architecture (sun4u and sun4v currently supported)
-
 
100
 * by inspecting the property called "compatible" in the OBP root node.
-
 
101
 */
-
 
102
static void detect_architecture(void)
-
 
103
{
-
 
104
    phandle root = ofw_find_device("/");
-
 
105
    char compatible[COMPATIBLE_PROP_MAXLEN];
-
 
106
 
-
 
107
    if (ofw_get_property(root, "compatible", compatible,
-
 
108
            COMPATIBLE_PROP_MAXLEN) <= 0) {
-
 
109
        printf("Unable to determine architecture, default: sun4u.\n");
-
 
110
        architecture = COMPATIBLE_SUN4U;
-
 
111
        return;
-
 
112
    }
-
 
113
 
-
 
114
    if (strcmp(compatible, "sun4v") == 0) {
-
 
115
        architecture = COMPATIBLE_SUN4V;
-
 
116
    } else {
-
 
117
        /*
-
 
118
         * As not all sun4u machines have "sun4u" in their "compatible"
-
 
119
         * OBP property (e.g. Serengeti's OBP "compatible" property is
-
 
120
         * "SUNW,Serengeti"), we will by default fallback to sun4u if
-
 
121
         * an unknown value of the "compatible" property is encountered.
-
 
122
         */
-
 
123
        architecture = COMPATIBLE_SUN4U;
-
 
124
    }
-
 
125
}
-
 
126
 
-
 
127
/**
-
 
128
 * Detects the subarchitecture (US, US3) of the sun4u
86
 * Sets the global variables "subarchitecture" and "mid_mask" to
129
 * processor. Sets the global variables "subarchitecture" and "mid_mask" to
87
 * correct values.
130
 * correct values.
88
 */
131
 */
89
static void detect_subarchitecture(void)
132
static void detect_subarchitecture(void)
90
{
133
{
91
    uint64_t v;
134
    uint64_t v;
Line 104... Line 147...
104
    } else {
147
    } else {
105
        printf("\nThis CPU is not supported by HelenOS.");
148
        printf("\nThis CPU is not supported by HelenOS.");
106
    }
149
    }
107
}
150
}
108
 
151
 
-
 
152
/**
-
 
153
 * Performs sun4u-specific initialization. The components are expected
-
 
154
 * to be already copied and boot allocator initialized.
-
 
155
 */
-
 
156
static void bootstrap_sun4u(void)
-
 
157
{
-
 
158
    printf("\nCanonizing OpenFirmware device tree...");
-
 
159
    bootinfo.ofw_root = ofw_tree_build();
-
 
160
    printf("done.\n");
-
 
161
 
-
 
162
    detect_subarchitecture();
-
 
163
 
-
 
164
#ifdef CONFIG_SMP
-
 
165
    printf("\nChecking for secondary processors...");
-
 
166
    if (!ofw_cpu())
-
 
167
        printf("Error: unable to get CPU properties\n");
-
 
168
    printf("done.\n");
-
 
169
#endif
-
 
170
 
-
 
171
    setup_palette();
-
 
172
}
-
 
173
 
-
 
174
/**
-
 
175
 * Performs sun4v-specific initialization. The components are expected
-
 
176
 * to be already copied and boot allocator initialized.
-
 
177
 */
-
 
178
static void bootstrap_sun4v(void)
-
 
179
{
-
 
180
}
-
 
181
 
109
void bootstrap(void)
182
void bootstrap(void)
110
{
183
{
111
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
184
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
112
    void *balloc_base;
185
    void *balloc_base;
113
    unsigned int top = 0;
186
    unsigned int top = 0;
114
    int i, j;
187
    int i, j;
115
 
188
 
116
    version_print();
-
 
117
   
-
 
118
    detect_subarchitecture();
189
    detect_architecture();
119
    init_components(components);
190
    init_components(components);
120
 
191
 
121
    if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
192
    if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
122
        printf("Error: unable to get start of physical memory.\n");
193
        printf("Error: unable to get start of physical memory.\n");
123
        halt();
194
        halt();
Line 254... Line 325...
254
    (void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
325
    (void) ofw_claim_phys(bootinfo.physmem_start + balloc_base,
255
        BALLOC_MAX_SIZE);
326
        BALLOC_MAX_SIZE);
256
    (void) ofw_map(balloc_base, balloc_base, BALLOC_MAX_SIZE, -1);
327
    (void) ofw_map(balloc_base, balloc_base, BALLOC_MAX_SIZE, -1);
257
    balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
328
    balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
258
 
329
 
259
    printf("\nCanonizing OpenFirmware device tree...");
330
    /* perform architecture-specific initialization */
260
    bootinfo.ofw_root = ofw_tree_build();
331
    if (architecture == COMPATIBLE_SUN4U) {
261
    printf("done.\n");
332
        bootstrap_sun4u();
262
 
-
 
263
#ifdef CONFIG_SMP
-
 
264
    printf("\nChecking for secondary processors...");
333
    } else if (architecture == COMPATIBLE_SUN4V) {
265
    if (!ofw_cpu())
334
        bootstrap_sun4v();
266
        printf("Error: unable to get CPU properties\n");
335
    } else {
267
    printf("done.\n");
336
        printf("Unknown architecture.\n");
268
#endif
337
        halt();
269
 
338
    }
270
    setup_palette();
-
 
271
 
339
 
272
    printf("\nBooting the kernel...\n");
340
    printf("\nBooting the kernel...\n");
273
    jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
341
    jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
274
        bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
342
        bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
275
        sizeof(bootinfo));
343
        sizeof(bootinfo));