iPXE
isapnp.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * isapnp.c -- Etherboot isapnp support for the 3Com 3c515
4 * Written 2002-2003 by Timothy Legge <tlegge@rogers.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Portions of this code:
22 * Copyright (C) 2001 P.J.H.Fox (fox@roestock.demon.co.uk)
23 *
24 *
25 * REVISION HISTORY:
26 * ================
27 * Version 0.1 April 26, 2002 TJL
28 * Version 0.2 01/08/2003 TJL Moved outside the 3c515.c driver file
29 * Version 0.3 Sept 23, 2003 timlegge Change delay to currticks
30 *
31 *
32 * Generalised into an ISAPnP bus that can be used by more than just
33 * the 3c515 by Michael Brown <mbrown@fensystems.co.uk>
34 *
35 ***************************************************************************/
36 
37 /** @file
38  *
39  * ISAPnP bus support
40  *
41  * Etherboot orignally gained ISAPnP support in a very limited way for
42  * the 3c515 NIC. The current implementation is almost a complete
43  * rewrite based on the ISAPnP specification, with passing reference
44  * to the Linux ISAPnP code.
45  *
46  * There can be only one ISAPnP bus in a system. Once the read port
47  * is known and all cards have been allocated CSNs, there's nothing to
48  * be gained by re-scanning for cards.
49  *
50  * External code (e.g. the ISAPnP ROM prefix) may already know the
51  * read port address, in which case it can store it in
52  * #isapnp_read_port. Note that setting the read port address in this
53  * way will prevent further isolation from taking place; you should
54  * set the read port address only if you know that devices have
55  * already been allocated CSNs.
56  *
57  */
58 
59 FILE_LICENCE ( GPL2_OR_LATER );
60 
61 #include <stdint.h>
62 #include <stdlib.h>
63 #include <string.h>
64 #include <stdio.h>
65 #include <errno.h>
66 #include <ipxe/io.h>
67 #include <unistd.h>
68 #include <ipxe/isapnp.h>
69 
70 /**
71  * ISAPnP Read Port address.
72  *
73  * ROM prefix may be able to set this address, which is why this is
74  * non-static.
75  */
77 
78 static void isapnpbus_remove ( struct root_device *rootdev );
79 
80 /*
81  * ISAPnP utility functions
82  *
83  */
84 
85 #define ISAPNP_CARD_ID_FMT "ID %04x:%04x (\"%s\") serial %x"
86 #define ISAPNP_CARD_ID_DATA(identifier) \
87  (identifier)->vendor_id, (identifier)->prod_id, \
88  isa_id_string ( (identifier)->vendor_id, (identifier)->prod_id ), \
89  (identifier)->serial
90 #define ISAPNP_DEV_ID_FMT "ID %04x:%04x (\"%s\")"
91 #define ISAPNP_DEV_ID_DATA(isapnp) \
92  (isapnp)->vendor_id, (isapnp)->prod_id, \
93  isa_id_string ( (isapnp)->vendor_id, (isapnp)->prod_id )
94 
95 static inline void isapnp_write_address ( unsigned int address ) {
97 }
98 
99 static inline void isapnp_write_data ( unsigned int data ) {
101 }
102 
103 static inline unsigned int isapnp_read_data ( void ) {
104  return inb ( isapnp_read_port );
105 }
106 
107 static inline void isapnp_write_byte ( unsigned int address,
108  unsigned int value ) {
111 }
112 
113 static inline unsigned int isapnp_read_byte ( unsigned int address ) {
115  return isapnp_read_data ();
116 }
117 
118 static inline unsigned int isapnp_read_word ( unsigned int address ) {
119  /* Yes, they're in big-endian order */
120  return ( ( isapnp_read_byte ( address ) << 8 )
121  | isapnp_read_byte ( address + 1 ) );
122 }
123 
124 /** Inform cards of a new read port address */
125 static inline void isapnp_set_read_port ( void ) {
127 }
128 
129 /**
130  * Enter the Isolation state.
131  *
132  * Only cards currently in the Sleep state will respond to this
133  * command.
134  */
135 static inline void isapnp_serialisolation ( void ) {
137 }
138 
139 /**
140  * Enter the Wait for Key state.
141  *
142  * All cards will respond to this command, regardless of their current
143  * state.
144  */
145 static inline void isapnp_wait_for_key ( void ) {
147 }
148 
149 /**
150  * Reset (i.e. remove) Card Select Number.
151  *
152  * Only cards currently in the Sleep state will respond to this
153  * command.
154  */
155 static inline void isapnp_reset_csn ( void ) {
157 }
158 
159 /**
160  * Place a specified card into the Config state.
161  *
162  * @v csn Card Select Number
163  * @ret None -
164  * @err None -
165  *
166  * Only cards currently in the Sleep, Isolation, or Config states will
167  * respond to this command. The card that has the specified CSN will
168  * enter the Config state, all other cards will enter the Sleep state.
169  */
170 static inline void isapnp_wake ( uint8_t csn ) {
172 }
173 
174 static inline unsigned int isapnp_read_resourcedata ( void ) {
176 }
177 
178 static inline unsigned int isapnp_read_status ( void ) {
179  return isapnp_read_byte ( ISAPNP_STATUS );
180 }
181 
182 /**
183  * Assign a Card Select Number to a card, and enter the Config state.
184  *
185  * @v csn Card Select Number
186  *
187  * Only cards in the Isolation state will respond to this command.
188  * The isolation protocol is designed so that only one card will
189  * remain in the Isolation state by the time the isolation protocol
190  * completes.
191  */
192 static inline void isapnp_write_csn ( unsigned int csn ) {
194 }
195 
196 static inline void isapnp_logicaldevice ( unsigned int logdev ) {
198 }
199 
200 static inline void isapnp_activate ( unsigned int logdev ) {
201  isapnp_logicaldevice ( logdev );
203 }
204 
205 static inline void isapnp_deactivate ( unsigned int logdev ) {
206  isapnp_logicaldevice ( logdev );
208 }
209 
210 static inline unsigned int isapnp_read_iobase ( unsigned int index ) {
211  return isapnp_read_word ( ISAPNP_IOBASE ( index ) );
212 }
213 
214 static inline unsigned int isapnp_read_irqno ( unsigned int index ) {
215  return isapnp_read_byte ( ISAPNP_IRQNO ( index ) );
216 }
217 
218 static void isapnp_delay ( void ) {
219  udelay ( 1000 );
220 }
221 
222 /**
223  * Linear feedback shift register.
224  *
225  * @v lfsr Current value of the LFSR
226  * @v input_bit Current input bit to the LFSR
227  * @ret lfsr Next value of the LFSR
228  *
229  * This routine implements the linear feedback shift register as
230  * described in Appendix B of the PnP ISA spec. The hardware
231  * implementation uses eight D-type latches and two XOR gates. I
232  * think this is probably the smallest possible implementation in
233  * software. Six instructions when input_bit is a constant 0 (for
234  * isapnp_send_key). :)
235  */
236 static inline unsigned int isapnp_lfsr_next ( unsigned int lfsr,
237  unsigned int input_bit ) {
238  register uint8_t lfsr_next;
239 
240  lfsr_next = lfsr >> 1;
241  lfsr_next |= ( ( ( lfsr ^ lfsr_next ) ^ input_bit ) ) << 7;
242  return lfsr_next;
243 }
244 
245 /**
246  * Send the ISAPnP initiation key.
247  *
248  * Sending the key causes all ISAPnP cards that are currently in the
249  * Wait for Key state to transition into the Sleep state.
250  */
251 static void isapnp_send_key ( void ) {
252  unsigned int i;
253  unsigned int lfsr;
254 
255  isapnp_delay();
256  isapnp_write_address ( 0x00 );
257  isapnp_write_address ( 0x00 );
258 
259  lfsr = ISAPNP_LFSR_SEED;
260  for ( i = 0 ; i < 32 ; i++ ) {
261  isapnp_write_address ( lfsr );
262  lfsr = isapnp_lfsr_next ( lfsr, 0 );
263  }
264 }
265 
266 /**
267  * Compute ISAPnP identifier checksum
268  *
269  * @v identifier ISAPnP identifier
270  * @ret checksum Expected checksum value
271  */
272 static unsigned int isapnp_checksum ( struct isapnp_identifier *identifier ) {
273  unsigned int i, j;
274  unsigned int lfsr;
275  unsigned int byte;
276 
277  lfsr = ISAPNP_LFSR_SEED;
278  for ( i = 0 ; i < 8 ; i++ ) {
279  byte = * ( ( ( uint8_t * ) identifier ) + i );
280  for ( j = 0 ; j < 8 ; j++ ) {
281  lfsr = isapnp_lfsr_next ( lfsr, byte );
282  byte >>= 1;
283  }
284  }
285  return lfsr;
286 }
287 
288 /*
289  * Read a byte of resource data from the current location
290  *
291  * @ret byte Byte of resource data
292  */
293 static inline unsigned int isapnp_peek_byte ( void ) {
294  unsigned int i;
295 
296  /* Wait for data to be ready */
297  for ( i = 0 ; i < 20 ; i++ ) {
298  if ( isapnp_read_status() & 0x01 ) {
299  /* Byte ready - read it */
300  return isapnp_read_resourcedata();
301  }
302  isapnp_delay();
303  }
304  /* Data never became ready - return 0xff */
305  return 0xff;
306 }
307 
308 /**
309  * Read resource data.
310  *
311  * @v buf Buffer in which to store data, or NULL
312  * @v bytes Number of bytes to read
313  *
314  * Resource data is read from the current location. If #buf is NULL,
315  * the data is discarded.
316  */
317 static void isapnp_peek ( void *buf, size_t len ) {
318  unsigned int i;
319  unsigned int byte;
320 
321  for ( i = 0 ; i < len ; i++) {
322  byte = isapnp_peek_byte();
323  if ( buf )
324  * ( ( uint8_t * ) buf + i ) = byte;
325  }
326 }
327 
328 /**
329  * Find a tag within the resource data.
330  *
331  * @v wanted_tag The tag that we're looking for
332  * @v buf Buffer in which to store the tag's contents
333  * @v len Length of buffer
334  * @ret rc Return status code
335  *
336  * Scan through the resource data until we find a particular tag, and
337  * read its contents into a buffer.
338  */
339 static int isapnp_find_tag ( unsigned int wanted_tag, void *buf, size_t len ) {
340  unsigned int tag;
341  unsigned int tag_len;
342 
343  DBG2 ( "ISAPnP read tag" );
344  do {
345  tag = isapnp_peek_byte();
346  if ( ISAPNP_IS_SMALL_TAG ( tag ) ) {
347  tag_len = ISAPNP_SMALL_TAG_LEN ( tag );
349  } else {
350  tag_len = ( isapnp_peek_byte() +
351  ( isapnp_peek_byte() << 8 ) );
353  }
354  DBG2 ( " %02x (%02x)", tag, tag_len );
355  if ( tag == wanted_tag ) {
356  if ( len > tag_len )
357  len = tag_len;
358  isapnp_peek ( buf, len );
359  DBG2 ( "\n" );
360  return 0;
361  } else {
362  isapnp_peek ( NULL, tag_len );
363  }
364  } while ( tag != ISAPNP_TAG_END );
365  DBG2 ( "\n" );
366  return -ENOENT;
367 }
368 
369 /**
370  * Find specified Logical Device ID tag
371  *
372  * @v logdev Logical device ID
373  * @v logdevid Logical device ID structure to fill in
374  * @ret rc Return status code
375  */
376 static int isapnp_find_logdevid ( unsigned int logdev,
377  struct isapnp_logdevid *logdevid ) {
378  unsigned int i;
379  int rc;
380 
381  for ( i = 0 ; i <= logdev ; i++ ) {
382  if ( ( rc = isapnp_find_tag ( ISAPNP_TAG_LOGDEVID, logdevid,
383  sizeof ( *logdevid ) ) ) != 0 )
384  return rc;
385  }
386  return 0;
387 }
388 
389 /**
390  * Try isolating ISAPnP cards at the current read port.
391  *
392  * @ret >0 Number of ISAPnP cards found
393  * @ret 0 There are no ISAPnP cards in the system
394  * @ret <0 A conflict was detected; try a new read port
395  * @err None -
396  *
397  * The state diagram on page 18 (PDF page 24) of the PnP ISA spec
398  * gives the best overview of what happens here.
399  */
400 static int isapnp_try_isolate ( void ) {
401  struct isapnp_identifier identifier;
402  unsigned int i, j;
403  unsigned int seen_55aa, seen_life;
404  unsigned int csn = 0;
405  unsigned int data;
406  unsigned int byte;
407 
408  DBG ( "ISAPnP attempting isolation at read port %04x\n",
410 
411  /* Place all cards into the Sleep state, whatever state
412  * they're currently in.
413  */
415  isapnp_send_key();
416 
417  /* Reset all assigned CSNs */
419  isapnp_delay();
420  isapnp_delay();
421 
422  /* Place all cards into the Isolation state */
424  isapnp_send_key();
425  isapnp_wake ( 0x00 );
426 
427  /* Set the read port */
429  isapnp_delay();
430 
431  while ( 1 ) {
432 
433  /* All cards that do not have assigned CSNs are
434  * currently in the Isolation state, each time we go
435  * through this loop.
436  */
437 
438  /* Initiate serial isolation */
440  isapnp_delay();
441 
442  /* Read identifier serially via the ISAPnP read port. */
443  memset ( &identifier, 0, sizeof ( identifier ) );
444  seen_55aa = seen_life = 0;
445  for ( i = 0 ; i < 9 ; i++ ) {
446  byte = 0;
447  for ( j = 0 ; j < 8 ; j++ ) {
449  isapnp_delay();
450  data = ( ( data << 8 ) | isapnp_read_data() );
451  isapnp_delay();
452  byte >>= 1;
453  if ( data != 0xffff ) {
454  seen_life++;
455  if ( data == 0x55aa ) {
456  byte |= 0x80;
457  seen_55aa++;
458  }
459  }
460  }
461  *( ( ( uint8_t * ) &identifier ) + i ) = byte;
462  }
463 
464  /* If we didn't see any 55aa patterns, stop here */
465  if ( ! seen_55aa ) {
466  if ( csn ) {
467  DBG ( "ISAPnP found no more cards\n" );
468  } else {
469  if ( seen_life ) {
470  DBG ( "ISAPnP saw life but no cards, "
471  "trying new read port\n" );
472  csn = -1;
473  } else {
474  DBG ( "ISAPnP saw no signs of life, "
475  "abandoning isolation\n" );
476  }
477  }
478  break;
479  }
480 
481  /* If the checksum was invalid stop here */
482  if ( identifier.checksum != isapnp_checksum ( &identifier) ) {
483  DBG ( "ISAPnP found malformed card "
484  ISAPNP_CARD_ID_FMT "\n with checksum %02x "
485  "(should be %02x), trying new read port\n",
486  ISAPNP_CARD_ID_DATA ( &identifier ),
487  identifier.checksum,
488  isapnp_checksum ( &identifier) );
489  csn = -1;
490  break;
491  }
492 
493  /* Give the device a CSN */
494  csn++;
495  DBG ( "ISAPnP found card " ISAPNP_CARD_ID_FMT
496  ", assigning CSN %02x\n",
497  ISAPNP_CARD_ID_DATA ( &identifier ), csn );
498 
499  isapnp_write_csn ( csn );
500  isapnp_delay();
501 
502  /* Send this card back to Sleep and force all cards
503  * without a CSN into Isolation state
504  */
505  isapnp_wake ( 0x00 );
506  isapnp_delay();
507  }
508 
509  /* Place all cards in Wait for Key state */
511 
512  /* Return number of cards found */
513  if ( csn > 0 ) {
514  DBG ( "ISAPnP found %d cards at read port %04x\n",
515  csn, isapnp_read_port );
516  }
517  return csn;
518 }
519 
520 /**
521  * Find a valid read port and isolate all ISAPnP cards.
522  *
523  */
524 static void isapnp_isolate ( void ) {
528  /* Avoid problematic locations such as the NE2000
529  * probe space
530  */
531  if ( ( isapnp_read_port >= 0x280 ) &&
532  ( isapnp_read_port <= 0x380 ) )
533  continue;
534 
535  /* If we detect any ISAPnP cards at this location, stop */
536  if ( isapnp_try_isolate() >= 0 )
537  return;
538  }
539 }
540 
541 /**
542  * Activate or deactivate an ISAPnP device.
543  *
544  * @v isapnp ISAPnP device
545  * @v activation True to enable, False to disable the device
546  * @ret None -
547  * @err None -
548  *
549  * This routine simply activates the device in its current
550  * configuration, or deactivates the device. It does not attempt any
551  * kind of resource arbitration.
552  *
553  */
555  int activation ) {
556  /* Wake the card and select the logical device */
558  isapnp_send_key ();
559  isapnp_wake ( isapnp->csn );
560  isapnp_logicaldevice ( isapnp->logdev );
561 
562  /* Activate/deactivate the logical device */
563  isapnp_activate ( activation );
564  isapnp_delay();
565 
566  /* Return all cards to Wait for Key state */
568 
569  DBG ( "ISAPnP %s device %02x:%02x\n",
570  ( activation ? "activated" : "deactivated" ),
571  isapnp->csn, isapnp->logdev );
572 }
573 
574 /**
575  * Probe an ISAPnP device
576  *
577  * @v isapnp ISAPnP device
578  * @ret rc Return status code
579  *
580  * Searches for a driver for the ISAPnP device. If a driver is found,
581  * its probe() routine is called.
582  */
583 static int isapnp_probe ( struct isapnp_device *isapnp ) {
584  struct isapnp_driver *driver;
585  struct isapnp_device_id *id;
586  unsigned int i;
587  int rc;
588 
589  DBG ( "Adding ISAPnP device %02x:%02x (%04x:%04x (\"%s\") "
590  "io %x irq %d)\n", isapnp->csn, isapnp->logdev,
591  isapnp->vendor_id, isapnp->prod_id,
592  isa_id_string ( isapnp->vendor_id, isapnp->prod_id ),
593  isapnp->ioaddr, isapnp->irqno );
594 
596  for ( i = 0 ; i < driver->id_count ; i++ ) {
597  id = &driver->ids[i];
598  if ( id->vendor_id != isapnp->vendor_id )
599  continue;
600  if ( ISA_PROD_ID ( id->prod_id ) !=
601  ISA_PROD_ID ( isapnp->prod_id ) )
602  continue;
603  isapnp->driver = driver;
604  isapnp->dev.driver_name = id->name;
605  DBG ( "...using driver %s\n", isapnp->dev.driver_name );
606  if ( ( rc = driver->probe ( isapnp, id ) ) != 0 ) {
607  DBG ( "......probe failed\n" );
608  continue;
609  }
610  return 0;
611  }
612  }
613 
614  DBG ( "...no driver found\n" );
615  return -ENOTTY;
616 }
617 
618 /**
619  * Remove an ISAPnP device
620  *
621  * @v isapnp ISAPnP device
622  */
623 static void isapnp_remove ( struct isapnp_device *isapnp ) {
624  isapnp->driver->remove ( isapnp );
625  DBG ( "Removed ISAPnP device %02x:%02x\n",
626  isapnp->csn, isapnp->logdev );
627 }
628 
629 /**
630  * Probe ISAPnP root bus
631  *
632  * @v rootdev ISAPnP bus root device
633  *
634  * Scans the ISAPnP bus for devices and registers all devices it can
635  * find.
636  */
637 static int isapnpbus_probe ( struct root_device *rootdev ) {
638  struct isapnp_device *isapnp = NULL;
639  struct isapnp_identifier identifier;
640  struct isapnp_logdevid logdevid;
641  unsigned int csn;
642  unsigned int logdev;
643  int rc;
644 
645  /* Perform isolation if it hasn't yet been done */
646  if ( ! isapnp_read_port )
647  isapnp_isolate();
648 
649  for ( csn = 1 ; csn <= 0xff ; csn++ ) {
650  for ( logdev = 0 ; logdev <= 0xff ; logdev++ ) {
651 
652  /* Allocate struct isapnp_device */
653  if ( ! isapnp )
654  isapnp = malloc ( sizeof ( *isapnp ) );
655  if ( ! isapnp ) {
656  rc = -ENOMEM;
657  goto err;
658  }
659  memset ( isapnp, 0, sizeof ( *isapnp ) );
660  isapnp->csn = csn;
661  isapnp->logdev = logdev;
662 
663  /* Wake the card */
665  isapnp_send_key();
666  isapnp_wake ( csn );
667 
668  /* Read the card identifier */
669  isapnp_peek ( &identifier, sizeof ( identifier ) );
670 
671  /* No card with this CSN; stop here */
672  if ( identifier.vendor_id & 0x80 )
673  goto done;
674 
675  /* Find the Logical Device ID tag */
676  if ( ( rc = isapnp_find_logdevid ( logdev,
677  &logdevid ) ) != 0){
678  /* No more logical devices; go to next CSN */
679  break;
680  }
681 
682  /* Select the logical device */
683  isapnp_logicaldevice ( logdev );
684 
685  /* Populate struct isapnp_device */
686  isapnp->vendor_id = logdevid.vendor_id;
687  isapnp->prod_id = logdevid.prod_id;
688  isapnp->ioaddr = isapnp_read_iobase ( 0 );
689  isapnp->irqno = isapnp_read_irqno ( 0 );
690 
691  /* Return all cards to Wait for Key state */
693 
694  /* Add to device hierarchy */
695  snprintf ( isapnp->dev.name,
696  sizeof ( isapnp->dev.name ),
697  "ISAPnP%02x:%02x", csn, logdev );
698  isapnp->dev.desc.bus_type = BUS_TYPE_ISAPNP;
699  isapnp->dev.desc.vendor = isapnp->vendor_id;
700  isapnp->dev.desc.device = isapnp->prod_id;
701  isapnp->dev.desc.ioaddr = isapnp->ioaddr;
702  isapnp->dev.desc.irq = isapnp->irqno;
703  isapnp->dev.parent = &rootdev->dev;
704  list_add ( &isapnp->dev.siblings,
705  &rootdev->dev.children );
706  INIT_LIST_HEAD ( &isapnp->dev.children );
707 
708  /* Look for a driver */
709  if ( isapnp_probe ( isapnp ) == 0 ) {
710  /* isapnpdev registered, we can drop our ref */
711  isapnp = NULL;
712  } else {
713  /* Not registered; re-use struct */
714  list_del ( &isapnp->dev.siblings );
715  }
716  }
717  }
718 
719  done:
720  free ( isapnp );
721  return 0;
722 
723  err:
724  free ( isapnp );
725  isapnpbus_remove ( rootdev );
726  return rc;
727 }
728 
729 /**
730  * Remove ISAPnP root bus
731  *
732  * @v rootdev ISAPnP bus root device
733  */
734 static void isapnpbus_remove ( struct root_device *rootdev ) {
735  struct isapnp_device *isapnp;
736  struct isapnp_device *tmp;
737 
738  list_for_each_entry_safe ( isapnp, tmp, &rootdev->dev.children,
739  dev.siblings ) {
740  isapnp_remove ( isapnp );
741  list_del ( &isapnp->dev.siblings );
742  free ( isapnp );
743  }
744 }
745 
746 /** ISAPnP bus root device driver */
749  .remove = isapnpbus_remove,
750 };
751 
752 /** ISAPnP bus root device */
753 struct root_device isapnp_root_device __root_device = {
754  .dev = { .name = "ISAPnP" },
755  .driver = &isapnp_root_driver,
756 };
#define ISAPNP_READPORT
Definition: isapnp.h:79
struct device dev
Generic device.
Definition: isapnp.h:185
int(* probe)(struct isapnp_device *isapnp, const struct isapnp_device_id *id)
Probe device.
Definition: isapnp.h:221
iPXE I/O API
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
unsigned int id_count
Number of entries in ISAPnP ID table.
Definition: isapnp.h:213
struct root_device isapnp_root_device __root_device
ISAPnP bus root device.
Definition: isapnp.c:753
#define ISAPNP_WRITE_DATA
Definition: isapnp.h:58
static unsigned int isapnp_read_iobase(unsigned int index)
Definition: isapnp.c:210
static unsigned int isapnp_peek_byte(void)
Definition: isapnp.c:293
static void isapnp_wake(uint8_t csn)
Place a specified card into the Config state.
Definition: isapnp.c:170
An ISAPnP driver.
Definition: isapnp.h:209
static void isapnp_write_address(unsigned int address)
Definition: isapnp.c:95
static struct root_driver isapnp_root_driver
ISAPnP bus root device driver.
Definition: isapnp.c:747
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:187
Error codes.
An ISAPnP device ID list entry.
Definition: isapnp.h:173
static void isapnp_write_byte(unsigned int address, unsigned int value)
Definition: isapnp.c:107
#define ISAPNP_TAG_END
Definition: isapnp.h:122
uint64_t address
Base address.
Definition: ena.h:24
unsigned long ioaddr
I/O address.
Definition: device.h:37
void(* remove)(struct isapnp_device *isapnp)
Remove device.
Definition: isapnp.h:228
uint16_t prod_id
Product ID.
Definition: isapnp.h:167
An ISAPnP logical device ID structure.
Definition: isapnp.h:163
#define ISAPNP_CONFIGCONTROL
Definition: isapnp.h:81
#define ISAPNP_SMALL_TAG_NAME(tag)
Definition: isapnp.h:106
#define ISAPNP_CARD_ID_DATA(identifier)
Definition: isapnp.c:86
#define ISAPNP_TAG_LOGDEVID
Definition: isapnp.h:109
char name[40]
Name.
Definition: device.h:75
#define ENOENT
No such file or directory.
Definition: errno.h:514
A root device.
Definition: device.h:94
static int isapnp_probe(struct isapnp_device *isapnp)
Probe an ISAPnP device.
Definition: isapnp.c:583
uint16_t ioaddr
I/O address.
Definition: isapnp.h:191
#define ISAPNP_CONFIG_RESET_CSN
Definition: isapnp.h:96
struct device dev
Device chain.
Definition: device.h:99
char * isa_id_string(unsigned int vendor, unsigned int product)
Definition: isa_ids.c:11
unsigned int vendor
Vendor ID.
Definition: device.h:31
struct device * parent
Bus device.
Definition: device.h:85
struct isapnp_device_id * ids
ISAPnP ID table.
Definition: isapnp.h:211
static unsigned int isapnp_read_status(void)
Definition: isapnp.c:178
#define ISAPNP_READ_PORT_MAX
Definition: isapnp.h:65
static unsigned int isapnp_read_resourcedata(void)
Definition: isapnp.c:174
unsigned long tmp
Definition: linux_pci.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
uint16_t prod_id
Product ID.
Definition: isapnp.h:189
#define ISAPNP_CARD_ID_FMT
Definition: isapnp.c:85
#define ISAPNP_LOGICALDEVICENUMBER
Definition: isapnp.h:86
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:153
static int isapnpbus_probe(struct root_device *rootdev)
Probe ISAPnP root bus.
Definition: isapnp.c:637
#define ISAPNP_SMALL_TAG_LEN(tag)
Definition: isapnp.h:107
static void isapnp_set_read_port(void)
Inform cards of a new read port address.
Definition: isapnp.c:125
#define ISAPNP_LARGE_TAG_NAME(tag)
Definition: isapnp.h:125
#define ISAPNP_ACTIVATE
Definition: isapnp.h:87
unsigned int irq
IRQ.
Definition: device.h:39
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
struct isapnp_driver * driver
Driver for this device.
Definition: isapnp.h:199
#define ISAPNP_ADDRESS
Definition: isapnp.h:57
static int isapnp_try_isolate(void)
Try isolating ISAPnP cards at the current read port.
Definition: isapnp.c:400
#define ISAPNP_STATUS
Definition: isapnp.h:84
static void isapnpbus_remove(struct root_device *rootdev)
Remove ISAPnP root bus.
Definition: isapnp.c:734
#define ISAPNP_IS_SMALL_TAG(tag)
Definition: isapnp.h:105
#define ISAPNP_READ_PORT_START
Definition: isapnp.h:60
const char * driver_name
Driver name.
Definition: device.h:77
void isapnp_device_activation(struct isapnp_device *isapnp, int activation)
Activate or deactivate an ISAPnP device.
Definition: isapnp.c:554
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
static void isapnp_deactivate(unsigned int logdev)
Definition: isapnp.c:205
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static void isapnp_reset_csn(void)
Reset (i.e.
Definition: isapnp.c:155
#define ISAPNP_WAKE
Definition: isapnp.h:82
static unsigned int isapnp_read_data(void)
Definition: isapnp.c:103
static unsigned int isapnp_read_word(unsigned int address)
Definition: isapnp.c:118
An ISAPnP device.
Definition: isapnp.h:183
uint8_t id
Request identifier.
Definition: ena.h:12
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void isapnp_delay(void)
Definition: isapnp.c:218
struct list_head siblings
Devices on the same bus.
Definition: device.h:81
static void isapnp_write_data(unsigned int data)
Definition: isapnp.c:99
uint16_t isapnp_read_port
ISAPnP Read Port address.
Definition: isapnp.c:76
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
#define ISAPNP_IOBASE(n)
Definition: isapnp.h:89
A root device driver.
Definition: device.h:107
static void isapnp_isolate(void)
Find a valid read port and isolate all ISAPnP cards.
Definition: isapnp.c:524
unsigned char uint8_t
Definition: stdint.h:10
#define ISAPNP_DRIVERS
ISAPnP driver table.
Definition: isapnp.h:232
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
#define ISAPNP_RESOURCEDATA
Definition: isapnp.h:83
int(* probe)(struct root_device *rootdev)
Add root device.
Definition: device.h:116
#define ISAPNP_READ_PORT_STEP
Definition: isapnp.h:66
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
static void isapnp_peek(void *buf, size_t len)
Read resource data.
Definition: isapnp.c:317
static int isapnp_find_logdevid(unsigned int logdev, struct isapnp_logdevid *logdevid)
Find specified Logical Device ID tag.
Definition: isapnp.c:376
unsigned char byte
Definition: smc9000.h:38
uint8_t irqno
Interrupt number.
Definition: isapnp.h:193
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
uint16_t vendor_id
Vendor ID.
Definition: isapnp.h:165
#define ISA_PROD_ID(product)
Definition: isa_ids.h:45
#define outb(data, io_addr)
Definition: io.h:309
unsigned int bus_type
Bus type.
Definition: device.h:24
#define ISAPNP_CARDSELECTNUMBER
Definition: isapnp.h:85
static int isapnp_find_tag(unsigned int wanted_tag, void *buf, size_t len)
Find a tag within the resource data.
Definition: isapnp.c:339
uint32_t len
Length.
Definition: ena.h:14
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
static void isapnp_logicaldevice(unsigned int logdev)
Definition: isapnp.c:196
unsigned int device
Device ID.
Definition: device.h:33
static void isapnp_write_csn(unsigned int csn)
Assign a Card Select Number to a card, and enter the Config state.
Definition: isapnp.c:192
struct list_head children
Devices attached to this device.
Definition: device.h:83
static void isapnp_serialisolation(void)
Enter the Isolation state.
Definition: isapnp.c:135
static void isapnp_wait_for_key(void)
Enter the Wait for Key state.
Definition: isapnp.c:145
static void isapnp_remove(struct isapnp_device *isapnp)
Remove an ISAPnP device.
Definition: isapnp.c:623
#define ISAPNP_SERIALISOLATION
Definition: isapnp.h:80
An ISAPnP serial identifier.
Definition: isapnp.h:151
uint8_t data[48]
Additional event data.
Definition: ena.h:22
struct device_description desc
Device description.
Definition: device.h:79
static unsigned int isapnp_checksum(struct isapnp_identifier *identifier)
Compute ISAPnP identifier checksum.
Definition: isapnp.c:272
static unsigned int isapnp_read_byte(unsigned int address)
Definition: isapnp.c:113
#define ISAPNP_IRQNO(n)
Definition: isapnp.h:90
static void isapnp_send_key(void)
Send the ISAPnP initiation key.
Definition: isapnp.c:251
#define ISAPNP_LFSR_SEED
Definition: isapnp.h:102
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
uint8_t csn
Card Select Number.
Definition: isapnp.h:195
uint8_t logdev
Logical Device ID.
Definition: isapnp.h:197
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
static void isapnp_activate(unsigned int logdev)
Definition: isapnp.c:200
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static unsigned int isapnp_read_irqno(unsigned int index)
Definition: isapnp.c:214
uint64_t tag
Identity tag.
Definition: edd.h:30
#define ISAPNP_CONFIG_WAIT_FOR_KEY
Definition: isapnp.h:95
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
struct bofm_section_header done
Definition: bofm_test.c:46
#define DBG2(...)
Definition: compiler.h:515
static unsigned int isapnp_lfsr_next(unsigned int lfsr, unsigned int input_bit)
Linear feedback shift register.
Definition: isapnp.c:236
#define BUS_TYPE_ISAPNP
ISAPnP bus type.
Definition: device.h:46
uint8_t checksum
Checksum.
Definition: isapnp.h:159
FILE_LICENCE(GPL2_OR_LATER)
void * memset(void *dest, int character, size_t len) __nonnull