summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorvbendeb <vbendeb@chromium.org>2010-06-24 16:19:53 -0700
committervbendeb <vbendeb@chromium.org>2010-06-24 16:19:53 -0700
commit3ecaf776d82d29573be083b2e5c6ddc5b9f49c70 (patch)
tree3887c0749d73e45562a250c275f56eb4f5356613 /firmware
parentd6aad3a0888ad57383036dacdfc4c01f0c3b56e3 (diff)
downloadvboot-3ecaf776d82d29573be083b2e5c6ddc5b9f49c70.tar.gz
Make vboot_reference build in MSVC command line environment.
This is a mostly NOOP change which modifies the source code to compile cleanly in the MSVC command line build environment. A new makefile is introduced (msc/nmakefile) along with a README.txt in the same directory explaining how to build the code in the DOS window. As of this submission the build is running in a 32 bit environment, the intention is to use the same makefile for 64 bit builds in the future. Enabling high compilation warnings level allowed to identify a couple of bugs in the code which are being fixed. Not all sources are being compiled in the MSVC environment, only those in firmware/ and most of those in test/ subdirectories. The benchmark calculations require porting of the timer facilities and are being postponed. TEST Built in DOS and linux environments. Ran unit tests in linux environment. Review URL: http://codereview.chromium.org/2809037
Diffstat (limited to 'firmware')
-rw-r--r--firmware/include/sysincludes.h12
-rw-r--r--firmware/include/utility.h4
-rw-r--r--firmware/lib/cgptlib/cgptlib_internal.c10
-rw-r--r--firmware/lib/cgptlib/include/cgptlib_internal.h2
-rw-r--r--firmware/lib/cgptlib/include/gpt.h8
-rw-r--r--firmware/lib/include/vboot_struct.h8
-rw-r--r--firmware/lib/rollback_index.c6
-rw-r--r--firmware/lib/vboot_kernel.c2
-rw-r--r--firmware/stub/boot_device_stub.c3
-rw-r--r--firmware/stub/include/biosincludes.h20
-rw-r--r--firmware/stub/load_firmware_stub.c6
-rw-r--r--firmware/stub/tlcl.c3
-rw-r--r--firmware/stub/utility_stub.c9
-rw-r--r--firmware/version.c2
14 files changed, 66 insertions, 29 deletions
diff --git a/firmware/include/sysincludes.h b/firmware/include/sysincludes.h
index be7e701d..ff24e4c3 100644
--- a/firmware/include/sysincludes.h
+++ b/firmware/include/sysincludes.h
@@ -26,12 +26,20 @@
#include <memory.h>
#endif
+#else
+#include "biosincludes.h"
+#endif
+
+#ifndef _MSC_VER
+#define __pragma(...)
+#endif
+
+#if defined (CHROMEOS_ENVIRONMENT) || defined (TARGET_TEST_MODE)
+
/* 64-bit operations, for platforms where they need to be function calls */
#define UINT64_RSHIFT(v, shiftby) (((uint64_t)(v)) >> (shiftby))
#define UINT64_MULT32(v, multby) (((uint64_t)(v)) * ((uint32_t)(multby)))
-#else
-#include "biosincludes.h"
#endif
#endif /* VBOOT_REFERENCE_SYSINCLUDES_H_ */
diff --git a/firmware/include/utility.h b/firmware/include/utility.h
index c1709384..0e05ee3b 100644
--- a/firmware/include/utility.h
+++ b/firmware/include/utility.h
@@ -52,10 +52,10 @@ void Free(void* ptr);
int Memcmp(const void* src1, const void* src2, size_t n);
/* Copy [n] bytes from [src] to [dest]. */
-void* Memcpy(void* dest, const void* src, size_t n);
+void* Memcpy(void* dest, const void* src, uint64_t n);
/* Set [n] bytes starting at [s] to [c]. */
-void* Memset(void *dest, const uint8_t c, size_t n);
+void* Memset(void *dest, const uint8_t c, uint64_t n);
/* Compare [n] bytes starting at [s1] with [s2] and return 0 if they match,
* 1 if they don't. Time taken to perform the comparison is only dependent on
diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c
index 4e0a06ac..c3fd1f32 100644
--- a/firmware/lib/cgptlib/cgptlib_internal.c
+++ b/firmware/lib/cgptlib/cgptlib_internal.c
@@ -115,7 +115,7 @@ int IsKernelEntry(const GptEntry* e) {
}
-int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors) {
+int CheckEntries(GptEntry* entries, GptHeader* h) {
GptEntry* entry;
uint32_t crc32;
@@ -227,17 +227,17 @@ int GptSanityCheck(GptData *gpt) {
* Note that we use the same header in both checks. This way we'll
* catch the case where (header1,entries1) and (header2,entries2)
* are both valid, but (entries1 != entries2). */
- if (0 == CheckEntries(entries1, goodhdr, gpt->drive_sectors))
+ if (0 == CheckEntries(entries1, goodhdr))
gpt->valid_entries |= MASK_PRIMARY;
- if (0 == CheckEntries(entries2, goodhdr, gpt->drive_sectors))
+ if (0 == CheckEntries(entries2, goodhdr))
gpt->valid_entries |= MASK_SECONDARY;
/* If both headers are good but neither entries were good, check the
* entries with the secondary header. */
if (MASK_BOTH == gpt->valid_headers && !gpt->valid_entries) {
- if (0 == CheckEntries(entries1, header2, gpt->drive_sectors))
+ if (0 == CheckEntries(entries1, header2))
gpt->valid_entries |= MASK_PRIMARY;
- if (0 == CheckEntries(entries2, header2, gpt->drive_sectors))
+ if (0 == CheckEntries(entries2, header2))
gpt->valid_entries |= MASK_SECONDARY;
if (gpt->valid_entries) {
/* Sure enough, header2 had a good CRC for one of the entries. Mark
diff --git a/firmware/lib/cgptlib/include/cgptlib_internal.h b/firmware/lib/cgptlib/include/cgptlib_internal.h
index 5252b6a0..95e5b4e7 100644
--- a/firmware/lib/cgptlib/include/cgptlib_internal.h
+++ b/firmware/lib/cgptlib/include/cgptlib_internal.h
@@ -83,7 +83,7 @@ uint32_t HeaderCrc(GptHeader* h);
/* Check entries.
*
* Returns 0 if entries are valid, 1 if invalid. */
-int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors);
+int CheckEntries(GptEntry* entries, GptHeader* h);
/* Check GptData, headers, entries.
*
diff --git a/firmware/lib/cgptlib/include/gpt.h b/firmware/lib/cgptlib/include/gpt.h
index 1d5cb58d..b55f921a 100644
--- a/firmware/lib/cgptlib/include/gpt.h
+++ b/firmware/lib/cgptlib/include/gpt.h
@@ -12,9 +12,7 @@
#include "sysincludes.h"
-#ifdef _MSC_VER
-#pragma pack(push,1) /* Support packing for MSVC. */
-#endif
+__pragma(pack(push,1)) /* Support packing for MSVC. */
#define GPT_HEADER_SIGNATURE "EFI PART"
#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE)
@@ -117,8 +115,6 @@ typedef struct {
#define GPTENTRY_EXPECTED_SIZE 128
-#ifdef _MSC_VER
-#pragma pack(pop) /* Support packing for MSVC. */
-#endif
+__pragma(pack(pop)) /* Support packing for MSVC. */
#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */
diff --git a/firmware/lib/include/vboot_struct.h b/firmware/lib/include/vboot_struct.h
index e6240c71..975d6f6d 100644
--- a/firmware/lib/include/vboot_struct.h
+++ b/firmware/lib/include/vboot_struct.h
@@ -11,9 +11,7 @@
#include "sysincludes.h"
-#ifdef _MSC_VER
-#pragma pack(push, 1) /* Support packing for MSVC. */
-#endif
+__pragma(pack(push, 1)) /* Support packing for MSVC. */
/* Public key data */
typedef struct VbPublicKey {
@@ -133,8 +131,6 @@ typedef struct VbKernelPreambleHeader {
#define EXPECTED_VBKERNELPREAMBLEHEADER_SIZE 96
-#ifdef _MSC_VER
-#pragma pack(pop) /* Support packing for MSVC. */
-#endif
+__pragma(pack(pop)) /* Support packing for MSVC. */
#endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index ebc721d8..4fb7ec97 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -17,6 +17,9 @@ uint16_t g_firmware_version = 0;
uint16_t g_kernel_key_version = 0;
uint16_t g_kernel_version = 0;
+/* disable MSVC warning on const logical expression (as in } while(0);) */
+__pragma(warning (disable: 4127))
+
#define RETURN_ON_FAILURE(tpm_command) do { \
uint32_t result; \
if ((result = (tpm_command)) != TPM_SUCCESS) { \
@@ -369,7 +372,8 @@ uint32_t LockKernelVersionsByLockingPP() {
return TlclLockPhysicalPresence();
}
-
+/* disable MSVC warnings on unused arguments */
+__pragma(warning (disable: 4100))
/* NEW APIS! HELP ME LUIGI, YOU'RE MY ONLY HOPE! */
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index e6658d75..17cd925e 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -108,6 +108,8 @@ int WriteAndFreeGptData(GptData* gptdata) {
return 0;
}
+/* disable MSVC warning on const logical expression (as in } while(0);) */
+__pragma(warning(disable: 4127))
int LoadKernel(LoadKernelParams* params) {
diff --git a/firmware/stub/boot_device_stub.c b/firmware/stub/boot_device_stub.c
index c7bb86f5..1316e01c 100644
--- a/firmware/stub/boot_device_stub.c
+++ b/firmware/stub/boot_device_stub.c
@@ -7,6 +7,9 @@
#include "boot_device.h"
+/* disable MSVC warnings on unused arguments */
+__pragma(warning (disable: 4100))
+
int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) {
return 1;
}
diff --git a/firmware/stub/include/biosincludes.h b/firmware/stub/include/biosincludes.h
index 9ed4eaba..ac0159d8 100644
--- a/firmware/stub/include/biosincludes.h
+++ b/firmware/stub/include/biosincludes.h
@@ -11,4 +11,24 @@
* CHROMEOS_ENVIRONMENT is not defined at compilation time.
*/
+#ifdef TARGET_TEST_MODE
+
+typedef unsigned long long uint64_t;
+typedef long long int64_t;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef unsigned char uint8_t;
+typedef unsigned size_t;
+
+#ifndef NULL
+#define NULL ((void*) 0)
+#endif
+
+#define UINT64_C(x) ((uint64_t)x)
+#define __attribute__(x)
+#define PRIu64 "%ll"
+extern void debug(const char *format, ...);
+
+#endif
+
#endif /*CHROMEOS_SRC_PLATFORM_VBOOT_REFERENCE_FIRMWARE_STUB_BIOSINCLUDES_H_*/
diff --git a/firmware/stub/load_firmware_stub.c b/firmware/stub/load_firmware_stub.c
index 9453856a..9d99b4a0 100644
--- a/firmware/stub/load_firmware_stub.c
+++ b/firmware/stub/load_firmware_stub.c
@@ -35,9 +35,13 @@ int GetFirmwareBody(LoadFirmwareParams* params, uint64_t index) {
case 0:
size = ci->firmwareA_size;
fw = ci->firmwareA;
+ break;
+
case 1:
size = ci->firmwareB_size;
fw = ci->firmwareB;
+ break;
+
default:
/* Anything else is invalid */
return 1;
@@ -68,6 +72,7 @@ int VerifyFirmwareDriver_stub(uint8_t* root_key_blob,
int rv;
CallerInternal ci;
+ LoadFirmwareParams p;
/* Copy the firmware volume pointers to our global variables. */
ci.firmwareA = firmwareA;
@@ -78,7 +83,6 @@ int VerifyFirmwareDriver_stub(uint8_t* root_key_blob,
ci.firmwareB_size = 0;
/* Set up the params for LoadFirmware() */
- LoadFirmwareParams p;
p.caller_internal = &ci;
p.firmware_root_key_blob = root_key_blob;
p.verification_block_0 = verification_headerA;
diff --git a/firmware/stub/tlcl.c b/firmware/stub/tlcl.c
index 23f0f09a..cad286a8 100644
--- a/firmware/stub/tlcl.c
+++ b/firmware/stub/tlcl.c
@@ -7,6 +7,9 @@
#include "tss_constants.h"
+/* disable MSVC warnings on unused arguments */
+__pragma(warning (disable: 4100))
+
void TlclLibInit(void) { return; }
uint32_t TlclStartup(void) { return TPM_SUCCESS; }
uint32_t TlclSelftestfull(void) { return TPM_SUCCESS; }
diff --git a/firmware/stub/utility_stub.c b/firmware/stub/utility_stub.c
index a41e3a3d..1445008c 100644
--- a/firmware/stub/utility_stub.c
+++ b/firmware/stub/utility_stub.c
@@ -48,13 +48,14 @@ int Memcmp(const void* src1, const void* src2, size_t n) {
return memcmp(src1, src2, n);
}
-void* Memcpy(void* dest, const void* src, size_t n) {
- return memcpy(dest, src, n);
+void* Memcpy(void* dest, const void* src, uint64_t n) {
+ return memcpy(dest, src, (size_t)n);
}
-void* Memset(void* dest, const uint8_t c, size_t n) {
+void* Memset(void* d, const uint8_t c, uint64_t n) {
+ uint8_t *dest = d; /* the only way to keep both cl and gcc happy */
while (n--) {
- *((uint8_t*)dest++) = c;
+ *dest++ = c;
}
return dest;
}
diff --git a/firmware/version.c b/firmware/version.c
index faadabaa..5fb57f5a 100644
--- a/firmware/version.c
+++ b/firmware/version.c
@@ -1 +1 @@
-char* VbootVersion = "VBOOv=c6976ffa";
+char* VbootVersion = "VBOOv=0c991073";