Changeset 76fca31 in mainline for kernel/generic/src
- Timestamp:
- 2008-12-16T19:02:07Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ae4443
- Parents:
- 8fe5980
- Location:
- kernel/generic/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r8fe5980 r76fca31 502 502 cmd_initialize(basic_commands[i]); 503 503 if (!cmd_register(basic_commands[i])) 504 p anic("couldnot register command %s\n", basic_commands[i]->name);504 printf("Cannot register command %s\n", basic_commands[i]->name); 505 505 } 506 506 } -
kernel/generic/src/console/console.c
r8fe5980 r76fca31 168 168 else 169 169 printf("cpu: "); 170 printf("halted - no kconsole\n");170 printf("halted (no kconsole)\n"); 171 171 cpu_halt(); 172 172 } -
kernel/generic/src/console/kconsole.c
r8fe5980 r76fca31 402 402 } 403 403 404 /** Kernel console managing thread.404 /** Kernel console prompt. 405 405 * 406 406 * @param prompt Kernel console prompt (e.g kconsole/panic). 407 */ 408 void kconsole(void *prompt) 407 * @param msg Message to display in the beginning. 408 * @param kcon Wait for keypress to show the prompt 409 * and never exit. 410 * 411 */ 412 void kconsole(char *prompt, char *msg, bool kcon) 409 413 { 410 414 cmd_info_t *cmd_info; … … 413 417 414 418 if (!stdin) { 415 printf("%s: no stdin\n", __func__);419 LOG("No stdin for kernel console"); 416 420 return; 417 421 } 422 423 if (msg) 424 printf("%s", msg); 425 426 if (kcon) 427 _getc(stdin); 418 428 419 429 while (true) { … … 422 432 if (!len) 423 433 continue; 434 424 435 cmd_info = parse_cmdline(cmdline, len); 425 436 if (!cmd_info) 426 437 continue; 427 if (strncmp(cmd_info->name, "exit", 428 min(strlen(cmd_info->name), 5)) == 0) 438 439 if ((!kcon) 440 && (strncmp(cmd_info->name, "exit", min(strlen(cmd_info->name), 5)) == 0)) 429 441 break; 442 430 443 (void) cmd_info->func(cmd_info->argv); 431 444 } 445 } 446 447 /** Kernel console managing thread. 448 * 449 */ 450 void kconsole_thread(void *data) 451 { 452 kconsole("kconsole", "Kernel console ready (press any key to activate)\n", true); 432 453 } 433 454 -
kernel/generic/src/cpu/cpu.c
r8fe5980 r76fca31 87 87 #endif /* CONFIG_SMP */ 88 88 89 CPU = &cpus[config.cpu_active -1];89 CPU = &cpus[config.cpu_active - 1]; 90 90 91 91 CPU->active = 1; -
kernel/generic/src/interrupt/interrupt.c
r8fe5980 r76fca31 110 110 } 111 111 112 #ifdef CONFIG_KCONSOLE 113 112 114 /** kconsole cmd - print all exceptions */ 113 static int exc_print_cmd(cmd_arg_t *argv)115 static int cmd_exc_print(cmd_arg_t *argv) 114 116 { 115 117 #if (IVT_ITEMS > 0) … … 159 161 } 160 162 163 161 164 static cmd_info_t exc_info = { 162 165 .name = "exc", 163 166 .description = "Print exception table.", 164 .func = exc_print_cmd,167 .func = cmd_exc_print, 165 168 .help = NULL, 166 169 .argc = 0, 167 170 .argv = NULL 168 171 }; 172 173 #endif 169 174 170 175 /** Initialize generic exception handling support */ … … 176 181 exc_register(i, "undef", (iroutine) exc_undef); 177 182 183 #ifdef CONFIG_KCONSOLE 178 184 cmd_initialize(&exc_info); 179 185 if (!cmd_register(&exc_info)) 180 panic("could not register command %s\n", exc_info.name); 186 printf("Cannot register command %s\n", exc_info.name); 187 #endif 181 188 } 182 189 -
kernel/generic/src/lib/func.c
r8fe5980 r76fca31 56 56 bool rundebugger = false; 57 57 58 // TODO test_and_set not defined on all arches59 // if (!test_and_set(&haltstate))60 58 if (!atomic_get(&haltstate)) { 61 59 atomic_set(&haltstate, 1); … … 67 65 68 66 interrupts_disable(); 69 #ifdef CONFIG_DEBUG 70 if (rundebugger) { 71 printf("\n");72 kconsole("panic" ); /* Run kconsole as a last resort to user */73 } 74 #endif 67 68 #if (defined(CONFIG_DEBUG)) && (defined(CONFIG_KCONSOLE)) 69 if (rundebugger) 70 kconsole("panic", "\nLast resort kernel console ready\n", false); 71 #endif 72 75 73 if (CPU) 76 74 printf("cpu%u: halted\n", CPU->id); -
kernel/generic/src/main/kinit.c
r8fe5980 r76fca31 83 83 void kinit(void *arg) 84 84 { 85 thread_t *t; 85 86 #if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE) 87 thread_t *thread; 88 #endif 86 89 87 90 /* … … 101 104 * Just a beautification. 102 105 */ 103 if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED,104 "kmp", true))) {105 spinlock_lock(&t ->lock);106 t ->cpu = &cpus[0];107 spinlock_unlock(&t ->lock);108 thread_ready(t );106 thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true); 107 if (thread != NULL) { 108 spinlock_lock(&thread->lock); 109 thread->cpu = &cpus[0]; 110 spinlock_unlock(&thread->lock); 111 thread_ready(thread); 109 112 } else 110 panic(" thread_create/kmp\n");111 thread_join(t );112 thread_detach(t );113 panic("Unable to create kmp thread\n"); 114 thread_join(thread); 115 thread_detach(thread); 113 116 } 114 117 #endif /* CONFIG_SMP */ 115 /* 116 * Now that all CPUs are up, we can report what we've found. 117 */ 118 cpu_list(); 119 118 120 119 #ifdef CONFIG_SMP 121 120 if (config.cpu_count > 1) { … … 126 125 */ 127 126 for (i = 0; i < config.cpu_count; i++) { 128 129 if ((t = thread_create(kcpulb, NULL, TASK, 130 THREAD_FLAG_WIRED, "kcpulb", true))) { 131 spinlock_lock(&t->lock); 132 t->cpu = &cpus[i]; 133 spinlock_unlock(&t->lock); 134 thread_ready(t); 127 thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true); 128 if (thread != NULL) { 129 spinlock_lock(&thread->lock); 130 thread->cpu = &cpus[i]; 131 spinlock_unlock(&thread->lock); 132 thread_ready(thread); 135 133 } else 136 p anic("thread_create/kcpulb\n");134 printf("Unable to create kcpulb thread for cpu" PRIc "\n", i); 137 135 138 136 } 139 137 } 140 138 #endif /* CONFIG_SMP */ 141 139 142 140 /* 143 141 * At this point SMP, if present, is configured. … … 145 143 arch_post_smp_init(); 146 144 147 /* 148 * Create kernel console. 149 */ 150 t = thread_create(kconsole, (void *) "kconsole", TASK, 0, "kconsole", 151 false); 152 if (t) 153 thread_ready(t); 154 else 155 panic("thread_create/kconsole\n"); 156 145 #ifdef CONFIG_KCONSOLE 146 if (stdin) { 147 /* 148 * Create kernel console. 149 */ 150 thread = thread_create(kconsole_thread, NULL, TASK, 0, "kconsole", false); 151 if (thread != NULL) 152 thread_ready(thread); 153 else 154 printf("Unable to create kconsole thread\n"); 155 } 156 #endif /* CONFIG_KCONSOLE */ 157 157 158 interrupts_enable(); 158 159 … … 165 166 for (i = 0; i < init.cnt; i++) { 166 167 if (init.tasks[i].addr % FRAME_SIZE) { 167 printf("init[%" PRIc "].addr is not frame aligned ", i);168 printf("init[%" PRIc "].addr is not frame aligned\n", i); 168 169 continue; 169 170 } 170 171 171 172 int rc = program_create_from_image((void *) init.tasks[i].addr, 172 173 "init-bin", &programs[i]); 173 174 if ( rc == 0 && programs[i].task != NULL) {174 175 if ((rc == 0) && (programs[i].task != NULL)) { 175 176 /* 176 177 * Set capabilities to init userspace tasks. … … 185 186 } else { 186 187 /* RAM disk image */ 187 int rd = init_rd((rd_header_t *) init.tasks[i].addr, 188 init.tasks[i].size); 188 int rd = init_rd((rd_header_t *) init.tasks[i].addr, init.tasks[i].size); 189 189 190 190 if (rd != RE_OK) 191 printf("Init binary %" PRIc " not used, error " 192 "code %d.\n", i, rd); 191 printf("Init binary %" PRIc " not used (error %d)\n", i, rd); 193 192 } 194 193 } … … 204 203 } 205 204 205 #ifdef CONFIG_KCONSOLE 206 206 if (!stdin) { 207 printf("kinit: No stdin\nKernel alive: "); 208 209 uint64_t i = 0; 207 210 while (1) { 211 printf(PRIu64 " ", i); 208 212 thread_sleep(1); 209 printf("kinit... "); 210 } 211 } 213 i++; 214 } 215 } 216 #endif /* CONFIG_KCONSOLE */ 212 217 } 213 218 -
kernel/generic/src/main/main.c
r8fe5980 r76fca31 192 192 /* Keep this the first thing. */ 193 193 the_initialize(THE); 194 195 LOG();196 194 197 195 version_print(); … … 201 199 config.base, config.kernel_size, config.stack_base, 202 200 config.stack_size); 203 204 201 202 #ifdef CONFIG_KCONSOLE 205 203 /* 206 204 * kconsole data structures must be initialized very early … … 209 207 */ 210 208 LOG_EXEC(kconsole_init()); 209 #endif 211 210 212 211 /* … … 253 252 count_t i; 254 253 for (i = 0; i < init.cnt; i++) 255 printf("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc254 LOG("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc 256 255 "].size=%#" PRIs "\n", i, init.tasks[i].addr, i, 257 256 init.tasks[i].size); … … 272 271 * Create the first thread. 273 272 */ 274 thread_t *kinit_thread = thread_create(kinit, NULL, kernel, 0, "kinit",275 273 thread_t *kinit_thread 274 = thread_create(kinit, NULL, kernel, 0, "kinit", true); 276 275 if (!kinit_thread) 277 276 panic("Can't create kinit thread\n"); -
kernel/generic/src/mm/as.c
r8fe5980 r76fca31 147 147 AS_KERNEL = as_create(FLAG_AS_KERNEL); 148 148 if (!AS_KERNEL) 149 panic("can't create kernel address space\n"); 150 149 panic("Cannot create kernel address space\n"); 150 151 /* Make sure the kernel address space 152 * reference count never drops to zero. 153 */ 154 atomic_set(&AS_KERNEL->refcount, 1); 151 155 } 152 156 … … 177 181 page_table_create(flags); 178 182 #endif 179 183 180 184 return as; 181 185 } … … 770 774 * into private anonymous memory (unless it's already there). 771 775 * 772 * @param as Address space. 773 * @param flags Flags of the area memory. 774 * @param address Address withing the area to be changed. 775 * 776 * @return Zero on success or a value from @ref errno.h on failure. 776 * @param as Address space. 777 * @param flags Flags of the area memory. 778 * @param address Address within the area to be changed. 779 * 780 * @return Zero on success or a value from @ref errno.h on failure. 781 * 777 782 */ 778 783 int as_area_change_flags(as_t *as, int flags, uintptr_t address) … … 786 791 index_t frame_idx; 787 792 count_t used_pages; 788 793 789 794 /* Flags for the new memory mapping */ 790 795 page_flags = area_flags_to_page_flags(flags); … … 800 805 } 801 806 802 if ( area->sh_info || area->backend != &anon_backend) {807 if ((area->sh_info) || (area->backend != &anon_backend)) { 803 808 /* Copying shared areas not supported yet */ 804 809 /* Copying non-anonymous memory not supported yet */ … … 871 876 872 877 tlb_invalidate_pages(as->asid, area->base, area->pages); 878 873 879 /* 874 880 * Invalidate potential software translation caches (e.g. TSB on -
kernel/generic/src/syscall/syscall.c
r8fe5980 r76fca31 93 93 static unative_t sys_debug_enable_console(void) 94 94 { 95 #ifdef CONFIG_KCONSOLE 95 96 arch_grab_console(); 96 return 0; 97 return true; 98 #else 99 return false; 100 #endif 97 101 } 98 102
Note:
See TracChangeset
for help on using the changeset viewer.