Defines for UEFI environment under MSVC added
diff --git a/library/base64.c b/library/base64.c
index e9527db..3b4376d 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -29,7 +29,7 @@
 
 #include "polarssl/base64.h"
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
 #include <basetsd.h>
 typedef UINT32 uint32_t;
 #else
diff --git a/library/cipher.c b/library/cipher.c
index 3ed6830..277811a 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -44,7 +44,7 @@
 #define POLARSSL_CIPHER_MODE_STREAM
 #endif
 
-#if defined _MSC_VER && !defined strcasecmp
+#if defined(_MSC_VER) && !defined strcasecmp
 #define strcasecmp _stricmp
 #endif
 
diff --git a/library/debug.c b/library/debug.c
index 2497a3b..fb0ec71 100644
--- a/library/debug.c
+++ b/library/debug.c
@@ -32,11 +32,15 @@
 #include <stdarg.h>
 #include <stdlib.h>
 
-#if defined _MSC_VER && !defined  snprintf
+#if defined(EFIX64) || defined(EFI32)
+#include <stdio.h>
+#endif
+
+#if defined(_MSC_VER) && !defined  snprintf
 #define  snprintf  _snprintf
 #endif
 
-#if defined _MSC_VER && !defined vsnprintf
+#if defined(_MSC_VER) && !defined vsnprintf
 #define vsnprintf _vsnprintf
 #endif
 
diff --git a/library/entropy_poll.c b/library/entropy_poll.c
index eec8ec4..badcfac 100644
--- a/library/entropy_poll.c
+++ b/library/entropy_poll.c
@@ -38,7 +38,7 @@
 #endif
 
 #if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
 
 #if !defined(_WIN32_WINNT)
 #define _WIN32_WINNT 0x0400
diff --git a/library/error.c b/library/error.c
index d17338a..3f4bc93 100644
--- a/library/error.c
+++ b/library/error.c
@@ -160,7 +160,7 @@
 
 #include <string.h>
 
-#if defined _MSC_VER && !defined  snprintf
+#if defined(_MSC_VER) && !defined  snprintf
 #define  snprintf  _snprintf
 #endif
 
diff --git a/library/md.c b/library/md.c
index 716c016..073f932 100644
--- a/library/md.c
+++ b/library/md.c
@@ -36,8 +36,8 @@
 
 #include <stdlib.h>
 
-#if defined _MSC_VER && !defined strcasecmp
-#define strcasecmp _stricmp
+#if defined(_MSC_VER) && !defined strcasecmp
+#define  snprintf  _stricmp
 #endif
 
 static const int supported_digests[] = {
diff --git a/library/net.c b/library/net.c
index 2ab12df..be2785d 100644
--- a/library/net.c
+++ b/library/net.c
@@ -29,7 +29,8 @@
 
 #include "polarssl/net.h"
 
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
+    !defined(EFI32)
 
 #include <winsock2.h>
 #include <windows.h>
@@ -64,7 +65,8 @@
 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) ||  \
     defined(__DragonflyBSD__)
 #include <sys/endian.h>
-#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H)
+#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H) ||   \
+      defined(EFIX64) || defined(EFI32)
 #include <machine/endian.h>
 #elif defined(sun)
 #include <sys/isa_defs.h>
@@ -83,7 +85,7 @@
 #include <time.h>
 #endif
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
 #include <basetsd.h>
 typedef UINT32 uint32_t;
 #else
@@ -120,7 +122,9 @@
     struct sockaddr_in server_addr;
     struct hostent *server_host;
 
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
+
     WSADATA wsaData;
 
     if( wsa_init_done == 0 )
@@ -131,8 +135,10 @@
         wsa_init_done = 1;
     }
 #else
+#if !defined(EFIX64) && !defined(EFI32)
     signal( SIGPIPE, SIG_IGN );
 #endif
+#endif
 
     if( ( server_host = gethostbyname( host ) ) == NULL )
         return( POLARSSL_ERR_NET_UNKNOWN_HOST );
@@ -165,7 +171,8 @@
     int n, c[4];
     struct sockaddr_in server_addr;
 
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
     WSADATA wsaData;
 
     if( wsa_init_done == 0 )
@@ -176,8 +183,10 @@
         wsa_init_done = 1;
     }
 #else
+#if !defined(EFIX64) && !defined(EFI32)
     signal( SIGPIPE, SIG_IGN );
 #endif
