Changeset 39e1b9a in mainline for kernel/generic/src/console/console.c
- Timestamp:
- 2025-04-17T15:37:05Z (5 days ago)
- Branches:
- master
- Children:
- 250a435
- Parents:
- 690ad20
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-14 16:54:54)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:37:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/console.c
r690ad20 r39e1b9a 80 80 IRQ_SPINLOCK_INITIALIZE(kio_lock); 81 81 82 static IRQ_SPINLOCK_INITIALIZE(flush_lock); 83 82 84 static IRQ_SPINLOCK_INITIALIZE(early_mbstate_lock); 83 85 static mbstate_t early_mbstate; … … 93 95 }; 94 96 95 static void stdout_write(outdev_t *, c har32_t);97 static void stdout_write(outdev_t *, const char *, size_t); 96 98 static void stdout_redraw(outdev_t *); 97 99 static void stdout_scroll_up(outdev_t *); … … 146 148 } 147 149 148 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) 149 151 { 150 152 list_foreach(dev->list, link, outdev_t, sink) { 151 153 if ((sink) && (sink->op->write)) 152 sink->op->write(sink, ch);154 sink->op->write(sink, s, n); 153 155 } 154 156 } … … 249 251 irq_spinlock_lock(&kio_lock, true); 250 252 251 static mbstate_t mbstate; 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]; 252 261 253 262 /* Print characters that weren't printed earlier */ … … 255 264 size_t offset = kio_processed % KIO_LENGTH; 256 265 size_t len = min(kio_written - kio_processed, KIO_LENGTH - offset); 257 size_t bytes = 0;258 259 char32_t ch = str_decode_r(&kio[offset], &bytes, len, U'�', &mbstate);260 assert(bytes <= 4);261 kio_processed += bytes;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; 262 271 263 272 /* 264 * We need to give up the spinlock for 265 * the physical operation of writing out 266 * the character. 273 * We need to give up the spinlock for the physical operation of writing 274 * out the buffer. 267 275 */ 268 276 irq_spinlock_unlock(&kio_lock, true); 269 stdout->op->write(stdout, ch);277 stdout->op->write(stdout, buffer, len); 270 278 irq_spinlock_lock(&kio_lock, true); 271 279 } 272 280 281 irq_spinlock_unlock(&flush_lock, false); 273 282 irq_spinlock_unlock(&kio_lock, true); 274 283 }
Note:
See TracChangeset
for help on using the changeset viewer.