1 | /*************************************************************************** |
---|
2 | * |
---|
3 | * Copyright (C) 2001 International Business Machines |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of the GPFS mmfslinux kernel module. |
---|
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 | * |
---|
12 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer in the |
---|
16 | * documentation and/or other materials provided with the distribution. |
---|
17 | * 3. The name of the author may not be used to endorse or promote products |
---|
18 | * derived from this software without specific prior written |
---|
19 | * permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
---|
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
31 | * |
---|
32 | *************************************************************************** */ |
---|
33 | /* @(#)65 1.6 src/avs/fs/mmfs/ts/kernext/gpl-linux/kdump.h, mmfs, avs_rgpfs24, rgpfs24s011a 3/14/07 10:53:41 */ |
---|
34 | /* Definitions for program to dump kernel memory */ |
---|
35 | |
---|
36 | /* Debugging printfs. The entire body of the printf call is the macro |
---|
37 | parameter. */ |
---|
38 | #ifdef DEBUG_KDUMP |
---|
39 | #define DBG(_p) do { _p; } while (0) |
---|
40 | #else |
---|
41 | #define DBG(_p) do {} while (0) |
---|
42 | #endif |
---|
43 | |
---|
44 | /* Symbol storage area. Each symbol has an address, some flags, and |
---|
45 | a name. Symbols are linked into a hash table by name. Although the |
---|
46 | symbol array itself is not sorted, the auxiliary array SymsByAddrPP is |
---|
47 | sorted by address to allow fast binary search by address. */ |
---|
48 | struct Symbol |
---|
49 | { |
---|
50 | unsigned long addr; |
---|
51 | int flags; |
---|
52 | char *nameP; |
---|
53 | struct Symbol *hashNextP; |
---|
54 | }; |
---|
55 | |
---|
56 | #define FL_TEXT 0x01 |
---|
57 | #define FL_BSS 0x02 |
---|
58 | #define FL_DATA 0x04 |
---|
59 | #define FL_RODATA 0x08 |
---|
60 | #define FL_SECTION 0x10 |
---|
61 | #define FL_KSTRTAB 0x20 |
---|
62 | |
---|
63 | struct Stab |
---|
64 | { |
---|
65 | unsigned short boff; /* bit offset of the member */ |
---|
66 | unsigned short blen; /* bit length of the member */ |
---|
67 | char *nameP; |
---|
68 | struct Stab *memNextP; /* next stab member of this stab string */ |
---|
69 | struct Stab *hashNextP; /* next stab entry hashed to same index */ |
---|
70 | }; |
---|
71 | |
---|
72 | /* Look up symbol by name. Returns a pointer to the symbol table entry |
---|
73 | if a matching name is found, otherwise NULL. */ |
---|
74 | extern struct Symbol* LookupSymbolByName(const char* nameP); |
---|
75 | |
---|
76 | /* Add a symbol to the table. The symbol name must not already be present. |
---|
77 | Returns the address of the new symbol table entry. */ |
---|
78 | extern struct Symbol* AddUniqueSymbol(unsigned long addr, int flags, |
---|
79 | char* nameP); |
---|
80 | |
---|
81 | /* Add a symbol to the table. If the symbol name is already present, |
---|
82 | append the address of the symbol to the symbol name to make it |
---|
83 | unique. Returns the address of the new symbol table entry. */ |
---|
84 | extern struct Symbol* AddSymbol(unsigned long addr, int flags, char* nameP); |
---|
85 | |
---|
86 | /* Look up symbol by address. Returns a pointer to the symbol table entry |
---|
87 | with the largest address that is less than or equal to the given |
---|
88 | address. There will always be a symbol in the table with address 0, |
---|
89 | so this can always return a pointer to some Symbol object. */ |
---|
90 | extern struct Symbol* LookupSymbolByAddr(unsigned long addr); |
---|
91 | |
---|
92 | /* Look up a symbol by address. If an exact match for the address is |
---|
93 | found, return a pointer to the symbol name, otherwise return a pointer |
---|
94 | to an empty string. */ |
---|
95 | extern const char* ExactAddrToSymbol(unsigned long addr); |
---|
96 | |
---|
97 | |
---|
98 | /* Bounds of the initial portion of kernel virtual memory. These are |
---|
99 | initialized to liberal values, then tightened by reading kernel |
---|
100 | variables. */ |
---|
101 | extern unsigned long LowKernelAddr; |
---|
102 | extern unsigned long HighKernelAddr; |
---|
103 | |
---|
104 | /* List of valid virtual memory areas outside of [LowKernelAddr..HighKernelAddr] */ |
---|
105 | struct vmStruct |
---|
106 | { |
---|
107 | unsigned long startAddr; |
---|
108 | int areaLen; |
---|
109 | off_t file_offset; |
---|
110 | struct vmStruct* nextAreaP; |
---|
111 | }; |
---|
112 | extern struct vmStruct* vmListHeadP; |
---|
113 | |
---|
114 | /* Return __START_KERNEL_map or PAGE_OFFSET */ |
---|
115 | extern unsigned long GetOffset(int fMap); |
---|
116 | |
---|
117 | /* Read kernel memory after checking the address for validity. If the address |
---|
118 | is invalid, return -1, otherwise return 0. */ |
---|
119 | extern int ReadKernel(unsigned long addr, void* bufP, int len, int fMap); |
---|
120 | |
---|
121 | /* Read the current value of a kernel symbol. Returns 0 on success, -1 |
---|
122 | on failure. */ |
---|
123 | extern int GetSymbolValue(const char* nameP, void* bufP, int len); |
---|
124 | |
---|
125 | /* Wrappers around malloc and free so they can be called from modules that |
---|
126 | include kernel files */ |
---|
127 | extern void* kMalloc(int len); |
---|
128 | extern void kFree(void* p); |
---|
129 | |
---|
130 | /* Conditional free. Free storage if p is not NULL. */ |
---|
131 | extern void CondFree(void* p); |
---|
132 | |
---|
133 | /* Dump a block of memory. Duplicate lines are supressed. */ |
---|
134 | #define DUMPMEM_ROUND 0x10 |
---|
135 | #define DUMPMEM_I1 0x01 |
---|
136 | #define DUMPMEM_I2 0x02 |
---|
137 | #define DUMPMEM_I4 0x04 |
---|
138 | #define DUMPMEM_I8 0x08 |
---|
139 | extern void DumpMemory(char* p, int nBytes, unsigned long origin, int dumpFlags); |
---|
140 | |
---|
141 | extern int DumpMemoryCast(unsigned long origin, char *stabNameP); |
---|
142 | |
---|
143 | extern void readCore(void* bufP, int len); |
---|
144 | extern void openCore(char* corefile); |
---|
145 | extern void seekCore(off_t pos); |
---|
146 | |
---|
147 | extern int isCore; |
---|