File: __init__.py

package info (click to toggle)
pykdumpfile 0.5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 300 kB
  • sloc: python: 2,607; ansic: 447; makefile: 17
file content (60 lines) | stat: -rw-r--r-- 1,450 bytes parent folder | download
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
'''addrxlat
'''

from _addrxlat import ffi, lib as C

from .constants import *
from .exceptions import *
from .objects import *
from . import utils

###
### Version codes
###

def VER_LINUX(a, b, c):
    '''VER_LINUX(a, b, c) -> version code

    Calculate the Linux kernel version code.'''
    return C.ADDRXLAT_VER_LINUX(a, b, c)

def VER_XEN(major, minor):
    '''VER_XEN(major, minor) -> version code

    Calculate the Xen hypervisor version code.'''
    return C.ADDRXLAT_VER_XEN(major, minor)

###
### Other static functions
###

def addrspace_name(addrspace):
    '''addrspace_name(addrspace) -> name

    Return the name of an address space constant.'''
    return utils.to_unicode(ffi.string(C.addrxlat_addrspace_name(addrspace)))

def CAPS(addrspace):
    '''CAPS(addrspace) -> capability bitmask

    Translate an address space constant into a capability bitmask.'''
    return C.ADDRXLAT_CAPS(addrspace)

def pte_format_name(fmt):
    '''pte_format_name(fmt) -> name

    Return the name of a PTE format constant.'''
    return utils.to_unicode(ffi.string(C.addrxlat_pte_format_name(fmt)))

def pte_format(name):
    '''pte_format(name) -> fmt

    Return the PTE format constant by name.'''
    return C.addrxlat_pte_format(utils.to_bytes(name))

def pteval_shift(fmt):
    '''pteval_shift(fmt) -> bit shift

    Get the pteval shift for a PTE format.
    See PTE_xxx for valid values of fmt.'''
    return C.addrxlat_pteval_shift(fmt)