libofw.h revision 329183
1/*-
2 * Copyright (C) 2000 Benno Rice.
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 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: stable/11/stand/ofw/libofw/libofw.h 329183 2018-02-12 20:51:28Z kevans $
26 */
27
28#include "openfirm.h"
29
30/* Note: Must match the 'struct devdesc' in bootstrap.h */
31struct ofw_devdesc {
32	struct devsw	*d_dev;
33	int		d_type;
34	int		d_unit;
35	ihandle_t	d_handle;
36	union {
37		char			d_path[256];
38		struct {
39			uint64_t	pool_guid;
40			uint64_t	root_guid;
41		};
42	};
43};
44
45extern int	ofw_getdev(void **vdev, const char *devspec, const char **path);
46extern ev_sethook_t ofw_setcurrdev;
47
48extern struct devsw		ofwdisk;
49extern struct netif_driver	ofwnet;
50
51int	ofwn_getunit(const char *);
52
53ssize_t	ofw_copyin(const void *src, vm_offset_t dest, const size_t len);
54ssize_t ofw_copyout(const vm_offset_t src, void *dest, const size_t len);
55ssize_t ofw_readin(const int fd, vm_offset_t dest, const size_t len);
56
57extern int	ofw_boot(void);
58extern int	ofw_autoload(void);
59
60void	ofw_memmap(int);
61
62struct preloaded_file;
63struct file_format;
64
65int	ofw_elf_loadfile(char *, vm_offset_t, struct preloaded_file **);
66int	ofw_elf_exec(struct preloaded_file *);
67
68/* MD code implementing MI interfaces */
69vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
70vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
71
72extern struct file_format	ofw_elf;
73#ifdef __powerpc__
74extern struct file_format	ofw_elf64;
75#endif
76
77extern void	reboot(void);
78
79struct ofw_reg
80{
81	cell_t		base;
82	cell_t		size;
83};
84
85struct ofw_reg2
86{
87	cell_t		base_hi;
88	cell_t		base_lo;
89	cell_t		size;
90};
91
92extern int (*openfirmware)(void *);
93