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