libkdumpfile-0.4.0
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_sym |
Data structure used to hold symbolic information. 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... | |
struct | _addrxlat_osdesc |
Description of an operating system. 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 4 |
Minor version (2nd number in the release tag). | |
#define | ADDRXLAT_VER_MICRO 0 |
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. More... | |
#define | ADDRXLAT_VERSION_STRING "0.4.0" |
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. More... | |
typedef uint_fast64_t | addrxlat_addr_t |
Type of a physical or virtual address. More... | |
typedef int_fast64_t | addrxlat_off_t |
Type of an address offset. More... | |
typedef uint_fast64_t | addrxlat_pte_t |
Type for a PTE value. More... | |
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. More... | |
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_SYM_ARGC_MAX 2 |
Maximum argument count for addrxlat_sym_t. | |
#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. More... | |
#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. More... | |
#define | ADDRXLAT_VER_XEN(major, minor) (((major) << 16) | (minor)) |
Xen version code. More... | |
enum | _addrxlat_addrspace { ADDRXLAT_KPHYSADDR , ADDRXLAT_MACHPHYSADDR , ADDRXLAT_KVADDR , ADDRXLAT_NOADDR = -1 } |
Address spaces. More... | |
enum | _addrxlat_sym_type { ADDRXLAT_SYM_REG , ADDRXLAT_SYM_VALUE , ADDRXLAT_SYM_SIZEOF , ADDRXLAT_SYM_OFFSETOF } |
Type of symbolic information. 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_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 } |
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_ostype { ADDRXLAT_OS_UNKNOWN , ADDRXLAT_OS_LINUX , ADDRXLAT_OS_XEN } |
Operating system type. 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. More... | |
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 void | addrxlat_cb_hook_fn(void *data, addrxlat_cb_t *cb) |
Type of the callback hook function. More... | |
typedef enum _addrxlat_sym_type | addrxlat_sym_type_t |
Type of symbolic information. | |
typedef struct _addrxlat_sym | addrxlat_sym_t |
Data structure used to hold symbolic information. | |
typedef addrxlat_status | addrxlat_sym_fn(void *data, addrxlat_sym_t *sym) |
Type of the symbolic information callback. More... | |
typedef enum _addrxlat_byte_order | addrxlat_byte_order_t |
Data byte order. More... | |
typedef struct _addrxlat_buffer | addrxlat_buffer_t |
Read buffer metadata. More... | |
typedef addrxlat_status | addrxlat_get_page_fn(void *data, addrxlat_buffer_t *buf) |
Type of the get-page callback. More... | |
typedef void | addrxlat_put_page_fn(void *data, const addrxlat_buffer_t *buf) |
Type of the put-page callback. More... | |
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. More... | |
typedef addrxlat_status | addrxlat_next_step_fn(addrxlat_step_t *step) |
Type of function to make one translation step. More... | |
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. More... | |
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. More... | |
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_ostype | addrxlat_ostype_t |
Operating system type. | |
typedef struct _addrxlat_osdesc | addrxlat_osdesc_t |
Description of an operating system. More... | |
typedef struct _addrxlat_sys | addrxlat_sys_t |
Address translations system. More... | |
typedef enum _addrxlat_sys_map | addrxlat_sys_map_t |
Translation system map index. More... | |
typedef addrxlat_status | addrxlat_op_fn(void *data, const addrxlat_fulladdr_t *addr) |
Type of the addrxlat_op callback. More... | |
typedef struct _addrxlat_op_ctl | addrxlat_op_ctl_t |
Callback function pointers and data. | |
addrxlat_ctx_t * | addrxlat_ctx_new (void) |
Allocate and initialize a new address translation context. More... | |
unsigned long | addrxlat_ctx_incref (addrxlat_ctx_t *ctx) |
Increment the reference counter. More... | |
unsigned long | addrxlat_ctx_decref (addrxlat_ctx_t *ctx) |
Decrement the reference counter. More... | |
addrxlat_status | addrxlat_ctx_err (addrxlat_ctx_t *ctx, addrxlat_status status, const char *msgfmt,...) __attribute__((format(printf |
Prepend an error message. More... | |
addrxlat_status void | addrxlat_ctx_clear_err (addrxlat_ctx_t *ctx) |
Clear the error message. More... | |
const char * | addrxlat_ctx_get_err (const addrxlat_ctx_t *ctx) |
Get a detailed error string. More... | |
void | addrxlat_ctx_set_cb (addrxlat_ctx_t *ctx, const addrxlat_cb_t *cb) |
Set callback information. More... | |
const addrxlat_cb_t * | addrxlat_ctx_get_cb (const addrxlat_ctx_t *ctx) |
Get the callback information. More... | |
addrxlat_cb_t * | addrxlat_ctx_get_ecb (addrxlat_ctx_t *ctx) |
Get the effective callback information. More... | |
addrxlat_map_t * | addrxlat_map_new (void) |
Allocate and initialize a new address translation map. More... | |
unsigned long | addrxlat_map_incref (addrxlat_map_t *map) |
Increment translation map reference counter. More... | |
unsigned long | addrxlat_map_decref (addrxlat_map_t *map) |
Decrement translation map reference counter. More... | |
size_t | addrxlat_map_len (const addrxlat_map_t *map) |
Get translation map length. More... | |
const addrxlat_range_t * | addrxlat_map_ranges (const addrxlat_map_t *map) |
Get the ranges in a translation map. More... | |
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. More... | |
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. More... | |
addrxlat_map_t * | addrxlat_map_copy (const addrxlat_map_t *map) |
Duplicate a translation map. More... | |
addrxlat_sys_t * | addrxlat_sys_new (void) |
Allocate a new translation system. More... | |
unsigned long | addrxlat_sys_incref (addrxlat_sys_t *sys) |
Increment translation system reference counter. More... | |
unsigned long | addrxlat_sys_decref (addrxlat_sys_t *sys) |
Decrement translation system reference counter. More... | |
addrxlat_status | addrxlat_sys_os_init (addrxlat_sys_t *sys, addrxlat_ctx_t *ctx, const addrxlat_osdesc_t *osdesc) |
Set up a translation system for a pre-defined operating system. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
addrxlat_status | addrxlat_launch (addrxlat_step_t *step, addrxlat_addr_t addr) |
Make the first translation step (launch a translation). More... | |
addrxlat_status | addrxlat_step (addrxlat_step_t *step) |
Perform one translation step. More... | |
addrxlat_status | addrxlat_walk (addrxlat_step_t *step) |
Perform one complete address translation. More... | |
addrxlat_status | addrxlat_op (const addrxlat_op_ctl_t *ctl, const addrxlat_fulladdr_t *addr) |
Perform a generic operation on a translated address. More... | |
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. More... | |
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 ver
in addrxlat_osdesc_t.
#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 ver
in addrxlat_osdesc_t.
#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 struct _addrxlat_buffer addrxlat_buffer_t |
Read buffer metadata.
This structure is used to pass data between the library and a callback function. The idea is that the library should not have to care about the limitations of any given implementation. It communicates the intention to get data at a given address, the get-page callback translates that to a full page and returns as much as possible, adjusting remaining fields accordingly.
NOTE: The callback may theoretically provide as little as one byte at the desired address. However, it does not happen in practice, because:
typedef enum _addrxlat_byte_order addrxlat_byte_order_t |
Data byte order.
Byte order of the raw data returned by callbacks.
typedef void addrxlat_cb_hook_fn(void *data, addrxlat_cb_t *cb) |
Type of the callback hook function.
data | Arbitrary user-supplied data. |
cb | New callbacks (already installed). |
This callback is called after installing new callbacks. This function may change the new callbacks, and the modified version will then be used instead of the original values.
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(void *data, addrxlat_buffer_t *buf) |
Type of the get-page callback.
data | Arbitrary user-supplied data. | |
[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 struct _addrxlat_osdesc addrxlat_osdesc_t |
Description of an operating system.
This structure is used to pass some details about the operating system to set up a translation map.
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(void *data, const addrxlat_buffer_t *buf) |
Type of the put-page callback.
data | Arbitrary user-supplied data. | |
[in] | buf | Page buffer metadata. |
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 addrxlat_status addrxlat_sym_fn(void *data, addrxlat_sym_t *sym) |
Type of the symbolic information callback.
data | Arbitrary user-supplied data. |
sym | Symbolic information, updated on success. |
The callback function should check the information type and fill in the output fields in sym
. If it is called for a type that is not handled (including an unknown type, not listed above), it must return ADDRXLAT_ERR_NOTIMPL.
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_ostype |
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_sym_type |
Type of symbolic information.
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.
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.
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. |
Note that this function returns a pointer into context private data. The location of this data does not change (i.e. when called with the same translation context, this function always returns the same value). However, the referenced data may change non-atomically during a call to addrxlat_ctx_set_cb.
addrxlat_cb_t* addrxlat_ctx_get_ecb | ( | addrxlat_ctx_t * | ctx | ) |
Get the effective callback information.
ctx | Address translation context. |
This function returns a pointer to the effective callback information, i.e. after modifications by callback hook(s). The effective callbacks may be modified by the caller, e.g. to install a new hook.
The callback hook cannot be installed through addrxlat_ctx_set_cb, because that would call the existing hook on it instead of letting the new hook decide if it wants to override the behaviour.
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.
void addrxlat_ctx_set_cb | ( | addrxlat_ctx_t * | ctx, |
const addrxlat_cb_t * | cb | ||
) |
Set callback information.
ctx | Address translation context. |
cb | New callback settings. |
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_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, | ||
const addrxlat_osdesc_t * | osdesc | ||
) |
Set up a translation system for a pre-defined operating system.
sys | Translation sytem. |
ctx | Address translation context. |
osdesc | Description of the operating system. |
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
.