1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* ppc.c
*
* Created by: Suzuki K. Poulose <suzuki@in.ibm.com>
* - Based on ppc64 implementation
* Copyright (C) IBM Corporation, 2012. All rights reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation (version 2 of the License).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef __powerpc32__
#include "../print_info.h"
#include "../elf_info.h"
#include "../makedumpfile.h"
int
get_machdep_info_ppc(void)
{
unsigned long vmlist, vmap_area_list, vmalloc_start;
info->section_size_bits = _SECTION_SIZE_BITS;
info->max_physmem_bits = _MAX_PHYSMEM_BITS;
info->page_offset = __PAGE_OFFSET;
if (SYMBOL(_stext) != NOT_FOUND_SYMBOL)
info->kernel_start = SYMBOL(_stext);
else {
ERRMSG("Can't get the symbol of _stext.\n");
return FALSE;
}
DEBUG_MSG("kernel_start : %lx\n", info->kernel_start);
/*
* Get vmalloc_start value from either vmap_area_list or vmlist.
*/
if ((SYMBOL(vmap_area_list) != NOT_FOUND_SYMBOL)
&& (OFFSET(vmap_area.va_start) != NOT_FOUND_STRUCTURE)
&& (OFFSET(vmap_area.list) != NOT_FOUND_STRUCTURE)) {
if (!readmem(VADDR, SYMBOL(vmap_area_list) + OFFSET(list_head.next),
&vmap_area_list, sizeof(vmap_area_list))) {
ERRMSG("Can't get vmap_area_list.\n");
return FALSE;
}
if (!readmem(VADDR, vmap_area_list - OFFSET(vmap_area.list) +
OFFSET(vmap_area.va_start), &vmalloc_start,
sizeof(vmalloc_start))) {
ERRMSG("Can't get vmalloc_start.\n");
return FALSE;
}
} else if ((SYMBOL(vmlist) != NOT_FOUND_SYMBOL)
&& (OFFSET(vm_struct.addr) != NOT_FOUND_STRUCTURE)) {
if (!readmem(VADDR, SYMBOL(vmlist), &vmlist, sizeof(vmlist))) {
ERRMSG("Can't get vmlist.\n");
return FALSE;
}
if (!readmem(VADDR, vmlist + OFFSET(vm_struct.addr), &vmalloc_start,
sizeof(vmalloc_start))) {
ERRMSG("Can't get vmalloc_start.\n");
return FALSE;
}
} else {
/*
* For the compatibility, makedumpfile should run without the symbol
* vmlist and the offset of vm_struct.addr if they are not necessary.
*/
return TRUE;
}
info->vmalloc_start = vmalloc_start;
DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start);
return TRUE;
}
int
is_vmalloc_addr_ppc(unsigned long vaddr)
{
return (info->vmalloc_start && vaddr >= info->vmalloc_start);
}
unsigned long long
vaddr_to_paddr_ppc(unsigned long vaddr)
{
unsigned long *pgd, *pmd;
unsigned long long pte;
unsigned long long paddr;
paddr = vaddr_to_paddr_general(vaddr);
if (paddr != NOT_PADDR)
return paddr;
if (((SYMBOL(vmap_area_list) == NOT_FOUND_SYMBOL)
|| (OFFSET(vmap_area.va_start) == NOT_FOUND_STRUCTURE)
|| (OFFSET(vmap_area.list) == NOT_FOUND_STRUCTURE))
&& ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL)
|| (OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE))) {
ERRMSG("Can't get necessary information for vmalloc translation.\n");
return NOT_PADDR;
}
if (!is_vmalloc_addr_ppc(vaddr))
return (vaddr - info->kernel_start);
/*
* TODO: Support vmalloc translation.
*/
ERRMSG("This makedumpfile does not support vmalloc translation.\n");
return NOT_PADDR;
}
#endif /* powerpc32 */
|