Patch from open source community for CryptoPkg to allow it to build for ARM using the RVCT toolchain.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11565 6f19259b-4bc3-4df7-8a09-765794883524
diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 8df9e30..f88b4f8 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -23,7 +23,7 @@
   PLATFORM_VERSION               = 0.91

   DSC_SPECIFICATION              = 0x00010005

   OUTPUT_DIRECTORY               = Build/CryptoPkg

-  SUPPORTED_ARCHITECTURES        = IA32|X64|IPF|EBC

+  SUPPORTED_ARCHITECTURES        = IA32|X64|IPF|EBC|ARM

   BUILD_TARGETS                  = DEBUG|RELEASE

   SKUID_IDENTIFIER               = DEFAULT

 

@@ -50,6 +50,14 @@
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf

 

+[LibraryClasses.ARM]

+  #

+  # It is not possible to prevent the ARM compiler for generic intrinsic functions.

+  # This library provides the instrinsic functions generate by a given compiler.

+  # [LibraryClasses.ARM] and NULL mean link this library into all ARM images.

+  #

+  NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

+

 [LibraryClasses.common.PEIM]

   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf

 

diff --git a/CryptoPkg/Include/OpenSslSupport.h b/CryptoPkg/Include/OpenSslSupport.h
index 5715115..258854b 100644
--- a/CryptoPkg/Include/OpenSslSupport.h
+++ b/CryptoPkg/Include/OpenSslSupport.h
@@ -30,10 +30,18 @@
 //

 // Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h

 //

+#if !defined(__CC_ARM) // if va_list is not already defined

 #define va_list   VA_LIST

 #define va_arg    VA_ARG

 #define va_start  VA_START

 #define va_end    VA_END

+#else // __CC_ARM

+#define va_start(Marker, Parameter)   __va_start(Marker, Parameter)

+#define va_arg(Marker, TYPE)          __va_arg(Marker, TYPE)

+#define va_end(Marker)                ((void)0)

+#endif

+

+

 

 //

 // #defines from EFI Application Toolkit required to buiild Open SSL

@@ -211,9 +219,9 @@
 //

 // Global variables from EFI Application Toolkit required to buiild Open SSL

 //

-FILE  *stderr;

-FILE  *stdin;

-FILE  *stdout;

+static FILE  *stderr;

+static FILE  *stdin;

+static FILE  *stdout;

 

 //

 // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions

diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
index b9daaee..46574dc 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
@@ -15,6 +15,8 @@
 

 #include <OpenSslSupport.h>

 

+int errno = 0;

+

 typedef

 INTN

 (*SORT_COMPARE)(

@@ -298,3 +300,113 @@
 {

   return NULL;

 }

+

+int X509_load_cert_file (VOID *ctx, const char *file, int type)

+{

+  return 0;

+}

+

+int X509_load_crl_file (VOID *ctx, const char *file, int type)

+{

+  return 0;

+}

+

+int chmod (const char *c, mode_t m)

+{

+  return -1;

+}

+

+int close (int f)

+{

+  return -1;

+}

+

+void closelog (void)

+{

+

+}

+

+void exit (int e)

+{

+

+}

+

+int fclose (FILE *f)

+{

+  return 0;

+}

+

+FILE *fopen (const char *c, const char *m)

+{

+  return NULL;

+}

+

+size_t fread (void *b, size_t c, size_t i, FILE *f)

+{

+  return 0;

+}

+

+int fprintf (FILE *f, const char *s, ...)

+{

+  return 0;

+}

+

+uid_t getuid (void)

+{

+  return 0;

+}

+

+uid_t geteuid (void)

+{

+  return 0;

+}

+

+gid_t getgid (void)

+{

+  return 0;

+}

+

+gid_t getegid (void)

+{

+  return 0;

+}

+

+off_t lseek (int a, off_t o, int d)

+{

+  return 0;

+}

+

+void openlog (const char *c, int a, int b)

+{

+

+}

+

+ssize_t read (int f, void *b, size_t c)

+{

+  return 0;

+}

+

+int stat (const char *c, struct stat *s)

+{

+  return -1;

+}

+

+int strcasecmp (const char *c, const char *s)

+{

+  return 0;

+}

+

+int strncasecmp (const char *c, const char *s, size_t l)

+{

+  return 0;

+}

+

+void syslog (int a, const char *c, ...)

+{

+

+}

+

+ssize_t write (int f, const void *b, size_t l)

+{

+  return 0;

+}

diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index 27547f3..7968275 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -51,7 +51,7 @@
 #

   

 #

-#  VALID_ARCHITECTURES           = IA32 X64 IPF

+#  VALID_ARCHITECTURES           = IA32 X64 IPF ARM

 #

 

 [Sources]

@@ -599,3 +599,7 @@
    MSFT:RELEASE_*_IPF_CC_FLAGS            == /nologo /c /WX /GS- /X /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 -U_WIN32 -U_WIN64 -U_MSC_VER $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) /w

   INTEL:*_*_*_CC_FLAGS                    = -U_WIN32 -U_WIN64 -U_MSC_VER -U__ICC $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) /w

     GCC:*_*_*_CC_FLAGS                    = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) -w

+   RVCT:DEBUG_*_*_CC_FLAGS                = $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) --library_interface=aeabi_clib99 --fpu=vfpv3

+   RVCT:RELEASE_*_*_CC_FLAGS              = $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) --library_interface=aeabi_clib99 --fpu=vfpv3

+

+