Changeset 28a5ebd in mainline for kernel/generic/src/console
- Timestamp:
- 2020-06-18T15:39:50Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce52c333
- Parents:
- 4f663f3e
- Location:
- kernel/generic/src/console
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/chardev.c
r4f663f3e r28a5ebd 65 65 * 66 66 */ 67 void indev_push_character(indev_t *indev, wchar_t ch)67 void indev_push_character(indev_t *indev, char32_t ch) 68 68 { 69 69 assert(indev); … … 92 92 * 93 93 */ 94 wchar_t indev_pop_character(indev_t *indev)94 char32_t indev_pop_character(indev_t *indev) 95 95 { 96 96 if (atomic_load(&haltstate)) { … … 117 117 waitq_sleep(&indev->wq); 118 118 irq_spinlock_lock(&indev->lock, true); 119 wchar_t ch = indev->buffer[(indev->index - indev->counter) %119 char32_t ch = indev->buffer[(indev->index - indev->counter) % 120 120 INDEV_BUFLEN]; 121 121 indev->counter--; -
kernel/generic/src/console/console.c
r4f663f3e r28a5ebd 59 59 60 60 #define KIO_PAGES 8 61 #define KIO_LENGTH (KIO_PAGES * PAGE_SIZE / sizeof( wchar_t))61 #define KIO_LENGTH (KIO_PAGES * PAGE_SIZE / sizeof(char32_t)) 62 62 63 63 /** Kernel log cyclic buffer */ 64 wchar_t kio[KIO_LENGTH] __attribute__((aligned(PAGE_SIZE)));64 char32_t kio[KIO_LENGTH] __attribute__((aligned(PAGE_SIZE))); 65 65 66 66 /** Kernel log initialized */ … … 95 95 }; 96 96 97 static void stdout_write(outdev_t *, wchar_t);97 static void stdout_write(outdev_t *, char32_t); 98 98 static void stdout_redraw(outdev_t *); 99 99 static void stdout_scroll_up(outdev_t *); … … 148 148 } 149 149 150 static void stdout_write(outdev_t *dev, wchar_t ch)150 static void stdout_write(outdev_t *dev, char32_t ch) 151 151 { 152 152 list_foreach(dev->list, link, outdev_t, sink) { … … 261 261 buf[offset] = 0; 262 262 263 wchar_t ch;263 char32_t ch; 264 264 while ((ch = indev_pop_character(indev)) != '\n') { 265 265 if (ch == '\b') { 266 266 if (count > 0) { 267 267 /* Space, backspace, space */ 268 put wchar('\b');269 put wchar(' ');270 put wchar('\b');268 putuchar('\b'); 269 putuchar(' '); 270 putuchar('\b'); 271 271 272 272 count--; … … 277 277 278 278 if (chr_encode(ch, buf, &offset, buflen - 1) == EOK) { 279 put wchar(ch);279 putuchar(ch); 280 280 count++; 281 281 buf[offset] = 0; … … 287 287 288 288 /** Get character from input device & echo it to screen */ 289 wchar_t getc(indev_t *indev)290 { 291 wchar_t ch = indev_pop_character(indev);292 put wchar(ch);289 char32_t getc(indev_t *indev) 290 { 291 char32_t ch = indev_pop_character(indev); 292 putuchar(ch); 293 293 return ch; 294 294 } … … 324 324 /* Print characters that weren't printed earlier */ 325 325 while (kio_stored > 0) { 326 wchar_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH];326 char32_t tmp = kio[(kio_start + kio_len - kio_stored) % KIO_LENGTH]; 327 327 kio_stored--; 328 328 … … 344 344 * The caller is required to hold kio_lock 345 345 */ 346 void kio_push_char(const wchar_t ch)346 void kio_push_char(const char32_t ch) 347 347 { 348 348 kio[(kio_start + kio_len) % KIO_LENGTH] = ch; … … 360 360 } 361 361 362 void put wchar(const wchar_t ch)362 void putuchar(const char32_t ch) 363 363 { 364 364 bool ordy = ((stdout) && (stdout->op->write)); … … 377 377 * for possible future output. 378 378 * 379 * The early_put wchar() function is used to output379 * The early_putuchar() function is used to output 380 380 * the character for low-level debugging purposes. 381 381 * Note that the early_putc() function might be 382 382 * a no-op on certain hardware configurations. 383 383 */ 384 early_put wchar(ch);384 early_putuchar(ch); 385 385 } 386 386 -
kernel/generic/src/console/kconsole.c
r4f663f3e r28a5ebd 86 86 LIST_INITIALIZE(cmd_list); /**< Command list. */ 87 87 88 static wchar_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = { };88 static char32_t history[KCONSOLE_HISTORY][MAX_CMDLINE] = { }; 89 89 static size_t history_pos = 0; 90 90 … … 156 156 157 157 /** Print count times a character */ 158 _NO_TRACE static void print_cc( wchar_t ch, size_t count)158 _NO_TRACE static void print_cc(char32_t ch, size_t count) 159 159 { 160 160 size_t i; 161 161 for (i = 0; i < count; i++) 162 put wchar(ch);162 putuchar(ch); 163 163 } 164 164 … … 290 290 } 291 291 292 _NO_TRACE static cmd_info_t *parse_cmd(const wchar_t *cmdline)292 _NO_TRACE static cmd_info_t *parse_cmd(const char32_t *cmdline) 293 293 { 294 294 size_t start = 0; … … 331 331 } 332 332 333 _NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev,333 _NO_TRACE static char32_t *clever_readline(const char *prompt, indev_t *indev, 334 334 char *tmp) 335 335 { … … 337 337 338 338 size_t position = 0; 339 wchar_t *current = history[history_pos];339 char32_t *current = history[history_pos]; 340 340 current[0] = 0; 341 341 342 342 while (true) { 343 wchar_t ch = indev_pop_character(indev);343 char32_t ch = indev_pop_character(indev); 344 344 345 345 if (ch == '\n') { 346 346 /* Enter */ 347 put wchar(ch);347 putuchar(ch); 348 348 break; 349 349 } … … 356 356 if (wstr_remove(current, position - 1)) { 357 357 position--; 358 put wchar('\b');358 putuchar('\b'); 359 359 printf("%ls ", current + position); 360 360 print_cc('\b', wstr_length(current) - position + 1); … … 369 369 for (; (current[position] != 0) && (!isspace(current[position])); 370 370 position++) 371 put wchar(current[position]);371 putuchar(current[position]); 372 372 373 373 /* … … 464 464 /* Left */ 465 465 if (position > 0) { 466 put wchar('\b');466 putuchar('\b'); 467 467 position--; 468 468 } … … 473 473 /* Right */ 474 474 if (position < wstr_length(current)) { 475 put wchar(current[position]);475 putuchar(current[position]); 476 476 position++; 477 477 } … … 646 646 size_t offset = *start; 647 647 size_t prev = *start; 648 wchar_t ch;648 char32_t ch; 649 649 650 650 while ((ch = str_decode(cmdline, &offset, size)) != 0) { … … 825 825 826 826 while (true) { 827 wchar_t *tmp = clever_readline((char *) prompt, stdin, buffer);827 char32_t *tmp = clever_readline((char *) prompt, stdin, buffer); 828 828 size_t len = wstr_length(tmp); 829 829 if (!len) -
kernel/generic/src/console/prompt.c
r4f663f3e r28a5ebd 56 56 57 57 while (true) { 58 wchar_t answer = indev_pop_character(indev);58 char32_t answer = indev_pop_character(indev); 59 59 60 60 if ((answer == 'y') || (answer == 'Y')) { … … 87 87 printf("--More--"); 88 88 while (true) { 89 wchar_t continue_showing_hints = indev_pop_character(indev);89 char32_t continue_showing_hints = indev_pop_character(indev); 90 90 /* Display a full page again? */ 91 91 if ((continue_showing_hints == 'y') ||
Note:
See TracChangeset
for help on using the changeset viewer.
