GithubHelp home page GithubHelp logo

visualuefi's Introduction

Synopsis

VisualUEFI is

  • A Solution and set of Visual Studio Project Files to allow building the official EDK-II (including OpenSSL 1.1.0e) without the use of inf files, python and 50 other build tools, a custom dependency tracker and build system, and twenty other custom pieces of code. The EDK-II and OpenSSL are present as submodules, directly from the official TianoCore Tree, and no changes are done to them.

  • A Solution and couple of Visual Studio Project Files to show four UEFI sample components: An UEFI Application and associated UEFI Boot Driver, the EDK-II Sample FtdiUsbSerialDxe Driver, and the EDK-II Sample Cryptest Application which uses OpenSSL 1.1.0e. The code is 100% EDK-II compatible, but built with VisualUEFI instead.

  • A working and FAST copy of QEMU64 2.10 for Windows, with a fairly recent UEFI 2.6 OVMF Secure Boot ROM which includes SMM support and an actual protected flash for enrolling PK/KEK/DB/DBX keys. These will updated on an ongoing basis as needed. This is integrated with the Visual Studio Sample Solution so that pressing F5 will spin up the instance for testing.

If you would like to know more about my research or work, I invite you check out my blog at http://www.alex-ionescu.com as well as my training & consulting company, Winsider Seminars & Solutions Inc., at http://www.windows-internals.com.

Code Example

Here is a very simple example of a UEFI application communicating with a UEFI driver protocol. This sample is part of VisualUefi.

//
// Basic UEFI Libraries
//
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>

//
// Boot and Runtime Services
//
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>

//
// Custom Driver Protocol
//
#include "../UefiDriver/drvproto.h"
EFI_GUID gEfiSampleDriverProtocolGuid = EFI_SAMPLE_DRIVER_PROTOCOL_GUID;

//
// We run on any UEFI Specification
//
extern CONST UINT32 _gUefiDriverRevision = 0;

//
// Our name
//
CHAR8 *gEfiCallerBaseName = "UefiApplication";

EFI_STATUS
EFIAPI
UefiUnload (
    IN EFI_HANDLE ImageHandle
    )
{
    //
    // This code should be compiled out and never called
    //
    ASSERT(FALSE);
}

EFI_STATUS
EFIAPI
UefiMain (
    IN EFI_HANDLE ImageHandle,
    IN EFI_SYSTEM_TABLE* SystemTable
    )
{
    EFI_STATUS efiStatus;
    SHELL_FILE_HANDLE fileHandle;
    UINT8 buffer[4];
    UINTN readSize;
    EFI_SAMPLE_DRIVER_PROTOCOL* sampleProtocol;

    // 
    // Print stuff out 
    // 
    fileHandle = NULL;
    Print(L"Hello World! My handle is %lx and System Table is at %p\n",
          ImageHandle, SystemTable);

    //
    // Initialize the shell library
    //
    efiStatus = ShellInitialize();
    if (EFI_ERROR(efiStatus))
    {
        Print(L"Failed to initialize shell: %lx\n", efiStatus);
        goto Exit;
    }

    //
    // Open ourselves
    //
    efiStatus = ShellOpenFileByName(L"fs1:\\UefiApplication.efi",
                                    &fileHandle,
                                    EFI_FILE_MODE_READ,
                                    0);
    if (EFI_ERROR(efiStatus))
    {
        Print(L"Failed to open ourselves: %lx\n", efiStatus);
        fileHandle = NULL;
        goto Exit;
    }

    //
    // Read 4 bytes at the top (MZ header)
    //
    readSize = sizeof(buffer);
    efiStatus = ShellReadFile(fileHandle, &readSize, &buffer);
    if (EFI_ERROR(efiStatus))
    {
        Print(L"Failed to read ourselves: %lx\n", efiStatus);
        goto Exit;
    }

    //
    // Print it
    //
    Print(L"Data: %lx\n", *(UINT32*)buffer);

    // 
    // Check if the sample driver is loaded 
    // 
    efiStatus = gBS->LocateProtocol(&gEfiSampleDriverProtocolGuid, NULL, &sampleProtocol);
    if (EFI_ERROR(efiStatus))
    {
        Print(L"Failed to locate our driver: %lx\n", efiStatus);
        goto Exit;
    }

    // 
    // Print the value and exit 
    // 
    Print(L"Sample driver is loaded: %lx\n", sampleProtocol->SampleValue);

Exit:
    //
    // Close our file handle
    //
    if (fileHandle != NULL)
    {
        ShellCloseFile(&fileHandle);
    }

    //
    // Sample complete!
    //
    return efiStatus;
}

