Changeset fd07e57b in mainline for kernel/generic
- Timestamp:
- 2014-01-05T21:25:41Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4aa2a27
- Parents:
- aacdb8e (diff), ca05e9b (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
- Files:
-
- 2 added
- 14 edited
-
include/console/console.h (modified) (2 diffs)
-
include/debug.h (modified) (1 diff)
-
include/log.h (added)
-
include/synch/spinlock.h (modified) (2 diffs)
-
src/console/cmd.c (modified) (3 diffs)
-
src/console/console.c (modified) (8 diffs)
-
src/lib/func.c (modified) (2 diffs)
-
src/lib/rd.c (modified) (2 diffs)
-
src/log/log.c (added)
-
src/main/kinit.c (modified) (6 diffs)
-
src/main/main.c (modified) (2 diffs)
-
src/main/shutdown.c (modified) (2 diffs)
-
src/mm/frame.c (modified) (5 diffs)
-
src/proc/program.c (modified) (4 diffs)
-
src/proc/scheduler.c (modified) (3 diffs)
-
src/syscall/syscall.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/console/console.h
raacdb8e rfd07e57b 39 39 #include <print.h> 40 40 #include <console/chardev.h> 41 #include <synch/spinlock.h> 41 42 42 43 #define PAGING(counter, increment, before, after) \ … … 62 63 extern void console_init(void); 63 64 64 extern void klog_init(void); 65 extern void klog_update(void *); 65 extern void kio_init(void); 66 extern void kio_update(void *); 67 extern void kio_flush(void); 68 extern void kio_push_char(const wchar_t); 69 SPINLOCK_EXTERN(kio_lock); 66 70 67 71 extern wchar_t getc(indev_t *indev); 68 72 extern size_t gets(indev_t *indev, char *buf, size_t buflen); 69 extern sysarg_t sys_k log(int cmd, const void *buf, size_t size);73 extern sysarg_t sys_kio(int cmd, const void *buf, size_t size); 70 74 71 75 extern void grab_console(void); -
kernel/generic/include/debug.h
raacdb8e rfd07e57b 107 107 #define LOG(format, ...) \ 108 108 do { \ 109 printf("%s() from %s at %s:%u: " format "\n", __func__, \ 109 log(LF_OTHER, LVL_DEBUG, \ 110 "%s() from %s at %s:%u: " format,__func__, \ 110 111 symtab_fmt_name_lookup(CALLER), __FILE__, __LINE__, \ 111 112 ##__VA_ARGS__); \ -
kernel/generic/include/synch/spinlock.h
raacdb8e rfd07e57b 137 137 #ifdef CONFIG_DEBUG_SPINLOCK 138 138 139 #include < print.h>139 #include <log.h> 140 140 141 141 #define DEADLOCK_THRESHOLD 100000000 … … 146 146 if ((pname)++ > (value)) { \ 147 147 (pname) = 0; \ 148 printf("Deadlock probe %s: exceeded threshold %u\n" \ 148 log(LF_OTHER, LVL_WARN, \ 149 "Deadlock probe %s: exceeded threshold %u\n" \ 149 150 "cpu%u: function=%s, line=%u\n", \ 150 151 #pname, (value), CPU->id, __func__, __LINE__); \ -
kernel/generic/src/console/cmd.c
raacdb8e rfd07e57b 45 45 #include <console/kconsole.h> 46 46 #include <print.h> 47 #include <log.h> 47 48 #include <panic.h> 48 49 #include <typedefs.h> … … 639 640 for (i = 0; basic_commands[i]; i++) { 640 641 if (!cmd_register(basic_commands[i])) { 641 printf("Cannot register command %s\n", 642 log(LF_OTHER, LVL_ERROR, 643 "Cannot register command %s", 642 644 basic_commands[i]->name); 643 645 } … … 665 667 unsigned int _len = (unsigned int) len; 666 668 if ((_len != len) || (((int) _len) < 0)) { 667 printf("Command length overflow\n");669 log(LF_OTHER, LVL_ERROR, "Command length overflow"); 668 670 return 1; 669 671 } -
kernel/generic/src/console/console.c
raacdb8e rfd07e57b 52 52 #include <errno.h> 53 53 #include <str.h> 54 #include <abi/k log.h>55 56 #define K LOG_PAGES 857 #define K LOG_LENGTH (KLOG_PAGES * PAGE_SIZE / sizeof(wchar_t))54 #include <abi/kio.h> 55 56 #define KIO_PAGES 8 57 #define KIO_LENGTH (KIO_PAGES * PAGE_SIZE / sizeof(wchar_t)) 58 58 59 59 /** Kernel log cyclic buffer */ 60 wchar_t k log[KLOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));60 wchar_t kio[KIO_LENGTH] __attribute__((aligned(PAGE_SIZE))); 61 61 62 62 /** Kernel log initialized */ 63 static atomic_t k log_inited = {false};63 static atomic_t kio_inited = {false}; 64 64 65 65 /** First kernel log characters */ 66 static size_t k log_start = 0;66 static size_t kio_start = 0; 67 67 68 68 /** Number of valid kernel log characters */ 69 static size_t k log_len = 0;69 static size_t kio_len = 0; 70 70 71 71 /** Number of stored (not printed) kernel log characters */ 72 static size_t k log_stored = 0;72 static size_t kio_stored = 0; 73 73 74 74 /** Number of stored kernel log characters for uspace */ 75 static size_t k log_uspace = 0;75 static size_t kio_uspace = 0; 76 76 77 77 /** Kernel log spinlock */ 78 SPINLOCK_ STATIC_INITIALIZE_NAME(klog_lock, "klog_lock");79 80 /** Physical memory area used for k logbuffer */81 static parea_t k log_parea;78 SPINLOCK_INITIALIZE_NAME(kio_lock, "kio_lock"); 79 80 /** Physical memory area used for kio buffer */ 81 static parea_t kio_parea; 82 82 83 83 static indev_t stdin_sink; … … 146 146 * 147 147 */ 148 void k log_init(void)149 { 150 void *faddr = (void *) KA2PA(k log);148 void kio_init(void) 149 { 150 void *faddr = (void *) KA2PA(kio); 151 151 152 152 ASSERT((uintptr_t) faddr % FRAME_SIZE == 0); 153 153 154 k log_parea.pbase = (uintptr_t) faddr;155 k log_parea.frames = SIZE2FRAMES(sizeof(klog));156 k log_parea.unpriv = false;157 k log_parea.mapped = false;158 ddi_parea_register(&k log_parea);159 160 sysinfo_set_item_val("k log.faddr", NULL, (sysarg_t) faddr);161 sysinfo_set_item_val("k log.pages", NULL, KLOG_PAGES);162 163 event_set_unmask_callback(EVENT_K LOG, klog_update);164 atomic_set(&k log_inited, true);154 kio_parea.pbase = (uintptr_t) faddr; 155 kio_parea.frames = SIZE2FRAMES(sizeof(kio)); 156 kio_parea.unpriv = false; 157 kio_parea.mapped = false; 158 ddi_parea_register(&kio_parea); 159 160 sysinfo_set_item_val("kio.faddr", NULL, (sysarg_t) faddr); 161 sysinfo_set_item_val("kio.pages", NULL, KIO_PAGES); 162 163 event_set_unmask_callback(EVENT_KIO, kio_update); 164 atomic_set(&kio_inited, true); 165 165 } 166 166 … … 247 247 } 248 248 249 void k log_update(void *event)250 { 251 if (!atomic_get(&k log_inited))249 void kio_update(void *event) 250 { 251 if (!atomic_get(&kio_inited)) 252 252 return; 253 253 254 spinlock_lock(&klog_lock); 255 256 if (klog_uspace > 0) { 257 if (event_notify_3(EVENT_KLOG, true, klog_start, klog_len, 258 klog_uspace) == EOK) 259 klog_uspace = 0; 260 } 261 262 spinlock_unlock(&klog_lock); 254 spinlock_lock(&kio_lock); 255 256 if (kio_uspace > 0) { 257 if (event_notify_3(EVENT_KIO, true, kio_start, kio_len, 258 kio_uspace) == EOK) 259 kio_uspace = 0; 260 } 261 262 spinlock_unlock(&kio_lock); 263 } 264 265 /** Flush characters that are stored in the output buffer 266 * 267 */ 268 void kio_flush(void) 269 { 270 bool ordy = ((stdout) && (stdout->op->write)); 271 272 if (!ordy) 273 return; 274 275 spinlock_lock(&kio_lock); 276 277 /* Print characters that weren't printed earlier */ 278 while (kio_stored > 0) { 279 wchar_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH]; 280 kio_stored--; 281 282 /* 283 * We need to give up the spinlock for 284 * the physical operation of writing out 285 * the character. 286 */ 287 spinlock_unlock(&kio_lock); 288 stdout->op->write(stdout, tmp); 289 spinlock_lock(&kio_lock); 290 } 291 292 spinlock_unlock(&kio_lock); 293 } 294 295 /** Put a character into the output buffer. 296 * 297 * The caller is required to hold kio_lock 298 */ 299 void kio_push_char(const wchar_t ch) 300 { 301 kio[(kio_start + kio_len) % KIO_LENGTH] = ch; 302 if (kio_len < KIO_LENGTH) 303 kio_len++; 304 else 305 kio_start = (kio_start + 1) % KIO_LENGTH; 306 307 if (kio_stored < kio_len) 308 kio_stored++; 309 310 /* The character is stored for uspace */ 311 if (kio_uspace < kio_len) 312 kio_uspace++; 263 313 } 264 314 … … 267 317 bool ordy = ((stdout) && (stdout->op->write)); 268 318 269 spinlock_lock(&klog_lock); 270 271 /* Print charaters stored in kernel log */ 272 if (ordy) { 273 while (klog_stored > 0) { 274 wchar_t tmp = klog[(klog_start + klog_len - klog_stored) % KLOG_LENGTH]; 275 klog_stored--; 276 277 /* 278 * We need to give up the spinlock for 279 * the physical operation of writting out 280 * the character. 281 */ 282 spinlock_unlock(&klog_lock); 283 stdout->op->write(stdout, tmp); 284 spinlock_lock(&klog_lock); 285 } 286 } 287 288 /* Store character in the cyclic kernel log */ 289 klog[(klog_start + klog_len) % KLOG_LENGTH] = ch; 290 if (klog_len < KLOG_LENGTH) 291 klog_len++; 292 else 293 klog_start = (klog_start + 1) % KLOG_LENGTH; 319 spinlock_lock(&kio_lock); 320 kio_push_char(ch); 321 spinlock_unlock(&kio_lock); 322 323 /* Output stored characters */ 324 kio_flush(); 294 325 295 326 if (!ordy) { 296 if (klog_stored < klog_len)297 klog_stored++;298 }299 300 /* The character is stored for uspace */301 if (klog_uspace < klog_len)302 klog_uspace++;303 304 spinlock_unlock(&klog_lock);305 306 if (ordy) {307 /*308 * Output the character. In this case309 * it should be no longer buffered.310 */311 stdout->op->write(stdout, ch);312 } else {313 327 /* 314 328 * No standard output routine defined yet. … … 326 340 /* Force notification on newline */ 327 341 if (ch == '\n') 328 k log_update(NULL);342 kio_update(NULL); 329 343 } 330 344 … … 334 348 * 335 349 */ 336 sysarg_t sys_k log(int cmd, const void *buf, size_t size)350 sysarg_t sys_kio(int cmd, const void *buf, size_t size) 337 351 { 338 352 char *data; … … 340 354 341 355 switch (cmd) { 342 case K LOG_UPDATE:343 k log_update(NULL);356 case KIO_UPDATE: 357 kio_update(NULL); 344 358 return EOK; 345 case K LOG_WRITE:346 case K LOG_COMMAND:359 case KIO_WRITE: 360 case KIO_COMMAND: 347 361 break; 348 362 default: … … 366 380 367 381 switch (cmd) { 368 case K LOG_WRITE:382 case KIO_WRITE: 369 383 printf("%s", data); 370 384 break; 371 case K LOG_COMMAND:385 case KIO_COMMAND: 372 386 if (!stdin) 373 387 break; -
kernel/generic/src/lib/func.c
raacdb8e rfd07e57b 37 37 38 38 #include <func.h> 39 #include < print.h>39 #include <log.h> 40 40 #include <cpu.h> 41 41 #include <arch/asm.h> … … 72 72 73 73 if (CPU) 74 printf("cpu%u: halted\n", CPU->id);74 log(LF_OTHER, LVL_NOTE, "cpu%u: halted", CPU->id); 75 75 else 76 printf("cpu: halted\n");76 log(LF_OTHER, LVL_NOTE, "cpu: halted"); 77 77 78 78 cpu_halt(); -
kernel/generic/src/lib/rd.c
raacdb8e rfd07e57b 38 38 */ 39 39 40 #include < print.h>40 #include <log.h> 41 41 #include <lib/rd.h> 42 42 #include <mm/frame.h> … … 68 68 sysinfo_set_item_val("rd.address.physical", NULL, (sysarg_t) base); 69 69 70 printf("RAM disk at %p (size %zu bytes)\n", (void *) base, size); 70 log(LF_OTHER, LVL_NOTE, "RAM disk at %p (size %zu bytes)", (void *) base, 71 size); 71 72 } 72 73 -
kernel/generic/src/main/kinit.c
raacdb8e rfd07e57b 59 59 #include <mm/km.h> 60 60 #include <print.h> 61 #include <log.h> 61 62 #include <memstr.h> 62 63 #include <console/console.h> … … 140 141 thread_ready(thread); 141 142 } else 142 printf("Unable to create kcpulb thread for cpu%u\n", i); 143 log(LF_OTHER, LVL_ERROR, 144 "Unable to create kcpulb thread for cpu%u", i); 143 145 } 144 146 } … … 156 158 thread_ready(thread); 157 159 else 158 printf("Unable to create kload thread\n");160 log(LF_OTHER, LVL_ERROR, "Unable to create kload thread"); 159 161 160 162 #ifdef CONFIG_KCONSOLE … … 168 170 thread_ready(thread); 169 171 else 170 printf("Unable to create kconsole thread\n"); 172 log(LF_OTHER, LVL_ERROR, 173 "Unable to create kconsole thread"); 171 174 } 172 175 #endif /* CONFIG_KCONSOLE */ … … 210 213 for (i = 0; i < init.cnt; i++) { 211 214 if (init.tasks[i].paddr % FRAME_SIZE) { 212 printf("init[%zu]: Address is not frame aligned\n", i); 215 log(LF_OTHER, LVL_ERROR, 216 "init[%zu]: Address is not frame aligned", i); 213 217 programs[i].task = NULL; 214 218 continue; … … 273 277 init_rd((void *) init.tasks[i].paddr, init.tasks[i].size); 274 278 } else 275 printf("init[%zu]: Init binary load failed " 276 "(error %d, loader status %u)\n", i, rc, 279 log(LF_OTHER, LVL_ERROR, 280 "init[%zu]: Init binary load failed " 281 "(error %d, loader status %u)", i, rc, 277 282 programs[i].loader_status); 278 283 } -
kernel/generic/src/main/main.c
raacdb8e rfd07e57b 62 62 #include <console/kconsole.h> 63 63 #include <console/console.h> 64 #include <log.h> 64 65 #include <cpu.h> 65 66 #include <align.h> … … 281 282 ipc_init(); 282 283 event_init(); 283 klog_init(); 284 kio_init(); 285 log_init(); 284 286 stats_init(); 285 287 -
kernel/generic/src/main/shutdown.c
raacdb8e rfd07e57b 39 39 #include <func.h> 40 40 #include <print.h> 41 #include <log.h> 41 42 42 43 void reboot(void) … … 45 46 46 47 #ifdef CONFIG_DEBUG 47 printf("Rebooting the system\n");48 log(LF_OTHER, LVL_DEBUG, "Rebooting the system"); 48 49 #endif 49 50 -
kernel/generic/src/mm/frame.c
raacdb8e rfd07e57b 54 54 #include <arch.h> 55 55 #include <print.h> 56 #include <log.h> 56 57 #include <align.h> 57 58 #include <mm/slab.h> … … 121 122 { 122 123 if (zones.count + 1 == ZONES_MAX) { 123 printf("Maximum zone count %u exceeded!\n", ZONES_MAX); 124 log(LF_OTHER, LVL_ERROR, "Maximum zone count %u exceeded!", 125 ZONES_MAX); 124 126 return (size_t) -1; 125 127 } … … 141 143 (!iswithin(zones.info[i].base, zones.info[i].count, 142 144 base, count))) { 143 printf("Zone (%p, %p) overlaps " 144 "with previous zone (%p %p)!\n", 145 log(LF_OTHER, LVL_WARN, 146 "Zone (%p, %p) overlaps " 147 "with previous zone (%p %p)!", 145 148 (void *) PFN2ADDR(base), (void *) PFN2ADDR(count), 146 149 (void *) PFN2ADDR(zones.info[i].base), … … 913 916 914 917 #ifdef CONFIG_DEBUG 915 printf("Thread %" PRIu64 " waiting for %zu frames " 916 "(%zu available).\n", THREAD->tid, count, avail); 918 log(LF_OTHER, LVL_DEBUG, 919 "Thread %" PRIu64 " waiting for %zu frames " 920 "%zu available.", THREAD->tid, count, avail); 917 921 #endif 918 922 … … 938 942 939 943 #ifdef CONFIG_DEBUG 940 printf("Thread %" PRIu64 " woken up.\n", THREAD->tid); 944 log(LF_OTHER, LVL_DEBUG, "Thread %" PRIu64 " woken up.", 945 THREAD->tid); 941 946 #endif 942 947 -
kernel/generic/src/proc/program.c
raacdb8e rfd07e57b 49 49 #include <lib/elf_load.h> 50 50 #include <errno.h> 51 #include < print.h>51 #include <log.h> 52 52 #include <syscall/copy.h> 53 53 #include <proc/program.h> … … 155 155 156 156 program_loader = image_addr; 157 printf("Program loader at %p\n", (void *) image_addr);157 log(LF_OTHER, LVL_NOTE, "Program loader at %p", (void *) image_addr); 158 158 159 159 return EOK; … … 181 181 if (!loader) { 182 182 as_destroy(as); 183 printf("Cannot spawn loader as none was registered\n"); 183 log(LF_OTHER, LVL_ERROR, 184 "Cannot spawn loader as none was registered"); 184 185 return ENOENT; 185 186 } … … 189 190 if (prg->loader_status != EE_OK) { 190 191 as_destroy(as); 191 printf("Cannot spawn loader (%s)\n",192 log(LF_OTHER, LVL_ERROR, "Cannot spawn loader (%s)", 192 193 elf_error(prg->loader_status)); 193 194 return ENOENT; -
kernel/generic/src/proc/scheduler.c
raacdb8e rfd07e57b 61 61 #include <cpu.h> 62 62 #include <print.h> 63 #include <log.h> 63 64 #include <debug.h> 64 65 #include <stacktrace.h> … … 517 518 518 519 #ifdef SCHEDULER_VERBOSE 519 printf("cpu%u: tid %" PRIu64 " (priority=%d, ticks=%" PRIu64 520 ", nrdy=%" PRIua ")\n", CPU->id, THREAD->tid, THREAD->priority, 520 log(LF_OTHER, LVL_DEBUG, 521 "cpu%u: tid %" PRIu64 " (priority=%d, ticks=%" PRIu64 522 ", nrdy=%" PRIua ")", CPU->id, THREAD->tid, THREAD->priority, 521 523 THREAD->ticks, atomic_get(&CPU->nrdy)); 522 524 #endif … … 663 665 664 666 #ifdef KCPULB_VERBOSE 665 printf("kcpulb%u: TID %" PRIu64 " -> cpu%u, " 666 "nrdy=%ld, avg=%ld\n", CPU->id, t->tid, 667 log(LF_OTHER, LVL_DEBUG, 668 "kcpulb%u: TID %" PRIu64 " -> cpu%u, " 669 "nrdy=%ld, avg=%ld", CPU->id, t->tid, 667 670 CPU->id, atomic_get(&CPU->nrdy), 668 671 atomic_get(&nrdy) / config.cpu_active); -
kernel/generic/src/syscall/syscall.c
raacdb8e rfd07e57b 56 56 #include <console/console.h> 57 57 #include <udebug/udebug.h> 58 #include <log.h> 58 59 59 60 /** Dispatch system call */ … … 86 87 rc = syscall_table[id](a1, a2, a3, a4, a5, a6); 87 88 } else { 88 printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); 89 log(LF_OTHER, LVL_ERROR, 90 "Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); 89 91 task_kill_self(true); 90 92 } … … 120 122 syshandler_t syscall_table[SYSCALL_END] = { 121 123 /* System management syscalls. */ 122 (syshandler_t) sys_k log,124 (syshandler_t) sys_kio, 123 125 (syshandler_t) sys_tls_set, 124 126 … … 190 192 191 193 /* Kernel console syscalls. */ 192 (syshandler_t) sys_debug_activate_console 194 (syshandler_t) sys_debug_activate_console, 195 196 (syshandler_t) sys_klog, 193 197 }; 194 198
Note:
See TracChangeset
for help on using the changeset viewer.
