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