Changeset 2270bef in mainline
- Timestamp:
- 2009-03-08T14:05:42Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b0b5628
- Parents:
- 0af8bcd
- Location:
- kernel/arch/ia64
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/include/ski/ski.h
r0af8bcd r2270bef 37 37 38 38 #include <arch/types.h> 39 #include <console/c onsole.h>39 #include <console/chardev.h> 40 40 41 41 #define SKI_INIT_CONSOLE 20 … … 43 43 #define SKI_PUTCHAR 31 44 44 45 extern chardev_t ski_uconsole; 46 47 extern void ski_init_console(void); 48 45 extern void ski_console_init(chardev_t *); 49 46 extern void ski_kbd_grab(void); 50 47 extern void ski_kbd_release(void); 51 52 extern void kkbdpoll(void *arg);53 48 54 49 #endif -
kernel/arch/ia64/src/ia64.c
r0af8bcd r2270bef 131 131 } 132 132 133 134 133 void arch_post_mm_init(void) 135 134 { … … 137 136 iosapic_init(); 138 137 irq_init(INR_COUNT, INR_COUNT); 138 } 139 it_init(); 140 } 141 142 void arch_post_cpu_init(void) 143 { 144 } 145 146 void arch_pre_smp_init(void) 147 { 148 } 149 150 void arch_post_smp_init(void) 151 { 139 152 #ifdef SKI 140 ski_init_console(); 141 #else 142 ega_init(EGA_BASE, EGA_VIDEORAM); 143 #endif 144 } 145 it_init(); 146 147 } 148 149 void arch_post_cpu_init(void) 150 { 151 } 152 153 void arch_pre_smp_init(void) 154 { 155 } 156 157 void arch_post_smp_init(void) 158 { 159 /* 160 * Create thread that polls keyboard. 161 */ 162 #ifdef SKI 163 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 164 if (!t) 165 panic("Cannot create kkbdpoll."); 166 thread_ready(t); 153 srln_init(stdin); 154 ski_console_init(&srlnin); 167 155 #endif 168 156 169 157 #ifdef I460GX 158 #ifdef CONFIG_EGA 159 ega_init(EGA_BASE, EGA_VIDEORAM); 160 #endif 161 170 162 devno_t devno = device_assign_devno(); 171 163 inr_t inr; -
kernel/arch/ia64/src/ski/ski.c
r0af8bcd r2270bef 36 36 #include <console/console.h> 37 37 #include <console/chardev.h> 38 #include <arch/interrupt.h>39 38 #include <sysinfo/sysinfo.h> 40 39 #include <arch/types.h> 41 #include <ddi/device.h>42 #include <ddi/irq.h>43 #include <ipc/irq.h>44 40 #include <proc/thread.h> 45 41 #include <synch/spinlock.h> 46 42 #include <arch/asm.h> 47 43 #include <arch/drivers/kbd.h> 44 #include <arch.h> 48 45 49 #define SKI_KBD_INR 0 46 static chardev_t *skiout; 50 47 51 static irq_t ski_kbd_irq; 52 static devno_t ski_kbd_devno; 53 54 chardev_t ski_console; 55 chardev_t ski_uconsole; 48 static chardev_t ski_stdout; 56 49 57 50 static bool kbd_disabled; … … 82 75 } 83 76 77 static chardev_operations_t ski_ops = { 78 .write = ski_putchar 79 }; 80 84 81 /** Ask debug console if a key was pressed. 85 82 * … … 108 105 } 109 106 110 /**111 * This is a blocking wrapper for ski_getchar().112 * To be used when the kernel crashes.113 */114 static char ski_getchar_blocking(chardev_t *d)115 {116 int ch;117 118 while(!(ch = ski_getchar()));119 120 if (ch == '\r')121 ch = '\n';122 return (char) ch;123 }124 125 107 /** Ask keyboard if a key was pressed. */ 126 108 static void poll_keyboard(void) 127 109 { 128 110 char ch; 129 static char last;130 111 ipl_t ipl; 131 112 … … 137 118 } 138 119 139 spinlock_lock(&ski_kbd_irq.lock);140 141 120 ch = ski_getchar(); 142 121 if(ch == '\r') 143 122 ch = '\n'; 144 if (ch) { 145 if (ski_kbd_irq.notif_cfg.notify && 146 ski_kbd_irq.notif_cfg.answerbox) { 147 chardev_push_character(&ski_uconsole, ch); 148 /* XXX: send notification to userspace */ 149 } else { 150 chardev_push_character(&ski_console, ch); 151 } 152 last = ch; 153 spinlock_unlock(&ski_kbd_irq.lock); 123 if (ch && skiout) { 124 chardev_push_character(skiout, ch); 154 125 interrupts_restore(ipl); 155 126 return; 156 127 } 157 128 158 if (last) {159 if (ski_kbd_irq.notif_cfg.notify &&160 ski_kbd_irq.notif_cfg.answerbox) {161 chardev_push_character(&ski_uconsole, 0);162 /* XXX: send notification to userspace */163 }164 last = 0;165 }166 167 spinlock_unlock(&ski_kbd_irq.lock);168 129 interrupts_restore(ipl); 169 130 } 170 131 171 /* Called from getc(). */ 172 static void ski_kbd_enable(chardev_t *d) 132 #define POLL_INTERVAL 10000 /* 10 ms */ 133 134 /** Kernel thread for polling keyboard. */ 135 static void kkbdpoll(void *arg) 173 136 { 174 kbd_disabled = false; 137 while (1) { 138 if (!silent) { 139 poll_keyboard(); 140 } 141 thread_usleep(POLL_INTERVAL); 142 } 175 143 } 176 177 /* Called from getc(). */178 static void ski_kbd_disable(chardev_t *d)179 {180 kbd_disabled = true;181 }182 183 /** Decline to service hardware IRQ.184 *185 * This is only a virtual IRQ, so always decline.186 *187 * @return Always IRQ_DECLINE.188 */189 static irq_ownership_t ski_kbd_claim(irq_t *irq)190 {191 return IRQ_DECLINE;192 }193 194 static chardev_operations_t ski_ops = {195 .resume = ski_kbd_enable,196 .suspend = ski_kbd_disable,197 .write = ski_putchar,198 .read = ski_getchar_blocking199 };200 144 201 145 /** Initialize debug console … … 204 148 * to open debug console. 205 149 */ 206 void ski_ init_console(void)150 void ski_console_init(chardev_t *devout) 207 151 { 208 152 asm volatile ( … … 214 158 ); 215 159 216 chardev_initialize("ski_console", &ski_console, &ski_ops); 217 chardev_initialize("ski_uconsole", &ski_uconsole, &ski_ops); 218 stdin = &ski_console; 219 stdout = &ski_console; 160 skiout = devout; 161 chardev_initialize("ski_stdout", &ski_stdout, &ski_ops); 162 stdout = &ski_stdout; 220 163 221 ski_kbd_devno = device_assign_devno(); 222 223 irq_initialize(&ski_kbd_irq); 224 ski_kbd_irq.inr = SKI_KBD_INR; 225 ski_kbd_irq.devno = ski_kbd_devno; 226 ski_kbd_irq.claim = ski_kbd_claim; 227 irq_register(&ski_kbd_irq); 164 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 165 if (!t) 166 panic("Cannot create kkbdpoll."); 167 thread_ready(t); 228 168 229 169 sysinfo_set_item_val("kbd", NULL, true); 230 sysinfo_set_item_val("kbd.inr", NULL, SKI_KBD_INR);231 sysinfo_set_item_val("kbd.devno", NULL, ski_kbd_devno);232 170 sysinfo_set_item_val("kbd.type", NULL, KBD_SKI); 233 171 … … 237 175 void ski_kbd_grab(void) 238 176 { 239 ipl_t ipl = interrupts_disable(); 240 spinlock_lock(&ski_kbd_irq.lock); 241 ski_kbd_irq.notif_cfg.notify = false; 242 spinlock_unlock(&ski_kbd_irq.lock); 243 interrupts_restore(ipl); 177 kbd_disabled = true; 244 178 } 245 179 246 180 void ski_kbd_release(void) 247 181 { 248 ipl_t ipl = interrupts_disable(); 249 spinlock_lock(&ski_kbd_irq.lock); 250 if (ski_kbd_irq.notif_cfg.answerbox) 251 ski_kbd_irq.notif_cfg.notify = true; 252 spinlock_unlock(&ski_kbd_irq.lock); 253 interrupts_restore(ipl); 254 } 255 256 257 #define POLL_INTERVAL 50000 /* 50 ms */ 258 259 /** Kernel thread for polling keyboard. */ 260 void kkbdpoll(void *arg) 261 { 262 while (1) { 263 if (!silent) { 264 poll_keyboard(); 265 } 266 thread_usleep(POLL_INTERVAL); 267 } 182 kbd_disabled = false; 268 183 } 269 184
Note:
See TracChangeset
for help on using the changeset viewer.