├── Android.mk ├── COPYING ├── README.md ├── avb ├── Android.mk ├── libavb │ ├── avb_chain_partition_descriptor.c │ ├── avb_chain_partition_descriptor.h │ ├── avb_cmdline.c │ ├── avb_cmdline.h │ ├── avb_crc32.c │ ├── avb_crypto.c │ ├── avb_crypto.h │ ├── avb_descriptor.c │ ├── avb_descriptor.h │ ├── avb_footer.c │ ├── avb_footer.h │ ├── avb_hash_descriptor.c │ ├── avb_hash_descriptor.h │ ├── avb_hashtree_descriptor.c │ ├── avb_hashtree_descriptor.h │ ├── avb_kernel_cmdline_descriptor.c │ ├── avb_kernel_cmdline_descriptor.h │ ├── avb_ops.h │ ├── avb_property_descriptor.c │ ├── avb_property_descriptor.h │ ├── avb_rsa.c │ ├── avb_rsa.h │ ├── avb_sha.h │ ├── avb_sha256.c │ ├── avb_sha512.c │ ├── avb_slot_verify.c │ ├── avb_slot_verify.h │ ├── avb_sysdeps.h │ ├── avb_sysdeps_posix.c │ ├── avb_util.c │ ├── avb_util.h │ ├── avb_vbmeta_image.c │ ├── avb_vbmeta_image.h │ ├── avb_version.c │ ├── avb_version.h │ └── libavb.h ├── libavb_ab │ ├── avb_ab_flow.c │ ├── avb_ab_flow.h │ ├── avb_ab_ops.h │ └── libavb_ab.h ├── libavb_atx │ ├── avb_atx_ops.h │ ├── avb_atx_types.h │ ├── avb_atx_validate.c │ ├── avb_atx_validate.h │ └── libavb_atx.h └── libavb_user │ ├── uefi_avb_ops.c │ ├── uefi_avb_ops.h │ ├── uefi_avb_sysdeps.c │ ├── uefi_avb_util.c │ └── uefi_avb_util.h ├── build ├── CMakeLists.txt ├── README ├── config.cmake ├── elf_ia32_abl.lds ├── libpayload-config.h └── sources.cmake ├── doc ├── autodetect.md ├── crashmode.md ├── fastboot.md └── installer.md ├── include ├── acpi.h ├── adb.h ├── aes_gcm.h ├── android.h ├── android_vb2.h ├── blobstore.h ├── dt_table.h ├── em.h ├── endian.h ├── fastboot.h ├── firststage_mount.h ├── gpio.h ├── gpt.h ├── gpt_bin.h ├── hecisupport.h ├── ioc_can.h ├── ioc_uart_protocol.h ├── keybox_provision.h ├── lib.h ├── libelfloader.h ├── libtipc.h ├── life_cycle.h ├── log.h ├── oemvars.h ├── options.h ├── pae.h ├── pci.h ├── power.h ├── protocol.h ├── security.h ├── security_interface.h ├── security_vb2.h ├── slot.h ├── smbios.h ├── sparse_format.h ├── storage.h ├── targets.h ├── tcp.h ├── text_parser.h ├── timer.h ├── tpm2_security.h ├── transport.h ├── trusty_common.h ├── trusty_interface.h ├── uefi_utils.h ├── ui.h ├── upng.h ├── usb.h ├── vars.h ├── vbmeta_ias.h ├── version.h └── watchdog.h ├── installer.c ├── kernelflinger.c ├── kf4abl.c ├── kf4cic.c ├── kfld.c ├── libadb ├── Android.mk ├── adb.c ├── adb_socket.c ├── adb_socket.h ├── devmem.c ├── devmem.h ├── hexdump.c ├── hexdump.h ├── ioport.c ├── ioport.h ├── lsacpi.c ├── lsacpi.h ├── lspartition.c ├── lspartition.h ├── lspci.c ├── lspci.h ├── pci_class.c ├── pci_class.h ├── reader.c ├── reader.h ├── reboot_service.c ├── service.h ├── shell_service.c ├── shell_service.h └── sync_service.c ├── libedk2_tpm ├── Android.mk ├── README ├── Tpm2Capability.c ├── Tpm2Context.c ├── Tpm2DeviceLib.c ├── Tpm2EnhancedAuthorization.c ├── Tpm2Help.c ├── Tpm2Hierarchy.c ├── Tpm2Integrity.c ├── Tpm2NVStorage.c ├── Tpm2Random.c ├── Tpm2Sequences.c ├── Tpm2Session.c └── include │ ├── Tcg2Protocol.h │ ├── Tpm12.h │ ├── Tpm20.h │ ├── Tpm2CommandLib.h │ ├── Tpm2DeviceLib.h │ ├── Tpm2Help.h │ └── UefiTcgPlatform.h ├── libefitcp ├── Android.mk └── tcp.c ├── libefiusb ├── Android.mk ├── device_mode │ ├── CpuIo2.h │ ├── UsbDeviceDxe.c │ ├── UsbDeviceDxe.h │ ├── UsbDeviceMode.c │ ├── UsbDeviceMode.h │ ├── XdciCommon.h │ ├── XdciDWC.c │ ├── XdciDWC.h │ ├── XdciDevice.c │ ├── XdciDevice.h │ ├── XdciInterface.h │ ├── XdciTable.c │ ├── XdciUtility.c │ ├── XdciUtility.h │ └── cpuio.c ├── protocol │ ├── Usb.h │ ├── UsbDeviceLib.h │ ├── UsbDeviceModeProtocol.h │ └── UsbIo.h └── usb.c ├── libelfloader ├── Android.mk ├── elf32_ld.c ├── elf64_ld.c ├── elf_ld.c └── include │ ├── elf32_ld.h │ ├── elf64_ld.h │ └── elf_ld.h ├── libfastboot ├── Android.mk ├── authenticated_action.c ├── authenticated_action.h ├── bootloader.c ├── bootloader.h ├── bootmgr.c ├── bootmgr.h ├── fastboot.c ├── fastboot_flashing.c ├── fastboot_flashing.h ├── fastboot_oem.c ├── fastboot_oem.h ├── fastboot_transport.c ├── fastboot_transport.h ├── fastboot_ui.c ├── fastboot_ui.h ├── flash.c ├── flash.h ├── hashes.c ├── hashes.h ├── info.c ├── info.h ├── intel_variables.c ├── intel_variables.h ├── keybox_provision.c ├── sparse.c └── sparse.h ├── libheci ├── Android.mk └── hecisupport.c ├── libkernelflinger ├── Android.mk ├── README ├── UsbMassBot.c ├── UsbMassBot.h ├── acpi.c ├── acpi_image.c ├── aes_gcm.c ├── android.c ├── android_vb2.c ├── blobstore.c ├── efilinux.c ├── efilinux.h ├── em.c ├── firststage_mount.c ├── general_block.c ├── gpio.c ├── gpt.c ├── ias_sig.c ├── ioc_can.c ├── lib.c ├── life_cycle.c ├── log.c ├── mmc.c ├── no_ui.c ├── nvme.c ├── oemvars.c ├── options.c ├── pae.c ├── pci.c ├── protocol │ ├── AcpiTableProtocol.h │ ├── Afws_general_heci_agent.h │ ├── Afws_keymaster_heci_agent.h │ ├── AtaPassThru.h │ ├── Atapi.h │ ├── BootloaderSeedProtocol.h │ ├── CardInfo.h │ ├── ChargingAppletProtocol.h │ ├── DevicePath.h │ ├── EraseBlock.h │ ├── GpioProtocol.h │ ├── Heci.h │ ├── LifeCycleProtocol.h │ ├── MkhiMsgs.h │ ├── Mmc.h │ ├── NvmExpressHci.h │ ├── NvmExpressPassthru.h │ ├── ScsiPassThruExt.h │ ├── SdHostIo.h │ ├── SdMmcPassThru.h │ ├── StorageSecurityCommand.h │ ├── tco_protocol.h │ └── ufs.h ├── qsort.c ├── res │ ├── fonts │ │ ├── 12x22_font.png │ │ ├── 18x32_font.png │ │ ├── OFL.txt │ │ └── README │ └── images │ │ ├── bootloader.png │ │ ├── crash_event.png │ │ ├── crashmode.png │ │ ├── droid_operation.png │ │ ├── empty_battery.png │ │ ├── low_battery.png │ │ ├── power_off.png │ │ ├── reboot.png │ │ ├── recoverymode.png │ │ ├── restartbootloader.png │ │ ├── splash_intel.png │ │ └── start.png ├── sata.c ├── sdcard.c ├── sdio.c ├── sdio.h ├── security.c ├── security_abl.c ├── security_efi.c ├── security_efi.h ├── security_sbl.c ├── security_vb2.c ├── security_vsbl.c ├── slot.c ├── slot_avb.c ├── smbios.c ├── storage.c ├── targets.c ├── text_parser.c ├── timer.c ├── tools │ ├── Android.mk │ ├── gen_fonts.sh │ └── png2c.c ├── tpm2_security.c ├── trusty_abl.c ├── trusty_common.c ├── trusty_efi.c ├── trusty_sbl.c ├── trusty_vsbl.c ├── uefi_utils.c ├── ufs.c ├── ui.c ├── ui_boot_menu.c ├── ui_color.c ├── ui_confirm.c ├── ui_font.c ├── ui_image.c ├── ui_textarea.c ├── upng.c ├── usb_storage.c ├── vars.c ├── vbmeta_ias.c ├── virtual_media.c └── watchdog.c ├── libqltipc ├── Android.mk ├── interface │ └── include │ │ └── interface │ │ ├── avb │ │ └── avb.h │ │ └── keymaster │ │ └── keymaster.h └── ql-tipc │ ├── Android.mk │ ├── LICENSE │ ├── README.md │ ├── arch │ └── x86 │ │ ├── compiler.h │ │ ├── sysdeps_osloader.c │ │ ├── trusty_dev.c │ │ └── trusty_mem.c │ ├── avb.c │ ├── include │ └── trusty │ │ ├── arm_ffa.h │ │ ├── avb.h │ │ ├── keymaster.h │ │ ├── keymaster_serializable.h │ │ ├── libtipc.h │ │ ├── rpmb.h │ │ ├── sm_err.h │ │ ├── smc.h │ │ ├── smcall.h │ │ ├── sysdeps.h │ │ ├── trusty_dev.h │ │ ├── trusty_ipc.h │ │ ├── trusty_mem.h │ │ └── util.h │ ├── ipc.c │ ├── ipc_dev.c │ ├── keymaster.c │ ├── keymaster_serializable.c │ ├── libtipc.c │ ├── trusty_dev_common.c │ └── util.c ├── libsslsupport ├── Android.mk ├── borningssl │ └── sys │ │ └── syscall.h ├── errno.h ├── inttypes.h ├── limits.h ├── openssl_support.h ├── stdarg.h ├── stddef.h ├── stdio.h ├── stdlib.h ├── sys │ └── types.h ├── time.h └── wrapper.c ├── libtransport ├── Android.mk └── transport.c ├── prebuilt └── board │ └── APL_UP2 │ └── fastboot.elf ├── unittest.c ├── unittest.h ├── ux.c └── ux.h /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Intel Corportaion 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /avb/libavb/avb_footer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "avb_footer.h" 26 | #include "avb_util.h" 27 | 28 | bool avb_footer_validate_and_byteswap(const AvbFooter* src, AvbFooter* dest) { 29 | avb_memcpy(dest, src, sizeof(AvbFooter)); 30 | 31 | dest->version_major = avb_be32toh(dest->version_major); 32 | dest->version_minor = avb_be32toh(dest->version_minor); 33 | 34 | dest->original_image_size = avb_be64toh(dest->original_image_size); 35 | dest->vbmeta_offset = avb_be64toh(dest->vbmeta_offset); 36 | dest->vbmeta_size = avb_be64toh(dest->vbmeta_size); 37 | 38 | /* Check that magic is correct. */ 39 | if (avb_safe_memcmp(dest->magic, AVB_FOOTER_MAGIC, AVB_FOOTER_MAGIC_LEN) != 40 | 0) { 41 | avb_error("Footer magic is incorrect.\n"); 42 | return false; 43 | } 44 | 45 | /* Ensure we don't attempt to access any fields if the footer major 46 | * version is not supported. 47 | */ 48 | if (dest->version_major > AVB_FOOTER_VERSION_MAJOR) { 49 | avb_error("No support for footer version.\n"); 50 | return false; 51 | } 52 | 53 | return true; 54 | } 55 | -------------------------------------------------------------------------------- /avb/libavb/avb_kernel_cmdline_descriptor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "avb_kernel_cmdline_descriptor.h" 26 | #include "avb_util.h" 27 | 28 | bool avb_kernel_cmdline_descriptor_validate_and_byteswap( 29 | const AvbKernelCmdlineDescriptor* src, AvbKernelCmdlineDescriptor* dest) { 30 | uint64_t expected_size; 31 | 32 | avb_memcpy(dest, src, sizeof(AvbKernelCmdlineDescriptor)); 33 | 34 | if (!avb_descriptor_validate_and_byteswap((const AvbDescriptor*)src, 35 | (AvbDescriptor*)dest)) 36 | return false; 37 | 38 | if (dest->parent_descriptor.tag != AVB_DESCRIPTOR_TAG_KERNEL_CMDLINE) { 39 | avb_error("Invalid tag for kernel cmdline descriptor.\n"); 40 | return false; 41 | } 42 | 43 | dest->flags = avb_be32toh(dest->flags); 44 | dest->kernel_cmdline_length = avb_be32toh(dest->kernel_cmdline_length); 45 | 46 | /* Check that kernel_cmdline is fully contained. */ 47 | expected_size = sizeof(AvbKernelCmdlineDescriptor) - sizeof(AvbDescriptor); 48 | if (!avb_safe_add_to(&expected_size, dest->kernel_cmdline_length)) { 49 | avb_error("Overflow while adding up sizes.\n"); 50 | return false; 51 | } 52 | if (expected_size > dest->parent_descriptor.num_bytes_following) { 53 | avb_error("Descriptor payload size overflow.\n"); 54 | return false; 55 | } 56 | 57 | return true; 58 | } 59 | -------------------------------------------------------------------------------- /avb/libavb/avb_sysdeps_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "avb_sysdeps.h" 32 | 33 | int avb_memcmp(const void* src1, const void* src2, size_t n) { 34 | return memcmp(src1, src2, n); 35 | } 36 | 37 | void* avb_memcpy(void* dest, const void* src, size_t n) { 38 | EFI_STATUS ret; 39 | ret = memcpy_s(dest, n, src, n); 40 | return (ret == EFI_SUCCESS) ? (dest) : (NULL); 41 | } 42 | 43 | void* avb_memset(void* dest, const int c, size_t n) { 44 | return memset_s(dest, n, c, n); 45 | } 46 | 47 | int avb_strcmp(const char* s1, const char* s2) { 48 | return strcmp(s1, s2); 49 | } 50 | 51 | size_t avb_strlen(const char* str) { 52 | return strlen(str); 53 | } 54 | 55 | void avb_abort(void) { 56 | abort(); 57 | } 58 | 59 | void avb_print(const char* message) { 60 | fprintf(stderr, "%s", message); 61 | } 62 | 63 | void avb_printv(const char* message, ...) { 64 | va_list ap; 65 | const char* m; 66 | 67 | va_start(ap, message); 68 | for (m = message; m != NULL; m = va_arg(ap, const char*)) { 69 | fprintf(stderr, "%s", m); 70 | } 71 | va_end(ap); 72 | } 73 | 74 | void* avb_malloc_(size_t size) { 75 | return malloc(size); 76 | } 77 | 78 | void avb_free(void* ptr) { 79 | free(ptr); 80 | } 81 | 82 | uint32_t avb_div_by_10(uint64_t* dividend) { 83 | uint32_t rem = (uint32_t)(*dividend % 10); 84 | *dividend /= 10; 85 | return rem; 86 | } 87 | -------------------------------------------------------------------------------- /avb/libavb/avb_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "avb_version.h" 26 | 27 | #define AVB_QUOTE(str) #str 28 | #define AVB_EXPAND_AND_QUOTE(str) AVB_QUOTE(str) 29 | 30 | /* Keep in sync with get_release_string() in avbtool. */ 31 | const char* avb_version_string(void) { 32 | return AVB_EXPAND_AND_QUOTE(AVB_VERSION_MAJOR) "." AVB_EXPAND_AND_QUOTE( 33 | AVB_VERSION_MINOR) "." AVB_EXPAND_AND_QUOTE(AVB_VERSION_SUB); 34 | } 35 | -------------------------------------------------------------------------------- /avb/libavb/avb_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION) 26 | #error "Never include this file directly, include libavb.h instead." 27 | #endif 28 | 29 | #ifndef AVB_VERSION_H_ 30 | #define AVB_VERSION_H_ 31 | 32 | #include "avb_sysdeps.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* The version number of AVB - keep in sync with avbtool. */ 39 | #define AVB_VERSION_MAJOR 1 40 | #define AVB_VERSION_MINOR 1 41 | #define AVB_VERSION_SUB 0 42 | 43 | /* Returns a NUL-terminated string for the libavb version in use. The 44 | * returned string usually looks like "%d.%d.%d". Applications must 45 | * not make assumptions about the content of this string. 46 | * 47 | * Boot loaders should display this string in debug/diagnostics output 48 | * to aid with debugging. 49 | * 50 | * This is similar to the string put in the |release_string| string 51 | * field in the VBMeta struct by avbtool. 52 | */ 53 | const char* avb_version_string(void); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* AVB_VERSION_H_ */ 60 | -------------------------------------------------------------------------------- /avb/libavb/libavb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef LIBAVB_H_ 26 | #define LIBAVB_H_ 27 | 28 | /* The AVB_INSIDE_LIBAVB_H preprocessor symbol is used to enforce 29 | * library users to include only this file. All public interfaces, and 30 | * only public interfaces, must be included here. 31 | */ 32 | 33 | #define AVB_INSIDE_LIBAVB_H 34 | #include "avb_chain_partition_descriptor.h" 35 | #include "avb_crypto.h" 36 | #include "avb_descriptor.h" 37 | #include "avb_footer.h" 38 | #include "avb_hash_descriptor.h" 39 | #include "avb_hashtree_descriptor.h" 40 | #include "avb_kernel_cmdline_descriptor.h" 41 | #include "avb_ops.h" 42 | #include "avb_property_descriptor.h" 43 | #include "avb_slot_verify.h" 44 | #include "avb_sysdeps.h" 45 | #include "avb_util.h" 46 | #include "avb_vbmeta_image.h" 47 | #include "avb_version.h" 48 | #undef AVB_INSIDE_LIBAVB_H 49 | 50 | #endif /* LIBAVB_H_ */ 51 | -------------------------------------------------------------------------------- /avb/libavb_ab/libavb_ab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef LIBAVB_AB_H_ 26 | #define LIBAVB_AB_H_ 27 | 28 | #include 29 | 30 | /* The libavb_ab/ and boot_control/ code has been marked for some time 31 | * as experimental in anticipation of being removed in the future. It 32 | * is now deprecated and to continue using it you must define 33 | * AVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED. It will be removed Jun 34 | * 1 2018. 35 | */ 36 | #ifndef AVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED 37 | #error \ 38 | "You must define AVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED to use this library." 39 | #endif 40 | 41 | /* The AVB_INSIDE_LIBAVB_AB_H preprocessor symbol is used to enforce 42 | * library users to include only this file. All public interfaces, and 43 | * only public interfaces, must be included here. 44 | */ 45 | 46 | #define AVB_INSIDE_LIBAVB_AB_H 47 | #include "avb_ab_flow.h" 48 | #include "avb_ab_ops.h" 49 | #undef AVB_INSIDE_LIBAVB_AB_H 50 | 51 | #endif /* LIBAVB_AB_H_ */ 52 | -------------------------------------------------------------------------------- /avb/libavb_atx/libavb_atx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef LIBAVB_ATX_H_ 26 | #define LIBAVB_ATX_H_ 27 | 28 | #include 29 | 30 | /* The AVB_INSIDE_LIBAVB_ATX_H preprocessor symbol is used to enforce 31 | * library users to include only this file. All public interfaces, and 32 | * only public interfaces, must be included here. 33 | */ 34 | 35 | #define AVB_INSIDE_LIBAVB_ATX_H 36 | #include "avb_atx_ops.h" 37 | #include "avb_atx_types.h" 38 | #include "avb_atx_validate.h" 39 | #undef AVB_INSIDE_LIBAVB_ATX_H 40 | 41 | #endif /* LIBAVB_ATX_H_ */ 42 | -------------------------------------------------------------------------------- /avb/libavb_user/uefi_avb_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef UEFI_AVB_OPS_H_ 26 | #define UEFI_AVB_OPS_H_ 27 | 28 | #include 29 | #include "libavb/libavb.h" 30 | /* The |user_data| member of AvbOps points to a struct of this type. */ 31 | typedef struct UEFIAvbOpsData { 32 | AvbOps ops; 33 | //AVbops_AB ops_ab; 34 | EFI_BLOCK_IO* block_io; 35 | EFI_DISK_IO* disk_io; 36 | } UEFIAvbOpsData; 37 | 38 | /* Returns an AvbOps for use with UEFI. */ 39 | AvbOps* uefi_avb_ops_new(void); 40 | 41 | /* Frees the AvbOps allocated with uefi_avb_ops_new(). */ 42 | void uefi_avb_ops_free(AvbOps* ops); 43 | 44 | #endif /* UEFI_AVB_OPS_H_ */ 45 | -------------------------------------------------------------------------------- /avb/libavb_user/uefi_avb_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | // NOTE: See avb_sysdeps.h 26 | 27 | #ifndef UEFI_AVB_UTIL_H_ 28 | #define UEFI_AVB_UTIL_H_ 29 | 30 | #include 31 | 32 | /* Converts UTF-8 to UCS-2. Returns |false| if invalid UTF-8 or if a 33 | * rune cannot be represented as UCS-2. 34 | */ 35 | bool uefi_avb_utf8_to_ucs2(const uint8_t* utf8_data, 36 | size_t utf8_num_bytes, 37 | uint16_t* ucs2_data, 38 | size_t ucs2_data_capacity_num_bytes, 39 | size_t* out_ucs2_data_num_bytes); 40 | 41 | #endif /* UEFI_AVB_UTIL_H_ */ 42 | -------------------------------------------------------------------------------- /build/README: -------------------------------------------------------------------------------- 1 | Files in this directory is used to build fastboot elf without Android 2 | build environment. 3 | 4 | The build out "fastboot" is positioned as basic flash tool only. Thus, 5 | limited fastboot commands are supported: 6 | 7 | fastboot flash //flash gpt or flash some data to 8 | a disk partition or some special data. 9 | fastboot erase //erase a partition. 10 | fastboot gatvar |all //get a var value or all vars value. 11 | fastboot reboot //Reboot the device. 12 | fastboot reboot-bootloader //Reboot the device to fastboot mode. 13 | 14 | Tested on ubuntu 16.04, cmake3.5 and clang6.0 or above are needed. 15 | for ubuntu 14.04, cmake3 and clang3.9 should be installed by apt-get. 16 | 17 | To compile fastboot.elf standalone, in your workdir 18 | cmake path-to-kernelflinger/build 19 | dependent sources will be cloned by git automatically, then 20 | cmake --build . 21 | 22 | The default target platform is broxton, optional target platform is 23 | broxton, icelake, tigerlake, kabylake, to set target platform, set variable 24 | TARGET_BOARD_PLATFORM in config.cmake 25 | 26 | The generated fastboot.sym.elf in workdir is an elf executable with system symbols, 27 | no ui, and doesn't support x86_64 for the time being. 28 | -------------------------------------------------------------------------------- /build/config.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018, Intel Corporation 3 | # All rights reserved. 4 | # 5 | # Author: Meng Xianglin 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | # OF THE POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | # This file defines bootlogic data structures, try to keep it without 32 | # any external definitions in order to ease export of it. 33 | # 34 | 35 | set(CAPSULE_SOURCE CAPSULE4ABL) 36 | set(TARGET_PRODUCT \"standalone\") 37 | set(PRODUCT_MANUFACTURER \"Intel\") 38 | # optional platform: PLATFORM_BROXTON, PLATFORM_ICELAKE 39 | # PLATFORM_TIGERLAKE, PLATFORM_KABYLAKE 40 | set(TARGET_BOARD_PLATFORM PLATFORM_BROXTON) 41 | 42 | set(EFIWRAPPER_LIB_DEF 43 | ${CAPSULE_SOURCE} 44 | ${TARGET_BOARD_PLATFOMR} 45 | PRODUCT_NAME=${TARGET_PRODUCT} 46 | PRODUCT_MANUFACTURER=${PRODUCT_MANUFACTURER} 47 | ) 48 | if(${LOADER_ARCH} STREQUAL "x86_64") 49 | set(EFIWRAPPER_LIB_DEF ${EFIWRAPPER_LIB_DEF} EFI_FUNCTION_WRAPPER GNU_EFI_USE_MS_ABI) 50 | endif() 51 | 52 | # optional drivers 53 | set(LIBEFIWRAPPER_DRIVERS 54 | s8250mem32 55 | sdhci_mmc 56 | dw3 57 | lpmemmap 58 | lprtc 59 | acpi 60 | cf9 61 | lifecycle 62 | abl 63 | ioc_uart 64 | heci 65 | tco_wdt 66 | mmc_serial 67 | ) 68 | -------------------------------------------------------------------------------- /build/elf_ia32_abl.lds: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the libpayload project. 3 | * 4 | * Copyright (C) 2008 Advanced Micro Devices, Inc. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | OUTPUT_FORMAT(elf32-i386) 31 | OUTPUT_ARCH(i386) 32 | 33 | ENTRY(_entry) 34 | 35 | SECTIONS 36 | { 37 | . = CONFIG_LP_BASE_ADDRESS; 38 | 39 | . = ALIGN(16); 40 | _start = .; 41 | 42 | .text : { 43 | *(.text._entry) 44 | libcrt0-libpayload-ia32.a(.text) 45 | *(.text) 46 | *(.text.*) 47 | } 48 | 49 | .rodata : { 50 | *(.rodata) 51 | *(.rodata.*) 52 | } 53 | 54 | .data : { 55 | *(.data) 56 | *(.data.*) 57 | } 58 | 59 | _edata = .; 60 | 61 | .bss : { 62 | *(.sbss) 63 | *(.sbss.*) 64 | *(.bss) 65 | *(.bss.*) 66 | *(COMMON) 67 | 68 | /* Stack and heap */ 69 | 70 | . = ALIGN(16); 71 | _heap = .; 72 | . += CONFIG_LP_HEAP_SIZE; 73 | . = ALIGN(16); 74 | _eheap = .; 75 | 76 | _estack = .; 77 | . += CONFIG_LP_STACK_SIZE; 78 | . = ALIGN(16); 79 | _stack = .; 80 | } 81 | 82 | _end = .; 83 | 84 | /DISCARD/ : { 85 | *(.comment) 86 | *(.note*) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /doc/autodetect.md: -------------------------------------------------------------------------------- 1 | Autodetect 2 | ========== 3 | 4 | Overview 5 | -------- 6 | 7 | Autodetect can be activated with the Kernelflinger `HAL_AUTODETECT` 8 | compilation flag. 9 | 10 | If Autodetect is enabled, Kernelflinger prepends some `androidboot` 11 | parameter to the kernel command line: 12 | 13 | - `androidboot.brand`: Combines the value of the DMI Board 14 | `manufacturer` and Product `manufacturer` fields. 15 | - `androidboot.name`: Combines the value of the DMI Product 16 | `product_name` and Board `product_name`. 17 | - `androidboot.device`: Combines the value of the DMI Board 18 | `product_name` and Board `version`. 19 | - `androidboot.model`: same value than `androidboot.device`. 20 | 21 | The init process is converting these command line parameters to 22 | properties that can be used to identify the device product. 23 | 24 | If Autodetect is enabled, Kernelflinger also loads the Blobstore 25 | stored in the second stage area of the boot image, extract the OEMVARS 26 | blob for the current device variant and flash these product dependent 27 | EFI variables. 28 | 29 | Blobstore 30 | --------- 31 | 32 | Blobstore is a structure storing any kind of data inside the second 33 | stage area of the bootimage. The data is organized as a dictionary in 34 | which the key is the string: `//`. 35 | (Cf. [blobstore.c](../libkernelflinger/blobstore.c). 36 | 37 | Blobstore current support the following data type: device tree blob, 38 | OEMVARS (Cf. [Fastboot](./fastboot.md)) and Kernel command line 39 | parameters. Kernelflinger does not make use of the device tree blob 40 | type. 41 | -------------------------------------------------------------------------------- /include/aes_gcm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _AES_GCM_H_ 18 | #define _AES_GCM_H_ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #define GCM_IV_SIZE 12 29 | #define GCM_TAG_SIZE 16 30 | #define GCM_KEY_SIZE 32 31 | 32 | struct gcm_key { 33 | uint8_t byte[GCM_KEY_SIZE]; 34 | }; 35 | 36 | struct gcm_tag { 37 | uint8_t byte[GCM_TAG_SIZE]; 38 | }; 39 | 40 | #define AES_GCM_NO_ERROR 0 41 | #define AES_GCM_ERR_GENERIC -1 42 | #define AES_GCM_ERR_AUTH_FAILED -2 43 | 44 | int aes_256_gcm_encrypt(const struct gcm_key *key, 45 | const void *iv, size_t iv_size, 46 | const void *aad, size_t aad_size, 47 | const void *plain, size_t plain_size, 48 | void *out, size_t *out_size); 49 | 50 | int aes_256_gcm_decrypt(const struct gcm_key *key, 51 | const void *iv, size_t iv_size, 52 | const void *aad, size_t aad_size, 53 | const void *cipher, size_t cipher_size, 54 | void *out, size_t *out_size); 55 | #endif 56 | -------------------------------------------------------------------------------- /include/android_vb2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ANDROID_VB2_H_ 18 | #define _ANDROID_VB2_H_ 19 | 20 | #include "libavb/libavb.h" 21 | #include "libavb_user/uefi_avb_ops.h" 22 | #include "libavb_ab/libavb_ab.h" 23 | 24 | typedef AvbSlotVerifyData VBDATA; 25 | 26 | AvbOps *avb_init(void); 27 | 28 | bool avb_update_stored_rollback_indexes_for_slot(AvbOps* ops, AvbSlotVerifyData* slot_data); 29 | 30 | EFI_STATUS prepend_slot_command_line(CHAR16 **cmdline16, 31 | enum boot_target boot_target, 32 | VBDATA *vb_data); 33 | 34 | EFI_STATUS get_avb_flow_result( 35 | IN AvbSlotVerifyData *slot_data, 36 | IN bool allow_verification_error, 37 | IN AvbABFlowResult flow_result, 38 | IN OUT UINT8 *boot_state); 39 | 40 | EFI_STATUS get_avb_result( 41 | IN AvbSlotVerifyData *slot_data, 42 | IN bool allow_verification_error, 43 | IN AvbSlotVerifyResult verify_result, 44 | IN OUT UINT8 *boot_state); 45 | 46 | EFI_STATUS android_query_image_from_avb_result( 47 | IN AvbSlotVerifyData *slot_data, 48 | IN const char *label, 49 | OUT VOID **image); 50 | 51 | EFI_STATUS android_install_acpi_table_avb(AvbSlotVerifyData *slot_data); 52 | 53 | EFI_STATUS android_image_load_partition_avb( 54 | IN const char *label, 55 | OUT VOID **bootimage_p, 56 | IN OUT UINT8* boot_state, 57 | AvbSlotVerifyData **slot_data); 58 | 59 | EFI_STATUS android_image_load_partition_avb_ab( 60 | IN const char *label, 61 | OUT VOID **bootimage_p, 62 | IN OUT UINT8* boot_state, 63 | AvbSlotVerifyData **slot_data); 64 | 65 | UINTN get_vb_cmdlen(VBDATA *vb_data); 66 | 67 | char *get_vb_cmdline(VBDATA *vb_data); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/blobstore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Andrew Boie 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef BLOBSTORE_H_ 34 | #define BLOBSTORE_H_ 35 | 36 | struct blobstore; 37 | 38 | enum blobtype { 39 | BLOB_TYPE_DTB, 40 | BLOB_TYPE_OEMVARS, 41 | BLOB_TYPE_BOOTVARS 42 | }; 43 | 44 | /* Cast an arbitray pointer to a blobstore pointer. This just does some 45 | * sanity checking, nothing is heap-allocated or changed in the data. 46 | * Returns NULL if this isn't a blobstore or is corrupted */ 47 | struct blobstore *blobstore_get(void *mem, unsigned int size); 48 | 49 | /* Fetch an item out of the blobstore. Returns nonzero if it isn't found 50 | * or the blobstore is corrupted */ 51 | int blobstore_get_item(struct blobstore *bs, char *key, enum blobtype type, 52 | void **data, unsigned int *size); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/dt_table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DT_TABLE_H 18 | #define DT_TABLE_H 19 | 20 | #include 21 | /* 22 | * For the image layout, refer README.md for the detail 23 | */ 24 | 25 | #define DT_TABLE_MAGIC 0xd7b7ab1e 26 | #define DT_TABLE_DEFAULT_PAGE_SIZE 2048 27 | #define DT_TABLE_DEFAULT_VERSION 0 28 | 29 | struct dt_table_header { 30 | UINT32 magic; /* DT_TABLE_MAGIC */ 31 | UINT32 total_size; /* includes dt_table_header + all dt_table_entry 32 | and all dtb/dtbo */ 33 | UINT32 header_size; /* sizeof(dt_table_header) */ 34 | 35 | UINT32 dt_entry_size; /* sizeof(dt_table_entry) */ 36 | UINT32 dt_entry_count; /* number of dt_table_entry */ 37 | UINT32 dt_entries_offset; /* offset to the first dt_table_entry 38 | from head of dt_table_header. 39 | The value will be equal to header_size if 40 | no padding is appended */ 41 | 42 | UINT32 page_size; /* flash page size we assume */ 43 | UINT32 version; /* DTBO image version, the current version is 0. 44 | The version will be incremented when the 45 | dt_table_header struct is updated. */ 46 | }; 47 | 48 | struct dt_table_entry { 49 | UINT32 dt_size; 50 | UINT32 dt_offset; /* offset from head of dt_table_header */ 51 | 52 | UINT32 id; /* optional, must be zero if unused */ 53 | UINT32 rev; /* optional, must be zero if unused */ 54 | UINT32 custom[4]; /* optional, must be zero if unused */ 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/em.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _EM_H_ 34 | #define _EM_H_ 35 | 36 | BOOLEAN is_charger_plugged_in(void); 37 | BOOLEAN is_battery_below_boot_OS_threshold(void); 38 | EFI_STATUS get_battery_voltage(UINTN *voltage); 39 | 40 | #endif /* _EM_H_ */ 41 | -------------------------------------------------------------------------------- /include/endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * This file defines bootlogic data structures, try to keep it without 30 | * any external definitions in order to ease export of it. 31 | */ 32 | 33 | #ifndef _ENDIAN_H_ 34 | #define _ENDIAN_H_ 35 | 36 | #include 37 | 38 | #define htobe16 __builtin_bswap16 39 | #define htobe32 __builtin_bswap32 40 | #define htobe64 __builtin_bswap64 41 | 42 | #define be16toh __builtin_bswap16 43 | #define be32toh __builtin_bswap32 44 | #define be64toh __builtin_bswap64 45 | 46 | #define le32toh(x) (x) 47 | #define htole32(x) (x) 48 | 49 | typedef UINT8 __be8; 50 | typedef UINT16 __be16; 51 | typedef UINT32 __be32; 52 | typedef UINT64 __be64; 53 | 54 | #endif /* _ENDIAN_H_ */ 55 | -------------------------------------------------------------------------------- /include/firststage_mount.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Haoyu Tang 6 | * Chen, ZhiminX 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #ifndef _FIRSTSTAGE_MOUNT_H_ 35 | #define _FIRSTSTAGE_MOUNT_H_ 36 | 37 | EFI_STATUS install_firststage_mount_aml(enum boot_target target); 38 | #ifdef AUTO_DISKBUS 39 | EFI_STATUS revise_diskbus_from_ssdt(CHAR8 *ssdt, UINTN ssdt_len); 40 | #endif 41 | 42 | #endif /* ifndef _FIRSTSTAGE_MOUNT_H_ */ 43 | -------------------------------------------------------------------------------- /include/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | */ 31 | 32 | #ifndef _GPIO_H_ 33 | #define _GPIO_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef enum 39 | { 40 | GpInOut = 0, 41 | GpIn = 1, /* GPI, input only in PAD_VALUE */ 42 | GpOut = 2, /* GPO, output only in PAD_VALUE */ 43 | } GPIO_DIRECTION; 44 | 45 | typedef enum 46 | { 47 | Low = 0, 48 | High = 1, 49 | } GPIO_LEVEL; 50 | 51 | typedef enum 52 | { 53 | Fn0 = 0, /* GPIO mode*/ 54 | Fn1 = 1, 55 | Fn2 = 2, 56 | Fn3 = 3, 57 | Fn4 = 4, 58 | Fn5 = 5 59 | } PAD_MODE; 60 | 61 | EFI_STATUS gpio_get_max_count(UINT32 *count); 62 | EFI_STATUS get_gpio_pin_dir(UINT32 PinNum, GPIO_DIRECTION *dir); 63 | EFI_STATUS set_gpio_pin_dir(UINT32 PinNum, GPIO_DIRECTION dir); 64 | EFI_STATUS get_gpio_pin_level(UINT32 PinNum, GPIO_LEVEL *level); 65 | EFI_STATUS set_gpio_pin_level(UINT32 PinNum, GPIO_LEVEL level); 66 | EFI_STATUS set_gpio_pin_mode(UINT32 PinNum, PAD_MODE mode); 67 | EFI_STATUS get_gpio_pin_mode(UINT32 PinNum, PAD_MODE *mode); 68 | 69 | #endif /*_GPIO_H_*/ 70 | -------------------------------------------------------------------------------- /include/gpt_bin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef __GPT_BIN_H__ 36 | #define __GPT_BIN_H__ 37 | 38 | #include 39 | 40 | #define GPT_BIN_MAGIC 0x6a8b0da1 41 | 42 | /* length unit is MiB */ 43 | #define MiB (1024 * 1024) 44 | 45 | struct gpt_bin_header { 46 | UINT32 magic; 47 | UINT32 start_lba; 48 | UINT32 npart; 49 | }; 50 | 51 | struct gpt_bin_part { 52 | INT32 length; 53 | CHAR16 label[36]; 54 | EFI_GUID type; 55 | EFI_GUID uuid; 56 | }; 57 | 58 | #endif /* __GPT_BIN_H__ */ 59 | -------------------------------------------------------------------------------- /include/hecisupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef _HECISUPPORT_H_ 31 | #define _HECISUPPORT_H_ 32 | 33 | #include "Heci.h" 34 | #include "MkhiMsgs.h" 35 | 36 | #define EOP_GROUP_ID 0xFF 37 | #define EOP_CMD_ID 0xC 38 | #define EOP_GET_STATUS_ID 0X1D 39 | 40 | //EOP-REQ 41 | typedef struct _GEN_END_OF_POST 42 | { 43 | MKHI_MESSAGE_HEADER MKHIHeader; 44 | } GEN_END_OF_POST; 45 | 46 | extern BOOLEAN heci_is_eop_received(void); 47 | extern EFI_STATUS heci_end_of_post(void); 48 | 49 | #endif /* _HECISUPPORT_H_ */ 50 | -------------------------------------------------------------------------------- /include/ioc_can.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: kui.wen@intel.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _IOC_CAN_H_ 34 | #define _IOC_CAN_H_ 35 | 36 | #include 37 | 38 | EFI_STATUS notify_ioc_ready(); 39 | EFI_STATUS set_suppress_heart_beat_timeout(UINT32 timeout); 40 | 41 | #endif /* _IOC_CAN_H_ */ -------------------------------------------------------------------------------- /include/ioc_uart_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: kui.wen@intel.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _IOC_UART_PROTOCOL_H_ 34 | #define _IOC_UART_PROTOCOL_H_ 35 | 36 | #include 37 | 38 | #define EFI_IOC_UART_PROTOCOL_GUID \ 39 | {0x6152f300, 0x957f, 0x40b2, {0x9e, 0x4b, 0xe9, 0x22, 0x37, 0xa6, 0x66, 0xed}} 40 | 41 | typedef struct _IOC_UART_PROTOCOL IOC_UART_PROTOCOL; 42 | 43 | typedef 44 | EFI_STATUS 45 | (EFIAPI *EFI_SET_SUPPRESS_HEART_BEAT_TIMEOUT) ( 46 | IN IOC_UART_PROTOCOL *This, 47 | IN UINT32 timeout 48 | ); 49 | 50 | typedef 51 | EFI_STATUS 52 | (EFIAPI *EFI_NOTIFY_IOC_CM_READY) ( 53 | IN IOC_UART_PROTOCOL *This 54 | ); 55 | 56 | typedef 57 | EFI_STATUS 58 | (EFIAPI * EFI_FLASH_IOC_FIRMWARE) ( 59 | IN IOC_UART_PROTOCOL * This, 60 | IN UINT8 * file_content, 61 | IN UINT32 file_size 62 | ); 63 | 64 | struct _IOC_UART_PROTOCOL { 65 | EFI_SET_SUPPRESS_HEART_BEAT_TIMEOUT SetSuppressHeartBeatTimeout; 66 | EFI_NOTIFY_IOC_CM_READY NotifyIOCCMReady; 67 | EFI_FLASH_IOC_FIRMWARE flash_ioc_firmware; 68 | } __attribute__((packed)); 69 | 70 | #endif /* _IOC_UART_PROTOCOL_H_ */ 71 | -------------------------------------------------------------------------------- /include/keybox_provision.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _KEYBOX_PROVISION_H_ 18 | #define _KEYBOX_PROVISION_H_ 19 | 20 | EFI_STATUS flash_keybox(VOID *data, UINTN size); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/libelfloader.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2017 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | 17 | #ifndef _LIBELFLOADER_H_ 18 | #define _LIBELFLOADER_H_ 19 | 20 | #include "efi.h" 21 | #include "efilib.h" 22 | 23 | BOOLEAN relocate_elf_image( IN uint64_t ld_addr, 24 | IN uint64_t ld_size, 25 | IN uint64_t rt_addr, 26 | IN uint64_t rt_size, 27 | OUT uint64_t *p_entry); 28 | 29 | #endif /* _LIBELFLOADER_H_ */ 30 | -------------------------------------------------------------------------------- /include/libtipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #ifndef TRUSTY_LIBTIPC_H_ 25 | #define TRUSTY_LIBTIPC_H_ 26 | 27 | 28 | /* 29 | * Initialize TIPC library 30 | */ 31 | int trusty_ipc_init(void); 32 | /* 33 | * Shutdown TIPC library 34 | */ 35 | void trusty_ipc_shutdown(void); 36 | 37 | #endif /* TRUSTY_LIBTIPC_H_ */ 38 | -------------------------------------------------------------------------------- /include/life_cycle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Leo Sartre 6 | * Jeremy Compostella 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #ifndef _LIFE_CYCLE_H_ 35 | #define _LIFE_CYCLE_H_ 36 | 37 | #include 38 | #include 39 | 40 | EFI_STATUS life_cycle_is_enduser(BOOLEAN *enduser); 41 | 42 | #endif /* _LIFE_CYCLE_H_ */ 43 | -------------------------------------------------------------------------------- /include/oemvars.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __OEMVARS_H__ 34 | #define __OEMVARS_H__ 35 | 36 | #include 37 | 38 | EFI_STATUS flash_oemvars(VOID *data, UINTN size); 39 | EFI_STATUS flash_oemvars_silent_write_error(VOID *data, UINTN size, 40 | const EFI_GUID *restricted_guid); 41 | 42 | #endif /* __OEMVARS_H__ */ 43 | -------------------------------------------------------------------------------- /include/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Andrew Boie 6 | * Some Linux bootstrapping code adapted from efilinux by 7 | * Matt Fleming 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _OPTIONS_H_ 36 | #define _OPTIONS_H_ 37 | 38 | #include 39 | #include 40 | 41 | EFI_STATUS get_argv(EFI_LOADED_IMAGE *image, UINTN *argc_p, CHAR16 ***argv_p, CHAR16 **options); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/pae.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _PAE_H_ 34 | #define _PAE_H_ 35 | 36 | EFI_STATUS pae_init(CHAR8 *entries, UINTN nr_entries, UINTN entry_sz); 37 | EFI_STATUS pae_map(EFI_PHYSICAL_ADDRESS addr, unsigned char **to, UINT64 *len); 38 | EFI_STATUS pae_exit(void); 39 | 40 | #endif /* _PAE_H_ */ 41 | -------------------------------------------------------------------------------- /include/security_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _SECURITY_INTERFACE_H_ 32 | #define _SECURITY_INTERFACE_H_ 33 | 34 | #include 35 | 36 | EFI_STATUS set_device_security_info(IN VOID *security_data); 37 | 38 | #endif /* _SECURITY_INTERFACE_H_ */ 39 | -------------------------------------------------------------------------------- /include/security_vb2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SECURITY_VB2_H_ 18 | #define _SECURITY_VB2_H_ 19 | 20 | EFI_STATUS rot_pub_key_sha256(IN VBDATA *vb_data, 21 | OUT UINT8 **hash_p); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/smbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _SMBIOS_H_ 34 | #define _SMBIOS_H_ 35 | 36 | #define TYPE_BIOS 0 37 | #define TYPE_PRODUCT 1 38 | #define TYPE_BOARD 2 39 | #define TYPE_CHASSIS 3 40 | 41 | extern char *SMBIOS_UNDEFINED; 42 | 43 | char *smbios_get_string(UINT8 type, UINT8 offset); 44 | 45 | #define SMBIOS_GET_STRING(type, field) \ 46 | smbios_get_string(type, offsetof(SMBIOS_TYPE##type, field)) 47 | 48 | #endif /* _SMBIOS_H_ */ 49 | -------------------------------------------------------------------------------- /include/targets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Andrew Boie 6 | * Jeremy Compostella 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #ifndef _TARGETS_H_ 35 | #define _TARGETS_H_ 36 | 37 | #include 38 | #include 39 | 40 | enum boot_target { 41 | UNKNOWN_TARGET = -1, 42 | NORMAL_BOOT, 43 | FASTBOOT, 44 | ELK, 45 | RECOVERY, 46 | CRASHMODE, 47 | DNX, 48 | ESP_BOOTIMAGE, 49 | ESP_EFI_BINARY, 50 | MEMORY, 51 | CHARGER, 52 | POWER_OFF, 53 | EXIT_SHELL 54 | }; 55 | 56 | #define is_bootimg_target(target) \ 57 | (target == NORMAL_BOOT || target == CHARGER || target == RECOVERY) 58 | 59 | const CHAR16 *boot_target_name(enum boot_target bt); 60 | const CHAR16 *boot_target_description(enum boot_target bt); 61 | enum boot_target name_to_boot_target(const CHAR16 *str); 62 | EFI_STATUS reboot_to_target(enum boot_target bt, EFI_RESET_TYPE type); 63 | 64 | #endif /* _TARGETS_H_ */ 65 | -------------------------------------------------------------------------------- /include/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _TCP_H_ 34 | #define _TCP_H_ 35 | 36 | #include 37 | #include 38 | 39 | EFI_STATUS tcp_start(UINT32 port, start_callback_t start_cb, 40 | data_callback_t rx_cb, data_callback_t tx_cb, 41 | EFI_IPv4_ADDRESS *station_address); 42 | EFI_STATUS tcp_stop(void); 43 | EFI_STATUS tcp_run(void); 44 | EFI_STATUS tcp_read(void *buf, UINT32 size); 45 | EFI_STATUS tcp_write(void *buf, UINT32 size); 46 | 47 | #endif /* _TCP_H_ */ 48 | -------------------------------------------------------------------------------- /include/text_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _TEXT_PARSER_H_ 34 | #define _TEXT_PARSER_H_ 35 | 36 | #include 37 | #include 38 | 39 | void skip_whitespace(char **line); 40 | EFI_STATUS parse_text_buffer(VOID *data, UINTN size, 41 | EFI_STATUS (*parse_line)(char *line, VOID *ctx), 42 | VOID *context); 43 | 44 | #endif /* _TEXT_PARSER_H_ */ 45 | -------------------------------------------------------------------------------- /include/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | #ifndef _TIMER_H_ 31 | #define _TIMER_H_ 32 | 33 | #include 34 | #include 35 | #include "lib.h" 36 | 37 | enum TM_POINT { 38 | TM_EFI_MAIN = 0, 39 | TM_AVB_START, 40 | TM_VERIFY_BOOT_DONE, 41 | TM_LOAD_TOS_DONE, 42 | TM_LAUNCH_TRUSTY_DONE, 43 | TM_PROCRSS_TRUSTY_DONE, 44 | TM_JMP_KERNEL, 45 | TM_POINT_LAST 46 | }; 47 | 48 | uint32_t get_cpu_freq(void); 49 | uint32_t boottime_in_msec(void); 50 | void set_boottime_stamp(int num); 51 | void set_efi_enter_point(unsigned int value); 52 | void construct_stages_boottime(CHAR8 *time_str, size_t buf_len); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _TRANSPORT_H_ 34 | #define _TRANSPORT_H_ 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | typedef void (*data_callback_t)(void *buf, unsigned len); 41 | typedef void (*start_callback_t)(void); 42 | 43 | typedef struct transport { 44 | const char *name; 45 | EFI_STATUS (*start)(start_callback_t start_cb, 46 | data_callback_t rx_cb, 47 | data_callback_t tx_cb); 48 | EFI_STATUS (*stop)(void); 49 | EFI_STATUS (*run)(void); 50 | EFI_STATUS (*read)(void *buf, UINT32 size); 51 | EFI_STATUS (*write)(void *buf, UINT32 size); 52 | } transport_t; 53 | 54 | EFI_STATUS transport_register(transport_t *trans, UINTN nb); 55 | void transport_unregister(void); 56 | 57 | EFI_STATUS transport_start(start_callback_t start_cb, 58 | data_callback_t rx_cb, 59 | data_callback_t tx_cb); 60 | EFI_STATUS transport_stop(void); 61 | EFI_STATUS transport_run(void); 62 | EFI_STATUS transport_read(void *buf, UINT32 len); 63 | EFI_STATUS transport_write(void *buf, UINT32 len); 64 | 65 | #endif /* _TRANSPORT_H_ */ 66 | -------------------------------------------------------------------------------- /include/trusty_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _TRUSTY_COMMON_H_ 32 | #define _TRUSTY_COMMON_H_ 33 | 34 | #include "efi.h" 35 | #include "efilib.h" 36 | 37 | EFI_STATUS load_tos_image(OUT VOID **bootimage); 38 | 39 | #endif /* _TRUSTY_COMMON_H_ */ 40 | -------------------------------------------------------------------------------- /include/trusty_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _TRUSTY_INTERFACE_H_ 32 | #define _TRUSTY_INTERFACE_H_ 33 | 34 | #include "efi.h" 35 | #include "efilib.h" 36 | #include "vars.h" 37 | #include 38 | 39 | #define LENGTH_TRUSTY_PARAM_STRING 18 40 | #define TRUSTY_PARAM_STRING "trusty.param_addr=" 41 | 42 | EFI_STATUS start_trusty(VOID *trusty_image); 43 | EFI_STATUS set_trusty_param(IN VOID *param_data); 44 | 45 | #endif /* _TRUSTY_INTERFACE_H_ */ 46 | -------------------------------------------------------------------------------- /include/upng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _UPNG_H_ 34 | #define _UPNG_H_ 35 | 36 | #include 37 | 38 | EFI_STATUS upng_load(const char *data, UINTN size, 39 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL **blt, 40 | UINTN *width, UINTN *height); 41 | 42 | #endif /* _UPNG_H_ */ 43 | -------------------------------------------------------------------------------- /include/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _USB_H_ 36 | #define _USB_H_ 37 | 38 | #include 39 | 40 | EFI_STATUS usb_start(UINT8 subclass, 41 | UINT8 protocol, 42 | CHAR16 *str_configuration, 43 | CHAR16 *str_interface, 44 | start_callback_t start_cb, 45 | data_callback_t rx_cb, 46 | data_callback_t tx_cb); 47 | EFI_STATUS usb_stop(void); 48 | EFI_STATUS usb_run(void); 49 | EFI_STATUS usb_read(void *buf, UINT32 size); 50 | EFI_STATUS usb_write(void *buf, UINT32 size); 51 | 52 | #endif /* _USB_H_ */ 53 | -------------------------------------------------------------------------------- /include/vbmeta_ias.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Wu Ji Zhang, GaofengX 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #ifndef _VBMETA_IAS_H 32 | #define _VBMETA_IAS_H 33 | EFI_STATUS verify_vbmeta_ias(CHAR16 *label, CHAR16* fileName, BOOLEAN *verify_pass); 34 | #endif 35 | -------------------------------------------------------------------------------- /include/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Andrew Boie 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef KERNELFLINGER_VERSION_H 34 | #define KERNELFLINGER_VERSION_H 35 | 36 | #define WIDE_STR2(x) L ## x 37 | #define WIDE_STR(x) WIDE_STR2(x) 38 | 39 | #if defined(USER) 40 | #define BUILD_VARIANT "" 41 | #elif defined(USERDEBUG) 42 | #define BUILD_VARIANT "-userdebug" 43 | #else 44 | #define BUILD_VARIANT "-eng" 45 | #endif 46 | 47 | #ifdef FASTBOOT_FOR_NON_ANDROID 48 | #define KERNELFLINGER_VERSION_8 "fastboot-NonAndroid-1.0" BUILD_VARIANT 49 | #else 50 | #define KERNELFLINGER_VERSION_8 "kernelflinger-07.02" BUILD_VARIANT 51 | #endif 52 | #define KERNELFLINGER_VERSION WIDE_STR(KERNELFLINGER_VERSION_8) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/watchdog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _WATCHDOG_H_ 32 | #define _WATCHDOG_H_ 33 | 34 | #include 35 | 36 | #define TCO_DEFAULT_TIMEOUT 60 37 | #define TCO_MIN_TIMEOUT 4 38 | #define TCO_OPT_DISABLED "iTCO_wdt.force_no_reboot=1" 39 | 40 | EFI_STATUS start_watchdog(UINT32 seconds); 41 | BOOLEAN watchdog_disabled_from_cmdline(CHAR8 *); 42 | 43 | #endif /* _WATCHDOG_H_ */ 44 | -------------------------------------------------------------------------------- /libadb/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libadb-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | LOCAL_STATIC_LIBRARIES := \ 8 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 9 | libefiusb-$(TARGET_BUILD_VARIANT) \ 10 | libefitcp-$(TARGET_BUILD_VARIANT) \ 11 | libtransport-$(TARGET_BUILD_VARIANT) \ 12 | libkernelflinger-$(TARGET_BUILD_VARIANT) 13 | 14 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libadb 15 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libadb 16 | LOCAL_SRC_FILES := \ 17 | adb.c \ 18 | adb_socket.c \ 19 | reboot_service.c \ 20 | sync_service.c \ 21 | reader.c \ 22 | shell_service.c \ 23 | devmem.c \ 24 | lsacpi.c \ 25 | hexdump.c \ 26 | ioport.c \ 27 | lspartition.c \ 28 | pci_class.c \ 29 | lspci.c 30 | 31 | include $(BUILD_EFI_STATIC_LIBRARY) 32 | -------------------------------------------------------------------------------- /libadb/adb_socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _ADB_SOCKET_H_ 34 | #define _ADB_SOCKET_H_ 35 | 36 | #include 37 | #include 38 | 39 | #include "adb.h" 40 | 41 | typedef struct asock * asock_t; 42 | 43 | struct service; 44 | 45 | #define MAX_ADB_SOCKET 5 46 | 47 | /* Host to device */ 48 | EFI_STATUS asock_open(UINT32 remote, struct service *service, char *arg); 49 | EFI_STATUS asock_close(asock_t s); 50 | EFI_STATUS asock_okay(asock_t s); 51 | EFI_STATUS asock_read(asock_t s, unsigned char *data, UINT32 length); 52 | 53 | /* Device to host */ 54 | EFI_STATUS asock_write(asock_t s, unsigned char *data, UINT32 length); 55 | EFI_STATUS asock_send_okay(asock_t s); 56 | EFI_STATUS asock_send_close(asock_t s); 57 | 58 | /* Tools */ 59 | void *asock_context(asock_t s); 60 | asock_t asock_find(UINT32 local, UINT32 remote); 61 | void asock_close_all(); 62 | 63 | #endif /* _ADB_SOCKET_H_ */ 64 | -------------------------------------------------------------------------------- /libadb/devmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _DEVMEM_H_ 34 | #define _DEVMEM_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | extern shcmd_t devmem_shcmd; 39 | 40 | #endif /* _DEVMEM_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/hexdump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "hexdump.h" 38 | 39 | static EFI_STATUS hexdump_main(INTN argc, const char **argv) 40 | { 41 | EFI_STATUS ret = EFI_INVALID_PARAMETER; 42 | EFI_PHYSICAL_ADDRESS address, real; 43 | UINT64 length; 44 | 45 | if (argc != 3) 46 | return EFI_INVALID_PARAMETER; 47 | 48 | ret = ss_read_number(argv[1], "ADDRESS", &address); 49 | if (EFI_ERROR(ret)) 50 | return EFI_INVALID_PARAMETER; 51 | real = address; 52 | 53 | ret = ss_read_number(argv[2], "LENGTH", &length); 54 | if (EFI_ERROR(ret)) 55 | return EFI_INVALID_PARAMETER; 56 | 57 | #ifndef __LP64__ 58 | if (address > UINT32_MAX) { 59 | ret = ss_pae_map(&address, length); 60 | if (EFI_ERROR(ret)) 61 | return ret; 62 | } 63 | #endif 64 | 65 | ss_hexdump((unsigned char *)address, length, real, TRUE); 66 | 67 | #ifndef __LP64__ 68 | pae_exit(); 69 | #endif 70 | 71 | return EFI_SUCCESS; 72 | } 73 | 74 | shcmd_t hexdump_shcmd = { 75 | .name = "hexdump", 76 | .summary = "Hexdump a memory region", 77 | .help = "Usage: hexdump ADDRESS LENGTH", 78 | .main = hexdump_main 79 | }; 80 | -------------------------------------------------------------------------------- /libadb/hexdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _HEXDUMP_H_ 34 | #define _HEXDUMP_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | extern shcmd_t hexdump_shcmd; 39 | 40 | #endif /* _HEXDUMP_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/ioport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _IOPORT_H_ 34 | #define _IOPORT_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | static inline UINT32 inl(int port) 39 | { 40 | UINT32 val; 41 | 42 | __asm__ __volatile__("inl %w1, %0" : "=a"(val) : "Nd"(port)); 43 | return val; 44 | } 45 | 46 | static inline void outl(UINT32 val, int port) 47 | { 48 | __asm__ __volatile__("outl %0, %w1" : : "a"(val), "Nd"(port)); 49 | } 50 | 51 | extern shcmd_t inb_shcmd; 52 | extern shcmd_t inw_shcmd; 53 | extern shcmd_t inl_shcmd; 54 | extern shcmd_t outb_shcmd; 55 | extern shcmd_t outw_shcmd; 56 | extern shcmd_t outl_shcmd; 57 | 58 | #endif /* _IOPORT_H_ */ 59 | -------------------------------------------------------------------------------- /libadb/lsacpi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _LSACPI_H_ 34 | #define _LSACPI_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | extern shcmd_t lsacpi_shcmd; 39 | 40 | #endif /* _LSACPI_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/lspartition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _LSPARTITION_H_ 34 | #define _LSPARTITION_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | extern shcmd_t lspartition_shcmd; 39 | 40 | #endif /* _LSPARTITION_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/lspci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _LSPCI_H_ 34 | #define _LSPCI_H_ 35 | 36 | #include "shell_service.h" 37 | 38 | extern shcmd_t lspci_shcmd; 39 | 40 | #endif /* _LSPCI_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/pci_class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _PCI_CLASS_H_ 34 | #define _PCI_CLASS_H_ 35 | 36 | #include 37 | 38 | const char *pci_class_string(UINT8 base, UINT8 sub); 39 | 40 | #endif /* _PCI_CLASS_H_ */ 41 | -------------------------------------------------------------------------------- /libadb/reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _READER_H_ 34 | #define _READER_H_ 35 | 36 | #include 37 | 38 | typedef struct reader_context { 39 | struct reader *reader; 40 | UINT64 cur; 41 | UINT64 len; 42 | void *private; 43 | } reader_ctx_t; 44 | 45 | EFI_STATUS reader_open(reader_ctx_t *reader, char *args); 46 | EFI_STATUS reader_read(reader_ctx_t *reader, unsigned char **buf, UINT64 *len); 47 | void reader_close(reader_ctx_t *reader); 48 | 49 | #endif /* _READER_H_ */ 50 | -------------------------------------------------------------------------------- /libadb/service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _SERVICE_H_ 34 | #define _SERVICE_H_ 35 | 36 | #include 37 | #include 38 | 39 | #include "adb_socket.h" 40 | 41 | /* adb service interface */ 42 | typedef struct service { 43 | const char *name; 44 | EFI_STATUS (*open)(const char *arg, void **context); 45 | EFI_STATUS (*ready)(asock_t s); 46 | EFI_STATUS (*close)(asock_t s); 47 | EFI_STATUS (*okay)(asock_t s); 48 | EFI_STATUS (*read)(asock_t s, unsigned char *data, UINT32 length); 49 | } service_t; 50 | 51 | extern service_t sync_service; 52 | extern service_t reboot_service; 53 | extern service_t shell_service; 54 | 55 | #endif /* _SERVICE_H_ */ 56 | -------------------------------------------------------------------------------- /libadb/shell_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _SHELL_SERVICE_H_ 34 | #define _SHELL_SERVICE_H_ 35 | 36 | #include 37 | 38 | EFI_STATUS ss_printf(const CHAR16 *fmt, ...); 39 | EFI_STATUS ss_read_number(const char *arg, const char *name, UINT64 *value); 40 | void ss_hexdump(unsigned char *buf, UINTN length, 41 | EFI_PHYSICAL_ADDRESS address, BOOLEAN canonical); 42 | 43 | #ifndef __LP64__ 44 | EFI_STATUS ss_pae_map(EFI_PHYSICAL_ADDRESS *address, UINT64 length); 45 | #endif 46 | 47 | typedef struct { 48 | const char *name; 49 | const char *summary; 50 | const char *help; 51 | EFI_STATUS (*main)(INTN argc, const char **argv); 52 | } shcmd_t; 53 | 54 | #endif /* _SHELL_SERVICE_H_ */ 55 | -------------------------------------------------------------------------------- /libedk2_tpm/Android.mk: -------------------------------------------------------------------------------- 1 | LIBEDK2_LOCAL_PATH := $(call my-dir) 2 | include $(call all-subdir-makefiles) 3 | LOCAL_PATH := $(LIBEDK2_LOCAL_PATH) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_MODULE := libedk2_tpm 8 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include \ 9 | $(LOCAL_PATH)/../include/libkernelflinger 10 | LOCAL_CFLAGS := -Wall -Wextra -Werror -mrdrnd \ 11 | -DTARGET_BOOTLOADER_BOARD_NAME=\"$(TARGET_BOOTLOADER_BOARD_NAME)\" 12 | LOCAL_STATIC_LIBRARIES := libgnuefi \ 13 | libefi 14 | 15 | LOCAL_SRC_FILES := \ 16 | Tpm2NVStorage.c \ 17 | Tpm2Random.c \ 18 | Tpm2DeviceLib.c \ 19 | Tpm2Help.c \ 20 | Tpm2Context.c \ 21 | Tpm2EnhancedAuthorization.c \ 22 | Tpm2Hierarchy.c \ 23 | Tpm2Integrity.c \ 24 | Tpm2Sequences.c \ 25 | Tpm2Session.c \ 26 | Tpm2Capability.c 27 | 28 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \ 29 | $(LOCAL_PATH)/../include/libkernelflinger \ 30 | $(res_intermediates) 31 | 32 | include $(BUILD_EFI_STATIC_LIBRARY) 33 | -------------------------------------------------------------------------------- /libedk2_tpm/README: -------------------------------------------------------------------------------- 1 | EDK2 Functionality 2 | 3 | We use the edk2 library for creating and managing the TPM 4 | entities in kernelflinger. The necessary TPM functions are 5 | ported to kernelflinger/edk2. The Tcg2 protocol headers are 6 | ported to edk2/include. 7 | 8 | Github link : https://github.com/tianocore/edk2 -------------------------------------------------------------------------------- /libedk2_tpm/Tpm2DeviceLib.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | Implement TPM2 SubmitCommand. 3 | 4 | Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
5 | This program and the accompanying materials 6 | are licensed and made available under the terms and conditions of the BSD License 7 | which accompanies this distribution. The full text of the license may be found at 8 | http://opensource.org/licenses/bsd-license.php 9 | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 | 13 | **/ 14 | 15 | #include 16 | #include 17 | #include "Tpm2Help.h" 18 | #include "Tcg2Protocol.h" 19 | #include "Tpm2DeviceLib.h" 20 | 21 | EFI_STATUS 22 | EFIAPI 23 | Tpm2SubmitCommand ( 24 | IN UINT32 InputParameterBlockSize, 25 | IN UINT8 *InputParameterBlock, 26 | IN OUT UINT32 *OutputParameterBlockSize, 27 | IN UINT8 *OutputParameterBlock 28 | ) 29 | { 30 | EFI_STATUS Status; 31 | TPM2_RESPONSE_HEADER *Header; 32 | 33 | EFI_GUID gEfiTcg2ProtocolGuid = EFI_TCG2_PROTOCOL_GUID; 34 | EFI_TCG2_PROTOCOL *mTcg2Protocol; 35 | 36 | Status = LibLocateProtocol (&gEfiTcg2ProtocolGuid, (void **) &mTcg2Protocol); 37 | if (EFI_ERROR (Status) || mTcg2Protocol == NULL ) { 38 | // 39 | // Tcg2 protocol is not installed. So, TPM2 is not present. 40 | // 41 | return EFI_NOT_FOUND; 42 | } 43 | // 44 | // Assume when Tcg2 Protocol is ready, RequestUseTpm already done. 45 | // 46 | Status = mTcg2Protocol->SubmitCommand ( 47 | mTcg2Protocol, 48 | InputParameterBlockSize, 49 | InputParameterBlock, 50 | *OutputParameterBlockSize, 51 | OutputParameterBlock 52 | ); 53 | if (EFI_ERROR (Status)) { 54 | return Status; 55 | } 56 | 57 | Header = (TPM2_RESPONSE_HEADER *)OutputParameterBlock; 58 | *OutputParameterBlockSize = SwapBytes32 (Header->paramSize); 59 | 60 | return EFI_SUCCESS; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /libedk2_tpm/Tpm2Random.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | 3 | Copyright (c) 2012, Intel Corporation. All rights reserved.
4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | **/ 13 | 14 | #include "UefiTcgPlatform.h" 15 | #include "Tpm2DeviceLib.h" 16 | #include "Tpm2Help.h" 17 | 18 | #pragma pack(1) 19 | 20 | typedef struct { 21 | TPM2_COMMAND_HEADER Header; 22 | UINT16 BytesRequested; 23 | } TPM2_GETRANDOM_COMMAND; 24 | 25 | typedef struct { 26 | TPM2_RESPONSE_HEADER Header; 27 | TPM2B_DIGEST RandomBytes; 28 | } TPM2_GETRANDOM_RESPONSE; 29 | 30 | #pragma pack() 31 | 32 | /** 33 | Send GetRandom command to TPM2. 34 | 35 | @param BytesRequested BytesRequested 36 | @param RandomBytes RandomBytes 37 | 38 | @retval EFI_SUCCESS Operation completed successfully. 39 | @retval EFI_DEVICE_ERROR Unexpected device behavior. 40 | **/ 41 | EFI_STATUS 42 | EFIAPI 43 | Tpm2GetRandom ( 44 | IN UINT16 BytesRequested, 45 | OUT TPM2B_DIGEST *RandomBytes 46 | ) 47 | { 48 | EFI_STATUS Status; 49 | TPM2_GETRANDOM_COMMAND Cmd; 50 | TPM2_GETRANDOM_RESPONSE Res; 51 | UINT32 ResultBufSize; 52 | 53 | Cmd.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS); 54 | Cmd.Header.paramSize = SwapBytes32(sizeof(Cmd)); 55 | Cmd.Header.commandCode = SwapBytes32(TPM_CC_GetRandom); 56 | Cmd.BytesRequested = SwapBytes16(BytesRequested); 57 | 58 | ResultBufSize = sizeof(Res); 59 | Status = Tpm2SubmitCommand (sizeof(Cmd), (UINT8 *)&Cmd, &ResultBufSize, (UINT8 *)&Res); 60 | if (EFI_ERROR (Status)) { 61 | return Status; 62 | } 63 | RandomBytes->size = SwapBytes16(Res.RandomBytes.size); 64 | CopyMem (RandomBytes->buffer, Res.RandomBytes.buffer, RandomBytes->size); 65 | 66 | return Status; 67 | } 68 | -------------------------------------------------------------------------------- /libefitcp/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libefitcp-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | LOCAL_STATIC_LIBRARIES := \ 8 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 9 | libkernelflinger-$(TARGET_BUILD_VARIANT) \ 10 | libtransport-$(TARGET_BUILD_VARIANT) 11 | 12 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libefitcp 13 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libefitcp 14 | LOCAL_SRC_FILES := \ 15 | tcp.c 16 | 17 | include $(BUILD_EFI_STATIC_LIBRARY) 18 | -------------------------------------------------------------------------------- /libefiusb/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libefiusb-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | LOCAL_STATIC_LIBRARIES := \ 8 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 9 | libtransport-$(TARGET_BUILD_VARIANT) \ 10 | libkernelflinger-$(TARGET_BUILD_VARIANT) 11 | 12 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libefiusb 13 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libefiusb 14 | LOCAL_SRC_FILES := \ 15 | usb.c 16 | 17 | ifeq ($(KERNELFLINGER_SUPPORT_SELF_USB_DEVICE_MODE_PROTOCOL),true) 18 | LOCAL_CFLAGS += -DUSE_SELF_USB_DEVICE_MODE_PROTOCOL 19 | LOCAL_SRC_FILES += \ 20 | device_mode/cpuio.c \ 21 | device_mode/UsbDeviceDxe.c \ 22 | device_mode/UsbDeviceMode.c \ 23 | device_mode/XdciDevice.c \ 24 | device_mode/XdciDWC.c \ 25 | device_mode/XdciTable.c \ 26 | device_mode/XdciUtility.c 27 | endif 28 | 29 | include $(BUILD_EFI_STATIC_LIBRARY) 30 | -------------------------------------------------------------------------------- /libefiusb/device_mode/UsbDeviceMode.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
3 | 4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php. 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | **/ 13 | 14 | #ifndef _USB_DEVICE_MODE_DXE_H_ 15 | #define _USB_DEVICE_MODE_DXE_H_ 16 | 17 | #include "protocol/UsbIo.h" 18 | #include "protocol/UsbDeviceModeProtocol.h" 19 | 20 | 21 | /// 22 | /// Function declaration 23 | /// 24 | EFI_STATUS 25 | UsbdSetupHdlr ( 26 | IN EFI_USB_DEVICE_REQUEST *CtrlRequest 27 | ); 28 | 29 | extern EFI_USB_DEVICE_MODE_PROTOCOL mUsbDeviceModeProtocol; 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /libefiusb/device_mode/XdciTable.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
3 | 4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php. 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | **/ 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "XdciCommon.h" 19 | #include "XdciDevice.h" 20 | #include "XdciInterface.h" 21 | #include "XdciDWC.h" 22 | #include "UsbDeviceDxe.h" 23 | 24 | static const struct UsbDeviceCoreDriver CoreDriverTbl[USB_CORE_ID_MAX] = { { 25 | DwcXdciCoreInit, 26 | DwcXdciCoreDeinit, 27 | DwcXdciCoreRegisterCallback, 28 | DwcXdciCoreUnregisterCallback, 29 | DwcXdciCoreIsrRoutine, 30 | DwcXdciCoreIsrRoutineTimerBased, 31 | DwcXdciCoreConnect, 32 | DwcXdciCoreDisconnect, 33 | DwcXdciCoreGetSpeed, 34 | DwcXdciCoreSetAddress, 35 | DwcXdciCoreSetConfig, 36 | DwcXdciSetLinkState, 37 | DwcXdciInitEp, 38 | DwcXdciEpEnable, 39 | DwcXdciEpDisable, 40 | DwcXdciEpStall, 41 | DwcXdciEpClearStall, 42 | DwcXdciEpSetNrdy, 43 | DwcXdciEp0ReceiveSetupPkt, 44 | DwcXdciEp0ReceiveStatusPkt, 45 | DwcXdciEp0SendStatusPkt, 46 | DwcXdciEpTxData, 47 | DwcXdciEpRxData, 48 | DwcXdciEpCancelTransfer} 49 | }; 50 | 51 | const struct UsbDeviceCoreDriver *UsbDeviceGetCoreDriver(USB_CONTROLLER_ID id) 52 | { 53 | if (id >= USB_CORE_ID_MAX) 54 | return NULL; 55 | 56 | return &CoreDriverTbl[id]; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /libefiusb/device_mode/XdciUtility.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
3 | 4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php. 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | **/ 13 | 14 | #ifndef _XDCI_UTILITY_H_ 15 | #define _XDCI_UTILITY_H_ 16 | 17 | #include "protocol/UsbDeviceLib.h" 18 | 19 | VOID 20 | PrintDeviceDescriptor ( 21 | IN USB_DEVICE_DESCRIPTOR *DevDesc 22 | ); 23 | 24 | VOID 25 | PrintConfigDescriptor ( 26 | IN EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc 27 | ); 28 | 29 | VOID 30 | PrintInterfaceDescriptor ( 31 | IN EFI_USB_INTERFACE_DESCRIPTOR *IfDesc 32 | ); 33 | 34 | VOID 35 | PrintEpDescriptor ( 36 | IN EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc 37 | ); 38 | 39 | VOID 40 | PrintEpCompDescriptor ( 41 | IN EFI_USB_ENDPOINT_COMPANION_DESCRIPTOR *EpDesc 42 | ); 43 | 44 | VOID 45 | PrintStringDescriptor ( 46 | IN USB_STRING_DESCRIPTOR *StrDesc 47 | ); 48 | 49 | VOID 50 | PrintDeviceRequest ( 51 | IN EFI_USB_DEVICE_REQUEST *DevReq 52 | ); 53 | 54 | VOID 55 | PrintBOSDescriptor ( 56 | IN EFI_USB_BOS_DESCRIPTOR *BosDesc 57 | ); 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /libelfloader/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libelfloader-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | LOCAL_STATIC_LIBRARIES := \ 8 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 9 | libkernelflinger-$(TARGET_BUILD_VARIANT) 10 | 11 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libelfloader 12 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include 13 | 14 | LOCAL_SRC_FILES := \ 15 | elf32_ld.c \ 16 | elf64_ld.c \ 17 | elf_ld.c 18 | 19 | include $(BUILD_EFI_STATIC_LIBRARY) 20 | -------------------------------------------------------------------------------- /libfastboot/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | SHARED_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include 4 | SHARED_CFLAGS := \ 5 | $(KERNELFLINGER_CFLAGS) \ 6 | -DTARGET_BOOTLOADER_BOARD_NAME=\"$(TARGET_BOOTLOADER_BOARD_NAME)\" 7 | 8 | SHARED_C_INCLUDES := $(LOCAL_PATH)/../include \ 9 | $(KERNELFLINGER_LOCAL_PATH)/avb 10 | SHARED_STATIC_LIBRARIES := \ 11 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 12 | libefiusb-$(TARGET_BUILD_VARIANT) \ 13 | libefitcp-$(TARGET_BUILD_VARIANT) \ 14 | libtransport-$(TARGET_BUILD_VARIANT) \ 15 | libkernelflinger-$(TARGET_BUILD_VARIANT) \ 16 | libavb_kernelflinger-$(TARGET_BUILD_VARIANT) 17 | 18 | ifeq ($(TARGET_USE_TPM),true) 19 | SHARED_STATIC_LIBRARIES += libedk2_tpm 20 | endif 21 | 22 | SHARED_SRC_FILES := \ 23 | fastboot.c \ 24 | fastboot_oem.c \ 25 | fastboot_flashing.c \ 26 | flash.c \ 27 | sparse.c \ 28 | info.c \ 29 | intel_variables.c \ 30 | bootmgr.c \ 31 | hashes.c \ 32 | bootloader.c \ 33 | keybox_provision.c 34 | 35 | include $(CLEAR_VARS) 36 | 37 | LOCAL_MODULE := libfastboot-$(TARGET_BUILD_VARIANT) 38 | LOCAL_CFLAGS := $(SHARED_CFLAGS) 39 | LOCAL_STATIC_LIBRARIES := $(SHARED_STATIC_LIBRARIES) 40 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(SHARED_EXPORT_C_INCLUDE_DIRS) 41 | LOCAL_C_INCLUDES := $(SHARED_C_INCLUDES) \ 42 | $(addprefix $(LOCAL_PATH)/../,avb) \ 43 | $(addprefix $(LOCAL_PATH)/../,libsslsupport) 44 | LOCAL_SRC_FILES := $(SHARED_SRC_FILES) \ 45 | fastboot_transport.c 46 | ifneq ($(strip $(KERNELFLINGER_USE_UI)),false) 47 | LOCAL_SRC_FILES += fastboot_ui.c 48 | endif 49 | 50 | ifeq ($(TARGET_USE_SBL),true) 51 | LOCAL_CFLAGS += -DUSE_SBL 52 | endif 53 | 54 | include $(BUILD_EFI_STATIC_LIBRARY) 55 | 56 | include $(CLEAR_VARS) 57 | 58 | LOCAL_MODULE := libfastboot-for-installer-$(TARGET_BUILD_VARIANT) 59 | LOCAL_CFLAGS := $(SHARED_CFLAGS) 60 | LOCAL_STATIC_LIBRARIES := $(SHARED_STATIC_LIBRARIES) 61 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(SHARED_EXPORT_C_INCLUDE_DIRS) 62 | LOCAL_C_INCLUDES := $(SHARED_C_INCLUDES) \ 63 | $(addprefix $(LOCAL_PATH)/../,libsslsupport) 64 | LOCAL_SRC_FILES := $(SHARED_SRC_FILES) 65 | 66 | ifeq ($(TARGET_USE_SBL),true) 67 | LOCAL_CFLAGS += -DUSE_SBL 68 | endif 69 | 70 | include $(BUILD_EFI_STATIC_LIBRARY) 71 | 72 | -------------------------------------------------------------------------------- /libfastboot/authenticated_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _AUTHENTICATED_ACTION_H_ 34 | #define _AUTHENTICATED_ACTION_H_ 35 | 36 | #define ACTION_AUTHORIZATION "action-authorization" 37 | 38 | char *authenticated_action_new_nonce(char *action_name); 39 | EFI_STATUS authenticated_action(void *data, UINTN size); 40 | 41 | #endif /* _AUTHENTICATED_ACTION_H_ */ 42 | -------------------------------------------------------------------------------- /libfastboot/bootloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _BOOTLOADER_H_ 34 | #define _BOOTLOADER_H_ 35 | 36 | EFI_STATUS flash_bootloader(VOID *data, UINTN size); 37 | 38 | EFI_STATUS flash_bootloader_a(VOID *data, UINTN size); 39 | 40 | EFI_STATUS flash_bootloader_b(VOID *data, UINTN size); 41 | 42 | EFI_STATUS flash_esp(VOID *data, UINTN size); 43 | 44 | #endif /* _BOOTLOADER_H_ */ 45 | -------------------------------------------------------------------------------- /libfastboot/bootmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _BOOTMGR_H_ 34 | #define _BOOTMGR_H_ 35 | 36 | #include 37 | 38 | typedef struct load_option { 39 | CHAR16 *description; 40 | CHAR16 *path; 41 | CHAR16 *opt_params; 42 | } load_option_t; 43 | 44 | /* Create or update the load options described by LOAD_OPTIONS and set 45 | these load options as the first ones in the boot order. PART_LABEL 46 | is the partition label where the load options PATH apply. */ 47 | EFI_STATUS bootmgr_register_entries(CHAR16 *part_label, 48 | load_option_t *load_options, UINTN load_option_nb); 49 | 50 | #endif /* _BOOTMGR_H_ */ 51 | -------------------------------------------------------------------------------- /libfastboot/fastboot_flashing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _FASTBOOT_FLASHING_H_ 32 | #define _FASTBOOT_FLASHING_H_ 33 | 34 | EFI_STATUS fastboot_flashing_init(void); 35 | void fastboot_flashing_free(); 36 | 37 | /* Change the current device state to NEW_STATE. If INTERACTIVE is 38 | * TRUE, UI confirmation is active and fastboot protocol response will 39 | * be sent. */ 40 | EFI_STATUS change_device_state(enum device_state new_state, BOOLEAN interactive); 41 | 42 | EFI_STATUS fastboot_flashing_publish(void); 43 | #endif /* _FASTBOOT_FLASHING_H_ */ 44 | -------------------------------------------------------------------------------- /libfastboot/fastboot_oem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _FASTBOOT_OEM_H_ 36 | #define _FASTBOOT_OEM_H_ 37 | 38 | EFI_STATUS fastboot_oem_init(void); 39 | void fastboot_oem_free(); 40 | 41 | #endif /* _FASTBOOT_OEM_H_ */ 42 | -------------------------------------------------------------------------------- /libfastboot/fastboot_transport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _FASTBOOT_TRANSPORT_H_ 34 | #define _FASTBOOT_TRANSPORT_H_ 35 | 36 | EFI_STATUS fastboot_transport_register(void); 37 | void fastboot_transport_unregister(void); 38 | 39 | #endif /* _FASTBOOT_TRANSPORT_H_ */ 40 | -------------------------------------------------------------------------------- /libfastboot/fastboot_ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef _FASTBOOT_UI_H_ 34 | #define _FASTBOOT_UI_H_ 35 | 36 | #include 37 | 38 | #include "fastboot_oem.h" 39 | 40 | EFI_STATUS fastboot_ui_init(void); 41 | void fastboot_ui_destroy(void); 42 | enum boot_target fastboot_ui_event_handler(void); 43 | BOOLEAN fastboot_ui_confirm_for_state(enum device_state target); 44 | void fastboot_ui_refresh(void); 45 | 46 | #endif /* _FASTBOOT_UI_H_ */ 47 | -------------------------------------------------------------------------------- /libfastboot/flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _FLASH_H_ 36 | #define _FLASH_H_ 37 | 38 | #include 39 | 40 | EFI_STATUS flash_skip(UINT64 size); 41 | EFI_STATUS flash_write(VOID *data, UINTN size); 42 | EFI_STATUS flash_fill(UINT32 pattern, UINTN size); 43 | 44 | /* return value for flash() function */ 45 | 46 | #define REFRESH_PARTITION_VAR 0x1 47 | 48 | EFI_STATUS flash(VOID *data, UINTN size, CHAR16 *label); 49 | EFI_STATUS flash_file(EFI_HANDLE image, CHAR16 *filename, CHAR16 *label); 50 | EFI_STATUS erase_by_label(CHAR16 *label); 51 | EFI_STATUS garbage_disk(void); 52 | EFI_STATUS flash_partition(VOID *data, UINTN size, CHAR16 *label); 53 | EFI_STATUS fill_zero(EFI_BLOCK_IO *bio, UINT64 start, UINT64 end); 54 | 55 | #endif /* _FLASH_H_ */ 56 | -------------------------------------------------------------------------------- /libfastboot/hashes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _HASHES_H_ 36 | #define _HASHES_H_ 37 | 38 | #ifdef USE_MULTIBOOT 39 | EFI_STATUS get_ias_image_hash(const CHAR16 *label); 40 | #endif 41 | EFI_STATUS get_vbmeta_image_hash(const CHAR16 *label); 42 | EFI_STATUS get_boot_image_hash(const CHAR16 *label); 43 | EFI_STATUS get_bootloader_hash(const CHAR16 *label); 44 | EFI_STATUS get_fs_hash(const CHAR16 *label); 45 | EFI_STATUS set_hash_algorithm(const CHAR8 *algo); 46 | #if defined(USE_ACPIO) || defined(USE_ACPI) 47 | EFI_STATUS get_acpi_hash(const CHAR16 *label); 48 | #endif 49 | #ifdef DYNAMIC_PARTITIONS 50 | EFI_STATUS get_super_image_hash(const CHAR16 *label); 51 | #endif 52 | #endif /* _HASHES_H_ */ 53 | -------------------------------------------------------------------------------- /libfastboot/info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "info.h" 39 | 40 | const char *info_bootloader_version(void) 41 | { 42 | return KERNELFLINGER_VERSION_8; 43 | } 44 | 45 | const char *info_baseband_version(void) 46 | { 47 | return "N/A"; 48 | } 49 | 50 | const char *info_variant(void) 51 | { 52 | #ifdef HAL_AUTODETECT 53 | return get_property_device(); 54 | #else 55 | return "N/A"; 56 | #endif 57 | 58 | } 59 | 60 | const char *info_product(void) 61 | { 62 | return TARGET_BOOTLOADER_BOARD_NAME; 63 | } 64 | 65 | const char *info_hw_revision(void) 66 | { 67 | return SMBIOS_GET_STRING(1, Version); 68 | } 69 | -------------------------------------------------------------------------------- /libfastboot/info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __INFO_H__ 34 | #define __INFO_H__ 35 | 36 | const char *info_bootloader_version(void); 37 | const char *info_baseband_version(void); 38 | const char *info_variant(void); 39 | const char *info_product(void); 40 | const char *info_hw_revision(void); 41 | 42 | #endif /* __INFO_H__ */ 43 | -------------------------------------------------------------------------------- /libfastboot/intel_variables.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef __INTEL_VARIABLES_H__ 34 | #define __INTEL_VARIABLES_H__ 35 | 36 | EFI_STATUS publish_intel_variables(void); 37 | 38 | #endif /* __INTEL_VARIABLES_H__ */ 39 | -------------------------------------------------------------------------------- /libfastboot/keybox_provision.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define MAX_KEYBOX_SIZE 16384 25 | #define KB_HEAD_OFFSET 0 26 | 27 | typedef struct keybox_header { 28 | uint8_t magic[12]; 29 | uint32_t size; 30 | uint8_t keybox[0]; 31 | } keybox_header_t; 32 | 33 | EFI_STATUS flash_keybox(VOID *data, UINTN size) 34 | { 35 | EFI_STATUS ret = EFI_SUCCESS; 36 | uint64_t partoffset; 37 | struct gpt_partition_interface gpart; 38 | keybox_header_t kb_header = 39 | { 40 | .magic = "MAGICKEYBOX", 41 | .size = size, 42 | }; 43 | 44 | if (!data) { 45 | error(L"keybox data is NULL!"); 46 | return EFI_INVALID_PARAMETER; 47 | } 48 | 49 | if (size > MAX_KEYBOX_SIZE) { 50 | error(L"keybox size exceeded limit"); 51 | return EFI_INVALID_PARAMETER; 52 | } 53 | 54 | ret = gpt_get_partition_by_label(L"teedata", &gpart, LOGICAL_UNIT_USER); 55 | if (EFI_ERROR(ret)) { 56 | efi_perror(ret, L"Partition teedata not found"); 57 | goto exit; 58 | } 59 | 60 | partoffset = gpart.part.starting_lba * gpart.bio->Media->BlockSize; 61 | 62 | ret = uefi_call_wrapper( 63 | gpart.dio->WriteDisk, 64 | 5, 65 | gpart.dio, 66 | gpart.bio->Media->MediaId, 67 | partoffset + KB_HEAD_OFFSET, 68 | sizeof(keybox_header_t), 69 | (void *)&kb_header); 70 | if (EFI_ERROR(ret)) { 71 | efi_perror(ret, L"Could not write keybox header to disk."); 72 | goto exit; 73 | } 74 | 75 | ret = uefi_call_wrapper( 76 | gpart.dio->WriteDisk, 77 | 5, 78 | gpart.dio, 79 | gpart.bio->Media->MediaId, 80 | sizeof(keybox_header_t) + partoffset + KB_HEAD_OFFSET, 81 | size, 82 | data); 83 | if (EFI_ERROR(ret)) { 84 | efi_perror(ret, L"Could not write keybox to disk."); 85 | goto exit; 86 | } 87 | 88 | exit: 89 | memset_s(data, size, 0, size); 90 | barrier(); 91 | return ret; 92 | } 93 | -------------------------------------------------------------------------------- /libfastboot/sparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Sylvain Chouleur 6 | * Jeremy Compostella 7 | * Jocelyn Falempe 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef _SPARSE_H_ 36 | #define _SPARSE_H_ 37 | 38 | #include 39 | 40 | int is_sparse_image(void *data, UINT64 size); 41 | EFI_STATUS flash_sparse(void *data, UINT64 size); 42 | 43 | #endif /* _SPARSE_H_ */ 44 | -------------------------------------------------------------------------------- /libheci/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libheci-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | 8 | ifeq ($(KERNELFLINGER_DISABLE_DEBUG_PRINT),true) 9 | LOCAL_CFLAGS += -D__DISABLE_DEBUG_PRINT 10 | endif 11 | 12 | LOCAL_STATIC_LIBRARIES := \ 13 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 14 | libkernelflinger-$(TARGET_BUILD_VARIANT) 15 | 16 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libheci 17 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libheci \ 18 | $(LOCAL_PATH)/../libkernelflinger/protocol 19 | 20 | 21 | LOCAL_SRC_FILES := \ 22 | hecisupport.c 23 | 24 | include $(BUILD_EFI_STATIC_LIBRARY) 25 | -------------------------------------------------------------------------------- /libkernelflinger/README: -------------------------------------------------------------------------------- 1 | All PNG files in this directory MUST be PNG RGBA non-interlaced 2 | encoded. The file name MUST NOT have any spaces or dash but only use 3 | underscore characters. -------------------------------------------------------------------------------- /libkernelflinger/life_cycle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Leo Sartre 6 | * Jeremy Compostella 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | * OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | */ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "life_cycle.h" 39 | #include "protocol/LifeCycleProtocol.h" 40 | 41 | EFI_STATUS life_cycle_is_enduser(BOOLEAN *enduser) 42 | { 43 | EFI_STATUS ret; 44 | EFI_GUID guid = EFI_LIFE_CYCLE_STATE_PROTOCOL_GUID; 45 | EFI_LIFE_CYCLE_STATE_PROTOCOL *lf; 46 | EFI_LIFE_CYCLE_STATE state; 47 | 48 | ret = LibLocateProtocol(&guid, (void **)&lf); 49 | if (EFI_ERROR(ret)) { 50 | debug(L"Life Cycle Protocol is not supported"); 51 | return ret; 52 | } 53 | 54 | if (lf->Revision != EFI_LIFE_CYCLE_STATE_PROTOCOL_REVISION1) 55 | return EFI_INCOMPATIBLE_VERSION; 56 | 57 | ret = uefi_call_wrapper(lf->GetLifeCycleState, 2, lf, &state); 58 | if (EFI_ERROR(ret)) { 59 | efi_perror(ret, L"Failed to get life cycle state"); 60 | return ret; 61 | } 62 | 63 | *enduser = state == LC_STATE_ENDUSER; 64 | 65 | return EFI_SUCCESS; 66 | } 67 | -------------------------------------------------------------------------------- /libkernelflinger/protocol/AcpiTableProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _ACPI_TABLE_PROTOCOL_H_ 32 | #define _ACPI_TABLE_PROTOCOL_H_ 33 | 34 | #define EFI_ACPI_TABLE_PROTOCOL_GUID \ 35 | {0xffe06bdd, 0x6107, 0x46a6, {0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c}} 36 | 37 | typedef struct _EFI_ACPI_TABLE_PROTOCOL EFI_ACPI_TABLE_PROTOCOL; 38 | 39 | typedef 40 | EFI_STATUS 41 | (EFIAPI *EFI_ACPI_TABLE_INSTALL_ACPI_TABLE) ( 42 | IN EFI_ACPI_TABLE_PROTOCOL *This, 43 | IN VOID *AcpiTableBuffer, 44 | IN UINTN AcpiTableBufferSize, 45 | OUT UINTN *TableKey 46 | ); 47 | 48 | typedef 49 | EFI_STATUS 50 | (EFIAPI *EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE) ( 51 | IN EFI_ACPI_TABLE_PROTOCOL *This, 52 | IN UINTN TableKey 53 | ); 54 | 55 | struct _EFI_ACPI_TABLE_PROTOCOL { 56 | EFI_ACPI_TABLE_INSTALL_ACPI_TABLE InstallAcpiTable; 57 | EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE UninstallAcpiTable; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /libkernelflinger/protocol/DevicePath.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2004, Intel Corporation. All rights reserved.
4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | Module Name: 13 | 14 | DevicePath.h 15 | 16 | Abstract: 17 | 18 | The device path protocol as defined in EFI 1.0. 19 | 20 | The device path represents a programatic path to a device. It's the view 21 | from a software point of view. It also must persist from boot to boot, so 22 | it can not contain things like PCI bus numbers that change from boot to boot. 23 | 24 | 25 | --*/ 26 | 27 | #ifndef _DEVICE_PATH_H_ 28 | #define _DEVICE_PATH_H_ 29 | 30 | // 31 | // Device Path protocol 32 | // 33 | #define EFI_DEVICE_PATH_PROTOCOL_GUID \ 34 | { \ 35 | 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ 36 | } 37 | 38 | #pragma pack(1) 39 | 40 | typedef EFI_DEVICE_PATH EFI_DEVICE_PATH_PROTOCOL; 41 | 42 | #pragma pack() 43 | 44 | #define EFI_END_ENTIRE_DEVICE_PATH 0xff 45 | #define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff 46 | #define EFI_END_INSTANCE_DEVICE_PATH 0x01 47 | #define EFI_END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL)) 48 | 49 | #define EfiDevicePathNodeLength(a) (((a)->Length[0]) | ((a)->Length[1] << 8)) 50 | #define EfiNextDevicePathNode(a) ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a))) 51 | 52 | #define EfiDevicePathType(a) (((a)->Type) & 0x7f) 53 | #define EfiIsDevicePathEndType(a) (EfiDevicePathType (a) == 0x7f) 54 | 55 | #define EfiIsDevicePathEndSubType(a) ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE) 56 | #define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH) 57 | 58 | #define EfiIsDevicePathEnd(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a)) 59 | #define EfiIsDevicePathEndInstance(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a)) 60 | 61 | extern EFI_GUID gEfiDevicePathProtocolGuid; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /libkernelflinger/protocol/LifeCycleProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _LIFE_CYCLE_PROTOCOL_H_ 32 | #define _LIFE_CYCLE_PROTOCOL_H_ 33 | 34 | #include 35 | 36 | #define EFI_LIFE_CYCLE_STATE_PROTOCOL_GUID \ 37 | {0xf3c1138e, 0xcd89, 0x4e20,{0x9e, 0x68, 0x25, 0xa6, 0x76, 0x95, 0xa5, 0x6a}} 38 | 39 | #define EFI_LIFE_CYCLE_STATE_PROTOCOL_REVISION1 0x00000001 40 | 41 | typedef enum life_cycle_state { 42 | LC_STATE_MANUFACTURING, 43 | LC_STATE_ENDUSER, 44 | LC_STATE_RND, 45 | LC_STATE_CARE 46 | } EFI_LIFE_CYCLE_STATE; 47 | 48 | typedef struct _EFI_LIFE_CYCLE_STATE_PROTOCOL EFI_LIFE_CYCLE_STATE_PROTOCOL; 49 | 50 | typedef 51 | EFI_STATUS 52 | (EFIAPI *EFI_GET_LIFE_CYCLE_STATE) ( 53 | IN EFI_LIFE_CYCLE_STATE_PROTOCOL *This, 54 | OUT EFI_LIFE_CYCLE_STATE *LifeCycleState 55 | ); 56 | 57 | struct _EFI_LIFE_CYCLE_STATE_PROTOCOL { 58 | UINT32 Revision; 59 | EFI_GET_LIFE_CYCLE_STATE GetLifeCycleState; 60 | } __attribute__((packed)); 61 | 62 | #endif /* _LIFE_CYCLE_PROTOCOL_H_ */ 63 | -------------------------------------------------------------------------------- /libkernelflinger/protocol/tco_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | */ 30 | 31 | #ifndef _TCO_PROTOCOL_H_ 32 | #define _TCO_PROTOCOL_H_ 33 | 34 | #include 35 | 36 | #define EFI_TCO_RESET_PROTOCOL_GUID \ 37 | {0xa6a79162, 0xe325, 0x4c30,{0xbc, 0xc3, 0x59, 0x37, 0x30, 0x64, 0xef, 0xb3}} 38 | 39 | typedef struct _EFI_TCO_RESET_PROTOCOL EFI_TCO_RESET_PROTOCOL; 40 | 41 | typedef 42 | EFI_STATUS 43 | (EFIAPI *EFI_TCO_RESET_PROTOCOL_ENABLE_WATCHDOG) ( 44 | IN OUT UINT32 *RcrbGcsValue 45 | ); 46 | 47 | typedef 48 | EFI_STATUS 49 | (EFIAPI *EFI_TCO_RESET_PROTOCOL_DISABLE_WATCHDOG) ( 50 | IN UINT32 RcrbGcsValue 51 | ); 52 | 53 | struct _EFI_TCO_RESET_PROTOCOL { 54 | EFI_TCO_RESET_PROTOCOL_ENABLE_WATCHDOG EnableTcoReset; 55 | EFI_TCO_RESET_PROTOCOL_DISABLE_WATCHDOG DisableTcoReset; 56 | }; 57 | 58 | #endif /* _TCO_PROTOCOL_H_ */ 59 | -------------------------------------------------------------------------------- /libkernelflinger/res/fonts/12x22_font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/fonts/12x22_font.png -------------------------------------------------------------------------------- /libkernelflinger/res/fonts/18x32_font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/fonts/18x32_font.png -------------------------------------------------------------------------------- /libkernelflinger/res/fonts/README: -------------------------------------------------------------------------------- 1 | The images in this directory were generated using the font 2 | Inconsolata, which is released under the OFL license and was obtained 3 | from: 4 | 5 | https://code.google.com/p/googlefontdirectory/source/browse/ofl/inconsolata/ 6 | 7 | -------------------------------------------------------------------------------- /libkernelflinger/res/images/bootloader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/bootloader.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/crash_event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/crash_event.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/crashmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/crashmode.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/droid_operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/droid_operation.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/empty_battery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/empty_battery.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/low_battery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/low_battery.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/power_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/power_off.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/reboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/reboot.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/recoverymode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/recoverymode.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/restartbootloader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/restartbootloader.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/splash_intel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/splash_intel.png -------------------------------------------------------------------------------- /libkernelflinger/res/images/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libkernelflinger/res/images/start.png -------------------------------------------------------------------------------- /libkernelflinger/sdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Jérémy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * This file defines bootlogic data structures, try to keep it without 32 | * any external definitions in order to ease export of it. 33 | */ 34 | 35 | #ifndef _SDIO_H_ 36 | #define _SDIO_H_ 37 | 38 | #include 39 | #include "protocol/SdHostIo.h" 40 | #include "protocol/CardInfo.h" 41 | 42 | #define SDIO_DFLT_TIMEOUT 3000 43 | 44 | EFI_STATUS sdio_get(EFI_DEVICE_PATH *p, 45 | EFI_HANDLE *handle, 46 | EFI_SD_HOST_IO_PROTOCOL **sdio); 47 | EFI_STATUS sdio_get_card_info(EFI_SD_HOST_IO_PROTOCOL *sdio, 48 | EFI_HANDLE handle, 49 | CARD_TYPE *type, 50 | UINT16 *address); 51 | EFI_STATUS sdio_erase(EFI_SD_HOST_IO_PROTOCOL *sdio, EFI_BLOCK_IO *bio, 52 | UINT64 start, UINT64 end, UINT16 card_address, 53 | UINTN erase_grp_size, UINTN erase_timeout, 54 | BOOLEAN emmc); 55 | 56 | #endif /* _SDIO_H_ */ 57 | -------------------------------------------------------------------------------- /libkernelflinger/security_efi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Ming Tan 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | #ifndef _SECURITY_EFI_H_ 33 | #define _SECURITY_EFI_H_ 34 | 35 | #include 36 | #include 37 | 38 | #define SECURITY_EFI_TRUSTY_SEED_LEN 64 39 | 40 | EFI_STATUS get_seed(OUT VOID *seed); 41 | 42 | EFI_STATUS stop_bls_proto(void); 43 | 44 | #endif // _SECURITY_EFI_H_ 45 | -------------------------------------------------------------------------------- /libkernelflinger/security_vb2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Genshen Li 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | #include "security.h" 33 | #include "security_vb2.h" 34 | 35 | EFI_STATUS rot_pub_key_sha256(IN VBDATA *vb_data, 36 | OUT UINT8 **hash_p) 37 | { 38 | EFI_STATUS ret = EFI_SUCCESS; 39 | const uint8_t *vbmeta_pub_key; 40 | UINTN vbmeta_pub_key_len; 41 | 42 | if (vb_data && hash_p) { 43 | ret = avb_vbmeta_image_verify(vb_data->vbmeta_images[0].vbmeta_data, 44 | vb_data->vbmeta_images[0].vbmeta_size, 45 | &vbmeta_pub_key, 46 | &vbmeta_pub_key_len); 47 | 48 | if (EFI_ERROR(ret)) { 49 | efi_perror(ret, L"Failed to get the vbmeta_pub_key"); 50 | return ret; 51 | } 52 | 53 | ret = raw_pub_key_sha256(vbmeta_pub_key, vbmeta_pub_key_len, hash_p); 54 | if (EFI_ERROR(ret)) 55 | efi_perror(ret, L"Failed to compute key hash"); 56 | } else 57 | ret = EFI_INVALID_PARAMETER; 58 | 59 | return ret; 60 | } 61 | -------------------------------------------------------------------------------- /libkernelflinger/smbios.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | #include "smbios.h" 37 | 38 | char *SMBIOS_UNDEFINED = "N/A"; 39 | 40 | #define offsetof(st, m) __builtin_offsetof(st, m) 41 | /* Allow cast to pointer from integer of different size. */ 42 | #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" 43 | 44 | char *smbios_get_string(UINT8 type, UINT8 offset) 45 | { 46 | SMBIOS_STRUCTURE_TABLE *table; 47 | EFI_STATUS ret; 48 | SMBIOS_STRUCTURE_POINTER sm_struct; 49 | UINT8 i; 50 | CHAR8 *str; 51 | 52 | ret = LibGetSystemConfigurationTable(&SMBIOSTableGuid, (VOID**)&table); 53 | if (EFI_ERROR(ret)) 54 | return SMBIOS_UNDEFINED; 55 | 56 | sm_struct.Hdr = (SMBIOS_HEADER *)table->TableAddress; 57 | for (i = 0; i < table->TableLength; i++) { 58 | if (sm_struct.Hdr->Type == type) 59 | break; 60 | LibGetSmbiosString(&sm_struct, -1); 61 | } 62 | 63 | if (i == table->TableLength) 64 | return SMBIOS_UNDEFINED; 65 | 66 | str = LibGetSmbiosString(&sm_struct, sm_struct.Raw[offset]); 67 | 68 | return str ? (char *)str : SMBIOS_UNDEFINED; 69 | } 70 | -------------------------------------------------------------------------------- /libkernelflinger/tools/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | ################################ 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := png2c.c 7 | LOCAL_STATIC_LIBRARIES := libpng libz 8 | LOCAL_C_INCLUDES += external/libpng 9 | LOCAL_CFLAGS += -O2 -g -Wall -Werror -pedantic 10 | LOCAL_MODULE := png2c 11 | 12 | include $(BUILD_HOST_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /libkernelflinger/tools/gen_fonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | header="/* This is an autogenerated header file. Please use gen_fonts.sh */\n\n" 4 | images=($1/*.png) 5 | output=$2 6 | 7 | echo -e "$header" > $output 8 | 9 | for file in ${images[*]} 10 | do 11 | name=$(basename ${file%_font.png}) 12 | png2c -i $file -o - -f GRAY -p "__"$name >> $output 13 | done 14 | 15 | echo -en "\nui_font_t ui_fonts[] = {" >> $output 16 | prefix="" 17 | fonts_nb=0 18 | for file in ${images[*]} 19 | do 20 | name=$(basename ${file%_font.png}) 21 | 22 | if [ $file != ${images[0]} ] 23 | then 24 | prefix="," 25 | fi 26 | 27 | cwidth=$(echo $name | cut -d 'x' -f 1) 28 | cheight=$(echo $name | cut -d 'x' -f 2 | cut -d '_' -f 1) 29 | width=$(file $file | cut -d ' ' -f 5) 30 | height=$(file $file | cut -d ' ' -f 7 | sed 's/,//') 31 | echo -en "$prefix\n\t{ \"$name\", $width, $height, $cwidth, $cheight, __"$name"_dat }" >> $output 32 | fonts_nb=$((fonts_nb+1)) 33 | done 34 | echo -e "\n};" >> $output 35 | echo -e "UINTN ui_fonts_nb = $fonts_nb;" >> $output 36 | -------------------------------------------------------------------------------- /libkernelflinger/trusty_sbl.c: -------------------------------------------------------------------------------- 1 | trusty_abl.c -------------------------------------------------------------------------------- /libkernelflinger/ui_color.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_BLACK = { 0, 0, 0, 0 }; 40 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_WHITE = { 255, 255, 255, 0 }; 41 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_LIGHTGRAY = { 127, 127, 127, 0 }; 42 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_LIGHTRED = { 0, 0, 127, 0 }; 43 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_YELLOW = { 0, 255, 255, 0 }; 44 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_RED = { 0, 0, 255, 0 }; 45 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_GREEN = { 0, 255, 0, 0 }; 46 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_HIGHLIGHT = { 157, 106, 0, 0 }; 47 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL COLOR_ORANGE = { 0, 157, 255, 0 }; 48 | -------------------------------------------------------------------------------- /libkernelflinger/ui_font.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Authors: Jeremy Compostella 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer 17 | * in the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | * OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #include 36 | #include 37 | 38 | #include "res/font_res.h" 39 | 40 | #define DEFAULT_FONT_NAME "18x32" 41 | 42 | ui_font_t *ui_font_get_default(void) 43 | { 44 | static ui_font_t *default_font = NULL; 45 | 46 | if (!default_font) 47 | default_font = ui_font_get(DEFAULT_FONT_NAME); 48 | 49 | if (!default_font) 50 | error(L"Unable to get %a default font", DEFAULT_FONT_NAME); 51 | 52 | return default_font; 53 | } 54 | 55 | ui_font_t *ui_font_get(char *name) 56 | { 57 | UINTN i; 58 | 59 | for (i = 0; i < ARRAY_SIZE(ui_fonts); i++) 60 | if (!strcmp((CHAR8 *)ui_fonts[i].name, (CHAR8 *)name)) 61 | return &ui_fonts[i]; 62 | 63 | return NULL; 64 | } 65 | -------------------------------------------------------------------------------- /libqltipc/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(all-subdir-makefiles) 3 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libqltipc-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | 8 | ifeq ($(TARGET_UEFI_ARCH),x86_64) 9 | LOCAL_CFLAGS += -DARCH_X86_64=1 10 | else 11 | LOCAL_CFLAGS += -DARCH_X86_32=1 12 | endif 13 | 14 | LOCAL_STATIC_LIBRARIES := \ 15 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 16 | libkernelflinger-$(TARGET_BUILD_VARIANT) 17 | 18 | LOCAL_C_INCLUDES := $(KERNELFLINGER_LOCAL_PATH) \ 19 | $(LOCAL_PATH)/include \ 20 | $(LOCAL_PATH)/arch/x86 \ 21 | $(LOCAL_PATH)/../interface/include \ 22 | $(KERNELFLINGER_LOCAL_PATH)/libsslsupport \ 23 | $(KERNELFLINGER_LOCAL_PATH)/avb 24 | 25 | LOCAL_SRC_FILES := \ 26 | ipc.c \ 27 | ipc_dev.c \ 28 | libtipc.c \ 29 | avb.c \ 30 | trusty_dev_common.c \ 31 | arch/x86/trusty_dev.c \ 32 | arch/x86/trusty_mem.c \ 33 | arch/x86/sysdeps_osloader.c \ 34 | util.c \ 35 | keymaster.c \ 36 | keymaster_serializable.c \ 37 | 38 | ifeq ($(KERNELFLINGER_TRUSTY_PLATFORM),vsbl) 39 | LOCAL_CFLAGS += -DHYPERVISOR_ACRN 40 | endif 41 | 42 | include $(BUILD_EFI_STATIC_LIBRARY) 43 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016, The Android Open Source Project 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/README.md: -------------------------------------------------------------------------------- 1 | # Queueless Trusty IPC 2 | 3 | ql-tipc is a portable client library that implements Trusty queueless IPC. 4 | It is intended to enable Trusty IPC in bootloader environments. 5 | 6 | ## Code organization 7 | 8 | ### IPC components 9 | 10 | - libtipc - Functions to be called by library user 11 | - ipc - IPC library 12 | - ipc_dev - Helper functions for sending requests to the secure OS 13 | 14 | ### Misc 15 | 16 | - examples/ - Implementations of bootloader-specific code. 17 | - arch/$ARCH/ - Architecture dependent implementation of Trusty device 18 | (see trusty_dev.h). Implements SMCs on ARM for example. 19 | 20 | ## Portability Notes 21 | 22 | The suggested approach to porting ql-tipc is to copy all header and C files 23 | into the bootloader and integrate as needed. RPMB storage operations and 24 | functions defined in trusty/sysdeps.h require system dependent implementations. 25 | 26 | If the TIPC_ENABLE_DEBUG preprocessor symbol is set, the code will include 27 | debug information and run-time checks. Production builds should not use this. 28 | 29 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/arch/x86/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer 13 | * in the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 | * OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef TRUSTY_QL_TIPC_COMPILER_H_ 31 | #define TRUSTY_QL_TIPC_COMPILER_H_ 32 | 33 | #pragma GCC diagnostic ignored "-Wunused-parameter" 34 | 35 | #ifndef offsetof 36 | #if __GNUC__ > 3 37 | #define offsetof(type, member) __builtin_offsetof(type, member) 38 | #else 39 | #define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 )) 40 | #endif 41 | #endif 42 | 43 | #define TRUSTY_QL_TIPC_MAX_BUFFER_LEN PAGE_SIZE 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/include/trusty/libtipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | #ifndef TRUSTY_LIBTIPC_H_ 25 | #define TRUSTY_LIBTIPC_H_ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | /* 32 | * Initialize TIPC library 33 | */ 34 | int trusty_ipc_init(void); 35 | /* 36 | * Shutdown TIPC library 37 | */ 38 | void trusty_ipc_shutdown(void); 39 | 40 | #endif /* TRUSTY_LIBTIPC_H_ */ 41 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/include/trusty/sm_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef QL_TIPC_SM_ERR_H_ 26 | #define QL_TIPC_SM_ERR_H_ 27 | 28 | /* Errors from the secure monitor */ 29 | 30 | /* Unknown SMC (defined by ARM DEN 0028A(0.9.0) */ 31 | #define SM_ERR_UNDEFINED_SMC 0xFFFFFFFF 32 | #define SM_ERR_INVALID_PARAMETERS -2 33 | /* Got interrupted. Call back with restart SMC */ 34 | #define SM_ERR_INTERRUPTED -3 35 | /* Got an restart SMC when we didn't expect it */ 36 | #define SM_ERR_UNEXPECTED_RESTART -4 37 | /* Temporarily busy. Call back with original args */ 38 | #define SM_ERR_BUSY -5 39 | /* Got a trusted_service SMC when a restart SMC is required */ 40 | #define SM_ERR_INTERLEAVED_SMC -6 41 | /* Unknown error */ 42 | #define SM_ERR_INTERNAL_FAILURE -7 43 | #define SM_ERR_NOT_SUPPORTED -8 44 | /* SMC call not allowed */ 45 | #define SM_ERR_NOT_ALLOWED -9 46 | #define SM_ERR_END_OF_INPUT -10 47 | /* Secure OS crashed */ 48 | #define SM_ERR_PANIC -11 49 | /* Got interrupted by FIQ. Call back with SMC_SC_RESTART_FIQ on same CPU */ 50 | #define SM_ERR_FIQ_INTERRUPTED -12 51 | /* SMC call waiting for another CPU */ 52 | #define SM_ERR_CPU_IDLE -13 53 | /* Got interrupted. Call back with new SMC_SC_NOP */ 54 | #define SM_ERR_NOP_INTERRUPTED -14 55 | /* Cpu idle after SMC_SC_NOP (not an error) */ 56 | #define SM_ERR_NOP_DONE -15 57 | 58 | #endif /* QL_TIPC_SM_ERR_H_ */ 59 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/include/trusty/smc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2016 The Android Open Source Project 4 | * 5 | * Permission is hereby granted, free of charge, to any person 6 | * obtaining a copy of this software and associated documentation 7 | * files (the "Software"), to deal in the Software without 8 | * restriction, including without limitation the rights to use, copy, 9 | * modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | /* 27 | * Execute SMC call into trusty or el3 28 | */ 29 | 30 | struct smc_ret8 { 31 | unsigned long r0; 32 | unsigned long r1; 33 | unsigned long r2; 34 | unsigned long r3; 35 | unsigned long r4; 36 | unsigned long r5; 37 | unsigned long r6; 38 | unsigned long r7; 39 | }; 40 | 41 | struct smc_ret8 smc8(unsigned long r0, 42 | unsigned long r1, 43 | unsigned long r2, 44 | unsigned long r3, 45 | unsigned long r4, 46 | unsigned long r5, 47 | unsigned long r6, 48 | unsigned long r7); 49 | 50 | static inline unsigned long smc(unsigned long r0, 51 | unsigned long r1, 52 | unsigned long r2, 53 | unsigned long r3) { 54 | return smc8(r0, r1, r2, r3, 0, 0, 0, 0).r0; 55 | } 56 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/include/trusty/trusty_mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef TRUSTY_TRUSTY_MEM_H_ 26 | #define TRUSTY_TRUSTY_MEM_H_ 27 | 28 | #include 29 | 30 | /* 31 | * Encodes the memory attributes of @va into @inf 32 | * 33 | * @inf: ns_mem_page_info allocated by the caller 34 | * @va: virtual addresses to retrieve attributes for 35 | * 36 | * Returns 0 on success and -1 on failure 37 | */ 38 | 39 | int trusty_encode_page_info(struct ns_mem_page_info* inf, void* va); 40 | 41 | #endif /* TRUSTY_TRUSTY_MEM_H_ */ 42 | -------------------------------------------------------------------------------- /libqltipc/ql-tipc/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include 26 | 27 | const char* trusty_basename(const char* str) { 28 | int64_t n; 29 | size_t len; 30 | 31 | len = trusty_strlen(str); 32 | if (len >= 2) { 33 | for (n = len - 2; n >= 0; n--) { 34 | if (str[n] == '/') { 35 | return str + n + 1; 36 | } 37 | } 38 | } 39 | return str; 40 | } 41 | -------------------------------------------------------------------------------- /libsslsupport/borningssl/sys/syscall.h: -------------------------------------------------------------------------------- 1 | /* 2 | function needed for compiling borningssl on Android O 3 | */ 4 | #pragma once 5 | long syscall(long __number, ...){return 0;}; 6 | -------------------------------------------------------------------------------- /libsslsupport/errno.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/inttypes.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/limits.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/openssl_support.h: -------------------------------------------------------------------------------- 1 | #ifndef _OPENSSL_SUPPORT_H_ 2 | #define _OPENSSL_SUPPORT_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef UINTN size_t; 8 | #define DEFINED_SIZE_T 9 | 10 | typedef long time_t; 11 | typedef VOID *FILE; 12 | 13 | #endif /* _OPENSSL_SUPPORT_H_ */ 14 | -------------------------------------------------------------------------------- /libsslsupport/stdarg.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/stddef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/libsslsupport/stddef.h -------------------------------------------------------------------------------- /libsslsupport/stdio.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/stdlib.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/sys/types.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libsslsupport/time.h: -------------------------------------------------------------------------------- 1 | #include "openssl_support.h" 2 | -------------------------------------------------------------------------------- /libtransport/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libtransport-$(TARGET_BUILD_VARIANT) 6 | LOCAL_CFLAGS := $(KERNELFLINGER_CFLAGS) 7 | LOCAL_STATIC_LIBRARIES := \ 8 | $(KERNELFLINGER_STATIC_LIBRARIES) \ 9 | libkernelflinger-$(TARGET_BUILD_VARIANT) 10 | 11 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libtransport 12 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libtransport 13 | LOCAL_SRC_FILES := \ 14 | transport.c 15 | 16 | include $(BUILD_EFI_STATIC_LIBRARY) 17 | -------------------------------------------------------------------------------- /prebuilt/board/APL_UP2/fastboot.elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/kernelflinger/ea3aad38e8f5019476e51de18d65ce0d6d433bf3/prebuilt/board/APL_UP2/fastboot.elf -------------------------------------------------------------------------------- /unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * All rights reserved. 4 | * 5 | * Author: Andrew Boie 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | */ 32 | 33 | #ifndef UNITTEST_H 34 | #define UNITTEST_H 35 | 36 | VOID unittest_main(CHAR16 *testname); 37 | 38 | #endif 39 | --------------------------------------------------------------------------------