Changeset c859753 in mainline for kernel/generic/src/console/console.c
- Timestamp:
- 2008-06-03T14:55:09Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 419886f6
- Parents:
- aa48a9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/console.c
raa48a9d rc859753 44 44 #include <atomic.h> 45 45 46 #define BUFLEN 2048 47 static char debug_buffer[BUFLEN]; 48 static size_t offset = 0; 49 /** Initialize stdout to something that does not print, but does not fail 50 * 51 * Save data in some buffer so that it could be retrieved in the debugger 52 */ 53 static void null_putchar(chardev_t *d, const char ch) 54 { 55 if (offset >= BUFLEN) 56 offset = 0; 57 debug_buffer[offset++] = ch; 58 } 46 #define KLOG_SIZE 4096 47 48 /**< Kernel log cyclic buffer */ 49 static char klog[KLOG_SIZE]; 50 51 /**< First kernel log characters */ 52 static index_t klog_start = 0; 53 /**< Number of valid kernel log characters */ 54 static size_t klog_len = 0; 55 /**< Number of stored (not printed) kernel log characters */ 56 static size_t klog_stored = 0; 59 57 60 58 static chardev_operations_t null_stdout_ops = { 61 .write = null_putchar 59 .suspend = NULL, 60 .resume = NULL, 61 .write = NULL, 62 .read = NULL 62 63 }; 63 64 … … 91 92 /* no other way of interacting with user, halt */ 92 93 if (CPU) 93 printf("cpu% d: ", CPU->id);94 printf("cpu%u: ", CPU->id); 94 95 else 95 96 printf("cpu: "); … … 162 163 void putchar(char c) 163 164 { 165 if ((klog_stored > 0) && (stdout->op->write)) { 166 /* Print charaters stored in kernel log */ 167 index_t i; 168 for (i = klog_len - klog_stored; i < klog_len; i++) 169 stdout->op->write(stdout, klog[(klog_start + i) % KLOG_SIZE]); 170 klog_stored = 0; 171 } 172 173 /* Store character in the cyclic kernel log */ 174 klog[(klog_start + klog_len) % KLOG_SIZE] = c; 175 if (klog_len < KLOG_SIZE) 176 klog_len++; 177 else 178 klog_start = (klog_start + 1) % KLOG_SIZE; 179 164 180 if (stdout->op->write) 165 181 stdout->op->write(stdout, c); 182 else { 183 /* The character is just in the kernel log */ 184 if (klog_stored < klog_len) 185 klog_stored++; 186 } 166 187 } 167 188
Note:
See TracChangeset
for help on using the changeset viewer.