libhd
5.0
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
hd
hd_int.h
Go to the documentation of this file.
1
#define PROC_CMDLINE "/proc/cmdline"
2
#define PROC_PCI_DEVICES "/proc/bus/pci/devices"
3
#define PROC_PCI_BUS "/proc/bus/pci"
4
#define PROC_CPUINFO "/proc/cpuinfo"
5
#define PROC_IOPORTS "/proc/ioports"
6
#define PROC_DMA "/proc/dma"
7
#define PROC_INTERRUPTS "/proc/interrupts"
8
#define PROC_NVRAM_22 "/proc/driver/nvram"
9
#define PROC_NVRAM_24 "/proc/nvram"
10
#define PROC_IDE "/proc/ide"
11
#define PROC_SCSI "/proc/scsi"
12
#define PROC_CDROM_INFO "/proc/sys/dev/cdrom/info"
13
#define PROC_NET_IF_INFO "/proc/net/dev"
14
#define PROC_MODULES "/proc/modules"
15
#define PROC_DRIVER_SERIAL "/proc/tty/driver/serial"
16
#define PROC_DRIVER_MACSERIAL "/proc/tty/driver/macserial"
17
#define PROC_PARPORT_22 "/proc/parport/"
/* Final '/' is essential! */
18
#define PROC_PARPORT_24 "/proc/sys/dev/parport/parport"
19
#define PROC_KCORE "/proc/kcore"
20
// #define PROC_USB_DEVICES "/proc/bus/usb/devices"
21
#define PROC_USB_DEVICES "/proc/bus/usb/devices_please-use-sysfs-instead"
22
#define PROC_PROM "/proc/device-tree"
23
#define PROC_MEMINFO "/proc/meminfo"
24
#define PROC_VERSION "/proc/version"
25
#define PROC_ISAPNP "/proc/isapnp"
26
#define PROC_PARTITIONS "/proc/partitions"
27
#define PROC_APM "/proc/apm"
28
29
#define DEV_NVRAM "/dev/nvram"
30
#define DEV_PSAUX "/dev/psaux"
31
#define DEV_ADBMOUSE "/dev/adbmouse"
32
#define DEV_MEM "/dev/mem"
33
#define DEV_KBD "/dev/kbd"
34
#define DEV_CONSOLE "/dev/console"
35
#define DEV_OPENPROM "/dev/openprom"
36
#define DEV_SUNMOUSE "/dev/sunmouse"
37
#define DEV_MICE "/dev/input/mice"
38
#define DEV_FB "/dev/fb"
39
#define DEV_FB0 "/dev/fb0"
40
41
#define PROG_MODPROBE "/sbin/modprobe"
42
#define PROG_RMMOD "/sbin/rmmod"
43
#define PROG_CARDCTL "/sbin/cardctl"
44
#define PROG_UDEVINFO "/usr/bin/udevinfo"
45
#define PROG_UDEVADM "/sbin/udevadm"
46
47
#define KLOG_BOOT "/var/log/boot.msg"
48
#define ISAPNP_CONF "/etc/isapnp.conf"
49
50
#define KERNEL_22 0x020200
51
#define KERNEL_24 0x020400
52
#define KERNEL_26 0x020600
53
54
#if defined(__s390__) || defined(__s390x__) || defined(__alpha__) || defined(LIBHD_TINY)
55
#define WITH_ISDN 0
56
#else
57
#define WITH_ISDN 1
58
#endif
59
60
#define PROGRESS(a, b, c) progress(hd_data, a, b, c)
61
#define ADD2LOG(a...) str_printf(&hd_data->log, -2, a)
62
63
#undef LIBHD_MEMCHECK
64
65
#if defined(__i386__) || defined(__PPC__)
66
/*
67
* f: function we are in
68
* a: first argument
69
*/
70
71
#ifdef __i386__
72
#define CALLED_FROM(f, a) ((void *) ((unsigned *) &a)[-1] - 5)
73
#endif
74
75
#ifdef __PPC__
76
/* (1-arg funcs only) #define CALLED_FROM(f, a) ((void *) *((unsigned *) ((void *) &a - ((short *) f)[1] - 4)) - 4) */
77
static
inline
void
*getr1() {
void
*p;
asm
(
"mr %0,1"
:
"=r"
(p) :);
return
p; }
78
#define CALLED_FROM(f, a) ((void *) ((unsigned *) (getr1() - ((short *) f)[1]))[1] - 4)
79
#endif
80
#else
81
#undef LIBHD_MEMCHECK
82
#endif
83
84
#ifdef LIBHD_MEMCHECK
85
FILE *libhd_log;
86
#endif
87
88
89
/*
90
* define to make (hd_t).unique_id a hex string, otherwise it is a
91
* base64-like string
92
*/
93
#undef NUMERIC_UNIQUE_ID
94
95
/*
96
* Internal probing module numbers. Use mod_name_by_idx() outside of libhd.
97
*/
98
enum
mod_idx
{
99
mod_none
,
mod_memory
,
mod_pci
,
mod_isapnp
,
mod_pnpdump
,
mod_net
,
100
mod_floppy
,
mod_misc
,
mod_bios
,
mod_cpu
,
mod_monitor
,
mod_mouse
,
mod_scsi
,
101
mod_serial
,
mod_usb
,
mod_adb
,
mod_modem
,
mod_parallel
,
mod_isa
,
mod_isdn
,
102
mod_kbd
,
mod_prom
,
mod_sbus
,
mod_int
,
mod_braille
,
mod_xtra
,
mod_sys
,
103
mod_manual
,
mod_fb
,
mod_veth
,
mod_pppoe
,
mod_pcmcia
,
mod_s390
,
104
mod_sysfs
,
mod_dsl
,
mod_block
,
mod_edd
,
mod_input
,
mod_wlan
,
mod_hal
105
};
106
107
void
*
new_mem
(
size_t
size
);
108
void
*
resize_mem
(
void
*,
size_t
);
109
void
*
add_mem
(
void
*,
size_t
,
size_t
);
110
char
*
new_str
(
const
char
*);
111
void
*
free_mem
(
void
*);
112
int
have_common_res
(
hd_res_t
*res1,
hd_res_t
*res2);
113
void
join_res_io
(
hd_res_t
**res1,
hd_res_t
*res2);
114
void
join_res_irq
(
hd_res_t
**res1,
hd_res_t
*res2);
115
void
join_res_dma
(
hd_res_t
**res1,
hd_res_t
*res2);
116
hd_res_t
*
free_res_list
(
hd_res_t
*res);
117
hd_res_t
*
add_res_entry
(
hd_res_t
**res,
hd_res_t
*new_res);
118
hd_t
*
add_hd_entry
(
hd_data_t
*
hd_data
,
unsigned
line
,
unsigned
count);
119
misc_t
*
free_misc
(
misc_t
*m);
120
scsi_t
*
free_scsi
(
scsi_t
*scsi,
int
free_all);
121
hd_detail_t
*
free_hd_detail
(
hd_detail_t
*d);
122
devtree_t
*
free_devtree
(
hd_data_t
*
hd_data
);
123
void
hd_add_id
(
hd_data_t
*
hd_data
,
hd_t
*hd);
124
125
char
*
isa_id2str
(
unsigned
);
126
char
*
eisa_vendor_str
(
unsigned
);
127
unsigned
name2eisa_id
(
char
*);
128
char
*
canon_str
(
char
*,
int
);
129
130
int
hex
(
char
*
string
,
int
digits);
131
132
void
str_printf
(
char
**buf,
int
offset,
char
*format, ...) __attribute__ ((format (printf, 3, 4)));
133
void
hexdump
(
char
**buf,
int
with_ascii,
unsigned
data_len,
unsigned
char
*data);
134
str_list_t
*
search_str_list
(
str_list_t
*sl,
char
*str);
135
str_list_t
*
add_str_list
(
str_list_t
**sl,
char
*str);
136
str_list_t
*
free_str_list
(
str_list_t
*list);
137
str_list_t
*
reverse_str_list
(
str_list_t
*list);
138
str_list_t
*
read_file
(
char
*file_name,
unsigned
start_line,
unsigned
lines);
139
str_list_t
*
read_dir
(
char
*dir_name,
int
type
);
140
char
*
hd_read_sysfs_link
(
char
*base_dir,
char
*link_name);
141
void
progress
(
hd_data_t
*
hd_data
,
unsigned
pos,
unsigned
count,
char
*msg);
142
143
void
remove_hd_entries
(
hd_data_t
*hd_data);
144
void
remove_tagged_hd_entries
(
hd_data_t
*hd_data);
145
146
driver_info_t
*
free_driver_info
(
driver_info_t
*di);
147
148
int
str2float
(
char
*s,
int
n);
149
char
*
float2str
(
int
i,
int
n);
150
151
/* return the file name of a module */
152
char
*
mod_name_by_idx
(
unsigned
idx);
153
154
int
hd_timeout
(
void
(*func)(
void
*),
void
*arg,
int
timeout);
155
156
str_list_t
*
read_kmods
(
hd_data_t
*hd_data);
157
char
*
get_cmd_param
(
hd_data_t
*hd_data,
int
field);
158
159
#ifdef __i386__
160
/* smp/smp.c */
161
int
detectSMP(
void
);
162
#endif
163
164
void
update_irq_usage
(
hd_data_t
*hd_data);
165
int
run_cmd
(
hd_data_t
*hd_data,
char
*cmd);
166
int
load_module_with_params
(
hd_data_t
*hd_data,
char
*
module
,
char
*params);
167
int
load_module
(
hd_data_t
*hd_data,
char
*
module
);
168
int
unload_module
(
hd_data_t
*hd_data,
char
*
module
);
169
int
probe_module
(
hd_data_t
*hd_data,
char
*
module
);
170
171
int
cmp_hd
(
hd_t
*hd1,
hd_t
*hd2);
172
unsigned
has_something_attached
(
hd_data_t
*hd_data,
hd_t
*hd);
173
174
str_list_t
*
get_cmdline
(
hd_data_t
*hd_data,
char
*key);
175
176
int
detect_smp_bios
(
hd_data_t
*hd_data);
177
int
detect_smp_prom
(
hd_data_t
*hd_data);
178
179
unsigned
char
*
read_block0
(
hd_data_t
*hd_data,
char
*dev,
int
*timeout);
180
181
void
hd_copy
(
hd_t
*dst,
hd_t
*src);
182
183
/* parameter for gather_resources(,,, which) */
184
#define W_IO (1 << 0)
185
#define W_DMA (1 << 1)
186
#define W_IRQ (1 << 2)
187
188
void
gather_resources
(
misc_t
*m,
hd_res_t
**r,
char
*name,
unsigned
which);
189
190
char
*
vend_id2str
(
unsigned
vend);
191
192
int
hd_getdisksize
(
hd_data_t
*hd_data,
char
*dev,
int
fd,
hd_res_t
**geo,
hd_res_t
**
size
);
193
194
str_list_t
*
hd_split
(
char
del,
const
char
*str);
195
char
*
hd_join
(
char
*del,
str_list_t
*str);
196
197
int
is_pnpinfo
(
ser_device_t
*mi,
int
ofs);
198
199
int
is_pcmcia_ctrl
(
hd_data_t
*hd_data,
hd_t
*hd);
200
201
void
hd_fork
(
hd_data_t
*hd_data,
int
timeout,
int
total_timeout);
202
void
hd_fork_done
(
hd_data_t
*hd_data);
203
void
hd_shm_init
(
hd_data_t
*hd_data);
204
void
hd_shm_clean
(
hd_data_t
*hd_data);
205
void
hd_shm_done
(
hd_data_t
*hd_data);
206
void
*
hd_shm_add
(
hd_data_t
*hd_data,
void
*ptr,
unsigned
len);
207
int
hd_is_shm_ptr
(
hd_data_t
*hd_data,
void
*ptr);
208
void
hd_move_to_shm
(
hd_data_t
*hd_data);
209
210
void
read_udevinfo
(
hd_data_t
*hd_data);
211
212
hd_t
*
hd_find_sysfs_id
(
hd_data_t
*hd_data,
char
*
id
);
213
hd_t
*
hd_find_sysfs_id_devname
(
hd_data_t
*hd_data,
char
*
id
,
char
*devname);
214
int
hd_attr_uint
(
char
* attr, uint64_t* u,
int
base);
215
str_list_t
*
hd_attr_list
(
char
*str);
216
char
*
hd_sysfs_id
(
char
*path);
217
char
*
hd_sysfs_name2_dev
(
char
*str);
218
char
*
hd_sysfs_dev2_name
(
char
*str);
219
void
hd_sysfs_driver_list
(
hd_data_t
*hd_data);
220
char
*
hd_sysfs_find_driver
(
hd_data_t
*hd_data,
char
*sysfs_id,
int
exact);
221
int
hd_report_this
(
hd_data_t
*hd_data,
hd_t
*hd);
222
str_list_t
*
hd_module_list
(
hd_data_t
*hd_data,
unsigned
id
);
223
224
char
*
get_sysfs_attr
(
const
char
* bus,
const
char
*
device
,
const
char
* attr);
225
char
*
get_sysfs_attr_by_path
(
const
char
* path,
const
char
* attr);
226
227
hal_device_t
*
hd_free_hal_devices
(
hal_device_t
*dev);
228
void
hd_pci_complete_data
(
hd_t
*hd);
229
void
hd_pci_read_data
(
hd_data_t
*hd_data);
230
231
char
*
hd_hal_print_prop
(
hal_prop_t
*prop);
232
233
void
hal_invalidate
(
hal_prop_t
*prop);
234
void
hal_invalidate_all
(
hal_prop_t
*prop,
const
char
*key);
235
hal_prop_t
*
hal_get_any
(
hal_prop_t
*prop,
const
char
*key);
236
hal_prop_t
*
hal_get_bool
(
hal_prop_t
*prop,
const
char
*key);
237
hal_prop_t
*
hal_get_int32
(
hal_prop_t
*prop,
const
char
*key);
238
hal_prop_t
*
hal_get_str
(
hal_prop_t
*prop,
const
char
*key);
239
hal_prop_t
*
hal_get_list
(
hal_prop_t
*prop,
const
char
*key);
240
char
*
hal_get_useful_str
(
hal_prop_t
*prop,
const
char
*key);
241
242
hal_device_t
*
hal_find_device
(
hd_data_t
*hd_data,
char
*udi);
243
hal_prop_t
*
hal_add_new
(
hal_prop_t
**prop);
244
245
char
*
hd_get_hddb_dir
(
void
);
246
char
*
hd_get_hddb_path
(
char
*sub);
247
248
int
hd_mod_cmp
(
char
*str1,
char
*str2);
249
250
int
get_probe_val_int
(
hd_data_t
*hd_data,
enum
probe_feature
feature
);
251
char
*
get_probe_val_str
(
hd_data_t
*hd_data,
enum
probe_feature
feature
);
252
str_list_t
*
get_probe_val_list
(
hd_data_t
*hd_data,
enum
probe_feature
feature
);
253
254
255
256
#ifdef __cplusplus
257
}
258
#endif
259