source: mainline/uspace/drv/uhci/root_hub/root_hub.c@ 15be932

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

port_status refactoring, use flags instead of structure

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