1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/*
* Copyright (c) 1997-1999 University of Utah and the Flux Group.
* All rights reserved.
*
* This file is part of the Flux OSKit. The OSKit is free software, also known
* as "open source;" you can redistribute it and/or modify it under the terms
* of the GNU General Public License (GPL), version 2, as published by the Free
* Software Foundation (FSF). To explore alternate licensing terms, contact
* the University of Utah at csl-dist@cs.utah.edu or +1-801-585-3271.
*
* The OSKit is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GPL for more details. You should have
* received a copy of the GPL along with the OSKit; see the file COPYING. If
* not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
*/
#include <oskit/com.h>
#include <oskit/dev/dev.h>
#include <oskit/dev/driver.h>
/*
* Local services database.
*/
static oskit_services_t *driver_registry;
oskit_error_t
osenv_driver_register(oskit_driver_t *driver,
const struct oskit_guid *iids, unsigned iid_count)
{
oskit_error_t rc;
int i;
#ifdef CPUNITS
osenv_assert(driver_registry);
#endif
/* Register the basic driver interface */
rc = oskit_services_addservice(driver_registry,
&oskit_driver_iid, driver);
if (rc)
return rc;
/* Register the other supported interfaces */
for (i = 0; i < iid_count; i++) {
oskit_iunknown_t *iu;
rc = driver->ops->query(driver, &iids[i], (void**)&iu);
if (rc)
return rc;
rc = oskit_services_addservice(driver_registry, &iids[i], iu);
if (rc)
return rc;
iu->ops->release(iu);
}
return 0;
}
oskit_error_t
osenv_driver_unregister(oskit_driver_t *driver,
const struct oskit_guid *iids, unsigned iid_count)
{
oskit_error_t rc;
int i;
#ifdef CPUNITS
osenv_assert(driver_registry);
#endif
/* Unregister the basic driver interface */
oskit_services_remservice(driver_registry, &oskit_driver_iid, driver);
/* Unregister the other supported interfaces */
for (i = 0; i < iid_count; i++) {
oskit_iunknown_t *iu;
rc = driver->ops->query(driver, &iids[i], (void**)&iu);
if (rc)
return rc;
rc = oskit_services_remservice(driver_registry, &iids[i], iu);
if (rc)
return rc;
iu->ops->release(iu);
}
return 0;
}
oskit_error_t
osenv_driver_lookup(const struct oskit_guid *iid, void ***out_interface_array)
{
#ifdef CPUNITS
osenv_assert(driver_registry);
#endif
return oskit_services_lookup(driver_registry,
iid, out_interface_array);
}
/*
* Initialize the driver registration service. Create a services database
* to hold all the goodies.
*/
#ifdef CPUNITS
oskit_error_t
init(void)
{
return oskit_services_create((struct oskit_mem *) 0, &driver_registry);
}
#else
void
osenv_driver_registration_init(void)
{
if (oskit_services_create((struct oskit_mem *) 0, &driver_registry))
osenv_panic("osenv_driver_registration_init: Bad registry");
}
#endif
|