?? pci_utils.h
字號:
#ifndef PCI_UTILS_H#define PCI_UTILS_H 1/* * * General PCI utilities. * * Copyright (c) 1999 Richard J.M. Close * Copyright (c) 1999 Pavel Machek <pavel@suse.cz> * Copyright (c) 1999 Jamie Lokier * * Can be freely distributed and used under the terms of the GNU GPL. */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include <ctype.h>#include "stdbool.h"#include "lib/pci.h"#include "pciutils.h"/******************************************************************************** PCI utilities.********************************************************************************//* Format strings used for IRQ numbers and memory addresses */#ifdef ARCH_SPARC64#define IRQ_FORMAT "%08x"#else#define IRQ_FORMAT "%d"#endif#ifdef HAVE_64BIT_ADDRESS#define ADDR_FORMAT "%016Lx"#else#define ADDR_FORMAT "%08lx"#endif#ifdef ARCH_SPARC64#define IO_FORMAT "%016Lx"#elif defined(HAVE_64BIT_ADDRESS)#define IO_FORMAT "%04Lx"#else#define IO_FORMAT "%04lx"#endif/* Communication with libpci */struct pci_access *pacc;/* Our view of the PCI bus */struct device *first_dev;struct device *modem_dev;bool modem_found; // Boolean: modem has been found./* Array to hold IO addresses and their width (in bytes). */unsigned int io_address[6];unsigned int io_length[6];/* The number of I/O ports found, = length of io_address. */unsigned int io_cnt;struct device { struct device *next; struct pci_dev *dev; unsigned int config_cnt; unsigned char config[256];};struct bus { unsigned int number; struct bus *sibling; struct device *first_dev, **last_dev;};/* Tree output */struct bridge { struct bridge *chain; /* Single-linked list of bridges */ struct bridge *next, *child; /* Tree of bridges */ struct bus *first_bus; /* List of busses connected to this bridge */ unsigned int primary, secondary, subordinate; /* Bus numbers */ struct device *br_dev;};struct pci_filter filter; /* Device filter */int buscentric_view; /* Show bus addresses/IRQ's instead of CPU-visible ones */void init_pci(void);void cleanup_pci (void);unsigned int get_pcimodem_irq (void);/* general scanning stuff. */struct device *scan_device(struct pci_dev *p);voidscan_devices(void);intcheck_root(void);intconfig_fetch(struct device *d, unsigned int pos, unsigned int len);/* Config space accesses */inline unsigned charget_conf_byte(struct device *d, unsigned int pos);wordget_conf_word(struct device *d, unsigned int pos);unsigned longget_conf_long(struct device *d, unsigned int pos);/* Count used to access bases of htype0 devices. */int htype0_cnt;/* Sorting */intcompare_them(const void *A, const void *B);voidsort_them(void);/* Normal output */#define FLAG(x,y) ((x & y) ? '+' : '-')voidshow_bases(struct device *d, int cnt);voidshow_htype0(struct device *d);struct bus *find_bus(struct bridge *b, unsigned int n);struct bus *new_bus(struct bridge *b, unsigned int n);voidinsert_dev(struct device *d, struct bridge *b);/* Bus mapping mode */struct bus_bridge { struct bus_bridge *next; unsigned char this, dev, func, first, last, bug;};struct bus_info { unsigned char exists; unsigned char guestbook; struct bus_bridge *bridges, *via;};struct bus_info *bus_info;void do_map_bridges(int bus, int min, int max);/* Show hexadecimal dump of first 64 bytes of the PCI configuration space (the standard header). */void show_pcihex_dump(struct device *d);void redisplay_modem_regs(void);/* Interactively set the control register. */void set_modem_cont_reg(void);/* Lucent modem specific stuff. */int find_modem(void);void show_pcimodem(void);#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -