hc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Jan Vesely
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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         { /* TODO: implement*/ };
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 

Generated on Thu Jun 2 07:45:44 2011 for HelenOS/USB by  doxygen 1.4.7