Whamcloud - gitweb
LU-12461 contrib: Add epython scripts for crash dump analysis
[fs/lustre-release.git] / contrib / debug_tools / epython_scripts / crashlib / addrlib.py
1
2 """
3 Set of routines for manipulating addresses.
4 Copyright 2014 Cray Inc.  All Rights Reserved
5 """
6
7 import crashlib.cid
8 import crashlib.cid.machdep_table
9
10 # --------------------------------------------------------------------------
11
12 def ptov(physaddr):
13     """Convert a physical address to a kernel virtual address."""
14     return int(physaddr) + crashlib.cid.mdtbl.kvbase
15
16 def phys2pfn(physaddr):
17     """Convert a physical address to a page offset."""
18     return physaddr >> crashlib.cid.mdtbl.pageshift
19
20 def pfn2phys(pfn):
21     """Convert a page offset into a physical address."""
22     return pfn << crashlib.cid.mdtbl.pageshift