1/* $NetBSD: core.h,v 1.12 2009/08/20 22:07:49 he 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#include <sys/aout_mids.h>
61
62/*
63 * A core file consists of a header followed by a number of segments.
64 * Each segment is preceded by a `coreseg' structure giving the
65 * segment's type, the virtual address where the bits resided in
66 * process address space and the size of the segment.
67 *
68 * The core header specifies the lengths of the core header itself and
69 * each of the following core segment headers to allow for any machine
70 * dependent alignment requirements.
71 */
72
73struct core {
74 uint32_t c_midmag; /* magic, id, flags */
75 uint16_t c_hdrsize; /* Size of this header (machdep algn) */
76 uint16_t c_seghdrsize; /* Size of a segment header */
77 uint32_t c_nseg; /* # of core segments */
78 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
79 uint32_t c_signo; /* Killing signal */
80 u_long c_ucode; /* Hmm ? */
81 u_long c_cpusize; /* Size of machine dependent segment */
82 u_long c_tsize; /* Size of traditional text segment */
83 u_long c_dsize; /* Size of traditional data segment */
84 u_long c_ssize; /* Size of traditional stack segment */
85};
86
87struct coreseg {
88 uint32_t c_midmag; /* magic, id, flags */
89 u_long c_addr; /* Virtual address of segment */
90 u_long c_size; /* Size of this segment */
91};
92
93/*
94 * 32-bit versions of the above.
95 */
96struct core32 {
97 uint32_t c_midmag; /* magic, id, flags */
98 uint16_t c_hdrsize; /* Size of this header (machdep algn) */
99 uint16_t c_seghdrsize; /* Size of a segment header */
100 uint32_t c_nseg; /* # of core segments */
101 char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
102 uint32_t c_signo; /* Killing signal */
103 u_int c_ucode; /* Hmm ? */
104 u_int c_cpusize; /* Size of machine dependent segment */
105 u_int c_tsize; /* Size of traditional text segment */
106 u_int c_dsize; /* Size of traditional data segment */
107 u_int c_ssize; /* Size of traditional stack segment */
108};
109
110struct coreseg32 {
111 uint32_t c_midmag; /* magic, id, flags */
112 u_int c_addr; /* Virtual address of segment */
113 u_int c_size; /* Size of this segment */
114};
115
116#endif /* !_SYS_CORE_H_ */
117