@@ -465,37 +465,155 @@ struct dmar_info {
465
465
466
466
extern struct dmar_info * get_dmar_info (void );
467
467
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
+ */
468
488
struct iommu_domain ;
469
489
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
+ */
471
505
int assign_iommu_device (const struct iommu_domain * domain ,
472
506
uint8_t bus , uint8_t devfun );
473
507
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
+ */
475
523
int unassign_iommu_device (const struct iommu_domain * domain ,
476
524
uint8_t bus , uint8_t devfun );
477
525
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
+ */
479
542
struct iommu_domain * create_iommu_domain (uint16_t vm_id ,
480
543
uint64_t translation_table , uint32_t addr_width );
481
544
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
+ */
483
555
void destroy_iommu_domain (struct iommu_domain * domain );
484
556
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
+ */
486
563
void enable_iommu (void );
487
564
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
+ */
489
571
void disable_iommu (void );
490
572
491
- /* suspend iomu */
573
+ /**
574
+ * @brief Suspend IOMMUs.
575
+ *
576
+ * Suspend all IOMMUs, which are not ignored on the platform.
577
+ *
578
+ */
492
579
void suspend_iommu (void );
493
580
494
- /* resume iomu */
581
+ /**
582
+ * @brief Resume IOMMUs.
583
+ *
584
+ * Resume all IOMMUs, which are not ignored on the platform.
585
+ *
586
+ */
495
587
void resume_iommu (void );
496
588
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
+ */
498
598
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
+ */
499
613
void init_iommu_vm0_domain (struct vm * vm0 );
500
614
615
+ /**
616
+ * @}
617
+ */
618
+
501
619
#endif
0 commit comments