Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:09

0001 /*
0002  * Copyright (c) 2005 Martin Decky
0003  * All rights reserved.
0004  *
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  *
0009  * - Redistributions of source code must retain the above copyright
0010  *   notice, this list of conditions and the following disclaimer.
0011  * - Redistributions in binary form must reproduce the above copyright
0012  *   notice, this list of conditions and the following disclaimer in the
0013  *   documentation and/or other materials provided with the distribution.
0014  * - The name of the author may not be used to endorse or promote products
0015  *   derived from this software without specific prior written permission.
0016  *
0017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifndef BOOT_OFW_H_
0030 #define BOOT_OFW_H_
0031 
0032 #include <boot/types.h>
0033 #include <stdarg.h>
0034 
0035 #define MEMMAP_MAX_RECORDS  32
0036 #define MAX_OFW_ARGS        12
0037 
0038 #define OFW_TREE_PATH_MAX_LEN           256
0039 #define OFW_TREE_PROPERTY_MAX_NAMELEN   32
0040 #define OFW_TREE_PROPERTY_MAX_VALUELEN  64
0041 
0042 typedef unative_t ofw_arg_t;
0043 typedef unsigned int ihandle;
0044 typedef unsigned int phandle;
0045 
0046 /** OpenFirmware command structure
0047  *
0048  */
0049 typedef struct {
0050     ofw_arg_t service;             /**< Command name. */
0051     ofw_arg_t nargs;               /**< Number of in arguments. */
0052     ofw_arg_t nret;                /**< Number of out arguments. */
0053     ofw_arg_t args[MAX_OFW_ARGS];  /**< List of arguments. */
0054 } ofw_args_t;
0055 
0056 typedef struct {
0057     void *start;
0058     uint32_t size;
0059 } memzone_t;
0060 
0061 typedef struct {
0062     uint32_t total;
0063     uint32_t count;
0064     memzone_t zones[MEMMAP_MAX_RECORDS];
0065 } memmap_t;
0066 
0067 typedef struct {
0068     uint32_t info;
0069     uint32_t addr_hi;
0070     uint32_t addr_lo;
0071 } pci_addr_t;
0072 
0073 typedef struct {
0074     pci_addr_t addr;
0075     uint32_t size_hi;
0076     uint32_t size_lo;
0077 } pci_reg_t;
0078 
0079 extern uintptr_t ofw_cif;
0080 
0081 extern phandle ofw_chosen;
0082 extern ihandle ofw_stdout;
0083 extern phandle ofw_root;
0084 extern ihandle ofw_mmu;
0085 extern phandle ofw_memory;
0086 
0087 extern void ofw_init(void);
0088 
0089 extern void ofw_write(const char *str, const int len);
0090 
0091 extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
0092 extern int ofw_get_proplen(const phandle device, const char *name);
0093 extern int ofw_next_property(const phandle device, char *previous, char *buf);
0094 
0095 extern phandle ofw_get_child_node(const phandle node);
0096 extern phandle ofw_get_peer_node(const phandle node);
0097 extern phandle ofw_find_device(const char *name);
0098 
0099 extern int ofw_package_to_path(const phandle device, char *buf, const int buflen);
0100 
0101 extern int ofw(ofw_args_t *arg);
0102 extern unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...);
0103 extern void ofw_write(const char *str, const int len);
0104 extern void ofw_read(void *str, const int len);
0105 extern unsigned int ofw_get_address_cells(const phandle device);
0106 extern unsigned int ofw_get_size_cells(const phandle device);
0107 extern void *ofw_translate(const void *virt);
0108 extern int ofw_translate_failed(ofw_arg_t flag);
0109 extern void *ofw_claim_virt(const void *virt, const unsigned int len);
0110 extern void *ofw_claim_phys(const void *virt, const unsigned int len);
0111 extern void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment);
0112 extern int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode);
0113 extern int ofw_memmap(memmap_t *map);
0114 extern void ofw_setup_screens(void);
0115 extern void ofw_quiesce(void);
0116 
0117 #endif