Motivation

Although EDK-II's build subsystem supports Visual Studio, it doesn't work with "in-IDE" building. Instead, special .inf files and other templates are used to define projects, and a custom build composed of multiple 3rd party tools must be ran -- including dependencies on Python, Ruby, and Perl. For developers already familiar with Visual Studio's project files/MSBUILD, as well as the IDE it offers, this can be cumbersome and limiting, slowing down the ability to quickly jump into UEFI development. Additionally, the EDK-II's default "test" environment is to build a Windows "NT32" layer around your application and running it as a command line executable. While this might work for very simple applications, it doesn't reliably provide an environment for testing DXE drivers, runtime services, and more.

VisualUefi aims to bridge these gaps by compiling 100% unmodified EDK-II libraries with a proper Visual Studio build environment, adding some VisualUefi-specific glue to support building within Visual Studio without 3rd party tools, and includes the latest QEMU and OVMF w/ SecureBoot packages for bare-metal testing of UEFI, without relying on Windows emulation.

Installation

At first install NASM (https://www.nasm.us/) and check, that environment variable NASM_PREFIX is correctly set to NASM installation path. No other 3rd party tools are needed.

Than you should be able to open the EDK-II.SLN file and build without any issues in either Visual Studio 2015 or 2017. WDK is not needed.

Once the EDK-II libraries are built, you should be able to open the SAMPLES.SLN file and build the samples, which will create UefiApplication.efi, UefiDriver.efi, Cryptest.efi, and FtdiUsbSerialDxe.efi

Documentation

Please refer to EDK-II/TianoCore for all documentation/help regarding EDK-II.

Tests

You can press F5 (Run/Debug) from within the Sample Solution, which should spin up the QEMU instance with 512MB of RAM, and your release directory as a virtual file system accessible through fs1:

You can then try loading the driver as follows:

* load fs1:\UefiDriver.efi

You can verify its presence by using either of these commands:

* drivers (Should display "Sample Driver")
* devtree (Should show a few "Sample Device" entries)

You can also launch the sample application, which should find the driver:

* fs1:\UefiApplication.efi

Contributors

Please use the GitHub issue tracker to submit any bugs/requests/etc.

For other feedback, you can reach me on Twitter at @aionescu

License

  • For the "samples" and "edk-ii" directory, the following license applies:

      Copyright (c) 2015-2017, Alex Ionescu. All rights reserved.
      This program and the accompanying materials are licensed and made available under
      the terms and conditions of the BSD License which accompanies this distribution. 
      The full text of the license may be found at
      http://opensource.org/licenses/bsd-license.php
    
  • For the "debugger" directory, the following license applies:

      The following points clarify the QEMU license:
    
      1) QEMU as a whole is released under the GNU General Public License,
      version 2.
    
      2) Parts of QEMU have specific licenses which are compatible with the
      GNU General Public License, version 2. Hence each source file contains
      its own licensing information.  Source files with no licensing information
      are released under the GNU General Public License, version 2 or (at your
      option) any later version.
    
      As of July 2013, contributions under version 2 of the GNU General Public
      License (and no later version) are only accepted for the following files
      or directories: bsd-user/, linux-user/, hw/misc/vfio.c, hw/xen/xen_pt*.
    
      3) The Tiny Code Generator (TCG) is released under the BSD license
         (see license headers in files).
    
      4) QEMU is a trademark of Fabrice Bellard.
    
      Fabrice Bellard and the QEMU team
    
  • The "edk2" submodule has its own licensing information, please read it.

visualuefi's People

Contributors

ionescu007 avatar mattiwatti avatar mcnameej avatar wallycz avatar williamleara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

visualuefi's Issues

Using unicode functions

First of alle Happy New Year !

I found an other issue. Whenever I'm trying to use a unicode function I get the linker error:

BaseLib.lib(SafeString.obj) : error LNK2001: Not resolved external symbol "__chkstk".

Here is my example
CHAR16 *str = L"";
str = CatSPrint(str, L"%s", "test");

I tried it with your sample.sln but it didn't work. Did I miss something or is it a bug ?

