Changeset 82b71ef1 in mainline
- Timestamp:
- 2008-06-04T19:17:36Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 32443b0
- Parents:
- 7ba289a
- Location:
- kernel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/smp/ap.S
r7ba289a r82b71ef1 46 46 KDATA=16 47 47 48 # This piece of code is real-mode and is meant to be al ligned at 4K boundary.48 # This piece of code is real-mode and is meant to be aligned at 4K boundary. 49 49 # The requirement for such an alignment comes from MP Specification's STARTUP IPI 50 50 # requirements. -
kernel/generic/include/console/console.h
r7ba289a r82b71ef1 42 42 extern chardev_t *stdout; 43 43 44 extern void klog_init(void); 45 extern void klog_update(void); 46 44 47 extern uint8_t getc(chardev_t *chardev); 45 48 uint8_t _getc(chardev_t *chardev); -
kernel/generic/src/console/console.c
r7ba289a r82b71ef1 36 36 #include <console/console.h> 37 37 #include <console/chardev.h> 38 #include <sysinfo/sysinfo.h> 38 39 #include <synch/waitq.h> 39 40 #include <synch/spinlock.h> 40 41 #include <arch/types.h> 42 #include <ddi/device.h> 43 #include <ddi/irq.h> 44 #include <ddi/ddi.h> 45 #include <ipc/irq.h> 41 46 #include <arch.h> 42 47 #include <func.h> … … 44 49 #include <atomic.h> 45 50 46 #define KLOG_SIZE 409651 #define KLOG_SIZE PAGE_SIZE 47 52 48 53 /**< Kernel log cyclic buffer */ 49 static char klog[KLOG_SIZE]; 50 54 static char klog[KLOG_SIZE] __attribute__ ((aligned (PAGE_SIZE))); 55 56 /**< Kernel log initialized */ 57 static bool klog_inited = false; 51 58 /**< First kernel log characters */ 52 59 static index_t klog_start = 0; … … 55 62 /**< Number of stored (not printed) kernel log characters */ 56 63 static size_t klog_stored = 0; 64 /**< Number of stored kernel log characters for uspace */ 65 static size_t klog_uspace = 0; 66 67 /**< Kernel log spinlock */ 68 SPINLOCK_INITIALIZE(klog_lock); 69 70 /** Physical memory area used for klog buffer */ 71 static parea_t klog_parea; 72 73 /* 74 * For now, we use 0 as INR. 75 * However, it is therefore desirable to have architecture specific 76 * definition of KLOG_VIRT_INR in the future. 77 */ 78 #define KLOG_VIRT_INR 0 79 80 static irq_t klog_irq; 57 81 58 82 static chardev_operations_t null_stdout_ops = { … … 68 92 }; 69 93 70 /** Standard input character device. */ 94 /** Allways refuse IRQ ownership. 95 * 96 * This is not a real IRQ, so we always decline. 97 * 98 * @return Always returns IRQ_DECLINE. 99 */ 100 static irq_ownership_t klog_claim(void) 101 { 102 return IRQ_DECLINE; 103 } 104 105 /** Standard input character device */ 71 106 chardev_t *stdin = NULL; 72 107 chardev_t *stdout = &null_stdout; 108 109 /** Initialize kernel logging facility 110 * 111 * The shared area contains kernel cyclic buffer. Userspace application may 112 * be notified on new data with indication of position and size 113 * of the data within the circular buffer. 114 */ 115 void klog_init(void) 116 { 117 void *faddr = (void *) KA2PA(klog); 118 119 ASSERT((uintptr_t) faddr % FRAME_SIZE == 0); 120 ASSERT(KLOG_SIZE % FRAME_SIZE == 0); 121 122 devno_t devno = device_assign_devno(); 123 124 klog_parea.pbase = (uintptr_t) faddr; 125 klog_parea.vbase = (uintptr_t) klog; 126 klog_parea.frames = SIZE2FRAMES(KLOG_SIZE); 127 klog_parea.cacheable = true; 128 ddi_parea_register(&klog_parea); 129 130 sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr); 131 sysinfo_set_item_val("klog.pages", NULL, SIZE2FRAMES(KLOG_SIZE)); 132 sysinfo_set_item_val("klog.devno", NULL, devno); 133 sysinfo_set_item_val("klog.inr", NULL, KLOG_VIRT_INR); 134 135 irq_initialize(&klog_irq); 136 klog_irq.devno = devno; 137 klog_irq.inr = KLOG_VIRT_INR; 138 klog_irq.claim = klog_claim; 139 irq_register(&klog_irq); 140 141 spinlock_lock(&klog_lock); 142 klog_inited = true; 143 spinlock_unlock(&klog_lock); 144 } 73 145 74 146 /** Get character from character device. Do not echo character. … … 161 233 } 162 234 235 void klog_update(void) 236 { 237 spinlock_lock(&klog_lock); 238 239 if ((klog_inited) && (klog_irq.notif_cfg.notify) && (klog_uspace > 0)) { 240 ipc_irq_send_msg_3(&klog_irq, klog_start, klog_len, klog_uspace); 241 klog_uspace = 0; 242 } 243 244 spinlock_unlock(&klog_lock); 245 } 246 163 247 void putchar(char c) 164 248 { 249 spinlock_lock(&klog_lock); 250 165 251 if ((klog_stored > 0) && (stdout->op->write)) { 166 252 /* Print charaters stored in kernel log */ … … 185 271 klog_stored++; 186 272 } 273 274 /* The character is stored for uspace */ 275 if (klog_uspace < klog_len) 276 klog_uspace++; 277 278 spinlock_unlock(&klog_lock); 279 280 klog_update(); 187 281 } 188 282 -
kernel/generic/src/main/main.c
r7ba289a r82b71ef1 81 81 #include <smp/smp.h> 82 82 #include <ddi/ddi.h> 83 #include <console/console.h> 83 84 84 85 /** Global configuration structure. */ … … 257 258 258 259 LOG_EXEC(ipc_init()); 260 LOG_EXEC(klog_init()); 259 261 260 262 /* -
kernel/generic/src/syscall/syscall.c
r7ba289a r82b71ef1 64 64 int rc; 65 65 66 if (count == 0)67 return 0;68 69 66 if (count > PAGE_SIZE) 70 67 return ELIMIT; 71 72 data = (char *) malloc(count, 0);73 if (!data)74 return ENOMEM;75 68 76 rc = copy_from_uspace(data, buf, count); 77 if (rc) { 69 if (count > 0) { 70 data = (char *) malloc(count, 0); 71 if (!data) 72 return ENOMEM; 73 74 rc = copy_from_uspace(data, buf, count); 75 if (rc) { 76 free(data); 77 return rc; 78 } 79 80 for (i = 0; i < count; i++) 81 putchar(data[i]); 78 82 free(data); 79 return rc; 80 } 81 82 for (i = 0; i < count; i++) 83 putchar(data[i]); 84 free(data); 83 } else 84 klog_update(); 85 85 86 86 return count;
Note:
See TracChangeset
for help on using the changeset viewer.