loadfile_machdep.h revision 1.4
11.4Schristos/*	$NetBSD: loadfile_machdep.h,v 1.4 2006/01/25 18:28:25 christos 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 * 3. All advertising materials mentioning features or use of this software
191.1Sross *    must display the following acknowledgement:
201.1Sross *        This product includes software developed by the NetBSD
211.1Sross *        Foundation, Inc. and its contributors.
221.1Sross * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Sross *    contributors may be used to endorse or promote products derived
241.1Sross *    from this software without specific prior written permission.
251.1Sross *
261.1Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Sross * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Sross * POSSIBILITY OF SUCH DAMAGE.
371.1Sross */
381.1Sross
391.1Sross#define LOAD_KERNEL	(LOAD_ALL & ~LOAD_TEXTA)
401.1Sross#define COUNT_KERNEL	(COUNT_ALL & ~COUNT_TEXTA)
411.1Sross
421.1Sross#ifdef _STANDALONE
431.1Sross
441.1Sross#define LOADADDR(a)		((a) + offset)
451.1Sross#define ALIGNENTRY(a)		Error! alpha supports ECOFF and ELF only!
461.1Sross#define READ(f, b, c)		pread((f), (void *)LOADADDR(b), (c))
471.1Sross#define BCOPY(s, d, c)		vpbcopy((s), (void *)LOADADDR(d), (c))
481.1Sross#define BZERO(d, c)		pbzero((void *)LOADADDR(d), (c))
491.1Sross#define	WARN(a)			(void)(printf a, \
501.1Sross				    printf((errno ? ": %s\n" : "\n"), \
511.1Sross				    strerror(errno)))
521.1Sross#define PROGRESS(a)		(void) printf a
531.1Sross#define ALLOC(a)		alloc(a)
541.4Schristos#define DEALLOC(a, b)		dealloc(a, b)
551.1Sross#define OKMAGIC(a)		Error! alpha supports ECOFF and ELF only!
561.1Sross
571.1Sross#define	vpbcopy bcopy
581.1Sross#define	pbzero  bzero
591.1Sross#define pread   read
601.1Sross
611.1Sross#else
621.1Sross
631.1Sross#define LOADADDR(a)		(((u_long)(a)) + offset)
641.1Sross#define ALIGNENTRY(a)		((u_long)(a))
651.1Sross#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
661.1Sross#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
671.1Sross#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
681.1Sross#define WARN(a)			warn a
691.1Sross#define PROGRESS(a)		/* nothing */
701.1Sross#define ALLOC(a)		malloc(a)
711.4Schristos#define DEALLOC(a, b)		free(a)
721.1Sross#define OKMAGIC(a)		((a) == OMAGIC)
731.1Sross
741.2Sthorpejssize_t vread(int, u_long, u_long *, size_t);
751.2Sthorpejvoid vcopy(u_long, u_long, u_long *, size_t);
761.2Sthorpejvoid vzero(u_long, u_long *, size_t);
771.1Sross
781.1Sross#endif
79