Kind regards
Daniel

Openssl compiling error

Hi Alex,
I built VisualUefi with VS2015, but project "OpenSSLlib" and "BaseCryptLib" in that solution failed to be compiled. The first error message sent by compiler is "size_t redefination". What has caused this problem?

regards,
Muju

How to install?

Hi Sir,
Sorry for bothering you.
I am new to EDK2 and trying to add the VisualUefi into my project.
How to install the "VisualUefi" that could work with EDK2?
(Copy all the files into EDK2 directory?)
I have set up the basic environment(VS2015 and Win32 BaseTools) that can compile the EDK2 applications successfully.

Thank you for your help.

Unable to clone 2

Unable to clone with
git clone --recursive https://github.com/ionescu007/VisualUefi does not help.

Error: server does not allow request for unadvertised object

This helped fix the problem.
git submodule init
git submodule sync
git submodule foreach "(git checkout master; git pull)"

Missing two QEMU files

Tried to run QEMU and nothing happened. Then I noticed that it created a stderr.txt file, which contained:

Could not open option rom 'kvmvapic.bin': No such file or directory
qemu.exe: Initialization of device VGA failed: failed to find romfile "vgabios-stdvga.bin"

I obtained a QEMU for Windows installer from https://qemu.weilnetz.de/w64/, and used 7-Zip to extract kvmvapic.bin and vgabios-stdvga.bin from it. I added those files to the debugger directory, and everything started working.

P.S. VisualUefi is a great idea. Thank you!

How to add a new library to sample project.

Hi,
I would like add a UEFI library to sample project, but I got the failed log as below.
error LNK2001: unresolved external symbol __security_check_cookie

Could you please help to add a demo project that can build a UEFI library?

Thanks!

How about other libraries?)

Hi Sir, sorry for bothering you, I am new to EDK2. Previously, I was using the standard method of assembly without VS. Thank you for a wonderful decision. But in my application I use the function ShellExecute located in UefiShellLib (VisualUefi-master\edk2\ShellPkg\Library\UefiShellLib). Can I add this library (and others) for using it? If yes, how? Thank you for understanding.
default

Add an Option Rom Driver

Great work on VisualUefi!
Is there any documentation on how to add an Option Rom driver.
Specifically, I am trying to add the UsbSerialDxe driver found in the OptionRom directory.

Thanks

ARM support

Hi,
Can you add support for building ARM EFI app?
Thank you.

BaseCryptLib

Hi,
I'm having trouble creating the BaseCryptLib. I always get an LNK2001 error in my application project. But the Library compiles without errors

BaseCryptLib.lib(CryptSha256.obj) : error LNK2001: "SHA256_Init"
I don't know what I'm doing wrong

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptMd4.c" />
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptMd4Null.c" />
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptMd5.c" />
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptSha1.c" />
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptSha256.c" />
    <ClCompile Include="..\..\edk2\CryptoPkg\Library\BaseCryptLib\Hash\CryptSha512.c" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{F2F48219-245E-4740-A859-9B7AC502DCBD}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>BaseCryptLib</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <Import Project="$(SolutionDir)\edk2.props" />
  <PropertyGroup Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v120</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
    <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <IncludePath>..\..\edk2\MdePkg\Include\;..\..\edk2\MdePkg\Include\X64;$(IncludePath);..\. .\edk2\CryptoPkg\Library;..\..\edk2\CryptoPkg\Include;..\..\edk2\CryptoPkg\Library\BaseCryptLibRuntimeCryptProtocol;..\..\edk2\CryptoPkg\Include\openssl;..\..\edk2\CryptoPkg\Library\OpensslLib\openssl-1.0.2e\lib</IncludePath>
    <IntDir>$(SolutionDir)$(Platform)\$(Configuration)\obj\</IntDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LibraryWPath>$(WindowsSDK_MetadataPath);..\..\edk-ii\$(Platform)\$(Configuration)\;$(LibraryPath)</LibraryWPath>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <ForcedIncludeFiles>..\..\..\EDK-II\BaseLib\vshacks.h</ForcedIncludeFiles>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
    <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
  </ImportGroup>
</Project>

This is my Visual Studio Projekt File. I hope you can help me

Kind regards
Daniel

C++ project

Hi,

