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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/***************************************************************************
* CVSID: $Id$
*
* osspec.c : HAL backend for FreeBSD
*
* Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/param.h>
#include <string.h>
#include "../ids.h"
#include "../logger.h"
#include "../osspec.h"
#include "hf-util.h"
#include "hf-osspec.h"
#include "hf-acpi.h"
#include "hf-ata.h"
#include "hf-computer.h"
#include "hf-devd.h"
#include "hf-devtree.h"
#include "hf-drm.h"
#include "hf-net.h"
#include "hf-pci.h"
#include "hf-scsi.h"
#include "hf-serial.h"
#include "hf-sound.h"
#include "hf-storage.h"
#include "hf-usb.h"
#ifdef HAVE_LIBUSB20
#include "hf-usb2.h"
#endif
#include "hf-volume.h"
/* the order matters: PCI devices must be created before their children, etc */
static HFHandler *handlers[] = {
&hf_pci_handler,
&hf_devtree_handler,
#if __FreeBSD_version < 800092
&hf_usb_handler,
#endif
#ifdef HAVE_LIBUSB20
&hf_usb2_handler,
#endif
&hf_ata_handler,
&hf_scsi_handler,
&hf_storage_handler,
&hf_volume_handler,
&hf_net_handler,
&hf_serial_handler,
&hf_acpi_handler,
&hf_sound_handler,
&hf_drm_handler,
&hf_devd_handler
};
static HalFileMonitor *file_monitor = NULL;
HalFileMonitor *
osspec_get_file_monitor (void)
{
return file_monitor;
}
void
osspec_privileged_init (void)
{
int i;
file_monitor = hal_file_monitor_new ();
if (file_monitor == NULL)
{
HAL_INFO(("Cannot initialize file monitor"));
}
for (i = 0; i < (int) G_N_ELEMENTS(handlers); i++)
if (handlers[i]->privileged_init)
handlers[i]->privileged_init();
}
void
osspec_init (void)
{
int i;
pci_ids_init();
for (i = 0; i < (int) G_N_ELEMENTS(handlers); i++)
if (handlers[i]->init)
handlers[i]->init();
}
void
osspec_probe (void)
{
if (hf_computer_device_add())
{
int i;
for (i = 0; i < (int) G_N_ELEMENTS(handlers); i++)
if (handlers[i]->probe)
handlers[i]->probe();
}
if (hald_is_initialising)
osspec_probe_done();
}
gboolean
osspec_device_rescan (HalDevice *d)
{
int i;
for (i = 0; i < (int) G_N_ELEMENTS(handlers); i++)
if (handlers[i]->device_rescan && handlers[i]->device_rescan(d))
return TRUE;
return FALSE;
}
gboolean
osspec_device_reprobe (HalDevice *d)
{
int i;
for (i = 0; i < (int) G_N_ELEMENTS(handlers); i++)
if (handlers[i]->device_reprobe && handlers[i]->device_reprobe(d))
goto end;
/* no match, default action */
hf_device_remove_tree(d);
osspec_probe();
end:
return FALSE; /* this is what linux2 returns */
}
void
osspec_refresh_mount_state_for_block_device (HalDevice *d)
{
hf_volume_update_mount(d);
}
DBusHandlerResult
osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
|