2 * Kernel header file for Linux crash dumps.
4 * Created by: Matt Robinson (yakker@sgi.com)
5 * Copyright 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
7 * vmdump.h to dump.h by: Matt D. Robinson (yakker@sourceforge.net)
8 * Copyright 2001 - 2002 Matt D. Robinson. All rights reserved.
9 * Copyright (C) 2002 Free Software Foundation, Inc. All rights reserved.
11 * Most of this is the same old stuff from vmdump.h, except now we're
12 * actually a stand-alone driver plugged into the block layer interface,
13 * with the exception that we now allow for compression modes externally
14 * loaded (e.g., someone can come up with their own).
16 * This code is released under version 2 of the GNU GPL.
19 /* This header file includes all structure definitions for crash dumps. */
23 #if defined(CONFIG_CRASH_DUMP)
25 #include <linux/list.h>
26 #include <linux/notifier.h>
27 #include <linux/dumpdev.h>
28 #include <asm/ioctl.h>
31 * Predefine default DUMP_PAGE constants, asm header may override.
33 * On ia64 discontinuous memory systems it's possible for the memory
34 * banks to stop at 2**12 page alignments, the smallest possible page
35 * size. But the system page size, PAGE_SIZE, is in fact larger.
37 #define DUMP_PAGE_SHIFT PAGE_SHIFT
38 #define DUMP_PAGE_MASK PAGE_MASK
39 #define DUMP_PAGE_ALIGN(addr) PAGE_ALIGN(addr)
40 #define DUMP_HEADER_OFFSET PAGE_SIZE
42 #define OLDMINORBITS 8
43 #define OLDMINORMASK ((1U << OLDMINORBITS) -1)
45 /* keep DUMP_PAGE_SIZE constant to 4K = 1<<12
46 * it may be different from PAGE_SIZE then.
48 #define DUMP_PAGE_SIZE 4096
51 * Predefined default memcpy() to use when copying memory to the dump buffer.
53 * On ia64 there is a heads up function that can be called to let the prom
54 * machine check monitor know that the current activity is risky and it should
55 * ignore the fault (nofault). In this case the ia64 header will redefine this
56 * macro to __dump_memcpy() and use it's arch specific version.
58 #define DUMP_memcpy memcpy
60 /* necessary header files */
61 #include <asm/dump.h> /* for architecture-specific header */
64 * Size of the buffer that's used to hold:
66 * 1. the dump header (padded to fill the complete buffer)
67 * 2. the possibly compressed page headers and data
69 #define DUMP_BUFFER_SIZE (64 * 1024) /* size of dump buffer */
70 #define DUMP_HEADER_SIZE DUMP_BUFFER_SIZE
72 /* standard header definitions */
73 #define DUMP_MAGIC_NUMBER 0xa8190173618f23edULL /* dump magic number */
74 #define DUMP_MAGIC_LIVE 0xa8190173618f23cdULL /* live magic number */
75 #define DUMP_VERSION_NUMBER 0x8 /* dump version number */
76 #define DUMP_PANIC_LEN 0x100 /* dump panic string length */
78 /* dump levels - type specific stuff added later -- add as necessary */
79 #define DUMP_LEVEL_NONE 0x0 /* no dumping at all -- just bail */
80 #define DUMP_LEVEL_HEADER 0x1 /* kernel dump header only */
81 #define DUMP_LEVEL_KERN 0x2 /* dump header and kernel pages */
82 #define DUMP_LEVEL_USED 0x4 /* dump header, kernel/user pages */
83 #define DUMP_LEVEL_ALL_RAM 0x8 /* dump header, all RAM pages */
84 #define DUMP_LEVEL_ALL 0x10 /* dump all memory RAM and firmware */
87 /* dump compression options -- add as necessary */
88 #define DUMP_COMPRESS_NONE 0x0 /* don't compress this dump */
89 #define DUMP_COMPRESS_RLE 0x1 /* use RLE compression */
90 #define DUMP_COMPRESS_GZIP 0x2 /* use GZIP compression */
92 /* dump flags - any dump-type specific flags -- add as necessary */
93 #define DUMP_FLAGS_NONE 0x0 /* no flags are set for this dump */
94 #define DUMP_FLAGS_SOFTBOOT 0x2 /* 2 stage soft-boot based dump */
95 #define DUMP_FLAGS_NONDISRUPT 0X1 /* non-disruptive dumping */
97 #define DUMP_FLAGS_TARGETMASK 0xf0000000 /* handle special case targets */
98 #define DUMP_FLAGS_DISKDUMP 0x80000000 /* dump to local disk */
99 #define DUMP_FLAGS_NETDUMP 0x40000000 /* dump over the network */
101 /* dump header flags -- add as necessary */
102 #define DUMP_DH_FLAGS_NONE 0x0 /* no flags set (error condition!) */
103 #define DUMP_DH_RAW 0x1 /* raw page (no compression) */
104 #define DUMP_DH_COMPRESSED 0x2 /* page is compressed */
105 #define DUMP_DH_END 0x4 /* end marker on a full dump */
106 #define DUMP_DH_TRUNCATED 0x8 /* dump is incomplete */
107 #define DUMP_DH_TEST_PATTERN 0x10 /* dump page is a test pattern */
108 #define DUMP_DH_NOT_USED 0x20 /* 1st bit not used in flags */
110 /* names for various dump parameters in /proc/kernel */
111 #define DUMP_ROOT_NAME "sys/dump"
112 #define DUMP_DEVICE_NAME "device"
113 #define DUMP_COMPRESS_NAME "compress"
114 #define DUMP_LEVEL_NAME "level"
115 #define DUMP_FLAGS_NAME "flags"
116 #define DUMP_ADDR_NAME "addr"
118 #define DUMP_SYSRQ_KEY 'd' /* key to use for MAGIC_SYSRQ key */
120 /* CTL_DUMP names: */
132 /* page size for gzip compression -- buffered slightly beyond hardware PAGE_SIZE used by DUMP */
133 #define DUMP_DPC_PAGE_SIZE (DUMP_PAGE_SIZE + 512)
135 /* dump ioctl() control options */
136 #define DIOSDUMPDEV _IOW('p', 0xA0, unsigned int) /* set the dump device */
137 #define DIOGDUMPDEV _IOR('p', 0xA1, unsigned int) /* get the dump device */
138 #define DIOSDUMPLEVEL _IOW('p', 0xA2, unsigned int) /* set the dump level */
139 #define DIOGDUMPLEVEL _IOR('p', 0xA3, unsigned int) /* get the dump level */
140 #define DIOSDUMPFLAGS _IOW('p', 0xA4, unsigned int) /* set the dump flag parameters */
141 #define DIOGDUMPFLAGS _IOR('p', 0xA5, unsigned int) /* get the dump flag parameters */
142 #define DIOSDUMPCOMPRESS _IOW('p', 0xA6, unsigned int) /* set the dump compress level */
143 #define DIOGDUMPCOMPRESS _IOR('p', 0xA7, unsigned int) /* get the dump compress level */
145 /* these ioctls are used only by netdump module */
146 #define DIOSTARGETIP _IOW('p', 0xA8, unsigned int) /* set the target m/c's ip */
147 #define DIOGTARGETIP _IOR('p', 0xA9, unsigned int) /* get the target m/c's ip */
148 #define DIOSTARGETPORT _IOW('p', 0xAA, unsigned int) /* set the target m/c's port */
149 #define DIOGTARGETPORT _IOR('p', 0xAB, unsigned int) /* get the target m/c's port */
150 #define DIOSSOURCEPORT _IOW('p', 0xAC, unsigned int) /* set the source m/c's port */
151 #define DIOGSOURCEPORT _IOR('p', 0xAD, unsigned int) /* get the source m/c's port */
152 #define DIOSETHADDR _IOW('p', 0xAE, unsigned int) /* set ethernet address */
153 #define DIOGETHADDR _IOR('p', 0xAF, unsigned int) /* get ethernet address */
154 #define DIOGDUMPOKAY _IOR('p', 0xB0, unsigned int) /* check if dump is configured */
155 #define DIOSDUMPTAKE _IOW('p', 0xB1, unsigned int) /* Take a manual dump */
158 * Structure: __dump_header
159 * Function: This is the header dumped at the top of every valid crash
162 struct __dump_header {
163 /* the dump magic number -- unique to verify dump is valid */
166 /* the version number of this dump */
169 /* the size of this header (in case we can't read it) */
172 /* the level of this dump (just a header?) */
176 * We assume dump_page_size to be 4K in every case.
177 * Store here the configurable system page size (4K, 8K, 16K, etc.)
181 /* the size of all physical memory */
184 /* the start of physical memory */
187 /* the end of physical memory */
190 /* the number of hardware/physical pages in this dump specifically */
191 u32 dh_num_dump_pages;
193 /* the panic string, if available */
194 char dh_panic_string[DUMP_PANIC_LEN];
196 /* timeval depends on architecture, two long values */
200 } dh_time; /* the time of the system crash */
202 /* the NEW utsname (uname) information -- in character form */
203 /* we do this so we don't have to include utsname.h */
204 /* plus it helps us be more architecture independent */
205 /* now maybe one day soon they'll make the [65] a #define! */
206 char dh_utsname_sysname[65];
207 char dh_utsname_nodename[65];
208 char dh_utsname_release[65];
209 char dh_utsname_version[65];
210 char dh_utsname_machine[65];
211 char dh_utsname_domainname[65];
213 /* the address of current task (OLD = void *, NEW = u64) */
216 /* what type of compression we're using in this dump (if any) */
217 u32 dh_dump_compress;
219 /* any additional flags */
222 /* any additional flags */
224 } __attribute__((packed));
227 * Structure: __dump_page
228 * Function: To act as the header associated to each physical page of
229 * memory saved in the system crash dump. This allows for
230 * easy reassembly of each crash dump page. The address bits
231 * are split to make things easier for 64-bit/32-bit system
234 * dp_byte_offset and dp_page_index are landmarks that are helpful when
235 * looking at a hex dump of /dev/vmdump,
238 /* the address of this dump page */
241 /* the size of this dump page */
244 /* flags (currently DUMP_COMPRESSED, DUMP_RAW or DUMP_END) */
246 } __attribute__((packed));
249 * Structure: __lkcdinfo
250 * Function: This structure contains information needed for the lkcdutils
251 * package (particularly lcrash) to determine what information is
252 * associated to this kernel, specifically.
269 * Structure: __dump_compress
270 * Function: This is what an individual compression mechanism can use
271 * to plug in their own compression techniques. It's always
272 * best to build these as individual modules so that people
273 * can put in whatever they want.
275 struct __dump_compress {
276 /* the list_head structure for list storage */
277 struct list_head list;
279 /* the type of compression to use (DUMP_COMPRESS_XXX) */
281 const char *compress_name;
283 /* the compression function to call */
284 u16 (*compress_func)(const u8 *, u16, u8 *, u16);
287 /* functions for dump compression registration */
288 extern void dump_register_compression(struct __dump_compress *);
289 extern void dump_unregister_compression(int);
292 * Structure dump_mbank[]:
294 * For CONFIG_DISCONTIGMEM systems this array specifies the
295 * memory banks/chunks that need to be dumped after a panic.
297 * For classic systems it specifies a single set of pages from
300 struct __dump_mbank {
308 #define DUMP_MBANK_TYPE_CONVENTIONAL_MEMORY 1
309 #define DUMP_MBANK_TYPE_OTHER 2
311 #define MAXCHUNKS 256
312 extern int dump_mbanks;
313 extern struct __dump_mbank dump_mbank[MAXCHUNKS];
315 /* notification event codes */
316 #define DUMP_BEGIN 0x0001 /* dump beginning */
317 #define DUMP_END 0x0002 /* dump ending */
319 /* Scheduler soft spin control.
321 * 0 - no dump in progress
322 * 1 - cpu0 is dumping, ...
324 extern unsigned long dump_oncpu;
325 extern void dump_execute(const char *, const struct pt_regs *);
328 * Notifier list for kernel code which wants to be called
331 extern struct notifier_block *dump_notifier_list;
332 static inline int register_dump_notifier(struct notifier_block *nb)
334 return notifier_chain_register(&dump_notifier_list, nb);
336 static inline int unregister_dump_notifier(struct notifier_block * nb)
338 return notifier_chain_unregister(&dump_notifier_list, nb);
341 extern void (*dump_function_ptr)(const char *, const struct pt_regs *);
342 static inline void dump(char * str, struct pt_regs * regs)
344 if (dump_function_ptr)
345 dump_function_ptr(str, regs);
349 * Common Arch Specific Functions should be declared here.
350 * This allows the C compiler to detect discrepancies.
352 extern void __dump_open(void);
353 extern void __dump_cleanup(void);
354 extern void __dump_init(u64);
355 extern void __dump_save_regs(struct pt_regs *, const struct pt_regs *);
356 extern int __dump_configure_header(const struct pt_regs *);
357 extern int __dump_irq_enable(void);
358 extern void __dump_irq_restore(void);
359 extern int __dump_page_valid(unsigned long index);
361 extern void __dump_save_other_cpus(void);
363 #define __dump_save_other_cpus()
366 extern int manual_handle_crashdump(void);
368 /* to track all used (compound + zero order) pages */
369 #define PageInuse(p) (PageCompound(p) || page_count(p))
371 #endif /* __KERNEL__ */
373 #else /* !CONFIG_CRASH_DUMP */
375 /* If not configured then make code disappear! */
376 #define register_dump_watchdog(x) do { } while(0)
377 #define unregister_dump_watchdog(x) do { } while(0)
378 #define register_dump_notifier(x) do { } while(0)
379 #define unregister_dump_notifier(x) do { } while(0)
380 #define dump_in_progress() 0
381 #define dump(x, y) do { } while(0)
383 #endif /* !CONFIG_CRASH_DUMP */