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