Changeset 91db0280 in mainline for kernel/generic/src/console/console.c
- Timestamp:
- 2014-01-05T19:59:56Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 927cd9c
- Parents:
- 6fa9a99d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/console.c
r6fa9a99d r91db0280 76 76 77 77 /** Kernel log spinlock */ 78 SPINLOCK_ STATIC_INITIALIZE_NAME(kio_lock, "kio_lock");78 SPINLOCK_INITIALIZE_NAME(kio_lock, "kio_lock"); 79 79 80 80 /** Physical memory area used for kio buffer */ … … 263 263 } 264 264 265 void putchar(const wchar_t ch) 265 /** Flush characters that are stored in the output buffer 266 * 267 */ 268 void kio_flush(void) 266 269 { 267 270 bool ordy = ((stdout) && (stdout->op->write)); 268 271 272 if (!ordy) 273 return; 274 269 275 spinlock_lock(&kio_lock); 270 271 /* Print charaters stored in kernel log */ 272 if (ordy) { 273 while (kio_stored > 0) { 274 wchar_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH]; 275 kio_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(&kio_lock); 283 stdout->op->write(stdout, tmp); 284 spinlock_lock(&kio_lock); 285 } 286 } 287 288 /* Store character in the cyclic kernel log */ 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 { 289 301 kio[(kio_start + kio_len) % KIO_LENGTH] = ch; 290 302 if (kio_len < KIO_LENGTH) … … 293 305 kio_start = (kio_start + 1) % KIO_LENGTH; 294 306 295 if (!ordy) { 296 if (kio_stored < kio_len) 297 kio_stored++; 298 } 307 if (kio_stored < kio_len) 308 kio_stored++; 299 309 300 310 /* The character is stored for uspace */ 301 311 if (kio_uspace < kio_len) 302 312 kio_uspace++; 303 313 } 314 315 void putchar(const wchar_t ch) 316 { 317 bool ordy = ((stdout) && (stdout->op->write)); 318 319 spinlock_lock(&kio_lock); 320 kio_push_char(ch); 304 321 spinlock_unlock(&kio_lock); 305 322 306 if (ordy) { 307 /* 308 * Output the character. In this case 309 * it should be no longer buffered. 310 */ 311 stdout->op->write(stdout, ch); 312 } else { 323 /* Output stored characters */ 324 kio_flush(); 325 326 if (!ordy) { 313 327 /* 314 328 * No standard output routine defined yet.
Note:
See TracChangeset
for help on using the changeset viewer.