DependencyObject* FrameworkTemplate::GetVisualTreeWithError (FrameworkElement *templateBindingSource, MoonError *error) { if (holdManagedRef || xaml_buffer) { DependencyObject *result = parse_template (parse_template_data, GetResourceBase (), GetDeployment ()->GetSurface (), templateBindingSource, xaml_buffer, error); if (result) NameScope::GetNameScope (result)->Lock (); return result; } return NULL; }
void BitmapImage::UriSourceChanged () { Surface *surface = Deployment::GetCurrent ()->GetSurface (); Application *app = Application::GetCurrent (); Uri *uri = GetUriSource (); if (surface == NULL) { SetBitmapData (NULL, false); return; } if (app && uri) { if (get_res_aborter) delete get_res_aborter; get_res_aborter = new Cancellable (); app->GetResource (GetResourceBase(), uri, resource_notify, pixbuf_write, policy, HttpRequest::DisableFileStorage, get_res_aborter, this); } }
/** Submits the I/O and memory resource requirements for the specified PCI Host Bridge. @param PciResAlloc Point to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL. @retval EFI_SUCCESS Successfully finished resource allocation. @retval EFI_NOT_FOUND Cannot get root bridge instance. @retval EFI_OUT_OF_RESOURCES Platform failed to program the resources if no hot plug supported. @retval other Some error occurred when allocating resources for the PCI Host Bridge. @note Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug. **/ EFI_STATUS PciHostBridgeResourceAllocator ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc ) { PCI_IO_DEVICE *RootBridgeDev; EFI_HANDLE RootBridgeHandle; VOID *AcpiConfig; EFI_STATUS Status; UINT64 IoBase; UINT64 Mem32Base; UINT64 PMem32Base; UINT64 Mem64Base; UINT64 PMem64Base; UINT64 IoResStatus; UINT64 Mem32ResStatus; UINT64 PMem32ResStatus; UINT64 Mem64ResStatus; UINT64 PMem64ResStatus; UINT64 MaxOptionRomSize; PCI_RESOURCE_NODE *IoBridge; PCI_RESOURCE_NODE *Mem32Bridge; PCI_RESOURCE_NODE *PMem32Bridge; PCI_RESOURCE_NODE *Mem64Bridge; PCI_RESOURCE_NODE *PMem64Bridge; PCI_RESOURCE_NODE IoPool; PCI_RESOURCE_NODE Mem32Pool; PCI_RESOURCE_NODE PMem32Pool; PCI_RESOURCE_NODE Mem64Pool; PCI_RESOURCE_NODE PMem64Pool; BOOLEAN ReAllocate; EFI_DEVICE_HANDLE_EXTENDED_DATA_PAYLOAD HandleExtendedData; EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD AllocFailExtendedData; // // Reallocate flag // ReAllocate = FALSE; // // It may try several times if the resource allocation fails // while (TRUE) { // // Initialize resource pool // InitializeResourcePool (&IoPool, PciBarTypeIo16); InitializeResourcePool (&Mem32Pool, PciBarTypeMem32); InitializeResourcePool (&PMem32Pool, PciBarTypePMem32); InitializeResourcePool (&Mem64Pool, PciBarTypeMem64); InitializeResourcePool (&PMem64Pool, PciBarTypePMem64); RootBridgeDev = NULL; RootBridgeHandle = 0; while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) { // // Get Root Bridge Device by handle // RootBridgeDev = GetRootBridgeByHandle (RootBridgeHandle); if (RootBridgeDev == NULL) { return EFI_NOT_FOUND; } // // Create the entire system resource map from the information collected by // enumerator. Several resource tree was created // // // If non-stardard PCI Bridge I/O window alignment is supported, // set I/O aligment to minimum possible alignment for root bridge. // IoBridge = CreateResourceNode ( RootBridgeDev, 0, FeaturePcdGet (PcdPciBridgeIoAlignmentProbe) ? 0x1FF: 0xFFF, RB_IO_RANGE, PciBarTypeIo16, PciResUsageTypical ); Mem32Bridge = CreateResourceNode ( RootBridgeDev, 0, 0xFFFFF, RB_MEM32_RANGE, PciBarTypeMem32, PciResUsageTypical ); PMem32Bridge = CreateResourceNode ( RootBridgeDev, 0, 0xFFFFF, RB_PMEM32_RANGE, PciBarTypePMem32, PciResUsageTypical ); Mem64Bridge = CreateResourceNode ( RootBridgeDev, 0, 0xFFFFF, RB_MEM64_RANGE, PciBarTypeMem64, PciResUsageTypical ); PMem64Bridge = CreateResourceNode ( RootBridgeDev, 0, 0xFFFFF, RB_PMEM64_RANGE, PciBarTypePMem64, PciResUsageTypical ); // // Create resourcemap by going through all the devices subject to this root bridge // CreateResourceMap ( RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge ); // // Get the max ROM size that the root bridge can process // RootBridgeDev->RomSize = Mem32Bridge->Length; // // Skip to enlarge the resource request during realloction // if (!ReAllocate) { // // Get Max Option Rom size for current root bridge // MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev); // // Enlarger the mem32 resource to accomdate the option rom // if the mem32 resource is not enough to hold the rom // if (MaxOptionRomSize > Mem32Bridge->Length) { Mem32Bridge->Length = MaxOptionRomSize; RootBridgeDev->RomSize = MaxOptionRomSize; // // Alignment should be adjusted as well // if (Mem32Bridge->Alignment < MaxOptionRomSize - 1) { Mem32Bridge->Alignment = MaxOptionRomSize - 1; } } } // // Based on the all the resource tree, contruct ACPI resource node to // submit the resource aperture to pci host bridge protocol // Status = ConstructAcpiResourceRequestor ( RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge, &AcpiConfig ); // // Insert these resource nodes into the database // InsertResourceNode (&IoPool, IoBridge); InsertResourceNode (&Mem32Pool, Mem32Bridge); InsertResourceNode (&PMem32Pool, PMem32Bridge); InsertResourceNode (&Mem64Pool, Mem64Bridge); InsertResourceNode (&PMem64Pool, PMem64Bridge); if (Status == EFI_SUCCESS) { // // Submit the resource requirement // Status = PciResAlloc->SubmitResources ( PciResAlloc, RootBridgeDev->Handle, AcpiConfig ); // // If SubmitResources returns error, PciBus isn't able to start. // It's a fatal error so assertion is added. // DEBUG ((EFI_D_INFO, "PciBus: HostBridge->SubmitResources() - %r\n", Status)); ASSERT_EFI_ERROR (Status); } // // Free acpi resource node // if (AcpiConfig != NULL) { FreePool (AcpiConfig); } if (EFI_ERROR (Status)) { // // Destroy all the resource tree // DestroyResourceTree (&IoPool); DestroyResourceTree (&Mem32Pool); DestroyResourceTree (&PMem32Pool); DestroyResourceTree (&Mem64Pool); DestroyResourceTree (&PMem64Pool); return Status; } } // // End while, at least one Root Bridge should be found. // ASSERT (RootBridgeDev != NULL); // // Notify platform to start to program the resource // Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeAllocateResources); DEBUG ((EFI_D_INFO, "PciBus: HostBridge->NotifyPhase(AllocateResources) - %r\n", Status)); if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) { // // If Hot Plug is not supported // if (EFI_ERROR (Status)) { // // Allocation failed, then return // return EFI_OUT_OF_RESOURCES; } // // Allocation succeed. // Get host bridge handle for status report, and then skip the main while // HandleExtendedData.Handle = RootBridgeDev->PciRootBridgeIo->ParentHandle; break; } else { // // If Hot Plug is supported // if (!EFI_ERROR (Status)) { // // Allocation succeed, then continue the following // break; } // // If the resource allocation is unsuccessful, free resources on bridge // RootBridgeDev = NULL; RootBridgeHandle = 0; IoResStatus = EFI_RESOURCE_SATISFIED; Mem32ResStatus = EFI_RESOURCE_SATISFIED; PMem32ResStatus = EFI_RESOURCE_SATISFIED; Mem64ResStatus = EFI_RESOURCE_SATISFIED; PMem64ResStatus = EFI_RESOURCE_SATISFIED; while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) { // // Get RootBridg Device by handle // RootBridgeDev = GetRootBridgeByHandle (RootBridgeHandle); if (RootBridgeDev == NULL) { return EFI_NOT_FOUND; } // // Get host bridge handle for status report // HandleExtendedData.Handle = RootBridgeDev->PciRootBridgeIo->ParentHandle; // // Get acpi resource node for all the resource types // AcpiConfig = NULL; Status = PciResAlloc->GetProposedResources ( PciResAlloc, RootBridgeDev->Handle, &AcpiConfig ); if (EFI_ERROR (Status)) { return Status; } if (AcpiConfig != NULL) { // // Adjust resource allocation policy for each RB // GetResourceAllocationStatus ( AcpiConfig, &IoResStatus, &Mem32ResStatus, &PMem32ResStatus, &Mem64ResStatus, &PMem64ResStatus ); FreePool (AcpiConfig); } } // // End while // // // Raise the EFI_IOB_EC_RESOURCE_CONFLICT status code // // // It is very difficult to follow the spec here // Device path , Bar index can not be get here // ZeroMem (&AllocFailExtendedData, sizeof (AllocFailExtendedData)); REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, EFI_IO_BUS_PCI | EFI_IOB_EC_RESOURCE_CONFLICT, (VOID *) &AllocFailExtendedData, sizeof (AllocFailExtendedData) ); Status = PciHostBridgeAdjustAllocation ( &IoPool, &Mem32Pool, &PMem32Pool, &Mem64Pool, &PMem64Pool, IoResStatus, Mem32ResStatus, PMem32ResStatus, Mem64ResStatus, PMem64ResStatus ); // // Destroy all the resource tree // DestroyResourceTree (&IoPool); DestroyResourceTree (&Mem32Pool); DestroyResourceTree (&PMem32Pool); DestroyResourceTree (&Mem64Pool); DestroyResourceTree (&PMem64Pool); NotifyPhase (PciResAlloc, EfiPciHostBridgeFreeResources); if (EFI_ERROR (Status)) { return Status; } ReAllocate = TRUE; } } // // End main while // // // Raise the EFI_IOB_PCI_RES_ALLOC status code // REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, EFI_IO_BUS_PCI | EFI_IOB_PCI_RES_ALLOC, (VOID *) &HandleExtendedData, sizeof (HandleExtendedData) ); // // Notify pci bus driver starts to program the resource // Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeSetResources); if (EFI_ERROR (Status)) { return Status; } RootBridgeDev = NULL; RootBridgeHandle = 0; while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) { // // Get RootBridg Device by handle // RootBridgeDev = GetRootBridgeByHandle (RootBridgeHandle); if (RootBridgeDev == NULL) { return EFI_NOT_FOUND; } // // Get acpi resource node for all the resource types // AcpiConfig = NULL; Status = PciResAlloc->GetProposedResources ( PciResAlloc, RootBridgeDev->Handle, &AcpiConfig ); if (EFI_ERROR (Status)) { return Status; } // // Get the resource base by interpreting acpi resource node // // GetResourceBase ( AcpiConfig, &IoBase, &Mem32Base, &PMem32Base, &Mem64Base, &PMem64Base ); // // Process option rom for this root bridge // ProcessOptionRom (RootBridgeDev, Mem32Base, RootBridgeDev->RomSize); // // Create the entire system resource map from the information collected by // enumerator. Several resource tree was created // IoBridge = FindResourceNode (RootBridgeDev, &IoPool); Mem32Bridge = FindResourceNode (RootBridgeDev, &Mem32Pool); PMem32Bridge = FindResourceNode (RootBridgeDev, &PMem32Pool); Mem64Bridge = FindResourceNode (RootBridgeDev, &Mem64Pool); PMem64Bridge = FindResourceNode (RootBridgeDev, &PMem64Pool); ASSERT (IoBridge != NULL); ASSERT (Mem32Bridge != NULL); ASSERT (PMem32Bridge != NULL); ASSERT (Mem64Bridge != NULL); ASSERT (PMem64Bridge != NULL); // // Program IO resources // ProgramResource ( IoBase, IoBridge ); // // Program Mem32 resources // ProgramResource ( Mem32Base, Mem32Bridge ); // // Program PMem32 resources // ProgramResource ( PMem32Base, PMem32Bridge ); // // Program Mem64 resources // ProgramResource ( Mem64Base, Mem64Bridge ); // // Program PMem64 resources // ProgramResource ( PMem64Base, PMem64Bridge ); IoBridge ->PciDev->PciBar[IoBridge ->Bar].BaseAddress = IoBase; Mem32Bridge ->PciDev->PciBar[Mem32Bridge ->Bar].BaseAddress = Mem32Base; PMem32Bridge->PciDev->PciBar[PMem32Bridge->Bar].BaseAddress = PMem32Base; Mem64Bridge ->PciDev->PciBar[Mem64Bridge ->Bar].BaseAddress = Mem64Base; PMem64Bridge->PciDev->PciBar[PMem64Bridge->Bar].BaseAddress = PMem64Base; // // Dump the resource map for current root bridge // DEBUG_CODE ( DumpResourceMap ( RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge ); ); FreePool (AcpiConfig); }