Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

hd_int.h

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