LCOV - code coverage report
Current view: top level - zephyr/xen - memory.h Coverage Total Hit
Test: new.info Lines: 83.3 % 6 5
Test Date: 2025-10-20 12:20:01

            Line data    Source code
       1            0 : /* SPDX-License-Identifier: Apache-2.0 */
       2              : /*
       3              :  * Copyright (c) 2023 EPAM Systems
       4              :  */
       5              : 
       6              : #ifndef ZEPHYR_XEN_MEMORY_H_
       7              : #define ZEPHYR_XEN_MEMORY_H_
       8              : 
       9              : #include <zephyr/kernel.h>
      10              : #include <zephyr/xen/public/memory.h>
      11              : #include <zephyr/xen/public/xen.h>
      12              : 
      13              : /**
      14              :  * Add mapping for specified page frame in Xen domain physmap.
      15              :  *
      16              :  * @param domid domain id, where mapping will be added. For unprivileged should
      17              :  *              be DOMID_SELF.
      18              :  * @param idx   index into space being mapped.
      19              :  * @param space XENMAPSPACE_* mapping space identifier.
      20              :  * @param gpfn  page frame where the source mapping page should appear.
      21              :  * @return      zero on success, negative errno on error.
      22              :  */
      23            1 : int xendom_add_to_physmap(int domid, unsigned long idx, unsigned int space,
      24              :                           xen_pfn_t gpfn);
      25              : 
      26              : /**
      27              :  * Add mapping for specified set of page frames to Xen domain physmap.
      28              :  *
      29              :  * @param domid         domain id, where mapping will be added. For unprivileged
      30              :  *                      should be DOMID_SELF.
      31              :  * @param foreign_domid for gmfn_foreign - domain id, whose pages being mapped,
      32              :  *                      0 for other.
      33              :  * @param space         XENMAPSPACE_* mapping space identifier.
      34              :  * @param size          number of page frames being mapped.
      35              :  * @param idxs          array of indexes into space being mapped.
      36              :  * @param gpfns         array of page frames where the mapping should appear.
      37              :  * @param errs          array of per-index error codes.
      38              :  * @return              zero on success, negative errno on error.
      39              :  */
      40            1 : int xendom_add_to_physmap_batch(int domid, int foreign_domid,
      41              :                                 unsigned int space, unsigned int size,
      42              :                                 xen_ulong_t *idxs, xen_pfn_t *gpfns, int *errs);
      43              : 
      44              : /**
      45              :  * Removes page frame from Xen domain physmap.
      46              :  *
      47              :  * @param domid domain id, whose page is going to be removed. For unprivileged
      48              :  *              should be DOMID_SELF.
      49              :  * @param gpfn  page frame number, that needs to be removed
      50              :  * @return      zero on success, negative errno on error.
      51              :  */
      52            1 : int xendom_remove_from_physmap(int domid, xen_pfn_t gpfn);
      53              : 
      54              : /**
      55              :  * Populate specified Xen domain page frames with memory.
      56              :  *
      57              :  * @param domid         domain id, where mapping will be added. For unprivileged
      58              :  *                      should be DOMID_SELF.
      59              :  * @param extent_order  size/alignment of each extent (size is 2^extent_order),
      60              :  *                      e.g. 0 for 4K extents, 9 for 2M etc.
      61              :  * @param nr_extents    number of page frames being populated.
      62              :  * @param mem_flags     N/A, should be 0 for Arm.
      63              :  * @param extent_start  page frame bases of extents to populate with memory.
      64              :  * @return              number of populated frames success, negative errno on
      65              :  *                      error.
      66              :  */
      67            1 : int xendom_populate_physmap(int domid, unsigned int extent_order,
      68              :                             unsigned int nr_extents, unsigned int mem_flags,
      69              :                             xen_pfn_t *extent_start);
      70              : 
      71              : /**
      72              :  * @brief Acquire a resource mapping for the Xen domain.
      73              :  *
      74              :  * Issues the XENMEM_acquire_resource hypercall to map a resource buffer
      75              :  * (e.g., I/O request server, grant table, VM trace buffer) into the
      76              :  * specified domain's physmap, or query its total size.
      77              :  *
      78              :  * @param domid        Target domain identifier. Use DOMID_SELF for the calling domain.
      79              :  * @param type         Resource type identifier (e.g., XENMEM_resource_ioreq_server).
      80              :  * @param id           Resource-specific identifier (e.g., server ID or table ID).
      81              :  * @param frame        Starting frame number for mapping, or ignored if *nr_frames == 0.
      82              :  * @param nr_frames    [in,out] On input, number of frames to map; on return,
      83              :  *                     number of frames actually mapped (or total frames if queried).
      84              :  * @param frame_list   Guest frame list buffer: input GFNs for HVM guests,
      85              :  *                     output MFNs for PV guests.
      86              :  * @return             Zero on success, or a negative errno code on failure.
      87              :  */
      88            1 : int xendom_acquire_resource(domid_t domid, uint16_t type, uint32_t id, uint64_t frame,
      89              :                             uint32_t *nr_frames, xen_pfn_t *frame_list);
      90              : 
      91              : #endif /* ZEPHYR_XEN_MEMORY_H_ */
        

Generated by: LCOV version 2.0-1