1 /* $NetBSD: core.h,v 1.11 2008/04/28 20:24:10 martin Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Paul Kranenburg. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _SYS_CORE_H_ 33 #define _SYS_CORE_H_ 34 35 #define COREMAGIC 0507 36 #define CORESEGMAGIC 0510 37 38 /* 39 * The core structure's c_midmag field (like exec's a_midmag) is a 40 * network-byteorder encoding of this int 41 * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM 42 * Where `F' is 6 bits of flag (currently unused), 43 * `m' is 10 bits of machine-id, and 44 * `M' is 16 bits worth of magic number, ie. COREMAGIC. 45 * The macros below will set/get the needed fields. 46 */ 47 #define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff ) 48 #define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff ) 49 #define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f ) 50 #define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \ 51 ( ((flag) & 0x3f) << 26) | \ 52 ( ((mid) & 0x03ff) << 16) | \ 53 ( ((mag) & 0xffff) ) ) ) 54 55 /* Flag definitions */ 56 #define CORE_CPU 1 57 #define CORE_DATA 2 58 #define CORE_STACK 4 59 60 /* 61 * A core file consists of a header followed by a number of segments. 62 * Each segment is preceded by a `coreseg' structure giving the 63 * segment's type, the virtual address where the bits resided in 64 * process address space and the size of the segment. 65 * 66 * The core header specifies the lengths of the core header itself and 67 * each of the following core segment headers to allow for any machine 68 * dependent alignment requirements. 69 */ 70 71 struct core { 72 uint32_t c_midmag; /* magic, id, flags */ 73 uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 74 uint16_t c_seghdrsize; /* Size of a segment header */ 75 uint32_t c_nseg; /* # of core segments */ 76 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 77 uint32_t c_signo; /* Killing signal */ 78 u_long c_ucode; /* Hmm ? */ 79 u_long c_cpusize; /* Size of machine dependent segment */ 80 u_long c_tsize; /* Size of traditional text segment */ 81 u_long c_dsize; /* Size of traditional data segment */ 82 u_long c_ssize; /* Size of traditional stack segment */ 83 }; 84 85 struct coreseg { 86 uint32_t c_midmag; /* magic, id, flags */ 87 u_long c_addr; /* Virtual address of segment */ 88 u_long c_size; /* Size of this segment */ 89 }; 90 91 /* 92 * 32-bit versions of the above. 93 */ 94 struct core32 { 95 uint32_t c_midmag; /* magic, id, flags */ 96 uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 97 uint16_t c_seghdrsize; /* Size of a segment header */ 98 uint32_t c_nseg; /* # of core segments */ 99 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 100 uint32_t c_signo; /* Killing signal */ 101 u_int c_ucode; /* Hmm ? */ 102 u_int c_cpusize; /* Size of machine dependent segment */ 103 u_int c_tsize; /* Size of traditional text segment */ 104 u_int c_dsize; /* Size of traditional data segment */ 105 u_int c_ssize; /* Size of traditional stack segment */ 106 }; 107 108 struct coreseg32 { 109 uint32_t c_midmag; /* magic, id, flags */ 110 u_int c_addr; /* Virtual address of segment */ 111 u_int c_size; /* Size of this segment */ 112 }; 113 114 #endif /* !_SYS_CORE_H_ */ 115