Changes in kernel/generic/src/console/console.c [d7533c7:712c4ba] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/console.c
rd7533c7 r712c4ba 53 53 #include <str.h> 54 54 55 #define KLOG_PAGES 455 #define KLOG_PAGES 8 56 56 #define KLOG_LENGTH (KLOG_PAGES * PAGE_SIZE / sizeof(wchar_t)) 57 #define KLOG_LATENCY 858 57 59 58 /** Kernel log cyclic buffer */ … … 61 60 62 61 /** Kernel log initialized */ 63 static bool klog_inited = false;62 static atomic_t klog_inited = {false}; 64 63 65 64 /** First kernel log characters */ … … 76 75 77 76 /** Kernel log spinlock */ 78 SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, " *klog_lock");77 SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "klog_lock"); 79 78 80 79 /** Physical memory area used for klog buffer */ … … 166 165 sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES); 167 166 168 spinlock_lock(&klog_lock); 169 klog_inited = true; 170 spinlock_unlock(&klog_lock); 167 event_set_unmask_callback(EVENT_KLOG, klog_update); 168 atomic_set(&klog_inited, true); 171 169 } 172 170 … … 263 261 void klog_update(void) 264 262 { 263 if (!atomic_get(&klog_inited)) 264 return; 265 265 266 spinlock_lock(&klog_lock); 266 267 267 if ((klog_inited) && (event_is_subscribed(EVENT_KLOG)) && (klog_uspace > 0)) { 268 event_notify_3(EVENT_KLOG, klog_start, klog_len, klog_uspace); 269 klog_uspace = 0; 268 if (klog_uspace > 0) { 269 if (event_notify_3(EVENT_KLOG, true, klog_start, klog_len, 270 klog_uspace) == EOK) 271 klog_uspace = 0; 270 272 } 271 273 … … 275 277 void putchar(const wchar_t ch) 276 278 { 279 bool ordy = ((stdout) && (stdout->op->write)); 280 277 281 spinlock_lock(&klog_lock); 278 282 279 if ((klog_stored > 0) && (stdout) && (stdout->op->write)) { 280 /* Print charaters stored in kernel log */ 281 size_t i; 282 for (i = klog_len - klog_stored; i < klog_len; i++) 283 stdout->op->write(stdout, klog[(klog_start + i) % KLOG_LENGTH], silent); 284 klog_stored = 0; 283 /* Print charaters stored in kernel log */ 284 if (ordy) { 285 while (klog_stored > 0) { 286 wchar_t tmp = klog[(klog_start + klog_len - klog_stored) % KLOG_LENGTH]; 287 klog_stored--; 288 289 /* 290 * We need to give up the spinlock for 291 * the physical operation of writting out 292 * the character. 293 */ 294 spinlock_unlock(&klog_lock); 295 stdout->op->write(stdout, tmp, silent); 296 spinlock_lock(&klog_lock); 297 } 285 298 } 286 299 … … 292 305 klog_start = (klog_start + 1) % KLOG_LENGTH; 293 306 294 if ((stdout) && (stdout->op->write)) 307 if (!ordy) { 308 if (klog_stored < klog_len) 309 klog_stored++; 310 } 311 312 /* The character is stored for uspace */ 313 if (klog_uspace < klog_len) 314 klog_uspace++; 315 316 spinlock_unlock(&klog_lock); 317 318 if (ordy) { 319 /* 320 * Output the character. In this case 321 * it should be no longer buffered. 322 */ 295 323 stdout->op->write(stdout, ch, silent); 296 else {324 } else { 297 325 /* 298 326 * No standard output routine defined yet. … … 304 332 * Note that the early_putc() function might be 305 333 * a no-op on certain hardware configurations. 306 *307 334 */ 308 335 early_putchar(ch); 309 310 if (klog_stored < klog_len) 311 klog_stored++; 312 } 313 314 /* The character is stored for uspace */ 315 if (klog_uspace < klog_len) 316 klog_uspace++; 317 318 /* Check notify uspace to update */ 319 bool update; 320 if ((klog_uspace > KLOG_LATENCY) || (ch == '\n')) 321 update = true; 322 else 323 update = false; 324 325 spinlock_unlock(&klog_lock); 326 327 if (update) 336 } 337 338 /* Force notification on newline */ 339 if (ch == '\n') 328 340 klog_update(); 329 341 }
Note:
See TracChangeset
for help on using the changeset viewer.