I wanted to write C++ code using the VisualUefi framework, but failed with quite some errors in the MdePkg.
Compiling the sme code as C-code works fine.

Is there way to also write C++ code, or is this currently not supported?

Question on how to use functions out of netlib.h

Hi,

I'm trying to use some functions out of the "edk2\MdeModulePkg\Include\Library\NetLib.h" like "NetLibGetMacAddress", however, when I try to use any function defined in this header file I'm not able to compile my project anymore. The defines and structures declared in this header however are perfectly accessible. Is there anything I have to consider doing to access these functions properly?
Right now I'm always prompted with this error: "LNK2001 unresolved external symbol NetLibGetmacAddress".
I would be more than happy if anyone could help me with this or at least point me in the right direction to fix this

Best Regards
Niko

Building samples fails due to data types mismatch on UefiHiiLib

I'm trying to build the UefiApplication sample under VS2013 and link is failing with the following report on several data structures mismatching between GlueLib and /edk2/MdeModulePkg/Library/UefiHiiLib:

1>------ Build started: Project: UefiApplication, Configuration: Release x64 ------
1>LINK : error C2220: warning treated as error - no 'executable' file generated
1>LINK : warning C4742: 'gHiiString' has different alignment in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiString.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 4
1>LINK : warning C4743: 'gHiiString' has different size in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiString.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 16 bytes
1>LINK : warning C4744: 'gHiiString' has different type in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiString.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 'pointer' and 'struct (16 bytes)'
1>LINK : warning C4742: 'gHiiDatabase' has different alignment in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 4
1>LINK : warning C4743: 'gHiiDatabase' has different size in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 16 bytes
1>LINK : warning C4744: 'gHiiDatabase' has different type in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 'pointer' and 'struct (16 bytes)'
1>LINK : warning C4742: 'gHiiConfigRouting' has different alignment in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 4
1>LINK : warning C4743: 'gHiiConfigRouting' has different size in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 16 bytes
1>LINK : warning C4744: 'gHiiConfigRouting' has different type in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLib.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 'pointer' and 'struct (16 bytes)'
1>LINK : warning C4742: 'gHiiString' has different alignment in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLanguage.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 4
1>LINK : warning C4743: 'gHiiString' has different size in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLanguage.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 8 and 16 bytes
1>LINK : warning C4744: 'gHiiString' has different type in 'C:\build\VisualUefi\edk2\MdeModulePkg\Library\UefiHiiLib\HiiLanguage.c' and 'C:\build\VisualUefi\EDK-II\GlueLib\guid.c': 'pointer' and 'struct (16 bytes)'
1>  Generating code
1>LINK : fatal error LNK1257: code generation failed
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The EDK-II build itself runs flawlessly, I git-clone --recursive'd the repo, opened EDK-II/EDK-II.sln, changed all solution's Projects Toolset to v120 and built the solution with no errors or warnings.

For the samples, opening the solution and changing the toolsets to v120 + setting GenerateDebugInformation to No instead of the default DebugFastLink builds the other 3 samples without warnings but fails for UefiApplication.

Cannot open include file: 'C:\Users\jguo5\source\repos\Uefi Application1\..\EDK-II\BaseLib\vshacks.h

Severity	Code	Description	Project	File	Line	Suppression State
Error	C1083	Cannot open include file: 'C:\Users\jguo5\source\repos\Uefi Application1\..\EDK-II\BaseLib\vshacks.h': No such file or directory	Uefi Application1	C:\Users\jguo5\source\repos\Uefi Application1\Uefi Application1\helloapp.c	1	


It gives me this error even though I verified that the path was correct

My vshacks.h is located in

C:\Users\jguo5\source\repos\Uefi Application1\EDK-II\BaseLib\vshacks.h

build fails with current source

It may be that I fail at git but reporting this just in case. Using VS2015 but with Target Platform set to 10.0.10240.0 (not sure if important).

  1. recent git pull cleaned up the openssl directory with the exeption of a few includes so BaseCryptLib and OpenSslLib fail to build due to missing .c files

  2. GlueLib fails to compile guid.c due to last line:

1>------ Build started: Project: GlueLib, Configuration: Release x64 ------
1>  guid.c
1>guid.c(105): error C2065: 'EDKII_IFR_BIT_VARSTORE_GUID': undeclared identifier
1>guid.c(105): error C2099: initializer is not a constant

commenting it out allows build to succeed and I can build the samples.

