Config option to turn off backspace for printk
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 10 Apr 2012 23:00:01 +0000 (16:00 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 10 Apr 2012 23:20:11 +0000 (16:20 -0700)
If you set CONFIG_PRINTK_NO_BACKSPACE, then the console won't try to go
backwards when you send a \b or \x7f, and will print ^H instead.

Makeconfig
Makelocal.template
kern/arch/i686/console.c
kern/arch/riscv/console.c
kern/arch/sparc/console.c

index 64c811c..8851c31 100644 (file)
@@ -33,6 +33,7 @@ CONFIG_PCI_VERBOSE:=               -D__CONFIG_PCI_VERBOSE__
 CONFIG_ETH_AUDIO:=                 -D__CONFIG_ETH_AUDIO__
 CONFIG_KB_CORE0_ONLY:=             -D__CONFIG_KB_CORE0_ONLY__
 CONFIG_KTHREAD_POISON:=            -D__CONFIG_KTHREAD_POISON__
+CONFIG_PRINTK_NO_BACKSPACE:=       -D__CONFIG_PRINTK_NO_BACKSPACE__
 
 # Userspace configuration parameters
 # By default, each of these options will be turned off
index a676a17..573ff19 100644 (file)
@@ -32,6 +32,7 @@
 # Avoid KB input on buggy nehalems (brho's machine)
 #KERN_CFLAGS += $(CONFIG_KB_CORE0_ONLY)
 #KERN_CFLAGS += $(CONFIG_KTHREAD_POISON)
+#KERN_CFLAGS += $(CONFIG_PRINTK_NO_BACKSPACE)
 
 #KERN_CFLAGS += -DDEVELOPER_NAME=waterman
 #KERN_CFLAGS += -DDEVELOPER_NAME=brho
index 7cc09cd..f6dea20 100644 (file)
@@ -69,13 +69,18 @@ static void serial_put_char(struct cons_dev *cdev, uint8_t c)
 {
        assert(cdev->type == CONS_SER_DEV);
        /* We do some funky editing of a few chars, to suit what minicom seems to
-        * expect (at least for brho) */
+        * expect (at least for brho). */
        switch (c & 0xff) {
                case '\b':
                case 0x7f:
+               #ifdef __CONFIG_PRINTK_NO_BACKSPACE__
+                       __serial_put_char(cdev->val, (uint8_t)('^'));
+                       __serial_put_char(cdev->val, (uint8_t)('H'));
+               #else
                        __serial_put_char(cdev->val, '\b');
                        __serial_put_char(cdev->val, (uint8_t)(' '));
                        __serial_put_char(cdev->val, '\b');
+               #endif /* __CONFIG_PRINTK_NO_BACKSPACE__ */
                        break;
                case '\n':
                case '\r':
@@ -318,13 +323,17 @@ cga_putc(int c)
        switch (c & 0xff) {
        case '\b':
        case 0x7f:
+       #ifdef __CONFIG_PRINTK_NO_BACKSPACE__
+               cga_putc('^');
+               cga_putc('H');
+       #else
                if (crt_pos > 0) {
                        crt_pos--;
                        scrolling_crt_pos--;
-
                        crt_buf[crt_pos] = (c & ~0xff) | ' ';
                        scrolling_crt_buf[scrolling_crt_pos] = crt_buf[crt_pos];
                }
+       #endif /* __CONFIG_PRINTK_NO_BACKSPACE__ */
                break;
        case '\n':
                crt_pos += CRT_COLS;
index 8cba973..f3fa4ba 100644 (file)
@@ -53,8 +53,13 @@ cons_putc(int c)
 {
        if(c == '\b' || c == 0x7F)
        {
+       #ifdef __CONFIG_PRINTK_NO_BACKSPACE__
+               char buf[2] = {'^', 'H'};
+               cputbuf(buf, 2);
+       #else
                char buf[3] = {'\b', ' ', '\b'};
-               cputbuf(buf,3);
+               cputbuf(buf, 3);
+       #endif /* __CONFIG_PRINTK_NO_BACKSPACE__ */
        }
        else
        {
index 3350158..2c203bd 100644 (file)
@@ -21,8 +21,13 @@ cons_putc(int c)
 {
        if(c == '\b' || c == 0x7F)
        {
+       #ifdef __CONFIG_PRINTK_NO_BACKSPACE__
+               char buf[2] = {'^', 'H'};
+               cputbuf(buf, 2);
+       #else
                char buf[3] = {'\b', ' ', '\b'};
-               cputbuf(buf,3);
+               cputbuf(buf, 3);
+       #endif /* __CONFIG_PRINTK_NO_BACKSPACE__ */
        }
        else
        {