Skip to content

Commit 1776d7e

Browse files
binbinwu1dbkinder
authored andcommitted
hv: vtd: add structure and API docs
This patch adds more comments to describe the structures and functions of vtd that are public to the other components in the hypervisor. The comments are in doxygen-style for document generation. Tracked-On: #1595 Signed-off-by: Binbin Wu <binbin.wu@intel.com>
1 parent 7dc3e60 commit 1776d7e

File tree

1 file changed

+127
-9
lines changed
  • hypervisor/include/arch/x86

1 file changed

+127
-9
lines changed

hypervisor/include/arch/x86/vtd.h

Lines changed: 127 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,37 +465,155 @@ struct dmar_info {
465465

466466
extern struct dmar_info *get_dmar_info(void);
467467

468+
/**
469+
* @file vtd.h
470+
*
471+
* @brief public APIs for VT-d
472+
*/
473+
474+
/**
475+
* @brief VT-d
476+
*
477+
* @defgroup acrn_vtd ACRN VT-d
478+
* @{
479+
*/
480+
481+
482+
/**
483+
* @brief iommu domain.
484+
*
485+
* This struct declaration for iommu domain.
486+
*
487+
*/
468488
struct iommu_domain;
469489

470-
/* Assign a device specified by bus & devfun to a iommu domain */
490+
/**
491+
* @brief Assign a device specified by bus & devfun to a iommu domain.
492+
*
493+
* Remove the device from the VM0 domain (if present), and add it to the specific domain.
494+
*
495+
* @param[in] domain iommu domain the device is assigned to
496+
* @param[in] bus the 8-bit bus number of the device
497+
* @param[in] devfun the 8-bit device(5-bit):function(3-bit) of the device
498+
*
499+
* @return 0 - on success.
500+
* @return 1 - fail to unassign the device
501+
*
502+
* @pre domain != NULL
503+
*
504+
*/
471505
int assign_iommu_device(const struct iommu_domain *domain,
472506
uint8_t bus, uint8_t devfun);
473507

474-
/* Unassign a device specified by bus & devfun to a iommu domain */
508+
/**
509+
* @brief Unassign a device specified by bus & devfun from a iommu domain .
510+
*
511+
* Remove the device from the specific domain, and then add it to the VM0 domain (if present).
512+
*
513+
* @param[in] domain iommu domain the device is assigned to
514+
* @param[in] bus the 8-bit bus number of the device
515+
* @param[in] devfun the 8-bit device(5-bit):function(3-bit) of the device
516+
*
517+
* @return 0 - on success.
518+
* @return 1 - fail to unassign the device
519+
*
520+
* @pre domain != NULL
521+
*
522+
*/
475523
int unassign_iommu_device(const struct iommu_domain *domain,
476524
uint8_t bus, uint8_t devfun);
477525

478-
/* Create a iommu domain for a VM specified by vm_id */
526+
/**
527+
* @brief Create a iommu domain for a VM specified by vm_id.
528+
*
529+
* Create a iommu domain for a VM specified by vm_id, along with address translation table and address width.
530+
*
531+
* @param[in] vm_id vm_id of the VM the domain created for
532+
* @param[in] translation_table the physcial address of EPT table of the VM specified by the vm_id
533+
* @param[in] addr_width address width of the VM
534+
*
535+
* @return Pointer pointer to iommu_domain
536+
* @return NULL if translation_table is 0
537+
*
538+
* @pre vm_id is valid
539+
* @pre translation_table != 0
540+
*
541+
*/
479542
struct iommu_domain *create_iommu_domain(uint16_t vm_id,
480543
uint64_t translation_table, uint32_t addr_width);
481544

482-
/* Destroy the iommu domain */
545+
/**
546+
* @brief Destroy the specific iommu domain.
547+
*
548+
* Destroy the specific iommu domain when a VM no longer needs it.
549+
*
550+
* @param[in] domain iommu domain to destroy
551+
*
552+
* @pre domain != NULL
553+
*
554+
*/
483555
void destroy_iommu_domain(struct iommu_domain *domain);
484556

485-
/* Enable translation of iommu*/
557+
/**
558+
* @brief Enable translation of IOMMUs.
559+
*
560+
* Enable address translation of all IOMMUs, which are not ignored on the platform.
561+
*
562+
*/
486563
void enable_iommu(void);
487564

488-
/* Disable translation of iommu*/
565+
/**
566+
* @brief Disable translation of IOMMUs.
567+
*
568+
* Disable address translation of all IOMMUs, which are not ignored on the platform.
569+
*
570+
*/
489571
void disable_iommu(void);
490572

491-
/* suspend iomu */
573+
/**
574+
* @brief Suspend IOMMUs.
575+
*
576+
* Suspend all IOMMUs, which are not ignored on the platform.
577+
*
578+
*/
492579
void suspend_iommu(void);
493580

494-
/* resume iomu */
581+
/**
582+
* @brief Resume IOMMUs.
583+
*
584+
* Resume all IOMMUs, which are not ignored on the platform.
585+
*
586+
*/
495587
void resume_iommu(void);
496588

497-
/* iommu initialization */
589+
/**
590+
* @brief Init IOMMUs.
591+
*
592+
* Register DMAR units on the platform according to the pre-parsed information or DMAR table.
593+
*
594+
* @return 0 - on success
595+
* @return non-zero - iommu is a must have feature, if init_iommu failed, the system should not continue booting
596+
*
597+
*/
498598
int init_iommu(void);
599+
600+
/**
601+
* @brief Init VM0 domain of iommu.
602+
*
603+
* Create VM0 domain using the Normal World's EPT table of VM0 as address translation table.
604+
* All PCI devices are added to the VM0 domain when creating it.
605+
*
606+
* @param[in] vm0 pointer to VM0
607+
*
608+
* @pre vm0 shall point to VM0
609+
*
610+
* @remark to reduce boot time & memory cost, a config IOMMU_INIT_BUS_LIMIT, which limit the bus number.
611+
*
612+
*/
499613
void init_iommu_vm0_domain(struct vm *vm0);
500614

615+
/**
616+
* @}
617+
*/
618+
501619
#endif

0 commit comments

Comments
 (0)