libhd  5.0
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...) hd_log_printf(hd_data, a)
62 
63 /*
64  * define to make (hd_t).unique_id a hex string, otherwise it is a
65  * base64-like string
66  */
67 #undef NUMERIC_UNIQUE_ID
68 
69 /*
70  * Internal probing module numbers. Use mod_name_by_idx() outside of libhd.
71  */
72 enum mod_idx {
79 };
80 
81 void *new_mem(size_t size);
82 void *resize_mem(void *, size_t);
83 void *add_mem(void *, size_t, size_t);
84 char *new_str(const char *);
85 void *free_mem(void *);
86 int have_common_res(hd_res_t *res1, hd_res_t *res2);
87 void join_res_io(hd_res_t **res1, hd_res_t *res2);
88 void join_res_irq(hd_res_t **res1, hd_res_t *res2);
89 void join_res_dma(hd_res_t **res1, hd_res_t *res2);
91 hd_res_t *add_res_entry(hd_res_t **res, hd_res_t *new_res);
92 hd_t *add_hd_entry(hd_data_t *hd_data, unsigned line, unsigned count);
94 scsi_t *free_scsi(scsi_t *scsi, int free_all);
97 void hd_add_id(hd_data_t *hd_data, hd_t *hd);
98 
99 char *isa_id2str(unsigned);
100 char *eisa_vendor_str(unsigned);
101 unsigned name2eisa_id(char *);
102 char *canon_str(char *, int);
103 
104 int hex(char *string, int digits);
105 
106 void hd_log(hd_data_t *hd_data, char *buf, ssize_t len);
107 void hd_log_printf(hd_data_t *hd_data, char *format, ...) __attribute__ ((format (printf, 2, 3)));
108 void hd_log_hex(hd_data_t *hd_data, int with_ascii, unsigned data_len, unsigned char *data);
109 
110 void str_printf(char **buf, int offset, char *format, ...) __attribute__ ((format (printf, 3, 4)));
111 void hexdump(char **buf, int with_ascii, unsigned data_len, unsigned char *data);
112 str_list_t *search_str_list(str_list_t *sl, char *str);
113 str_list_t *add_str_list(str_list_t **sl, char *str);
116 str_list_t *read_file(char *file_name, unsigned start_line, unsigned lines);
117 str_list_t *read_dir(char *dir_name, int type);
118 char *hd_read_sysfs_link(char *base_dir, char *link_name);
119 void progress(hd_data_t *hd_data, unsigned pos, unsigned count, char *msg);
120 
121 void remove_hd_entries(hd_data_t *hd_data);
122 void remove_tagged_hd_entries(hd_data_t *hd_data);
123 
125 
126 int str2float(char *s, int n);
127 char *float2str(int i, int n);
128 
129 /* return the file name of a module */
130 char *mod_name_by_idx(unsigned idx);
131 
132 int hd_timeout(void(*func)(void *), void *arg, int timeout);
133 
134 str_list_t *read_kmods(hd_data_t *hd_data);
135 char *get_cmd_param(hd_data_t *hd_data, int field);
136 
137 #ifdef __i386__
138 /* smp/smp.c */
139 int detectSMP(void);
140 #endif
141 
142 void update_irq_usage(hd_data_t *hd_data);
143 int run_cmd(hd_data_t *hd_data, char *cmd);
144 int load_module_with_params(hd_data_t *hd_data, char *module, char *params);
145 int load_module(hd_data_t *hd_data, char *module);
146 int unload_module(hd_data_t *hd_data, char *module);
147 int probe_module(hd_data_t *hd_data, char *module);
148 
149 int cmp_hd(hd_t *hd1, hd_t *hd2);
150 unsigned has_something_attached(hd_data_t *hd_data, hd_t *hd);
151 
152 str_list_t *get_cmdline(hd_data_t *hd_data, char *key);
153 
154 int detect_smp_bios(hd_data_t *hd_data);
155 int detect_smp_prom(hd_data_t *hd_data);
156 
157 unsigned char *read_block0(hd_data_t *hd_data, char *dev, int *timeout);
158 
159 void hd_copy(hd_t *dst, hd_t *src);
160 
161 /* parameter for gather_resources(,,, which) */
162 #define W_IO (1 << 0)
163 #define W_DMA (1 << 1)
164 #define W_IRQ (1 << 2)
165 
166 void gather_resources(misc_t *m, hd_res_t **r, char *name, unsigned which);
167 
168 char *vend_id2str(unsigned vend);
169 
170 int hd_getdisksize(hd_data_t *hd_data, char *dev, int fd, hd_res_t **geo, hd_res_t **size);
171 
172 str_list_t *hd_split(char del, const char *str);
173 char *hd_join(char *del, str_list_t *str);
174 
175 int is_pnpinfo(ser_device_t *mi, int ofs);
176 
177 int is_pcmcia_ctrl(hd_data_t *hd_data, hd_t *hd);
178 
179 void hd_fork(hd_data_t *hd_data, int timeout, int total_timeout);
180 void hd_fork_done(hd_data_t *hd_data);
181 void hd_shm_init(hd_data_t *hd_data);
182 void hd_shm_clean(hd_data_t *hd_data);
183 void hd_shm_done(hd_data_t *hd_data);
184 void *hd_shm_add(hd_data_t *hd_data, void *ptr, unsigned len);
185 int hd_is_shm_ptr(hd_data_t *hd_data, void *ptr);
186 void hd_move_to_shm(hd_data_t *hd_data);
187 
188 void read_udevinfo(hd_data_t *hd_data);
189 
190 hd_t *hd_find_sysfs_id(hd_data_t *hd_data, char *id);
191 hd_t *hd_find_sysfs_id_devname(hd_data_t *hd_data, char *id, char *devname);
192 int hd_attr_uint(char* attr, uint64_t* u, int base);
193 str_list_t *hd_attr_list(char *str);
194 char *hd_sysfs_id(char *path);
195 char *hd_sysfs_name2_dev(char *str);
196 char *hd_sysfs_dev2_name(char *str);
197 void hd_sysfs_driver_list(hd_data_t *hd_data);
198 char *hd_sysfs_find_driver(hd_data_t *hd_data, char *sysfs_id, int exact);
199 int hd_report_this(hd_data_t *hd_data, hd_t *hd);
200 str_list_t *hd_module_list(hd_data_t *hd_data, unsigned id);
201 
202 char* get_sysfs_attr(const char* bus, const char* device, const char* attr);
203 char* get_sysfs_attr_by_path(const char* path, const char* attr);
204 
205 void hd_pci_complete_data(hd_t *hd);
206 void hd_pci_read_data(hd_data_t *hd_data);
207 
209 char *hd_hal_print_prop(hal_prop_t *prop);
210 
211 void hal_invalidate(hal_prop_t *prop);
212 void hal_invalidate_all(hal_prop_t *prop, const char *key);
213 hal_prop_t *hal_get_any(hal_prop_t *prop, const char *key);
214 hal_prop_t *hal_get_bool(hal_prop_t *prop, const char *key);
215 hal_prop_t *hal_get_int32(hal_prop_t *prop, const char *key);
216 hal_prop_t *hal_get_str(hal_prop_t *prop, const char *key);
217 hal_prop_t *hal_get_list(hal_prop_t *prop, const char *key);
218 char *hal_get_useful_str(hal_prop_t *prop, const char *key);
219 
220 hal_device_t *hal_find_device(hd_data_t *hd_data, char *udi);
222 
223 char *hd_get_hddb_dir(void);
224 char *hd_get_hddb_path(char *sub);
225 
226 int hd_mod_cmp(char *str1, char *str2);
227 
229 char *get_probe_val_str(hd_data_t *hd_data, enum probe_feature feature);
231 
232 str_list_t *sort_str_list(str_list_t *sl0, int (*cmp_func)(const void *, const void *));
233 
234 
235 #ifdef __cplusplus
236 }
237 #endif
238