Changeset b6f2ebc in mainline
- Timestamp:
- 2009-03-12T17:52:33Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0e1b48
- Parents:
- a7efdec
- Location:
- kernel/genarch
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/kbrd/kbrd.h
ra7efdec rb6f2ebc 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 39 39 #include <console/chardev.h> 40 40 41 extern chardev_t kbrdin; 42 43 extern void kbrd_init(chardev_t *); 41 extern void kbrd_init(indev_t *devin); 44 42 45 43 #endif -
kernel/genarch/include/srln/srln.h
ra7efdec rb6f2ebc 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 39 39 #include <console/chardev.h> 40 40 41 extern chardev_t srlnin; 42 43 extern void srln_init(chardev_t *); 41 extern void srln_init(indev_t *devin); 44 42 45 43 #endif -
kernel/genarch/src/kbrd/kbrd.c
ra7efdec rb6f2ebc 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Keyboard processing. 35 35 */ 36 36 … … 54 54 55 55 #ifdef CONFIG_SUN_KBD 56 # define IGNORE_CODE 0x7f 57 #endif 58 59 #define KEY_RELEASE 0x80 60 61 #define PRESSED_SHIFT (1 << 0) 62 #define PRESSED_CAPSLOCK (1 << 1) 63 #define LOCKED_CAPSLOCK (1 << 0) 64 65 chardev_t kbrdin; 66 static chardev_t *kbdout; 67 68 static void kbrdin_suspend(chardev_t *d) 69 { 70 } 71 72 static void kbrdin_resume(chardev_t *d) 73 { 74 } 75 76 chardev_operations_t kbrdin_ops = { 77 .suspend = kbrdin_suspend, 78 .resume = kbrdin_resume, 56 #define IGNORE_CODE 0x7f 57 #endif 58 59 #define KEY_RELEASE 0x80 60 61 #define PRESSED_SHIFT (1 << 0) 62 #define PRESSED_CAPSLOCK (1 << 1) 63 #define LOCKED_CAPSLOCK (1 << 0) 64 65 static indev_t kbrdout; 66 67 indev_operations_t kbrdout_ops = { 68 .poll = NULL 79 69 }; 80 70 81 SPINLOCK_INITIALIZE(keylock); 82 static volatile int keyflags; 83 static volatile int lockflags; 71 SPINLOCK_INITIALIZE(keylock); /**< keylock protects keyflags and lockflags. */ 72 static volatile int keyflags; /**< Tracking of multiple keypresses. */ 73 static volatile int lockflags; /**< Tracking of multiple keys lockings. */ 84 74 85 75 static void key_released(uint8_t); … … 88 78 static void kkbrd(void *arg) 89 79 { 90 chardev_t *in = (chardev_t *) arg; 91 uint8_t sc; 92 93 while (1) { 94 sc = _getc(in); 95 80 indev_t *in = (indev_t *) arg; 81 82 while (true) { 83 uint8_t sc = _getc(in); 84 96 85 #ifdef CONFIG_SUN_KBD 97 86 if (sc == IGNORE_CODE) … … 106 95 } 107 96 108 109 void kbrd_init(chardev_t *devout) 110 { 111 thread_t *t; 112 113 chardev_initialize("kbrd", &kbrdin, &kbrdin_ops); 114 kbdout = devout; 97 void kbrd_init(indev_t *devin) 98 { 99 indev_initialize("kbrd", &kbrdout, &kbrdout_ops); 100 thread_t *thread 101 = thread_create(kkbrd, devin, TASK, 0, "kkbrd", false); 115 102 116 t = thread_create(kkbrd, &kbrdin, TASK, 0, "kkbrd", false); 117 ASSERT(t); 118 thread_ready(t); 103 if (thread) { 104 stdin = &kbrdout; 105 thread_ready(thread); 106 } 119 107 } 120 108 … … 154 142 bool shift, capslock; 155 143 bool letter = false; 156 144 157 145 spinlock_lock(&keylock); 158 146 switch (sc) { 159 147 case SC_LSHIFT: 160 148 case SC_RSHIFT: 161 149 keyflags |= PRESSED_SHIFT; 162 150 break; 163 151 case SC_CAPSLOCK: … … 167 155 break; 168 156 case SC_LEFTARR: 169 chardev_push_character(kbdout, 0x1b);170 chardev_push_character(kbdout, 0x5b);171 chardev_push_character(kbdout, 0x44);157 indev_push_character(stdin, 0x1b); 158 indev_push_character(stdin, 0x5b); 159 indev_push_character(stdin, 0x44); 172 160 break; 173 161 case SC_RIGHTARR: 174 chardev_push_character(kbdout, 0x1b);175 chardev_push_character(kbdout, 0x5b);176 chardev_push_character(kbdout, 0x43);162 indev_push_character(stdin, 0x1b); 163 indev_push_character(stdin, 0x5b); 164 indev_push_character(stdin, 0x43); 177 165 break; 178 166 case SC_UPARR: 179 chardev_push_character(kbdout, 0x1b);180 chardev_push_character(kbdout, 0x5b);181 chardev_push_character(kbdout, 0x41);167 indev_push_character(stdin, 0x1b); 168 indev_push_character(stdin, 0x5b); 169 indev_push_character(stdin, 0x41); 182 170 break; 183 171 case SC_DOWNARR: 184 chardev_push_character(kbdout, 0x1b);185 chardev_push_character(kbdout, 0x5b);186 chardev_push_character(kbdout, 0x42);172 indev_push_character(stdin, 0x1b); 173 indev_push_character(stdin, 0x5b); 174 indev_push_character(stdin, 0x42); 187 175 break; 188 176 case SC_HOME: 189 chardev_push_character(kbdout, 0x1b);190 chardev_push_character(kbdout, 0x4f);191 chardev_push_character(kbdout, 0x48);177 indev_push_character(stdin, 0x1b); 178 indev_push_character(stdin, 0x4f); 179 indev_push_character(stdin, 0x48); 192 180 break; 193 181 case SC_END: 194 chardev_push_character(kbdout, 0x1b);195 chardev_push_character(kbdout, 0x4f);196 chardev_push_character(kbdout, 0x46);182 indev_push_character(stdin, 0x1b); 183 indev_push_character(stdin, 0x4f); 184 indev_push_character(stdin, 0x46); 197 185 break; 198 186 case SC_DELETE: 199 chardev_push_character(kbdout, 0x1b);200 chardev_push_character(kbdout, 0x5b);201 chardev_push_character(kbdout, 0x33);202 chardev_push_character(kbdout, 0x7e);187 indev_push_character(stdin, 0x1b); 188 indev_push_character(stdin, 0x5b); 189 indev_push_character(stdin, 0x33); 190 indev_push_character(stdin, 0x7e); 203 191 break; 204 192 default: 205 193 letter = islower(ascii); 206 194 capslock = (keyflags & PRESSED_CAPSLOCK) || 207 195 (lockflags & LOCKED_CAPSLOCK); … … 211 199 if (shift) 212 200 map = sc_secondary_map; 213 chardev_push_character(kbdout, map[sc]);201 indev_push_character(stdin, map[sc]); 214 202 break; 215 203 } -
kernel/genarch/src/srln/srln.c
ra7efdec rb6f2ebc 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Serial line processing. 35 35 */ 36 36 … … 41 41 #include <arch.h> 42 42 43 chardev_t srlnin; 44 static chardev_t *srlnout; 43 static indev_t srlnout; 45 44 46 static void srlnin_suspend(chardev_t *d) 47 { 48 } 49 50 static void srlnin_resume(chardev_t *d) 51 { 52 } 53 54 chardev_operations_t srlnin_ops = { 55 .suspend = srlnin_suspend, 56 .resume = srlnin_resume, 45 indev_operations_t srlnout_ops = { 46 .poll = NULL 57 47 }; 58 48 59 49 static void ksrln(void *arg) 60 50 { 61 chardev_t *in = (chardev_t *) arg;62 uint8_t ch;63 64 while ( 1) {65 ch = _getc(in);51 indev_t *in = (indev_t *) arg; 52 bool cr = false; 53 54 while (true) { 55 uint8_t ch = _getc(in); 66 56 67 if (ch == '\r') 57 if ((ch == '\n') && (cr)) { 58 cr = false; 68 59 continue; 60 } 69 61 70 chardev_push_character(srlnout, ch); 62 if (ch == '\r') { 63 ch = '\n'; 64 cr = true; 65 } else 66 cr = false; 67 68 if (ch == 0x7f) 69 ch = '\b'; 70 71 indev_push_character(stdin, ch); 71 72 } 72 73 } 73 74 74 75 void srln_init(chardev_t *devout) 75 void srln_init(indev_t *devin) 76 76 { 77 thread_t *t; 78 79 chardev_initialize("srln", &srlnin, &srlnin_ops); 80 srlnout = devout; 77 indev_initialize("srln", &srlnout, &srlnout_ops); 78 thread_t *thread 79 = thread_create(ksrln, devin, TASK, 0, "ksrln", false); 81 80 82 t = thread_create(ksrln, &srlnin, TASK, 0, "ksrln", false); 83 ASSERT(t); 84 thread_ready(t); 81 if (thread) { 82 stdin = &srlnout; 83 thread_ready(thread); 84 } 85 85 } 86 86 87 87 /** @} 88 88 */ 89
Note:
See TracChangeset
for help on using the changeset viewer.