xref: /netbsd-src/sys/arch/sparc/include/loadfile_machdep.h (revision eb6cc7528a5a7cb93a1d37aa9d3b5a814f13bc58)
1*eb6cc752Sjoerg /*	$NetBSD: loadfile_machdep.h,v 1.11 2014/08/06 21:57:51 joerg Exp $	 */
2b40179bdSchristos 
3b40179bdSchristos /*-
4b40179bdSchristos  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5b40179bdSchristos  * All rights reserved.
6b40179bdSchristos  *
7b40179bdSchristos  * This code is derived from software contributed to The NetBSD Foundation
8b40179bdSchristos  * by Christos Zoulas.
9b40179bdSchristos  *
10b40179bdSchristos  * Redistribution and use in source and binary forms, with or without
11b40179bdSchristos  * modification, are permitted provided that the following conditions
12b40179bdSchristos  * are met:
13b40179bdSchristos  * 1. Redistributions of source code must retain the above copyright
14b40179bdSchristos  *    notice, this list of conditions and the following disclaimer.
15b40179bdSchristos  * 2. Redistributions in binary form must reproduce the above copyright
16b40179bdSchristos  *    notice, this list of conditions and the following disclaimer in the
17b40179bdSchristos  *    documentation and/or other materials provided with the distribution.
18b40179bdSchristos  *
19b40179bdSchristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b40179bdSchristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b40179bdSchristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b40179bdSchristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b40179bdSchristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b40179bdSchristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b40179bdSchristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b40179bdSchristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b40179bdSchristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b40179bdSchristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b40179bdSchristos  * POSSIBILITY OF SUCH DAMAGE.
30b40179bdSchristos  */
31b40179bdSchristos 
3235e47f06Schristos #define LOAD_KERNEL	LOAD_ALL
3335e47f06Schristos #define COUNT_KERNEL	COUNT_ALL
34b40179bdSchristos 
35b40179bdSchristos #ifdef _STANDALONE
361b5340d3Spk #define LOADADDR(a)		(a)
37b40179bdSchristos #define ALIGNENTRY(a)		((u_long)(a))
38b40179bdSchristos #define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
39b40179bdSchristos #define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
40b40179bdSchristos #define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
41*eb6cc752Sjoerg #define	WARN(a)			do { \
42*eb6cc752Sjoerg 					(void)printf a; \
43*eb6cc752Sjoerg 					if (errno) \
44*eb6cc752Sjoerg 						(void)printf(": %s\n", \
45*eb6cc752Sjoerg 						             strerror(errno)); \
46*eb6cc752Sjoerg 					else \
47*eb6cc752Sjoerg 						(void)printf("\n"); \
48*eb6cc752Sjoerg 				} while(/* CONSTCOND */0)
49b40179bdSchristos #define PROGRESS(a)		(void) printf a
50b40179bdSchristos #define ALLOC(a)		alloc(a)
51606bb2caSchristos #define DEALLOC(a, b)		dealloc(a, b)
52b40179bdSchristos #define OKMAGIC(a)		((a) == OMAGIC)
53b40179bdSchristos #else
5444a3eec3Smrg #define LOADADDR(a)		(((u_long)(a)) + (u_long)offset)
55b40179bdSchristos #define ALIGNENTRY(a)		((u_long)(a))
56b40179bdSchristos #define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
57b40179bdSchristos #define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
58b40179bdSchristos #define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
59b40179bdSchristos #define WARN(a)			warn a
60b40179bdSchristos #define PROGRESS(a)		/* nothing */
61b40179bdSchristos #define ALLOC(a)		malloc(a)
62b40179bdSchristos #define FREE(a, b)		free(a)
63b40179bdSchristos #define OKMAGIC(a)		((a) == OMAGIC)
64b40179bdSchristos #endif
65