diff options
| author | Michael Brown | 2005-04-13 14:01:44 +0200 |
|---|---|---|
| committer | Michael Brown | 2005-04-13 14:01:44 +0200 |
| commit | 9711f50e204c6e918a983e9dbfa864fd006acb01 (patch) | |
| tree | b1bab7a3a7040ee3c4e27670a13586140b0c494d | |
| parent | Add MCA devices (diff) | |
| download | ipxe-9711f50e204c6e918a983e9dbfa864fd006acb01.tar.gz ipxe-9711f50e204c6e918a983e9dbfa864fd006acb01.tar.xz ipxe-9711f50e204c6e918a983e9dbfa864fd006acb01.zip | |
Created separate isa_ids.h file and a utility function to print out ISA
IDs in a human-readable format.
| -rw-r--r-- | src/drivers/bus/isa_ids.c | 24 | ||||
| -rw-r--r-- | src/include/isa.h | 8 | ||||
| -rw-r--r-- | src/include/isa_ids.h | 44 | ||||
| -rw-r--r-- | src/include/mca.h | 4 |
4 files changed, 72 insertions, 8 deletions
diff --git a/src/drivers/bus/isa_ids.c b/src/drivers/bus/isa_ids.c new file mode 100644 index 000000000..f7be1129c --- /dev/null +++ b/src/drivers/bus/isa_ids.c @@ -0,0 +1,24 @@ +#include "etherboot.h" +#include "isa_ids.h" + +/* + * EISA and ISAPnP IDs are actually mildly human readable, though in a + * somewhat brain-damaged way. + * + */ +char * isa_id_string ( uint16_t vendor, uint16_t product ) { + static unsigned char buf[7]; + int i; + + /* Vendor ID is a compressed ASCII string */ + vendor = htons ( vendor ); + for ( i = 2 ; i >= 0 ; i-- ) { + buf[i] = ( 'A' - 1 + ( vendor & 0x1f ) ); + vendor >>= 5; + } + + /* Product ID is a 4-digit hex string */ + sprintf ( &buf[3], "%hx", htons ( product ) ); + + return buf; +} diff --git a/src/include/isa.h b/src/include/isa.h index 23a8f2ffa..fe5c557bc 100644 --- a/src/include/isa.h +++ b/src/include/isa.h @@ -1,13 +1,9 @@ #ifndef ISA_H #define ISA_H -struct dev; - -#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\ - ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\ - ((((c)-'A'+1)&0x1f)<<8)) +#include "isa_ids.h" -#define GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR('P','N','P') +struct dev; struct isa_driver { diff --git a/src/include/isa_ids.h b/src/include/isa_ids.h new file mode 100644 index 000000000..0eaa3da12 --- /dev/null +++ b/src/include/isa_ids.h @@ -0,0 +1,44 @@ +#ifndef ISA_IDS_H +#define ISA_IDS_H + +/* + * This file defines IDs as used by ISAPnP and EISA devices. These + * IDs have the format: + * + * vendor byte 0 bit 7 must be zero + * bits 6-2 first vendor char in compressed ASCII + * bits 1-0 second vendor char in compressed ASCII (bits 4-3) + * byte 1 bits 7-5 second vendor char in compressed ASCII (bits 2-0) + * bits 4-0 third vendor char in compressed ASCII + * product byte 0 bits 7-4 first hex digit of product number + * bits 3-0 second hex digit of product number + * byte 1 bits 7-4 third hex digit of product number + * bits 3-0 hex digit of revision level + * + */ + +#include "stdint.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 GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR('P','N','P') + +/* + * Extract product ID and revision from combined product field + * + */ +#define ISA_PROD_ID(product) ( (product) & 0xf0ff ) +#define ISA_PROD_REV(product) ( ( (product) & 0x0f00 ) >> 8 ) + +/* Functions in isa_ids.c */ +extern char * isa_id_string ( uint16_t vendor, uint16_t product ); + +#endif /* ISA_IDS_H */ diff --git a/src/include/mca.h b/src/include/mca.h index f6d37ba79..e69b65601 100644 --- a/src/include/mca.h +++ b/src/include/mca.h @@ -19,8 +19,8 @@ #define MCA_POS_REG(n) (0x100+(n)) /* Is there a standard that would define this? */ -#include "isa.h" -#define GENERIC_MCA_VENDOR ISAPNP_VENDOR ( 'M', 'C', 'A' ) +#include "isa_ids.h" +#define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' ) /* * A physical MCA device |
