root/arch/sparc/kernel/promops.c

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

DEFINITIONS

This source file includes following definitions.
  1. node_get_sibling
  2. node_get_child
  3. get_int_from_prom
  4. get_str_from_prom
  5. init_prom

   1 /* promops.c:  Prom node tree operations and Prom Vector initialization
   2  *             initialization routines.
   3  *
   4  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <linux/kernel.h>
   8 
   9 #include <asm/openprom.h>
  10 
  11 /* #define DEBUG_PROMOPS */
  12 #define MAX_PR_LEN   16           /* exotic hardware probably overshoots this */
  13 
  14 int prom_node_root;               /* initialized in init_prom */
  15 
  16 extern struct linux_romvec *romvec;
  17 
  18 /* These two functions return and siblings and direct child descendents
  19  * in the prom device tree respectively.
  20  */
  21 
  22 int
  23 node_get_sibling(int node)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25   return (*(romvec->pv_nodeops->no_nextnode))(node);
  26 }
  27 
  28 int
  29 node_get_child(int node)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31   return (*(romvec->pv_nodeops->no_child))(node);
  32 }
  33 
  34 /* The following routine is used during device probing to determine
  35  * an integer value property about a (perhaps virtual) device. This
  36  * could be anything, like the size of the mmu cache lines, etc.
  37  * the default return value is -1 is the prom has nothing interesting.
  38  */
  39 
  40 unsigned int *
  41 get_int_from_prom(int node, char *nd_prop, unsigned int *value)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43   unsigned int pr_len;
  44 
  45   *value = 0;    /* duh, I was returning -1 as an unsigned int, prom_panic() */
  46 
  47   pr_len = romvec->pv_nodeops->no_proplen(node, nd_prop);
  48   if(pr_len > MAX_PR_LEN)
  49     {
  50 #ifdef DEBUG_PROMOPS
  51       printk("Bad pr_len in promops -- node: %d nd_prop: %s pr_len: %d",
  52              node, nd_prop, (int) pr_len);
  53 #endif
  54       return value;      /* XXX */
  55     }
  56 
  57   romvec->pv_nodeops->no_getprop(node, nd_prop, (char *) value);
  58 
  59   return value;
  60 }
  61 
  62 
  63 /* This routine returns what is termed a property string as opposed
  64  * to a property integer as above. This can be used to extract the
  65  * 'type' of device from the prom. An example could be the clock timer
  66  * chip type. By default you get returned a null string if garbage
  67  * is returned from the prom.
  68  */
  69 
  70 char *
  71 get_str_from_prom(int node, char *nd_prop, char *value)
     /* [previous][next][first][last][top][bottom][index][help] */
  72 {
  73   unsigned int pr_len;
  74 
  75   *value='\n';
  76 
  77   pr_len = romvec->pv_nodeops->no_proplen(node, nd_prop);
  78   if(pr_len > MAX_PR_LEN)
  79     {
  80 #ifdef DEBUG_PROMOPS
  81       printk("Bad pr_len in promops -- node: %d nd_prop: %s pr_len: %d",
  82              node, nd_prop, pr_len);
  83 #endif
  84       return value;      /* XXX */
  85     }
  86 
  87   romvec->pv_nodeops->no_getprop(node, nd_prop, value);
  88   value[pr_len] = 0;
  89 
  90   return value;
  91 }
  92 
  93 /* This gets called from head.S upon bootup to initialize the
  94  * prom vector pointer for the rest of the kernel.
  95  */
  96 
  97 void
  98 init_prom(struct linux_romvec *r_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
  99 {
 100   romvec = r_ptr;
 101   prom_node_root = romvec->pv_nodeops->no_nextnode(0);
 102   
 103   return;
 104 }

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