linux/arch/s390/boot/zfcpdump.h
<<
>>
Prefs
   1/*
   2 * zfcpdump userspace tool
   3 *
   4 * Copyright IBM Corp. 2003, 2007.
   5 * Author(s): Michael Holzheu
   6 */
   7
   8#ifndef _ZFCPDUMP_H
   9#define _ZFCPDUMP_H
  10
  11#include <stdio.h>
  12#include <signal.h>
  13#include <stdint.h>
  14
  15#define ZFCPDUMP_VERSION "2.2"
  16
  17#define PRINT_TRACE(x...) \
  18        do { \
  19                if (g.parm_debug >= 3) { \
  20                        fprintf(stderr, "TRACE: "); \
  21                        fprintf(stderr, ##x); \
  22                } \
  23        } while (0)
  24
  25#define PRINT_ERR(x...) \
  26        do { \
  27                fprintf(stderr, "ERROR: "); \
  28                fprintf(stderr, ##x); \
  29        } while (0)
  30
  31#define PRINT_WARN(x...) \
  32        do { \
  33                fprintf(stderr, "WARNING: "); \
  34                fprintf(stderr, ##x); \
  35        } while (0)
  36
  37#define PRINT_PERR(x...) \
  38        do { \
  39                fprintf(stderr, "ERROR: "); \
  40                fprintf(stderr, ##x); \
  41                perror(""); \
  42        } while (0)
  43
  44#define PRINT(x...) fprintf(stdout, ##x)
  45#define CMDLINE_MAX_LEN 1024
  46#define KERN_PARM_MAX 100
  47
  48#define DUMP_FLAGS (O_CREAT | O_RDWR | O_TRUNC | O_DIRECT)
  49#define DUMP_MODE (S_IRUSR | S_IWUSR | S_IRGRP)
  50
  51struct globals {
  52        char    *parm_compress;
  53        char    *parm_dir;
  54        char    *parm_part;
  55        int     parm_debug;
  56        int     parm_mode;
  57        __u64   parm_mem;
  58        char    parmline[CMDLINE_MAX_LEN];
  59        char    dump_dir[1024];
  60        int     dump_nr;
  61        int     last_progress;
  62        struct  sigaction sigact;
  63        char    dump_devno[16];
  64        char    dump_wwpn[32];
  65        char    dump_lun[32];
  66        char    dump_bootprog[32];
  67};
  68
  69#ifndef MIN
  70#define MIN(x, y) ((x) < (y) ? (x) : (y))
  71#endif
  72#ifndef MAX
  73#define MAX(x, y) ((x) > (y) ? (x) : (y))
  74#endif
  75
  76#define PROC_CMDLINE    "/proc/cmdline"
  77#define PROC_MISC       "/proc/misc"
  78#define DEV_ZCORE       "/sys/kernel/debug/zcore/mem"
  79#define DEV_ZCORE_MAP   "/sys/kernel/debug/zcore/memmap"
  80#define DEV_ZCORE_REIPL "/sys/kernel/debug/zcore/reipl"
  81#define REIPL           "1"
  82#define DEV_SCSI        "/dev/sda"
  83#define DUMP_DIR        "/mnt"
  84
  85#define IPL_WWPN        "/sys/firmware/ipl/wwpn"
  86#define IPL_DEVNO       "/sys/firmware/ipl/device"
  87#define IPL_LUN         "/sys/firmware/ipl/lun"
  88
  89#define PARM_DIR        "dump_dir"
  90#define PARM_DIR_DFLT   "/"
  91
  92#define PARM_PART       "dump_part"
  93#define PARM_PART_DFLT  "1"
  94
  95#define PARM_COMP       "dump_compress"
  96#define PARM_COMP_GZIP  "gzip"
  97#define PARM_COMP_NONE  "none"
  98#define PARM_COMP_DFLT  PARM_COMP_NONE
  99
 100#define PARM_MEM        "dump_mem"
 101#ifdef __s390x__
 102#define PARM_MEM_DFLT   0xffffffffffffffff
 103#else
 104#define PARM_MEM_DFLT   0xffffffff
 105#endif
 106
 107#define PARM_DEBUG      "dump_debug"
 108#define PARM_DEBUG_DFLT 2
 109#define PARM_DEBUG_MIN  1
 110#define PARM_DEBUG_MAX  6
 111
 112#define PARM_MODE               "dump_mode"
 113#define PARM_MODE_INTERACT      "interactive"
 114#define PARM_MODE_INTERACT_NUM  0
 115#define PARM_MODE_AUTO          "auto"
 116#define PARM_MODE_AUTO_NUM      1
 117#define PARM_MODE_DFLT          PARM_MODE_INTERACT
 118#define PARM_MODE_NUM_DFLT      PARM_MODE_INTERACT_NUM
 119
 120#define DUMP_FIRST      0
 121#define DUMP_LAST       1
 122#define NO_DUMP         -1
 123
 124#define WAIT_TIME_ERASE         5 /* seconds */
 125#define WAIT_TIME_END           3 /* seconds */
 126#define WAIT_TIME_ONLINE        2 /* seconds */
 127
 128#define UTS_LEN         65
 129
 130#define PAGE_SIZE               4096
 131#define DUMP_BUF_SIZE           (80 * PAGE_SIZE)
 132#define LKCD_HDR_SIZE           (64 * 1024)
 133
 134/* header definitions for dumps from s390 standalone dump tools */
 135#define DUMP_MAGIC_S390SA       0xa8190173618f23fdULL /* s390sa magic number */
 136#define DUMP_HEADER_SZ_S390SA   4096
 137
 138/* standard header definitions */
 139#define DUMP_MAGIC_NUMBER       0xa8190173618f23edULL  /* dump magic number  */
 140#define DUMP_MAGIC_NUMBER_ASM   0x733339302d64756dULL
 141#define DUMP_VERSION_NUMBER     0x8      /* dump version number             */
 142#define DUMP_PANIC_LEN          0x100    /* dump panic string length        */
 143
 144/* dump compression options -- add as necessary */
 145#define DUMP_COMPRESS_NONE      0x0   /* don't compress this dump      */
 146#define DUMP_COMPRESS_GZIP      0x2   /* use GZIP compression          */
 147
 148/* dump header flags -- add as necessary */
 149#define DUMP_DH_RAW             0x1   /* raw page (no compression)        */
 150#define DUMP_DH_COMPRESSED      0x2   /* page is compressed               */
 151#define DUMP_DH_END             0x4   /* end marker on a full dump        */
 152
 153#define CHUNK_INFO_SIZE         34  /* 2 16-byte char, each followed by blank */
 154
 155/*
 156 * This is the header dumped at the top of every valid crash dump.
 157 */
 158struct dump_hdr_lkcd {
 159        __u64 magic_number;
 160        __u32 version;
 161        __u32 header_size;
 162        __u32 dump_level;
 163        __u32 page_size;
 164        __u64 memory_size;
 165        __u64 memory_start;
 166        __u64 memory_end;
 167        __u32 num_dump_pages;
 168        char panic_string[DUMP_PANIC_LEN];
 169        struct {
 170                __u64 tv_sec;
 171                __u64 tv_usec;
 172        } time;
 173        char utsname_sysname[UTS_LEN];
 174        char utsname_nodename[UTS_LEN];
 175        char utsname_release[UTS_LEN];
 176        char utsname_version[UTS_LEN];
 177        char utsname_machine[UTS_LEN];
 178        char utsname_domainname[UTS_LEN];
 179        __u64 current_task;
 180        __u32 dump_compress;
 181        __u32 dump_flags;
 182        __u32 dump_device;
 183} __attribute__((packed));
 184
 185#define DH_ARCH_ID_S390X 2
 186#define DH_ARCH_ID_S390  1
 187
 188/*
 189 * s390 LKCD asm header
 190 */
 191struct dump_hdr_lkcd_asm {
 192        __u64   magic_number;
 193        __u32   version;
 194        __u32   hdr_size;
 195        __u16   cpu_cnt;
 196        __u16   real_cpu_cnt;
 197        __u32   lc_vec[512];
 198} __attribute__((packed));
 199
 200/*
 201 * This is the header used by zcore
 202 */
 203struct dump_hdr_s390 {
 204        __u64 magic_number;
 205        __u32 version;
 206        __u32 header_size;
 207        __u32 dump_level;
 208        __u32 page_size;
 209        __u64 memory_size;
 210        __u64 memory_start;
 211        __u64 memory_end;
 212        __u32 num_pages;
 213        __u32 pad;
 214        __u64 tod;
 215        __u64 cpu_id;
 216        __u32 arch_id;
 217        __u32 volnr;
 218        __u32 build_arch;
 219        __u64 rmem_size;
 220        __u8 mvdump;
 221        __u16 cpu_cnt;
 222        __u16 real_cpu_cnt;
 223        __u8 end_pad1[0x200-0x061];
 224        __u64 mvdump_sign;
 225        __u64 mvdump_zipl_time;
 226        __u8 end_pad2[0x800-0x210];
 227        __u32 lc_vec[512];
 228} __attribute__((packed));
 229
 230/*
 231 * Header associated to each physical page of memory saved in the system
 232 * crash dump.
 233 */
 234struct dump_page {
 235        __u64 address; /* the address of this dump page */
 236        __u32 size;    /* the size of this dump page */
 237        __u32 flags;   /* flags (DUMP_COMPRESSED, DUMP_RAW or DUMP_END) */
 238} __attribute__((packed));
 239
 240struct mem_chunk {
 241        __u64 addr;    /* the start address of this memory chunk */
 242        __u64 size;    /* the length of this memory chunk */
 243        struct mem_chunk *next; /* pointer to next memory chunk */
 244};
 245
 246/* Compression function */
 247typedef int (*compress_fn_t)(const unsigned char *old, __u32 old_size,
 248                             unsigned char *new, __u32 size);
 249
 250#endif /* _ZFCPDUMP_H */
 251