Changeset 46c20c8 in mainline for kernel/generic/src/main
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/generic/src/main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/main/kinit.c
rfb150d78 r46c20c8 66 66 #include <ipc/ipc.h> 67 67 #include <debug.h> 68 #include <string.h> 68 #include <str.h> 69 #include <sysinfo/stats.h> 69 70 70 71 #ifdef CONFIG_SMP … … 94 95 void kinit(void *arg) 95 96 { 96 97 #if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE)98 97 thread_t *thread; 99 #endif100 98 101 99 /* … … 109 107 if (config.cpu_count > 1) { 110 108 waitq_initialize(&ap_completion_wq); 109 111 110 /* 112 111 * Create the kmp thread and wait for its completion. … … 117 116 thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true); 118 117 if (thread != NULL) { 119 spinlock_lock(&thread->lock);118 irq_spinlock_lock(&thread->lock, false); 120 119 thread->cpu = &cpus[0]; 121 spinlock_unlock(&thread->lock);120 irq_spinlock_unlock(&thread->lock, false); 122 121 thread_ready(thread); 123 122 } else 124 123 panic("Unable to create kmp thread."); 124 125 125 thread_join(thread); 126 126 thread_detach(thread); 127 }128 129 if (config.cpu_count > 1) {130 size_t i;131 127 132 128 /* 133 129 * For each CPU, create its load balancing thread. 134 130 */ 131 unsigned int i; 132 135 133 for (i = 0; i < config.cpu_count; i++) { 136 134 thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true); 137 135 if (thread != NULL) { 138 spinlock_lock(&thread->lock);136 irq_spinlock_lock(&thread->lock, false); 139 137 thread->cpu = &cpus[i]; 140 spinlock_unlock(&thread->lock);138 irq_spinlock_unlock(&thread->lock, false); 141 139 thread_ready(thread); 142 140 } else 143 printf("Unable to create kcpulb thread for cpu " PRIs "\n", i);141 printf("Unable to create kcpulb thread for cpu%u\n", i); 144 142 } 145 143 } … … 150 148 */ 151 149 arch_post_smp_init(); 150 151 /* Start thread computing system load */ 152 thread = thread_create(kload, NULL, TASK, 0, "kload", false); 153 if (thread != NULL) 154 thread_ready(thread); 155 else 156 printf("Unable to create kload thread\n"); 152 157 153 158 #ifdef CONFIG_KCONSOLE … … 174 179 for (i = 0; i < init.cnt; i++) { 175 180 if (init.tasks[i].addr % FRAME_SIZE) { 176 printf("init[%" PRIs "].addr is not frame aligned\n", i); 181 printf("init[%zu].addr is not frame aligned\n", i); 182 programs[i].task = NULL; 177 183 continue; 178 184 } … … 184 190 185 191 char namebuf[TASK_NAME_BUFLEN]; 186 char *name; 187 188 name = init.tasks[i].name; 192 193 const char *name = init.tasks[i].name; 189 194 if (name[0] == 0) 190 195 name = "<unknown>"; … … 194 199 str_cpy(namebuf + INIT_PREFIX_LEN, 195 200 TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name); 196 201 197 202 int rc = program_create_from_image((void *) init.tasks[i].addr, 198 203 namebuf, &programs[i]); … … 203 208 */ 204 209 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER | 205 CAP_IO_MANAGER | CAP_ PREEMPT_CONTROL | CAP_IRQ_REG);210 CAP_IO_MANAGER | CAP_IRQ_REG); 206 211 207 212 if (!ipc_phone_0) … … 214 219 215 220 if (rd != RE_OK) 216 printf("Init binary % " PRIs "not used (error %d)\n", i, rd);221 printf("Init binary %zu not used (error %d)\n", i, rd); 217 222 } 218 223 } -
kernel/generic/src/main/main.c
rfb150d78 r46c20c8 84 84 #include <main/main.h> 85 85 #include <ipc/event.h> 86 #include <sysinfo/sysinfo.h> 87 #include <sysinfo/stats.h> 86 88 87 89 /** Global configuration structure. */ … … 95 97 /** Boot allocations. */ 96 98 ballocs_t ballocs = { 97 .base = NULL,99 .base = (uintptr_t) NULL, 98 100 .size = 0 99 101 }; … … 102 104 103 105 /** Lowest safe stack virtual address. */ 104 uintptr_t stack_safe = 0; 106 uintptr_t stack_safe = 0; 105 107 106 108 /* … … 111 113 */ 112 114 static void main_bsp_separated_stack(void); 115 113 116 #ifdef CONFIG_SMP 114 117 static void main_ap_separated_stack(void); 115 118 #endif 116 119 117 #define CONFIG_STACK_SIZE ((1 << STACK_FRAMES) * STACK_SIZE)120 #define CONFIG_STACK_SIZE ((1 << STACK_FRAMES) * STACK_SIZE) 118 121 119 122 /** Main kernel routine for bootstrap CPU. … … 128 131 * 129 132 */ 130 void main_bsp(void)133 NO_TRACE void main_bsp(void) 131 134 { 132 135 config.cpu_count = 1; … … 144 147 size_t i; 145 148 for (i = 0; i < init.cnt; i++) { 146 if (PA_ overlaps(config.stack_base, config.stack_size,149 if (PA_OVERLAPS(config.stack_base, config.stack_size, 147 150 init.tasks[i].addr, init.tasks[i].size)) 148 151 config.stack_base = ALIGN_UP(init.tasks[i].addr + 149 152 init.tasks[i].size, config.stack_size); 150 153 } 151 154 152 155 /* Avoid placing stack on top of boot allocations. */ 153 156 if (ballocs.size) { 154 if (PA_ overlaps(config.stack_base, config.stack_size,157 if (PA_OVERLAPS(config.stack_base, config.stack_size, 155 158 ballocs.base, ballocs.size)) 156 159 config.stack_base = ALIGN_UP(ballocs.base + … … 168 171 } 169 172 170 171 173 /** Main kernel routine for bootstrap CPU using new stack. 172 174 * … … 174 176 * 175 177 */ 176 void main_bsp_separated_stack(void) 178 void main_bsp_separated_stack(void) 177 179 { 178 180 /* Keep this the first thing. */ … … 181 183 version_print(); 182 184 183 LOG("\nconfig.base=% #" PRIp " config.kernel_size=%" PRIs184 "\nconfig.stack_base=% #" PRIp " config.stack_size=%" PRIs,185 LOG("\nconfig.base=%p config.kernel_size=%zu" 186 "\nconfig.stack_base=%p config.stack_size=%zu", 185 187 config.base, config.kernel_size, config.stack_base, 186 188 config.stack_size); … … 192 194 * commands. 193 195 */ 194 LOG_EXEC(kconsole_init());196 kconsole_init(); 195 197 #endif 196 198 … … 199 201 * starts adding its own handlers 200 202 */ 201 LOG_EXEC(exc_init());203 exc_init(); 202 204 203 205 /* 204 206 * Memory management subsystems initialization. 205 207 */ 206 LOG_EXEC(arch_pre_mm_init());207 LOG_EXEC(frame_init());208 arch_pre_mm_init(); 209 frame_init(); 208 210 209 211 /* Initialize at least 1 memory segment big enough for slab to work. */ 210 LOG_EXEC(slab_cache_init()); 211 LOG_EXEC(btree_init()); 212 LOG_EXEC(as_init()); 213 LOG_EXEC(page_init()); 214 LOG_EXEC(tlb_init()); 215 LOG_EXEC(ddi_init()); 216 LOG_EXEC(tasklet_init()); 217 LOG_EXEC(arch_post_mm_init()); 218 LOG_EXEC(arch_pre_smp_init()); 219 LOG_EXEC(smp_init()); 212 slab_cache_init(); 213 sysinfo_init(); 214 btree_init(); 215 as_init(); 216 page_init(); 217 tlb_init(); 218 ddi_init(); 219 tasklet_init(); 220 arch_post_mm_init(); 221 arch_pre_smp_init(); 222 smp_init(); 220 223 221 224 /* Slab must be initialized after we know the number of processors. */ 222 LOG_EXEC(slab_enable_cpucache());223 224 printf("Detected % " PRIs " CPU(s), %" PRIu64" MiB free memory\n",225 config.cpu_count, SIZE2MB(zone _total_size()));226 227 LOG_EXEC(cpu_init());228 229 LOG_EXEC(calibrate_delay_loop());230 LOG_EXEC(clock_counter_init());231 LOG_EXEC(timeout_init());232 LOG_EXEC(scheduler_init());233 LOG_EXEC(task_init());234 LOG_EXEC(thread_init());235 LOG_EXEC(futex_init());225 slab_enable_cpucache(); 226 227 printf("Detected %u CPU(s), %" PRIu64 " MiB free memory\n", 228 config.cpu_count, SIZE2MB(zones_total_size())); 229 230 cpu_init(); 231 232 calibrate_delay_loop(); 233 clock_counter_init(); 234 timeout_init(); 235 scheduler_init(); 236 task_init(); 237 thread_init(); 238 futex_init(); 236 239 237 240 if (init.cnt > 0) { 238 241 size_t i; 239 242 for (i = 0; i < init.cnt; i++) 240 LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs 241 "].size=%#" PRIs, i, init.tasks[i].addr, i, 242 init.tasks[i].size); 243 LOG("init[%zu].addr=%p, init[%zu].size=%zu", 244 i, init.tasks[i].addr, i, init.tasks[i].size); 243 245 } else 244 246 printf("No init binaries found.\n"); 245 247 246 LOG_EXEC(ipc_init()); 247 LOG_EXEC(event_init()); 248 LOG_EXEC(klog_init()); 248 ipc_init(); 249 event_init(); 250 klog_init(); 251 stats_init(); 249 252 250 253 /* … … 262 265 if (!kinit_thread) 263 266 panic("Cannot create kinit thread."); 264 LOG_EXEC(thread_ready(kinit_thread));267 thread_ready(kinit_thread); 265 268 266 269 /* … … 272 275 } 273 276 274 275 277 #ifdef CONFIG_SMP 278 276 279 /** Main kernel routine for application CPUs. 277 280 * … … 292 295 */ 293 296 config.cpu_active++; 294 297 295 298 /* 296 299 * The THE structure is well defined because ctx.sp is used as stack. … … 307 310 calibrate_delay_loop(); 308 311 arch_post_cpu_init(); 309 312 310 313 the_copy(THE, (the_t *) CPU->stack); 311 314 312 315 /* 313 316 * If we woke kmp up before we left the kernel stack, we could … … 322 325 } 323 326 324 325 327 /** Main kernel routine for application CPUs using new stack. 326 328 * … … 334 336 */ 335 337 timeout_init(); 336 338 337 339 waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST); 338 340 scheduler(); 339 341 /* not reached */ 340 342 } 343 341 344 #endif /* CONFIG_SMP */ 342 345 -
kernel/generic/src/main/uinit.c
rfb150d78 r46c20c8 42 42 43 43 #include <main/uinit.h> 44 #include < arch/types.h>44 #include <typedefs.h> 45 45 #include <proc/thread.h> 46 46 #include <userspace.h> -
kernel/generic/src/main/version.c
rfb150d78 r46c20c8 37 37 #include <macros.h> 38 38 39 char *project = "SPARTAN kernel";40 char *copyright = "Copyright (c) 2001-2009HelenOS project";41 char *release = STRING(RELEASE);42 char *name = STRING(NAME);43 char *arch = STRING(KARCH);39 static const char *project = "SPARTAN kernel"; 40 static const char *copyright = "Copyright (c) 2001-2010 HelenOS project"; 41 static const char *release = STRING(RELEASE); 42 static const char *name = STRING(NAME); 43 static const char *arch = STRING(KARCH); 44 44 45 45 #ifdef REVISION 46 char *revision = ", revision " STRING(REVISION);46 static const char *revision = ", revision " STRING(REVISION); 47 47 #else 48 char *revision = "";48 static const char *revision = ""; 49 49 #endif 50 50 51 51 #ifdef TIMESTAMP 52 char *timestamp = " on " STRING(TIMESTAMP);52 static const char *timestamp = " on " STRING(TIMESTAMP); 53 53 #else 54 char *timestamp = "";54 static const char *timestamp = ""; 55 55 #endif 56 56 … … 59 59 { 60 60 printf("%s, release %s (%s)%s\nBuilt%s for %s\n%s\n", 61 project, release, name, revision, timestamp, arch, copyright);61 project, release, name, revision, timestamp, arch, copyright); 62 62 } 63 63
Note:
See TracChangeset
for help on using the changeset viewer.
