| /* |
| * |
| * Copyright (c) 2018 Google Inc. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| */ |
| |
| #include <lib/fdio/directory.h> |
| |
| #include "loader.h" |
| |
| typedef VkResult(VKAPI_PTR *PFN_vkConnectToServiceAddr)(const char *pName, uint32_t handle); |
| typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_vkInitializeConnectToServiceCallbackAddr)(PFN_vkConnectToServiceAddr); |
| |
| VKAPI_ATTR static VkResult VKAPI_CALL loader_fdio_get_service(const char *pName, uint32_t handle) { |
| zx_status_t status = fdio_service_connect(pName, handle); |
| if (status == ZX_OK) { |
| return VK_SUCCESS; |
| } else { |
| loader_log(NULL, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Failed to load service %s - error %d", pName, status); |
| return VK_ERROR_INITIALIZATION_FAILED; |
| } |
| } |
| |
| void loader_initialize_icd_services(loader_platform_dl_handle handle) { |
| PFN_vkInitializeConnectToServiceCallbackAddr fp_initialize_connect_to_service_callback_addr; |
| |
| fp_initialize_connect_to_service_callback_addr = |
| loader_platform_get_proc_address(handle, "vk_icdInitializeConnectToServiceCallback"); |
| if (!fp_initialize_connect_to_service_callback_addr) { |
| // ICD isn't required to expose this entrypoint. |
| return; |
| } |
| |
| fp_initialize_connect_to_service_callback_addr(&loader_fdio_get_service); |
| } |