Changeset c2417bc in mainline for kernel/arch/ia64/src/drivers/ski.c
- Timestamp:
- 2009-04-21T12:46:26Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2d2c7ba
- Parents:
- 44b7783
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia64/src/drivers/ski.c
r44b7783 rc2417bc 33 33 */ 34 34 35 #include <arch/ ski/ski.h>35 #include <arch/drivers/ski.h> 36 36 #include <console/console.h> 37 37 #include <console/chardev.h> … … 45 45 #include <arch.h> 46 46 47 static indev_t skiin; /**< Ski input device. */ 48 static outdev_t skiout; /**< Ski output device. */ 49 50 static bool kbd_disabled; 47 #define POLL_INTERVAL 10000 /* 10 ms */ 48 49 #define SKI_INIT_CONSOLE 20 50 #define SKI_GETCHAR 21 51 #define SKI_PUTCHAR 31 52 53 static void ski_putchar(outdev_t *, const wchar_t, bool); 54 55 static outdev_operations_t skiout_ops = { 56 .write = ski_putchar 57 }; 58 59 static outdev_t skiout; /**< Ski output device. */ 60 static bool initialized = false; 61 static bool kbd_disabled = false; 62 63 /** Initialize debug console 64 * 65 * Issue SSC (Simulator System Call) to 66 * to open debug console. 67 * 68 */ 69 static void ski_init(void) 70 { 71 if (initialized) 72 return; 73 74 asm volatile ( 75 "mov r15 = %0\n" 76 "break 0x80000\n" 77 : 78 : "i" (SKI_INIT_CONSOLE) 79 : "r15", "r8" 80 ); 81 82 initialized = true; 83 } 51 84 52 85 static void ski_do_putchar(const wchar_t ch) … … 55 88 "mov r15 = %[cmd]\n" 56 89 "mov r32 = %[ch]\n" /* r32 is in0 */ 57 "break 0x80000\n" /* modifies r8 */90 "break 0x80000\n" /* modifies r8 */ 58 91 : 59 92 : [cmd] "i" (SKI_PUTCHAR), [ch] "r" (ch) … … 67 100 * display character on debug console. 68 101 * 69 * @param d Character device. 70 * @param ch Character to be printed. 71 */ 72 static void ski_putchar(outdev_t *d, const wchar_t ch, bool silent) 102 * @param dev Character device. 103 * @param ch Character to be printed. 104 * @param silent Whether the output should be silenced. 105 * 106 */ 107 static void ski_putchar(outdev_t *dev, const wchar_t ch, bool silent) 73 108 { 74 109 if (!silent) { … … 79 114 ski_do_putchar(ch); 80 115 } else 81 ski_do_putchar( SPECIAL);116 ski_do_putchar(U_SPECIAL); 82 117 } 83 118 } 84 119 85 static indev_operations_t skiin_ops = { 86 .poll = NULL 87 }; 88 89 static outdev_operations_t skiout_ops = { 90 .write = ski_putchar 91 }; 120 void skiout_init(void) 121 { 122 ski_init(); 123 124 outdev_initialize("skiout", &skiout, &skiout_ops); 125 stdout = &skiout; 126 127 sysinfo_set_item_val("fb", NULL, false); 128 } 92 129 93 130 /** Ask debug console if a key was pressed. … … 99 136 * 100 137 * @return ASCII code of pressed key or 0 if no key pressed. 101 */ 102 static int32_t ski_getchar(void) 138 * 139 */ 140 static wchar_t ski_getchar(void) 103 141 { 104 142 uint64_t ch; … … 106 144 asm volatile ( 107 145 "mov r15 = %1\n" 108 "break 0x80000;;\n" 109 "mov %0 = r8;;\n" 110 146 "break 0x80000;;\n" /* modifies r8 */ 147 "mov %0 = r8;;\n" 148 111 149 : "=r" (ch) 112 150 : "i" (SKI_GETCHAR) 113 151 : "r15", "r8" 114 152 ); 115 116 return ( int32_t) ch;153 154 return (wchar_t) ch; 117 155 } 118 156 119 157 /** Ask keyboard if a key was pressed. */ 120 static void poll_keyboard(void) 121 { 122 char ch; 123 158 static void poll_keyboard(ski_instance_t *instance) 159 { 124 160 if (kbd_disabled) 125 161 return; 126 ch = ski_getchar(); 127 if(ch == '\r') 128 ch = '\n'; 129 if (ch) { 130 indev_push_character(&skiin, ch); 131 return; 132 } 133 } 134 135 #define POLL_INTERVAL 10000 /* 10 ms */ 162 163 wchar_t ch = ski_getchar(); 164 165 if (ch != 0) 166 indev_push_character(instance->srlnin, ch); 167 } 136 168 137 169 /** Kernel thread for polling keyboard. */ 138 static void kkbdpoll(void *arg) 139 { 140 while (1) { 141 if (!silent) { 142 poll_keyboard(); 143 } 170 static void kskipoll(void *arg) 171 { 172 ski_instance_t *instance = (ski_instance_t *) arg; 173 174 while (true) { 175 if (!silent) 176 poll_keyboard(instance); 177 144 178 thread_usleep(POLL_INTERVAL); 145 179 } 146 180 } 147 181 148 /** Initialize debug console 149 * 150 * Issue SSC (Simulator System Call) to 151 * to open debug console. 152 */ 153 static void ski_init(void) 154 { 155 static bool initialized; 156 157 if (initialized) 158 return; 159 160 asm volatile ( 161 "mov r15 = %0\n" 162 "break 0x80000\n" 163 : 164 : "i" (SKI_INIT_CONSOLE) 165 : "r15", "r8" 166 ); 167 168 initialized = true; 169 } 170 171 indev_t *skiin_init(void) 182 ski_instance_t *skiin_init(void) 172 183 { 173 184 ski_init(); 174 175 indev_initialize("skiin", &skiin, &skiin_ops); 176 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); 177 if (t) 178 thread_ready(t); 179 else 180 return NULL; 181 185 186 ski_instance_t *instance 187 = malloc(sizeof(ski_instance_t), FRAME_ATOMIC); 188 189 if (instance) { 190 instance->thread = thread_create(kskipoll, (void *) instance, TASK, 0, "kskipoll", true); 191 192 if (!instance->thread) { 193 free(instance); 194 return NULL; 195 } 196 197 instance->srlnin = NULL; 198 } 199 200 return instance; 201 } 202 203 void skiin_wire(ski_instance_t *instance, indev_t *srlnin) 204 { 205 ASSERT(instance); 206 ASSERT(srlnin); 207 208 instance->srlnin = srlnin; 209 thread_ready(instance->thread); 210 182 211 sysinfo_set_item_val("kbd", NULL, true); 183 212 sysinfo_set_item_val("kbd.type", NULL, KBD_SKI); 184 185 return &skiin;186 }187 188 189 void skiout_init(void)190 {191 ski_init();192 193 outdev_initialize("skiout", &skiout, &skiout_ops);194 stdout = &skiout;195 196 sysinfo_set_item_val("fb", NULL, false);197 213 } 198 214
Note:
See TracChangeset
for help on using the changeset viewer.