root/arch/sparc/prom/devtree.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. prom_build_devtree
  2. prom_find_dev_on_bus
  3. prom_find_next_dev

   1 /* devtree.c: Build a copy of the prom device tree in kernel
   2  *            memory for easier access and cleaner interface.
   3  *
   4  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <asm/openprom.h>
   8 #include <asm/oplib.h>
   9 
  10 /* Add more as appropriate. */
  11 enum bus_t {
  12         OBIO_BUS,
  13         SBUS_BUS,
  14         PCI_BUS,
  15         PMEM_BUS,
  16         CPU_BUS,
  17 };
  18 
  19 struct sdevmapping {
  20         unsigned long physpage;
  21         int mapsz;
  22         enum bus_t where;
  23 };
  24 
  25 /* limitation of sparc arch. */
  26 #define NUM_SPARC_IRQS    15
  27 
  28 struct sdev_irqs {
  29         int level;
  30         int vector; /* For vme/sbus irq sharing methinks. */
  31 };
  32 
  33 struct sparcdev {
  34         struct sparcdev *next;
  35         struct sparcdev *prev;
  36         int node;
  37         char *name;
  38         int num_mappings;
  39         struct sdevmapping *maps;
  40         int num_irqs;
  41         struct sdev_irqs irqinfo[NUM_SPARC_IRQS];
  42 };
  43 
  44 struct sparcbus {
  45         struct sparcbus *next;
  46         enum bus_t type;
  47         struct sparcdev *device_list;
  48 };
  49 
  50 /* Add more as appropriate. */
  51 struct sparcbus obiobus_info = { 0, OBIO_BUS, { 0, 0}, };
  52 struct sparcbus sbusbus_info = { 0, SBUS_BUS, { 0, 0}, };
  53 struct sparcbus pcibus_info = { 0, PCI_BUS, { 0, 0}, };
  54 struct sparcbus pmembus_info = { 0, PMEM_BUS, { 0, 0}, };
  55 struct sparcbus cpubus_info = { 0, CPU_BUS, { 0, 0}, };
  56 
  57 struct sparcbus *sparcbus_list = 0;
  58 
  59 /* This is called at boot time to build the prom device tree. */
  60 int prom_build_devtree(unsigned long start_mem, unsigned long end_mem)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62 }
  63 
  64 /* Search the bus device list for a device which matches one of the
  65  * names in NAME_VECTOR which is an array or NUM_NAMES strings, given
  66  * the passed BUSTYPE.  Return ptr to the matching sparcdev structure
  67  * or NULL if no matches found.
  68  */
  69 struct sparcdev *prom_find_dev_on_bus(bus_t bustype, char **name_vector, int num_names)
     /* [previous][next][first][last][top][bottom][index][help] */
  70 {
  71         struct sparcdev *sdp;
  72         struct sparcbus *thebus;
  73         int niter;
  74 
  75         if(!num_names)
  76                 return 0;
  77 
  78         if(!sparcbus_list) {
  79                 prom_printf("prom_find_dev_on_bus: Device list not initted yet!\n");
  80                 prom_halt();
  81         }
  82 
  83         while(thebus = sparcbus_list; thebus; thebus = thebus->next)
  84                 if(thebus->type == bustype)
  85                         break;
  86         if(!thebus || !thebus->device_list)
  87                 return 0;
  88 
  89         for(sdp = thebus->device_list; sdp; sdp = sdp->next) {
  90                 for(niter = 0; niter < num_names; niter++)
  91                         if(!strcmp(sdp->name, name_vector[niter]))
  92                                 break;
  93         }
  94         return sdp;
  95 }
  96 
  97 /* Continue searching on a device list, starting at START_DEV for the next
  98  * instance whose name matches one of the elements of NAME_VECTOR which is
  99  * of length NUM_NAMES.
 100  */
 101 struct sparcdev *prom_find_next_dev(struct sparcdev *start_dev, char **name_vector, int num_names)
     /* [previous][next][first][last][top][bottom][index][help] */
 102 {
 103         struct sparcdev *sdp;
 104         int niter;
 105 
 106         if(!start_dev->next || !num_names)
 107                 return 0;
 108         for(sdp = start_dev->next; sdp; sdp = sdp->next) {
 109                 for(niter = 0; niter < num_names; niter++)
 110                         if(!strcmp(sdp->name, name_vector[niter]))
 111                                 break;
 112         }
 113         return sdp;
 114 }

/* [previous][next][first][last][top][bottom][index][help] */