+#endif
 
     if( ( *fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 )
         return( POLARSSL_ERR_NET_SOCKET_FAILED );
@@ -228,7 +237,8 @@
  */
 static int net_is_blocking( void )
 {
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
     return( WSAGetLastError() == WSAEWOULDBLOCK );
 #else
     switch( errno )
@@ -282,7 +292,8 @@
  */
 int net_set_block( int fd )
 {
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
     u_long n = 0;
     return( ioctlsocket( fd, FIONBIO, &n ) );
 #else
@@ -292,7 +303,8 @@
 
 int net_set_nonblock( int fd )
 {
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
     u_long n = 1;
     return( ioctlsocket( fd, FIONBIO, &n ) );
 #else
@@ -317,7 +329,7 @@
  * Read at most 'len' characters
  */
 int net_recv( void *ctx, unsigned char *buf, size_t len )
-{ 
+{
     int ret = read( *((int *) ctx), buf, len );
 
     if( ret < 0 )
@@ -325,7 +337,8 @@
         if( net_is_blocking() != 0 )
             return( POLARSSL_ERR_NET_WANT_READ );
 
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
         if( WSAGetLastError() == WSAECONNRESET )
             return( POLARSSL_ERR_NET_CONN_RESET );
 #else
@@ -354,7 +367,8 @@
         if( net_is_blocking() != 0 )
             return( POLARSSL_ERR_NET_WANT_WRITE );
 
-#if defined(_WIN32) || defined(_WIN32_WCE)
+#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
+    !defined(EFI32)
         if( WSAGetLastError() == WSAECONNRESET )
             return( POLARSSL_ERR_NET_CONN_RESET );
 #else
diff --git a/library/oid.c b/library/oid.c
index a4f2c0c..6efd510 100644
--- a/library/oid.c
+++ b/library/oid.c
@@ -530,7 +530,7 @@
 FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg);
 #endif /* POLARSSL_PKCS12_C */
 
-#if defined _MSC_VER && !defined snprintf
+#if defined(_MSC_VER) && !defined snprintf
 #include <stdarg.h>
 
 #if !defined vsnprintf
diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c
index 1c9f809..e1a8626 100644
--- a/library/ssl_ciphersuites.c
+++ b/library/ssl_ciphersuites.c
@@ -34,7 +34,7 @@
 
 #include <stdlib.h>
 
-#if defined _MSC_VER && !defined strcasecmp
+#if defined(_MSC_VER) && !defined strcasecmp
 #define strcasecmp _stricmp
 #endif
 
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index bb2afb2..ad6583b 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -40,7 +40,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
 #include <basetsd.h>
 typedef UINT32 uint32_t;
 #else
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 4d65479..c86e774 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -47,7 +47,7 @@
 
 #include <stdlib.h>
 
-#if defined _MSC_VER && !defined strcasecmp
+#if defined(_MSC_VER) && !defined strcasecmp
 #define strcasecmp _stricmp
 #endif
 
diff --git a/library/timing.c b/library/timing.c
index 0273d1a..1b4311c 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -29,7 +29,7 @@
 
 #include "polarssl/timing.h"
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
 
 #include <windows.h>
 #include <winbase.h>
@@ -172,14 +172,15 @@
 }
 #endif
 
-#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER)
+#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER) && \
+    !defined(EFIX64) && !defined(EFI32)
 
 #define POLARSSL_HAVE_HARDCLOCK
 
 unsigned long hardclock( void )
 {
     LARGE_INTEGER offset;
-    
+
 	QueryPerformanceCounter( &offset );
 
 	return (unsigned long)( offset.QuadPart );
@@ -211,7 +212,7 @@
 
 volatile int alarmed = 0;
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
 
 unsigned long get_timer( struct hr_time *val, int reset )
 {
diff --git a/library/x509.c b/library/x509.c
index 677760e..27040b9 100644
--- a/library/x509.c
+++ b/library/x509.c
@@ -54,12 +54,16 @@
 
 #include <string.h>
 #include <stdlib.h>
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
 #include <windows.h>
 #else
 #include <time.h>
 #endif
 
+#if defined(EFIX64) || defined(EFI32)
+#include <stdio.h>
+#endif
+
 #if defined(POLARSSL_FS_IO)
 #include <stdio.h>
 #if !defined(_WIN32)
@@ -425,7 +429,7 @@
 }
 #endif /* POLARSSL_FS_IO */
 
-#if defined _MSC_VER && !defined snprintf
+#if defined(_MSC_VER) && !defined snprintf
 #include <stdarg.h>
 
 #if !defined vsnprintf
@@ -620,7 +624,7 @@
     int year, mon, day;
     int hour, min, sec;
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
     SYSTEMTIME st;
 
     GetLocalTime(&st);
diff --git a/library/x509_crl.c b/library/x509_crl.c
index 00d51bd..90ceabd 100644
--- a/library/x509_crl.c
+++ b/library/x509_crl.c
@@ -53,13 +53,14 @@
 
 #include <string.h>
 #include <stdlib.h>
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
+
 #include <windows.h>
 #else
 #include <time.h>
 #endif
 
-#if defined(POLARSSL_FS_IO)
+#if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
 #include <stdio.h>
 #endif
 
@@ -544,7 +545,7 @@
 }
 #endif /* POLARSSL_FS_IO */
 
-#if defined _MSC_VER && !defined snprintf
+#if defined(_MSC_VER) && !defined snprintf
 #include <stdarg.h>
 
 #if !defined vsnprintf
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 9eba14d..9470132 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -53,12 +53,16 @@
 
 #include <string.h>
 #include <stdlib.h>
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
 #include <windows.h>
 #else
 #include <time.h>
 #endif
 
+#if defined(EFIX64) || defined(EFI32)
+#include <stdio.h>
+#endif
+
 #if defined(POLARSSL_FS_IO)
 #include <stdio.h>
 #if !defined(_WIN32)
@@ -935,7 +939,7 @@
 int x509_crt_parse_path( x509_crt *chain, const char *path )
 {
     int ret = 0;
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
     int w_ret;
     WCHAR szDir[MAX_PATH];
     char filename[MAX_PATH];
@@ -1035,7 +1039,7 @@
 }
 #endif /* POLARSSL_FS_IO */
 
-#if defined _MSC_VER && !defined snprintf
+#if defined(_MSC_VER) && !defined snprintf
 #include <stdarg.h>
 
 #if !defined vsnprintf
diff --git a/library/x509_csr.c b/library/x509_csr.c
index 8496f5b..4dec9b9 100644
--- a/library/x509_csr.c
+++ b/library/x509_csr.c
@@ -54,7 +54,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#if defined(POLARSSL_FS_IO)
+#if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
 #include <stdio.h>
 #endif
 
@@ -302,7 +302,7 @@
 }
 #endif /* POLARSSL_FS_IO */
 
-#if defined _MSC_VER && !defined snprintf
+#if defined(_MSC_VER) && !defined snprintf
 #include <stdarg.h>
 
 #if !defined vsnprintf