From f648e29d050cab362cc660c1a5c5109182028768 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Mon, 23 Jan 2017 15:30:22 +0300 Subject: DcsInfo added DcsBoot is driver now (to support DriverOrder list) --- Library/CommonLib/CommonLib.inf | 7 ++++++ Library/CommonLib/EfiBluetooth.c | 50 ++++++++++++++++++++++++++++++++++++++++ Library/CommonLib/EfiFile.c | 19 +++++++++++++++ Library/CommonLib/EfiTpm.c | 34 +++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 Library/CommonLib/EfiBluetooth.c create mode 100644 Library/CommonLib/EfiTpm.c (limited to 'Library/CommonLib') diff --git a/Library/CommonLib/CommonLib.inf b/Library/CommonLib/CommonLib.inf index 2c379b8..b5758f5 100644 --- a/Library/CommonLib/CommonLib.inf +++ b/Library/CommonLib/CommonLib.inf @@ -36,6 +36,8 @@ EfiExec.c EfiUsb.c EfiTouch.c + EfiBluetooth.c + EfiTpm.c [Sources.IA32] IA32/EfiCpuHalt.asm @@ -63,3 +65,8 @@ gEfiAbsolutePointerProtocolGuid gEfiGraphicsOutputProtocolGuid gEfiSimpleTextOutProtocolGuid + gEfiBluetoothIoProtocolGuid + gEfiBluetoothHcProtocolGuid + gEfiBluetoothConfigProtocolGuid + gEfiTcgProtocolGuid + gEfiTcg2ProtocolGuid diff --git a/Library/CommonLib/EfiBluetooth.c b/Library/CommonLib/EfiBluetooth.c new file mode 100644 index 0000000..13b03e3 --- /dev/null +++ b/Library/CommonLib/EfiBluetooth.c @@ -0,0 +1,50 @@ +/** @file +EFI BLUETOOTH helpers + +Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov +Copyright (c) 2016. VeraCrypt, Mounir IDRASSI + +This program and the accompanying materials are licensed and made available +under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0). + +The full text of the license may be found at +https://opensource.org/licenses/LGPL-3.0 +**/ + +#include +#include +#include +#include +#include +#include +#include + +EFI_HANDLE* gBluetoothIoHandles = NULL; +UINTN gBluetoothIoCount = 0; + +EFI_HANDLE* gBluetoothHcHandles = NULL; +UINTN gBluetoothHcCount = 0; + +EFI_HANDLE* gBluetoothConfigHandles = NULL; +UINTN gBluetoothConfigCount = 0; + +EFI_STATUS +InitBluetooth() { + EFI_STATUS res; + res = EfiGetHandles(ByProtocol, &gEfiBluetoothIoProtocolGuid, 0, &gBluetoothIoHandles, &gBluetoothIoCount); + res = EfiGetHandles(ByProtocol, &gEfiBluetoothHcProtocolGuid, 0, &gBluetoothHcHandles, &gBluetoothHcCount); + res = EfiGetHandles(ByProtocol, &gEfiBluetoothConfigProtocolGuid, 0, &gBluetoothConfigHandles, &gBluetoothConfigCount); + return res; +} + +EFI_STATUS +BluetoothGetIO( + IN EFI_HANDLE Handle, + OUT EFI_BLUETOOTH_IO_PROTOCOL** io + ) { + if (!io) { + return EFI_INVALID_PARAMETER; + } + return gBS->HandleProtocol(Handle, &gEfiBluetoothIoProtocolGuid, (VOID**)io); +} + diff --git a/Library/CommonLib/EfiFile.c b/Library/CommonLib/EfiFile.c index b1e2076..fdc999c 100644 --- a/Library/CommonLib/EfiFile.c +++ b/Library/CommonLib/EfiFile.c @@ -18,6 +18,7 @@ https://opensource.org/licenses/LGPL-3.0 #include #include #include +#include ////////////////////////////////////////////////////////////////////////// // EFI file @@ -151,6 +152,24 @@ FileWrite( return res; } +CHAR8 gFileAsciiPrintBuffer[1024]; + +UINTN +FileAsciiPrint( + IN EFI_FILE *f, + IN CONST CHAR8 *format, + ... + ) { + VA_LIST marker; + UINTN len; + if (f == NULL) return 0; + VA_START(marker, format); + len = AsciiVSPrint((CHAR8*)gFileAsciiPrintBuffer, sizeof(gFileAsciiPrintBuffer), format, marker); + VA_END(marker); + f->Write(f, &len, gFileAsciiPrintBuffer); + return len; +} + EFI_STATUS FileGetInfo( IN EFI_FILE* f, diff --git a/Library/CommonLib/EfiTpm.c b/Library/CommonLib/EfiTpm.c new file mode 100644 index 0000000..9b236c5 --- /dev/null +++ b/Library/CommonLib/EfiTpm.c @@ -0,0 +1,34 @@ +/** @file +EFI TCG/TPM helpers + +Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov +Copyright (c) 2016. VeraCrypt, Mounir IDRASSI + +This program and the accompanying materials are licensed and made available +under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0). + +The full text of the license may be found at +https://opensource.org/licenses/LGPL-3.0 +**/ + +#include +#include +#include +#include +#include +#include + +EFI_HANDLE* gTcgHandles = NULL; +UINTN gTcgCount = 0; + +EFI_HANDLE* gTcg2Handles = NULL; +UINTN gTcg2Count = 0; + +EFI_STATUS +InitTcg() { + EFI_STATUS res; + res = EfiGetHandles(ByProtocol, &gEfiTcgProtocolGuid, 0, &gTcgHandles, &gTcgCount); + res = EfiGetHandles(ByProtocol, &gEfiTcg2ProtocolGuid, 0, &gTcg2Handles, &gTcg2Count); + return res; +} + -- cgit v1.2.3