loadfile_machdep.h revision 1.1
11.1Sthorpej/* $NetBSD: loadfile_machdep.h,v 1.1 1999/12/14 20:52:58 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. 51.1Sthorpej * All rights reserved. 61.1Sthorpej * 71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation 81.1Sthorpej * by Christos Zoulas and Jason R. Thorpe. 91.1Sthorpej * 101.1Sthorpej * Redistribution and use in source and binary forms, with or without 111.1Sthorpej * modification, are permitted provided that the following conditions 121.1Sthorpej * are met: 131.1Sthorpej * 1. Redistributions of source code must retain the above copyright 141.1Sthorpej * notice, this list of conditions and the following disclaimer. 151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer in the 171.1Sthorpej * documentation and/or other materials provided with the distribution. 181.1Sthorpej * 3. All advertising materials mentioning features or use of this software 191.1Sthorpej * must display the following acknowledgement: 201.1Sthorpej * This product includes software developed by the NetBSD 211.1Sthorpej * Foundation, Inc. and its contributors. 221.1Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sthorpej * contributors may be used to endorse or promote products derived 241.1Sthorpej * from this software without specific prior written permission. 251.1Sthorpej * 261.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 371.1Sthorpej */ 381.1Sthorpej 391.1Sthorpej/* 401.1Sthorpej * XXX THIS DOES NOT WORK PROPERLY YET! 411.1Sthorpej */ 421.1Sthorpej 431.1Sthorpej#define ELFSIZE 32 441.1Sthorpej 451.1Sthorpej#define LOAD_KERNEL (LOAD_ALL & ~LOAD_HDR) 461.1Sthorpej#define COUNT_KERNEL (COUNT_ALL & ~COUNT_HDR) 471.1Sthorpej 481.1Sthorpej#ifdef _STANDALONE 491.1Sthorpej 501.1Sthorpej#define LOADADDR(a) ((a) + offset) 511.1Sthorpej#define ALIGNENTRY(a) 0 521.1Sthorpej#define READ(f, b, c) pread((f), (void *)LOADADDR(b), (c)) 531.1Sthorpej#define BCOPY(s, d, c) vpbcopy((s), (void *)LOADADDR(d), (c)) 541.1Sthorpej#define BZERO(d, c) pbzero((void *)LOADADDR(d), (c)) 551.1Sthorpej#define WARN(a) (void)(printf a, \ 561.1Sthorpej printf((errno ? ": %s\n" : "\n"), \ 571.1Sthorpej strerror(errno))) 581.1Sthorpej#define PROGRESS(a) (void) printf a 591.1Sthorpej#define ALLOC(a) alloc(a) 601.1Sthorpej#define FREE(a, b) free(a, b) 611.1Sthorpej#define OKMAGIC(a) ((a) == OMAGIC || (a) == NMAGIC || \ 621.1Sthorpej (a) == ZMAGIC) 631.1Sthorpej 641.1Sthorpej#define vpbcopy bcopy 651.1Sthorpej#define pbzero bzero 661.1Sthorpej#define pread read 671.1Sthorpej 681.1Sthorpej#else 691.1Sthorpej 701.1Sthorpej/* 711.1Sthorpej * XXX Not right, and we don't use it in userland yet. 721.1Sthorpej */ 731.1Sthorpej 741.1Sthorpej#define LOADADDR(a) (((u_long)(a)) + offset) 751.1Sthorpej#define ALIGNENTRY(a) ((u_long)(a)) 761.1Sthorpej#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c)) 771.1Sthorpej#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c)) 781.1Sthorpej#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c)) 791.1Sthorpej#define WARN(a) warn a 801.1Sthorpej#define PROGRESS(a) /* nothing */ 811.1Sthorpej#define ALLOC(a) malloc(a) 821.1Sthorpej#define FREE(a, b) free(a) 831.1Sthorpej#define OKMAGIC(a) ((a) == OMAGIC) 841.1Sthorpej 851.1Sthorpejssize_t vread __P((int, u_long, u_long *, size_t)); 861.1Sthorpejvoid vcopy __P((u_long, u_long, u_long *, size_t)); 871.1Sthorpejvoid vzero __P((u_long, u_long *, size_t)); 881.1Sthorpej 891.1Sthorpej#endif 90