| 1 | /*	$OpenBSD: core.h,v 1.9 2024/01/17 22:22:25 kurt Exp $	*/ |
| 2 | /*	$NetBSD: core.h,v 1.4 1994/10/29 08:20:14 cgd Exp $	*/ |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1994 Paul Kranenburg |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. All advertising materials mentioning features or use of this software |
| 17 | * must display the following acknowledgement: |
| 18 | * This product includes software developed by Paul Kranenburg. |
| 19 | * 4. The name of the author may not be used to endorse or promote products |
| 20 | * derived from this software without specific prior written permission |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #define COREMAGIC	0507 |
| 35 | #define CORESEGMAGIC	0510 |
| 36 | |
| 37 | /* |
| 38 | * The core structure's c_midmag field (like exec's a_midmag) is a |
| 39 | * network-byteorder encoding of this int |
| 40 | *	FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM |
| 41 | * Where `F' is 6 bits of flag (currently unused), |
| 42 | * `m' is 10 bits of machine-id, and |
| 43 | * `M' is 16 bits worth of magic number, ie. COREMAGIC. |
| 44 | * The macros below will set/get the needed fields. |
| 45 | */ |
| 46 | #define	CORE_GETMAGIC(c) ( ntohl(((c).c_midmag)) & 0xffff ) |
| 47 | #define	CORE_GETMID(c) ( (ntohl(((c).c_midmag)) >> 16) & 0x03ff ) |
| 48 | #define	CORE_GETFLAG(c) ( (ntohl(((c).c_midmag)) >> 26) & 0x03f ) |
| 49 | #define	CORE_SETMAGIC(c,mag,mid,flag) ( (c).c_midmag = htonl ( \ |
| 50 | 			( ((flag) & 0x3f) << 26) | \ |
| 51 | 			( ((mid) & 0x03ff) << 16) | \ |
| 52 | 			( ((mag) & 0xffff) ) ) ) |
| 53 | |
| 54 | /* Flag definitions */ |
| 55 | #define CORE_CPU	1 |
| 56 | #define CORE_DATA	2 |
| 57 | #define CORE_STACK	4 |
| 58 | |
| 59 | #ifndef _KERNEL |
| 60 | /* |
| 61 | * XXX OBSOLETE, NO LONGER USED |
| 62 | * XXX This header file exists to support binutils' netbsd-core format |
| 63 | * XXX which is still needed for the a.out-m88k-openbsd use in luna88k |
| 64 | * XXX boot block creation. |
| 65 | * |
| 66 | * A core file consists of a header followed by a number of segments. |
| 67 | * Each segment is preceded by a `coreseg' structure giving the |
| 68 | * segment's type, the virtual address where the bits resided in |
| 69 | * process address space and the size of the segment. |
| 70 | * |
| 71 | * The core header specifies the lengths of the core header itself and |
| 72 | * each of the following core segment headers to allow for any machine |
| 73 | * dependent alignment requirements. |
| 74 | */ |
| 75 | |
| 76 | struct core { |
| 77 | 	u_int32_t c_midmag;		/* magic, id, flags */ |
| 78 | 	u_int16_t c_hdrsize;		/* Size of this header (machdep algn) */ |
| 79 | 	u_int16_t c_seghdrsize;		/* Size of a segment header */ |
| 80 | 	u_int32_t c_nseg;		/* # of core segments */ |
| 81 | 	char	c_name[_MAXCOMLEN];	/* Copy of p->p_comm, incl NUL */ |
| 82 | 	u_int32_t c_signo;		/* Killing signal */ |
| 83 | 	u_long	c_ucode;		/* Hmm ? */ |
| 84 | 	u_long	c_cpusize;		/* Size of machine dependent segment */ |
| 85 | 	u_long	c_tsize;		/* Size of traditional text segment */ |
| 86 | 	u_long	c_dsize;		/* Size of traditional data segment */ |
| 87 | 	u_long	c_ssize;		/* Size of traditional stack segment */ |
| 88 | }; |
| 89 | |
| 90 | struct coreseg { |
| 91 | 	u_int32_t c_midmag;		/* magic, id, flags */ |
| 92 | 	u_long	c_addr;			/* Virtual address of segment */ |
| 93 | 	u_long	c_size;			/* Size of this segment */ |
| 94 | }; |
| 95 | |
| 96 | #else |
| 97 | int	coredump_write(void *, enum uio_seg, const void *, size_t, int); |
| 98 | void	coredump_unmap(void *, vaddr_t, vaddr_t); |
| 99 | #endif |