1 | /*
|
---|
2 | * Copyright (c) 2005 Martin Decky
|
---|
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 |
|
---|
29 | #ifndef BOOT_OFW_H_
|
---|
30 | #define BOOT_OFW_H_
|
---|
31 |
|
---|
32 | #include <typedefs.h>
|
---|
33 | #include <stdarg.h>
|
---|
34 |
|
---|
35 | #define MEMMAP_MAX_RECORDS 32
|
---|
36 | #define MAX_OFW_ARGS 12
|
---|
37 |
|
---|
38 | #define OFW_TREE_PATH_MAX_LEN 256
|
---|
39 | #define OFW_TREE_PROPERTY_MAX_NAMELEN 32
|
---|
40 | #define OFW_TREE_PROPERTY_MAX_VALUELEN 64
|
---|
41 |
|
---|
42 | typedef sysarg_t ofw_arg_t;
|
---|
43 | typedef native_t ofw_ret_t;
|
---|
44 | typedef uint32_t ofw_prop_t;
|
---|
45 | typedef uint32_t ihandle;
|
---|
46 | typedef uint32_t phandle;
|
---|
47 |
|
---|
48 | /** OpenFirmware command structure
|
---|
49 | *
|
---|
50 | */
|
---|
51 | typedef struct {
|
---|
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. */
|
---|
56 | } ofw_args_t;
|
---|
57 |
|
---|
58 | typedef struct {
|
---|
59 | void *start;
|
---|
60 | size_t size;
|
---|
61 | } memzone_t;
|
---|
62 |
|
---|
63 | typedef struct {
|
---|
64 | uint64_t total;
|
---|
65 | size_t cnt;
|
---|
66 | memzone_t zones[MEMMAP_MAX_RECORDS];
|
---|
67 | } memmap_t;
|
---|
68 |
|
---|
69 | typedef struct {
|
---|
70 | uint32_t info;
|
---|
71 | uint32_t addr_hi;
|
---|
72 | uint32_t addr_lo;
|
---|
73 | } pci_addr_t;
|
---|
74 |
|
---|
75 | typedef struct {
|
---|
76 | pci_addr_t addr;
|
---|
77 | uint32_t size_hi;
|
---|
78 | uint32_t size_lo;
|
---|
79 | } pci_reg_t;
|
---|
80 |
|
---|
81 | extern uintptr_t ofw_cif;
|
---|
82 |
|
---|
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;
|
---|
88 |
|
---|
89 | extern void ofw_init(void);
|
---|
90 |
|
---|
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 *);
|
---|
125 | extern void ofw_setup_screens(void);
|
---|
126 | extern void ofw_quiesce(void);
|
---|
127 |
|
---|
128 | #endif
|
---|