LNK2005: InternalMemSetMem is already set in BaseMemoryLib.lib(SetMem.obj)

Hi,
you did a great job!
If I'm trying to use an ASCII method like AsciiStrnCat(...) i got an linker warning : LNK2005: InternalMemSetMem is already set in BaseMemoryLib.lib(SetMem.obj)

Do you have any idea?
PS: I commented out the SetMem.c code of BaseMemoryLib and after that it worked

Kind Regards an Merry Xmas
Daniel

Cannot build project

I am trying to build this project but it is impossible. I am getting long list of errors about 'No such file or directory', 'Cannot open source file' all the time. I set NASM_PREFIX environment variable correctly but nasm cannot execute command

Error MSB3721 The command ""D:\NASM\nasm.exe" -o "D:\VisualUefi\EDK-II\x64\Release\obj\BaseCpuLib\CpuFlushTlb.obj" -fwin64 -g -I"D:\VisualUefi\EDK-II\..\edk2\MdePkg" -I"D:\VisualUefi\EDK-II\..\edk2\MdePkg\Include" -I"D:\VisualUefi\EDK-II\..\edk2\MdePkg\Library\BaseLib\X64" -I"D:\VisualUefi\EDK-II\..\edk2\MdePkg\Include\X64" -P"D:\VisualUefi\EDK-II\BaseLib\vshacks.nasm" "D:\VisualUefi\edk2\MdePkg\Library\BaseCpuLib\x64\CpuFlushTlb.nasm"" exited with code 1. BaseCpuLib D:\VisualUefi\EDK-II\MSBuild\nasm.targets 33

What is the problem? How to resolve it?

VS2017 Compile Error

Hi,
After recursively cloning this repo, opening the sample solution in VS2017, and attempting to run it, I get the following error:
LNK1181: cannot open input file 'UefiApplicationEntryPoint.lib'
Am I doing something wrong?
Thanks :)

nasm errors during build

Severity	Code	Description	Project	Path	File	Line	Suppression State	Tool
Error	MSB3721	The command ""nasm.exe" -o "C:\Users\<user>\source\repos\VisualUefi\EDK-II\x64\Release\obj\BaseCpuLib\CpuFlushTlb.obj" -fwin64 -g -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include\X64" -P"C:\Users\<user>\source\repos\VisualUefi\EDK-II\BaseLib\vshacks.nasm"  "C:\Users\<user>\source\repos\VisualUefi\edk2\MdePkg\Library\BaseCpuLib\x64\CpuFlushTlb.nasm"" exited with code 1.	BaseCpuLib	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild\nasm.targets	33		NASM
Error	MSB3721	The command ""nasm.exe" -o "C:\Users\<user>\source\repos\VisualUefi\EDK-II\x64\Release\obj\BaseLib\CpuId.obj" -fwin64 -g -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include\X64" -P"C:\Users\<user>\source\repos\VisualUefi\EDK-II\BaseLib\vshacks.nasm"  "C:\Users\<user>\source\repos\VisualUefi\edk2\MdePkg\Library\BaseLib\X64\CpuId.nasm"" exited with code 1.	BaseLib	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild\nasm.targets	33		NASM
Error	MSB3721	The command ""nasm.exe" -o "C:\Users\<user>\source\repos\VisualUefi\EDK-II\x64\Release\obj\BaseSynchronizationLib\InterlockedDecrement.obj" -fwin64 -g -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\<user>\source\repos\VisualUefi\EDK-II\..\edk2\MdePkg\Include\X64" -P"C:\Users\<user>\source\repos\VisualUefi\EDK-II\BaseLib\vshacks.nasm"  "C:\Users\<user>\source\repos\VisualUefi\edk2\MdePkg\Library\BaseSynchronizationLib\X64\InterlockedDecrement.nasm"" exited with code 1.	BaseSynchronizationLib	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild	C:\Users\<user>\source\repos\VisualUefi\EDK-II\MSBuild\nasm.targets	33		NASM

How to fix bug "nasm".

hi u !
When build EDK-II , I has been opened file EDK-II.sln by VC++2015. An error message....

