Changeset de57e060 in mainline for kernel/arch/ia64/src/ski/ski.c
- Timestamp:
- 2006-10-18T20:51:15Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 80ca47e
- Parents:
- cd13c2a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/ski/ski.c
rcd13c2a rde57e060 38 38 #include <arch/interrupt.h> 39 39 #include <sysinfo/sysinfo.h> 40 #include <arch/types.h> 41 #include <typedefs.h> 42 #include <ddi/device.h> 43 #include <ddi/irq.h> 44 #include <ipc/irq.h> 45 #include <synch/spinlock.h> 46 #include <arch/asm.h> 47 48 #define SKI_KBD_INR 0 49 50 static irq_t ski_kbd_irq; 51 static devno_t ski_kbd_devno; 40 52 41 53 chardev_t ski_console; 42 54 chardev_t ski_uconsole; 43 static bool kb_disable; 44 int kbd_uspace=0;55 56 static bool kbd_disabled; 45 57 46 58 static void ski_putchar(chardev_t *d, const char ch); … … 58 70 { 59 71 __asm__ volatile ( 60 "mov r15 =%0\n"61 "mov r32 =%1\n"/* r32 is in0 */72 "mov r15 = %0\n" 73 "mov r32 = %1\n" /* r32 is in0 */ 62 74 "break 0x80000\n" /* modifies r8 */ 63 75 : … … 84 96 85 97 __asm__ volatile ( 86 "mov r15 =%1\n"98 "mov r15 = %1\n" 87 99 "break 0x80000;;\n" /* modifies r8 */ 88 "mov %0 =r8;;\n"100 "mov %0 = r8;;\n" 89 101 90 102 : "=r" (ch) 91 103 : "i" (SKI_GETCHAR) 92 : "r15", 104 : "r15", "r8" 93 105 ); 94 106 … … 104 116 int ch; 105 117 106 while(!(ch =ski_getchar()))118 while(!(ch = ski_getchar())) 107 119 ; 108 120 if(ch == '\r') … … 116 128 char ch; 117 129 static char last; 118 119 if (kb_disable) 130 ipl_t ipl; 131 132 ipl = interrupts_disable(); 133 134 if (kbd_disabled) { 135 interrupts_restore(ipl); 120 136 return; 137 } 138 139 spinlock_lock(&ski_kbd_irq.lock); 121 140 122 141 ch = ski_getchar(); 123 142 if(ch == '\r') 124 143 ch = '\n'; 125 if (ch) {126 if (kbd_uspace){144 if (ch) { 145 if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { 127 146 chardev_push_character(&ski_uconsole, ch); 128 virtual_interrupt(IRQ_KBD,NULL); 129 } 130 else { 147 ipc_irq_send_notif(&ski_kbd_irq); 148 } else { 131 149 chardev_push_character(&ski_console, ch); 132 150 } 133 last = ch; 151 last = ch; 152 spinlock_unlock(&ski_kbd_irq.lock); 153 interrupts_restore(ipl); 134 154 return; 135 } 136 137 if (last) {138 if (kbd_uspace){155 } 156 157 if (last) { 158 if (ski_kbd_irq.notif_cfg.notify && ski_kbd_irq.notif_cfg.answerbox) { 139 159 chardev_push_character(&ski_uconsole, 0); 140 virtual_interrupt(IRQ_KBD,NULL);160 ipc_irq_send_notif(&ski_kbd_irq); 141 161 } 142 else {143 }144 last = 0; 145 }146 162 last = 0; 163 } 164 165 spinlock_unlock(&ski_kbd_irq.lock); 166 interrupts_restore(ipl); 147 167 } 148 168 149 169 /* Called from getc(). */ 150 static void ski_kb _enable(chardev_t *d)151 { 152 kb _disable= false;170 static void ski_kbd_enable(chardev_t *d) 171 { 172 kbd_disabled = false; 153 173 } 154 174 155 175 /* Called from getc(). */ 156 static void ski_kb_disable(chardev_t *d) 157 { 158 kb_disable = true; 176 static void ski_kbd_disable(chardev_t *d) 177 { 178 kbd_disabled = true; 179 } 180 181 /** Decline to service hardware IRQ. 182 * 183 * This is only a virtual IRQ, so always decline. 184 * 185 * @return Always IRQ_DECLINE. 186 */ 187 static irq_ownership_t ski_kbd_claim(void) 188 { 189 return IRQ_DECLINE; 159 190 } 160 191 161 192 static chardev_operations_t ski_ops = { 162 .resume = ski_kb _enable,163 .suspend = ski_kb _disable,193 .resume = ski_kbd_enable, 194 .suspend = ski_kbd_disable, 164 195 .write = ski_putchar, 165 196 .read = ski_getchar_blocking … … 174 205 { 175 206 __asm__ volatile ( 176 "mov r15 =%0\n"207 "mov r15 = %0\n" 177 208 "break 0x80000\n" 178 209 : … … 186 217 stdout = &ski_console; 187 218 219 ski_kbd_devno = device_assign_devno(); 220 221 irq_initialize(&ski_kbd_irq); 222 ski_kbd_irq.inr = SKI_KBD_INR; 223 ski_kbd_irq.devno = ski_kbd_devno; 224 ski_kbd_irq.claim = ski_kbd_claim; 225 irq_register(&ski_kbd_irq); 226 188 227 } 189 228 … … 196 235 void ski_set_console_sysinfo(void) 197 236 { 198 sysinfo_set_item_val("kbd",NULL,true); 199 sysinfo_set_item_val("kbd.irq",NULL,IRQ_KBD); 237 sysinfo_set_item_val("kbd", NULL, true); 238 sysinfo_set_item_val("kbd.inr", NULL, SKI_KBD_INR); 239 sysinfo_set_item_val("kbd.devno", NULL, ski_kbd_devno); 240 } 241 242 void ski_kbd_grab(void) 243 { 244 ski_kbd_irq.notif_cfg.notify = false; 245 } 246 247 void ski_kbd_release(void) 248 { 249 if (ski_kbd_irq.notif_cfg.answerbox) 250 ski_kbd_irq.notif_cfg.notify = true; 200 251 } 201 252
Note:
See TracChangeset
for help on using the changeset viewer.