diff options
| author | Michael Brown | 2007-03-10 19:08:33 +0100 |
|---|---|---|
| committer | Michael Brown | 2007-03-10 19:08:33 +0100 |
| commit | 520d9c36af2f9e4f207dd7275a47ea97c668f749 (patch) | |
| tree | fc665c3d4c250d3c9411219f580f5affbbf03873 /src/include | |
| parent | Start a new release notes file (RELNOTES) in preparation for release (diff) | |
| download | ipxe-520d9c36af2f9e4f207dd7275a47ea97c668f749.tar.gz ipxe-520d9c36af2f9e4f207dd7275a47ea97c668f749.tar.xz ipxe-520d9c36af2f9e4f207dd7275a47ea97c668f749.zip | |
Updated ISAPnP, EISA, MCA and ISA buses to current device model.
ISA 3c509 is currently non-functional, although the EISA (3c509-eisa) and
MCA (3c529) variants should build OK.
None of this code is yet tested.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/eisa.h | 95 | ||||
| -rw-r--r-- | src/include/gpxe/device.h | 45 | ||||
| -rw-r--r-- | src/include/gpxe/eisa.h | 125 | ||||
| -rw-r--r-- | src/include/gpxe/isa.h | 92 | ||||
| -rw-r--r-- | src/include/gpxe/isa_ids.h (renamed from src/include/isa_ids.h) | 22 | ||||
| -rw-r--r-- | src/include/gpxe/isapnp.h (renamed from src/include/isapnp.h) | 150 | ||||
| -rw-r--r-- | src/include/gpxe/mca.h | 103 | ||||
| -rw-r--r-- | src/include/isa.h | 85 | ||||
| -rw-r--r-- | src/include/mca.h | 88 | ||||
| -rw-r--r-- | src/include/nic.h | 257 |
10 files changed, 670 insertions, 392 deletions
diff --git a/src/include/eisa.h b/src/include/eisa.h deleted file mode 100644 index 403a133f4..000000000 --- a/src/include/eisa.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef EISA_H -#define EISA_H - -#include "stdint.h" -#include "isa_ids.h" -#include "nic.h" - -/* - * EISA constants - * - */ - -#define EISA_MIN_SLOT (0x1) -#define EISA_MAX_SLOT (0xf) /* Must be 2^n - 1 */ -#define EISA_SLOT_BASE( n ) ( 0x1000 * (n) ) - -#define EISA_MFG_ID_HI ( 0xc80 ) -#define EISA_MFG_ID_LO ( 0xc81 ) -#define EISA_PROD_ID_HI ( 0xc82 ) -#define EISA_PROD_ID_LO ( 0xc83 ) -#define EISA_GLOBAL_CONFIG ( 0xc84 ) - -#define EISA_CMD_RESET ( 1 << 2 ) -#define EISA_CMD_ENABLE ( 1 << 0 ) - -/* - * A location on an EISA bus - * - */ -struct eisa_loc { - unsigned int slot; -}; - -/* - * A physical EISA device - * - */ -struct eisa_device { - const char *name; - unsigned int slot; - uint16_t ioaddr; - uint16_t mfg_id; - uint16_t prod_id; -}; - -/* - * An individual EISA device identified by ID - * - */ -struct eisa_id { - const char *name; - uint16_t mfg_id, prod_id; -}; - -/* - * An EISA driver, with a device ID (struct eisa_id) table. - * - */ -struct eisa_driver { - const char *name; - struct eisa_id *ids; - unsigned int id_count; -}; - -/* - * Define an EISA driver - * - */ -#define EISA_DRIVER( _name, _ids ) \ - static struct eisa_driver _name = { \ - .ids = _ids, \ - .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ - } - -/* - * Functions in eisa.c - * - */ -extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled ); -extern void eisa_fill_nic ( struct nic *nic, struct eisa_device *eisa ); - -static inline void enable_eisa_device ( struct eisa_device *eisa ) { - eisa_device_enabled ( eisa, 1 ); -} -static inline void disable_eisa_device ( struct eisa_device *eisa ) { - eisa_device_enabled ( eisa, 0 ); -} - -/* - * EISA bus global definition - * - */ -extern struct bus_driver eisa_driver; - -#endif /* EISA_H */ diff --git a/src/include/gpxe/device.h b/src/include/gpxe/device.h index 139fb78b5..f88a2da5a 100644 --- a/src/include/gpxe/device.h +++ b/src/include/gpxe/device.h @@ -11,18 +11,18 @@ #include <gpxe/list.h> #include <gpxe/tables.h> -/** A PCI device description */ -struct pci_device_description { +/** A hardware device description */ +struct device_description { /** Bus type * - * Must be @c BUS_TYPE_PCI. + * This must be a BUS_TYPE_XXX constant. */ unsigned int bus_type; - /** Bus:dev.fn address + /** Location * - * As constructed by PCI_BUSDEVFN(). + * The interpretation of this field is bus-type-specific. */ - unsigned int busdevfn; + unsigned int location; /** Vendor ID */ unsigned int vendor; /** Device ID */ @@ -32,37 +32,24 @@ struct pci_device_description { /** PCI bus type */ #define BUS_TYPE_PCI 1 -/** An ISAPnP device description */ -struct isapnp_device_description { - /** Bus type - * - * Must be @c BUS_TYPE_ISAPNP. - */ - unsigned int bus_type; -}; - -/** PCI bus type */ +/** ISAPnP bus type */ #define BUS_TYPE_ISAPNP 2 -/** A hardware device description */ -union device_description { - /** Bus type - * - * This must be a BUS_TYPE_XXX constant. - */ - unsigned int bus_type; - /** PCI device description */ - struct pci_device_description pci; - /** ISAPnP device description */ - struct isapnp_device_description isapnp; -}; +/** EISA bus type */ +#define BUS_TYPE_EISA 3 + +/** MCA bus type */ +#define BUS_TYPE_MCA 4 + +/** ISA bus type */ +#define BUS_TYPE_ISA 5 /** A hardware device */ struct device { /** Name */ char name[16]; /** Device description */ - union device_description desc; + struct device_description desc; /** Devices on the same bus */ struct list_head siblings; /** Devices attached to this device */ diff --git a/src/include/gpxe/eisa.h b/src/include/gpxe/eisa.h new file mode 100644 index 000000000..e9d890e16 --- /dev/null +++ b/src/include/gpxe/eisa.h @@ -0,0 +1,125 @@ +#ifndef EISA_H +#define EISA_H + +#include <stdint.h> +#include <gpxe/isa_ids.h> +#include <gpxe/device.h> +#include <gpxe/tables.h> + +/* + * EISA constants + * + */ + +#define EISA_MIN_SLOT (0x1) +#define EISA_MAX_SLOT (0xf) /* Must be 2^n - 1 */ +#define EISA_SLOT_BASE( n ) ( 0x1000 * (n) ) + +#define EISA_VENDOR_ID ( 0xc80 ) +#define EISA_PROD_ID ( 0xc82 ) +#define EISA_GLOBAL_CONFIG ( 0xc84 ) + +#define EISA_CMD_RESET ( 1 << 2 ) +#define EISA_CMD_ENABLE ( 1 << 0 ) + +/** An EISA device ID list entry */ +struct eisa_device_id { + /** Name */ + const char *name; + /** Manufacturer ID */ + uint16_t vendor_id; + /** Product ID */ + uint16_t prod_id; +}; + +/** An EISA device */ +struct eisa_device { + /** Generic device */ + struct device dev; + /** Slot number */ + unsigned int slot; + /** I/O address */ + uint16_t ioaddr; + /** Manufacturer ID */ + uint16_t vendor_id; + /** Product ID */ + uint16_t prod_id; + /** Driver for this device */ + struct eisa_driver *driver; + /** Driver-private data + * + * Use eisa_set_drvdata() and eisa_get_drvdata() to access + * this field. + */ + void *priv; + /** Driver name */ + const char *driver_name; +}; + +/** An EISA driver */ +struct eisa_driver { + /** EISA ID table */ + struct eisa_device_id *ids; + /** Number of entries in EISA ID table */ + unsigned int id_count; + /** + * Probe device + * + * @v eisa EISA device + * @v id Matching entry in ID table + * @ret rc Return status code + */ + int ( * probe ) ( struct eisa_device *eisa, + const struct eisa_device_id *id ); + /** + * Remove device + * + * @v eisa EISA device + */ + void ( * remove ) ( struct eisa_device *eisa ); +}; + +/** Declare an EISA driver */ +#define __eisa_driver __table ( struct eisa_driver, eisa_drivers, 01 ) + +extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled ); + +/** + * Enable EISA device + * + * @v eisa EISA device + */ +static inline void enable_eisa_device ( struct eisa_device *eisa ) { + eisa_device_enabled ( eisa, 1 ); +} + +/** + * Disable EISA device + * + * @v eisa EISA device + */ +static inline void disable_eisa_device ( struct eisa_device *eisa ) { + eisa_device_enabled ( eisa, 0 ); +} + +/** + * Set EISA driver-private data + * + * @v eisa EISA device + * @v priv Private data + */ +static inline void eisa_set_drvdata ( struct eisa_device *eisa, void *priv ) { + eisa->priv = priv; +} + +/** + * Get EISA driver-private data + * + * @v eisa EISA device + * @ret priv Private data + */ +static inline void * eisa_get_drvdata ( struct eisa_device *eisa ) { + return eisa->priv; +} + +#endif /* EISA_H */ diff --git a/src/include/gpxe/isa.h b/src/include/gpxe/isa.h new file mode 100644 index 000000000..bb25dbce0 --- /dev/null +++ b/src/include/gpxe/isa.h @@ -0,0 +1,92 @@ +#ifndef ISA_H +#define ISA_H + +#include <stdint.h> +#include <gpxe/isa_ids.h> +#include <gpxe/device.h> +#include <gpxe/tables.h> + +/** An ISA device */ +struct isa_device { + /** Generic device */ + struct device dev; + /** I/O address */ + uint16_t ioaddr; + /** Driver for this device */ + struct isa_driver *driver; + /** Driver-private data + * + * Use isa_set_drvdata() and isa_get_drvdata() to access + * this field. + */ + void *priv; + /** Driver name */ + const char *driver_name; +}; + +/* + * An individual ISA device, identified by probe address + * + */ +typedef uint16_t isa_probe_addr_t; + +/** An ISA driver */ +struct isa_driver { + /** Name */ + const char *name; + /** Probe address list */ + isa_probe_addr_t *probe_addrs; + /** Number of entries in probe address list */ + unsigned int addr_count; + /** Manufacturer ID to be assumed for this device */ + uint16_t vendor_id; + /** Product ID to be assumed for this device */ + uint16_t prod_id; + /** + * Probe device + * + * @v isa ISA device + * @v id Matching entry in ID table + * @ret rc Return status code + */ + int ( * probe ) ( struct isa_device *isa ); + /** + * Remove device + * + * @v isa ISA device + */ + void ( * remove ) ( struct isa_device *isa ); +}; + +/** Declare an ISA driver */ +#define __isa_driver __table ( struct isa_driver, isa_drivers, 01 ) + +/** + * Set ISA driver-private data + * + * @v isa ISA device + * @v priv Private data + */ +static inline void isa_set_drvdata ( struct isa_device *isa, void *priv ) { + isa->priv = priv; +} + +/** + * Get ISA driver-private data + * + * @v isa ISA device + * @ret priv Private data + */ +static inline void * isa_get_drvdata ( struct isa_device *isa ) { + return isa->priv; +} + +/* + * ISA_ROM is parsed by parserom.pl to generate Makefile rules and + * files for rom-o-matic. + * + */ +#define ISA_ROM( IMAGE, DESCRIPTION ) + +#endif /* ISA_H */ + diff --git a/src/include/isa_ids.h b/src/include/gpxe/isa_ids.h index 7d77f0d86..bf3f1015a 100644 --- a/src/include/isa_ids.h +++ b/src/include/gpxe/isa_ids.h @@ -15,23 +15,25 @@ * byte 1 bits 7-4 third hex digit of product number * bits 3-0 hex digit of revision level * + * ISA IDs are always expressed in little-endian order, even though + * the underlying "meaning" is big-endian. */ -#include "stdint.h" - -#define ISA_BUS_TYPE 2 +#include <byteswap.h> /* * Construct a vendor ID from three ASCII characters * */ -#define ISA_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\ - ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\ - ((((c)-'A'+1)&0x1f)<<8)) -#define ISAPNP_VENDOR(a,b,c) ISA_VENDOR(a,b,c) -#define EISA_VENDOR(a,b,c) ISA_VENDOR(a,b,c) +#define ISA_VENDOR( a, b, c ) \ + bswap_16 ( ( ( ( (a) - 'A' + 1 ) & 0x1f ) << 10 ) | \ + ( ( ( (b) - 'A' + 1 ) & 0x1f ) << 5 ) | \ + ( ( ( (c) - 'A' + 1 ) & 0x1f ) << 0 ) ) + +#define ISAPNP_VENDOR( a, b, c ) ISA_VENDOR ( a, b, c ) +#define EISA_VENDOR( a, b, c ) ISA_VENDOR ( a, b, c ) -#define GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR('P','N','P') +#define GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR ( 'P','N','P' ) /* * Extract product ID and revision from combined product field @@ -42,6 +44,6 @@ #define ISA_PROD_REV(product) ( ( (product) & ~ISA_PROD_ID_MASK ) >> 8 ) /* Functions in isa_ids.c */ -extern char * isa_id_string ( uint16_t vendor, uint16_t product ); +extern char * isa_id_string ( unsigned int vendor, unsigned int product ); #endif /* ISA_IDS_H */ diff --git a/src/include/isapnp.h b/src/include/gpxe/isapnp.h index 476b26f82..72ce0a6fe 100644 --- a/src/include/isapnp.h +++ b/src/include/gpxe/isapnp.h @@ -36,9 +36,10 @@ #ifndef ISAPNP_H #define ISAPNP_H -#include "stdint.h" -#include "nic.h" -#include "isa_ids.h" +#include <stdint.h> +#include <gpxe/isa_ids.h> +#include <gpxe/device.h> +#include <gpxe/tables.h> /* * ISAPnP constants @@ -134,103 +135,134 @@ #define ISAPNP_TAG_RSVDLONGF 0xFF #define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100 -/* - * An ISAPnP serial identifier - * - */ +/** An ISAPnP serial identifier */ struct isapnp_identifier { + /** Vendor ID */ uint16_t vendor_id; + /** Product ID */ uint16_t prod_id; + /** Serial number */ uint32_t serial; + /** Checksum */ uint8_t checksum; } __attribute__ (( packed )); -/* - * An ISAPnP logical device ID structure - * - */ +/** An ISAPnP logical device ID structure */ struct isapnp_logdevid { + /** Vendor ID */ uint16_t vendor_id; + /** Product ID */ uint16_t prod_id; + /** Flags */ uint16_t flags; } __attribute__ (( packed )); -/* - * A location on an ISAPnP bus - * - */ -struct isapnp_loc { - uint8_t csn; - uint8_t logdev; +/** An ISAPnP device ID list entry */ +struct isapnp_device_id { + /** Name */ + const char *name; + /** Vendor ID */ + uint16_t vendor_id; + /** Product ID */ + uint16_t prod_id; }; -/* - * A physical ISAPnP device - * - */ +/** An ISAPnP device */ struct isapnp_device { - const char *name; - uint8_t csn; - uint8_t logdev; + /** Generic device */ + struct device dev; + /** Vendor ID */ uint16_t vendor_id; + /** Product ID */ uint16_t prod_id; + /** I/O address */ uint16_t ioaddr; + /** Interrupt number */ uint8_t irqno; + /** Card Select Number */ + uint8_t csn; + /** Logical Device ID */ + uint8_t logdev; + /** Driver for this device */ + struct isapnp_driver *driver; + /** Driver-private data + * + * Use isapnp_set_drvdata() and isapnp_get_drvdata() to access + * this field. + */ + void *priv; + /** Driver name */ + const char *driver_name; }; -/* - * An individual ISAPnP device identified by ID - * - */ -struct isapnp_id { - const char *name; - uint16_t vendor_id, prod_id; -}; - -/* - * An ISAPnP driver, with a device ID (struct isapnp_id) table. - * - */ +/** An ISAPnP driver */ struct isapnp_driver { - struct isapnp_id *ids; + /** ISAPnP ID table */ + struct isapnp_device_id *ids; + /** Number of entries in ISAPnP ID table */ unsigned int id_count; + /** + * Probe device + * + * @v isapnp ISAPnP device + * @v id Matching entry in ID table + * @ret rc Return status code + */ + int ( * probe ) ( struct isapnp_device *isapnp, + const struct isapnp_device_id *id ); + /** + * Remove device + * + * @v isapnp ISAPnP device + */ + void ( * remove ) ( struct isapnp_device *isapnp ); }; -/* - * Define an ISAPnP driver - * - */ -#define ISAPNP_DRIVER( _name, _ids ) \ - static struct isapnp_driver _name = { \ - .ids = _ids, \ - .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ - } +/** Declare an ISAPnP driver */ +#define __isapnp_driver __table ( struct isapnp_driver, isapnp_drivers, 01 ) + +extern uint16_t isapnp_read_port; -/* - * Functions in isapnp.c - * - */ extern void isapnp_device_activation ( struct isapnp_device *isapnp, int activation ); -extern void isapnp_fill_nic ( struct nic *nic, struct isapnp_device *isapnp ); +/** + * Activate ISAPnP device + * + * @v isapnp ISAPnP device + */ static inline void activate_isapnp_device ( struct isapnp_device *isapnp ) { isapnp_device_activation ( isapnp, 1 ); } + +/** + * Deactivate ISAPnP device + * + * @v isapnp ISAPnP device + */ static inline void deactivate_isapnp_device ( struct isapnp_device *isapnp ) { isapnp_device_activation ( isapnp, 0 ); } -/* - * ISAPnP bus global definition +/** + * Set ISAPnP driver-private data * + * @v isapnp ISAPnP device + * @v priv Private data */ -extern struct bus_driver isapnp_driver; +static inline void isapnp_set_drvdata ( struct isapnp_device *isapnp, + void *priv ) { + isapnp->priv = priv; +} -/* - * ISAPnP read port. ROM prefix may be able to set this address. +/** + * Get ISAPnP driver-private data * + * @v isapnp ISAPnP device + * @ret priv Private data */ -extern uint16_t isapnp_read_port; +static inline void * isapnp_get_drvdata ( struct isapnp_device *isapnp ) { + return isapnp->priv; +} #endif /* ISAPNP_H */ diff --git a/src/include/gpxe/mca.h b/src/include/gpxe/mca.h new file mode 100644 index 000000000..21f9e74d7 --- /dev/null +++ b/src/include/gpxe/mca.h @@ -0,0 +1,103 @@ +/* + * MCA bus driver code + * + * Abstracted from 3c509.c. + * + */ + +#ifndef MCA_H +#define MCA_H + +#include <gpxe/isa_ids.h> +#include <gpxe/device.h> +#include <gpxe/tables.h> + +/* + * MCA constants + * + */ +#define MCA_MOTHERBOARD_SETUP_REG 0x94 +#define MCA_ADAPTER_SETUP_REG 0x96 +#define MCA_MAX_SLOT_NR 0x07 /* Must be 2^n - 1 */ +#define MCA_POS_REG(n) (0x100+(n)) + +/* Is there a standard that would define this? */ +#define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' ) + +/** An MCA device ID list entry */ +struct mca_device_id { + /** Name */ + const char *name; + /** Device ID */ + uint16_t id; +}; + +/** An MCA device */ +struct mca_device { + /** Generic device */ + struct device dev; + /** Slot number */ + unsigned int slot; + /** POS register values */ + unsigned char pos[8]; + /** Driver for this device */ + struct mca_driver *driver; + /** Driver-private data + * + * Use mca_set_drvdata() and mca_get_drvdata() to access + * this field. + */ + void *priv; + /** Driver name */ + const char *driver_name; +}; + +#define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] ) + +/** An MCA driver */ +struct mca_driver { + /** MCA ID table */ + struct mca_device_id *ids; + /** Number of entries in MCA ID table */ + unsigned int id_count; + /** + * Probe device + * + * @v mca MCA device + * @v id Matching entry in ID table + * @ret rc Return status code + */ + int ( * probe ) ( struct mca_device *mca, + const struct mca_device_id *id ); + /** + * Remove device + * + * @v mca MCA device + */ + void ( * remove ) ( struct mca_device *mca ); +}; + +/** Declare an MCA driver */ +#define __mca_driver __table ( struct mca_driver, mca_drivers, 01 ) + +/** + * Set MCA driver-private data + * + * @v mca MCA device + * @v priv Private data + */ +static inline void mca_set_drvdata ( struct mca_device *mca, void *priv ) { + mca->priv = priv; +} + +/** + * Get MCA driver-private data + * + * @v mca MCA device + * @ret priv Private data + */ +static inline void * mca_get_drvdata ( struct mca_device *mca ) { + return mca->priv; +} + +#endif diff --git a/src/include/isa.h b/src/include/isa.h deleted file mode 100644 index 372656176..000000000 --- a/src/include/isa.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef ISA_H -#define ISA_H - -#include "stdint.h" -#include "isa_ids.h" -#include "nic.h" - -/* - * A location on an ISA bus - * - */ -struct isa_driver; -struct isa_loc { - unsigned int driver; - unsigned int probe_idx; -}; - -/* - * A physical ISA device - * - */ -struct isa_device { - const char *name; - struct isa_driver *driver; - uint16_t ioaddr; - uint16_t mfg_id; - uint16_t prod_id; -}; - -/* - * An individual ISA device, identified by probe address - * - */ -typedef uint16_t isa_probe_addr_t; - -/* - * An ISA driver, with a probe address list and a probe_addr method. - * probe_addr() should return 1 if a card is physically present, - * leaving the other operations (read MAC address etc.) down to the - * main probe() routine. - * - */ -struct isa_driver { - const char *name; - isa_probe_addr_t *probe_addrs; - unsigned int addr_count; - int ( * probe_addr ) ( isa_probe_addr_t addr ); - uint16_t mfg_id; - uint16_t prod_id; -}; - -/* - * Define an ISA driver - * - */ -#define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id ) \ -struct isa_driver _name __table ( struct isa_driver, isa_driver, 01 ) = { \ - .probe_addrs = _probe_addrs, \ - .addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \ - .probe_addr = _probe_addr, \ - .mfg_id = _mfg_id, \ - .prod_id = _prod_id, \ -} - -/* - * ISA_ROM is parsed by parserom.pl to generate Makefile rules and - * files for rom-o-matic. - * - */ -#define ISA_ROM( IMAGE, DESCRIPTION ) - -/* - * Functions in isa.c - * - */ -extern void isa_fill_nic ( struct nic *nic, struct isa_device *isa ); - -/* - * ISA bus global definition - * - */ -extern struct bus_driver isa_driver; - -#endif /* ISA_H */ - diff --git a/src/include/mca.h b/src/include/mca.h deleted file mode 100644 index 31285580b..000000000 --- a/src/include/mca.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * MCA bus driver code - * - * Abstracted from 3c509.c. - * - */ - -#ifndef MCA_H -#define MCA_H - -#include "isa_ids.h" -#include "nic.h" - -#define MCA_BUS_TYPE 3 - -/* - * MCA constants - * - */ - -#define MCA_MOTHERBOARD_SETUP_REG 0x94 -#define MCA_ADAPTER_SETUP_REG 0x96 -#define MCA_MAX_SLOT_NR 0x07 /* Must be 2^n - 1 */ -#define MCA_POS_REG(n) (0x100+(n)) - -/* Is there a standard that would define this? */ -#define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' ) - -/* - * A location on an MCA bus - * - */ -struct mca_loc { - unsigned int slot; -}; - -/* - * A physical MCA device - * - */ -struct mca_device { - const char *name; - unsigned int slot; - unsigned char pos[8]; -}; -#define MCA_ID(mca) ( ( (mca)->pos[1] << 8 ) + (mca)->pos[0] ) - -/* - * An individual MCA device identified by ID - * - */ -struct mca_id { - const char *name; - int id; -}; - -/* - * An MCA driver, with a device ID (struct mca_id) table. - * - */ -struct mca_driver { - struct mca_id *ids; - unsigned int id_count; -}; - -/* - * Define an MCA driver - * - */ -#define MCA_DRIVER( _name, _ids ) \ - static struct mca_driver _name = { \ - .ids = _ids, \ - .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ - } - -/* - * Functions in mca.c - * - */ -extern void mca_fill_nic ( struct nic *nic, struct mca_device *mca ); - -/* - * MCA bus global definition - * - */ -extern struct bus_driver mca_driver; - -#endif diff --git a/src/include/nic.h b/src/include/nic.h index d1e2b77b6..0f4822529 100644 --- a/src/include/nic.h +++ b/src/include/nic.h @@ -8,8 +8,16 @@ #ifndef NIC_H #define NIC_H +#include <stdint.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> #include <byteswap.h> #include <gpxe/pci.h> +#include <gpxe/isapnp.h> +#include <gpxe/isa.h> +#include <gpxe/eisa.h> +#include <gpxe/mca.h> #include "dhcp.h" typedef enum { @@ -66,34 +74,231 @@ static inline void eth_transmit ( const char *dest, unsigned int type, */ extern int dummy_connect ( struct nic *nic ); extern void dummy_irq ( struct nic *nic, irq_action_t irq_action ); -extern int legacy_probe ( struct pci_device *pci, - const struct pci_device_id *id, - int ( * probe ) ( struct nic *nic, - struct pci_device *pci ), - void ( * disable ) ( struct nic *nic ) ); -extern void legacy_remove ( struct pci_device *pci, - void ( * disable ) ( struct nic *nic ) ); -extern void pci_fill_nic ( struct nic *nic, struct pci_device *pci ); - -#define PCI_DRIVER(_name,_ids,_class) \ - static int _name ## _legacy_probe ( struct pci_device *pci, \ - const struct pci_device_id *id ); \ - static void _name ## _legacy_remove ( struct pci_device *pci ); \ - struct pci_driver _name __pci_driver = { \ - .ids = _ids, \ - .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ - .probe = _name ## _legacy_probe, \ - .remove = _name ## _legacy_remove, \ - }; +extern int legacy_probe ( void *hwdev, + void ( * set_drvdata ) ( void *hwdev, void *priv ), + struct device *dev, + int ( * probe ) ( struct nic *nic, void *hwdev ), + void ( * disable ) ( struct nic *nic, void *hwdev )); +void legacy_remove ( void *hwdev, + void * ( * get_drvdata ) ( void *hwdev ), + void ( * disable ) ( struct nic *nic, void *hwdev ) ); + +#define PCI_DRIVER(_name,_ids,_class) \ + static inline int \ + _name ## _pci_legacy_probe ( struct pci_device *pci, \ + const struct pci_device_id *id ); \ + static inline void \ + _name ## _pci_legacy_remove ( struct pci_device *pci ); \ + struct pci_driver _name __pci_driver = { \ + .ids = _ids, \ + .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ + .probe = _name ## _pci_legacy_probe, \ + .remove = _name ## _pci_legacy_remove, \ + }; \ + REQUIRE_OBJECT ( pci ); + +static inline void legacy_pci_set_drvdata ( void *hwdev, void *priv ) { + pci_set_drvdata ( hwdev, priv ); +} +static inline void * legacy_pci_get_drvdata ( void *hwdev ) { + return pci_get_drvdata ( hwdev ); +} + +#define ISAPNP_DRIVER(_name,_ids) \ + static inline int \ + _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \ + const struct isapnp_device_id *id ); \ + static inline void \ + _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ); \ + struct isapnp_driver _name __isapnp_driver = { \ + .ids = _ids, \ + .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ + .probe = _name ## _isapnp_legacy_probe, \ + .remove = _name ## _isapnp_legacy_remove, \ + }; \ + REQUIRE_OBJECT ( isapnp ); + +static inline void legacy_isapnp_set_drvdata ( void *hwdev, void *priv ) { + isapnp_set_drvdata ( hwdev, priv ); +} +static inline void * legacy_isapnp_get_drvdata ( void *hwdev ) { + return isapnp_get_drvdata ( hwdev ); +} + +#define EISA_DRIVER(_name,_ids) \ + static inline int \ + _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \ + const struct eisa_device_id *id ); \ + static inline void \ + _name ## _eisa_legacy_remove ( struct eisa_device *eisa ); \ + struct eisa_driver _name __eisa_driver = { \ + .ids = _ids, \ + .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ + .probe = _name ## _eisa_legacy_probe, \ + .remove = _name ## _eisa_legacy_remove, \ + }; \ + REQUIRE_OBJECT ( eisa ); + +static inline void legacy_eisa_set_drvdata ( void *hwdev, void *priv ) { + eisa_set_drvdata ( hwdev, priv ); +} +static inline void * legacy_eisa_get_drvdata ( void *hwdev ) { + return eisa_get_drvdata ( hwdev ); +} + +#define MCA_DRIVER(_name,_ids) \ + static inline int \ + _name ## _mca_legacy_probe ( struct mca_device *mca, \ + const struct mca_device_id *id ); \ + static inline void \ + _name ## _mca_legacy_remove ( struct mca_device *mca ); \ + struct mca_driver _name __mca_driver = { \ + .ids = _ids, \ + .id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \ + .probe = _name ## _mca_legacy_probe, \ + .remove = _name ## _mca_legacy_remove, \ + }; \ + REQUIRE_OBJECT ( mca ); + +static inline void legacy_mca_set_drvdata ( void *hwdev, void *priv ) { + mca_set_drvdata ( hwdev, priv ); +} +static inline void * legacy_mca_get_drvdata ( void *hwdev ) { + return mca_get_drvdata ( hwdev ); +} + +#define ISA_DRIVER(_name,_probe_addrs,_probe_addr,_vendor_id,_prod_id) \ + static inline int \ + _name ## _isa_legacy_probe ( struct isa_device *isa ); \ + static inline int \ + _name ## _isa_legacy_probe_at_addr ( struct isa_device *isa ) { \ + if ( ! _probe_addr ( isa->ioaddr ) ) \ + return -ENODEV; \ + return _name ## _isa_legacy_probe ( isa ); \ + } \ + static inline void \ + _name ## _isa_legacy_remove ( struct isa_device *isa ); \ + static const char _name ## _text[]; \ + struct isa_driver _name __isa_driver = { \ + .name = _name ## _text, \ + .probe_addrs = _probe_addrs, \ + .addr_count = ( sizeof ( _probe_addrs ) / \ + sizeof ( _probe_addrs[0] ) ), \ + .vendor_id = _vendor_id, \ + .prod_id = _prod_id, \ + .probe = _name ## _isa_legacy_probe_at_addr, \ + .remove = _name ## _isa_legacy_remove, \ + }; \ + REQUIRE_OBJECT ( isa ); + +static inline void legacy_isa_set_drvdata ( void *hwdev, void *priv ) { + isa_set_drvdata ( hwdev, priv ); +} +static inline void * legacy_isa_get_drvdata ( void *hwdev ) { + return isa_get_drvdata ( hwdev ); +} #undef DRIVER -#define DRIVER(_unused1,_unused2,_unused3,_name,_probe,_disable) \ - static int _name ## _legacy_probe ( struct pci_device *pci, \ - const struct pci_device_id *id ) {\ - return legacy_probe ( pci, id, _probe, _disable ); \ - } \ - static void _name ## _legacy_remove ( struct pci_device *pci ) {\ - return legacy_remove ( pci, _disable ); \ +#define DRIVER(_name_text,_unused2,_unused3,_name,_probe,_disable) \ + static const char _name ## _text[] = _name_text; \ + static inline int \ + _name ## _probe ( struct nic *nic, void *hwdev ) { \ + return _probe ( nic, hwdev ); \ + } \ + static inline void \ + _name ## _disable ( struct nic *nic, void *hwdev ) { \ + void ( * _unsafe_disable ) () = _disable; \ + _unsafe_disable ( nic, hwdev ); \ + } \ + static inline int \ + _name ## _pci_legacy_probe ( struct pci_device *pci, \ + const struct pci_device_id *id __unused ) { \ + return legacy_probe ( pci, legacy_pci_set_drvdata, \ + &pci->dev, _name ## _probe, \ + _name ## _disable ); \ + } \ + static inline void \ + _name ## _pci_legacy_remove ( struct pci_device *pci ) { \ + return legacy_remove ( pci, legacy_pci_get_drvdata, \ + _name ## _disable ); \ + } \ + static inline int \ + _name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \ + const struct isapnp_device_id *id __unused ) { \ + return legacy_probe ( isapnp, legacy_isapnp_set_drvdata, \ + &isapnp->dev, _name ## _probe, \ + _name ## _disable ); \ + } \ + static inline void \ + _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ) { \ + return legacy_remove ( isapnp, legacy_isapnp_get_drvdata, \ + _name ## _disable ); \ + } \ + static inline int \ + _name ## _eisa_legacy_probe ( struct eisa_device *eisa, \ + const struct eisa_device_id *id __unused ) { \ + return legacy_probe ( eisa, legacy_eisa_set_drvdata, \ + &eisa->dev, _name ## _probe, \ + _name ## _disable ); \ + } \ + static inline void \ + _name ## _eisa_legacy_remove ( struct eisa_device *eisa ) { \ + return legacy_remove ( eisa, legacy_eisa_get_drvdata, \ + _name ## _disable ); \ + } \ + static inline int \ + _name ## _mca_legacy_probe ( struct mca_device *mca, \ + const struct mca_device_id *id __unused ) { \ + return legacy_probe ( mca, legacy_mca_set_drvdata, \ + &mca->dev, _name ## _probe, \ + _name ## _disable ); \ + } \ + static inline void \ + _name ## _mca_legacy_remove ( struct mca_device *mca ) { \ + return legacy_remove ( mca, legacy_mca_get_drvdata, \ + _name ## _disable ); \ + } \ + static inline int \ + _name ## _isa_legacy_probe ( struct isa_device *isa ) { \ + return legacy_probe ( isa, legacy_isa_set_drvdata, \ + &isa->dev, _name ## _probe, \ + _name ## _disable ); \ + } \ + static inline void \ + _name ## _isa_legacy_remove ( struct isa_device *isa ) { \ + return legacy_remove ( isa, legacy_isa_get_drvdata, \ + _name ## _disable ); \ } +static inline void pci_fill_nic ( struct nic *nic, struct pci_device *pci ) { + nic->ioaddr = pci->ioaddr; + nic->irqno = pci->irq; +} + +static inline void isapnp_fill_nic ( struct nic *nic, + struct isapnp_device *isapnp ) { + nic->ioaddr = isapnp->ioaddr; + nic->irqno = isapnp->irqno; +} + +static inline void eisa_fill_nic ( struct nic *nic, + struct eisa_device *eisa ) { + nic->ioaddr = eisa->ioaddr; + nic->irqno = 0; +} + +static inline void mca_fill_nic ( struct nic *nic, + struct mca_device *mca __unused ) { + /* ioaddr and irqno must be read in a device-dependent way + * from the POS registers + */ + nic->ioaddr = 0; + nic->irqno = 0; +} + +static inline void isa_fill_nic ( struct nic *nic, struct isa_device *isa ) { + nic->ioaddr = isa->ioaddr; + nic->irqno = 0; +} + #endif /* NIC_H */ |
