Changeset 83a2f43 in mainline for uspace/lib/drv/generic/driver.c
- Timestamp:
- 2011-02-15T19:43:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af6b5157
- Parents:
- 34588a80
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r34588a80 r83a2f43 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 76 77 }; 77 78 78 static d evice_t *create_device(void);79 static void delete_device(d evice_t *);79 static ddf_dev_t *create_device(void); 80 static void delete_device(ddf_dev_t *); 80 81 81 82 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall) … … 152 153 153 154 interrupt_context_t * 154 find_interrupt_context(interrupt_context_list_t *list, d evice_t *dev, int irq)155 find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq) 155 156 { 156 157 fibril_mutex_lock(&list->mutex); … … 174 175 175 176 int 176 register_interrupt_handler(d evice_t *dev, int irq, interrupt_handler_t *handler,177 register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler, 177 178 irq_code_t *pseudocode) 178 179 { … … 197 198 } 198 199 199 int unregister_interrupt_handler(d evice_t *dev, int irq)200 int unregister_interrupt_handler(ddf_dev_t *dev, int irq) 200 201 { 201 202 interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts, … … 211 212 } 212 213 213 static void add_to_functions_list( function_t *fun)214 static void add_to_functions_list(ddf_fun_t *fun) 214 215 { 215 216 fibril_mutex_lock(&functions_mutex); … … 218 219 } 219 220 220 static void remove_from_functions_list( function_t *fun)221 static void remove_from_functions_list(ddf_fun_t *fun) 221 222 { 222 223 fibril_mutex_lock(&functions_mutex); … … 225 226 } 226 227 227 static function_t *driver_get_function(link_t *functions, devman_handle_t handle)228 { 229 function_t *fun = NULL;228 static ddf_fun_t *driver_get_function(link_t *functions, devman_handle_t handle) 229 { 230 ddf_fun_t *fun = NULL; 230 231 printf("driver_get_function handle=%" PRIun "\n", handle); 231 232 … … 234 235 235 236 while (link != functions) { 236 fun = list_get_instance(link, function_t, link);237 fun = list_get_instance(link, ddf_fun_t, link); 237 238 printf(" - fun handle %" PRIun "\n", fun->handle); 238 239 if (fun->handle == handle) { … … 257 258 devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall); 258 259 259 d evice_t *dev = create_device();260 ddf_dev_t *dev = create_device(); 260 261 dev->handle = dev_handle; 261 262 … … 318 319 */ 319 320 devman_handle_t handle = IPC_GET_ARG2(*icall); 320 function_t *fun = driver_get_function(&functions, handle);321 ddf_fun_t *fun = driver_get_function(&functions, handle); 321 322 322 323 if (fun == NULL) { … … 461 462 * @return The device structure. 462 463 */ 463 static d evice_t *create_device(void)464 { 465 d evice_t *dev;466 467 dev = malloc(sizeof(d evice_t));464 static ddf_dev_t *create_device(void) 465 { 466 ddf_dev_t *dev; 467 468 dev = malloc(sizeof(ddf_dev_t)); 468 469 if (dev == NULL) 469 470 return NULL; 470 471 471 memset(dev, 0, sizeof(d evice_t));472 memset(dev, 0, sizeof(ddf_dev_t)); 472 473 return dev; 473 474 } … … 477 478 * @return The device structure. 478 479 */ 479 static function_t *create_function(void)480 { 481 function_t *fun;482 483 fun = calloc(1, sizeof( function_t));480 static ddf_fun_t *create_function(void) 481 { 482 ddf_fun_t *fun; 483 484 fun = calloc(1, sizeof(ddf_fun_t)); 484 485 if (fun == NULL) 485 486 return NULL; … … 495 496 * @param dev The device structure. 496 497 */ 497 static void delete_device(d evice_t *dev)498 static void delete_device(ddf_dev_t *dev) 498 499 { 499 500 free(dev); … … 504 505 * @param dev The device structure. 505 506 */ 506 static void delete_function( function_t *fun)507 static void delete_function(ddf_fun_t *fun) 507 508 { 508 509 clean_match_ids(&fun->match_ids); … … 535 536 * @return New function or @c NULL if memory is not available 536 537 */ 537 function_t *ddf_fun_create(device_t *dev, fun_type_t ftype, const char *name)538 { 539 function_t *fun;538 ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name) 539 { 540 ddf_fun_t *fun; 540 541 541 542 fun = create_function(); … … 563 564 * @param fun Function to destroy 564 565 */ 565 void ddf_fun_destroy( function_t *fun)566 void ddf_fun_destroy(ddf_fun_t *fun) 566 567 { 567 568 assert(fun->bound == false); … … 569 570 } 570 571 571 void *function_get_ops( function_t *fun, dev_inferface_idx_t idx)572 void *function_get_ops(ddf_fun_t *fun, dev_inferface_idx_t idx) 572 573 { 573 574 assert(is_valid_iface_idx(idx)); … … 589 590 * @return EOK on success or negative error code 590 591 */ 591 int ddf_fun_bind( function_t *fun)592 int ddf_fun_bind(ddf_fun_t *fun) 592 593 { 593 594 assert(fun->name != NULL); … … 617 618 * @return EOK on success, ENOMEM if out of memory. 618 619 */ 619 int ddf_fun_add_match_id( function_t *fun, const char *match_id_str,620 int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str, 620 621 int match_score) 621 622 { … … 637 638 638 639 /** Get default handler for client requests */ 639 remote_handler_t *function_get_default_handler( function_t *fun)640 remote_handler_t *function_get_default_handler(ddf_fun_t *fun) 640 641 { 641 642 if (fun->ops == NULL) … … 648 649 * Must only be called when the function is bound. 649 650 */ 650 int add_function_to_class(function_t *fun, const char *class_name)651 int ddf_fun_add_to_class(ddf_fun_t *fun, const char *class_name) 651 652 { 652 653 assert(fun->bound == true); … … 656 657 } 657 658 658 int d river_main(driver_t *drv)659 int ddf_driver_main(driver_t *drv) 659 660 { 660 661 /*
Note:
See TracChangeset
for help on using the changeset viewer.