浏览代码

Read current ioaddr and irqno from PnP registers.

tags/v0.9.3
Michael Brown 19 年前
父节点
当前提交
888277d2d1
共有 2 个文件被更改,包括 33 次插入2 次删除
  1. 28
    2
      src/drivers/bus/isapnp.c
  2. 5
    0
      src/include/isapnp.h

+ 28
- 2
src/drivers/bus/isapnp.c 查看文件

@@ -87,6 +87,12 @@ static inline uint8_t isapnp_read_byte ( uint8_t address ) {
87 87
 	return isapnp_read_data ();
88 88
 }
89 89
 
90
+static inline uint16_t isapnp_read_word ( uint8_t address ) {
91
+	/* Yes, they're in big-endian order */
92
+	return ( ( isapnp_read_byte ( address ) << 8 )
93
+		 + isapnp_read_byte ( address + 1 ) );
94
+}
95
+
90 96
 static inline void isapnp_set_read_port ( void ) {
91 97
 	isapnp_write_byte ( ISAPNP_READPORT, isapnp_read_port >> 2 );
92 98
 }
@@ -133,6 +139,14 @@ static inline void isapnp_deactivate ( uint8_t logdev ) {
133 139
 	isapnp_write_byte ( ISAPNP_ACTIVATE, 0 );
134 140
 }
135 141
 
142
+static inline uint16_t isapnp_read_iobase ( unsigned int index ) {
143
+	return isapnp_read_word ( ISAPNP_IOBASE ( index ) );
144
+}
145
+
146
+static inline uint8_t isapnp_read_irqno ( unsigned int index ) {
147
+	return isapnp_read_byte ( ISAPNP_IRQNO ( index ) );
148
+}
149
+
136 150
 static void isapnp_delay ( void ) {
137 151
 	udelay ( 1000 );
138 152
 }
@@ -388,6 +402,13 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
388 402
 	isapnp->vendor_id = identifier.vendor_id;
389 403
 	isapnp->prod_id = identifier.prod_id;
390 404
 
405
+	/* I/O addresses and IRQs are associated with logical devices,
406
+	 * not with cards.  They will be assigned when
407
+	 * activate_isapnp_device() is called.
408
+	 */
409
+	isapnp->ioaddr = 0;
410
+	isapnp->irqno = 0;
411
+
391 412
 	/* Return all cards to Wait for Key state */
392 413
 	isapnp_wait_for_key ();
393 414
 
@@ -471,7 +492,8 @@ int find_isapnp_boot_device ( struct dev *dev, struct isapnp_driver *driver ) {
471 492
 }
472 493
 
473 494
 /*
474
- * Activate a logical function on an ISAPnP device
495
+ * Activate a logical function on an ISAPnP device, and fill in the
496
+ * ioaddr and irqno fields in the isapnp struct.
475 497
  *
476 498
  * This routine simply activates the device in its current
477 499
  * configuration.  It does not attempt any kind of resource
@@ -488,6 +510,10 @@ void activate_isapnp_device ( struct isapnp_device *isapnp,
488 510
 	/* Select the specified logical device */
489 511
 	isapnp_activate ( logdev );
490 512
 	isapnp_delay();
513
+
514
+	/* Read the current ioaddr and irqno */
515
+	isapnp->ioaddr = isapnp_read_iobase ( 0 );
516
+	isapnp->irqno = isapnp_read_irqno ( 0 );
491 517
 	
492 518
 	/* Return all cards to Wait for Key state */
493 519
 	isapnp_wait_for_key ();
@@ -498,7 +524,7 @@ void activate_isapnp_device ( struct isapnp_device *isapnp,
498 524
  *
499 525
  */
500 526
 void deactivate_isapnp_device ( struct isapnp_device *isapnp,
501
-			      uint8_t logdev ) {
527
+				uint8_t logdev ) {
502 528
 	/* Wake the device */
503 529
 	isapnp_wait_for_key ();
504 530
 	isapnp_send_key ();

+ 5
- 0
src/include/isapnp.h 查看文件

@@ -66,6 +66,9 @@
66 66
 #define ISAPNP_LOGICALDEVICENUMBER	0x07
67 67
 #define ISAPNP_ACTIVATE			0x30
68 68
 #define ISAPNP_IORANGECHECK		0x31
69
+#define ISAPNP_IOBASE(n)		( 0x60 + ( (n) * 2 ) )
70
+#define ISAPNP_IRQNO(n)			( 0x70 + ( (n) * 2 ) )
71
+#define ISAPNP_IRQTYPE(n)		( 0x71 + ( (n) * 2 ) )
69 72
 
70 73
 /* Bits in the CONFIGCONTROL register */
71 74
 #define ISAPNP_CONFIG_RESET		( 1 << 0 )
@@ -143,6 +146,8 @@ struct isapnp_device {
143 146
 	unsigned char csn;
144 147
 	uint16_t vendor_id;
145 148
 	uint16_t prod_id;
149
+	uint16_t ioaddr;
150
+	uint8_t irqno;
146 151
 	int already_tried;
147 152
 };
148 153
 

正在加载...
取消
保存