Changes in kernel/arch/ia64/src/drivers/ski.c [a71c158:66b430e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/drivers/ski.c
ra71c158 r66b430e 47 47 enum { 48 48 /** Interval between polling in microseconds */ 49 POLL_INTERVAL = 10000, /* 0.01 s */50 49 POLL_INTERVAL = 10000, /* 0.01 s */ 50 51 51 /** Max. number of characters to pull out at a time */ 52 POLL_LIMIT =30,53 54 SKI_INIT_CONSOLE = 20,55 SKI_GETCHAR = 21,56 SKI_PUTCHAR = 3152 POLL_LIMIT = 30, 53 54 SKI_INIT_CONSOLE = 20, 55 SKI_GETCHAR = 21, 56 SKI_PUTCHAR = 31 57 57 }; 58 58 59 59 static void ski_putchar(outdev_t *, const wchar_t, bool); 60 60 61 static outdev_operations_t skidev_ops = { 62 .write = ski_putchar, 63 .redraw = NULL 61 static outdev_operations_t skiout_ops = { 62 .write = ski_putchar 64 63 }; 65 64 66 static ski_instance_t *instance = NULL; 67 68 /** Ask debug console if a key was pressed. 69 * 70 * Use SSC (Simulator System Call) to 71 * get character from debug console. 72 * 73 * This call is non-blocking. 74 * 75 * @return ASCII code of pressed key or 0 if no key pressed. 76 * 77 */ 78 static wchar_t ski_getchar(void) 79 { 80 uint64_t ch; 81 82 asm volatile ( 83 "mov r15 = %1\n" 84 "break 0x80000;;\n" /* modifies r8 */ 85 "mov %0 = r8;;\n" 86 87 : "=r" (ch) 88 : "i" (SKI_GETCHAR) 89 : "r15", "r8" 90 ); 91 92 return (wchar_t) ch; 93 } 94 95 /** Ask keyboard if a key was pressed. 96 * 97 * If so, it will repeat and pull up to POLL_LIMIT characters. 98 */ 99 static void poll_keyboard(ski_instance_t *instance) 100 { 101 if (silent) 102 return; 103 104 int count = POLL_LIMIT; 105 106 while (count > 0) { 107 wchar_t ch = ski_getchar(); 108 109 if (ch == '\0') 110 break; 111 112 indev_push_character(instance->srlnin, ch); 113 --count; 114 } 115 } 116 117 /** Kernel thread for polling keyboard. */ 118 static void kskipoll(void *arg) 119 { 120 ski_instance_t *instance = (ski_instance_t *) arg; 121 122 while (true) { 123 if (!silent) 124 poll_keyboard(instance); 125 126 thread_usleep(POLL_INTERVAL); 127 } 128 } 65 static outdev_t skiout; /**< Ski output device. */ 66 static bool initialized = false; 67 static bool kbd_disabled = false; 129 68 130 69 /** Initialize debug console … … 136 75 static void ski_init(void) 137 76 { 138 if (in stance)77 if (initialized) 139 78 return; 140 79 … … 147 86 ); 148 87 149 instance = malloc(sizeof(ski_instance_t), FRAME_ATOMIC); 150 151 if (instance) { 152 instance->thread = thread_create(kskipoll, instance, TASK, 0, 153 "kskipoll", true); 154 155 if (!instance->thread) { 156 free(instance); 157 instance = NULL; 158 return; 159 } 160 161 instance->srlnin = NULL; 162 } 88 initialized = true; 163 89 } 164 90 … … 198 124 } 199 125 200 outdev_t *skiout_init(void)126 void skiout_init(void) 201 127 { 202 128 ski_init(); 203 if (!instance) 204 return NULL; 205 206 outdev_t *skidev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 207 if (!skidev) 208 return NULL; 209 210 outdev_initialize("skidev", skidev, &skidev_ops); 211 skidev->data = instance; 212 213 if (!fb_exported) { 214 /* 215 * This is the necessary evil until the userspace driver is entirely 216 * self-sufficient. 217 */ 218 sysinfo_set_item_val("fb", NULL, false); 219 220 fb_exported = true; 221 } 222 223 return skidev; 129 130 outdev_initialize("skiout", &skiout, &skiout_ops); 131 stdout = &skiout; 132 133 sysinfo_set_item_val("fb", NULL, false); 134 } 135 136 /** Ask debug console if a key was pressed. 137 * 138 * Use SSC (Simulator System Call) to 139 * get character from debug console. 140 * 141 * This call is non-blocking. 142 * 143 * @return ASCII code of pressed key or 0 if no key pressed. 144 * 145 */ 146 static wchar_t ski_getchar(void) 147 { 148 uint64_t ch; 149 150 asm volatile ( 151 "mov r15 = %1\n" 152 "break 0x80000;;\n" /* modifies r8 */ 153 "mov %0 = r8;;\n" 154 155 : "=r" (ch) 156 : "i" (SKI_GETCHAR) 157 : "r15", "r8" 158 ); 159 160 return (wchar_t) ch; 161 } 162 163 /** Ask keyboard if a key was pressed. 164 * 165 * If so, it will repeat and pull up to POLL_LIMIT characters. 166 */ 167 static void poll_keyboard(ski_instance_t *instance) 168 { 169 wchar_t ch; 170 int count; 171 172 if (kbd_disabled) 173 return; 174 175 count = POLL_LIMIT; 176 177 while (count > 0) { 178 ch = ski_getchar(); 179 180 if (ch == '\0') 181 break; 182 183 indev_push_character(instance->srlnin, ch); 184 --count; 185 } 186 } 187 188 /** Kernel thread for polling keyboard. */ 189 static void kskipoll(void *arg) 190 { 191 ski_instance_t *instance = (ski_instance_t *) arg; 192 193 while (true) { 194 if (!silent) 195 poll_keyboard(instance); 196 197 thread_usleep(POLL_INTERVAL); 198 } 224 199 } 225 200 … … 227 202 { 228 203 ski_init(); 204 205 ski_instance_t *instance = 206 malloc(sizeof(ski_instance_t), FRAME_ATOMIC); 207 208 if (instance) { 209 instance->thread = thread_create(kskipoll, instance, TASK, 0, 210 "kskipoll", true); 211 212 if (!instance->thread) { 213 free(instance); 214 return NULL; 215 } 216 217 instance->srlnin = NULL; 218 } 219 229 220 return instance; 230 221 } … … 242 233 } 243 234 235 void ski_kbd_grab(void) 236 { 237 kbd_disabled = false; 238 } 239 240 void ski_kbd_release(void) 241 { 242 kbd_disabled = true; 243 } 244 244 245 /** @} 245 246 */
Note:
See TracChangeset
for help on using the changeset viewer.