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   64           /* 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 prom_int_null;
  41 
  42 unsigned int *
  43 get_int_from_prom(int node, char *nd_prop, unsigned int *value)
     /* [previous][next][first][last][top][bottom][index][help] */
  44 {
  45   unsigned int pr_len;
  46 
  47   *value = &prom_int_null;    /* duh, I was returning -1 as an unsigned int, prom_panic() */
  48 
  49   pr_len = romvec->pv_nodeops->no_proplen(node, nd_prop);
  50   if(pr_len > MAX_PR_LEN)
  51     {
  52 #ifdef DEBUG_PROMOPS
  53       printk("Bad pr_len in promops -- node: %d nd_prop: %s pr_len: %d",
  54              node, nd_prop, (int) pr_len);
  55 #endif
  56       return value;      /* XXX */
  57     }
  58 
  59   romvec->pv_nodeops->no_getprop(node, nd_prop, (char *) value);
  60 
  61   return value;
  62 }
  63 
  64 
  65 /* This routine returns what is termed a property string as opposed
  66  * to a property integer as above. This can be used to extract the
  67  * 'type' of device from the prom. An example could be the clock timer
  68  * chip type. By default you get returned a null string if garbage
  69  * is returned from the prom.
  70  */
  71 
  72 char *
  73 get_str_from_prom(int node, char *nd_prop, char *value)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75   unsigned int pr_len;
  76 
  77   *value='\n';
  78 
  79   pr_len = romvec->pv_nodeops->no_proplen(node, nd_prop);
  80   if(pr_len > MAX_PR_LEN)
  81     {
  82 #ifdef DEBUG_PROMOPS
  83       printk("Bad pr_len in promops -- node: %d nd_prop: %s pr_len: %d",
  84              node, nd_prop, pr_len);
  85 #endif
  86       return value;      /* XXX */
  87     }
  88 
  89   romvec->pv_nodeops->no_getprop(node, nd_prop, value);
  90   value[pr_len] = 0;
  91 
  92   return value;
  93 }
  94 
  95 /* This gets called from head.S upon bootup to initialize the
  96  * prom vector pointer for the rest of the kernel.
  97  */
  98 
  99 void
 100 init_prom(struct linux_romvec *r_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102   romvec = r_ptr;
 103   prom_node_root = romvec->pv_nodeops->no_nextnode(0);
 104   prom_int_null = 0;
 105   
 106   return;
 107 }

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