source: mainline/uspace/srv/dd/isa.c@ fcbd1be

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fcbd1be was fcbd1be, checked in by Lenka Trochtova <trochtova.lenka@…>, 16 years ago

the name of the hierarchical driver was changed II

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <futex.h>
2#include <assert.h>
3
4#include "isa.h"
5
6LIST_INITIALIZE(isa_bridges_list);
7LIST_INITIALIZE(isa_drivers_list);
8
9static atomic_t isa_bus_futex = FUTEX_INITIALIZER;
10
11static void isa_probe_all(bridge_to_isa_t *bridge);
12static void isa_drv_probe(isa_drv_t *drv);
13
14int isa_bus_init()
15{
16 return 1;
17}
18
19void isa_register_bridge(bridge_to_isa_t *bridge)
20{
21 futex_down(&isa_bus_futex);
22
23 printf("ISA: registering new sth-to-isa bridge.\n");
24
25 // add bridge to the list
26 list_append(&(bridge->link), &isa_bridges_list);
27
28 // call probe function of all registered drivers of isa devices
29 isa_probe_all(bridge);
30
31 futex_up(&isa_bus_futex);
32}
33
34void isa_register_driver(isa_drv_t *drv)
35{
36 assert(drv->name != NULL);
37
38 futex_down(&isa_bus_futex);
39
40 printf("ISA: registering new driver '%s'.\n", drv->name);
41
42 // add bridge to the list
43 list_append(&(drv->link), &isa_drivers_list);
44
45 // call driver's probe function on all registered bridges
46 isa_drv_probe(drv);
47
48 futex_up(&isa_bus_futex);
49}
50
51static void isa_probe_all(bridge_to_isa_t *bridge)
52{
53 link_t *item = isa_drivers_list.next;
54 isa_drv_t *drv = NULL;
55
56 while (item != &isa_drivers_list) {
57 drv = list_get_instance(item, isa_drv_t, link);
58 if (drv->ops != NULL && drv->ops->probe != NULL) {
59 drv->ops->probe(bridge);
60 }
61 item = item->next;
62 }
63}
64
65static void isa_drv_probe(isa_drv_t *drv)
66{
67 link_t *item = isa_bridges_list.next;
68 bridge_to_isa_t *bridge = NULL;
69
70 if (drv->ops != NULL && drv->ops->probe != NULL) {
71 while (item != &isa_bridges_list) {
72 bridge = list_get_instance(item, bridge_to_isa_t, link);
73 {
74 drv->ops->probe(bridge);
75 }
76 item = item->next;
77 }
78 }
79}
Note: See TracBrowser for help on using the repository browser.