Changeset b1bdc7a4 in mainline
- Timestamp:
- 2011-06-11T19:48:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 56ad818
- Parents:
- 774fc85
- Location:
- uspace/srv/hid/kbd
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/Makefile
r774fc85 rb1bdc7a4 49 49 layout/cz.c \ 50 50 layout/us_qwerty.c \ 51 layout/us_dvorak.c 51 layout/us_dvorak.c \ 52 port/adb.c \ 53 port/chardev.c \ 54 port/dummy.c \ 55 port/gxemul.c \ 56 port/msim.c \ 57 port/niagara.c \ 58 port/ns16550.c \ 59 port/pl050.c \ 60 port/sgcn.c \ 61 port/ski.c \ 62 port/sun.c \ 63 port/z8530.c 64 52 65 53 66 ifeq ($(UARCH),amd64) 54 67 SOURCES += \ 55 port/chardev.c \56 68 ctl/pc.c 57 69 endif … … 60 72 ifeq ($(MACHINE),gta02) 61 73 SOURCES += \ 62 port/chardev.c \63 74 ctl/stty.c 64 75 endif 65 76 ifeq ($(MACHINE),testarm) 66 SOURCES += \67 port/gxemul.c68 69 77 ifeq ($(CONFIG_FB),y) 70 78 SOURCES += \ … … 77 85 ifeq ($(MACHINE),integratorcp) 78 86 SOURCES += \ 79 port/pl050.c \80 87 ctl/pc.c 81 88 endif … … 84 91 ifeq ($(UARCH),ia32) 85 92 SOURCES += \ 86 port/chardev.c \87 93 ctl/pc.c 88 94 endif … … 90 96 ifeq ($(MACHINE),i460GX) 91 97 SOURCES += \ 92 port/chardev.c \93 98 ctl/pc.c 94 99 endif … … 96 101 ifeq ($(MACHINE),ski) 97 102 SOURCES += \ 98 port/ski.c \99 103 ctl/stty.c 100 104 endif … … 102 106 ifeq ($(MACHINE),msim) 103 107 SOURCES += \ 104 port/msim.c \105 108 ctl/stty.c 106 109 endif 107 110 108 111 ifeq ($(MACHINE),lgxemul) 109 SOURCES += \110 port/gxemul.c111 112 112 ifeq ($(CONFIG_FB),y) 113 113 SOURCES += \ … … 120 120 121 121 ifeq ($(MACHINE),bgxemul) 122 SOURCES += \123 port/gxemul.c124 125 122 ifeq ($(CONFIG_FB),y) 126 123 SOURCES += \ … … 134 131 ifeq ($(UARCH),ppc32) 135 132 SOURCES += \ 136 port/adb.c \137 133 ctl/apple.c 138 134 endif … … 141 137 ifeq ($(PROCESSOR),sun4v) 142 138 SOURCES += \ 143 port/niagara.c \144 139 ctl/stty.c 145 140 else 146 141 ifeq ($(MACHINE),serengeti) 147 142 SOURCES += \ 148 port/sgcn.c \149 143 ctl/stty.c 150 144 endif 151 145 ifeq ($(MACHINE),generic) 152 146 SOURCES += \ 153 port/sun.c \ 154 port/z8530.c \ 155 port/ns16550.c \ 156 ctl/sun.c 147 ctl/sun.c 157 148 endif 158 149 endif … … 161 152 ifeq ($(UARCH),abs32le) 162 153 SOURCES += \ 163 port/dummy.c \164 154 ctl/pc.c 165 155 endif -
uspace/srv/hid/kbd/ctl/apple.c
r774fc85 rb1bdc7a4 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 43 44 #define KBD_KEY_RELEASE 0x80 … … 45 46 static int scanmap[]; 46 47 47 int kbd_ctl_init( void)48 int kbd_ctl_init(kbd_port_ops_t *kbd_port) 48 49 { 50 (void) kbd_port; 49 51 return 0; 50 52 } -
uspace/srv/hid/kbd/ctl/gxe_fb.c
r774fc85 rb1bdc7a4 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 #include <gsp.h> 43 44 #include <stroke.h> … … 207 208 }; 208 209 209 int kbd_ctl_init( void)210 int kbd_ctl_init(kbd_port_ops_t *kbd_port) 210 211 { 212 (void) kbd_port; 211 213 ds = 0; 212 214 -
uspace/srv/hid/kbd/ctl/pc.c
r774fc85 rb1bdc7a4 64 64 65 65 static enum dec_state ds; 66 static kbd_port_ops_t *kbd_port; 66 67 67 68 static int scanmap_simple[] = { … … 197 198 }; 198 199 199 int kbd_ctl_init( void)200 int kbd_ctl_init(kbd_port_ops_t *kbd_p) 200 201 { 202 kbd_port = kbd_p; 201 203 ds = ds_s; 202 204 return 0; … … 265 267 b = b | LI_SCROLL; 266 268 267 kbd_port_write(KBD_CMD_SET_LEDS);268 kbd_port_write(b);269 (*kbd_port->write)(KBD_CMD_SET_LEDS); 270 (*kbd_port->write)(b); 269 271 } 270 272 -
uspace/srv/hid/kbd/ctl/stty.c
r774fc85 rb1bdc7a4 39 39 #include <io/keycode.h> 40 40 #include <kbd_ctl.h> 41 #include <kbd_port.h> 41 42 #include <gsp.h> 42 43 #include <stroke.h> … … 206 207 }; 207 208 208 int kbd_ctl_init( void)209 int kbd_ctl_init(kbd_port_ops_t *kbd_port) 209 210 { 211 (void) kbd_port; 210 212 ds = 0; 211 213 -
uspace/srv/hid/kbd/ctl/sun.c
r774fc85 rb1bdc7a4 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 43 44 #define KBD_KEY_RELEASE 0x80 … … 46 47 static int scanmap_simple[]; 47 48 48 int kbd_ctl_init( void)49 int kbd_ctl_init(kbd_port_ops_t *kbd_port) 49 50 { 50 51 return 0; -
uspace/srv/hid/kbd/generic/kbd.c
r774fc85 rb1bdc7a4 71 71 static unsigned lock_keys; 72 72 73 static kbd_port_ops_t *kbd_port; 74 73 75 bool irc_service = false; 74 76 int irc_phone = -1; … … 201 203 break; 202 204 case KBD_YIELD: 203 kbd_port_yield();205 (*kbd_port->yield)(); 204 206 retval = 0; 205 207 break; 206 208 case KBD_RECLAIM: 207 kbd_port_reclaim();209 (*kbd_port->reclaim)(); 208 210 retval = 0; 209 211 break; … … 215 217 } 216 218 219 static kbd_port_ops_t *kbd_select_port(void) 220 { 221 kbd_port_ops_t *kbd_port; 222 223 #if defined(UARCH_amd64) 224 kbd_port = &chardev_port; 225 #elif defined(UARCH_arm32) && defined(MACHINE_gta02) 226 kbd_port = &chardev_port; 227 #elif defined(UARCH_arm32) && defined(MACHINE_testarm) 228 kbd_port = &gxemul_port; 229 #elif defined(UARCH_arm32) && defined(MACHINE_integratorcp) 230 kbd_port = &pl050_port; 231 #elif defined(UARCH_ia32) 232 kbd_port = &chardev_port; 233 #elif defined(MACHINE_i460GX) 234 kbd_port = &chardev_port; 235 #elif defined(MACHINE_ski) 236 kbd_port = &ski_port; 237 #elif defined(MACHINE_msim) 238 kbd_port = &msim_port; 239 #elif defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) 240 kbd_port = &gxemul_port; 241 #elif defined(UARCH_ppc32) 242 kbd_port = &adb_port; 243 #elif defined(UARCH_sparc64) && defined(PROCESSOR_sun4v) 244 kbd_port = &niagara_port; 245 #elif defined(UARCH_sparc64) && defined(MACHINE_serengeti) 246 kbd_port = &sgcn_port; 247 #elif defined(UARCH_sparc64) && defined(MACHINE_generic) 248 kbd_port = &sun_port; 249 #else 250 kbd_port = &dummy_port; 251 #endif 252 return kbd_port; 253 } 217 254 218 255 int main(int argc, char **argv) … … 232 269 } 233 270 271 /* Select port driver. */ 272 kbd_port = kbd_select_port(); 273 234 274 /* Initialize port driver. */ 235 if ( kbd_port_init() != 0)275 if ((*kbd_port->init)() != 0) 236 276 return -1; 237 277 238 278 /* Initialize controller driver. */ 239 if (kbd_ctl_init( ) != 0)279 if (kbd_ctl_init(kbd_port) != 0) 240 280 return -1; 241 281 -
uspace/srv/hid/kbd/include/kbd_ctl.h
r774fc85 rb1bdc7a4 38 38 #define KBD_CTL_H_ 39 39 40 #include <kbd_port.h> 41 40 42 extern void kbd_ctl_parse_scancode(int); 41 extern int kbd_ctl_init( void);43 extern int kbd_ctl_init(kbd_port_ops_t *); 42 44 extern void kbd_ctl_set_ind(unsigned); 43 45 -
uspace/srv/hid/kbd/include/kbd_port.h
r774fc85 rb1bdc7a4 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 #include <sys/types.h> 41 41 42 extern int kbd_port_init(void); 43 extern void kbd_port_yield(void); 44 extern void kbd_port_reclaim(void); 45 extern void kbd_port_write(uint8_t); 42 typedef struct { 43 int (*init)(void); 44 void (*yield)(void); 45 void (*reclaim)(void); 46 void (*write)(uint8_t); 47 } kbd_port_ops_t; 48 49 extern kbd_port_ops_t adb_port; 50 extern kbd_port_ops_t chardev_port; 51 extern kbd_port_ops_t dummy_port; 52 extern kbd_port_ops_t gxemul_port; 53 extern kbd_port_ops_t msim_port; 54 extern kbd_port_ops_t niagara_port; 55 extern kbd_port_ops_t ns16550_port; 56 extern kbd_port_ops_t pl050_port; 57 extern kbd_port_ops_t sgcn_port; 58 extern kbd_port_ops_t ski_port; 59 extern kbd_port_ops_t sun_port; 60 extern kbd_port_ops_t z8530_port; 46 61 47 62 #endif -
uspace/srv/hid/kbd/port/adb.c
r774fc85 rb1bdc7a4 49 49 static void adb_kbd_reg0_data(uint16_t data); 50 50 51 static int adb_port_init(void); 52 static void adb_port_yield(void); 53 static void adb_port_reclaim(void); 54 static void adb_port_write(uint8_t data); 55 56 kbd_port_ops_t adb_port = { 57 .init = adb_port_init, 58 .yield = adb_port_yield, 59 .reclaim = adb_port_reclaim, 60 .write = adb_port_write 61 }; 62 51 63 static int dev_phone; 52 64 53 65 #define NAME "kbd" 54 66 55 int kbd_port_init(void)67 static int adb_port_init(void) 56 68 { 57 69 const char *dev = "adb/kbd"; … … 78 90 } 79 91 80 void kbd_port_yield(void)92 static void adb_port_yield(void) 81 93 { 82 94 } 83 95 84 void kbd_port_reclaim(void)96 static void adb_port_reclaim(void) 85 97 { 86 98 } 87 99 88 void kbd_port_write(uint8_t data)100 static void adb_port_write(uint8_t data) 89 101 { 90 102 /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/ -
uspace/srv/hid/kbd/port/chardev.c
r774fc85 rb1bdc7a4 49 49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); 50 50 51 static int chardev_port_init(void); 52 static void chardev_port_yield(void); 53 static void chardev_port_reclaim(void); 54 static void chardev_port_write(uint8_t data); 55 56 kbd_port_ops_t chardev_port = { 57 .init = chardev_port_init, 58 .yield = chardev_port_yield, 59 .reclaim = chardev_port_reclaim, 60 .write = chardev_port_write 61 }; 62 51 63 static int dev_phone; 52 64 … … 59 71 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 60 72 61 int kbd_port_init(void)73 static int chardev_port_init(void) 62 74 { 63 75 devmap_handle_t handle; … … 91 103 } 92 104 93 void kbd_port_yield(void)105 static void chardev_port_yield(void) 94 106 { 95 107 } 96 108 97 void kbd_port_reclaim(void)109 static void chardev_port_reclaim(void) 98 110 { 99 111 } 100 112 101 void kbd_port_write(uint8_t data)113 static void chardev_port_write(uint8_t data) 102 114 { 103 115 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); -
uspace/srv/hid/kbd/port/dummy.c
r774fc85 rb1bdc7a4 38 38 #include <kbd.h> 39 39 40 int kbd_port_init(void) 40 static int dummy_port_init(void); 41 static void dummy_port_yield(void); 42 static void dummy_port_reclaim(void); 43 static void dummy_port_write(uint8_t data); 44 45 kbd_port_ops_t dummy_port = { 46 .init = dummy_port_init, 47 .yield = dummy_port_yield, 48 .reclaim = dummy_port_reclaim, 49 .write = dummy_port_write 50 }; 51 52 53 static int dummy_port_init(void) 41 54 { 42 55 return 0; 43 56 } 44 57 45 void kbd_port_yield(void)58 static void dummy_port_yield(void) 46 59 { 47 60 } 48 61 49 void kbd_port_reclaim(void)62 static void dummy_port_reclaim(void) 50 63 { 51 64 } 52 65 53 void kbd_port_write(uint8_t data)66 static void dummy_port_write(uint8_t data) 54 67 { 55 68 (void) data; -
uspace/srv/hid/kbd/port/gxemul.c
r774fc85 rb1bdc7a4 42 42 #include <errno.h> 43 43 44 static int gxemul_port_init(void); 45 static void gxemul_port_yield(void); 46 static void gxemul_port_reclaim(void); 47 static void gxemul_port_write(uint8_t data); 48 49 kbd_port_ops_t gxemul_port = { 50 .init = gxemul_port_init, 51 .yield = gxemul_port_yield, 52 .reclaim = gxemul_port_reclaim, 53 .write = gxemul_port_write 54 }; 55 44 56 static irq_cmd_t gxemul_cmds[] = { 45 57 { … … 61 73 62 74 /** Initializes keyboard handler. */ 63 int kbd_port_init(void)75 static int gxemul_port_init(void) 64 76 { 65 77 sysarg_t addr; … … 77 89 } 78 90 79 void kbd_port_yield(void)91 static void gxemul_port_yield(void) 80 92 { 81 93 } 82 94 83 void kbd_port_reclaim(void)95 static void gxemul_port_reclaim(void) 84 96 { 85 97 } 86 98 87 void kbd_port_write(uint8_t data)99 static void gxemul_port_write(uint8_t data) 88 100 { 89 101 (void) data; -
uspace/srv/hid/kbd/port/msim.c
r774fc85 rb1bdc7a4 42 42 #include <errno.h> 43 43 44 irq_cmd_t msim_cmds[] = { 44 static int msim_port_init(void); 45 static void msim_port_yield(void); 46 static void msim_port_reclaim(void); 47 static void msim_port_write(uint8_t data); 48 49 kbd_port_ops_t msim_port = { 50 .init = msim_port_init, 51 .yield = msim_port_yield, 52 .reclaim = msim_port_reclaim, 53 .write = msim_port_write 54 }; 55 56 static irq_cmd_t msim_cmds[] = { 45 57 { 46 58 .cmd = CMD_PIO_READ_8, … … 51 63 .cmd = CMD_ACCEPT 52 64 } 53 54 65 }; 55 66 56 irq_code_t msim_kbd = {67 static irq_code_t msim_kbd = { 57 68 sizeof(msim_cmds) / sizeof(irq_cmd_t), 58 69 msim_cmds … … 61 72 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call); 62 73 63 int kbd_port_init(void)74 static int msim_port_init(void) 64 75 { 65 76 sysarg_t vaddr; … … 78 89 } 79 90 80 void kbd_port_yield(void)91 static void msim_port_yield(void) 81 92 { 82 93 } 83 94 84 void kbd_port_reclaim(void)95 static void msim_port_reclaim(void) 85 96 { 86 97 } 87 98 88 void kbd_port_write(uint8_t data)99 static void msim_port_write(uint8_t data) 89 100 { 90 101 (void) data; -
uspace/srv/hid/kbd/port/niagara.c
r774fc85 rb1bdc7a4 46 46 #include <errno.h> 47 47 48 static int niagara_port_init(void); 49 static void niagara_port_yield(void); 50 static void niagara_port_reclaim(void); 51 static void niagara_port_write(uint8_t data); 52 53 kbd_port_ops_t niagara_port = { 54 .init = niagara_port_init, 55 .yield = niagara_port_yield, 56 .reclaim = niagara_port_reclaim, 57 .write = niagara_port_write 58 }; 59 48 60 #define POLL_INTERVAL 10000 49 61 … … 70 82 71 83 /* virtual address of the shared buffer */ 72 input_buffer_t input_buffer;84 static input_buffer_t input_buffer; 73 85 74 86 static volatile bool polling_disabled = false; … … 79 91 * Maps the shared buffer and creates the polling thread. 80 92 */ 81 int kbd_port_init(void)93 static int niagara_port_init(void) 82 94 { 83 95 sysarg_t paddr; … … 105 117 } 106 118 107 void kbd_port_yield(void)119 static void niagara_port_yield(void) 108 120 { 109 121 polling_disabled = true; 110 122 } 111 123 112 void kbd_port_reclaim(void)124 static void niagara_port_reclaim(void) 113 125 { 114 126 polling_disabled = false; 115 127 } 116 128 117 void kbd_port_write(uint8_t data)129 static void niagara_port_write(uint8_t data) 118 130 { 119 131 (void) data; -
uspace/srv/hid/kbd/port/pl050.c
r774fc85 rb1bdc7a4 46 46 #include <errno.h> 47 47 48 static int pl050_port_init(void); 49 static void pl050_port_yield(void); 50 static void pl050_port_reclaim(void); 51 static void pl050_port_write(uint8_t data); 52 53 kbd_port_ops_t pl050_port = { 54 .init = pl050_port_init, 55 .yield = pl050_port_yield, 56 .reclaim = pl050_port_reclaim, 57 .write = pl050_port_write 58 }; 59 48 60 #define PL050_STAT_RXFULL (1 << 4) 49 61 … … 82 94 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call); 83 95 84 int kbd_port_init(void)96 static int pl050_port_init(void) 85 97 { 86 98 sysarg_t addr; … … 105 117 } 106 118 107 void kbd_port_yield(void)119 static void pl050_port_yield(void) 108 120 { 109 121 } 110 122 111 void kbd_port_reclaim(void)123 static void pl050_port_reclaim(void) 112 124 { 113 125 } 114 126 115 void kbd_port_write(uint8_t data)127 static void pl050_port_write(uint8_t data) 116 128 { 117 129 (void) data; -
uspace/srv/hid/kbd/port/sgcn.c
r774fc85 rb1bdc7a4 46 46 #include <errno.h> 47 47 48 static int sgcn_port_init(void); 49 static void sgcn_port_yield(void); 50 static void sgcn_port_reclaim(void); 51 static void sgcn_port_write(uint8_t data); 52 53 kbd_port_ops_t sgcn_port = { 54 .init = sgcn_port_init, 55 .yield = sgcn_port_yield, 56 .reclaim = sgcn_port_reclaim, 57 .write = sgcn_port_write 58 }; 59 48 60 #define POLL_INTERVAL 10000 49 61 … … 101 113 * Maps the physical memory (SRAM) and creates the polling thread. 102 114 */ 103 int kbd_port_init(void)115 static int sgcn_port_init(void) 104 116 { 105 117 sysarg_t sram_paddr; … … 130 142 } 131 143 132 void kbd_port_yield(void)144 static void sgcn_port_yield(void) 133 145 { 134 146 polling_disabled = true; 135 147 } 136 148 137 void kbd_port_reclaim(void)149 static void sgcn_port_reclaim(void) 138 150 { 139 151 polling_disabled = false; 140 152 } 141 153 142 void kbd_port_write(uint8_t data)154 static void sgcn_port_write(uint8_t data) 143 155 { 144 156 (void) data; -
uspace/srv/hid/kbd/port/ski.c
r774fc85 rb1bdc7a4 45 45 #include <bool.h> 46 46 47 static int ski_port_init(void); 48 static void ski_port_yield(void); 49 static void ski_port_reclaim(void); 50 static void ski_port_write(uint8_t data); 51 52 kbd_port_ops_t ski_port = { 53 .init = ski_port_init, 54 .yield = ski_port_yield, 55 .reclaim = ski_port_reclaim, 56 .write = ski_port_write 57 }; 58 47 59 #define SKI_GETCHAR 21 48 60 … … 55 67 56 68 /** Initialize Ski port driver. */ 57 int kbd_port_init(void)69 static int ski_port_init(void) 58 70 { 59 71 thread_id_t tid; … … 68 80 } 69 81 70 void kbd_port_yield(void)82 static void ski_port_yield(void) 71 83 { 72 84 polling_disabled = true; 73 85 } 74 86 75 void kbd_port_reclaim(void)87 static void ski_port_reclaim(void) 76 88 { 77 89 polling_disabled = false; 78 90 } 79 91 80 void kbd_port_write(uint8_t data)92 static void ski_port_write(uint8_t data) 81 93 { 82 94 (void) data; … … 112 124 uint64_t ch; 113 125 126 #ifdef UARCH_ia64 114 127 asm volatile ( 115 128 "mov r15 = %1\n" … … 121 134 : "r15", "r8" 122 135 ); 123 136 #else 137 ch = 0; 138 #endif 124 139 return (int32_t) ch; 125 140 } -
uspace/srv/hid/kbd/port/sun.c
r774fc85 rb1bdc7a4 42 42 #include <bool.h> 43 43 44 static int sun_port_init(void); 45 static void sun_port_yield(void); 46 static void sun_port_reclaim(void); 47 static void sun_port_write(uint8_t data); 48 49 kbd_port_ops_t sun_port = { 50 .init = sun_port_init, 51 .yield = sun_port_yield, 52 .reclaim = sun_port_reclaim, 53 .write = sun_port_write 54 }; 55 56 44 57 /** Sun keyboard virtual port driver. 45 58 * … … 50 63 * 51 64 */ 52 int kbd_port_init(void)65 static int sun_port_init(void) 53 66 { 54 67 sysarg_t z8530; … … 73 86 } 74 87 75 void kbd_port_yield(void)88 static void sun_port_yield(void) 76 89 { 77 90 } 78 91 79 void kbd_port_reclaim(void)92 static void sun_port_reclaim(void) 80 93 { 81 94 } 82 95 83 void kbd_port_write(uint8_t data)96 static void sun_port_write(uint8_t data) 84 97 { 85 98 (void) data; -
uspace/srv/hid/kbd/port/z8530.c
r774fc85 rb1bdc7a4 77 77 } 78 78 }; 79 80 irq_code_t z8530_kbd = {79 80 static irq_code_t z8530_kbd = { 81 81 sizeof(z8530_cmds) / sizeof(irq_cmd_t), 82 82 z8530_cmds
Note:
See TracChangeset
for help on using the changeset viewer.