mirror of
https://github.com/ipxe/ipxe
synced 2026-04-04 03:00:20 +03:00
Use the magic of common symbols to allow struct dev to effectively grow at
link time to accommodate whatever bus objects are included.
This commit is contained in:
@@ -3,11 +3,6 @@
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/* Bus types */
|
||||
#include "pci.h"
|
||||
#include "eisa.h"
|
||||
#include "mca.h"
|
||||
|
||||
/* Device types */
|
||||
#include "nic.h"
|
||||
|
||||
@@ -18,8 +13,7 @@ struct dev_id {
|
||||
uint8_t bus_type;
|
||||
#define PCI_BUS_TYPE 1
|
||||
#define ISA_BUS_TYPE 2
|
||||
#define EISA_BUS_TYPE 3
|
||||
#define MCA_BUS_TYPE 4
|
||||
#define MCA_BUS_TYPE 3
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Dont use sizeof, that will include the padding */
|
||||
@@ -29,18 +23,25 @@ struct dev {
|
||||
struct dev_operations *dev_op;
|
||||
const char *name;
|
||||
struct dev_id devid; /* device ID string (sent to DHCP server) */
|
||||
/* All possible bus types */
|
||||
union {
|
||||
struct pci_device pci;
|
||||
struct eisa_device eisa;
|
||||
struct mca_device mca;
|
||||
};
|
||||
/* Pointer to bus information for device. Whatever sets up
|
||||
* the struct dev must make sure that this points to a buffer
|
||||
* large enough for the required struct <bus>_device.
|
||||
*/
|
||||
void *bus;
|
||||
/* All possible device types */
|
||||
union {
|
||||
struct nic nic;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Macro to help create a common symbol with enough space for any
|
||||
* struct <bus>_device.
|
||||
*
|
||||
* Use as e.g. DEV_BUS(struct pci_device);
|
||||
*/
|
||||
#define DEV_BUS(datatype,symbol) datatype symbol __asm__ ( "_dev_bus" );
|
||||
|
||||
struct dev_operations {
|
||||
void ( *disable ) ( struct dev * );
|
||||
void ( *print_info ) ( struct dev * );
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
struct dev;
|
||||
struct eisa_device {
|
||||
char *magic; /* must be first */
|
||||
struct dev *dev;
|
||||
unsigned int slot;
|
||||
uint16_t ioaddr;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
struct dev;
|
||||
struct mca_device {
|
||||
char *magic; /* must be first */
|
||||
struct dev *dev;
|
||||
unsigned int slot;
|
||||
unsigned char pos[8];
|
||||
|
||||
@@ -232,13 +232,13 @@
|
||||
#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
|
||||
#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
|
||||
#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
|
||||
|
||||
/*
|
||||
* A physical PCI device
|
||||
*
|
||||
*/
|
||||
struct dev;
|
||||
struct pci_device {
|
||||
char * magic; /* must be first */
|
||||
struct dev * dev;
|
||||
uint32_t membase; /* BAR 1 */
|
||||
uint32_t ioaddr; /* first IO BAR */
|
||||
|
||||
Reference in New Issue
Block a user