2 * Generic dump device interfaces for flexible system dump
3 * (Enables variation of dump target types e.g disk, network, memory)
5 * These interfaces have evolved based on discussions on lkcd-devel.
6 * Eventually the intent is to support primary and secondary or
7 * alternate targets registered at the same time, with scope for
8 * situation based failover or multiple dump devices used for parallel
11 * Started: Oct 2002 - Suparna Bhattacharya (suparna@in.ibm.com)
13 * Copyright (C) 2001 - 2002 Matt D. Robinson. All rights reserved.
14 * Copyright (C) 2002 International Business Machines Corp.
16 * This code is released under version 2 of the GNU GPL.
19 #ifndef _LINUX_DUMPDEV_H
20 #define _LINUX_DUMPDEV_H
22 #include <linux/kernel.h>
23 #include <linux/wait.h>
24 #include <linux/bio.h>
26 /* Determined by the dump target (device) type */
31 int (*open)(struct dump_dev *, unsigned long); /* configure */
32 int (*release)(struct dump_dev *); /* unconfigure */
33 int (*silence)(struct dump_dev *); /* when dump starts */
34 int (*resume)(struct dump_dev *); /* when dump is over */
35 int (*seek)(struct dump_dev *, loff_t);
36 /* trigger a write (async in nature typically) */
37 int (*write)(struct dump_dev *, void *, unsigned long);
38 /* not usually used during dump, but option available */
39 int (*read)(struct dump_dev *, void *, unsigned long);
40 /* use to poll for completion */
41 int (*ready)(struct dump_dev *, void *);
42 int (*ioctl)(struct dump_dev *, unsigned int, unsigned long);
46 char type_name[32]; /* block, net-poll etc */
47 unsigned long device_id; /* interpreted differently for various types */
48 struct dump_dev_ops *ops;
49 struct list_head list;
54 * dump_dev type variations:
58 struct dump_blockdev {
61 struct block_device *bdev;
68 static inline struct dump_blockdev *DUMP_BDEV(struct dump_dev *dev)
70 return container_of(dev, struct dump_blockdev, ddev);
74 /* mem - for internal use by soft-boot based dumper */
77 unsigned long indirect_map_root;
78 unsigned long nr_free;
79 struct page *curr_page;
80 unsigned long *curr_map;
81 unsigned long curr_map_offset;
82 unsigned long last_offset;
83 unsigned long last_used_offset;
84 unsigned long last_bs_offset;
87 static inline struct dump_memdev *DUMP_MDEV(struct dump_dev *dev)
89 return container_of(dev, struct dump_memdev, ddev);
92 /* Todo/future - meant for raw dedicated interfaces e.g. mini-ide driver */
96 int (*reset)(struct dump_rdev *, unsigned int,
101 /* just to get the size right when saving config across a soft-reboot */
104 struct dump_blockdev bddev;
105 /* .. add other types here .. */
111 /* Dump device / target operation wrappers */
112 /* These assume that dump_dev is initiatized to dump_config.dumper->dev */
114 extern struct dump_dev *dump_dev;
116 static inline int dump_dev_open(unsigned long arg)
118 return dump_dev->ops->open(dump_dev, arg);
121 static inline int dump_dev_release(void)
123 return dump_dev->ops->release(dump_dev);
126 static inline int dump_dev_silence(void)
128 return dump_dev->ops->silence(dump_dev);
131 static inline int dump_dev_resume(void)
133 return dump_dev->ops->resume(dump_dev);
136 static inline int dump_dev_seek(loff_t offset)
138 return dump_dev->ops->seek(dump_dev, offset);
141 static inline int dump_dev_write(void *buf, unsigned long len)
143 return dump_dev->ops->write(dump_dev, buf, len);
146 static inline int dump_dev_ready(void *buf)
148 return dump_dev->ops->ready(dump_dev, buf);
151 static inline int dump_dev_ioctl(unsigned int cmd, unsigned long arg)
153 if (!dump_dev || !dump_dev->ops->ioctl)
155 return dump_dev->ops->ioctl(dump_dev, cmd, arg);
158 extern int dump_register_device(struct dump_dev *);
159 extern void dump_unregister_device(struct dump_dev *);
161 #endif /* _LINUX_DUMPDEV_H */