1 /* ieee1275.h - Access the Open Firmware client interface. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2003,2004,2005,2007,2008 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
25 #include <grub/types.h>
26 #include <grub/machine/ieee1275.h>
28 /* Maps a device alias to a pathname. */
29 struct grub_ieee1275_devalias
36 struct grub_ieee1275_mem_region
42 #define IEEE1275_MAX_PROP_LEN 8192
43 #define IEEE1275_MAX_PATH_LEN 256
45 #ifndef IEEE1275_CALL_ENTRY_FN
46 #define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args)
49 /* All backcalls to the firmware is done by calling an entry function
50 which was passed to us from the bootloader. When doing the backcall,
51 a structure is passed which specifies what the firmware should do.
52 NAME is the requested service. NR_INS and NR_OUTS is the number of
53 passed arguments and the expected number of return values, resp. */
54 struct grub_ieee1275_common_hdr
56 grub_ieee1275_cell_t name
;
57 grub_ieee1275_cell_t nr_ins
;
58 grub_ieee1275_cell_t nr_outs
;
61 #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
62 (p)->name = (grub_ieee1275_cell_t) xname; \
63 (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
64 (p)->nr_outs = (grub_ieee1275_cell_t) xouts
66 typedef grub_uint32_t grub_ieee1275_ihandle_t
;
67 typedef grub_uint32_t grub_ieee1275_phandle_t
;
69 extern grub_ieee1275_phandle_t
EXPORT_VAR(grub_ieee1275_chosen
);
70 extern grub_ieee1275_ihandle_t
EXPORT_VAR(grub_ieee1275_mmu
);
71 extern int (* EXPORT_VAR(grub_ieee1275_entry_fn
)) (void *);
73 enum grub_ieee1275_flag
75 /* Old World Macintosh firmware fails seek when "dev:0" is opened. */
76 GRUB_IEEE1275_FLAG_NO_PARTITION_0
,
78 /* Apple firmware runs in translated mode and requires use of the "map"
79 method. Other firmware runs in untranslated mode and doesn't like "map"
81 GRUB_IEEE1275_FLAG_REAL_MODE
,
83 /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the
84 whole disk). However, CodeGen firmware numbers partitions from 0. */
85 GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS
,
87 /* CodeGen firmware does not correctly implement "output-device output" */
88 GRUB_IEEE1275_FLAG_BROKEN_OUTPUT
,
90 /* OLPC / XO firmware hangs when accessing USB devices. */
91 GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY
,
93 /* Open Hack'Ware stops when trying to set colors */
94 GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS
,
96 /* Open Hack'Ware stops when grub_ieee1275_interpret is used. */
97 GRUB_IEEE1275_FLAG_CANNOT_INTERPRET
,
99 /* Open Hack'Ware has no memory map, just claim what we need. */
100 GRUB_IEEE1275_FLAG_FORCE_CLAIM
,
102 /* Open Hack'Ware don't support the ANSI sequence. */
103 GRUB_IEEE1275_FLAG_NO_ANSI
,
106 extern int EXPORT_FUNC(grub_ieee1275_test_flag
) (enum grub_ieee1275_flag flag
);
107 extern void EXPORT_FUNC(grub_ieee1275_set_flag
) (enum grub_ieee1275_flag flag
);
112 void EXPORT_FUNC(grub_ieee1275_init
) (void);
113 int EXPORT_FUNC(grub_ieee1275_finddevice
) (char *name
,
114 grub_ieee1275_phandle_t
*phandlep
);
115 int EXPORT_FUNC(grub_ieee1275_get_property
) (grub_ieee1275_phandle_t phandle
,
116 const char *property
, void *buf
,
118 grub_ssize_t
*actual
);
119 int EXPORT_FUNC(grub_ieee1275_get_integer_property
) (grub_ieee1275_phandle_t phandle
,
120 const char *property
, grub_uint32_t
*buf
,
122 grub_ssize_t
*actual
);
123 int EXPORT_FUNC(grub_ieee1275_next_property
) (grub_ieee1275_phandle_t phandle
,
124 char *prev_prop
, char *prop
);
125 int EXPORT_FUNC(grub_ieee1275_get_property_length
)
126 (grub_ieee1275_phandle_t phandle
, const char *prop
, grub_ssize_t
*length
);
127 int EXPORT_FUNC(grub_ieee1275_instance_to_package
)
128 (grub_ieee1275_ihandle_t ihandle
, grub_ieee1275_phandle_t
*phandlep
);
129 int EXPORT_FUNC(grub_ieee1275_package_to_path
) (grub_ieee1275_phandle_t phandle
,
130 char *path
, grub_size_t len
,
131 grub_ssize_t
*actual
);
132 int EXPORT_FUNC(grub_ieee1275_instance_to_path
)
133 (grub_ieee1275_ihandle_t ihandle
, char *path
, grub_size_t len
,
134 grub_ssize_t
*actual
);
135 int EXPORT_FUNC(grub_ieee1275_write
) (grub_ieee1275_ihandle_t ihandle
,
136 void *buffer
, grub_size_t len
,
137 grub_ssize_t
*actualp
);
138 int EXPORT_FUNC(grub_ieee1275_read
) (grub_ieee1275_ihandle_t ihandle
,
139 void *buffer
, grub_size_t len
,
140 grub_ssize_t
*actualp
);
141 int EXPORT_FUNC(grub_ieee1275_seek
) (grub_ieee1275_ihandle_t ihandle
,
142 int pos_hi
, int pos_lo
,
143 grub_ssize_t
*result
);
144 int EXPORT_FUNC(grub_ieee1275_peer
) (grub_ieee1275_phandle_t node
,
145 grub_ieee1275_phandle_t
*result
);
146 int EXPORT_FUNC(grub_ieee1275_child
) (grub_ieee1275_phandle_t node
,
147 grub_ieee1275_phandle_t
*result
);
148 int EXPORT_FUNC(grub_ieee1275_parent
) (grub_ieee1275_phandle_t node
,
149 grub_ieee1275_phandle_t
*result
);
150 int EXPORT_FUNC(grub_ieee1275_interpret
) (const char *command
,
151 grub_ieee1275_cell_t
*catch);
152 int EXPORT_FUNC(grub_ieee1275_enter
) (void);
153 void EXPORT_FUNC(grub_ieee1275_exit
) (void) __attribute__ ((noreturn
));
154 int EXPORT_FUNC(grub_ieee1275_open
) (const char *node
,
155 grub_ieee1275_ihandle_t
*result
);
156 int EXPORT_FUNC(grub_ieee1275_close
) (grub_ieee1275_ihandle_t ihandle
);
157 int EXPORT_FUNC(grub_ieee1275_claim
) (grub_addr_t addr
, grub_size_t size
,
158 unsigned int align
, grub_addr_t
*result
);
159 int EXPORT_FUNC(grub_ieee1275_release
) (grub_addr_t addr
, grub_size_t size
);
160 int EXPORT_FUNC(grub_ieee1275_set_property
) (grub_ieee1275_phandle_t phandle
,
161 const char *propname
, void *buf
,
163 grub_ssize_t
*actual
);
164 int EXPORT_FUNC(grub_ieee1275_set_color
) (grub_ieee1275_ihandle_t ihandle
,
165 int index
, int r
, int g
, int b
);
166 int EXPORT_FUNC(grub_ieee1275_milliseconds
) (grub_uint32_t
*msecs
);
169 int EXPORT_FUNC(grub_devalias_iterate
)
170 (int (*hook
) (struct grub_ieee1275_devalias
*alias
));
171 int EXPORT_FUNC(grub_children_iterate
) (char *devpath
,
172 int (*hook
) (struct grub_ieee1275_devalias
*alias
));
173 grub_err_t
EXPORT_FUNC(grub_machine_mmap_iterate
)
174 (int NESTED_FUNC_ATTR (*hook
) (grub_uint64_t
, grub_uint64_t
, grub_uint32_t
));
175 int EXPORT_FUNC(grub_claimmap
) (grub_addr_t addr
, grub_size_t size
);
177 char *EXPORT_FUNC(grub_ieee1275_encode_devname
) (const char *path
);
178 char *EXPORT_FUNC(grub_ieee1275_get_filename
) (const char *path
);
180 #endif /* ! GRUB_IEEE1275_HEADER */