1 #ifndef _LINUX_DISKDUMP_H
2 #define _LINUX_DISKDUMP_H
5 * linux/include/linux/diskdump.h
7 * Copyright (c) 2004 FUJITSU LIMITED
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <linux/list.h>
26 #include <linux/blkdev.h>
27 #include <linux/utsname.h>
28 #include <linux/device.h>
30 /* The minimum Dump I/O unit. Must be the same of PAGE_SIZE */
31 #define DUMP_BLOCK_SIZE PAGE_SIZE
32 #define DUMP_BLOCK_SHIFT PAGE_SHIFT
34 int diskdump_register_hook(void (*dump_func)(struct pt_regs *));
35 void diskdump_unregister_hook(void);
38 * The handler of diskdump module
40 struct disk_dump_ops {
41 int (*add_dump)(struct device *, struct block_device *);
42 int (*remove_dump)(struct block_device *);
43 int (*find_dump)(struct block_device *);
46 int diskdump_register_ops(struct disk_dump_ops* op);
47 void diskdump_unregister_ops(void);
51 * The handler that adapter driver provides for the common module of
54 struct disk_dump_partition;
55 struct disk_dump_device;
57 struct disk_dump_type {
58 void *(*probe)(struct device *);
59 int (*add_device)(struct disk_dump_device *);
60 void (*remove_device)(struct disk_dump_device *);
62 struct list_head list;
65 struct disk_dump_device_ops {
66 int (*sanity_check)(struct disk_dump_device *);
67 int (*quiesce)(struct disk_dump_device *);
68 int (*shutdown)(struct disk_dump_device *);
69 int (*rw_block)(struct disk_dump_partition *, int rw, unsigned long block_nr, void *buf, int len);
72 /* The data structure for a dump device */
73 struct disk_dump_device {
74 struct list_head list;
75 struct disk_dump_device_ops ops;
76 struct disk_dump_type *dump_type;
78 unsigned int max_blocks;
79 struct list_head partitions;
82 /* The data structure for a dump partition */
83 struct disk_dump_partition {
84 struct list_head list;
85 struct disk_dump_device *device;
86 struct block_device *bdev;
87 unsigned long start_sect;
88 unsigned long nr_sects;
91 int register_disk_dump_type(struct disk_dump_type *);
92 int unregister_disk_dump_type(struct disk_dump_type *);
98 ssize_t diskdump_sysfs_store(struct device *dev, const char *buf, size_t count);
99 ssize_t diskdump_sysfs_show(struct device *dev, char *buf);
102 void diskdump_update(void);
103 void diskdump_setup_timestamp(void);
105 /* mdelay() is trapped by WARN_ON if we are in the interrupt context. */
106 #define diskdump_mdelay(n) \
107 ({unsigned long __ms=(n); while (__ms--) udelay(1000);})
111 * Architecture-independent dump header
114 /* The signature which is written in each block in the dump partition */
115 #define DISK_DUMP_SIGNATURE "DISKDUMP"
116 #define DISK_DUMP_HEADER_VERSION 1
118 #define DUMP_PARTITION_SIGNATURE "diskdump"
120 #define DUMP_HEADER_COMPLETED 0
121 #define DUMP_HEADER_INCOMPLETED 1
123 struct disk_dump_header {
124 char signature[8]; /* = "DISKDUMP" */
125 int header_version; /* Dump header version */
126 struct new_utsname utsname; /* copy of system_utsname */
127 struct timespec timestamp; /* Time stamp */
128 unsigned int status; /* Above flags */
129 int block_size; /* Size of a block in byte */
130 int sub_hdr_size; /* Size of arch dependent
132 unsigned int bitmap_blocks; /* Size of Memory bitmap in
134 unsigned int max_mapnr; /* = max_mapnr */
135 unsigned int total_ram_blocks;/* Size of Memory in block */
136 unsigned int device_blocks; /* Number of total blocks in
138 unsigned int written_blocks; /* Number of written blocks */
139 unsigned int current_cpu; /* CPU# which handles dump */
140 int nr_cpus; /* Number of CPUs */
141 struct task_struct *tasks[NR_CPUS];
145 extern enum disk_dump_states {
153 * Calculate the check sum of the whole module
155 #define get_crc_module() \
157 struct module *module = &__this_module; \
158 crc32_le(0, (char *)(module->module_core), \
159 ((unsigned long)module - (unsigned long)(module->module_core))); \
162 /* Calculate the checksum of the whole module */
163 #define set_crc_modules() \
166 module_crc = get_crc_module(); \
170 * Compare the checksum value that is stored in module_crc to the check
171 * sum of current whole module. Must be called with holding disk_dump_lock.
172 * Return TRUE if they are the same, else return FALSE
175 #define check_crc_module() \
177 uint32_t orig_crc, cur_crc; \
179 orig_crc = module_crc; module_crc = 0; \
180 cur_crc = get_crc_module(); \
181 module_crc = orig_crc; \
182 orig_crc == cur_crc; \
186 #endif /* _LINUX_DISKDUMP_H */