Quellcode durchsuchen

Created separate isa_ids.h file and a utility function to print out ISA

IDs in a human-readable format.
tags/v0.9.3
Michael Brown vor 19 Jahren
Ursprung
Commit
9711f50e20
4 geänderte Dateien mit 72 neuen und 8 gelöschten Zeilen
  1. 24
    0
      src/drivers/bus/isa_ids.c
  2. 2
    6
      src/include/isa.h
  3. 44
    0
      src/include/isa_ids.h
  4. 2
    2
      src/include/mca.h

+ 24
- 0
src/drivers/bus/isa_ids.c Datei anzeigen

@@ -0,0 +1,24 @@
1
+#include "etherboot.h"
2
+#include "isa_ids.h"
3
+
4
+/* 
5
+ * EISA and ISAPnP IDs are actually mildly human readable, though in a
6
+ * somewhat brain-damaged way.
7
+ *
8
+ */
9
+char * isa_id_string ( uint16_t vendor, uint16_t product ) {
10
+	static unsigned char buf[7];
11
+	int i;
12
+
13
+	/* Vendor ID is a compressed ASCII string */
14
+	vendor = htons ( vendor );
15
+	for ( i = 2 ; i >= 0 ; i-- ) {
16
+		buf[i] = ( 'A' - 1 + ( vendor & 0x1f ) );
17
+		vendor >>= 5;
18
+	}
19
+	
20
+	/* Product ID is a 4-digit hex string */
21
+	sprintf ( &buf[3], "%hx", htons ( product ) );
22
+
23
+	return buf;
24
+}

+ 2
- 6
src/include/isa.h Datei anzeigen

@@ -1,13 +1,9 @@
1 1
 #ifndef	ISA_H
2 2
 #define ISA_H
3 3
 
4
-struct dev;
5
-
6
-#define ISAPNP_VENDOR(a,b,c)	(((((a)-'A'+1)&0x3f)<<2)|\
7
-				((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
8
-				((((c)-'A'+1)&0x1f)<<8))
4
+#include "isa_ids.h"
9 5
 
10
-#define	GENERIC_ISAPNP_VENDOR	ISAPNP_VENDOR('P','N','P')
6
+struct dev;
11 7
 
12 8
 struct isa_driver
13 9
 {

+ 44
- 0
src/include/isa_ids.h Datei anzeigen

@@ -0,0 +1,44 @@
1
+#ifndef ISA_IDS_H
2
+#define ISA_IDS_H
3
+
4
+/* 
5
+ * This file defines IDs as used by ISAPnP and EISA devices.  These
6
+ * IDs have the format:
7
+ *
8
+ * vendor  byte 0 bit  7    must be zero
9
+ *		  bits 6-2  first vendor char in compressed ASCII
10
+ *		  bits 1-0  second vendor char in compressed ASCII (bits 4-3)
11
+ *	   byte 1 bits 7-5  second vendor char in compressed ASCII (bits 2-0)
12
+ *                bits 4-0  third vendor char in compressed ASCII
13
+ * product byte 0 bits 7-4  first hex digit of product number
14
+ *		  bits 3-0  second hex digit of product number
15
+ *	   byte 1 bits 7-4  third hex digit of product number
16
+ *		  bits 3-0  hex digit of revision level
17
+ *
18
+ */
19
+
20
+#include "stdint.h"
21
+
22
+/*
23
+ * Construct a vendor ID from three ASCII characters
24
+ *
25
+ */
26
+#define ISA_VENDOR(a,b,c)	(((((a)-'A'+1)&0x3f)<<2)|\
27
+				((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
28
+				((((c)-'A'+1)&0x1f)<<8))
29
+#define ISAPNP_VENDOR(a,b,c)	ISA_VENDOR(a,b,c)
30
+#define EISA_VENDOR(a,b,c)	ISA_VENDOR(a,b,c)
31
+
32
+#define	GENERIC_ISAPNP_VENDOR	ISAPNP_VENDOR('P','N','P')
33
+
34
+/*
35
+ * Extract product ID and revision from combined product field
36
+ *
37
+ */
38
+#define ISA_PROD_ID(product)	( (product) & 0xf0ff )
39
+#define ISA_PROD_REV(product)	( ( (product) & 0x0f00 ) >> 8 )
40
+
41
+/* Functions in isa_ids.c */
42
+extern char * isa_id_string ( uint16_t vendor, uint16_t product );
43
+
44
+#endif /* ISA_IDS_H */

+ 2
- 2
src/include/mca.h Datei anzeigen

@@ -19,8 +19,8 @@
19 19
 #define MCA_POS_REG(n)			(0x100+(n))
20 20
 
21 21
 /* Is there a standard that would define this? */
22
-#include "isa.h"
23
-#define GENERIC_MCA_VENDOR ISAPNP_VENDOR ( 'M', 'C', 'A' )
22
+#include "isa_ids.h"
23
+#define GENERIC_MCA_VENDOR ISA_VENDOR ( 'M', 'C', 'A' )
24 24
 
25 25
 /*
26 26
  * A physical MCA device

Laden…
Abbrechen
Speichern