Changeset 77ad86c in mainline
- Timestamp:
- 2012-06-01T19:00:32Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b713ff80
- Parents:
- 4e5dabf
- Location:
- uspace/lib
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
r4e5dabf r77ad86c 44 44 { 45 45 async_exch_t *exch = async_exchange_begin(inet_sess); 46 46 47 47 ipc_call_t answer; 48 48 aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer); 49 49 int rc = async_connect_to_me(exch, 0, 0, 0, inet_cb_conn, NULL); 50 50 async_exchange_end(exch); 51 51 52 52 if (rc != EOK) 53 53 return rc; 54 54 55 55 sysarg_t retval; 56 56 async_wait_for(req, &retval); 57 if (retval != EOK) 58 return retval; 59 60 return EOK; 57 58 return retval; 61 59 } 62 60 63 61 static int inet_set_proto(uint8_t protocol) 64 62 { 65 int rc;66 67 63 async_exch_t *exch = async_exchange_begin(inet_sess); 68 rc = async_req_1_0(exch, INET_SET_PROTO, protocol);64 int rc = async_req_1_0(exch, INET_SET_PROTO, protocol); 69 65 async_exchange_end(exch); 70 66 71 67 return rc; 72 68 } … … 80 76 assert(inet_ev_ops == NULL); 81 77 assert(inet_protocol == 0); 82 78 83 79 rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc, 84 80 IPC_FLAG_BLOCKING); 85 81 if (rc != EOK) 86 82 return ENOENT; 87 83 88 84 inet_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc, 89 85 IPC_FLAG_BLOCKING); 90 86 if (inet_sess == NULL) 91 87 return ENOENT; 92 88 93 89 if (inet_set_proto(protocol) != EOK) { 94 90 async_hangup(inet_sess); … … 96 92 return EIO; 97 93 } 98 94 99 95 if (inet_callback_create() != EOK) { 100 96 async_hangup(inet_sess); … … 102 98 return EIO; 103 99 } 104 100 105 101 inet_protocol = protocol; 106 102 inet_ev_ops = ev_ops; -
uspace/lib/c/generic/inetcfg.c
r4e5dabf r77ad86c 119 119 120 120 assert(inetcfg_sess == NULL); 121 121 122 122 rc = loc_service_get_id(SERVICE_NAME_INETCFG, &inet_svc, 123 123 IPC_FLAG_BLOCKING); 124 124 if (rc != EOK) 125 125 return ENOENT; 126 126 127 127 inetcfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc, 128 128 IPC_FLAG_BLOCKING); 129 129 if (inetcfg_sess == NULL) 130 130 return ENOENT; 131 131 132 132 return EOK; 133 133 } -
uspace/lib/c/generic/inetping.c
r4e5dabf r77ad86c 49 49 50 50 assert(inetping_sess == NULL); 51 51 52 52 inetping_ev_ops = ev_ops; 53 53 54 54 rc = loc_service_get_id(SERVICE_NAME_INETPING, &inetping_svc, 55 55 IPC_FLAG_BLOCKING); 56 56 if (rc != EOK) 57 57 return ENOENT; 58 58 59 59 inetping_sess = loc_service_connect(EXCHANGE_SERIALIZE, inetping_svc, 60 60 IPC_FLAG_BLOCKING); 61 61 if (inetping_sess == NULL) 62 62 return ENOENT; 63 63 64 64 async_exch_t *exch = async_exchange_begin(inetping_sess); 65 65 66 66 rc = async_connect_to_me(exch, 0, 0, 0, inetping_cb_conn, NULL); 67 67 async_exchange_end(exch); 68 68 69 69 if (rc != EOK) { 70 70 async_hangup(inetping_sess); … … 72 72 return rc; 73 73 } 74 74 75 75 return EOK; 76 76 } -
uspace/lib/c/generic/iplink.c
r4e5dabf r77ad86c 49 49 iplink_t **riplink) 50 50 { 51 iplink_t *iplink = NULL; 52 int rc; 53 54 iplink = calloc(1, sizeof(iplink_t)); 51 iplink_t *iplink = calloc(1, sizeof(iplink_t)); 55 52 if (iplink == NULL) 56 53 return ENOMEM; 57 54 58 55 iplink->sess = sess; 59 56 iplink->ev_ops = ev_ops; 60 57 61 58 async_exch_t *exch = async_exchange_begin(sess); 62 63 rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);59 60 int rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink); 64 61 async_exchange_end(exch); 65 62 66 63 if (rc != EOK) 67 64 goto error; 68 65 69 66 *riplink = iplink; 70 67 return EOK; 71 68 72 69 error: 73 70 if (iplink != NULL) 74 71 free(iplink); 75 72 76 73 return rc; 77 74 } -
uspace/lib/c/generic/net/socket_client.c
r4e5dabf r77ad86c 283 283 static async_sess_t *socket_get_tcp_sess(void) 284 284 { 285 if (socket_globals.tcp_sess == NULL) {285 if (socket_globals.tcp_sess == NULL) 286 286 socket_globals.tcp_sess = service_bind(SERVICE_TCP, 287 287 0, 0, SERVICE_TCP, socket_connection); 288 } 289 288 290 289 return socket_globals.tcp_sess; 291 290 } … … 300 299 static async_sess_t *socket_get_udp_sess(void) 301 300 { 302 if (socket_globals.udp_sess == NULL) {301 if (socket_globals.udp_sess == NULL) 303 302 socket_globals.udp_sess = service_bind(SERVICE_UDP, 304 303 0, 0, SERVICE_UDP, socket_connection); 305 } 306 304 307 305 return socket_globals.udp_sess; 308 306 } -
uspace/lib/drv/generic/driver.c
r4e5dabf r77ad86c 125 125 static void driver_dev_add(ipc_callid_t iid, ipc_call_t *icall) 126 126 { 127 char *dev_name = NULL;128 int res;129 130 127 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 131 128 devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall); 132 129 133 130 ddf_dev_t *dev = create_device(); 134 131 135 132 /* Add one reference that will be dropped by driver_dev_remove() */ 136 133 dev_add_ref(dev); 137 134 dev->handle = dev_handle; 138 135 136 char *dev_name = NULL; 139 137 async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0); 140 138 dev->name = dev_name; 141 139 142 140 /* 143 141 * Currently not used, parent fun handle is stored in context … … 146 144 (void) parent_fun_handle; 147 145 148 res = driver->driver_ops->dev_add(dev);146 int res = driver->driver_ops->dev_add(dev); 149 147 150 148 if (res != EOK) { … … 163 161 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall) 164 162 { 165 devman_handle_t devh; 166 ddf_dev_t *dev; 167 int rc; 168 169 devh = IPC_GET_ARG1(*icall); 163 devman_handle_t devh = IPC_GET_ARG1(*icall); 170 164 171 165 fibril_mutex_lock(&devices_mutex); 172 d ev = driver_get_device(devh);166 ddf_dev_t *dev = driver_get_device(devh); 173 167 if (dev != NULL) 174 168 dev_add_ref(dev); … … 179 173 return; 180 174 } 175 176 int rc; 181 177 182 178 if (driver->driver_ops->dev_remove != NULL) … … 193 189 static void driver_dev_gone(ipc_callid_t iid, ipc_call_t *icall) 194 190 { 195 devman_handle_t devh; 196 ddf_dev_t *dev; 197 int rc; 198 199 devh = IPC_GET_ARG1(*icall); 191 devman_handle_t devh = IPC_GET_ARG1(*icall); 200 192 201 193 fibril_mutex_lock(&devices_mutex); 202 d ev = driver_get_device(devh);194 ddf_dev_t *dev = driver_get_device(devh); 203 195 if (dev != NULL) 204 196 dev_add_ref(dev); … … 209 201 return; 210 202 } 203 204 int rc; 211 205 212 206 if (driver->driver_ops->dev_gone != NULL) … … 223 217 static void driver_fun_online(ipc_callid_t iid, ipc_call_t *icall) 224 218 { 225 devman_handle_t funh; 226 ddf_fun_t *fun; 227 int rc; 228 229 funh = IPC_GET_ARG1(*icall); 219 devman_handle_t funh = IPC_GET_ARG1(*icall); 230 220 231 221 /* … … 236 226 fibril_mutex_lock(&functions_mutex); 237 227 238 fun = driver_get_function(funh);228 ddf_fun_t *fun = driver_get_function(funh); 239 229 if (fun != NULL) 240 230 fun_add_ref(fun); … … 248 238 249 239 /* Call driver entry point */ 240 int rc; 241 250 242 if (driver->driver_ops->fun_online != NULL) 251 243 rc = driver->driver_ops->fun_online(fun); … … 260 252 static void driver_fun_offline(ipc_callid_t iid, ipc_call_t *icall) 261 253 { 262 devman_handle_t funh; 263 ddf_fun_t *fun; 264 int rc; 265 266 funh = IPC_GET_ARG1(*icall); 254 devman_handle_t funh = IPC_GET_ARG1(*icall); 267 255 268 256 /* … … 273 261 fibril_mutex_lock(&functions_mutex); 274 262 275 fun = driver_get_function(funh);263 ddf_fun_t *fun = driver_get_function(funh); 276 264 if (fun != NULL) 277 265 fun_add_ref(fun); … … 285 273 286 274 /* Call driver entry point */ 275 int rc; 276 287 277 if (driver->driver_ops->fun_offline != NULL) 288 278 rc = driver->driver_ops->fun_offline(fun); … … 597 587 void *ddf_dev_data_alloc(ddf_dev_t *dev, size_t size) 598 588 { 599 void *data;600 601 589 assert(dev->driver_data == NULL); 602 603 data = calloc(1, size);590 591 void *data = calloc(1, size); 604 592 if (data == NULL) 605 593 return NULL; 606 594 607 595 dev->driver_data = data; 608 596 return data; … … 634 622 ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name) 635 623 { 636 ddf_fun_t *fun; 637 638 fun = create_function(); 624 ddf_fun_t *fun = create_function(); 639 625 if (fun == NULL) 640 626 return NULL; 641 627 642 628 /* Add one reference that will be dropped by ddf_fun_destroy() */ 643 629 fun->dev = dev; 644 630 fun_add_ref(fun); 645 631 646 632 fun->bound = false; 647 633 fun->ftype = ftype; 648 634 649 635 fun->name = str_dup(name); 650 636 if (fun->name == NULL) { … … 652 638 return NULL; 653 639 } 654 640 655 641 return fun; 656 642 } … … 659 645 void *ddf_fun_data_alloc(ddf_fun_t *fun, size_t size) 660 646 { 661 void *data;662 663 647 assert(fun->bound == false); 664 648 assert(fun->driver_data == NULL); 665 666 data = calloc(1, size);649 650 void *data = calloc(1, size); 667 651 if (data == NULL) 668 652 return NULL; 669 653 670 654 fun->driver_data = data; 671 655 return data; … … 677 661 * must not be bound. 678 662 * 679 * @param fun Function to destroy 663 * @param fun Function to destroy 664 * 680 665 */ 681 666 void ddf_fun_destroy(ddf_fun_t *fun) 682 667 { 683 668 assert(fun->bound == false); 684 669 685 670 /* 686 671 * Drop the reference added by ddf_fun_create(). This will deallocate … … 697 682 if (fun->ops == NULL) 698 683 return NULL; 684 699 685 return fun->ops->interfaces[idx]; 700 686 } … … 709 695 * the same name. 710 696 * 711 * @param fun Function to bind 712 * @return EOK on success or negative error code 697 * @param fun Function to bind 698 * 699 * @return EOK on success or negative error code 700 * 713 701 */ 714 702 int ddf_fun_bind(ddf_fun_t *fun) … … 717 705 assert(fun->name != NULL); 718 706 719 int res;720 721 707 add_to_functions_list(fun); 722 res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,708 int res = devman_add_function(fun->name, fun->ftype, &fun->match_ids, 723 709 fun->dev->handle, &fun->handle); 724 710 if (res != EOK) { … … 736 722 * the function invisible to the system. 737 723 * 738 * @param fun Function to unbind 739 * @return EOK on success or negative error code 724 * @param fun Function to unbind 725 * 726 * @return EOK on success or negative error code 727 * 740 728 */ 741 729 int ddf_fun_unbind(ddf_fun_t *fun) 742 730 { 743 int res;744 745 731 assert(fun->bound == true); 746 732 747 res = devman_remove_function(fun->handle);733 int res = devman_remove_function(fun->handle); 748 734 if (res != EOK) 749 735 return res; 750 736 751 737 remove_from_functions_list(fun); 752 738 … … 757 743 /** Online function. 758 744 * 759 * @param fun Function to online 760 * @return EOK on success or negative error code 745 * @param fun Function to online 746 * 747 * @return EOK on success or negative error code 748 * 761 749 */ 762 750 int ddf_fun_online(ddf_fun_t *fun) 763 751 { 764 int res;765 766 752 assert(fun->bound == true); 767 753 768 res = devman_drv_fun_online(fun->handle);754 int res = devman_drv_fun_online(fun->handle); 769 755 if (res != EOK) 770 756 return res; … … 775 761 /** Offline function. 776 762 * 777 * @param fun Function to offline 778 * @return EOK on success or negative error code 763 * @param fun Function to offline 764 * 765 * @return EOK on success or negative error code 766 * 779 767 */ 780 768 int ddf_fun_offline(ddf_fun_t *fun) 781 769 { 782 int res;783 784 770 assert(fun->bound == true); 785 771 786 res = devman_drv_fun_offline(fun->handle);772 int res = devman_drv_fun_offline(fun->handle); 787 773 if (res != EOK) 788 774 return res; … … 796 782 * Cannot be called when the function node is bound. 797 783 * 798 * @param fun Function 799 * @param match_id_str Match string 800 * @param match_score Match score 801 * @return EOK on success, ENOMEM if out of memory. 784 * @param fun Function 785 * @param match_id_str Match string 786 * @param match_score Match score 787 * 788 * @return EOK on success. 789 * @return ENOMEM if out of memory. 790 * 802 791 */ 803 792 int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str, 804 793 int match_score) 805 794 { 806 match_id_t *match_id;807 808 795 assert(fun->bound == false); 809 796 assert(fun->ftype == fun_inner); 810 797 811 match_id = create_match_id();798 match_id_t *match_id = create_match_id(); 812 799 if (match_id == NULL) 813 800 return ENOMEM; … … 831 818 * 832 819 * Must only be called when the function is bound. 820 * 833 821 */ 834 822 int ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name) … … 842 830 int ddf_driver_main(driver_t *drv) 843 831 { 844 int rc;845 846 832 /* 847 833 * Remember the driver structure - driver_ops will be called by generic … … 858 844 */ 859 845 async_set_client_connection(driver_connection); 860 rc = devman_driver_register(driver->name);846 int rc = devman_driver_register(driver->name); 861 847 if (rc != EOK) { 862 848 printf("Error: Failed to register driver with device manager " … … 864 850 str_error(rc)); 865 851 866 return 1;852 return rc; 867 853 } 868 854 … … 870 856 rc = task_retval(0); 871 857 if (rc != EOK) 872 return 1;873 858 return rc; 859 874 860 async_manager(); 875 861 876 862 /* Never reached. */ 877 return 0;863 return EOK; 878 864 } 879 865 -
uspace/lib/drv/generic/interrupt.c
r4e5dabf r77ad86c 117 117 } 118 118 119 static void 120 add_interrupt_context(interrupt_context_list_t *list,interrupt_context_t *ctx)119 static void add_interrupt_context(interrupt_context_list_t *list, 120 interrupt_context_t *ctx) 121 121 { 122 122 fibril_mutex_lock(&list->mutex); … … 134 134 } 135 135 136 static interrupt_context_t * 137 find_interrupt_context_by_id(interrupt_context_list_t *list, int id)136 static interrupt_context_t *find_interrupt_context_by_id( 137 interrupt_context_list_t *list, int id) 138 138 { 139 139 interrupt_context_t *ctx; … … 153 153 } 154 154 155 static interrupt_context_t * 156 find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)155 static interrupt_context_t *find_interrupt_context( 156 interrupt_context_list_t *list, ddf_dev_t *dev, int irq) 157 157 { 158 158 interrupt_context_t *ctx; … … 173 173 174 174 175 int 176 register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler, 177 irq_code_t *pseudocode) 175 int register_interrupt_handler(ddf_dev_t *dev, int irq, 176 interrupt_handler_t *handler, irq_code_t *pseudocode) 178 177 { 179 178 interrupt_context_t *ctx = create_interrupt_context(); … … 193 192 delete_interrupt_context(ctx); 194 193 } 195 194 196 195 return res; 197 196 } -
uspace/lib/drv/generic/log.c
r4e5dabf r77ad86c 33 33 #include <io/log.h> 34 34 #include <stdarg.h> 35 36 35 #include <ddf/log.h> 37 36 38 37 /** Initialize the logging system. 39 38 * 40 * @param drv_name Driver name, will be printed as part of message 41 * @param level Minimum message level to print 39 * @param drv_name Driver name, will be printed as part of message 40 * @param level Minimum message level to print 41 * 42 42 */ 43 43 int ddf_log_init(const char *drv_name, log_level_t level) … … 48 48 /** Log a driver message. 49 49 * 50 * @param level Message verbosity level. Message is only printed 51 * if verbosity is less than or equal to current 52 * reporting level. 53 * @param fmt Format string (no trailing newline) 50 * @param level Message verbosity level. Message is only printed 51 * if verbosity is less than or equal to current 52 * reporting level. 53 * @param fmt Format string (no trailing newline) 54 * 54 55 */ 55 56 void ddf_msg(log_level_t level, const char *fmt, ...) 56 57 { 57 58 va_list args; 58 59 59 60 va_start(args, fmt); 60 61 log_msgv(level, fmt, args); -
uspace/lib/drv/include/ddf/driver.h
r4e5dabf r77ad86c 81 81 */ 82 82 devman_handle_t handle; 83 83 84 /** Reference count */ 84 85 atomic_t refcnt; … … 104 105 /** True if bound to the device manager */ 105 106 bool bound; 107 106 108 /** Function indentifier (asigned by device manager) */ 107 109 devman_handle_t handle; 110 108 111 /** Reference count */ 109 112 atomic_t refcnt; … … 114 117 /** Function type */ 115 118 fun_type_t ftype; 119 116 120 /** Function name */ 117 121 const char *name; 122 118 123 /** List of device ids for driver matching */ 119 124 match_id_list_t match_ids; 125 120 126 /** Driver-specific data associated with this function */ 121 127 void *driver_data; 128 122 129 /** Implementation of operations provided by this function */ 123 130 ddf_dev_ops_t *ops; 131 124 132 /** Connection handler or @c NULL to use the DDF default handler. */ 125 133 async_client_conn_t conn_handler; … … 137 145 /** Callback method for passing a new device to the device driver */ 138 146 int (*dev_add)(ddf_dev_t *); 147 139 148 /** Ask driver to remove a device */ 140 149 int (*dev_remove)(ddf_dev_t *); 150 141 151 /** Inform driver a device disappeared */ 142 152 int (*dev_gone)(ddf_dev_t *); 153 143 154 /** Ask driver to online a specific function */ 144 155 int (*fun_online)(ddf_fun_t *); 156 145 157 /** Ask driver to offline a specific function */ 146 158 int (*fun_offline)(ddf_fun_t *); -
uspace/lib/drv/include/ddf/interrupt.h
r4e5dabf r77ad86c 42 42 #include <ddi.h> 43 43 #include <fibril_synch.h> 44 45 44 #include "driver.h" 46 45 #include "../dev_iface.h" -
uspace/lib/drv/include/ops/hw_res.h
r4e5dabf r77ad86c 39 39 #include <device/hw_res.h> 40 40 #include <sys/types.h> 41 42 41 #include "../ddf/driver.h" 43 42 -
uspace/lib/drv/include/ops/nic.h
r4e5dabf r77ad86c 40 40 #include <nic/nic.h> 41 41 #include <sys/time.h> 42 43 42 #include "../ddf/driver.h" 44 43 -
uspace/lib/nic/include/nic.h
r4e5dabf r77ad86c 83 83 */ 84 84 typedef void (*send_frame_handler)(nic_t *, void *, size_t); 85 85 86 /** 86 87 * The handler for transitions between driver states. … … 94 95 */ 95 96 typedef int (*state_change_handler)(nic_t *); 97 96 98 /** 97 99 * Handler for unicast filtering mode change. … … 106 108 */ 107 109 typedef int (*unicast_mode_change_handler)(nic_t *, 108 nic_unicast_mode_t, const nic_address_t *, size_t); 110 nic_unicast_mode_t, const nic_address_t *, size_t); 111 109 112 /** 110 113 * Handler for multicast filtering mode change. … … 119 122 */ 120 123 typedef int (*multicast_mode_change_handler)(nic_t *, 121 nic_multicast_mode_t, const nic_address_t *, size_t); 124 nic_multicast_mode_t, const nic_address_t *, size_t); 125 122 126 /** 123 127 * Handler for broadcast filtering mode change. … … 130 134 */ 131 135 typedef int (*broadcast_mode_change_handler)(nic_t *, nic_broadcast_mode_t); 136 132 137 /** 133 138 * Handler for blocked sources list change. … … 138 143 */ 139 144 typedef void (*blocked_sources_change_handler)(nic_t *, 140 const nic_address_t *, size_t); 145 const nic_address_t *, size_t); 146 141 147 /** 142 148 * Handler for VLAN filtering mask change. … … 145 151 */ 146 152 typedef void (*vlan_mask_change_handler)(nic_t *, const nic_vlan_mask_t *); 153 147 154 /** 148 155 * Handler called when a WOL virtue is added. … … 165 172 */ 166 173 typedef int (*wol_virtue_add_handler)(nic_t *, const nic_wol_virtue_t *); 174 167 175 /** 168 176 * Handler called when a WOL virtue is removed. … … 174 182 */ 175 183 typedef void (*wol_virtue_remove_handler)(nic_t *, const nic_wol_virtue_t *); 184 176 185 /** 177 186 * Handler for poll mode change. … … 186 195 */ 187 196 typedef int (*poll_mode_change_handler)(nic_t *, 188 nic_poll_mode_t, const struct timeval *); 197 nic_poll_mode_t, const struct timeval *); 198 189 199 /** 190 200 * Event handler called when the NIC should poll its buffers for a new frame … … 202 212 extern int nic_driver_init(const char *); 203 213 extern void nic_driver_implement(driver_ops_t *, ddf_dev_ops_t *, 204 214 nic_iface_t *); 205 215 206 216 /* Functions called in add_device */ … … 210 220 extern void nic_set_send_frame_handler(nic_t *, send_frame_handler); 211 221 extern void nic_set_state_change_handlers(nic_t *, 212 222 state_change_handler, state_change_handler, state_change_handler); 213 223 extern void nic_set_filtering_change_handlers(nic_t *, 214 215 216 224 unicast_mode_change_handler, multicast_mode_change_handler, 225 broadcast_mode_change_handler, blocked_sources_change_handler, 226 vlan_mask_change_handler); 217 227 extern void nic_set_wol_virtue_change_handlers(nic_t *, 218 228 wol_virtue_add_handler, wol_virtue_remove_handler); 219 229 extern void nic_set_poll_handlers(nic_t *, 220 230 poll_mode_change_handler, poll_request_handler); 221 231 222 232 /* General driver functions */ … … 254 264 extern void nic_report_hw_filtering(nic_t *, int, int, int); 255 265 extern void nic_query_unicast(const nic_t *, 256 266 nic_unicast_mode_t *, size_t, nic_address_t *, size_t *); 257 267 extern void nic_query_multicast(const nic_t *, 258 268 nic_multicast_mode_t *, size_t, nic_address_t *, size_t *); 259 269 extern void nic_query_broadcast(const nic_t *, nic_broadcast_mode_t *); 260 270 extern void nic_query_blocked_sources(const nic_t *, 261 271 size_t, nic_address_t *, size_t *); 262 272 extern int nic_query_vlan_mask(const nic_t *, nic_vlan_mask_t *); 263 273 extern int nic_query_wol_max_caps(const nic_t *, nic_wv_type_t); -
uspace/lib/nic/include/nic_impl.h
r4e5dabf r77ad86c 53 53 extern int nic_get_stats_impl(ddf_fun_t *dev_fun, nic_device_stats_t *stats); 54 54 extern int nic_unicast_get_mode_impl(ddf_fun_t *dev_fun, 55 55 nic_unicast_mode_t *, size_t, nic_address_t *, size_t *); 56 56 extern int nic_unicast_set_mode_impl(ddf_fun_t *dev_fun, 57 57 nic_unicast_mode_t, const nic_address_t *, size_t); 58 58 extern int nic_multicast_get_mode_impl(ddf_fun_t *dev_fun, 59 59 nic_multicast_mode_t *, size_t, nic_address_t *, size_t *); 60 60 extern int nic_multicast_set_mode_impl(ddf_fun_t *dev_fun, 61 61 nic_multicast_mode_t, const nic_address_t *, size_t); 62 62 extern int nic_broadcast_get_mode_impl(ddf_fun_t *, nic_broadcast_mode_t *); 63 63 extern int nic_broadcast_set_mode_impl(ddf_fun_t *, nic_broadcast_mode_t); 64 64 extern int nic_blocked_sources_get_impl(ddf_fun_t *, 65 65 size_t, nic_address_t *, size_t *); 66 66 extern int nic_blocked_sources_set_impl(ddf_fun_t *, const nic_address_t *, size_t); 67 67 extern int nic_vlan_get_mask_impl(ddf_fun_t *, nic_vlan_mask_t *); 68 68 extern int nic_vlan_set_mask_impl(ddf_fun_t *, const nic_vlan_mask_t *); 69 69 extern int nic_wol_virtue_add_impl(ddf_fun_t *dev_fun, nic_wv_type_t type, 70 70 const void *data, size_t length, nic_wv_id_t *new_id); 71 71 extern int nic_wol_virtue_remove_impl(ddf_fun_t *dev_fun, nic_wv_id_t id); 72 72 extern int nic_wol_virtue_probe_impl(ddf_fun_t *dev_fun, nic_wv_id_t id, 73 73 nic_wv_type_t *type, size_t max_length, void *data, size_t *length); 74 74 extern int nic_wol_virtue_list_impl(ddf_fun_t *dev_fun, nic_wv_type_t type, 75 75 size_t max_count, nic_wv_id_t *id_list, size_t *id_count); 76 76 extern int nic_wol_virtue_get_caps_impl(ddf_fun_t *, nic_wv_type_t, int *); 77 77 extern int nic_poll_get_mode_impl(ddf_fun_t *, 78 78 nic_poll_mode_t *, struct timeval *); 79 79 extern int nic_poll_set_mode_impl(ddf_fun_t *, 80 80 nic_poll_mode_t, const struct timeval *); 81 81 extern int nic_poll_now_impl(ddf_fun_t *); 82 82 -
uspace/lib/nic/src/nic_driver.c
r4e5dabf r77ad86c 79 79 } 80 80 81 /** 82 * Fill in the default implementations for device options and NIC interface. 81 /** Fill in the default implementations for device options and NIC interface. 83 82 * 84 83 * @param driver_ops -
uspace/lib/posix/stdbool.h
r4e5dabf r77ad86c 37 37 38 38 #ifdef LIBC_BOOL_H_ 39 #if (!defined(POSIX_STDIO_H_)) \ 40 && (!defined(POSIX_STDLIB_H_)) \ 41 && (!defined(POSIX_STRING_H_)) 42 #error "You can't include bool.h and stdbool.h at the same time." 39 40 #if (!defined(POSIX_STDIO_H_)) && \ 41 (!defined(POSIX_STDLIB_H_)) && \ 42 (!defined(POSIX_STRING_H_)) 43 #error "You can't include bool.h and stdbool.h at the same time." 43 44 #endif 44 #endif 45 46 #endif /* LIBC_BOOL_H */ 45 47 46 48 #define LIBC_BOOL_H_ -
uspace/lib/usb/include/usb/ddfiface.h
r4e5dabf r77ad86c 33 33 * Implementations of DDF interfaces functions. 34 34 */ 35 35 36 #ifndef LIBUSB_DDFIFACE_H_ 36 37 #define LIBUSB_DDFIFACE_H_ … … 39 40 #include <usb_iface.h> 40 41 41 int usb_iface_get_hc_handle_device_impl(ddf_fun_t *, devman_handle_t *);42 int usb_iface_get_my_address_forward_impl(ddf_fun_t *, usb_address_t *);42 extern int usb_iface_get_hc_handle_device_impl(ddf_fun_t *, devman_handle_t *); 43 extern int usb_iface_get_my_address_forward_impl(ddf_fun_t *, usb_address_t *); 43 44 extern usb_iface_t usb_iface_hub_impl; 44 45 45 int usb_iface_get_my_address_from_device_data(ddf_fun_t *, usb_address_t *);46 extern int usb_iface_get_my_address_from_device_data(ddf_fun_t *, usb_address_t *); 46 47 extern usb_iface_t usb_iface_hub_child_impl; 47 48 48 int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);49 extern int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *); 49 50 50 51 #endif 52 51 53 /** 52 54 * @} -
uspace/lib/usb/include/usb/debug.h
r4e5dabf r77ad86c 82 82 /** Default log level. */ 83 83 #ifdef CONFIG_USB_VERBOSE 84 #define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG84 #define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG 85 85 #else 86 #define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_INFO86 #define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_INFO 87 87 #endif 88 88 -
uspace/lib/usb/src/ddfiface.c
r4e5dabf r77ad86c 33 33 * Implementations of DDF interfaces functions (actual implementation). 34 34 */ 35 35 36 #include <devman.h> 36 37 #include <async.h> -
uspace/lib/usb/src/hc.c
r4e5dabf r77ad86c 27 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 */ 29 29 30 /** @addtogroup libusb 30 31 * @{ … … 33 34 * General communication with host controller driver (implementation). 34 35 */ 36 35 37 #include <usb/debug.h> 36 38 … … 44 46 { 45 47 assert(connection); 48 46 49 fibril_mutex_lock(&connection->guard); 47 50 if (connection->ref_count == 0) { … … 55 58 } 56 59 } 60 57 61 ++connection->ref_count; 58 62 fibril_mutex_unlock(&connection->guard); 59 63 return EOK; 60 64 } 61 /*----------------------------------------------------------------------------*/ 65 62 66 static int usb_hc_connection_del_ref(usb_hc_connection_t *connection) 63 67 { 64 68 assert(connection); 69 65 70 fibril_mutex_lock(&connection->guard); 66 71 if (connection->ref_count == 0) { … … 70 75 return EOK; 71 76 } 77 72 78 --connection->ref_count; 73 79 int ret = EOK; … … 125 131 return rc; 126 132 } 127 /*----------------------------------------------------------------------------*/ 133 128 134 void usb_hc_connection_deinitialize(usb_hc_connection_t *connection) 129 135 { … … 140 146 fibril_mutex_unlock(&connection->guard); 141 147 } 142 /*----------------------------------------------------------------------------*/ 148 143 149 /** Open connection to host controller. 144 150 * … … 150 156 return usb_hc_connection_add_ref(connection); 151 157 } 152 /*----------------------------------------------------------------------------*/ 158 153 159 /** Close connection to the host controller. 154 160 * … … 160 166 return usb_hc_connection_del_ref(connection); 161 167 } 162 /*----------------------------------------------------------------------------*/ 168 163 169 /** Ask host controller for free address assignment. 164 170 * … … 182 188 return ret == EOK ? address : ret; 183 189 } 184 /*----------------------------------------------------------------------------*/ 190 185 191 int usb_hc_bind_address(usb_hc_connection_t * connection, 186 192 usb_address_t address, devman_handle_t handle) … … 194 200 return ret; 195 201 } 196 /*----------------------------------------------------------------------------*/ 202 197 203 /** Get handle of USB device with given address. 198 204 * … … 213 219 return ret; 214 220 } 215 /*----------------------------------------------------------------------------*/ 221 216 222 int usb_hc_release_address(usb_hc_connection_t *connection, 217 223 usb_address_t address) … … 225 231 return ret; 226 232 } 227 /*----------------------------------------------------------------------------*/ 233 228 234 int usb_hc_register_endpoint(usb_hc_connection_t *connection, 229 235 usb_address_t address, usb_endpoint_t endpoint, usb_transfer_type_t type, … … 239 245 return ret; 240 246 } 241 /*----------------------------------------------------------------------------*/ 247 242 248 int usb_hc_unregister_endpoint(usb_hc_connection_t *connection, 243 249 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction) … … 252 258 return ret; 253 259 } 254 /*----------------------------------------------------------------------------*/ 260 255 261 int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address, 256 262 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, … … 266 272 return ret; 267 273 } 268 /*----------------------------------------------------------------------------*/ 274 269 275 int usb_hc_write(usb_hc_connection_t *connection, usb_address_t address, 270 276 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size) -
uspace/lib/usbdev/include/usb/dev/driver.h
r4e5dabf r77ad86c 33 33 * USB device driver framework. 34 34 */ 35 35 36 #ifndef LIBUSBDEV_DRIVER_H_ 36 37 #define LIBUSBDEV_DRIVER_H_ -
uspace/lib/usbdev/include/usb/dev/hub.h
r4e5dabf r77ad86c 35 35 * For class specific requests, see usb/classes/hub.h. 36 36 */ 37 37 38 #ifndef LIBUSBDEV_HUB_H_ 38 39 #define LIBUSBDEV_HUB_H_ … … 43 44 #include <usb/hc.h> 44 45 45 int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t, 46 47 int (*)(void *), void *, usb_address_t *, ddf_dev_ops_t *, void *, 47 48 ddf_fun_t **); … … 60 61 } usb_hub_attached_device_t; 61 62 62 int usb_hub_register_device(usb_hc_connection_t *,63 extern int usb_hub_register_device(usb_hc_connection_t *, 63 64 const usb_hub_attached_device_t *); 64 65 … … 69 70 if (attached_device == NULL) 70 71 return EBADMEM; 72 71 73 return usb_hc_release_address(conn, attached_device->address); 72 74 } 73 75 74 76 #endif 77 75 78 /** 76 79 * @} -
uspace/lib/usbdev/include/usb/dev/recognise.h
r4e5dabf r77ad86c 33 33 * USB device recognition. 34 34 */ 35 35 36 #ifndef LIBUSBDEV_RECOGNISE_H_ 36 37 #define LIBUSBDEV_RECOGNISE_H_ … … 41 42 #include <ipc/devman.h> 42 43 43 int usb_device_create_match_ids_from_device_descriptor(44 extern int usb_device_create_match_ids_from_device_descriptor( 44 45 const usb_standard_device_descriptor_t *, match_id_list_t *); 45 46 46 int usb_device_create_match_ids_from_interface(47 extern int usb_device_create_match_ids_from_interface( 47 48 const usb_standard_device_descriptor_t *, 48 49 const usb_standard_interface_descriptor_t *, match_id_list_t *); 49 50 50 int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);51 extern int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *); 51 52 52 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,53 extern int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 53 54 ddf_dev_t *, ddf_dev_ops_t *, void *, ddf_fun_t **); 54 55 55 56 #endif 57 56 58 /** 57 59 * @} -
uspace/lib/usbdev/src/altiface.c
r4e5dabf r77ad86c 33 33 * Handling alternate interface settings. 34 34 */ 35 35 36 #include <usb/dev/driver.h> 36 37 #include <usb/dev/request.h> -
uspace/lib/usbdev/src/hub.c
r4e5dabf r77ad86c 33 33 * Functions needed by hub drivers. 34 34 */ 35 35 36 #include <usb/dev/hub.h> 36 37 #include <usb/dev/pipes.h> … … 114 115 return EOK; 115 116 } 116 117 117 118 118 /** Wrapper for registering attached device to the hub. … … 160 160 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 161 161 { 162 if ( new_fun == NULL || hc_conn == NULL)162 if ((new_fun == NULL) || (hc_conn == NULL)) 163 163 return EINVAL; 164 164 -
uspace/lib/usbdev/src/recognise.c
r4e5dabf r77ad86c 33 33 * Functions for recognition of attached devices. 34 34 */ 35 35 36 #include <sys/types.h> 36 37 #include <fibril_synch.h> … … 311 312 * will be written. 312 313 * @return Error code. 314 * 313 315 */ 314 316 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, … … 318 320 if (child_fun == NULL || ctrl_pipe == NULL) 319 321 return EINVAL; 320 322 321 323 if (!dev_ops && dev_data) { 322 324 usb_log_warning("Using standard fun ops with arbitrary " 323 325 "driver data. This does not have to work.\n"); 324 326 } 325 327 326 328 /** Index to append after device name for uniqueness. */ 327 329 static atomic_t device_name_index = {0}; 328 330 const size_t this_device_name_index = 329 331 (size_t) atomic_preinc(&device_name_index); 330 332 331 333 ddf_fun_t *child = NULL; 332 334 int rc; 333 335 334 336 /* 335 337 * TODO: Once the device driver framework support persistent 336 338 * naming etc., something more descriptive could be created. 337 339 */ 338 char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */340 char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */ 339 341 rc = snprintf(child_name, sizeof(child_name), 340 342 "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address); … … 342 344 goto failure; 343 345 } 344 346 345 347 child = ddf_fun_create(parent, fun_inner, child_name); 346 348 if (child == NULL) { … … 348 350 goto failure; 349 351 } 350 351 if (dev_ops != NULL) {352 353 if (dev_ops != NULL) 352 354 child->ops = dev_ops; 353 } else {355 else 354 356 child->ops = &child_ops; 355 } 356 357 357 358 child->driver_data = dev_data; 358 /* Store the attached device in fun driver data if there is no 359 * other data */ 359 /* 360 * Store the attached device in fun 361 * driver data if there is no other data 362 */ 360 363 if (!dev_data) { 361 364 usb_hub_attached_device_t *new_device = ddf_fun_data_alloc( … … 365 368 goto failure; 366 369 } 370 367 371 new_device->address = ctrl_pipe->wire->address; 368 372 new_device->fun = child; 369 373 } 370 371 374 372 375 rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids); 373 if (rc != EOK) {376 if (rc != EOK) 374 377 goto failure; 375 } 376 378 377 379 rc = ddf_fun_bind(child); 378 if (rc != EOK) {380 if (rc != EOK) 379 381 goto failure; 380 } 381 382 382 383 *child_fun = child; 383 384 return EOK; 384 385 385 386 failure: 386 387 if (child != NULL) { 387 388 /* We know nothing about the data if it came from outside. */ 388 if (dev_data) {389 if (dev_data) 389 390 child->driver_data = NULL; 390 }391 391 392 /* This takes care of match_id deallocation as well. */ 392 393 ddf_fun_destroy(child); 393 394 } 394 395 395 396 return rc; 396 397 } 397 398 398 399 399 /** 400 400 * @} -
uspace/lib/usbhid/src/hidiface.c
r4e5dabf r77ad86c 33 33 * Client functions for accessing USB HID interface (implementation). 34 34 */ 35 35 36 #include <dev_iface.h> 36 37 #include <usbhid_iface.h> -
uspace/lib/usbhost/include/usb/host/hcd.h
r4e5dabf r77ad86c 33 33 * 34 34 */ 35 35 36 #ifndef LIBUSBHOST_HOST_HCD_H 36 37 #define LIBUSBHOST_HOST_HCD_H … … 61 62 void (*ep_remove_hook)(hcd_t *, endpoint_t *); 62 63 }; 63 /*----------------------------------------------------------------------------*/ 64 64 65 /** Initialize hcd_t structure. 65 66 * Initializes device and endpoint managers. Sets data and hook pointer to NULL. … … 79 80 hcd->ep_remove_hook = NULL; 80 81 } 81 /*----------------------------------------------------------------------------*/ 82 82 83 /** Check registered endpoints and reset toggle bit if necessary. 83 84 * @param hcd hcd_t structure, non-null. … … 92 93 &hcd->ep_manager, target, (const uint8_t *)setup_data); 93 94 } 94 /*----------------------------------------------------------------------------*/ 95 95 96 /** Data retrieve wrapper. 96 97 * @param fun ddf function, non-null. … … 102 103 return fun->driver_data; 103 104 } 104 /*----------------------------------------------------------------------------*/ 105 105 106 extern usbhc_iface_t hcd_iface; 106 107 107 108 #endif 109 108 110 /** 109 111 * @} -
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
r4e5dabf r77ad86c 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup libusbhost 29 30 * @{ … … 32 33 * USB transfer transaction structures. 33 34 */ 35 34 36 #ifndef LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H 35 37 #define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H … … 115 117 void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance, 116 118 const void* data, size_t size, int error); 117 /*----------------------------------------------------------------------------*/ 119 118 120 /** Finish batch using stored error value and transferred size. 119 121 * … … 128 130 instance, data, instance->transfered_size, instance->error); 129 131 } 130 /*----------------------------------------------------------------------------*/ 132 131 133 /** Determine batch direction based on the callbacks present 132 134 * @param[in] instance Batch structure to use, non-null. … … 153 155 assert(false); 154 156 } 157 155 158 #endif 159 156 160 /** 157 161 * @} -
uspace/lib/usbhost/src/iface.c
r4e5dabf r77ad86c 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup libusbhost 29 30 * @{ … … 32 33 * @brief HCD DDF interface implementation 33 34 */ 35 34 36 #include <ddf/driver.h> 35 37 #include <errno.h> … … 98 100 return ret; 99 101 } 100 /*----------------------------------------------------------------------------*/ 102 101 103 /** Calls ep_add_hook upon endpoint registration. 102 104 * @param ep Endpoint to be registered. … … 113 115 return EOK; 114 116 } 115 /*----------------------------------------------------------------------------*/ 117 116 118 /** Calls ep_remove_hook upon endpoint removal. 117 119 * @param ep Endpoint to be unregistered. … … 126 128 hcd->ep_remove_hook(hcd, ep); 127 129 } 128 /*----------------------------------------------------------------------------*/ 130 129 131 /** Calls ep_remove_hook upon endpoint removal. Prints warning. 130 132 * @param ep Endpoint to be unregistered. … … 141 143 hcd->ep_remove_hook(hcd, ep); 142 144 } 143 /*----------------------------------------------------------------------------*/ 145 144 146 /** Request address interface function. 145 147 * … … 164 166 &hcd->dev_manager, address, strict, speed); 165 167 } 166 /*----------------------------------------------------------------------------*/ 168 167 169 /** Bind address interface function. 168 170 * … … 183 185 &hcd->dev_manager, address, handle); 184 186 } 185 /*----------------------------------------------------------------------------*/ 187 186 188 /** Find device handle by address interface function. 187 189 * … … 200 202 &hcd->dev_manager, address, handle, NULL); 201 203 } 202 /*----------------------------------------------------------------------------*/ 204 203 205 /** Release address interface function. 204 206 * … … 218 220 return EOK; 219 221 } 220 /*----------------------------------------------------------------------------*/ 222 221 223 /** Register endpoint interface function. 222 224 * @param fun DDF function. … … 254 256 register_helper, hcd); 255 257 } 256 /*----------------------------------------------------------------------------*/ 258 257 259 /** Unregister endpoint interface function. 258 260 * @param fun DDF function. … … 274 276 endpoint, direction, unregister_helper, hcd); 275 277 } 276 /*----------------------------------------------------------------------------*/ 278 277 279 /** Inbound communication interface function. 278 280 * @param fun DDF function. … … 292 294 setup_data, callback, NULL, arg, "READ"); 293 295 } 294 /*----------------------------------------------------------------------------*/ 296 295 297 /** Outbound communication interface function. 296 298 * @param fun DDF function. … … 310 312 setup_data, NULL, callback, arg, "WRITE"); 311 313 } 312 /*----------------------------------------------------------------------------*/ 314 313 315 /** usbhc Interface implementation using hcd_t from libusbhost library. */ 314 316 usbhc_iface_t hcd_iface = { … … 324 326 .write = usb_write, 325 327 }; 328 326 329 /** 327 330 * @} -
uspace/lib/usbvirt/src/device.c
r4e5dabf r77ad86c 33 33 * Virtual USB device main routines. 34 34 */ 35 35 36 #include <errno.h> 36 37 #include <str.h>
Note:
See TracChangeset
for help on using the changeset viewer.