================================================================
1>D:\code\git\VisualUefi\EDK-II\MSBuild\nasm.targets(33,5): error MSB3721: The command ""C:\nasm\nasm.exe" -o "D:\code\git\VisualUefi\EDK-II\x64\Release\obj\BaseLib\LongJump.obj" -fwin64 -g -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Include" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Include\X64" -P"D:\code\git\VisualUefi\EDK-II\BaseLib\vshacks.nasm" "D:\code\git\VisualUefi\edk2\MdePkg\Library\BaseLib\X64\LongJump.nasm"" exited with code 1.

=================================================================
I has been fix it. I can run by cmd or :
go to disk :D
D:

go to folder include LongJump.nasm

cd D:\code\git\VisualUefi\edk2\MdePkg\Library\BaseLib\X64\LongJump.nasm

run nasm:
C:\nasm\nasm.exe -o "D:\code\git\VisualUefi\EDK-II\x64\Release\obj\BaseLib\LongJump.obj" -fwin64 -g -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Include" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"D:\code\git\VisualUefi\EDK-II..\edk2\MdePkg\Include\X64" -P"D:\code\git\VisualUefi\EDK-II\BaseLib\vshacks.nasm" "D:\code\git\VisualUefi\edk2\MdePkg\Library\BaseLib\X64\LongJump.nasm

Done.

Application type

How can I specify what kind of application it is? Such as DXE driver, UEFI application, UEFI driver etc.

Thank You!

This is awesome, neat and masterly crafted, Thank you for your time and effort.

How to add another EDK2 module to VisualUefi

  1. Open the solution with Visual Studio;
  2. Create a new project for the module in question. In my case, this was "DnsDxe" - part of "NetworkPkg";
  3. Change the project from Application (.exe) to Static library (.lib)
  4. Add all the relevant C files to the project;
  5. Fix the include path

FtdiUsbSerialDriver usage example

Hi,

in the VisualUefi package is the Ftdi driver as an example included.
In order to learn how to write own drivers,
I would like to see how the Ftdi could be used within an own project.
Does someone have a code example where the Ftdi driver is being used?

Thank you.

Adding StdLib

Hi, I've got an example driver from a company, and they are using std functions such as 'sprintf', 'printf' and '_wcsnicmp'. Trying to build this it gives 'unresolved external symbol' errors, which is ofcourse expected. The driver builds with just using the EDK2 build system (using UDK2015).

I tried adding the include directories of StdLib in EDK2, but it needs a lib as well. So, is there a way to add StdLib to the EDK-II libraries, or get it to build some other way?

I've tried adding a new project to EDK-II and adding the stdio and stdlib sources there, and then building the libraries, but this doesn't work. The StdLib will build into a library, but the stdio will complain about not finding things like memcpy, which is probably due to the compiler optimising some things and using the non-UEFI functions for that.

I can't build OpensslLib and BaseCryptLib

Hi, I cloned the git repository with

git clone https://github.com/ionescu007/VisualUefi.git --recurse-submodules

set NASM_PREFIX=C:\NASM as system variable and compiled the whole solution but I wasn't able to build OpensslLib and BaseCryptLib.

Has anyone tried to compile from scratch lately? Is it still working?

Missing UefiHandleParsingLib

I tried to create a new UefiHandleParsingLib project, but the compilation failed.

UefiHandleParsingLib.vcxproj file:
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <Keyword>Win32Proj</Keyword> <ProjectGuid>{A5267D46-2AB2-4252-9B70-203503D3223C}</ProjectGuid> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(SolutionDir)\edk2.default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" /> <Import Project="$(SolutionDir)\edk2.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> <ItemGroup> <ClCompile Include="$(EDK_PATH)\ShellPkg\Library\UefiHandleParsingLib\UefiHandleParsingLib.c" /> </ItemGroup> </Project>

Get error:
1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(181): error C2065: “UefiHandleParsingLibStrings”: 未声明的标识符 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(268): error C2065: “STR_LI_DUMP_NAME”: 未声明的标识符 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(268): warning C4244: “函数”: 从“int”转换到“EFI_STRING_ID”,可能丢失数据 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(278): error C2065: “STR_LI_DUMP_MAIN”: 未声明的标识符 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(278): warning C4244: “函数”: 从“int”转换到“EFI_STRING_ID”,可能丢失数据 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(346): error C2065: “STR_GOP_DUMP_MAIN”: 未声明的标识符 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(346): warning C4244: “函数”: 从“int”转换到“EFI_STRING_ID”,可能丢失数据 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(387): error C2065: “STR_GOP_RES_LIST_MAIN”: 未声明的标识符 1>d:\uefi\visualuefi\edk2\shellpkg\library\uefihandleparsinglib\uefihandleparsinglib.c(387): warning C4244: “函数”: 从“int”转换到“EFI_STRING_ID”,可能丢失数据 ......

