1 /* ieee1275.h - Access the Open Firmware client interface. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef GRUB_IEEE1275_HEADER
21 #define GRUB_IEEE1275_HEADER 1
24 #include <grub/types.h>
25 #include <grub/machine/ieee1275.h>
27 struct grub_ieee1275_devalias
34 struct grub_ieee1275_mem_region
40 #define IEEE1275_MAX_PROP_LEN 8192
41 #define IEEE1275_MAX_PATH_LEN 256
43 #ifndef IEEE1275_CALL_ENTRY_FN
44 #define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args)
47 /* All backcalls to the firmware is done by calling an entry function
48 which was passed to us from the bootloader. When doing the backcall,
49 a structure is passed which specifies what the firmware should do.
50 NAME is the requested service. NR_INS and NR_OUTS is the number of
51 passed arguments and the expected number of return values, resp. */
52 struct grub_ieee1275_common_hdr
54 grub_ieee1275_cell_t name
;
55 grub_ieee1275_cell_t nr_ins
;
56 grub_ieee1275_cell_t nr_outs
;
59 #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
60 (p)->name = (grub_ieee1275_cell_t) xname; \
61 (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
62 (p)->nr_outs = (grub_ieee1275_cell_t) xouts
64 typedef grub_uint32_t grub_ieee1275_ihandle_t
;
65 typedef grub_uint32_t grub_ieee1275_phandle_t
;
67 extern void (*EXPORT_VAR(grub_ieee1275_net_config
)) (const char *dev
,
71 /* Maps a device alias to a pathname. */
72 extern grub_ieee1275_phandle_t
EXPORT_VAR(grub_ieee1275_chosen
);
73 extern grub_ieee1275_ihandle_t
EXPORT_VAR(grub_ieee1275_mmu
);
74 extern int (* EXPORT_VAR(grub_ieee1275_entry_fn
)) (void *);
76 enum grub_ieee1275_flag
78 /* Old World Macintosh firmware fails seek when "dev:0" is opened. */
79 GRUB_IEEE1275_FLAG_NO_PARTITION_0
,
81 /* Apple firmware runs in translated mode and requires use of the "map"
82 method. Other firmware runs in untranslated mode and doesn't like "map"
84 GRUB_IEEE1275_FLAG_REAL_MODE
,
86 /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the
87 whole disk). However, CodeGen firmware numbers partitions from 0. */
88 GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS
,
90 /* CodeGen firmware does not correctly implement "output-device output" */
91 GRUB_IEEE1275_FLAG_BROKEN_OUTPUT
,
93 /* OLPC / XO firmware hangs when accessing USB devices. */
94 GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY
,
96 /* Open Hack'Ware stops when trying to set colors */
97 GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS
,
99 /* Open Hack'Ware stops when grub_ieee1275_interpret is used. */
100 GRUB_IEEE1275_FLAG_CANNOT_INTERPRET
,
102 /* Open Hack'Ware has no memory map, just claim what we need. */
103 GRUB_IEEE1275_FLAG_FORCE_CLAIM
,
105 /* Open Hack'Ware don't support the ANSI sequence. */
106 GRUB_IEEE1275_FLAG_NO_ANSI
,
108 /* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
109 GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM
,
111 /* OLPC / XO firmware has the cursor ON/OFF routines. */
112 GRUB_IEEE1275_FLAG_HAS_CURSORONOFF
,
114 /* Some PowerMacs claim to use 2 address cells but in fact use only 1.
115 Other PowerMacs claim to use only 1 and really do so. Always assume
116 1 address cell is used on PowerMacs.
118 GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS
,
120 GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS
,
122 GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX
,
124 GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN
,
126 GRUB_IEEE1275_FLAG_BROKEN_REPEAT
129 extern int EXPORT_FUNC(grub_ieee1275_test_flag
) (enum grub_ieee1275_flag flag
);
130 extern void EXPORT_FUNC(grub_ieee1275_set_flag
) (enum grub_ieee1275_flag flag
);
135 void EXPORT_FUNC(grub_ieee1275_init
) (void);
136 int EXPORT_FUNC(grub_ieee1275_finddevice
) (const char *name
,
137 grub_ieee1275_phandle_t
*phandlep
);
138 int EXPORT_FUNC(grub_ieee1275_get_property
) (grub_ieee1275_phandle_t phandle
,
139 const char *property
, void *buf
,
141 grub_ssize_t
*actual
);
142 int EXPORT_FUNC(grub_ieee1275_get_integer_property
) (grub_ieee1275_phandle_t phandle
,
143 const char *property
, grub_uint32_t
*buf
,
145 grub_ssize_t
*actual
);
146 int EXPORT_FUNC(grub_ieee1275_next_property
) (grub_ieee1275_phandle_t phandle
,
147 char *prev_prop
, char *prop
);
148 int EXPORT_FUNC(grub_ieee1275_get_property_length
)
149 (grub_ieee1275_phandle_t phandle
, const char *prop
, grub_ssize_t
*length
);
150 int EXPORT_FUNC(grub_ieee1275_instance_to_package
)
151 (grub_ieee1275_ihandle_t ihandle
, grub_ieee1275_phandle_t
*phandlep
);
152 int EXPORT_FUNC(grub_ieee1275_package_to_path
) (grub_ieee1275_phandle_t phandle
,
153 char *path
, grub_size_t len
,
154 grub_ssize_t
*actual
);
155 int EXPORT_FUNC(grub_ieee1275_instance_to_path
)
156 (grub_ieee1275_ihandle_t ihandle
, char *path
, grub_size_t len
,
157 grub_ssize_t
*actual
);
158 int EXPORT_FUNC(grub_ieee1275_write
) (grub_ieee1275_ihandle_t ihandle
,
159 const void *buffer
, grub_size_t len
,
160 grub_ssize_t
*actualp
);
161 int EXPORT_FUNC(grub_ieee1275_read
) (grub_ieee1275_ihandle_t ihandle
,
162 void *buffer
, grub_size_t len
,
163 grub_ssize_t
*actualp
);
164 int EXPORT_FUNC(grub_ieee1275_seek
) (grub_ieee1275_ihandle_t ihandle
,
165 grub_disk_addr_t pos
,
166 grub_ssize_t
*result
);
167 int EXPORT_FUNC(grub_ieee1275_peer
) (grub_ieee1275_phandle_t node
,
168 grub_ieee1275_phandle_t
*result
);
169 int EXPORT_FUNC(grub_ieee1275_child
) (grub_ieee1275_phandle_t node
,
170 grub_ieee1275_phandle_t
*result
);
171 int EXPORT_FUNC(grub_ieee1275_parent
) (grub_ieee1275_phandle_t node
,
172 grub_ieee1275_phandle_t
*result
);
173 int EXPORT_FUNC(grub_ieee1275_interpret
) (const char *command
,
174 grub_ieee1275_cell_t
*catch);
175 int EXPORT_FUNC(grub_ieee1275_enter
) (void);
176 void EXPORT_FUNC(grub_ieee1275_exit
) (void) __attribute__ ((noreturn
));
177 int EXPORT_FUNC(grub_ieee1275_open
) (const char *node
,
178 grub_ieee1275_ihandle_t
*result
);
179 int EXPORT_FUNC(grub_ieee1275_close
) (grub_ieee1275_ihandle_t ihandle
);
180 int EXPORT_FUNC(grub_ieee1275_claim
) (grub_addr_t addr
, grub_size_t size
,
181 unsigned int align
, grub_addr_t
*result
);
182 int EXPORT_FUNC(grub_ieee1275_release
) (grub_addr_t addr
, grub_size_t size
);
183 int EXPORT_FUNC(grub_ieee1275_set_property
) (grub_ieee1275_phandle_t phandle
,
184 const char *propname
,
187 grub_ssize_t
*actual
);
188 int EXPORT_FUNC(grub_ieee1275_set_color
) (grub_ieee1275_ihandle_t ihandle
,
189 int index
, int r
, int g
, int b
);
190 int EXPORT_FUNC(grub_ieee1275_milliseconds
) (grub_uint32_t
*msecs
);
193 int EXPORT_FUNC(grub_devalias_iterate
)
194 (int (*hook
) (struct grub_ieee1275_devalias
*alias
));
195 int EXPORT_FUNC(grub_children_iterate
) (const char *devpath
,
196 int (*hook
) (struct grub_ieee1275_devalias
*alias
));
197 grub_err_t
EXPORT_FUNC(grub_claimmap
) (grub_addr_t addr
, grub_size_t size
);
200 EXPORT_FUNC(grub_ieee1275_map
) (grub_addr_t phys
, grub_addr_t virt
,
201 grub_size_t size
, grub_uint32_t mode
);
203 char *EXPORT_FUNC(grub_ieee1275_encode_devname
) (const char *path
);
204 char *EXPORT_FUNC(grub_ieee1275_get_filename
) (const char *path
);
205 int EXPORT_FUNC(grub_ieee1275_devices_iterate
) (int (*hook
)
206 (struct grub_ieee1275_devalias
*
208 char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname
) (const char *path
);
209 char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname
) (const char *path
);
210 char *EXPORT_FUNC(grub_ieee1275_get_device_type
) (const char *path
);
212 #endif /* ! GRUB_IEEE1275_HEADER */