@@ -237,7 +237,6 @@ IoMmuDeviceTreeDiscovery (
237237
238238 //
239239 // Now, gather all the downstreams. Perform this separately to avoid excessive nesting.
240- // - TODO: Look for platform devices.
241240 //
242241 DownstreamDeviceNode = FdtNextNode (Fdt , -1 , NULL );
243242 while (DownstreamDeviceNode != - FDT_ERR_NOTFOUND ) {
@@ -246,6 +245,11 @@ IoMmuDeviceTreeDiscovery (
246245 goto NextDownstreamDeviceNode ;
247246 }
248247
248+ //
249+ // As the DevicePath on the DeviceHandle passed to IoMmuSetAttribute() isn't standardised
250+ // for platform devices, we've elected to create the EDKII_RISC_V_IO_MMU_PLATFORM_POLICY_PROTOCOL hook.
251+ // Even with information in the FDT/ACPI, this is unimplementable, because we can't construct a device_id.
252+ //
249253 if (!FdtStringListContains (PropertyPtr , TempLen , "pci-host-ecam-generic" ) && !FdtStringListContains (PropertyPtr , TempLen , "pci-host-cam-generic" )) {
250254 goto NextDownstreamDeviceNode ;
251255 }
@@ -320,7 +324,6 @@ IoMmuAcpiRimtDiscovery (
320324 EFI_ACPI_6_6_RIMT_PCIE_ROOT_COMPLEX_NODE_STRUCTURE * RimtPcieNode ;
321325 UINT16 NumberOfIdMappings ;
322326 EFI_ACPI_6_6_RIMT_ID_MAPPING_STRUCTURE * NodeMapping ;
323- //EFI_ACPI_6_6_RIMT_PLATFORM_DEVICE_NODE_STRUCTURE *RimtPlatformNode;
324327 UINTN MappingIndex ;
325328 LIST_ENTRY * Link ;
326329 RISCV_IOMMU_DOWNSTREAMS * IoMmuDownstreams ;
@@ -371,20 +374,19 @@ IoMmuAcpiRimtDiscovery (
371374 goto NodeEnd ;
372375 }
373376
374- if ( RimtNodeHeader -> Type == RimtNodePcieRc ) {
375- RimtPcieNode = ( VOID * ) RimtNodeHeader ;
376- NumberOfIdMappings = RimtPcieNode -> NumberOfIdMappings ;
377- NodeMapping = ( VOID * )(( UINT8 * ) RimtPcieNode + RimtPcieNode -> IdMappingArrayOffset );
378- } else {
379- // TODO: Look for platform devices properly.
377+ //
378+ // As the DevicePath on the DeviceHandle passed to IoMmuSetAttribute() isn't standardised
379+ // for platform devices, we've elected to create the EDKII_RISC_V_IO_MMU_PLATFORM_POLICY_PROTOCOL hook.
380+ // Even with information in the FDT/ACPI, this is unimplementable, because we can't construct a device_id.
381+ //
382+ if ( RimtNodeHeader -> Type != RimtNodePcieRc ) {
380383 goto NodeEnd ;
381- #if 0
382- RimtPlatformNode = (VOID * )RimtNodeHeader ;
383- NumberOfIdMappings = RimtPlatformNode -> NumberOfIdMappings ;
384- NodeMapping = (VOID * )((UINT8 * )RimtPlatformNode + RimtPlatformNode -> IdMappingArrayOffset );
385- #endif
386384 }
387385
386+ RimtPcieNode = (VOID * )RimtNodeHeader ;
387+ NumberOfIdMappings = RimtPcieNode -> NumberOfIdMappings ;
388+ NodeMapping = (VOID * )((UINT8 * )RimtPcieNode + RimtPcieNode -> IdMappingArrayOffset );
389+
388390 for (MappingIndex = 0 ; MappingIndex < NumberOfIdMappings ; MappingIndex ++ ) {
389391 for (Link = GetFirstNode (& mRiscVIoMmuContexts )
390392 ; !IsNull (& mRiscVIoMmuContexts , Link )
0 commit comments