1*7529c7ccShe /* $NetBSD: core.h,v 1.12 2009/08/20 22:07:49 he Exp $ */ 2fccfa11aScgd 318da157aSpk /*- 418da157aSpk * Copyright (c) 1998 The NetBSD Foundation, Inc. 5d9c1fc92Spk * All rights reserved. 6d9c1fc92Spk * 718da157aSpk * This code is derived from software contributed to The NetBSD Foundation 818da157aSpk * by Paul Kranenburg. 918da157aSpk * 10d9c1fc92Spk * Redistribution and use in source and binary forms, with or without 11d9c1fc92Spk * modification, are permitted provided that the following conditions 12d9c1fc92Spk * are met: 13d9c1fc92Spk * 1. Redistributions of source code must retain the above copyright 14d9c1fc92Spk * notice, this list of conditions and the following disclaimer. 15d9c1fc92Spk * 2. Redistributions in binary form must reproduce the above copyright 16d9c1fc92Spk * notice, this list of conditions and the following disclaimer in the 17d9c1fc92Spk * documentation and/or other materials provided with the distribution. 18d9c1fc92Spk * 1918da157aSpk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2018da157aSpk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2118da157aSpk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2218da157aSpk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2318da157aSpk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2418da157aSpk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2518da157aSpk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2618da157aSpk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2718da157aSpk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2818da157aSpk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2918da157aSpk * POSSIBILITY OF SUCH DAMAGE. 30d9c1fc92Spk */ 31d9c1fc92Spk 326bd4a3a7Smikel #ifndef _SYS_CORE_H_ 336bd4a3a7Smikel #define _SYS_CORE_H_ 346bd4a3a7Smikel 35d9c1fc92Spk #define COREMAGIC 0507 36d9c1fc92Spk #define CORESEGMAGIC 0510 37d9c1fc92Spk 38d9c1fc92Spk /* 39d9c1fc92Spk * The core structure's c_midmag field (like exec's a_midmag) is a 40d9c1fc92Spk * network-byteorder encoding of this int 41d9c1fc92Spk * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM 42d9c1fc92Spk * Where `F' is 6 bits of flag (currently unused), 43d9c1fc92Spk * `m' is 10 bits of machine-id, and 44d9c1fc92Spk * `M' is 16 bits worth of magic number, ie. COREMAGIC. 45d9c1fc92Spk * The macros below will set/get the needed fields. 46d9c1fc92Spk */ 47d9c1fc92Spk #define CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff ) 48d9c1fc92Spk #define CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff ) 49d9c1fc92Spk #define CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f ) 50d9c1fc92Spk #define CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \ 51d9c1fc92Spk ( ((flag) & 0x3f) << 26) | \ 52d9c1fc92Spk ( ((mid) & 0x03ff) << 16) | \ 53d9c1fc92Spk ( ((mag) & 0xffff) ) ) ) 54d9c1fc92Spk 55d9c1fc92Spk /* Flag definitions */ 56d9c1fc92Spk #define CORE_CPU 1 57d9c1fc92Spk #define CORE_DATA 2 58d9c1fc92Spk #define CORE_STACK 4 59d9c1fc92Spk 60*7529c7ccShe #include <sys/aout_mids.h> 61*7529c7ccShe 62d9c1fc92Spk /* 63d9c1fc92Spk * A core file consists of a header followed by a number of segments. 641e378c4cSwiz * Each segment is preceded by a `coreseg' structure giving the 65d9c1fc92Spk * segment's type, the virtual address where the bits resided in 66d9c1fc92Spk * process address space and the size of the segment. 67d9c1fc92Spk * 68d9c1fc92Spk * The core header specifies the lengths of the core header itself and 69d9c1fc92Spk * each of the following core segment headers to allow for any machine 70d9c1fc92Spk * dependent alignment requirements. 71d9c1fc92Spk */ 72d9c1fc92Spk 73d9c1fc92Spk struct core { 74144515ceSperry uint32_t c_midmag; /* magic, id, flags */ 75144515ceSperry uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 76144515ceSperry uint16_t c_seghdrsize; /* Size of a segment header */ 77144515ceSperry uint32_t c_nseg; /* # of core segments */ 78d9c1fc92Spk char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 79144515ceSperry uint32_t c_signo; /* Killing signal */ 80d9c1fc92Spk u_long c_ucode; /* Hmm ? */ 81d9c1fc92Spk u_long c_cpusize; /* Size of machine dependent segment */ 82d9c1fc92Spk u_long c_tsize; /* Size of traditional text segment */ 83d9c1fc92Spk u_long c_dsize; /* Size of traditional data segment */ 84d9c1fc92Spk u_long c_ssize; /* Size of traditional stack segment */ 85d9c1fc92Spk }; 86d9c1fc92Spk 87d9c1fc92Spk struct coreseg { 88144515ceSperry uint32_t c_midmag; /* magic, id, flags */ 89d9c1fc92Spk u_long c_addr; /* Virtual address of segment */ 90d9c1fc92Spk u_long c_size; /* Size of this segment */ 91d9c1fc92Spk }; 926bd4a3a7Smikel 939701a23cSeeh /* 949701a23cSeeh * 32-bit versions of the above. 959701a23cSeeh */ 969701a23cSeeh struct core32 { 97144515ceSperry uint32_t c_midmag; /* magic, id, flags */ 98144515ceSperry uint16_t c_hdrsize; /* Size of this header (machdep algn) */ 99144515ceSperry uint16_t c_seghdrsize; /* Size of a segment header */ 100144515ceSperry uint32_t c_nseg; /* # of core segments */ 1019701a23cSeeh char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */ 102144515ceSperry uint32_t c_signo; /* Killing signal */ 1039701a23cSeeh u_int c_ucode; /* Hmm ? */ 1049701a23cSeeh u_int c_cpusize; /* Size of machine dependent segment */ 1059701a23cSeeh u_int c_tsize; /* Size of traditional text segment */ 1069701a23cSeeh u_int c_dsize; /* Size of traditional data segment */ 1079701a23cSeeh u_int c_ssize; /* Size of traditional stack segment */ 1089701a23cSeeh }; 1099701a23cSeeh 1109701a23cSeeh struct coreseg32 { 111144515ceSperry uint32_t c_midmag; /* magic, id, flags */ 1129701a23cSeeh u_int c_addr; /* Virtual address of segment */ 1139701a23cSeeh u_int c_size; /* Size of this segment */ 1149701a23cSeeh }; 1159701a23cSeeh 1166bd4a3a7Smikel #endif /* !_SYS_CORE_H_ */ 117