Changeset 9f97ffe in mainline
- Timestamp:
- 2011-12-26T15:44:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d56ab85
- Parents:
- c6c5ff3b
- Location:
- uspace/drv/char/i8042
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/i8042.c
rc6c5ff3b r9f97ffe 142 142 return; 143 143 i8042_t *controller = dev->driver_data; 144 fibril_mutex_lock(&controller->guard);144 // fibril_mutex_lock(&controller->guard); 145 145 146 146 const uint8_t status = IPC_GET_ARG1(*call); 147 147 const uint8_t data = IPC_GET_ARG2(*call); 148 const bool aux = (status & i8042_AUX_DATA); 148 buffer_t *buffer = (status & i8042_AUX_DATA) ? 149 &controller->aux_buffer : &controller->kbd_buffer; 150 buffer_write(buffer, data); 151 #if 0 149 152 char ** buffer = 150 153 aux ? &controller->aux_buffer : &controller->kbd_buffer; … … 162 165 163 166 fibril_mutex_unlock(&controller->guard); 167 #endif 164 168 } 165 169 /*----------------------------------------------------------------------------*/ … … 203 207 dev->mouse_fun->driver_data = dev; 204 208 205 fibril_mutex_initialize(&dev->guard); 206 fibril_condvar_initialize(&dev->data_avail); 207 dev->kbd_buffer = NULL; 208 dev->kbd_buffer_end = NULL; 209 dev->aux_buffer = NULL; 210 dev->aux_buffer_end = NULL; 209 buffer_init(&dev->kbd_buffer, dev->kbd_data, BUFFER_SIZE); 210 buffer_init(&dev->aux_buffer, dev->aux_data, BUFFER_SIZE); 211 fibril_mutex_initialize(&dev->write_guard); 211 212 212 213 #define CHECK_RET_DESTROY(ret, msg...) \ … … 300 301 assert(fun->driver_data); 301 302 i8042_t *controller = fun->driver_data; 302 fibril_mutex_lock(&controller-> guard);303 fibril_mutex_lock(&controller->write_guard); 303 304 for (size_t i = 0; i < size; ++i) { 304 305 wait_ready_write(controller); 305 306 pio_write_8(&controller->regs->data, buffer[i]); 306 307 } 307 fibril_mutex_unlock(&controller-> guard);308 fibril_mutex_unlock(&controller->write_guard); 308 309 return size; 309 310 } … … 316 317 317 318 i8042_t *controller = fun->driver_data; 318 fibril_mutex_lock(&controller->guard); 319 /* There is someone else reading from the device. */ 320 if (controller->kbd_buffer) { 321 fibril_mutex_unlock(&controller->guard); 322 return EBUSY; 323 } 324 controller->kbd_buffer = buffer; 325 controller->kbd_buffer_end = buffer + size; 326 327 /* Wait for buffer to be filled */ 328 while (controller->kbd_buffer != controller->kbd_buffer_end) 329 fibril_condvar_wait( 330 &controller->data_avail, &controller->guard); 331 332 controller->kbd_buffer = NULL; 333 controller->kbd_buffer_end = NULL; 334 fibril_mutex_unlock(&controller->guard); 319 320 for (size_t i = 0; i < size; ++i) { 321 *buffer++ = buffer_read(&controller->kbd_buffer); 322 } 335 323 return size; 336 324 } … … 341 329 assert(fun->driver_data); 342 330 i8042_t *controller = fun->driver_data; 343 fibril_mutex_lock(&controller-> guard);331 fibril_mutex_lock(&controller->write_guard); 344 332 for (size_t i = 0; i < size; ++i) { 345 333 wait_ready_write(controller); … … 347 335 pio_write_8(&controller->regs->data, buffer[i]); 348 336 } 349 fibril_mutex_unlock(&controller-> guard);337 fibril_mutex_unlock(&controller->write_guard); 350 338 return size; 351 339 } … … 358 346 359 347 i8042_t *controller = fun->driver_data; 360 fibril_mutex_lock(&controller->guard); 361 /* There is someone else reading from the device. */ 362 if (controller->aux_buffer) { 363 fibril_mutex_unlock(&controller->guard); 364 return EBUSY; 365 } 366 controller->aux_buffer = buffer; 367 controller->aux_buffer_end = buffer + size; 368 369 /* Wait for buffer to be filled */ 370 while (controller->aux_buffer != controller->aux_buffer_end) 371 fibril_condvar_wait( 372 &controller->data_avail, &controller->guard); 373 374 controller->aux_buffer = NULL; 375 controller->aux_buffer_end = NULL; 376 fibril_mutex_unlock(&controller->guard); 348 for (size_t i = 0; i < size; ++i) { 349 *buffer++ = buffer_read(&controller->aux_buffer); 350 } 377 351 return size; 378 352 } -
uspace/drv/char/i8042/i8042.h
rc6c5ff3b r9f97ffe 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 26 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 */ 28 29 29 /** @addtogroup kbd_port 30 30 * @ingroup kbd 31 31 * @{ 32 32 */ 33 34 33 /** @file 35 34 * @brief i8042 port driver. … … 45 44 #include <ddf/driver.h> 46 45 46 #include "buffer.h" 47 48 #define BUFFER_SIZE 12 49 47 50 /** i8042 HW I/O interface */ 48 51 typedef struct { … … 52 55 } __attribute__ ((packed)) i8042_regs_t; 53 56 54 /** Softstate structure, one for each serial port (primary and aux). */55 /*56 typedef struct {57 service_id_t service_id;58 async_sess_t *client_sess;59 } i8042_port_t;60 */61 62 57 typedef struct i8042 i8042_t; 63 64 enum {65 DEVID_PRI = 0, /**< primary device */66 DEVID_AUX = 1, /**< AUX device */67 MAX_DEVS = 268 };69 58 70 59 struct i8042 { 71 60 i8042_regs_t *regs; 72 // i8042_port_t port[MAX_DEVS];73 61 ddf_fun_t *kbd_fun; 74 62 ddf_fun_t *mouse_fun; 75 char * kbd_buffer; 76 char * kbd_buffer_end; 77 char * aux_buffer; 78 char * aux_buffer_end; 79 fibril_mutex_t guard; 80 fibril_condvar_t data_avail; 63 buffer_t aux_buffer; 64 buffer_t kbd_buffer; 65 uint8_t aux_data[BUFFER_SIZE]; 66 uint8_t kbd_data[BUFFER_SIZE]; 67 fibril_mutex_t write_guard; 81 68 }; 82 69
Note:
See TracChangeset
for help on using the changeset viewer.