1 /* 2 * Definitions for talking to the Open Firmware PROM on 3 * Power Macintosh computers. 4 * 5 * Copyright (C) 1996 Paul Mackerras. 6 */ 7 #ifdef __KERNEL__ 8 #ifndef _PPC_PROM_H 9 #define _PPC_PROM_H 10 11 #include <linux/config.h> 12 13 typedef void *phandle; 14 typedef void *ihandle; 15 16 extern char *prom_display_paths[]; 17 extern unsigned int prom_num_displays; 18 19 struct address_range { 20 unsigned int space; 21 unsigned int address; 22 unsigned int size; 23 }; 24 25 struct interrupt_info { 26 int line; 27 int sense; /* +ve/-ve logic, edge or level, etc. */ 28 }; 29 30 struct reg_property { 31 unsigned int address; 32 unsigned int size; 33 }; 34 35 struct property { 36 char *name; 37 int length; 38 unsigned char *value; 39 struct property *next; 40 }; 41 42 /* 43 * Note: don't change this structure for now or you'll break BootX ! 44 */ 45 struct device_node { 46 char *name; 47 char *type; 48 phandle node; 49 int n_addrs; 50 struct address_range *addrs; 51 int n_intrs; 52 struct interrupt_info *intrs; 53 char *full_name; 54 struct property *properties; 55 struct device_node *parent; 56 struct device_node *child; 57 struct device_node *sibling; 58 struct device_node *next; /* next device of same type */ 59 struct device_node *allnext; /* next in list of all nodes */ 60 }; 61 62 struct prom_args; 63 typedef void (*prom_entry)(struct prom_args *); 64 65 /* Prototypes */ 66 extern void abort(void); 67 extern unsigned long prom_init(int, int, prom_entry); 68 extern void prom_print(const char *msg); 69 extern void relocate_nodes(void); 70 extern void finish_device_tree(void); 71 extern struct device_node *find_devices(const char *name); 72 extern struct device_node *find_type_devices(const char *type); 73 extern struct device_node *find_path_device(const char *path); 74 extern struct device_node *find_compatible_devices(const char *type, 75 const char *compat); 76 extern struct device_node *find_all_nodes(void); 77 extern struct device_node *find_phandle(phandle); 78 extern int device_is_compatible(struct device_node *device, const char *); 79 extern int machine_is_compatible(const char *compat); 80 extern unsigned char *get_property(struct device_node *node, const char *name, 81 int *lenp); 82 extern void prom_add_property(struct device_node* np, struct property* prop); 83 extern void prom_get_irq_senses(unsigned char *, int, int); 84 extern int prom_n_addr_cells(struct device_node* np); 85 extern int prom_n_size_cells(struct device_node* np); 86 87 extern struct resource* 88 request_OF_resource(struct device_node* node, int index, const char* name_postfix); 89 extern int release_OF_resource(struct device_node* node, int index); 90 91 extern void print_properties(struct device_node *node); 92 extern int call_rtas(const char *service, int nargs, int nret, 93 unsigned long *outputs, ...); 94 95 /* 96 * When we call back to the Open Firmware client interface, we usually 97 * have to do that before the kernel is relocated to its final location 98 * (this is because we can't use OF after we have overwritten the 99 * exception vectors with our exception handlers). These macros assist 100 * in performing the address calculations that we need to do to access 101 * data when the kernel is running at an address that is different from 102 * the address that the kernel is linked at. The reloc_offset() function 103 * returns the difference between these two addresses and the macros 104 * simplify the process of adding or subtracting this offset to/from 105 * pointer values. See arch/ppc/kernel/prom.c for how these are used. 106 */ 107 extern unsigned long reloc_offset(void); 108 extern unsigned long add_reloc_offset(unsigned long); 109 extern unsigned long sub_reloc_offset(unsigned long); 110 111 #define PTRRELOC(x) ((typeof(x))add_reloc_offset((unsigned long)(x))) 112 #define PTRUNRELOC(x) ((typeof(x))sub_reloc_offset((unsigned long)(x))) 113 114 #endif /* _PPC_PROM_H */ 115 #endif /* __KERNEL__ */ 116