source: mainline/uspace/drv/uhci/root_hub/root_hub.c@ 44d8853

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 44d8853 was f9dd44d, checked in by Jan Vesely <jano.vesely@…>, 15 years ago

refactoring, use libusb device identification

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#include <async.h>
2#include <ddi.h>
3#include <errno.h>
4#include <stdint.h>
5#include <stdio.h>
6
7#include "debug.h"
8#include "root_hub.h"
9
10#define ROOT_HUB_WAIT_USEC 10000000 /* 10 seconds */
11
12int uhci_root_hub_init( uhci_root_hub_t *hub, device_t *hc, void *addr )
13{
14 assert( hub );
15
16 /* allow access to root hub registers */
17 port_status_t *regs;
18 const int ret = pio_enable(
19 addr, sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT, (void**)&regs);
20
21 if (ret < 0) {
22 uhci_print_error(": Failed to gain access to port registers at %p\n", regs);
23 return ret;
24 }
25
26 /* add fibrils for periodic port checks */
27 unsigned i = 0;
28 for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
29 /* mind pointer arithmetics */
30 uhci_port_init(
31 &hub->ports[i], regs + i, hc, i, ROOT_HUB_WAIT_USEC);
32
33 hub->checker[i] = fibril_create(uhci_port_check, &hub->ports[i]);
34 if (hub->checker[i] == 0) {
35 uhci_print_error(": failed to launch root hub fibril.");
36 return ENOMEM;
37 }
38 fibril_add_ready(hub->checker[i]);
39 uhci_print_verbose(" added fibril for port %d: %p.\n", i, hub->checker[i]);
40 }
41
42 return EOK;
43}
44/*----------------------------------------------------------------------------*/
45int uhci_root_hub_fini( uhci_root_hub_t* instance )
46{
47 assert( instance );
48 // TODO:
49 //destroy fibril here
50 //disable access to registers
51 return EOK;
52}
53/*----------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.