Unable to clone

This project looks very promising and would love to make use of it in developing my little EFI app. However, I am unable to clone in Github for Windows app (it produces an error message which can be traced to an out of memory exception in the logs) and unable to clone in git shell which (1) complains that 'reference is not a tree: 7b40a4de48cfd3725c92ae2a68f57babda7a6ed2' when cloning the edk2 submodule and (2) that it is 'unable to connect to git.infradead.org' when cloning the openssl submodule. Are these known problems or some temporary connectivity/conf problem?

I also wonder why you decided to point to edk2 hosted on infraded rather than the (afaik official) repo on github? Same thing with openssl.

Cant fully complie

### I already set environment variables of nasm but still have troble help!!!

Error MSB3721 The command ""C:\nasmnasm.exe" -o "C:\Users\1\Downloads\VisualUefi-master\EDK-II\x64\Release\obj\BaseSynchronizationLib\InterlockedDecrement.obj" -fwin64 -g -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include\X64" -P"C:\Users\1\Downloads\VisualUefi-master\EDK-II\BaseLib\vshacks.nasm" "C:\Users\1\Downloads\VisualUefi-master\edk2\MdePkg\Library\BaseSynchronizationLib\X64\InterlockedDecrement.nasm"" exited with code 1. BaseSynchronizationLib C:\Users\1\Downloads\VisualUefi-master\EDK-II\MSBuild\nasm.targets 33
Severity Code Description Project File Line Suppression State
Error MSB3721 The command ""C:\nasmnasm.exe" -o "C:\Users\1\Downloads\VisualUefi-master\EDK-II\x64\Release\obj\BaseCpuLib\CpuFlushTlb.obj" -fwin64 -g -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include\X64" -P"C:\Users\1\Downloads\VisualUefi-master\EDK-II\BaseLib\vshacks.nasm" "C:\Users\1\Downloads\VisualUefi-master\edk2\MdePkg\Library\BaseCpuLib\x64\CpuFlushTlb.nasm"" exited with code 1. BaseCpuLib C:\Users\1\Downloads\VisualUefi-master\EDK-II\MSBuild\nasm.targets 33
Severity Code Description Project File Line Suppression State
Error MSB3721 The command ""C:\nasmnasm.exe" -o "C:\Users\1\Downloads\VisualUefi-master\EDK-II\x64\Release\obj\BaseLib\CpuId.obj" -fwin64 -g -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\1\Downloads\VisualUefi-master\EDK-II..\edk2\MdePkg\Include\X64" -P"C:\Users\1\Downloads\VisualUefi-master\EDK-II\BaseLib\vshacks.nasm" "C:\Users\1\Downloads\VisualUefi-master\edk2\MdePkg\Library\BaseLib\X64\CpuId.nasm"" exited with code 1. BaseLib C:\Users\1\Downloads\VisualUefi-master\EDK-II\MSBuild\nasm.targets 33

OpenSSLLib fails to compile

Hello Alex,

I want to thank you for sharing the project.

I'm not sure what am I doing wrong but I'm having issues compiling OpensslLib, after git clone --recursive and building with VS 2017 24 project compile 2 failed (BaseCryptLib and OpensslLib). Error that repeats is "Cannot open openssl/opensslconf.h". Since I already have compiled version of OpenSSL(1.1.0), I added new include folder where it resolves the issue with opensslconf but then another issues raise (missing machine/int_type, limit.h etc) so I guess that is not the solution. Can you somehow point me in the right direction or should I use openssl 1.0.2?

Error

Gravedad Código Descripción Proyecto Archivo Línea Estado suprimido
Error MSB3721 El comando ""nasm.exe" -o "C:\Users\123\VisualUefi\EDK-II\x64\Release\obj\BaseLib\CpuId.obj" -fwin64 -g -I"C:\Users\123\VisualUefi\EDK-II..\edk2\MdePkg" -I"C:\Users\123\VisualUefi\EDK-II..\edk2\MdePkg\Include" -I"C:\Users\123\VisualUefi\EDK-II..\edk2\MdePkg\Library\BaseLib\X64" -I"C:\Users\123\VisualUefi\EDK-II..\edk2\MdePkg\Include\X64" -P"C:\Users\123\VisualUefi\EDK-II\BaseLib\vshacks.nasm" "C:\Users\123\VisualUefi\edk2\MdePkg\Library\BaseLib\X64\CpuId.nasm"" salió con el código 1. BaseLib C:\Users\123\VisualUefi\EDK-II\MSBuild\nasm.targets 33

