- Timestamp:
- 2025-04-17T16:01:16Z (3 months ago)
- Branches:
- master
- Children:
- 888c06e
- Parents:
- 1db4e2ae (diff), 250a435 (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. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:51:11)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 16:01:16)
- Location:
- kernel
- Files:
-
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/ega/ega.c
r1db4e2ae rc4cfe4c 69 69 uint8_t *backbuf; 70 70 ioport8_t *base; 71 mbstate_t mbstate; 71 72 } ega_instance_t; 72 73 73 static void ega_ putuchar(outdev_t *, char32_t);74 static void ega_write(outdev_t *, const char *, size_t); 74 75 static void ega_redraw(outdev_t *); 75 76 76 77 static outdev_operations_t egadev_ops = { 77 .write = ega_ putuchar,78 .write = ega_write, 78 79 .redraw = ega_redraw, 79 80 .scroll_up = NULL, … … 538 539 } 539 540 540 static void ega_putuchar(outdev_t *dev, char32_t ch) 541 { 542 ega_instance_t *instance = (ega_instance_t *) dev->data; 543 544 irq_spinlock_lock(&instance->lock, true); 545 541 static void _putuchar(ega_instance_t *instance, char32_t ch) 542 { 546 543 switch (ch) { 547 544 case '\n': … … 564 561 ega_check_cursor(instance); 565 562 ega_move_cursor(instance); 563 } 564 565 static void ega_write(outdev_t *dev, const char *s, size_t n) 566 { 567 ega_instance_t *instance = (ega_instance_t *) dev->data; 568 569 irq_spinlock_lock(&instance->lock, true); 570 571 size_t offset = 0; 572 char32_t ch; 573 574 while ((ch = str_decode_r(s, &offset, n, U_SPECIAL, &instance->mbstate))) 575 _putuchar(instance, ch); 566 576 567 577 irq_spinlock_unlock(&instance->lock, true); -
kernel/genarch/src/drivers/ns16550/ns16550.c
r1db4e2ae rc4cfe4c 112 112 } 113 113 114 static void ns16550_ putuchar(outdev_t *dev, char32_t ch)114 static void ns16550_write(outdev_t *dev, const char *s, size_t n) 115 115 { 116 116 ns16550_instance_t *instance = (ns16550_instance_t *) dev->data; 117 117 118 if ((!instance->parea.mapped) || (console_override)) { 119 if (ch == '\n') 118 if (instance->parea.mapped && !console_override) 119 return; 120 121 const char *top = s + n; 122 assert(top >= s); 123 124 for (; s < top; s++) { 125 if (*s == '\n') 120 126 ns16550_sendb(instance, '\r'); 121 127 122 if (ascii_check(ch)) 123 ns16550_sendb(instance, (uint8_t) ch); 124 else 125 ns16550_sendb(instance, U_SPECIAL); 128 ns16550_sendb(instance, (uint8_t) *s); 126 129 } 127 130 } 128 131 129 132 static outdev_operations_t ns16550_ops = { 130 .write = ns16550_ putuchar,133 .write = ns16550_write, 131 134 .redraw = NULL 132 135 }; -
kernel/genarch/src/drivers/pl011/pl011.c
r1db4e2ae rc4cfe4c 56 56 } 57 57 58 static void pl011_uart_ putuchar(outdev_t *dev, char32_t ch)58 static void pl011_uart_write(outdev_t *dev, const char *s, size_t n) 59 59 { 60 60 pl011_uart_t *uart = dev->data; … … 64 64 return; 65 65 66 if (!ascii_check(ch)) 67 pl011_uart_sendb(uart, U_SPECIAL); 68 else { 69 if (ch == '\n') 70 pl011_uart_sendb(uart, (uint8_t) '\r'); 71 pl011_uart_sendb(uart, (uint8_t) ch); 66 const char *top = s + n; 67 assert(top >= s); 68 69 for (; s < top; s++) { 70 if (*s == '\n') 71 pl011_uart_sendb(uart, '\r'); 72 73 pl011_uart_sendb(uart, (uint8_t) *s); 72 74 } 73 75 } 74 76 75 77 static outdev_operations_t pl011_uart_ops = { 76 .write = pl011_uart_ putuchar,78 .write = pl011_uart_write, 77 79 .redraw = NULL, 78 80 .scroll_up = NULL, -
kernel/genarch/src/fb/fb.c
r1db4e2ae rc4cfe4c 121 121 /** Current backbuffer position */ 122 122 unsigned int position; 123 124 /** Partial character between writes */ 125 mbstate_t mbstate; 123 126 } fb_instance_t; 124 127 125 static void fb_ putuchar(outdev_t *, char32_t);128 static void fb_write(outdev_t *, const char *, size_t); 126 129 static void fb_redraw(outdev_t *); 127 130 static void fb_scroll_up(outdev_t *); … … 129 132 130 133 static outdev_operations_t fbdev_ops = { 131 .write = fb_ putuchar,134 .write = fb_write, 132 135 .redraw = fb_redraw, 133 136 .scroll_up = fb_scroll_up, … … 418 421 * 419 422 */ 420 static void fb_putuchar(outdev_t *dev, char32_t ch) 421 { 422 fb_instance_t *instance = (fb_instance_t *) dev->data; 423 spinlock_lock(&instance->lock); 424 423 static void _putuchar(fb_instance_t *instance, char32_t ch) 424 { 425 425 switch (ch) { 426 426 case '\n': 427 cursor_remove(instance);428 427 instance->position += instance->cols; 429 428 instance->position -= instance->position % instance->cols; 430 429 break; 431 430 case '\r': 432 cursor_remove(instance);433 431 instance->position -= instance->position % instance->cols; 434 432 break; 435 433 case '\b': 436 cursor_remove(instance);437 434 if (instance->position % instance->cols) 438 435 instance->position--; 439 436 break; 440 437 case '\t': 441 cursor_remove(instance);442 438 do { 443 439 glyph_draw(instance, fb_font_glyph(' '), … … 459 455 screen_scroll(instance); 460 456 } 457 } 458 459 static void fb_write(outdev_t *dev, const char *s, size_t n) 460 { 461 fb_instance_t *instance = (fb_instance_t *) dev->data; 462 463 spinlock_lock(&instance->lock); 464 cursor_remove(instance); 465 466 size_t offset = 0; 467 char32_t ch; 468 469 while ((ch = str_decode_r(s, &offset, n, U_SPECIAL, &instance->mbstate))) 470 _putuchar(instance, ch); 461 471 462 472 cursor_put(instance); 463 464 473 spinlock_unlock(&instance->lock); 465 474 } -
kernel/generic/include/console/chardev.h
r1db4e2ae rc4cfe4c 81 81 /** Output character device operations interface. */ 82 82 typedef struct { 83 /** Write characterto output. */84 void (*write)(struct outdev *, c har32_t);83 /** Write string to output. */ 84 void (*write)(struct outdev *, const char *, size_t); 85 85 86 86 /** Redraw any previously cached characters. */ -
kernel/generic/include/console/console.h
r1db4e2ae rc4cfe4c 36 36 #define KERN_CONSOLE_H_ 37 37 38 #include <typedefs.h>39 #include <print.h>40 38 #include <console/chardev.h> 41 39 #include <synch/spinlock.h> … … 66 64 extern void kio_update(void *); 67 65 extern void kio_flush(void); 68 extern void kio_push_ char(const char32_t);69 SPINLOCK_EXTERN(kio_lock);66 extern void kio_push_bytes(const char *, size_t); 67 extern irq_spinlock_t kio_lock; 70 68 69 extern sysarg_t sys_kio_read(uspace_addr_t buf, size_t size, size_t at); 71 70 extern sys_errno_t sys_kio(int cmd, uspace_addr_t buf, size_t size); 72 71 … … 79 78 extern void console_unlock(void); 80 79 80 extern void putstr(const char *s, size_t n); 81 81 82 #endif /* KERN_CONSOLE_H_ */ 82 83 -
kernel/generic/include/stdio.h
r1db4e2ae rc4cfe4c 37 37 38 38 #include <print.h> 39 #include <putchar.h>40 39 41 40 #endif -
kernel/generic/src/console/console.c
r1db4e2ae rc4cfe4c 2 2 * Copyright (c) 2003 Josef Cejka 3 3 * Copyright (c) 2005 Jakub Jermar 4 * Copyright (c) 2025 Jiří Zárevúcky 4 5 * All rights reserved. 5 6 * … … 35 36 36 37 #include <abi/kio.h> 37 #include <arch.h>38 #include <assert.h>39 #include <atomic.h>40 38 #include <console/chardev.h> 41 39 #include <console/console.h> 42 #include <ddi/ddi.h>43 #include <ddi/irq.h>44 40 #include <errno.h> 45 41 #include <ipc/event.h> 46 #include <ipc/irq.h> 47 #include <mm/frame.h> /* SIZE2FRAMES */ 42 #include <log.h> 48 43 #include <panic.h> 49 44 #include <preemption.h> 50 #include <proc/thread.h> 51 #include <putchar.h> 45 #include <proc/task.h> 52 46 #include <stdatomic.h> 53 47 #include <stdio.h> … … 56 50 #include <synch/mutex.h> 57 51 #include <synch/spinlock.h> 58 #include <synch/waitq.h>59 52 #include <syscall/copy.h> 60 53 #include <sysinfo/sysinfo.h> 61 #include <typedefs.h>62 54 63 55 #define KIO_PAGES 8 64 #define KIO_LENGTH (KIO_PAGES * PAGE_SIZE / sizeof(char32_t))56 #define KIO_LENGTH (KIO_PAGES * PAGE_SIZE) 65 57 66 58 /** Kernel log cyclic buffer */ 67 char32_t kio[KIO_LENGTH] __attribute__((aligned(PAGE_SIZE)));59 static char kio[KIO_LENGTH]; 68 60 69 61 /** Kernel log initialized */ … … 76 68 static MUTEX_INITIALIZE(console_mutex, MUTEX_RECURSIVE); 77 69 78 /** First kernel log characters */ 79 static size_t kio_start = 0; 80 81 /** Number of valid kernel log characters */ 82 static size_t kio_len = 0; 83 84 /** Number of stored (not printed) kernel log characters */ 85 static size_t kio_stored = 0; 86 87 /** Number of stored kernel log characters for uspace */ 88 static size_t kio_uspace = 0; 70 /** Number of characters written to buffer. Periodically overflows. */ 71 static size_t kio_written = 0; 72 73 /** Number of characters written to output devices. Periodically overflows. */ 74 static size_t kio_processed = 0; 75 76 /** Last notification sent to uspace. */ 77 static size_t kio_notified = 0; 89 78 90 79 /** Kernel log spinlock */ 91 SPINLOCK_INITIALIZE_NAME(kio_lock, "kio_lock"); 92 93 /** Physical memory area used for kio buffer */ 94 static parea_t kio_parea; 80 IRQ_SPINLOCK_INITIALIZE(kio_lock); 81 82 static IRQ_SPINLOCK_INITIALIZE(flush_lock); 83 84 static IRQ_SPINLOCK_INITIALIZE(early_mbstate_lock); 85 static mbstate_t early_mbstate; 95 86 96 87 static indev_t stdin_sink; … … 104 95 }; 105 96 106 static void stdout_write(outdev_t *, c har32_t);97 static void stdout_write(outdev_t *, const char *, size_t); 107 98 static void stdout_redraw(outdev_t *); 108 99 static void stdout_scroll_up(outdev_t *); … … 157 148 } 158 149 159 static void stdout_write(outdev_t *dev, c har32_t ch)150 static void stdout_write(outdev_t *dev, const char *s, size_t n) 160 151 { 161 152 list_foreach(dev->list, link, outdev_t, sink) { 162 153 if ((sink) && (sink->op->write)) 163 sink->op->write(sink, ch);154 sink->op->write(sink, s, n); 164 155 } 165 156 } … … 190 181 191 182 /** Initialize kernel logging facility 192 *193 * The shared area contains kernel cyclic buffer. Userspace application may194 * be notified on new data with indication of position and size195 * of the data within the circular buffer.196 *197 183 */ 198 184 void kio_init(void) 199 185 { 200 void *faddr = (void *) KA2PA(kio);201 202 assert((uintptr_t) faddr % FRAME_SIZE == 0);203 204 ddi_parea_init(&kio_parea);205 kio_parea.pbase = (uintptr_t) faddr;206 kio_parea.frames = SIZE2FRAMES(sizeof(kio));207 kio_parea.unpriv = false;208 kio_parea.mapped = false;209 ddi_parea_register(&kio_parea);210 211 sysinfo_set_item_val("kio.faddr", NULL, (sysarg_t) faddr);212 sysinfo_set_item_val("kio.pages", NULL, KIO_PAGES);213 214 186 event_set_unmask_callback(EVENT_KIO, kio_update); 215 187 atomic_store(&kio_inited, true); … … 257 229 return; 258 230 259 spinlock_lock(&kio_lock); 260 261 if (kio_uspace > 0) { 262 if (event_notify_3(EVENT_KIO, true, kio_start, kio_len, 263 kio_uspace) == EOK) 264 kio_uspace = 0; 265 } 266 267 spinlock_unlock(&kio_lock); 231 irq_spinlock_lock(&kio_lock, true); 232 233 if (kio_notified != kio_written) { 234 if (event_notify_1(EVENT_KIO, true, kio_written) == EOK) 235 kio_notified = kio_written; 236 } 237 238 irq_spinlock_unlock(&kio_lock, true); 268 239 } 269 240 … … 278 249 return; 279 250 280 spinlock_lock(&kio_lock); 251 irq_spinlock_lock(&kio_lock, true); 252 253 if (!irq_spinlock_trylock(&flush_lock)) { 254 /* Someone is currently flushing. */ 255 irq_spinlock_unlock(&kio_lock, true); 256 return; 257 } 258 259 /* A small-ish local buffer so that we can write to output in chunks. */ 260 char buffer[256]; 281 261 282 262 /* Print characters that weren't printed earlier */ 283 while (kio_stored > 0) { 284 char32_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH]; 285 kio_stored--; 263 while (kio_written != kio_processed) { 264 size_t offset = kio_processed % KIO_LENGTH; 265 size_t len = min(kio_written - kio_processed, KIO_LENGTH - offset); 266 len = min(len, sizeof(buffer)); 267 268 /* Take out a chunk of the big buffer. */ 269 memcpy(buffer, &kio[offset], len); 270 kio_processed += len; 286 271 287 272 /* 288 * We need to give up the spinlock for 289 * the physical operation of writing out 290 * the character. 273 * We need to give up the spinlock for the physical operation of writing 274 * out the buffer. 291 275 */ 292 spinlock_unlock(&kio_lock); 293 stdout->op->write(stdout, tmp); 294 spinlock_lock(&kio_lock); 295 } 296 297 spinlock_unlock(&kio_lock); 298 } 299 300 /** Put a character into the output buffer. 301 * 302 * The caller is required to hold kio_lock 303 */ 304 void kio_push_char(const char32_t ch) 305 { 306 kio[(kio_start + kio_len) % KIO_LENGTH] = ch; 307 if (kio_len < KIO_LENGTH) 308 kio_len++; 309 else 310 kio_start = (kio_start + 1) % KIO_LENGTH; 311 312 if (kio_stored < kio_len) 313 kio_stored++; 314 315 /* The character is stored for uspace */ 316 if (kio_uspace < kio_len) 317 kio_uspace++; 318 } 319 320 void putuchar(const char32_t ch) 276 irq_spinlock_unlock(&kio_lock, true); 277 stdout->op->write(stdout, buffer, len); 278 irq_spinlock_lock(&kio_lock, true); 279 } 280 281 irq_spinlock_unlock(&flush_lock, false); 282 irq_spinlock_unlock(&kio_lock, true); 283 } 284 285 void kio_push_bytes(const char *s, size_t n) 286 { 287 /* Skip the section we know we can't keep. */ 288 if (n > KIO_LENGTH) { 289 size_t lost = n - KIO_LENGTH; 290 kio_written += lost; 291 s += lost; 292 n -= lost; 293 } 294 295 size_t offset = kio_written % KIO_LENGTH; 296 if (offset + n > KIO_LENGTH) { 297 size_t first = KIO_LENGTH - offset; 298 size_t last = n - first; 299 memcpy(kio + offset, s, first); 300 memcpy(kio, s + first, last); 301 } else { 302 memcpy(kio + offset, s, n); 303 } 304 305 kio_written += n; 306 } 307 308 static void early_putstr(const char *s, size_t n) 309 { 310 irq_spinlock_lock(&early_mbstate_lock, true); 311 312 size_t offset = 0; 313 char32_t c; 314 315 while ((c = str_decode_r(s, &offset, n, U_SPECIAL, &early_mbstate))) 316 early_putuchar(c); 317 318 irq_spinlock_unlock(&early_mbstate_lock, true); 319 } 320 321 void putstr(const char *s, size_t n) 321 322 { 322 323 bool ordy = ((stdout) && (stdout->op->write)); 323 324 324 spinlock_lock(&kio_lock);325 kio_push_ char(ch);326 spinlock_unlock(&kio_lock);325 irq_spinlock_lock(&kio_lock, true); 326 kio_push_bytes(s, n); 327 irq_spinlock_unlock(&kio_lock, true); 327 328 328 329 /* Output stored characters */ … … 340 341 * a no-op on certain hardware configurations. 341 342 */ 342 early_put uchar(ch);343 } 344 345 /* Force notification onnewline */346 if ( ch == '\n')343 early_putstr(s, n); 344 } 345 346 /* Force notification when containing a newline */ 347 if (memchr(s, '\n', n) != NULL) 347 348 kio_update(NULL); 349 } 350 351 /** Reads up to `size` characters from kio buffer starting at character `at`. 352 * 353 * @param size Maximum number of characters that can be stored in buffer. 354 * Values greater than KIO_LENGTH are silently treated as KIO_LENGTH 355 * for the purposes of calculating the return value. 356 * @return Number of characters read. Can be more than `size`. 357 * In that case, `size` characters are written to user buffer 358 * and the extra amount is the number of characters missed. 359 */ 360 sysarg_t sys_kio_read(uspace_addr_t buf, size_t size, size_t at) 361 { 362 errno_t rc; 363 size_t missed = 0; 364 365 irq_spinlock_lock(&kio_lock, true); 366 367 if (at == kio_written) { 368 irq_spinlock_unlock(&kio_lock, true); 369 return 0; 370 } 371 372 size_t readable_chars = kio_written - at; 373 if (readable_chars > KIO_LENGTH) { 374 missed = readable_chars - KIO_LENGTH; 375 readable_chars = KIO_LENGTH; 376 } 377 378 size_t actual_read = min(readable_chars, size); 379 size_t offset = (kio_written - readable_chars) % KIO_LENGTH; 380 381 if (offset + actual_read > KIO_LENGTH) { 382 size_t first = KIO_LENGTH - offset; 383 size_t last = actual_read - first; 384 385 rc = copy_to_uspace(buf, &kio[offset], first); 386 if (rc == EOK) 387 rc = copy_to_uspace(buf + first, &kio[0], last); 388 } else { 389 rc = copy_to_uspace(buf, &kio[offset], actual_read); 390 } 391 392 irq_spinlock_unlock(&kio_lock, true); 393 394 if (rc != EOK) { 395 log(LF_OTHER, LVL_WARN, 396 "[%s(%" PRIu64 ")] Terminating due to invalid memory buffer" 397 " in SYS_KIO_READ.\n", TASK->name, TASK->taskid); 398 task_kill_self(true); 399 } 400 401 return actual_read + missed; 348 402 } 349 403 -
kernel/generic/src/console/kconsole.c
r1db4e2ae rc4cfe4c 39 39 */ 40 40 41 #include <adt/list.h> 42 #include <arch.h> 41 43 #include <assert.h> 42 #include <console/kconsole.h>43 #include <console/console.h>44 44 #include <console/chardev.h> 45 45 #include <console/cmd.h> 46 #include <console/console.h> 47 #include <console/kconsole.h> 46 48 #include <console/prompt.h> 49 #include <debug.h> 50 #include <errno.h> 51 #include <halt.h> 52 #include <macros.h> 53 #include <panic.h> 47 54 #include <stdio.h> 48 #include <panic.h> 55 #include <stdlib.h> 56 #include <str.h> 57 #include <symtab.h> 58 #include <sysinfo/sysinfo.h> 49 59 #include <typedefs.h> 50 #include <adt/list.h>51 #include <arch.h>52 #include <macros.h>53 #include <debug.h>54 #include <halt.h>55 #include <str.h>56 #include <sysinfo/sysinfo.h>57 #include <symtab.h>58 #include <errno.h>59 #include <putchar.h>60 #include <stdlib.h>61 60 62 61 /** Simple kernel console. … … 158 157 159 158 /** Print count times a character */ 160 _NO_TRACE static void print_cc(char32_t ch, size_t count) 161 { 162 size_t i; 163 for (i = 0; i < count; i++) 164 putuchar(ch); 159 _NO_TRACE static void print_cc(char ch, size_t count) 160 { 161 // FIXME: only lock once 162 163 for (size_t i = 0; i < count; i++) 164 putstr(&ch, 1); 165 165 } 166 166 … … 347 347 if (ch == '\n') { 348 348 /* Enter */ 349 put uchar(ch);349 putstr("\n", 1); 350 350 break; 351 351 } … … 358 358 if (wstr_remove(current, position - 1)) { 359 359 position--; 360 put uchar('\b');360 putstr("\b", 1); 361 361 printf("%ls ", current + position); 362 362 print_cc('\b', wstr_length(current) - position + 1); … … 368 368 /* Tab completion */ 369 369 370 /* Move to the end of the word */ 371 for (; (current[position] != 0) && (!isspace(current[position])); 372 position++) 373 putuchar(current[position]); 370 size_t i = position; 371 while (current[i] && !isspace(current[i])) 372 i++; 373 374 char32_t stash = current[i]; 375 current[i] = 0; 376 printf("%ls", ¤t[position]); 377 current[i] = stash; 378 position = i; 374 379 375 380 /* … … 430 435 */ 431 436 size_t off = 0; 432 size_t i = 0; 433 while ((ch = str_decode(tmp, &off, STR_NO_LIMIT)) != 0) { 437 for (size_t i = 0; (ch = str_decode(tmp, &off, STR_NO_LIMIT)); i++) 434 438 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 435 439 break; 436 437 i++;438 }439 440 440 441 if (found > 1) { … … 466 467 /* Left */ 467 468 if (position > 0) { 468 put uchar('\b');469 putstr("\b", 1); 469 470 position--; 470 471 } … … 475 476 /* Right */ 476 477 if (position < wstr_length(current)) { 477 p utuchar(current[position]);478 printf("%lc", current[position]); 478 479 position++; 479 480 } -
kernel/generic/src/log/log.c
r1db4e2ae rc4cfe4c 46 46 #include <print.h> 47 47 #include <printf_core.h> 48 #include <putchar.h>49 48 #include <stdarg.h> 50 49 #include <stdlib.h> … … 60 59 61 60 /** Cyclic buffer holding the data for kernel log */ 62 uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE)));61 static uint8_t log_buffer[LOG_LENGTH] __attribute__((aligned(PAGE_SIZE))); 63 62 64 63 /** Kernel log initialized */ … … 66 65 67 66 /** Position in the cyclic buffer where the first log entry starts */ 68 s ize_t log_start = 0;67 static size_t log_start = 0; 69 68 70 69 /** Sum of length of all log entries currently stored in the cyclic buffer */ 71 s ize_t log_used = 0;70 static size_t log_used = 0; 72 71 73 72 /** Log spinlock */ 74 SPINLOCK_STATIC_INITIALIZE_NAME(log_lock, "log_lock");73 static IRQ_SPINLOCK_INITIALIZE(log_lock); 75 74 76 75 /** Overall count of logged messages, which may overflow as needed */ … … 152 151 { 153 152 console_lock(); 154 spinlock_lock(&log_lock);155 spinlock_lock(&kio_lock);153 irq_spinlock_lock(&log_lock, true); 154 irq_spinlock_lock(&kio_lock, true); 156 155 157 156 log_current_start = (log_start + log_used) % LOG_LENGTH; … … 179 178 log_used += log_current_len; 180 179 181 kio_push_ char('\n');182 spinlock_unlock(&kio_lock);183 spinlock_unlock(&log_lock);180 kio_push_bytes("\n", 1); 181 irq_spinlock_unlock(&kio_lock, true); 182 irq_spinlock_unlock(&log_lock, true); 184 183 185 184 /* This has to be called after we released the locks above */ … … 195 194 return; 196 195 197 spinlock_lock(&log_lock);196 irq_spinlock_lock(&log_lock, true); 198 197 if (next_for_uspace < log_used) 199 198 event_notify_0(EVENT_KLOG, true); 200 spinlock_unlock(&log_lock);199 irq_spinlock_unlock(&log_lock, true); 201 200 } 202 201 203 202 static int log_printf_str_write(const char *str, size_t size, void *data) 204 203 { 205 size_t offset = 0; 206 207 while (offset < size) 208 kio_push_char(str_decode(str, &offset, size)); 209 204 kio_push_bytes(str, size); 210 205 log_append((const uint8_t *)str, size); 211 212 206 return EOK; 213 207 } … … 307 301 rc = EOK; 308 302 309 spinlock_lock(&log_lock);303 irq_spinlock_lock(&log_lock, true); 310 304 311 305 while (next_for_uspace < log_used) { … … 337 331 } 338 332 339 spinlock_unlock(&log_lock);333 irq_spinlock_unlock(&log_lock, true); 340 334 341 335 if (rc != EOK) { -
kernel/generic/src/printf/vprintf.c
r1db4e2ae rc4cfe4c 37 37 #include <print.h> 38 38 #include <printf_core.h> 39 #include <putchar.h>40 39 #include <str.h> 41 40 #include <synch/spinlock.h> … … 44 43 static errno_t vprintf_str_write(const char *str, size_t size, void *data) 45 44 { 46 size_t offset = 0; 47 48 while (offset < size) 49 putuchar(str_decode(str, &offset, size)); 50 45 putstr(str, size); 51 46 return EOK; 52 47 } … … 54 49 int puts(const char *str) 55 50 { 56 size_t offset = 0; 57 size_t chars = 0; 58 char32_t uc; 59 60 console_lock(); 61 62 while ((uc = str_decode(str, &offset, STR_NO_LIMIT)) != 0) { 63 putuchar(uc); 64 chars++; 65 } 66 67 putuchar('\n'); 68 69 console_unlock(); 70 return chars; 51 size_t n = str_size(str); 52 putstr(str, n); 53 return n; 71 54 } 72 55 -
kernel/generic/src/syscall/syscall.c
r1db4e2ae rc4cfe4c 137 137 138 138 [SYS_KLOG] = (syshandler_t) sys_klog, 139 [SYS_KIO_READ] = (syshandler_t) sys_kio_read, 139 140 }; 140 141 -
kernel/test/print/print4.c
r1db4e2ae rc4cfe4c 50 50 } 51 51 52 TPRINTF("\nExtended ASCII characters (1 28- 255) using printf(\"%%lc\"):\n");52 TPRINTF("\nExtended ASCII characters (160 - 255) using printf(\"%%lc\"):\n"); 53 53 54 for (group = 4; group < 8; group++) {54 for (group = 5; group < 8; group++) { 55 55 TPRINTF("%#x: ", group << 5); 56 56
Note:
See TracChangeset
for help on using the changeset viewer.