[3c1dec0] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2005 Martin Decky
|
---|
[3c1dec0] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[63cda71] | 29 | #ifndef BOOT_OFW_H_
|
---|
| 30 | #define BOOT_OFW_H_
|
---|
[3c1dec0] | 31 |
|
---|
[4872160] | 32 | #include <typedefs.h>
|
---|
[b7b5f83] | 33 | #include <stdarg.h>
|
---|
[3c1dec0] | 34 |
|
---|
[e731b0d] | 35 | #define MEMMAP_MAX_RECORDS 32
|
---|
[e0565005] | 36 | #define MAX_OFW_ARGS 12
|
---|
[3c1dec0] | 37 |
|
---|
[e0565005] | 38 | #define OFW_TREE_PATH_MAX_LEN 256
|
---|
| 39 | #define OFW_TREE_PROPERTY_MAX_NAMELEN 32
|
---|
| 40 | #define OFW_TREE_PROPERTY_MAX_VALUELEN 64
|
---|
[2e672fd] | 41 |
|
---|
[96b02eb9] | 42 | typedef sysarg_t ofw_arg_t;
|
---|
[4872160] | 43 | typedef native_t ofw_ret_t;
|
---|
| 44 | typedef uint32_t ofw_prop_t;
|
---|
| 45 | typedef uint32_t ihandle;
|
---|
| 46 | typedef uint32_t phandle;
|
---|
[2e672fd] | 47 |
|
---|
| 48 | /** OpenFirmware command structure
|
---|
| 49 | *
|
---|
| 50 | */
|
---|
| 51 | typedef struct {
|
---|
[e731b0d] | 52 | ofw_arg_t service; /**< Command name. */
|
---|
| 53 | ofw_arg_t nargs; /**< Number of in arguments. */
|
---|
| 54 | ofw_arg_t nret; /**< Number of out arguments. */
|
---|
| 55 | ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments. */
|
---|
[2e672fd] | 56 | } ofw_args_t;
|
---|
| 57 |
|
---|
[6323989] | 58 | typedef struct {
|
---|
| 59 | void *start;
|
---|
[4872160] | 60 | size_t size;
|
---|
[6323989] | 61 | } memzone_t;
|
---|
[3c1dec0] | 62 |
|
---|
| 63 | typedef struct {
|
---|
[4872160] | 64 | uint64_t total;
|
---|
| 65 | size_t cnt;
|
---|
[6323989] | 66 | memzone_t zones[MEMMAP_MAX_RECORDS];
|
---|
| 67 | } memmap_t;
|
---|
[3c1dec0] | 68 |
|
---|
[b7b5f83] | 69 | typedef struct {
|
---|
[94d614e] | 70 | uint32_t info;
|
---|
| 71 | uint32_t addr_hi;
|
---|
| 72 | uint32_t addr_lo;
|
---|
[b7b5f83] | 73 | } pci_addr_t;
|
---|
| 74 |
|
---|
| 75 | typedef struct {
|
---|
| 76 | pci_addr_t addr;
|
---|
[94d614e] | 77 | uint32_t size_hi;
|
---|
| 78 | uint32_t size_lo;
|
---|
[b7b5f83] | 79 | } pci_reg_t;
|
---|
| 80 |
|
---|
[2e672fd] | 81 | extern uintptr_t ofw_cif;
|
---|
[b7b5f83] | 82 |
|
---|
[9a5b556] | 83 | extern phandle ofw_chosen;
|
---|
| 84 | extern ihandle ofw_stdout;
|
---|
| 85 | extern phandle ofw_root;
|
---|
| 86 | extern ihandle ofw_mmu;
|
---|
| 87 | extern phandle ofw_memory;
|
---|
[3c1dec0] | 88 |
|
---|
[63cda71] | 89 | extern void ofw_init(void);
|
---|
[9a5b556] | 90 |
|
---|
[4872160] | 91 | extern void ofw_putchar(const char);
|
---|
| 92 |
|
---|
| 93 | extern ofw_arg_t ofw_get_property(const phandle, const char *, void *,
|
---|
| 94 | const size_t);
|
---|
| 95 | extern ofw_arg_t ofw_get_proplen(const phandle, const char *);
|
---|
| 96 | extern ofw_arg_t ofw_next_property(const phandle, char *, char *);
|
---|
| 97 |
|
---|
| 98 | extern phandle ofw_get_child_node(const phandle);
|
---|
| 99 | extern phandle ofw_get_peer_node(const phandle);
|
---|
| 100 | extern phandle ofw_find_device(const char *);
|
---|
| 101 |
|
---|
| 102 | extern ofw_arg_t ofw_package_to_path(const phandle, char *, const size_t);
|
---|
| 103 |
|
---|
| 104 | extern ofw_arg_t ofw(ofw_args_t *);
|
---|
| 105 | extern ofw_arg_t ofw_call(const char *, const size_t, const size_t, ofw_arg_t *,
|
---|
| 106 | ...);
|
---|
| 107 |
|
---|
| 108 | extern size_t ofw_get_address_cells(const phandle);
|
---|
| 109 | extern size_t ofw_get_size_cells(const phandle);
|
---|
| 110 |
|
---|
| 111 | extern void *ofw_translate(const void *);
|
---|
| 112 |
|
---|
| 113 | extern void ofw_claim_virt(const void *, const size_t);
|
---|
| 114 | extern void *ofw_claim_virt_any(const size_t, const size_t);
|
---|
| 115 |
|
---|
| 116 | extern void ofw_claim_phys(const void *, const size_t);
|
---|
| 117 | extern void *ofw_claim_phys_any(const size_t, const size_t);
|
---|
| 118 |
|
---|
| 119 | extern void ofw_map(const void *, const void *, const size_t,
|
---|
| 120 | const ofw_arg_t);
|
---|
| 121 |
|
---|
| 122 | extern void ofw_alloc(const char *, void **, void **, const size_t, void *);
|
---|
| 123 |
|
---|
| 124 | extern void ofw_memmap(memmap_t *);
|
---|
[e0565005] | 125 | extern void ofw_setup_screens(void);
|
---|
[deb14fb] | 126 | extern void ofw_quiesce(void);
|
---|
[3c1dec0] | 127 |
|
---|
| 128 | #endif
|
---|