svn commit: r202956 - projects/ppc64/lib/libkvm
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Mon Jan 25 02:13:01 UTC 2010
Author: nwhitehorn
Date: Mon Jan 25 02:13:00 2010
New Revision: 202956
URL: http://svn.freebsd.org/changeset/base/202956
Log:
First hash at ppc64 KVM implementation.
Added:
projects/ppc64/lib/libkvm/kvm_powerpc64.c
- copied, changed from r202947, projects/ppc64/lib/libkvm/kvm_powerpc.c
Copied and modified: projects/ppc64/lib/libkvm/kvm_powerpc64.c (from r202947, projects/ppc64/lib/libkvm/kvm_powerpc.c)
==============================================================================
--- projects/ppc64/lib/libkvm/kvm_powerpc.c Sun Jan 24 20:15:59 2010 (r202947, copy source)
+++ projects/ppc64/lib/libkvm/kvm_powerpc64.c Mon Jan 25 02:13:00 2010 (r202956)
@@ -48,17 +48,17 @@ struct vmstate {
void *map;
size_t mapsz;
size_t dmphdrsz;
- Elf32_Ehdr *eh;
- Elf32_Phdr *ph;
+ Elf64_Ehdr *eh;
+ Elf64_Phdr *ph;
};
static int
-valid_elf_header(Elf32_Ehdr *eh)
+valid_elf_header(Elf64_Ehdr *eh)
{
if (!IS_ELF(*eh))
return (0);
- if (eh->e_ident[EI_CLASS] != ELFCLASS32)
+ if (eh->e_ident[EI_CLASS] != ELFCLASS64)
return (0);
if (eh->e_ident[EI_DATA] != ELFDATA2MSB)
return (0);
@@ -68,7 +68,7 @@ valid_elf_header(Elf32_Ehdr *eh)
return (0);
if (be16toh(eh->e_type) != ET_CORE)
return (0);
- if (be16toh(eh->e_machine) != EM_PPC)
+ if (be16toh(eh->e_machine) != EM_PPC64)
return (0);
/* Can't think of anything else to check... */
return (1);
@@ -80,7 +80,7 @@ dump_header_size(struct kerneldumpheader
if (strcmp(dh->magic, KERNELDUMPMAGIC) != 0)
return (0);
- if (strcmp(dh->architecture, "powerpc") != 0)
+ if (strcmp(dh->architecture, "powerpc64") != 0)
return (0);
/* That should do it... */
return (sizeof(*dh));
@@ -122,7 +122,7 @@ powerpc_maphdrs(kvm_t *kd)
goto inval;
}
mapsz = be16toh(vm->eh->e_phentsize) * be16toh(vm->eh->e_phnum) +
- be32toh(vm->eh->e_phoff);
+ be64toh(vm->eh->e_phoff);
munmap(vm->map, vm->mapsz);
/* Map all headers. */
@@ -133,7 +133,7 @@ powerpc_maphdrs(kvm_t *kd)
return (-1);
}
vm->eh = (void *)((uintptr_t)vm->map + vm->dmphdrsz);
- vm->ph = (void *)((uintptr_t)vm->eh + be32toh(vm->eh->e_phoff));
+ vm->ph = (void *)((uintptr_t)vm->eh + be64toh(vm->eh->e_phoff));
return (0);
inval:
@@ -149,16 +149,16 @@ powerpc_maphdrs(kvm_t *kd)
* 0 when the virtual address is invalid.
*/
static size_t
-powerpc_va2off(kvm_t *kd, u_long va, off_t *ofs)
+powerpc64_va2off(kvm_t *kd, u_long va, off_t *ofs)
{
struct vmstate *vm = kd->vmst;
- Elf32_Phdr *ph;
+ Elf64_Phdr *ph;
int nph;
ph = vm->ph;
nph = be16toh(vm->eh->e_phnum);
- while (nph && (va < be32toh(ph->p_vaddr) ||
- va >= be32toh(ph->p_vaddr) + be32toh(ph->p_memsz))) {
+ while (nph && (va < be64toh(ph->p_vaddr) ||
+ va >= be64toh(ph->p_vaddr) + be64toh(ph->p_memsz))) {
nph--;
ph = (void *)((uintptr_t)ph + be16toh(vm->eh->e_phentsize));
}
@@ -166,9 +166,9 @@ powerpc_va2off(kvm_t *kd, u_long va, off
return (0);
/* Segment found. Return file offset and range. */
- *ofs = vm->dmphdrsz + be32toh(ph->p_offset) +
- (va - be32toh(ph->p_vaddr));
- return (be32toh(ph->p_memsz) - (va - be32toh(ph->p_vaddr)));
+ *ofs = vm->dmphdrsz + be64toh(ph->p_offset) +
+ (va - be64toh(ph->p_vaddr));
+ return (be64toh(ph->p_memsz) - (va - be64toh(ph->p_vaddr)));
}
void
@@ -210,8 +210,8 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t
struct vmstate *vm;
vm = kd->vmst;
- if (vm->ph->p_paddr == ~0U)
- return ((int)powerpc_va2off(kd, va, ofs));
+ if (vm->ph->p_paddr == ~0UL)
+ return ((int)powerpc64_va2off(kd, va, ofs));
_kvm_err(kd, kd->program, "Raw corefile not supported");
return (0);
More information about the svn-src-projects
mailing list