Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:54

0001 /*
0002  *  PCI defines and function prototypes
0003  *  Copyright 1994, Drew Eckhardt
0004  *  Copyright 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
0005  *
0006  *  For more information, please consult the following manuals (look at
0007  *  http://www.pcisig.com/ for how to get them):
0008  *
0009  *  PCI BIOS Specification
0010  *  PCI Local Bus Specification
0011  *  PCI to PCI Bridge Specification
0012  *  PCI System Design Guide
0013  */
0014 
0015 #ifndef BOOTLOADER_PCI_H
0016 #define BOOTLOADER_PCI_H
0017 
0018 #include <rtems/pci.h>
0019 
0020 
0021 /* Functions used to access pci configuration space */
0022 struct pci_bootloader_config_access_functions {
0023         int (*read_config_byte)(unsigned char, unsigned char,
0024                                unsigned char, uint8_t *);
0025         int (*read_config_word)(unsigned char, unsigned char,
0026                                unsigned char, uint16_t *);
0027         int (*read_config_dword)(unsigned char, unsigned char,
0028                                unsigned char, uint32_t *);
0029         int (*write_config_byte)(unsigned char, unsigned char,
0030                                unsigned char, uint8_t);
0031         int (*write_config_word)(unsigned char, unsigned char,
0032                                unsigned char, uint16_t);
0033         int (*write_config_dword)(unsigned char, unsigned char,
0034                                unsigned char, uint32_t);
0035 };
0036 
0037 /*
0038  * There is one pci_dev structure for each slot-number/function-number
0039  * combination:
0040  */
0041 struct pci_dev {
0042     struct pci_bus  *bus;       /* bus this device is on */
0043     struct pci_dev  *sibling;   /* next device on this bus */
0044     struct pci_dev  *next;      /* chain of all devices */
0045 
0046     void        *sysdata;   /* hook for sys-specific extension */
0047     struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
0048 
0049     unsigned int    devfn;      /* encoded device & function index */
0050     unsigned short  vendor;
0051     unsigned short  device;
0052     unsigned int    class;      /* 3 bytes: (base,sub,prog-if) */
0053     unsigned int    hdr_type;   /* PCI header type */
0054     unsigned int    master : 1; /* set if device is master capable */
0055     /*
0056      * In theory, the irq level can be read from configuration
0057      * space and all would be fine.  However, old PCI chips don't
0058      * support these registers and return 0 instead.  For example,
0059      * the Vision864-P rev 0 chip can uses INTA, but returns 0 in
0060      * the interrupt line and pin registers.  pci_init()
0061      * initializes this field with the value at PCI_INTERRUPT_LINE
0062      * and it is the job of pcibios_fixup() to change it if
0063      * necessary.  The field must not be 0 unless the device
0064      * cannot generate interrupts at all.
0065      */
0066     unsigned int    irq;        /* irq generated by this device */
0067 
0068     /* Base registers for this device, can be adjusted by
0069      * pcibios_fixup() as necessary.
0070      */
0071     unsigned long   base_address[6];
0072     unsigned long   rom_address;
0073 };
0074 
0075 struct pci_bus {
0076     struct pci_bus  *parent;    /* parent bus this bridge is on */
0077     struct pci_bus  *children;  /* chain of P2P bridges on this bus */
0078     struct pci_bus  *next;      /* chain of all PCI buses */
0079 
0080     struct pci_dev  *self;      /* bridge device as seen by parent */
0081     struct pci_dev  *devices;   /* devices behind this bridge */
0082 
0083     void        *sysdata;   /* hook for sys-specific extension */
0084     struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
0085 
0086     unsigned char   number;     /* bus number */
0087     unsigned char   primary;    /* number of primary bridge */
0088     unsigned char   secondary;  /* number of secondary bridge */
0089     unsigned char   subordinate;    /* max number of subordinate buses */
0090 };
0091 
0092 extern struct pci_bus   pci_root;   /* root bus */
0093 extern struct pci_dev   *pci_devices;   /* list of all devices */
0094 
0095 #endif /* BOOTLOADER_PCI_H */