libkdumpfile-0.5.4
Kernel coredump file access
|
Public interface for libaddrxlat
(address translation library).
More...
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
Data Structures | |
struct | _addrxlat_fulladdr |
Full address (including address space specification). More... | |
struct | _addrxlat_buffer |
Read buffer metadata. More... | |
struct | _addrxlat_cb |
Callback function pointers and data. More... | |
struct | _addrxlat_param_custom |
Parameters of custom translation. More... | |
struct | _addrxlat_param_linear |
Parameters of linear translation. More... | |
struct | _addrxlat_paging_form |
struct | _addrxlat_param_pgt |
Parameters of page table translation. More... | |
struct | _addrxlat_lookup_elem |
Lookup table element. More... | |
struct | _addrxlat_param_lookup |
Parameters of table lookup translation. More... | |
struct | _addrxlat_param_memarr |
Parameters of memory array translation. More... | |
union | _addrxlat_param |
Parameters of the translation method. More... | |
struct | _addrxlat_meth |
Address translation method. More... | |
struct | _addrxlat_range |
Definition of an address range. More... | |
union | _addrxlat_optval |
Single option value. More... | |
struct | _addrxlat_opt |
Single option. More... | |
struct | _addrxlat_step |
State of the current step in address translation. More... | |
struct | _addrxlat_op_ctl |
Callback function pointers and data. More... | |
Macros | |
#define | ADDRXLAT_VER_MAJOR 0 |
Major version (1st number in the release tag). | |
#define | ADDRXLAT_VER_MINOR 5 |
Minor version (2nd number in the release tag). | |
#define | ADDRXLAT_VER_MICRO 4 |
Micro version (3rd number in the release tag). | |
#define | ADDRXLAT_MKVER(major, minor, micro) (((major) << 16) | ((minor) << 8) | ((micro))) |
Make a single-number version from three digits of the release tag. | |
#define | ADDRXLAT_VERSION |
Version as a single number. | |
#define | ADDRXLAT_VERSION_STRING "0.5.4" |
Version as a string constant. | |
#define | ADDRXLAT_ADDR_MAX (~(addrxlat_addr_t)0) |
Maximum value that can be represented by addrxlat_addr_t. | |
Typedefs | |
typedef enum _addrxlat_status | addrxlat_status |
Status code. | |
typedef uint_fast64_t | addrxlat_addr_t |
Type of a physical or virtual address. | |
typedef int_fast64_t | addrxlat_off_t |
Type of an address offset. | |
typedef uint_fast64_t | addrxlat_pte_t |
Type for a PTE value. | |
Enumerations | |
enum | _addrxlat_status { ADDRXLAT_OK = 0 , ADDRXLAT_ERR_NOTIMPL , ADDRXLAT_ERR_NOTPRESENT , ADDRXLAT_ERR_INVALID , ADDRXLAT_ERR_NOMEM , ADDRXLAT_ERR_NODATA , ADDRXLAT_ERR_NOMETH , ADDRXLAT_ERR_CUSTOM_BASE = -1 } |
Status code. More... | |
Functions | |
const char * | addrxlat_strerror (addrxlat_status status) |
Return the string describing a given error status. | |
fprintf() macros for addrxlat types | |
These macros are similar to POSIX Each of these macros expands to a character string literal containing a conversion specifier, possibly modified by a length modifier, suitable for use within the format argument of a formatted input/output function when converting the corresponding integer type. | |
#define | ADDRXLAT_PRIoADDR PRIoFAST64 |
Octal address. | |
#define | ADDRXLAT_PRIuADDR PRIuFAST64 |
Decimal address. | |
#define | ADDRXLAT_PRIxADDR PRIxFAST64 |
Lowercase hex address. | |
#define | ADDRXLAT_PRIXADDR PRIXFAST64 |
Uppercase hex address. | |
#define | ADDRXLAT_PRIoPTE PRIoFAST64 |
Octal PTE. | |
#define | ADDRXLAT_PRIuPTE PRIuFAST64 |
Decimal PTE. | |
#define | ADDRXLAT_PRIxPTE PRIxFAST64 |
Lowercase hex PTE. | |
#define | ADDRXLAT_PRIXPTE PRIXFAST64 |
Uppercase hex PTE. | |
#define | ADDRXLAT_CAPS(val) (1UL << (unsigned)(val)) |
Translate an enum value into a capability bitmask. | |
#define | ADDRXLAT_FIELDS_MAX 8 |
Maximum number of bit fields in the source address. | |
#define | ADDRXLAT_SYS_METH_CUSTOM_NUM 8 |
Number of custom methods. | |
#define | ADDRXLAT_SYS_METH_NUM (ADDRXLAT_SYS_METH_CUSTOM + ADDRXLAT_SYS_METH_CUSTOM_NUM) |
Total number of system method indices. | |
#define | ADDRXLAT_VER_LINUX(a, b, c) (((a) << 16) + ((b) << 8) + (c)) |
Linux kernel version code. | |
#define | ADDRXLAT_VER_XEN(major, minor) (((major) << 16) | (minor)) |
Xen version code. | |
enum | _addrxlat_addrspace { ADDRXLAT_KPHYSADDR , ADDRXLAT_MACHPHYSADDR , ADDRXLAT_KVADDR , ADDRXLAT_NOADDR = -1 } |
Address spaces. More... | |
enum | _addrxlat_byte_order { ADDRXLAT_BIG_ENDIAN , ADDRXLAT_LITTLE_ENDIAN , ADDRXLAT_HOST_ENDIAN = -1 } |
Data byte order. More... | |
enum | _addrxlat_kind { ADDRXLAT_NOMETH , ADDRXLAT_CUSTOM , ADDRXLAT_LINEAR , ADDRXLAT_PGT , ADDRXLAT_LOOKUP , ADDRXLAT_MEMARR } |
Address translation kind. More... | |
enum | _addrxlat_pte_format { ADDRXLAT_PTE_INVALID = -1 , ADDRXLAT_PTE_NONE , ADDRXLAT_PTE_PFN32 , ADDRXLAT_PTE_PFN64 , ADDRXLAT_PTE_AARCH64 , ADDRXLAT_PTE_IA32 , ADDRXLAT_PTE_IA32_PAE , ADDRXLAT_PTE_X86_64 , ADDRXLAT_PTE_S390X , ADDRXLAT_PTE_PPC64_LINUX_RPN30 , ADDRXLAT_PTE_AARCH64_LPA , ADDRXLAT_PTE_AARCH64_LPA2 , ADDRXLAT_PTE_ARM , ADDRXLAT_PTE_RISCV32 , ADDRXLAT_PTE_RISCV64 } |
Page table entry format. More... | |
enum | _addrxlat_sys_meth { ADDRXLAT_SYS_METH_NONE = -1 , ADDRXLAT_SYS_METH_PGT , ADDRXLAT_SYS_METH_UPGT , ADDRXLAT_SYS_METH_DIRECT , ADDRXLAT_SYS_METH_KTEXT , ADDRXLAT_SYS_METH_VMEMMAP , ADDRXLAT_SYS_METH_RDIRECT , ADDRXLAT_SYS_METH_MACHPHYS_KPHYS , ADDRXLAT_SYS_METH_KPHYS_MACHPHYS , ADDRXLAT_SYS_METH_CUSTOM } |
Translation system method index. More... | |
enum | _addrxlat_optidx { ADDRXLAT_OPT_NULL , ADDRXLAT_OPT_arch , ADDRXLAT_OPT_os_type , ADDRXLAT_OPT_version_code , ADDRXLAT_OPT_phys_bits , ADDRXLAT_OPT_virt_bits , ADDRXLAT_OPT_page_shift , ADDRXLAT_OPT_phys_base , ADDRXLAT_OPT_rootpgt , ADDRXLAT_OPT_xen_p2m_mfn , ADDRXLAT_OPT_xen_xlat , ADDRXLAT_OPT_NUM } |
Option number. More... | |
enum | _addrxlat_sys_map { ADDRXLAT_SYS_MAP_HW , ADDRXLAT_SYS_MAP_KV_PHYS , ADDRXLAT_SYS_MAP_KPHYS_DIRECT , ADDRXLAT_SYS_MAP_MACHPHYS_KPHYS , ADDRXLAT_SYS_MAP_KPHYS_MACHPHYS , ADDRXLAT_SYS_MAP_NUM } |
Translation system map index. More... | |
typedef enum _addrxlat_addrspace | addrxlat_addrspace_t |
Address spaces. | |
typedef struct _addrxlat_fulladdr | addrxlat_fulladdr_t |
Full address (including address space specification). | |
typedef struct _addrxlat_ctx | addrxlat_ctx_t |
typedef struct _addrxlat_cb | addrxlat_cb_t |
typedef addrxlat_status | addrxlat_cb_reg_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the register value callback. | |
typedef addrxlat_status | addrxlat_cb_sym_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the symbol value callback. | |
typedef addrxlat_status | addrxlat_cb_sym_sizeof_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the symbol size callback. | |
typedef addrxlat_status | addrxlat_cb_sym_offsetof_fn(const addrxlat_cb_t *cb, const char *obj, const char *elem, addrxlat_addr_t *val) |
Type of the element offset callback. | |
typedef addrxlat_status | addrxlat_cb_num_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the number value callback. | |
typedef enum _addrxlat_byte_order | addrxlat_byte_order_t |
Data byte order. | |
typedef struct _addrxlat_buffer | addrxlat_buffer_t |
Read buffer metadata. | |
typedef void | addrxlat_put_page_fn(const addrxlat_buffer_t *buf) |
Type of the put-page callback. | |
typedef addrxlat_status | addrxlat_get_page_fn(const addrxlat_cb_t *cb, addrxlat_buffer_t *buf) |
Type of the get-page callback. | |
typedef unsigned long | addrxlat_read_caps_fn(const addrxlat_cb_t *cb) |
Type of the read capabilities callback. | |
typedef enum _addrxlat_kind | addrxlat_kind_t |
Address translation kind. | |
typedef struct _addrxlat_step | addrxlat_step_t |
typedef addrxlat_status | addrxlat_first_step_fn(addrxlat_step_t *step, addrxlat_addr_t addr) |
Type of function to initialize the first translation step. | |
typedef addrxlat_status | addrxlat_next_step_fn(addrxlat_step_t *step) |
Type of function to make one translation step. | |
typedef struct _addrxlat_param_custom | addrxlat_param_custom_t |
Parameters of custom translation. | |
typedef struct _addrxlat_param_linear | addrxlat_param_linear_t |
Parameters of linear translation. | |
typedef enum _addrxlat_pte_format | addrxlat_pte_format_t |
Page table entry format. | |
typedef struct _addrxlat_paging_form | addrxlat_paging_form_t |
typedef struct _addrxlat_param_pgt | addrxlat_param_pgt_t |
Parameters of page table translation. | |
typedef struct _addrxlat_lookup_elem | addrxlat_lookup_elem_t |
Lookup table element. | |
typedef struct _addrxlat_param_lookup | addrxlat_param_lookup_t |
Parameters of table lookup translation. | |
typedef struct _addrxlat_param_memarr | addrxlat_param_memarr_t |
Parameters of memory array translation. | |
typedef union _addrxlat_param | addrxlat_param_t |
Parameters of the translation method. | |
typedef struct _addrxlat_meth | addrxlat_meth_t |
Address translation method. | |
typedef enum _addrxlat_sys_meth | addrxlat_sys_meth_t |
Translation system method index. | |
typedef struct _addrxlat_range | addrxlat_range_t |
Definition of an address range. | |
typedef struct _addrxlat_map | addrxlat_map_t |
Address translation map. | |
typedef enum _addrxlat_optidx | addrxlat_optidx_t |
Option number. | |
typedef union _addrxlat_optval | addrxlat_optval_t |
Single option value. | |
typedef struct _addrxlat_opt | addrxlat_opt_t |
Single option. | |
typedef struct _addrxlat_sys | addrxlat_sys_t |
Address translations system. | |
typedef enum _addrxlat_sys_map | addrxlat_sys_map_t |
Translation system map index. | |
typedef addrxlat_status | addrxlat_op_fn(void *data, const addrxlat_fulladdr_t *addr) |
Type of the addrxlat_op callback. | |
typedef struct _addrxlat_op_ctl | addrxlat_op_ctl_t |
Callback function pointers and data. | |
const char * | addrxlat_addrspace_name (addrxlat_addrspace_t as) |
Get the (string) name of an address space. | |
addrxlat_ctx_t * | addrxlat_ctx_new (void) |
Allocate and initialize a new address translation context. | |
unsigned long | addrxlat_ctx_incref (addrxlat_ctx_t *ctx) |
Increment the reference counter. | |
unsigned long | addrxlat_ctx_decref (addrxlat_ctx_t *ctx) |
Decrement the reference counter. | |
addrxlat_status | addrxlat_ctx_err (addrxlat_ctx_t *ctx, addrxlat_status status, const char *msgfmt,...) __attribute__((format(printf |
Prepend an error message. | |
addrxlat_status void | addrxlat_ctx_clear_err (addrxlat_ctx_t *ctx) |
Clear the error message. | |
const char * | addrxlat_ctx_get_err (const addrxlat_ctx_t *ctx) |
Get a detailed error string. | |
addrxlat_cb_t * | addrxlat_ctx_add_cb (addrxlat_ctx_t *ctx) |
Add a callback implementation. | |
void | addrxlat_ctx_del_cb (addrxlat_ctx_t *ctx, addrxlat_cb_t *cb) |
Remove a callback implementation. | |
const addrxlat_cb_t * | addrxlat_ctx_get_cb (const addrxlat_ctx_t *ctx) |
Get the callback information. | |
const char * | addrxlat_pte_format_name (addrxlat_pte_format_t fmt) |
Get the (string) name of a PTE format. | |
addrxlat_pte_format_t | addrxlat_pte_format (const char *name) |
Get a PTE format enum value by name. | |
int | addrxlat_pteval_shift (addrxlat_pte_format_t fmt) |
Get the pteval shift for a PTE format. | |
addrxlat_map_t * | addrxlat_map_new (void) |
Allocate and initialize a new address translation map. | |
unsigned long | addrxlat_map_incref (addrxlat_map_t *map) |
Increment translation map reference counter. | |
unsigned long | addrxlat_map_decref (addrxlat_map_t *map) |
Decrement translation map reference counter. | |
size_t | addrxlat_map_len (const addrxlat_map_t *map) |
Get translation map length. | |
const addrxlat_range_t * | addrxlat_map_ranges (const addrxlat_map_t *map) |
Get the ranges in a translation map. | |
addrxlat_status | addrxlat_map_set (addrxlat_map_t *map, addrxlat_addr_t addr, const addrxlat_range_t *range) |
Set map translation for an address range. | |
addrxlat_sys_meth_t | addrxlat_map_search (const addrxlat_map_t *map, addrxlat_addr_t addr) |
Find an address translation method in a translation map. | |
addrxlat_map_t * | addrxlat_map_copy (const addrxlat_map_t *map) |
Duplicate a translation map. | |
addrxlat_sys_t * | addrxlat_sys_new (void) |
Allocate a new translation system. | |
unsigned long | addrxlat_sys_incref (addrxlat_sys_t *sys) |
Increment translation system reference counter. | |
unsigned long | addrxlat_sys_decref (addrxlat_sys_t *sys) |
Decrement translation system reference counter. | |
addrxlat_status | addrxlat_sys_os_init (addrxlat_sys_t *sys, addrxlat_ctx_t *ctx, unsigned optc, const addrxlat_opt_t *opts) |
Set up a translation system for a pre-defined operating system. | |
void | addrxlat_sys_set_map (addrxlat_sys_t *sys, addrxlat_sys_map_t idx, addrxlat_map_t *map) |
Explicitly set the translation map of an OS map object. | |
addrxlat_map_t * | addrxlat_sys_get_map (const addrxlat_sys_t *sys, addrxlat_sys_map_t idx) |
Get the translation map of an OS map object. | |
void | addrxlat_sys_set_meth (addrxlat_sys_t *sys, addrxlat_sys_meth_t idx, const addrxlat_meth_t *meth) |
Explicitly set an address translation method for a translation system. | |
const addrxlat_meth_t * | addrxlat_sys_get_meth (const addrxlat_sys_t *sys, addrxlat_sys_meth_t idx) |
Get a specific translation method of a translation system. | |
addrxlat_status | addrxlat_launch (addrxlat_step_t *step, addrxlat_addr_t addr) |
Make the first translation step (launch a translation). | |
addrxlat_status | addrxlat_step (addrxlat_step_t *step) |
Perform one translation step. | |
addrxlat_status | addrxlat_walk (addrxlat_step_t *step) |
Perform one complete address translation. | |
addrxlat_status | addrxlat_op (const addrxlat_op_ctl_t *ctl, const addrxlat_fulladdr_t *addr) |
Perform a generic operation on a translated address. | |
addrxlat_status | addrxlat_fulladdr_conv (addrxlat_fulladdr_t *faddr, addrxlat_addrspace_t as, addrxlat_ctx_t *ctx, addrxlat_sys_t *sys) |
Translate a full address. | |
Public interface for libaddrxlat
(address translation library).
#define ADDRXLAT_FIELDS_MAX 8 |
Maximum number of bit fields in the source address.
This is a theoretical limit, with enough reserve for future enhancements. Currently, IBM z/Architecture has up to 5-level paging (i.e. up to 6 fields in the virtual address), but only 4 are used by the Linux kernel. All other architectures have less paging levels.
#define ADDRXLAT_VER_LINUX | ( | a, | |
b, | |||
c | |||
) | (((a) << 16) + ((b) << 8) + (c)) |
Linux kernel version code.
This macro can be used to convert a three-part Linux kernel version to a single number for use as @xref ADDRXLAT_OPT_version_code.
#define ADDRXLAT_VER_XEN | ( | major, | |
minor | |||
) | (((major) << 16) | (minor)) |
Xen version code.
This macro can be used to convert a Xen major/minor version pair to a single number for use as @xref ADDRXLAT_OPT_version_code.
#define ADDRXLAT_VERSION |
Version as a single number.
typedef uint_fast64_t addrxlat_addr_t |
Type of a physical or virtual address.
This type is large enough to hold any possible address type on any architecture supported by libaddrxlat
. Note that this type may be larger than the actual address in the target.
typedef enum _addrxlat_addrspace addrxlat_addrspace_t |
Address spaces.
This type is used to specify the kind of address.
The difference between ADDRXLAT_KPHYSADDR
and ADDRXLAT_MACHPHYSADDR
matters only in environments where the kernel has a different view of physical address space than the CPU, e.g. paravirtualized kernels under Xen.
typedef enum _addrxlat_byte_order addrxlat_byte_order_t |
Data byte order.
Byte order of the raw data returned by callbacks.
typedef addrxlat_status addrxlat_cb_num_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the number value callback.
cb | This callback definition. |
name[in] | Name of the numeric parameter. |
val[out] | Parameter value. |
typedef addrxlat_status addrxlat_cb_reg_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the register value callback.
cb | This callback definition. |
name[in] | Register name. |
val[out] | Register value. |
typedef addrxlat_status addrxlat_cb_sym_offsetof_fn(const addrxlat_cb_t *cb, const char *obj, const char *elem, addrxlat_addr_t *val) |
Type of the element offset callback.
cb | This callback definition. |
obj[in] | Name of the container object (e.g. of a struct ). |
elem[in] | Name of the element (e.g. a structure field). |
val[out] | Offset of elem within obj , offsetof(obj, elem) . |
typedef addrxlat_status addrxlat_cb_sym_sizeof_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the symbol size callback.
cb | This callback definition. |
name[in] | Name of a symbol or data type. |
val[out] | Symbol size, sizeof(name) . |
typedef addrxlat_status addrxlat_cb_sym_value_fn(const addrxlat_cb_t *cb, const char *name, addrxlat_addr_t *val) |
Type of the symbol value callback.
cb | This callback definition. |
name[in] | Symbol name. |
val[out] | Symbol value (e.g. address of a variable). |
typedef addrxlat_status addrxlat_first_step_fn(addrxlat_step_t *step, addrxlat_addr_t addr) |
Type of function to initialize the first translation step.
step | Partially initialized step state. |
addr | Address to be translated. |
Only the context fields (ctx
, sys
and meth
) are set by the caller. The state fields are uninitialized.
typedef addrxlat_status addrxlat_get_page_fn(const addrxlat_cb_t *cb, addrxlat_buffer_t *buf) |
Type of the get-page callback.
cb | This callback definition. | |
[in,out] | buf | Page buffer metadata. |
typedef struct _addrxlat_lookup_elem addrxlat_lookup_elem_t |
Lookup table element.
This defines address mapping for a single object. Addresses inside the object are mapped linearly using an offset.
typedef addrxlat_status addrxlat_next_step_fn(addrxlat_step_t *step) |
Type of function to make one translation step.
step | Current step state. |
This function is called repeatedly with a non-zero step->remain
.
Note that page offset is automatically added by addrxlat_step when step->remain
is 1. The callback function is never called to do this final step.
The callback function is explicitly allowed to modify step->remain
and/or the indices in step->idx
[]. This is needed if some levels of paging are skipped (huge pages).
typedef int_fast64_t addrxlat_off_t |
Type of an address offset.
This type is as large as addrxlat_addr_t, but it is signed, so suitable for offsets, both positive and negative.
typedef addrxlat_status addrxlat_op_fn(void *data, const addrxlat_fulladdr_t *addr) |
Type of the addrxlat_op callback.
data | Arbitrary user-supplied data. | |
[in] | addr | Translated address. |
typedef uint_fast64_t addrxlat_pte_t |
Type for a PTE value.
Use this type to work with PTE values. Note that this type may be bigger than the actual PTE on a given architecture and always uses host byte order, so variables of this type are not suitable for use as a buffer.
typedef void addrxlat_put_page_fn(const addrxlat_buffer_t *buf) |
Type of the put-page callback.
[in] | buf | Page buffer metadata. |
typedef unsigned long addrxlat_read_caps_fn(const addrxlat_cb_t *cb) |
Type of the read capabilities callback.
cb | This callback definition. |
The return value is a bit mask of address spaces that can be read directly by the read callbacks. Bits are enumerated by addrxlat_addrspace_t (least significant bit first).
typedef enum _addrxlat_status addrxlat_status |
Status code.
Positive codes are reserved for future library enhancements. Negative status codes may be used for custom use.
typedef enum _addrxlat_sys_map addrxlat_sys_map_t |
Translation system map index.
The OS map object contains several translation maps to allow translation between different address spaces. They can be manipulated directly using addrxlat_sys_set_map and addrxlat_sys_get_map using one of these indices.
typedef enum _addrxlat_sys_meth addrxlat_sys_meth_t |
Translation system method index.
A translation system uses a number of translation methods to do its job. Any of them can be obtained with addrxlat_sys_get_meth or overridden with addrxlat_sys_set_meth using one of these indices.
typedef struct _addrxlat_sys addrxlat_sys_t |
Address translations system.
In addition to a addrxlat_map_t, this structure also contains any OS-specific data.
enum _addrxlat_addrspace |
Address spaces.
This type is used to specify the kind of address.
The difference between ADDRXLAT_KPHYSADDR
and ADDRXLAT_MACHPHYSADDR
matters only in environments where the kernel has a different view of physical address space than the CPU, e.g. paravirtualized kernels under Xen.
Enumerator | |
---|---|
ADDRXLAT_KPHYSADDR | Kernel physical address. |
ADDRXLAT_MACHPHYSADDR | Machine physical address. |
ADDRXLAT_KVADDR | Kernel virtual address. |
ADDRXLAT_NOADDR | Invalid address. |
enum _addrxlat_byte_order |
enum _addrxlat_kind |
enum _addrxlat_optidx |
Option number.
enum _addrxlat_pte_format |
Page table entry format.
enum _addrxlat_status |
Status code.
Positive codes are reserved for future library enhancements. Negative status codes may be used for custom use.
enum _addrxlat_sys_map |
Translation system map index.
The OS map object contains several translation maps to allow translation between different address spaces. They can be manipulated directly using addrxlat_sys_set_map and addrxlat_sys_get_map using one of these indices.
Enumerator | |
---|---|
ADDRXLAT_SYS_MAP_HW | Map virtual addresses using same method as hardware. Unlike ADDRXLAT_SYS_MAP_KV_PHYS, translations in this map will always walk the hardware page table. This is mostly useful for implementing a verbose |
ADDRXLAT_SYS_MAP_KV_PHYS | Map kernel virtual addresses to physical addresses. This translation accepts ADDRXLAT_KVADDR on input and translates it to a physical address. This is either ADDRXLAT_KPHYSADDR or ADDRXLAT_MACHPHYSADDR, whichever is more efficient. |
ADDRXLAT_SYS_MAP_KPHYS_DIRECT | Map kernel physical addresses to a direct-mapped virtual address. |
ADDRXLAT_SYS_MAP_MACHPHYS_KPHYS | Map machine physical addresses to kernel physical addresses. |
ADDRXLAT_SYS_MAP_KPHYS_MACHPHYS | Map kernel physical addresses to machine physical addresses. |
ADDRXLAT_SYS_MAP_NUM | Total number of indices. |
enum _addrxlat_sys_meth |
Translation system method index.
A translation system uses a number of translation methods to do its job. Any of them can be obtained with addrxlat_sys_get_meth or overridden with addrxlat_sys_set_meth using one of these indices.
const char * addrxlat_addrspace_name | ( | addrxlat_addrspace_t | as | ) |
Get the (string) name of an address space.
as | Address space. |
addrxlat_cb_t * addrxlat_ctx_add_cb | ( | addrxlat_ctx_t * | ctx | ) |
Add a callback implementation.
ctx | Address translation context. |
NULL
on allocation error.The caller should override the callback settings in the returned structure as necessary. Callbacks that are not modified will use the previously installed implementation.
addrxlat_status void addrxlat_ctx_clear_err | ( | addrxlat_ctx_t * | ctx | ) |
Clear the error message.
ctx | Address translation context. |
unsigned long addrxlat_ctx_decref | ( | addrxlat_ctx_t * | ctx | ) |
Decrement the reference counter.
ctx | Address translation context. |
If the new reference count is zero, the underlying object is freed and its address must not be used afterwards.
void addrxlat_ctx_del_cb | ( | addrxlat_ctx_t * | ctx, |
addrxlat_cb_t * | cb | ||
) |
Remove a callback implementation.
ctx | Address translation context. |
cb | Callback settings previously returned by addrxlat_ctx_add_cb. |
The cb
parameter is invalid and must not be used after calling this function. It is an error to call this function twice on the same value. It is also an error to pass a pointer that was not obtained by calling addrxlat_ctx_add_cb.
addrxlat_status addrxlat_ctx_err | ( | addrxlat_ctx_t * | ctx, |
addrxlat_status | status, | ||
const char * | msgfmt, | ||
... | |||
) |
Prepend an error message.
ctx | Address translation context. |
status | Error status. |
msgfmt | Message format string (printf style). |
This function prepends the new error message to the existing content of the error buffer, resulting in a kind of error backtrace.
const addrxlat_cb_t * addrxlat_ctx_get_cb | ( | const addrxlat_ctx_t * | ctx | ) |
Get the callback information.
ctx | Address translation context. |
The return value is const
to indicate that it should not be modified by the caller, but the value can be modified non-atomically by another caller who obtained the pointer through addrxlat_ctx_add_cb.
const char * addrxlat_ctx_get_err | ( | const addrxlat_ctx_t * | ctx | ) |
Get a detailed error string.
ctx | Address translation context. |
If an error status is returned, this function can be used to get a human-readable description of the error. The error string is not reset by calling this function, but it is reset by calling any library function that returns addrxlat_status.
unsigned long addrxlat_ctx_incref | ( | addrxlat_ctx_t * | ctx | ) |
Increment the reference counter.
ctx | Address translation context. |
addrxlat_ctx_t * addrxlat_ctx_new | ( | void | ) |
Allocate and initialize a new address translation context.
NULL
on failure.This call can fail if and only if memory allocation fails. The reference count of the newly created object is one.
addrxlat_status addrxlat_fulladdr_conv | ( | addrxlat_fulladdr_t * | faddr, |
addrxlat_addrspace_t | as, | ||
addrxlat_ctx_t * | ctx, | ||
addrxlat_sys_t * | sys | ||
) |
Translate a full address.
faddr | Full address to be translated. |
as | Target address space. |
ctx | Address translation context. |
sys | Translation system. |
Convert a full address to the target address space using the given translation context and translation system.
addrxlat_status addrxlat_launch | ( | addrxlat_step_t * | step, |
addrxlat_addr_t | addr | ||
) |
Make the first translation step (launch a translation).
step | (Initialized) translation step state. |
addr | Address to be translated. |
See addrxlat_step_t for information on which fields in @step must be initialized prior to calling this function.
addrxlat_map_t * addrxlat_map_copy | ( | const addrxlat_map_t * | map | ) |
Duplicate a translation map.
map | Source translation map. |
map
, or NULL
on allocation failure. unsigned long addrxlat_map_decref | ( | addrxlat_map_t * | map | ) |
Decrement translation map reference counter.
map | Translation map. |
If the new reference count is zero, the underlying object is freed and its address must not be used afterwards.
unsigned long addrxlat_map_incref | ( | addrxlat_map_t * | map | ) |
Increment translation map reference counter.
map | Translation map. |
size_t addrxlat_map_len | ( | const addrxlat_map_t * | map | ) |
Get translation map length.
map | Address translation map. |
addrxlat_map_t * addrxlat_map_new | ( | void | ) |
Allocate and initialize a new address translation map.
NULL
on failure.This call can fail if and only if memory allocation fails. The reference count of the newly created object is one.
const addrxlat_range_t * addrxlat_map_ranges | ( | const addrxlat_map_t * | map | ) |
Get the ranges in a translation map.
map | Address translation map. |
The first range in a map starts at address 0, and each following range starts right after the previous one (i.e. at endoff
+ 1).
addrxlat_sys_meth_t addrxlat_map_search | ( | const addrxlat_map_t * | map, |
addrxlat_addr_t | addr | ||
) |
Find an address translation method in a translation map.
map | Address translation map. |
addr | Address to be translated. |
If no entry is found in the translation map, this function returns ADDRXLAT_SYS_METH_NONE
.
addrxlat_status addrxlat_map_set | ( | addrxlat_map_t * | map, |
addrxlat_addr_t | addr, | ||
const addrxlat_range_t * | range | ||
) |
Set map translation for an address range.
map | Address translation map. |
addr | Range start address. |
range | Translation range definition. |
If this function fails, the original map
is left untouched.
addrxlat_status addrxlat_op | ( | const addrxlat_op_ctl_t * | ctl, |
const addrxlat_fulladdr_t * | addr | ||
) |
Perform a generic operation on a translated address.
ctl | Control structure. |
addr | Address (in any address space). |
NB: If there is no way to translate the source address space to target address space, this function returns ADDRXLAT_ERR_NOMETH.
addrxlat_pte_format_t addrxlat_pte_format | ( | const char * | name | ) |
Get a PTE format enum value by name.
name | PTE name. |
ADDRXLAT_PTE_INVALID
if name
is not recognized.The name is not case-sensitive, e.g. "AARCH64", "AArch64" and "aarch64" are handled the same.
const char * addrxlat_pte_format_name | ( | addrxlat_pte_format_t | fmt | ) |
Get the (string) name of a PTE format.
fmt | PTE format. |
NULL
if unknown. int addrxlat_pteval_shift | ( | addrxlat_pte_format_t | fmt | ) |
Get the pteval shift for a PTE format.
fmt | PTE format. |
addrxlat_status addrxlat_step | ( | addrxlat_step_t * | step | ) |
Perform one translation step.
step | Current step state. |
const char * addrxlat_strerror | ( | addrxlat_status | status | ) |
Return the string describing a given error status.
status | Error status. |
unsigned long addrxlat_sys_decref | ( | addrxlat_sys_t * | sys | ) |
Decrement translation system reference counter.
sys | Translation system. |
If the new reference count is zero, the underlying object is freed and its address must not be used afterwards.
addrxlat_map_t * addrxlat_sys_get_map | ( | const addrxlat_sys_t * | sys, |
addrxlat_sys_map_t | idx | ||
) |
Get the translation map of an OS map object.
sys | Translation system. |
idx | Map index. |
const addrxlat_meth_t * addrxlat_sys_get_meth | ( | const addrxlat_sys_t * | sys, |
addrxlat_sys_meth_t | idx | ||
) |
Get a specific translation method of a translation system.
sys | Translation system. |
idx | Translation method index. |
unsigned long addrxlat_sys_incref | ( | addrxlat_sys_t * | sys | ) |
Increment translation system reference counter.
sys | Translation system. |
addrxlat_sys_t * addrxlat_sys_new | ( | void | ) |
Allocate a new translation system.
NULL
.This call can fail if and only if memory allocation fails.
addrxlat_status addrxlat_sys_os_init | ( | addrxlat_sys_t * | sys, |
addrxlat_ctx_t * | ctx, | ||
unsigned | optc, | ||
const addrxlat_opt_t * | opts | ||
) |
Set up a translation system for a pre-defined operating system.
sys | Translation sytem. |
ctx | Address translation context. |
optc | Number of options. |
opts | Additional options (ignored if optc is zero). |
This function uses OS-specific data and built-in heuristics to determine the translation map and page-table translation for an operating system.
void addrxlat_sys_set_map | ( | addrxlat_sys_t * | sys, |
addrxlat_sys_map_t | idx, | ||
addrxlat_map_t * | map | ||
) |
Explicitly set the translation map of an OS map object.
sys | Translation system. |
idx | Map index. |
map | Translation map. |
void addrxlat_sys_set_meth | ( | addrxlat_sys_t * | sys, |
addrxlat_sys_meth_t | idx, | ||
const addrxlat_meth_t * | meth | ||
) |
Explicitly set an address translation method for a translation system.
sys | Translation system. |
idx | Translation method index. |
meth | New translation method. |
addrxlat_status addrxlat_walk | ( | addrxlat_step_t * | step | ) |
Perform one complete address translation.
step | Initialized translation step state. |
The source address to be translated is in step->base
. All other fields must be initialized as for a call to addrxlat_launch. On successful return, the resulting address is found in step->base
.