1 /* $NetBSD: core.h,v 1.13 2026/01/08 15:39:08 nia 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 #include <sys/endian.h> /* ntohl(3) */ 36 37 #define COREMAGIC 0507 38 #define CORESEGMAGIC 0510 39 40 /* 41 * The core structure's c_midmag field (like exec's a_midmag) is a 42 * network-byteorder encoding of this int 43 * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM 44 * Where `F' is 6 bits of flag (currently unused), 45 * `m' is 10 bits of machine-id, and 46 * `M' is 16 bits worth of magic number, ie. COREMAGIC. 47 * The macros below will set/get the needed fields. 48 */ 49 #define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff ) 50 #define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff ) 51 #define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f ) 52 #define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \ 53 ( ((flag) & 0x3f) << 26) | \ 54 ( ((mid) & 0x03ff) << 16) | \ 55 ( ((mag) & 0xffff) ) ) ) 56 57 /* Flag definitions */ 58 #define CORE_CPU 1 59 #define CORE_DATA 2 60 #define CORE_STACK 4 61 62 #include <sys/aout_mids.h> 63 64 /* 65 * A core file consists of a header followed by a number of segments. 66 * Each segment is preceded by a `coreseg' structure giving the 67 * segment's type, the virtual address where the bits resided in 68 * process address space and the size of the segment. 69 * 70 * The core header specifies the lengths of the core header itself and 71 * each of the following core segment headers to allow for any machine 72 * dependent alignment requirements. 73 */ 74 75 struct core { 76 uint32_t c_midmag; /* magic, id, flags */ 77 uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 78 uint16_t c_seghdrsize; /* Size of a segment header */ 79 uint32_t c_nseg; /* # of core segments */ 80 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 81 uint32_t c_signo; /* Killing signal */ 82 u_long c_ucode; /* Hmm ? */ 83 u_long c_cpusize; /* Size of machine dependent segment */ 84 u_long c_tsize; /* Size of traditional text segment */ 85 u_long c_dsize; /* Size of traditional data segment */ 86 u_long c_ssize; /* Size of traditional stack segment */ 87 }; 88 89 struct coreseg { 90 uint32_t c_midmag; /* magic, id, flags */ 91 u_long c_addr; /* Virtual address of segment */ 92 u_long c_size; /* Size of this segment */ 93 }; 94 95 /* 96 * 32-bit versions of the above. 97 */ 98 struct core32 { 99 uint32_t c_midmag; /* magic, id, flags */ 100 uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 101 uint16_t c_seghdrsize; /* Size of a segment header */ 102 uint32_t c_nseg; /* # of core segments */ 103 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 104 uint32_t c_signo; /* Killing signal */ 105 u_int c_ucode; /* Hmm ? */ 106 u_int c_cpusize; /* Size of machine dependent segment */ 107 u_int c_tsize; /* Size of traditional text segment */ 108 u_int c_dsize; /* Size of traditional data segment */ 109 u_int c_ssize; /* Size of traditional stack segment */ 110 }; 111 112 struct coreseg32 { 113 uint32_t c_midmag; /* magic, id, flags */ 114 u_int c_addr; /* Virtual address of segment */ 115 u_int c_size; /* Size of this segment */ 116 }; 117 118 #endif /* !_SYS_CORE_H_ */ 119