FatPkg support

Hello,

First, I'd like to thank you very much for the VisualUEFI project. We got rid of many unnecessary jobs and installations by this project. I would like to use FatPkg/EnhancedFatDxe/Fat.h and so on in EFI applications. May you build the FAT library into the VisualUEFI project? Thank you in advance so much.

Sincerely,
Fatih Aydın

Cannot link against BaseSynchronizationLib

Hi, thanks for your work on this!

The following code will fail to link:

#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/SynchronizationLib.h>

CONST UINT32 _gUefiDriverRevision = 0;

CHAR8 *gEfiCallerBaseName = "LinkMe";

EFI_STATUS
EFIAPI
UefiUnload (
    IN EFI_HANDLE ImageHandle
    )
{
    ASSERT(FALSE);
}

EFI_STATUS
EFIAPI
UefiMain (
    IN EFI_HANDLE ImageHandle,
    IN EFI_SYSTEM_TABLE* SystemTable
    )
{
    InterlockedCompareExchange32(NULL, 0, 0);

    return EFI_SUCCESS;
}

I'm using MSVC 2017. Output:

1>Target Link:
1>  BaseSynchronizationLib.lib(SynchronizationMsc.obj) : error LNK2001: unresolved external symbol InternalGetSpinLockProperties
1>  BaseSynchronizationLib.lib(SynchronizationMsc.obj) : error LNK2001: unresolved external symbol GetPerformanceCounter
1>  BaseSynchronizationLib.lib(SynchronizationMsc.obj) : error LNK2001: unresolved external symbol GetPerformanceCounterProperties
1>  C:\Users\Matti\Desktop\VisualUefi\samples\x64\Release\UefiApplication.efi : fatal error LNK1120: 3 unresolved externals

After checking out BaseSynchronizationLib.inf in the edk2 directory, it seems that the culprit is Ia32/InternalGetSpinLockProperties.c which is not in the project. Confusingly, despite being under /Ia32, this file is used for both Ia32 and X64 targets on MSVC:

# BaseSynchronizationLib.inf

[Sources.X64]
  Ia32/InternalGetSpinLockProperties.c | MSFT

I added this file to BaseSynchronizationLib.vcxproj and was immediately greeted with another error, because this file has the following include:

#include "BaseSynchronizationLibInternals.h"

This file is one level up from the source file, and its path is not in the standard include paths for the project. I worked around this by adding the 3 extra characters needed (../) that the original author could have added in the first place, because I didn't want to modify the include paths for the entire solution just for one file.

After this, BaseSynchronizationLib compiled once again, but the sample still fails to link with GetPerformanceCounter and GetPerformanceCounterProperties from TimerLib missing (of which there are many implementations). After some grepping it seemed to me that SecPeiDxeTimerLibCpu would probably be best suited for most use cases on X64. I added its single source file X86TimerLib.c to the project. The result:

1>edk2\mdepkg\library\secpeidxetimerlibcpu\x86timerlib.c(100): error C2065: '_PCD_GET_MODE_32_PcdFSBClock': undeclared identifier

Because this PCD blatantly exists in pcd.c, I added yet another hack by redeclaring this as a top level extern variable in X86TimerLib.c. After this, BaseSynchronizationLib compiled once more! However, upon trying to finally get my sample to link, I got:

1>Target Link:
1>  BaseSynchronizationLib.lib(X86TimerLib.obj) : error LNK2001: unresolved external symbol MmioRead32
1>  BaseSynchronizationLib.lib(X86TimerLib.obj) : error LNK2001: unresolved external symbol MmioBitFieldRead32
1>  C:\Users\Matti\Desktop\VisualUefi\samples\x64\Release\UefiApplication.efi : fatal error LNK1120: 2 unresolved externals

At this point I finally gave up and started swearing a lot. This helped a little, but not enough to get my sample to work. Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.