libhd 5.0
|
00001 #define PROC_CMDLINE "/proc/cmdline" 00002 #define PROC_PCI_DEVICES "/proc/bus/pci/devices" 00003 #define PROC_PCI_BUS "/proc/bus/pci" 00004 #define PROC_CPUINFO "/proc/cpuinfo" 00005 #define PROC_IOPORTS "/proc/ioports" 00006 #define PROC_DMA "/proc/dma" 00007 #define PROC_INTERRUPTS "/proc/interrupts" 00008 #define PROC_NVRAM_22 "/proc/driver/nvram" 00009 #define PROC_NVRAM_24 "/proc/nvram" 00010 #define PROC_IDE "/proc/ide" 00011 #define PROC_SCSI "/proc/scsi" 00012 #define PROC_CDROM_INFO "/proc/sys/dev/cdrom/info" 00013 #define PROC_NET_IF_INFO "/proc/net/dev" 00014 #define PROC_MODULES "/proc/modules" 00015 #define PROC_DRIVER_SERIAL "/proc/tty/driver/serial" 00016 #define PROC_DRIVER_MACSERIAL "/proc/tty/driver/macserial" 00017 #define PROC_PARPORT_22 "/proc/parport/" /* Final '/' is essential! */ 00018 #define PROC_PARPORT_24 "/proc/sys/dev/parport/parport" 00019 #define PROC_KCORE "/proc/kcore" 00020 // #define PROC_USB_DEVICES "/proc/bus/usb/devices" 00021 #define PROC_USB_DEVICES "/proc/bus/usb/devices_please-use-sysfs-instead" 00022 #define PROC_PROM "/proc/device-tree" 00023 #define PROC_MEMINFO "/proc/meminfo" 00024 #define PROC_VERSION "/proc/version" 00025 #define PROC_ISAPNP "/proc/isapnp" 00026 #define PROC_PARTITIONS "/proc/partitions" 00027 #define PROC_APM "/proc/apm" 00028 00029 #define DEV_NVRAM "/dev/nvram" 00030 #define DEV_PSAUX "/dev/psaux" 00031 #define DEV_ADBMOUSE "/dev/adbmouse" 00032 #define DEV_MEM "/dev/mem" 00033 #define DEV_KBD "/dev/kbd" 00034 #define DEV_CONSOLE "/dev/console" 00035 #define DEV_OPENPROM "/dev/openprom" 00036 #define DEV_SUNMOUSE "/dev/sunmouse" 00037 #define DEV_MICE "/dev/input/mice" 00038 #define DEV_FB "/dev/fb" 00039 #define DEV_FB0 "/dev/fb0" 00040 00041 #define PROG_MODPROBE "/sbin/modprobe" 00042 #define PROG_RMMOD "/sbin/rmmod" 00043 #define PROG_CARDCTL "/sbin/cardctl" 00044 #define PROG_UDEVINFO "/usr/bin/udevinfo" 00045 #define PROG_UDEVADM "/sbin/udevadm" 00046 00047 #define KLOG_BOOT "/var/log/boot.msg" 00048 #define ISAPNP_CONF "/etc/isapnp.conf" 00049 00050 #define KERNEL_22 0x020200 00051 #define KERNEL_24 0x020400 00052 #define KERNEL_26 0x020600 00053 00054 #if defined(__s390__) || defined(__s390x__) || defined(__alpha__) || defined(LIBHD_TINY) 00055 #define WITH_ISDN 0 00056 #else 00057 #define WITH_ISDN 1 00058 #endif 00059 00060 #define PROGRESS(a, b, c) progress(hd_data, a, b, c) 00061 #define ADD2LOG(a...) str_printf(&hd_data->log, -2, a) 00062 00063 #undef LIBHD_MEMCHECK 00064 00065 #if defined(__i386__) || defined(__PPC__) 00066 /* 00067 * f: function we are in 00068 * a: first argument 00069 */ 00070 00071 #ifdef __i386__ 00072 #define CALLED_FROM(f, a) ((void *) ((unsigned *) &a)[-1] - 5) 00073 #endif 00074 00075 #ifdef __PPC__ 00076 /* (1-arg funcs only) #define CALLED_FROM(f, a) ((void *) *((unsigned *) ((void *) &a - ((short *) f)[1] - 4)) - 4) */ 00077 static inline void *getr1() { void *p; asm("mr %0,1" : "=r" (p) :); return p; } 00078 #define CALLED_FROM(f, a) ((void *) ((unsigned *) (getr1() - ((short *) f)[1]))[1] - 4) 00079 #endif 00080 #else 00081 #undef LIBHD_MEMCHECK 00082 #endif 00083 00084 #ifdef LIBHD_MEMCHECK 00085 FILE *libhd_log; 00086 #endif 00087 00088 00089 /* 00090 * define to make (hd_t).unique_id a hex string, otherwise it is a 00091 * base64-like string 00092 */ 00093 #undef NUMERIC_UNIQUE_ID 00094 00095 /* 00096 * Internal probing module numbers. Use mod_name_by_idx() outside of libhd. 00097 */ 00098 enum mod_idx { 00099 mod_none, mod_memory, mod_pci, mod_isapnp, mod_pnpdump, mod_net, 00100 mod_floppy, mod_misc, mod_bios, mod_cpu, mod_monitor, mod_mouse, mod_scsi, 00101 mod_serial, mod_usb, mod_adb, mod_modem, mod_parallel, mod_isa, mod_isdn, 00102 mod_kbd, mod_prom, mod_sbus, mod_int, mod_braille, mod_xtra, mod_sys, 00103 mod_manual, mod_fb, mod_veth, mod_pppoe, mod_pcmcia, mod_s390, 00104 mod_sysfs, mod_dsl, mod_block, mod_edd, mod_input, mod_wlan, mod_hal 00105 }; 00106 00107 void *new_mem(size_t size); 00108 void *resize_mem(void *, size_t); 00109 void *add_mem(void *, size_t, size_t); 00110 char *new_str(const char *); 00111 void *free_mem(void *); 00112 int have_common_res(hd_res_t *res1, hd_res_t *res2); 00113 void join_res_io(hd_res_t **res1, hd_res_t *res2); 00114 void join_res_irq(hd_res_t **res1, hd_res_t *res2); 00115 void join_res_dma(hd_res_t **res1, hd_res_t *res2); 00116 hd_res_t *free_res_list(hd_res_t *res); 00117 hd_res_t *add_res_entry(hd_res_t **res, hd_res_t *new_res); 00118 hd_t *add_hd_entry(hd_data_t *hd_data, unsigned line, unsigned count); 00119 misc_t *free_misc(misc_t *m); 00120 scsi_t *free_scsi(scsi_t *scsi, int free_all); 00121 hd_detail_t *free_hd_detail(hd_detail_t *d); 00122 devtree_t *free_devtree(hd_data_t *hd_data); 00123 void hd_add_id(hd_data_t *hd_data, hd_t *hd); 00124 00125 char *isa_id2str(unsigned); 00126 char *eisa_vendor_str(unsigned); 00127 unsigned name2eisa_id(char *); 00128 char *canon_str(char *, int); 00129 00130 int hex(char *string, int digits); 00131 00132 void str_printf(char **buf, int offset, char *format, ...) __attribute__ ((format (printf, 3, 4))); 00133 void hexdump(char **buf, int with_ascii, unsigned data_len, unsigned char *data); 00134 str_list_t *search_str_list(str_list_t *sl, char *str); 00135 str_list_t *add_str_list(str_list_t **sl, char *str); 00136 str_list_t *free_str_list(str_list_t *list); 00137 str_list_t *reverse_str_list(str_list_t *list); 00138 str_list_t *read_file(char *file_name, unsigned start_line, unsigned lines); 00139 str_list_t *read_dir(char *dir_name, int type); 00140 char *hd_read_sysfs_link(char *base_dir, char *link_name); 00141 void progress(hd_data_t *hd_data, unsigned pos, unsigned count, char *msg); 00142 00143 void remove_hd_entries(hd_data_t *hd_data); 00144 void remove_tagged_hd_entries(hd_data_t *hd_data); 00145 00146 driver_info_t *free_driver_info(driver_info_t *di); 00147 00148 int str2float(char *s, int n); 00149 char *float2str(int i, int n); 00150 00151 /* return the file name of a module */ 00152 char *mod_name_by_idx(unsigned idx); 00153 00154 int hd_timeout(void(*func)(void *), void *arg, int timeout); 00155 00156 str_list_t *read_kmods(hd_data_t *hd_data); 00157 char *get_cmd_param(hd_data_t *hd_data, int field); 00158 00159 #ifdef __i386__ 00160 /* smp/smp.c */ 00161 int detectSMP(void); 00162 #endif 00163 00164 void update_irq_usage(hd_data_t *hd_data); 00165 int run_cmd(hd_data_t *hd_data, char *cmd); 00166 int load_module_with_params(hd_data_t *hd_data, char *module, char *params); 00167 int load_module(hd_data_t *hd_data, char *module); 00168 int unload_module(hd_data_t *hd_data, char *module); 00169 int probe_module(hd_data_t *hd_data, char *module); 00170 00171 int cmp_hd(hd_t *hd1, hd_t *hd2); 00172 unsigned has_something_attached(hd_data_t *hd_data, hd_t *hd); 00173 00174 str_list_t *get_cmdline(hd_data_t *hd_data, char *key); 00175 00176 int detect_smp_bios(hd_data_t *hd_data); 00177 int detect_smp_prom(hd_data_t *hd_data); 00178 00179 unsigned char *read_block0(hd_data_t *hd_data, char *dev, int *timeout); 00180 00181 void hd_copy(hd_t *dst, hd_t *src); 00182 00183 /* parameter for gather_resources(,,, which) */ 00184 #define W_IO (1 << 0) 00185 #define W_DMA (1 << 1) 00186 #define W_IRQ (1 << 2) 00187 00188 void gather_resources(misc_t *m, hd_res_t **r, char *name, unsigned which); 00189 00190 char *vend_id2str(unsigned vend); 00191 00192 int hd_getdisksize(hd_data_t *hd_data, char *dev, int fd, hd_res_t **geo, hd_res_t **size); 00193 00194 str_list_t *hd_split(char del, const char *str); 00195 char *hd_join(char *del, str_list_t *str); 00196 00197 int is_pnpinfo(ser_device_t *mi, int ofs); 00198 00199 int is_pcmcia_ctrl(hd_data_t *hd_data, hd_t *hd); 00200 00201 void hd_fork(hd_data_t *hd_data, int timeout, int total_timeout); 00202 void hd_fork_done(hd_data_t *hd_data); 00203 void hd_shm_init(hd_data_t *hd_data); 00204 void hd_shm_clean(hd_data_t *hd_data); 00205 void hd_shm_done(hd_data_t *hd_data); 00206 void *hd_shm_add(hd_data_t *hd_data, void *ptr, unsigned len); 00207 int hd_is_shm_ptr(hd_data_t *hd_data, void *ptr); 00208 void hd_move_to_shm(hd_data_t *hd_data); 00209 00210 void read_udevinfo(hd_data_t *hd_data); 00211 00212 hd_t *hd_find_sysfs_id(hd_data_t *hd_data, char *id); 00213 hd_t *hd_find_sysfs_id_devname(hd_data_t *hd_data, char *id, char *devname); 00214 int hd_attr_uint(char* attr, uint64_t* u, int base); 00215 str_list_t *hd_attr_list(char *str); 00216 char *hd_sysfs_id(char *path); 00217 char *hd_sysfs_name2_dev(char *str); 00218 char *hd_sysfs_dev2_name(char *str); 00219 void hd_sysfs_driver_list(hd_data_t *hd_data); 00220 char *hd_sysfs_find_driver(hd_data_t *hd_data, char *sysfs_id, int exact); 00221 int hd_report_this(hd_data_t *hd_data, hd_t *hd); 00222 str_list_t *hd_module_list(hd_data_t *hd_data, unsigned id); 00223 00224 char* get_sysfs_attr(const char* bus, const char* device, const char* attr); 00225 char* get_sysfs_attr_by_path(const char* path, const char* attr); 00226 00227 hal_device_t *hd_free_hal_devices(hal_device_t *dev); 00228 void hd_pci_complete_data(hd_t *hd); 00229 void hd_pci_read_data(hd_data_t *hd_data); 00230 00231 char *hd_hal_print_prop(hal_prop_t *prop); 00232 00233 void hal_invalidate(hal_prop_t *prop); 00234 void hal_invalidate_all(hal_prop_t *prop, const char *key); 00235 hal_prop_t *hal_get_any(hal_prop_t *prop, const char *key); 00236 hal_prop_t *hal_get_bool(hal_prop_t *prop, const char *key); 00237 hal_prop_t *hal_get_int32(hal_prop_t *prop, const char *key); 00238 hal_prop_t *hal_get_str(hal_prop_t *prop, const char *key); 00239 hal_prop_t *hal_get_list(hal_prop_t *prop, const char *key); 00240 char *hal_get_useful_str(hal_prop_t *prop, const char *key); 00241 00242 hal_device_t *hal_find_device(hd_data_t *hd_data, char *udi); 00243 hal_prop_t *hal_add_new(hal_prop_t **prop); 00244 00245 char *hd_get_hddb_dir(void); 00246 char *hd_get_hddb_path(char *sub); 00247 00248 int hd_mod_cmp(char *str1, char *str2); 00249 00250 int get_probe_val_int(hd_data_t *hd_data, enum probe_feature feature); 00251 char *get_probe_val_str(hd_data_t *hd_data, enum probe_feature feature); 00252 str_list_t *get_probe_val_list(hd_data_t *hd_data, enum probe_feature feature); 00253 00254 00255 00256 #ifdef __cplusplus 00257 } 00258 #endif 00259