11.6Sjoerg/*	$NetBSD: loadfile_machdep.h,v 1.6 2014/08/06 21:57:48 joerg Exp $	 */
21.1Sross
31.1Sross/*-
41.1Sross * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.1Sross * All rights reserved.
61.1Sross *
71.1Sross * This code is derived from software contributed to The NetBSD Foundation
81.1Sross * by Christos Zoulas and Ross Harvey.
91.1Sross *
101.1Sross * Redistribution and use in source and binary forms, with or without
111.1Sross * modification, are permitted provided that the following conditions
121.1Sross * are met:
131.1Sross * 1. Redistributions of source code must retain the above copyright
141.1Sross *    notice, this list of conditions and the following disclaimer.
151.1Sross * 2. Redistributions in binary form must reproduce the above copyright
161.1Sross *    notice, this list of conditions and the following disclaimer in the
171.1Sross *    documentation and/or other materials provided with the distribution.
181.1Sross *
191.1Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sross * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sross * POSSIBILITY OF SUCH DAMAGE.
301.1Sross */
311.1Sross
321.1Sross#define LOAD_KERNEL	(LOAD_ALL & ~LOAD_TEXTA)
331.1Sross#define COUNT_KERNEL	(COUNT_ALL & ~COUNT_TEXTA)
341.1Sross
351.1Sross#ifdef _STANDALONE
361.1Sross
371.1Sross#define LOADADDR(a)		((a) + offset)
381.1Sross#define ALIGNENTRY(a)		Error! alpha supports ECOFF and ELF only!
391.1Sross#define READ(f, b, c)		pread((f), (void *)LOADADDR(b), (c))
401.1Sross#define BCOPY(s, d, c)		vpbcopy((s), (void *)LOADADDR(d), (c))
411.1Sross#define BZERO(d, c)		pbzero((void *)LOADADDR(d), (c))
421.6Sjoerg#define	WARN(a)			do { \
431.6Sjoerg					(void)printf a; \
441.6Sjoerg					if (errno) \
451.6Sjoerg						(void)printf(": %s\n", \
461.6Sjoerg						             strerror(errno)); \
471.6Sjoerg					else \
481.6Sjoerg						(void)printf("\n"); \
491.6Sjoerg				} while(/* CONSTCOND */0)
501.1Sross#define PROGRESS(a)		(void) printf a
511.1Sross#define ALLOC(a)		alloc(a)
521.4Schristos#define DEALLOC(a, b)		dealloc(a, b)
531.1Sross#define OKMAGIC(a)		Error! alpha supports ECOFF and ELF only!
541.1Sross
551.1Sross#define	vpbcopy bcopy
561.1Sross#define	pbzero  bzero
571.1Sross#define pread   read
581.1Sross
591.1Sross#else
601.1Sross
611.1Sross#define LOADADDR(a)		(((u_long)(a)) + offset)
621.1Sross#define ALIGNENTRY(a)		((u_long)(a))
631.1Sross#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
641.1Sross#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
651.1Sross#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
661.1Sross#define WARN(a)			warn a
671.1Sross#define PROGRESS(a)		/* nothing */
681.1Sross#define ALLOC(a)		malloc(a)
691.4Schristos#define DEALLOC(a, b)		free(a)
701.1Sross#define OKMAGIC(a)		((a) == OMAGIC)
711.1Sross
721.2Sthorpejssize_t vread(int, u_long, u_long *, size_t);
731.2Sthorpejvoid vcopy(u_long, u_long, u_long *, size_t);
741.2Sthorpejvoid vzero(u_long, u_long *, size_t);
751.1Sross
761.1Sross#endif
77