00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef DRV_OHCI_HC_H
00035 #define DRV_OHCI_HC_H
00036
00037 #include <fibril.h>
00038 #include <fibril_synch.h>
00039 #include <adt/list.h>
00040 #include <ddi.h>
00041
00042 #include <usb/usb.h>
00043 #include <usb/host/device_keeper.h>
00044 #include <usb/host/usb_endpoint_manager.h>
00045 #include <usbhc_iface.h>
00046
00047 #include "batch.h"
00048 #include "ohci_regs.h"
00049 #include "root_hub.h"
00050 #include "endpoint_list.h"
00051 #include "hw_struct/hcca.h"
00052
00053 #define OHCI_NEEDED_IRQ_COMMANDS 5
00054
00056 typedef struct hc {
00058 usb_device_keeper_t manager;
00060 usb_endpoint_manager_t ep_manager;
00061
00063 ohci_regs_t *registers;
00065 hcca_t *hcca;
00066
00068 endpoint_list_t lists[4];
00070 link_t pending_batches;
00071
00073 fid_t interrupt_emulator;
00074
00076 fibril_mutex_t guard;
00077
00079 irq_code_t interrupt_code;
00080
00082 irq_cmd_t interrupt_commands[OHCI_NEEDED_IRQ_COMMANDS];
00083
00085 rh_t rh;
00086 } hc_t;
00087
00088 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
00089 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);
00090 void hc_start_hw(hc_t *instance);
00091
00096 static inline void hc_fini(hc_t *instance)
00097 { };
00098
00099 int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep,
00100 usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
00101 size_t max_packet_size, size_t size, unsigned interval);
00102 int hc_remove_endpoint(hc_t *instance, usb_address_t address,
00103 usb_endpoint_t endpoint, usb_direction_t direction);
00104 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
00105 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw);
00106
00107 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
00108 void hc_interrupt(hc_t *instance, uint32_t status);
00109
00115 static inline hc_t * fun_to_hc(ddf_fun_t *fun)
00116 { return fun->driver_data; }
00117 #endif
00118