FreeBSD/lib/libkvm/kvm_i386.c
/*
 * Translate a physical memory address to a file-offset in the crash-dump.
 */
Translate a physical memory address to a file-offset in the crash-dump.
Translate a physical memory address to a file - offset in the crash - dump .
static size_t
_kvm_pa2off(kvm_t *kd, uint64_t pa, off_t *ofs)
{
	struct vmstate *vm = kd->vmst;
	GElf_Phdr *p;
	size_t n;
	if (kd->rawdump) {
		*ofs = pa;
		return (I386_PAGE_SIZE - (pa & I386_PAGE_MASK));
	}
	p = vm->phdr;
	n = vm->phnum;
	while (n && (pa < p->p_paddr || pa >= p->p_paddr + p->p_memsz))
		p++, n--;
	if (n == 0)
		return (0);
	*ofs = (pa - p->p_paddr) + p->p_offset;
	return (I386_PAGE_SIZE - (pa & I386_PAGE_MASK));
}
static size_t _kvm_pa2off ( kvm_t * kd , uint64_t pa , off_t * ofs ) { struct vmstate * vm = kd -> vmst ; GElf_Phdr * p ; size_t n ; if ( kd -> rawdump ) { * ofs = pa ; return ( I386_PAGE_SIZE - ( pa & I386_PAGE_MASK ) ) ; } p = vm -> phdr ; n = vm -> phnum ; while ( n && ( pa < p -> p_paddr || pa >= p -> p_paddr + p -> p_memsz ) ) p ++ , n -- ; if ( n == 0 ) return ( 0 ) ; * ofs = ( pa - p -> p_paddr ) + p -> p_offset ; return ( I386_PAGE_SIZE - ( pa & I386_PAGE_MASK ) ) ; }
Translate a physical memory address to a file-offset in the crash-dump.
Translate a physical memory address to a file - offset in the crash - dump .