Changeset 2f79a38 in mainline
- Timestamp:
- 2012-01-04T00:45:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bd87ae0
- Parents:
- 22e4e9b
- Location:
- uspace/drv/char/ps2mouse
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/ps2mouse/chardev.c
r22e4e9b r2f79a38 40 40 }; 41 41 42 s tatic ssize_t chardev_read_int(async_exch_t *exch, void *data, size_t size)42 ssize_t chardev_read(async_exch_t *exch, void *data, size_t size) 43 43 { 44 44 if (!exch) … … 55 55 } 56 56 57 s tatic ssize_t chardev_write_int(async_exch_t *exch, const void *data, size_t size)57 ssize_t chardev_write(async_exch_t *exch, const void *data, size_t size) 58 58 { 59 59 if (!exch) … … 67 67 message[0], message[1], message[2]); 68 68 } 69 70 71 ssize_t chardev_write(async_sess_t *sess, const void *data, size_t size)72 {73 async_exch_t *exch = async_exchange_begin(sess);74 const ssize_t ret = chardev_write_int(exch, data, size);75 async_exchange_end(exch);76 return ret;77 }78 79 ssize_t chardev_read(async_sess_t *sess, void *data, size_t size)80 {81 async_exch_t *exch = async_exchange_begin(sess);82 const ssize_t ret = chardev_read_int(exch, data, size);83 async_exchange_end(exch);84 return ret;85 } -
uspace/drv/char/ps2mouse/chardev.h
r22e4e9b r2f79a38 39 39 #include <async.h> 40 40 41 ssize_t chardev_read(async_ sess_t *, void *, size_t);42 ssize_t chardev_write(async_ sess_t *, const void *, size_t);41 ssize_t chardev_read(async_exch_t *, void *, size_t); 42 ssize_t chardev_write(async_exch_t *, const void *, size_t); 43 43 44 44 #endif -
uspace/drv/char/ps2mouse/ps2mouse.c
r22e4e9b r2f79a38 74 74 do { \ 75 75 uint8_t data = 0; \ 76 const ssize_t size = chardev_read(sess ion, &data, 1); \76 const ssize_t size = chardev_read(sess, &data, 1); \ 77 77 if (size != 1) { \ 78 78 ddf_msg(LVL_ERROR, "Failed reading byte: %d)", size);\ … … 89 89 do { \ 90 90 uint8_t data = (value); \ 91 const ssize_t size = chardev_write(sess ion, &data, 1); \91 const ssize_t size = chardev_write(sess, &data, 1); \ 92 92 if (size < 0 ) { \ 93 93 ddf_msg(LVL_ERROR, "Failed writing byte: %hhx", value); \ … … 98 98 static int polling_ps2(void *); 99 99 static int polling_intellimouse(void *); 100 static int probe_intellimouse(async_ sess_t *, bool);100 static int probe_intellimouse(async_exch_t *, bool); 101 101 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 102 102 … … 148 148 /* Probe IntelliMouse extensions. */ 149 149 int (*polling_f)(void*) = polling_ps2; 150 if (probe_intellimouse(mouse->parent_sess, false) == EOK) { 150 async_exch_t *exch = async_exchange_begin(mouse->parent_sess); 151 if (probe_intellimouse(exch, false) == EOK) { 151 152 ddf_msg(LVL_NOTE, "Enabled IntelliMouse extensions"); 152 153 polling_f = polling_intellimouse; 153 if (probe_intellimouse( mouse->parent_sess, true) == EOK)154 if (probe_intellimouse(exch, true) == EOK) 154 155 ddf_msg(LVL_NOTE, "Enabled 4th and 5th button."); 155 156 } 156 157 /* Enable mouse data reporting. */ 157 158 uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT; 158 ssize_t size = chardev_write( mouse->parent_sess, &report, 1);159 ssize_t size = chardev_write(exch, &report, 1); 159 160 if (size != 1) { 160 161 ddf_msg(LVL_ERROR, "Failed to enable data reporting."); 162 async_exchange_end(exch); 161 163 async_hangup(mouse->parent_sess); 162 164 ddf_fun_unbind(mouse->mouse_fun); … … 166 168 } 167 169 168 size = chardev_read(mouse->parent_sess, &report, 1); 170 size = chardev_read(exch, &report, 1); 171 async_exchange_end(exch); 169 172 if (size != 1 || report != PS2_MOUSE_ACK) { 170 173 ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.", … … 200 203 assert(mouse->parent_sess); 201 204 bool buttons[PS2_BUTTON_COUNT] = {}; 205 async_exch_t *parent_exch = async_exchange_begin(mouse->parent_sess); 202 206 while (1) { 203 207 204 208 uint8_t packet[PS2_BUFSIZE] = {}; 205 209 const ssize_t size = 206 chardev_read( mouse->parent_sess, packet, PS2_BUFSIZE);210 chardev_read(parent_exch, packet, PS2_BUFSIZE); 207 211 208 212 if (size != PS2_BUFSIZE) { … … 242 246 async_exchange_end(exch); 243 247 } 248 async_exchange_end(parent_exch); 244 249 } 245 250 … … 255 260 assert(mouse->parent_sess); 256 261 bool buttons[INTELLIMOUSE_BUTTON_COUNT] = {}; 262 async_exch_t *parent_exch = NULL; 257 263 while (1) { 264 if (!parent_exch) 265 parent_exch = async_exchange_begin(mouse->parent_sess); 258 266 259 267 uint8_t packet[INTELLIMOUSE_BUFSIZE] = {}; 260 268 const ssize_t size = chardev_read( 261 mouse->parent_sess, packet, INTELLIMOUSE_BUFSIZE);269 parent_exch, packet, INTELLIMOUSE_BUFSIZE); 262 270 263 271 if (size != INTELLIMOUSE_BUFSIZE) { … … 316 324 async_exchange_end(exch); 317 325 } 326 async_exchange_end(parent_exch); 318 327 } 319 328 320 329 /** Send magic sequence to initialize IntelliMouse extensions. 321 * @param session IPC sessionto the parent device.330 * @param exch IPC exchange to the parent device. 322 331 * @param buttons True selects magic sequence for 4th and 5th button, 323 332 * false selects wheel support magic sequence. 324 333 * See http://www.computer-engineering.org/ps2mouse/ for details. 325 334 */ 326 static int probe_intellimouse(async_ sess_t *session, bool buttons)335 static int probe_intellimouse(async_exch_t *exch, bool buttons) 327 336 { 328 assert( session);329 330 MOUSE_WRITE_BYTE( session, PS2_MOUSE_SET_SAMPLE_RATE);331 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);332 MOUSE_WRITE_BYTE( session, 200);333 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);334 335 MOUSE_WRITE_BYTE( session, PS2_MOUSE_SET_SAMPLE_RATE);336 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);337 MOUSE_WRITE_BYTE( session, buttons ? 200 : 100);338 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);339 340 MOUSE_WRITE_BYTE( session, PS2_MOUSE_SET_SAMPLE_RATE);341 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);342 MOUSE_WRITE_BYTE( session, 80);343 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);344 345 MOUSE_WRITE_BYTE( session, PS2_MOUSE_GET_DEVICE_ID);346 MOUSE_READ_BYTE_TEST( session, PS2_MOUSE_ACK);347 MOUSE_READ_BYTE_TEST( session, buttons ? 4 : 3);337 assert(exch); 338 339 MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE); 340 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 341 MOUSE_WRITE_BYTE(exch, 200); 342 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 343 344 MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE); 345 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 346 MOUSE_WRITE_BYTE(exch, buttons ? 200 : 100); 347 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 348 349 MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE); 350 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 351 MOUSE_WRITE_BYTE(exch, 80); 352 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 353 354 MOUSE_WRITE_BYTE(exch, PS2_MOUSE_GET_DEVICE_ID); 355 MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK); 356 MOUSE_READ_BYTE_TEST(exch, buttons ? 4 : 3); 348 357 349 358 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.