2N/A/* ieee1275.h - Access the Open Firmware client interface. */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#ifndef GRUB_IEEE1275_HEADER
2N/A#define GRUB_IEEE1275_HEADER 1
2N/A
2N/A#include <grub/err.h>
2N/A#include <grub/types.h>
2N/A#include <grub/machine/ieee1275.h>
2N/A
2N/Astruct grub_ieee1275_devalias
2N/A{
2N/A char *name;
2N/A char *path;
2N/A char *type;
2N/A};
2N/A
2N/Astruct grub_ieee1275_mem_region
2N/A{
2N/A unsigned int start;
2N/A unsigned int size;
2N/A};
2N/A
2N/A#define IEEE1275_MAX_PROP_LEN 8192
2N/A#define IEEE1275_MAX_PATH_LEN 256
2N/A
2N/A#ifndef IEEE1275_CALL_ENTRY_FN
2N/A#define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args)
2N/A#endif
2N/A
2N/A/* All backcalls to the firmware is done by calling an entry function
2N/A which was passed to us from the bootloader. When doing the backcall,
2N/A a structure is passed which specifies what the firmware should do.
2N/A NAME is the requested service. NR_INS and NR_OUTS is the number of
2N/A passed arguments and the expected number of return values, resp. */
2N/Astruct grub_ieee1275_common_hdr
2N/A{
2N/A grub_ieee1275_cell_t name;
2N/A grub_ieee1275_cell_t nr_ins;
2N/A grub_ieee1275_cell_t nr_outs;
2N/A};
2N/A
2N/A#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
2N/A (p)->name = (grub_ieee1275_cell_t) xname; \
2N/A (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
2N/A (p)->nr_outs = (grub_ieee1275_cell_t) xouts
2N/A
2N/Atypedef grub_uint32_t grub_ieee1275_ihandle_t;
2N/Atypedef grub_uint32_t grub_ieee1275_phandle_t;
2N/A
2N/Aextern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
2N/A char **device,
2N/A char **path);
2N/A
2N/A/* Maps a device alias to a pathname. */
2N/Aextern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
2N/Aextern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu);
2N/Aextern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *);
2N/A
2N/Aenum grub_ieee1275_flag
2N/A{
2N/A /* Old World Macintosh firmware fails seek when "dev:0" is opened. */
2N/A GRUB_IEEE1275_FLAG_NO_PARTITION_0,
2N/A
2N/A /* Apple firmware runs in translated mode and requires use of the "map"
2N/A method. Other firmware runs in untranslated mode and doesn't like "map"
2N/A calls. */
2N/A GRUB_IEEE1275_FLAG_REAL_MODE,
2N/A
2N/A /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the
2N/A whole disk). However, CodeGen firmware numbers partitions from 0. */
2N/A GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS,
2N/A
2N/A /* CodeGen firmware does not correctly implement "output-device output" */
2N/A GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
2N/A
2N/A /* OLPC / XO firmware hangs when accessing USB devices. */
2N/A GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY,
2N/A
2N/A /* Open Hack'Ware stops when trying to set colors */
2N/A GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS,
2N/A
2N/A /* Open Hack'Ware stops when grub_ieee1275_interpret is used. */
2N/A GRUB_IEEE1275_FLAG_CANNOT_INTERPRET,
2N/A
2N/A /* Open Hack'Ware has no memory map, just claim what we need. */
2N/A GRUB_IEEE1275_FLAG_FORCE_CLAIM,
2N/A
2N/A /* Open Hack'Ware don't support the ANSI sequence. */
2N/A GRUB_IEEE1275_FLAG_NO_ANSI,
2N/A
2N/A /* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
2N/A GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
2N/A
2N/A /* OLPC / XO firmware has the cursor ON/OFF routines. */
2N/A GRUB_IEEE1275_FLAG_HAS_CURSORONOFF,
2N/A
2N/A /* Some PowerMacs claim to use 2 address cells but in fact use only 1.
2N/A Other PowerMacs claim to use only 1 and really do so. Always assume
2N/A 1 address cell is used on PowerMacs.
2N/A */
2N/A GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS,
2N/A};
2N/A
2N/Aextern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
2N/Aextern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag);
2N/A
2N/A
2N/A
2N/A
2N/Avoid EXPORT_FUNC(grub_ieee1275_init) (void);
2N/Aint EXPORT_FUNC(grub_ieee1275_finddevice) (const char *name,
2N/A grub_ieee1275_phandle_t *phandlep);
2N/Aint EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t phandle,
2N/A const char *property, void *buf,
2N/A grub_size_t size,
2N/A grub_ssize_t *actual);
2N/Aint EXPORT_FUNC(grub_ieee1275_get_integer_property) (grub_ieee1275_phandle_t phandle,
2N/A const char *property, grub_uint32_t *buf,
2N/A grub_size_t size,
2N/A grub_ssize_t *actual);
2N/Aint EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t phandle,
2N/A char *prev_prop, char *prop);
2N/Aint EXPORT_FUNC(grub_ieee1275_get_property_length)
2N/A (grub_ieee1275_phandle_t phandle, const char *prop, grub_ssize_t *length);
2N/Aint EXPORT_FUNC(grub_ieee1275_instance_to_package)
2N/A (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep);
2N/Aint EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle,
2N/A char *path, grub_size_t len,
2N/A grub_ssize_t *actual);
2N/Aint EXPORT_FUNC(grub_ieee1275_instance_to_path)
2N/A (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len,
2N/A grub_ssize_t *actual);
2N/Aint EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle,
2N/A void *buffer, grub_size_t len,
2N/A grub_ssize_t *actualp);
2N/Aint EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
2N/A void *buffer, grub_size_t len,
2N/A grub_ssize_t *actualp);
2N/Aint EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
2N/A grub_disk_addr_t pos,
2N/A grub_ssize_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
2N/A grub_ieee1275_phandle_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node,
2N/A grub_ieee1275_phandle_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node,
2N/A grub_ieee1275_phandle_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_interpret) (const char *command,
2N/A grub_ieee1275_cell_t *catch);
2N/Aint EXPORT_FUNC(grub_ieee1275_enter) (void);
2N/Avoid EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
2N/Aint EXPORT_FUNC(grub_ieee1275_open) (const char *node,
2N/A grub_ieee1275_ihandle_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle);
2N/Aint EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size,
2N/A unsigned int align, grub_addr_t *result);
2N/Aint EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size);
2N/Aint EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle,
2N/A const char *propname,
2N/A const void *buf,
2N/A grub_size_t size,
2N/A grub_ssize_t *actual);
2N/Aint EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
2N/A int index, int r, int g, int b);
2N/Aint EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
2N/A
2N/A
2N/Aint EXPORT_FUNC(grub_devalias_iterate)
2N/A (int (*hook) (struct grub_ieee1275_devalias *alias));
2N/Aint EXPORT_FUNC(grub_children_iterate) (const char *devpath,
2N/A int (*hook) (struct grub_ieee1275_devalias *alias));
2N/Aint EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
2N/A
2N/Aint
2N/AEXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
2N/A grub_size_t size, grub_uint32_t mode);
2N/A
2N/Achar *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
2N/Achar *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
2N/Aint EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
2N/A (struct grub_ieee1275_devalias *
2N/A alias));
2N/Achar *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
2N/Achar *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
2N/Achar *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
2N/A
2N/A#endif /* ! GRUB_IEEE1275_HEADER */