cleanup
[linux-2.4.git] / include / asm-ppc64 / prom.h
1 #ifndef _PPC64_PROM_H
2 #define _PPC64_PROM_H
3
4 /*
5  * Definitions for talking to the Open Firmware PROM on
6  * Power Macintosh computers.
7  *
8  * Copyright (C) 1996 Paul Mackerras.
9  *
10  * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version
15  * 2 of the License, or (at your option) any later version.
16  */
17
18 #define PTRRELOC(x)     ((typeof(x))((unsigned long)(x) - offset))
19 #define PTRUNRELOC(x)   ((typeof(x))((unsigned long)(x) + offset))
20 #define RELOC(x)        (*PTRRELOC(&(x)))
21
22 #define LONG_LSW(X) (((unsigned long)X) & 0xffffffff)
23 #define LONG_MSW(X) (((unsigned long)X) >> 32)
24
25 typedef u32 phandle;
26 typedef void *ihandle;
27 typedef u32 phandle32;
28 typedef u32 ihandle32;
29
30 extern char *prom_display_paths[];
31 extern unsigned int prom_num_displays;
32
33 struct address_range {
34         unsigned long space;
35         unsigned long address;
36         unsigned long size;
37 };
38
39 struct interrupt_info {
40         int     line;
41         int     sense;          /* +ve/-ve logic, edge or level, etc. */
42 };
43
44 struct pci_address {
45         u32 a_hi;
46         u32 a_mid;
47         u32 a_lo;
48 };
49
50 struct pci_range32 {
51         struct pci_address child_addr;
52         unsigned int  parent_addr;
53         unsigned long size; 
54 };
55
56 struct pci_range64 {
57         struct pci_address child_addr;
58         unsigned long parent_addr;
59         unsigned long size; 
60 };
61
62 union pci_range {
63         struct {
64                 struct pci_address addr;
65                 u32 phys;
66                 u32 size_hi;
67         } pci32;
68         struct {
69                 struct pci_address addr;
70                 u32 phys_hi;
71                 u32 phys_lo;
72                 u32 size_hi;
73                 u32 size_lo;
74         } pci64;
75 };
76
77 struct _of_tce_table {
78         phandle node;
79         unsigned long base;
80         unsigned long size;
81 };
82
83 struct reg_property {
84         unsigned long address;
85         unsigned long size;
86 };
87
88 struct reg_property32 {
89         unsigned int address;
90         unsigned int size;
91 };
92
93 struct reg_property64 {
94         unsigned long address;
95         unsigned long size;
96 };
97
98 struct translation_property {
99         unsigned long virt;
100         unsigned long size;
101         unsigned long phys;
102         unsigned int flags;
103 };
104
105 struct property {
106         char    *name;
107         int     length;
108         unsigned char *value;
109         struct property *next;
110 };
111
112 /* NOTE: the device_node contains PCI specific info for pci devices.
113  * This perhaps could be hung off the device_node with another struct,
114  * but for now it is directly in the node.  The phb ptr is a good
115  * indication of a real PCI node.  Other nodes leave these fields zeroed.
116  */
117 struct pci_controller;
118 struct TceTable;
119 struct device_node {
120         char    *name;
121         char    *type;
122         phandle node;
123         phandle linux_phandle;
124         int     n_addrs;
125         struct  address_range *addrs;
126         int     n_intrs;
127         struct  interrupt_info *intrs;
128         char    *full_name;
129
130         /* PCI stuff probably doesn't belong here */
131         int     busno;                  /* for pci devices */
132         int     devfn;                  /* for pci devices */
133 #define DN_STATUS_BIST_FAILED (1<<0)
134         int     status;                 /* Current device status (non-zero is bad) */
135         int     eeh_mode;               /* See eeh.h for possible EEH_MODEs */
136         int     eeh_config_addr;
137         struct  pci_controller *phb;    /* for pci devices */
138         struct  TceTable *tce_table;    /* for phb's or bridges */
139
140         struct  property *properties;
141         struct  device_node *parent;
142         struct  device_node *child;
143         struct  device_node *sibling;
144         struct  device_node *next;      /* next device of same type */
145         struct  device_node *allnext;   /* next in list of all nodes */
146 };
147
148 typedef u32 prom_arg_t;
149
150 struct prom_args {
151         u32 service;
152         u32 nargs;
153         u32 nret;
154         prom_arg_t args[10];
155         prom_arg_t *rets;     /* Pointer to return values in args[16]. */
156 };
157
158 typedef struct {
159         u32  printf;    /* void (*printf)(char *, ...); */
160         u32  memdump;   /* void (*memdump)(unsigned char *, unsigned long); */
161         u32  dummy;             /* void (*dummy)(void); */
162 } yaboot_debug_t;
163
164 struct prom_t {
165         unsigned long entry;
166         ihandle chosen;
167         int cpu;
168         ihandle stdout;
169         ihandle disp_node;
170         struct prom_args args;
171         unsigned long version;
172         unsigned long encode_phys_size;
173         struct bi_record *bi_recs;
174 #ifdef DEBUG_YABOOT
175         yaboot_debug_t *yaboot;
176 #endif
177 };
178
179 extern struct prom_t prom;
180 extern char *of_stdout_device;
181
182 /* Prototypes */
183 extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
184     unsigned long, unsigned long, yaboot_debug_t *);
185 extern void prom_print(const char *msg);
186 extern void relocate_nodes(void);
187 extern void finish_device_tree(void);
188 extern struct device_node *find_devices(const char *name);
189 extern struct device_node *find_type_devices(const char *type);
190 extern struct device_node *find_path_device(const char *path);
191 extern struct device_node *find_compatible_devices(const char *type,
192                                                    const char *compat);
193 extern struct device_node *find_pci_device_OFnode(unsigned char bus,
194         unsigned char dev_fn);
195 extern struct device_node *find_all_nodes(void);
196 extern int device_is_compatible(struct device_node *device, const char *);
197 extern int machine_is_compatible(const char *compat);
198 extern unsigned char *get_property(struct device_node *node, const char *name,
199                                    int *lenp);
200 extern void print_properties(struct device_node *node);
201 extern int prom_n_addr_cells(struct device_node* np);
202 extern int prom_n_size_cells(struct device_node* np);
203 extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
204 extern void prom_add_property(struct device_node* np, struct property* prop);
205
206 #endif /* _PPC64_PROM_H */