Subversion Repositories HelenOS

Rev

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

Rev 3408 Rev 3672
Line 37... Line 37...
37
#include "ofwarch.h"
37
#include "ofwarch.h"
38
#include <align.h>
38
#include <align.h>
39
#include <string.h>
39
#include <string.h>
40
 
40
 
41
bootinfo_t bootinfo;
41
bootinfo_t bootinfo;
-
 
42
 
42
component_t components[COMPONENTS];
43
component_t components[COMPONENTS];
43
 
44
 
44
char *release = RELEASE;
45
char *release = RELEASE;
45
 
46
 
46
#ifdef REVISION
47
#ifdef REVISION
Line 53... Line 54...
53
    char *timestamp = "\nBuilt on " TIMESTAMP;
54
    char *timestamp = "\nBuilt on " TIMESTAMP;
54
#else
55
#else
55
    char *timestamp = "";
56
    char *timestamp = "";
56
#endif
57
#endif
57
 
58
 
-
 
59
/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
-
 
60
uint8_t subarchitecture;
-
 
61
 
-
 
62
/**
-
 
63
 * mask of the MID field inside the ICBUS_CONFIG register shifted by
-
 
64
 * MID_SHIFT bits to the right
-
 
65
 */
-
 
66
uint16_t mid_mask;
-
 
67
 
58
/** Print version information. */
68
/** Print version information. */
59
static void version_print(void)
69
static void version_print(void)
60
{
70
{
61
    printf("HelenOS SPARC64 Bootloader\nRelease %s%s%s\n"
71
    printf("HelenOS SPARC64 Bootloader\nRelease %s%s%s\n"
62
        "Copyright (c) 2006 HelenOS project\n",
72
        "Copyright (c) 2006 HelenOS project\n",
63
        release, revision, timestamp);
73
        release, revision, timestamp);
64
}
74
}
65
 
75
 
-
 
76
/* the lowest ID (read from the VER register) of some US3 CPU model */
-
 
77
#define FIRST_US3_CPU   0x14
-
 
78
 
-
 
79
/* the greatest ID (read from the VER register) of some US3 CPU model */
-
 
80
#define LAST_US3_CPU    0x19
-
 
81
 
-
 
82
/* UltraSPARC IIIi processor implementation code */
-
 
83
#define US_IIIi_CODE    0x15
-
 
84
 
-
 
85
/**
-
 
86
 * Sets the global variables "subarchitecture" and "mid_mask" to
-
 
87
 * correct values.
-
 
88
 */
-
 
89
static void detect_subarchitecture(void)
-
 
90
{
-
 
91
    uint64_t v;
-
 
92
    asm volatile ("rdpr %%ver, %0\n" : "=r" (v));
-
 
93
   
-
 
94
    v = (v << 16) >> 48;
-
 
95
    if ((v >= FIRST_US3_CPU) && (v <= LAST_US3_CPU)) {
-
 
96
        subarchitecture = SUBARCH_US3;
-
 
97
        if (v == US_IIIi_CODE)
-
 
98
            mid_mask = (1 << 5) - 1;
-
 
99
        else
-
 
100
            mid_mask = (1 << 10) - 1;
-
 
101
    } else if (v < FIRST_US3_CPU) {
-
 
102
        subarchitecture = SUBARCH_US;
-
 
103
        mid_mask = (1 << 5) - 1;
-
 
104
    } else {
-
 
105
        printf("\nThis CPU is not supported by HelenOS.");
-
 
106
    }
-
 
107
}
-
 
108
 
66
void bootstrap(void)
109
void bootstrap(void)
67
{
110
{
68
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
111
    void *base = (void *) KERNEL_VIRTUAL_ADDRESS;
69
    void *balloc_base;
112
    void *balloc_base;
70
    unsigned int top = 0;
113
    unsigned int top = 0;
71
    int i, j;
114
    int i, j;
72
 
115
 
73
    version_print();
116
    version_print();
74
   
117
   
-
 
118
    detect_subarchitecture();
75
    init_components(components);
119
    init_components(components);
76
 
120
 
77
    if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
121
    if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
78
        printf("Error: unable to get start of physical memory.\n");
122
        printf("Error: unable to get start of physical memory.\n");
79
        halt();
123
        halt();
Line 81... Line 125...
81
 
125
 
82
    if (!ofw_memmap(&bootinfo.memmap)) {
126
    if (!ofw_memmap(&bootinfo.memmap)) {
83
        printf("Error: unable to get memory map, halting.\n");
127
        printf("Error: unable to get memory map, halting.\n");
84
        halt();
128
        halt();
85
    }
129
    }
86
   
130
 
87
    if (bootinfo.memmap.total == 0) {
131
    if (bootinfo.memmap.total == 0) {
88
        printf("Error: no memory detected, halting.\n");
132
        printf("Error: no memory detected, halting.\n");
89
        halt();
133
        halt();
90
    }
134
    }
91
 
135