Massive refactoring of external header files.

This reduces the number of exported header files to the minimum needed by
the existing userspace utilities and firmware implementations.

BUG=chromium:221544
BRANCH=none
TEST=manual, trybots
CQ-DEPEND=CL:47019,CL:47022,CL:47023

  sudo FEATURES=test emerge vboot_reference
  FEATURES=test emerge-$BOARD \
                vboot_reference \
                chromeos-cryptohome \
                chromeos-installer \
                chromeos-u-boot \
                peach-u-boot \
                depthcharge

Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47021
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/Makefile b/Makefile
index 9467779..d1708ef 100644
--- a/Makefile
+++ b/Makefile
@@ -160,6 +160,9 @@
 # Create / use dependency files
 CFLAGS += -MMD -MF $@.d
 
+# These are required to access large disks and files on 32-bit systems.
+CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+
 # Code coverage
 ifneq (${COV},)
   COV_FLAGS = -O0 --coverage
@@ -659,8 +662,9 @@
 hostlib: ${HOSTLIB} ${BUILD}/host/linktest/main
 
 ${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
-	-Ihost/include\
-	-Ihost/arch/${ARCH}/include
+	-Ihost/include \
+	-Ihost/arch/${ARCH}/include \
+	-Ihost/lib/include
 
 # TODO: better way to make .a than duplicating this recipe each time?
 ${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS}
@@ -687,6 +691,8 @@
 .PHONY: cgpt
 cgpt: ${CGPT}
 
+${CGPT_OBJS}: INCLUDES += -Ihost/include
+
 ${CGPT}: LDFLAGS += -static
 ${CGPT}: LDLIBS += -luuid
 
@@ -704,7 +710,10 @@
 # Utilities
 
 # These have their own headers too.
-${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include
+${BUILD}/utility/%: INCLUDES += \
+	-Ihost/include \
+	-Ihost/lib/include \
+	-Iutility/include
 
 # Utilities for auto-update toolkits must be statically linked.
 ${UTIL_BINS_STATIC}: LDFLAGS += -static
@@ -855,7 +864,7 @@
 
 # Allow multiple definitions, so tests can mock functions from other libraries
 ${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
-${BUILD}/tests/%: INCLUDES += -Ihost/include
+${BUILD}/tests/%: INCLUDES += -Ihost/include -Ihost/lib/include
 ${BUILD}/tests/%: LDLIBS += -lrt -luuid
 ${BUILD}/tests/%: LIBS += ${TESTLIB}
 
diff --git a/cgpt/cgpt.c b/cgpt/cgpt.c
index ac7aecd..a3b20d9 100644
--- a/cgpt/cgpt.c
+++ b/cgpt/cgpt.c
@@ -6,13 +6,14 @@
  * files for more details.
  */
 
-#include "cgpt.h"
-
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
 
+#include "cgpt.h"
+#include "vboot_host.h"
+
 const char* progname;
 const char* command;
 void (*uuid_generator)(uint8_t* buffer);
diff --git a/cgpt/cgpt.h b/cgpt/cgpt.h
index 4763092..3d09fb9 100644
--- a/cgpt/cgpt.h
+++ b/cgpt/cgpt.h
@@ -5,11 +5,6 @@
 #ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
 #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#define _FILE_OFFSET_BITS 64
 #include <fcntl.h>
 #include <features.h>
 #include <stdint.h>
@@ -20,13 +15,6 @@
 #include "cgptlib.h"
 
 
-// Just for clarity
-enum {
-  CGPT_OK = 0,
-  CGPT_FAILED,
-};
-
-
 struct legacy_partition {
   uint8_t  status;
   uint8_t  f_head;
@@ -67,19 +55,6 @@
 int DriveClose(struct drive *drive, int update_as_needed);
 int CheckValid(const struct drive *drive);
 
-/* GUID conversion functions. Accepted format:
- *
- *   "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
- *
- * At least GUID_STRLEN bytes should be reserved in 'str' (included the tailing
- * '\0').
- */
-#define GUID_STRLEN 37
-int StrToGuid(const char *str, Guid *guid);
-void GuidToStr(const Guid *guid, char *str, unsigned int buflen);
-int GuidEqual(const Guid *guid1, const Guid *guid2);
-int GuidIsZero(const Guid *guid);
-
 /* Constant global type values to compare against */
 extern const Guid guid_chromeos_firmware;
 extern const Guid guid_chromeos_kernel;
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c
index 684d4d2..eaf0b73 100644
--- a/cgpt/cgpt_add.c
+++ b/cgpt/cgpt_add.c
@@ -2,14 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <string.h>
 
-#include "cgptlib_internal.h"
-#include "cgpt_params.h"
 #define _STUB_IMPLEMENTATION_
+
+#include "cgpt.h"
+#include "cgpt_params.h"
+#include "cgptlib_internal.h"
 #include "utility.h"
+#include "vboot_host.h"
 
 static const char* DumpCgptAddParams(const CgptAddParams *params) {
   static char buf[256];
diff --git a/cgpt/cgpt_boot.c b/cgpt/cgpt_boot.c
index 4de9c4c..00b783f 100644
--- a/cgpt/cgpt_boot.c
+++ b/cgpt/cgpt_boot.c
@@ -11,7 +11,7 @@
 #include "cgpt_params.h"
 #include "cgptlib_internal.h"
 #include "endian.h"
-
+#include "vboot_host.h"
 
 int CgptGetBootPartitionNumber(CgptBootParams *params) {
   struct drive drive;
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index dc42d41..dec26d1 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -6,8 +6,6 @@
  * files for more details.
  */
 
-#include "cgpt.h"
-
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
@@ -22,8 +20,10 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
 #include "crc32.h"
+#include "vboot_host.h"
 
 void Error(const char *format, ...) {
   va_list ap;
diff --git a/cgpt/cgpt_create.c b/cgpt/cgpt_create.c
index f4d67d5..b0256c5 100644
--- a/cgpt/cgpt_create.c
+++ b/cgpt/cgpt_create.c
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
 
 #include <string.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
 
 int CgptCreate(CgptCreateParams *params) {
   struct drive drive;
diff --git a/cgpt/cgpt_find.c b/cgpt/cgpt_find.c
index 795eab6..c7c77b0 100644
--- a/cgpt/cgpt_find.c
+++ b/cgpt/cgpt_find.c
@@ -8,8 +8,8 @@
 #include <unistd.h>
 
 #include "cgpt.h"
-#include "cgpt_params.h"
 #include "cgptlib_internal.h"
+#include "vboot_host.h"
 
 #define BUFSIZE 1024
 // FIXME: currently we only support 512-byte sectors.
diff --git a/cgpt/cgpt_legacy.c b/cgpt/cgpt_legacy.c
index ac2d4f0..932fbb9 100644
--- a/cgpt/cgpt_legacy.c
+++ b/cgpt/cgpt_legacy.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <string.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
 
 int CgptLegacy(CgptLegacyParams *params) {
   struct drive drive;
diff --git a/cgpt/cgpt_params.h b/cgpt/cgpt_params.h
deleted file mode 100644
index 470e0ff..0000000
--- a/cgpt/cgpt_params.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
-#define VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
-
-#include "cgpt.h"
-
-// This file defines the internal methods that use the user-mode cgpt programatically.
-// This is the interface for the callers such as the cgpt tool or the C++ post installer
-// executable.
-
-typedef struct CgptCreateParams {
-  char *drive_name;
-  int zap;
-} CgptCreateParams;
-
-typedef struct CgptAddParams {
-  char *drive_name;
-  uint32_t partition;
-  uint64_t begin;
-  uint64_t size;
-  Guid type_guid;
-  Guid unique_guid;
-  char *label;
-  int successful;
-  int tries;
-  int priority;
-  uint16_t raw_value;
-  int set_begin;
-  int set_size;
-  int set_type;
-  int set_unique;
-  int set_successful;
-  int set_tries;
-  int set_priority;
-  int set_raw;
-} CgptAddParams;
-
-typedef struct CgptShowParams {
-  char *drive_name;
-  int numeric;
-  int verbose;
-  int quick;
-  uint32_t partition;
-  int single_item;
-  int debug;
-
-  // This is filled in by the relevant methods in CgptShow.c
-  int num_partitions;
-} CgptShowParams;
-
-typedef struct CgptRepairParams {
-  char *drive_name;
-  int verbose;
-} CgptRepairParams;
-
-typedef struct CgptBootParams {
-  char *drive_name;
-  uint32_t partition;
-  char *bootfile;
-  int create_pmbr;
-} CgptBootParams;
-
-typedef struct CgptPrioritizeParams {
-  char *drive_name;
-
-  uint32_t set_partition;
-  int set_friends;
-  int max_priority;
-  int orig_priority;
-} CgptPrioritizeParams;
-
-typedef struct CgptFindParams {
-  char *drive_name;
-
-  int verbose;
-  int set_unique;
-  int set_type;
-  int set_label;
-  int oneonly;
-  int numeric;
-  uint8_t *matchbuf;
-  uint64_t matchlen;
-  uint64_t matchoffset;
-  uint8_t *comparebuf;
-  Guid unique_guid;
-  Guid type_guid;
-  char *label;
-  int hits;
-  int match_partnum;           // 0 for no match, 1-N for match
-} CgptFindParams;
-
-typedef struct CgptLegacyParams {
-  char *drive_name;
-  int efipart;
-} CgptLegacyParams;
-
-// create related methods.
-int CgptCreate(CgptCreateParams *params);
-
-// add/attribute/details related methods
-int CgptAdd(CgptAddParams *params);
-int CgptSetAttributes(CgptAddParams *params);
-int CgptGetPartitionDetails(CgptAddParams *params);
-
-// boot related methods.
-int CgptBoot(CgptBootParams *params);
-int CgptGetBootPartitionNumber(CgptBootParams *params);
-
-// show/get related methods.
-int CgptShow(CgptShowParams *params);
-int CgptGetNumNonEmptyPartitions(CgptShowParams *params);
-
-// repair related methods.
-int CgptRepair(CgptRepairParams *params);
-
-// priority related methods.
-int CgptPrioritize(CgptPrioritizeParams *params);
-
-// find related methods.
-void CgptFind(CgptFindParams *params);
-
-// legacy related methods.
-int CgptLegacy(CgptLegacyParams *params);
-
-#endif  // VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
diff --git a/cgpt/cgpt_prioritize.c b/cgpt/cgpt_prioritize.c
index dd74ccf..7cd73c0 100644
--- a/cgpt/cgpt_prioritize.c
+++ b/cgpt/cgpt_prioritize.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <string.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
 
 //////////////////////////////////////////////////////////////////////////////
 // We need a sorted list of priority groups, where each element in the list
diff --git a/cgpt/cgpt_repair.c b/cgpt/cgpt_repair.c
index aeac0b9..e591c75 100644
--- a/cgpt/cgpt_repair.c
+++ b/cgpt/cgpt_repair.c
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
 
 #include <string.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
 
 int CgptRepair(CgptRepairParams *params) {
   struct drive drive;
diff --git a/cgpt/cgpt_show.c b/cgpt/cgpt_show.c
index 6c2160c..cb5e275 100644
--- a/cgpt/cgpt_show.c
+++ b/cgpt/cgpt_show.c
@@ -2,15 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #define __STDC_FORMAT_MACROS
 
 #include <string.h>
 
+#include "cgpt.h"
 #include "cgptlib_internal.h"
-#include "cgpt_params.h"
 #include "crc32.h"
+#include "vboot_host.h"
 
 /* Generate output like:
  *
diff --git a/cgpt/cmd_add.c b/cgpt/cmd_add.c
index 500633b..a48ab33 100644
--- a/cgpt/cmd_add.c
+++ b/cgpt/cmd_add.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_boot.c b/cgpt/cmd_boot.c
index d2e63b7..caa94bc 100644
--- a/cgpt/cmd_boot.c
+++ b/cgpt/cmd_boot.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_create.c b/cgpt/cmd_create.c
index c2b8adf..0d91b08 100644
--- a/cgpt/cmd_create.c
+++ b/cgpt/cmd_create.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_find.c b/cgpt/cmd_find.c
index 4b2964d..1a3dc69 100644
--- a/cgpt/cmd_find.c
+++ b/cgpt/cmd_find.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_legacy.c b/cgpt/cmd_legacy.c
index 593d2ec..a126949 100644
--- a/cgpt/cmd_legacy.c
+++ b/cgpt/cmd_legacy.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_prioritize.c b/cgpt/cmd_prioritize.c
index 05e7e0e..3a692b8 100644
--- a/cgpt/cmd_prioritize.c
+++ b/cgpt/cmd_prioritize.c
@@ -8,7 +8,8 @@
 #include <string.h>
 #include <uuid/uuid.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_repair.c b/cgpt/cmd_repair.c
index 3c31330..ac5578a 100644
--- a/cgpt/cmd_repair.c
+++ b/cgpt/cmd_repair.c
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #include <getopt.h>
 #include <string.h>
 
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/cgpt/cmd_show.c b/cgpt/cmd_show.c
index 2df199d..1b31f39 100644
--- a/cgpt/cmd_show.c
+++ b/cgpt/cmd_show.c
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "cgpt.h"
-
 #define __STDC_FORMAT_MACROS
 #include <getopt.h>
 #include <inttypes.h>
 #include <string.h>
-#include "cgpt_params.h"
+
+#include "cgpt.h"
+#include "vboot_host.h"
 
 static void Usage(void)
 {
diff --git a/firmware/include/bmpblk_header.h b/firmware/include/bmpblk_header.h
index 1b04bf7..4889a6a 100644
--- a/firmware/include/bmpblk_header.h
+++ b/firmware/include/bmpblk_header.h
@@ -41,11 +41,9 @@
  *  |        List of locale names             |
  *  +-----------------------------------------+
  */
-
 #ifndef VBOOT_REFERENCE_BMPBLK_HEADER_H_
 #define VBOOT_REFERENCE_BMPBLK_HEADER_H_
-
-#include "sysincludes.h"
+#include <stdint.h>
 
 #define BMPBLOCK_SIGNATURE      "$BMP"
 #define BMPBLOCK_SIGNATURE_SIZE (4)
@@ -130,14 +128,6 @@
 	FORMAT_FONT,
 } ImageFormat;
 
-/* Constants for ImageInfo.compression */
-typedef enum Compression {
-	COMPRESS_NONE = 0,
-	COMPRESS_EFIv1,           /* The x86 BIOS only supports this */
-	COMPRESS_LZMA1,           /* The ARM BIOS supports LZMA1 */
-	MAX_COMPRESS,
-} Compression;
-
 /*
  * These magic image names can be used in the .yaml file to indicate that the
  * ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
diff --git a/firmware/include/gbb_header.h b/firmware/include/gbb_header.h
index 5ab5121..43aa3e7 100644
--- a/firmware/include/gbb_header.h
+++ b/firmware/include/gbb_header.h
@@ -4,11 +4,9 @@
  *
  * Data structure of Google Binary Block (GBB)
  */
-
 #ifndef VBOOT_REFERENCE_GBB_HEADER_H_
 #define VBOOT_REFERENCE_GBB_HEADER_H_
-
-#include "sysincludes.h"
+#include <stdint.h>
 
 #define GBB_HEADER_SIZE    128
 
diff --git a/firmware/lib/cgptlib/include/gpt.h b/firmware/include/gpt.h
similarity index 98%
rename from firmware/lib/cgptlib/include/gpt.h
rename to firmware/include/gpt.h
index 0418655..fa53739 100644
--- a/firmware/lib/cgptlib/include/gpt.h
+++ b/firmware/include/gpt.h
@@ -9,8 +9,7 @@
  */
 #ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_
 #define VBOOT_REFERENCE_CGPTLIB_GPT_H_
-
-#include "sysincludes.h"
+#include <stdint.h>
 
 #define GPT_HEADER_SIGNATURE  "EFI PART"
 #define GPT_HEADER_SIGNATURE2 "CHROMEOS"
diff --git a/firmware/include/tlcl.h b/firmware/include/tlcl.h
index 5ce0563..a71136b 100644
--- a/firmware/include/tlcl.h
+++ b/firmware/include/tlcl.h
@@ -11,8 +11,8 @@
 
 #ifndef TPM_LITE_TLCL_H_
 #define TPM_LITE_TLCL_H_
+#include <stdint.h>
 
-#include "sysincludes.h"
 #include "tss_constants.h"
 
 /*****************************************************************************/
diff --git a/firmware/include/tss_constants.h b/firmware/include/tss_constants.h
index bcceded..883a5ad 100644
--- a/firmware/include/tss_constants.h
+++ b/firmware/include/tss_constants.h
@@ -5,11 +5,9 @@
  * Some TPM constants and type definitions for standalone compilation for use
  * in the firmware
  */
-
 #ifndef VBOOT_REFERENCE_TSS_CONSTANTS_H_
 #define VBOOT_REFERENCE_TSS_CONSTANTS_H_
-
-#include "sysincludes.h"
+#include <stdint.h>
 
 #define TPM_MAX_COMMAND_SIZE 4096
 #define TPM_LARGE_ENOUGH_COMMAND_SIZE 256  /* saves space in the firmware */
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 31e91a7..dc8be1c 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -21,9 +21,7 @@
 
 #ifndef VBOOT_REFERENCE_VBOOT_API_H_
 #define VBOOT_REFERENCE_VBOOT_API_H_
-
-#include "sysincludes.h"
-#include "bmpblk_header.h"
+#include <stdint.h>
 
 /*****************************************************************************/
 /* Error codes */
@@ -814,6 +812,14 @@
                          uint32_t compression_type,
                          void *outbuf, uint32_t *out_size);
 
+/* Constants for compression_type */
+enum {
+	COMPRESS_NONE = 0,
+	COMPRESS_EFIv1,           /* The x86 BIOS only supports this */
+	COMPRESS_LZMA1,           /* The ARM BIOS supports LZMA1 */
+	MAX_COMPRESS,
+};
+
 /**
  * Execute legacy boot option.
  */
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index 943a566..e6b014a 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.h
@@ -7,6 +7,7 @@
 
 #ifndef VBOOT_REFERENCE_NVSTORAGE_H_
 #define VBOOT_REFERENCE_NVSTORAGE_H_
+#include <stdint.h>
 
 #define VBNV_BLOCK_SIZE 16  /* Size of NV storage block in bytes */
 
diff --git a/firmware/include/vboot_struct.h b/firmware/include/vboot_struct.h
index ee912a3..e20b0aa 100644
--- a/firmware/include/vboot_struct.h
+++ b/firmware/include/vboot_struct.h
@@ -8,8 +8,7 @@
 
 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_
 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_
-
-#include "sysincludes.h"
+#include <stdint.h>
 
 /* Public key data */
 typedef struct VbPublicKey {
diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c
index 370530f..6fc29f6 100644
--- a/firmware/lib/cgptlib/cgptlib.c
+++ b/firmware/lib/cgptlib/cgptlib.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "cgptlib.h"
 #include "cgptlib_internal.h"
 #include "crc32.h"
diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c
index d51ce33..c87f981 100644
--- a/firmware/lib/cgptlib/cgptlib_internal.c
+++ b/firmware/lib/cgptlib/cgptlib_internal.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "cgptlib.h"
 #include "cgptlib_internal.h"
 #include "crc32.h"
diff --git a/firmware/lib/cgptlib/crc32.c b/firmware/lib/cgptlib/crc32.c
index 002c5b9..286cfa0 100644
--- a/firmware/lib/cgptlib/crc32.c
+++ b/firmware/lib/cgptlib/crc32.c
@@ -39,6 +39,8 @@
 /*      polynomial $edb88320                                              */
 /*                                                                        */
 /*  --------------------------------------------------------------------  */
+#include "sysincludes.h"
+
 #include "crc32.h"
 
 static uint32_t crc32_tab[] = {
diff --git a/firmware/lib/crc8.c b/firmware/lib/crc8.c
index b0ee867..0e38e1e 100644
--- a/firmware/lib/crc8.c
+++ b/firmware/lib/crc8.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "crc8.h"
 
 /**
diff --git a/firmware/lib/cryptolib/padding.c b/firmware/lib/cryptolib/padding.c
index 24b1c15..4fc939a 100644
--- a/firmware/lib/cryptolib/padding.c
+++ b/firmware/lib/cryptolib/padding.c
@@ -5,6 +5,8 @@
  * arrays corresponding to various combinations of algorithms for RSA signatures.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 
 
diff --git a/firmware/lib/cryptolib/rsa.c b/firmware/lib/cryptolib/rsa.c
index 897816e..6d61a21 100644
--- a/firmware/lib/cryptolib/rsa.c
+++ b/firmware/lib/cryptolib/rsa.c
@@ -8,6 +8,8 @@
  * support multiple RSA key lengths and hash digest algorithms.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "vboot_api.h"
 #include "utility.h"
diff --git a/firmware/lib/cryptolib/rsa_utility.c b/firmware/lib/cryptolib/rsa_utility.c
index ab4650c..f6eefe2 100644
--- a/firmware/lib/cryptolib/rsa_utility.c
+++ b/firmware/lib/cryptolib/rsa_utility.c
@@ -5,6 +5,8 @@
  * Implementation of RSA utility functions.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "stateful_util.h"
 #include "utility.h"
diff --git a/firmware/lib/cryptolib/sha1.c b/firmware/lib/cryptolib/sha1.c
index 0a3f8f6..b34b8a9 100644
--- a/firmware/lib/cryptolib/sha1.c
+++ b/firmware/lib/cryptolib/sha1.c
@@ -6,6 +6,8 @@
  * Open Source Project (platorm/system/core.git/libmincrypt/sha.c
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "utility.h"
 
diff --git a/firmware/lib/cryptolib/sha256.c b/firmware/lib/cryptolib/sha256.c
index 6d3c08d..664b876 100644
--- a/firmware/lib/cryptolib/sha256.c
+++ b/firmware/lib/cryptolib/sha256.c
@@ -35,6 +35,8 @@
  * SUCH DAMAGE.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "utility.h"
 
diff --git a/firmware/lib/cryptolib/sha512.c b/firmware/lib/cryptolib/sha512.c
index 66c9a35..96b2bef 100644
--- a/firmware/lib/cryptolib/sha512.c
+++ b/firmware/lib/cryptolib/sha512.c
@@ -35,6 +35,8 @@
  * SUCH DAMAGE.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "utility.h"
 
diff --git a/firmware/lib/cryptolib/sha_utility.c b/firmware/lib/cryptolib/sha_utility.c
index bd7e140..6c7aa49 100644
--- a/firmware/lib/cryptolib/sha_utility.c
+++ b/firmware/lib/cryptolib/sha_utility.c
@@ -5,6 +5,8 @@
  * Utility functions for message digest functions.
  */
 
+#include "sysincludes.h"
+
 #include "cryptolib.h"
 #include "utility.h"
 #include "vboot_api.h"
diff --git a/firmware/include/load_firmware_fw.h b/firmware/lib/include/load_firmware_fw.h
similarity index 97%
rename from firmware/include/load_firmware_fw.h
rename to firmware/lib/include/load_firmware_fw.h
index f582e88..555cf6f 100644
--- a/firmware/include/load_firmware_fw.h
+++ b/firmware/lib/include/load_firmware_fw.h
@@ -9,7 +9,6 @@
 #ifndef VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_
 #define VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_
 
-#include "sysincludes.h"
 #include "vboot_api.h"
 #include "vboot_nvstorage.h"
 #include "vboot_struct.h"
diff --git a/firmware/include/load_kernel_fw.h b/firmware/lib/include/load_kernel_fw.h
similarity index 98%
rename from firmware/include/load_kernel_fw.h
rename to firmware/lib/include/load_kernel_fw.h
index 7439e57..dd6e1a8 100644
--- a/firmware/include/load_kernel_fw.h
+++ b/firmware/lib/include/load_kernel_fw.h
@@ -9,7 +9,6 @@
 #ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_
 #define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_
 
-#include "sysincludes.h"
 #include "vboot_api.h"
 #include "vboot_nvstorage.h"
 
diff --git a/firmware/include/sysincludes.h b/firmware/lib/include/sysincludes.h
similarity index 100%
rename from firmware/include/sysincludes.h
rename to firmware/lib/include/sysincludes.h
diff --git a/firmware/include/utility.h b/firmware/lib/include/utility.h
similarity index 100%
rename from firmware/include/utility.h
rename to firmware/lib/include/utility.h
diff --git a/firmware/lib/mocked_rollback_index.c b/firmware/lib/mocked_rollback_index.c
index 65dfd4d..e866f13 100644
--- a/firmware/lib/mocked_rollback_index.c
+++ b/firmware/lib/mocked_rollback_index.c
@@ -6,6 +6,8 @@
  * stored in the TPM NVRAM.
  */
 
+#include "sysincludes.h"
+
 #include "rollback_index.h"
 
 #include "tss_constants.h"
diff --git a/firmware/lib/mocked_tpm_bootmode.c b/firmware/lib/mocked_tpm_bootmode.c
index b42c2c7..e9d82de 100644
--- a/firmware/lib/mocked_tpm_bootmode.c
+++ b/firmware/lib/mocked_tpm_bootmode.c
@@ -5,8 +5,9 @@
  * Functions for updating the TPM state with the status of boot path.
  */
 
-#include "tpm_bootmode.h"
+#include "sysincludes.h"
 
+#include "tpm_bootmode.h"
 #include "tss_constants.h"
 
 const char* kBootStateSHA1Digests[] = {
diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c
index e430bea..3744f4b 100644
--- a/firmware/lib/rollback_index.c
+++ b/firmware/lib/rollback_index.c
@@ -6,6 +6,8 @@
  * stored in the TPM NVRAM.
  */
 
+#include "sysincludes.h"
+
 #include "crc8.h"
 #include "rollback_index.h"
 #include "tlcl.h"
diff --git a/firmware/lib/stateful_util.c b/firmware/lib/stateful_util.c
index 6db03fc..fbbc48c 100644
--- a/firmware/lib/stateful_util.c
+++ b/firmware/lib/stateful_util.c
@@ -5,6 +5,8 @@
  * Implementations of stateful memory operations.
  */
 
+#include "sysincludes.h"
+
 #include "stateful_util.h"
 #include "utility.h"
 
diff --git a/firmware/lib/tpm_bootmode.c b/firmware/lib/tpm_bootmode.c
index 218db20..a8e1a7c 100644
--- a/firmware/lib/tpm_bootmode.c
+++ b/firmware/lib/tpm_bootmode.c
@@ -5,9 +5,10 @@
  * Functions for updating the TPM state with the status of boot path.
  */
 
-#include "tpm_bootmode.h"
+#include "sysincludes.h"
 
 #include "tlcl.h"
+#include "tpm_bootmode.h"
 #include "utility.h"
 #include "vboot_api.h"
 
diff --git a/firmware/lib/tpm_lite/mocked_tlcl.c b/firmware/lib/tpm_lite/mocked_tlcl.c
index e977cd5..2657cb6 100644
--- a/firmware/lib/tpm_lite/mocked_tlcl.c
+++ b/firmware/lib/tpm_lite/mocked_tlcl.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "tlcl.h"
 #include "tlcl_internal.h"
 #include "utility.h"
diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c
index 50b3877..c015e89 100644
--- a/firmware/lib/tpm_lite/tlcl.c
+++ b/firmware/lib/tpm_lite/tlcl.c
@@ -15,6 +15,7 @@
  */
 
 #include "sysincludes.h"
+
 #include "tlcl.h"
 #include "tlcl_internal.h"
 #include "tlcl_structures.h"
diff --git a/firmware/lib/utility.c b/firmware/lib/utility.c
index 66b8eff..2f8c90d 100644
--- a/firmware/lib/utility.c
+++ b/firmware/lib/utility.c
@@ -6,6 +6,7 @@
  */
 
 #include "sysincludes.h"
+
 #include "utility.h"
 
 int SafeMemcmp(const void *s1, const void *s2, size_t n) {
diff --git a/firmware/lib/utility_string.c b/firmware/lib/utility_string.c
index 4a7e3e3..361d180 100644
--- a/firmware/lib/utility_string.c
+++ b/firmware/lib/utility_string.c
@@ -6,6 +6,7 @@
  */
 
 #include "sysincludes.h"
+
 #include "utility.h"
 
 
diff --git a/firmware/lib/vboot_api_firmware.c b/firmware/lib/vboot_api_firmware.c
index 5889e93..e0c93a3 100644
--- a/firmware/lib/vboot_api_firmware.c
+++ b/firmware/lib/vboot_api_firmware.c
@@ -5,6 +5,8 @@
  * High-level firmware wrapper API - entry points for init, firmware selection
  */
 
+#include "sysincludes.h"
+
 #include "gbb_header.h"
 #include "load_firmware_fw.h"
 #include "rollback_index.h"
diff --git a/firmware/lib/vboot_api_init.c b/firmware/lib/vboot_api_init.c
index 39c9056..b6c7064 100644
--- a/firmware/lib/vboot_api_init.c
+++ b/firmware/lib/vboot_api_init.c
@@ -5,6 +5,8 @@
  * High-level firmware wrapper API - entry points for init, firmware selection
  */
 
+#include "sysincludes.h"
+
 #include "gbb_header.h"
 #include "load_firmware_fw.h"
 #include "rollback_index.h"
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 483d47e..3f1dfc5 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -5,6 +5,8 @@
  * High-level firmware wrapper API - entry points for kernel selection
  */
 
+#include "sysincludes.h"
+
 #include "gbb_header.h"
 #include "load_kernel_fw.h"
 #include "rollback_index.h"
diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c
index d89bc43..2694b0e 100644
--- a/firmware/lib/vboot_audio.c
+++ b/firmware/lib/vboot_audio.c
@@ -5,6 +5,8 @@
  * Delay/beep functions used in dev-mode kernel selection.
  */
 
+#include "sysincludes.h"
+
 #include "crc32.h"
 #include "gbb_header.h"
 #include "utility.h"
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index 3e3375f..bd93710 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -6,6 +6,8 @@
  * (Firmware portion)
  */
 
+#include "sysincludes.h"
+
 #include "vboot_api.h"
 #include "vboot_common.h"
 #include "utility.h"
diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c
index 9d6670e..0e5e9f3 100644
--- a/firmware/lib/vboot_common_init.c
+++ b/firmware/lib/vboot_common_init.c
@@ -6,6 +6,8 @@
  * (Firmware portion)
  */
 
+#include "sysincludes.h"
+
 #include "vboot_api.h"
 #include "vboot_common.h"
 #include "utility.h"
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index adf4a3f..f79dfe1 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -5,6 +5,8 @@
  * Display functions used in kernel selection.
  */
 
+#include "sysincludes.h"
+
 #include "bmpblk_font.h"
 #include "gbb_header.h"
 #include "utility.h"
diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c
index 405a545..8d165f2 100644
--- a/firmware/lib/vboot_firmware.c
+++ b/firmware/lib/vboot_firmware.c
@@ -6,6 +6,8 @@
  * (Firmware portion)
  */
 
+#include "sysincludes.h"
+
 #include "gbb_header.h"
 #include "load_firmware_fw.h"
 #include "utility.h"
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 41d44f6..d63d4ee 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -6,6 +6,7 @@
  * (Firmware portion)
  */
 
+#include "sysincludes.h"
 
 #include "cgptlib.h"
 #include "cgptlib_internal.h"
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index 618c712..9b2eca1 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -5,6 +5,8 @@
 
 /* Non-volatile storage routines.
  */
+#include "sysincludes.h"
+
 
 #include "crc8.h"
 #include "utility.h"
diff --git a/firmware/linktest/main.c b/firmware/linktest/main.c
index c5ce2c1..2a55248 100644
--- a/firmware/linktest/main.c
+++ b/firmware/linktest/main.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "cgptlib.h"
 #include "load_firmware_fw.h"
 #include "load_kernel_fw.h"
diff --git a/firmware/linktest/main_vbinit.c b/firmware/linktest/main_vbinit.c
index a3d5019..0300c91 100644
--- a/firmware/linktest/main_vbinit.c
+++ b/firmware/linktest/main_vbinit.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "vboot_api.h"
 
 int main(void)
diff --git a/firmware/linktest/main_vbsf.c b/firmware/linktest/main_vbsf.c
index 1a3825a..db5c266 100644
--- a/firmware/linktest/main_vbsf.c
+++ b/firmware/linktest/main_vbsf.c
@@ -3,6 +3,8 @@
  * found in the LICENSE file.
  */
 
+#include "sysincludes.h"
+
 #include "vboot_api.h"
 
 int main(void)
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c
index 6818f2b..5e6c719 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -6,6 +6,8 @@
  * equivalents.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 #include "tlcl.h"
 #include "tlcl_internal.h"
@@ -24,6 +26,7 @@
 #include <time.h>
 #include <unistd.h>
 
+
 #define TPM_DEVICE_PATH "/dev/tpm0"
 /* Retry failed open()s for 5 seconds in 10ms polling intervals. */
 #define OPEN_RETRY_DELAY_NS (10 * 1000 * 1000)
diff --git a/firmware/stub/utility_stub.c b/firmware/stub/utility_stub.c
index 549ee85..a1daed0 100644
--- a/firmware/stub/utility_stub.c
+++ b/firmware/stub/utility_stub.c
@@ -6,6 +6,8 @@
  * equivalents.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 #include "utility.h"
 
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index fd531ac..36d5603 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -5,6 +5,8 @@
  * Stub implementations of firmware-provided API functions.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 
 #include <stdarg.h>
diff --git a/firmware/stub/vboot_api_stub_disk.c b/firmware/stub/vboot_api_stub_disk.c
index aca38af..186cd97 100644
--- a/firmware/stub/vboot_api_stub_disk.c
+++ b/firmware/stub/vboot_api_stub_disk.c
@@ -5,6 +5,8 @@
  * Stub implementations of disk APIs.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 
 #include <stdarg.h>
diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c
index 76052da..9e4f637 100644
--- a/firmware/stub/vboot_api_stub_init.c
+++ b/firmware/stub/vboot_api_stub_init.c
@@ -5,6 +5,8 @@
  * Stub implementations of firmware-provided API functions.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 
 #include <stdarg.h>
diff --git a/firmware/stub/vboot_api_stub_sf.c b/firmware/stub/vboot_api_stub_sf.c
index 96eeb85..e2f1c1a 100644
--- a/firmware/stub/vboot_api_stub_sf.c
+++ b/firmware/stub/vboot_api_stub_sf.c
@@ -5,6 +5,8 @@
  * Stub implementations of firmware-provided API functions.
  */
 
+#include <stdint.h>
+
 #define _STUB_IMPLEMENTATION_
 
 #include <stdarg.h>
diff --git a/futility/futility.c b/futility/futility.c
index c30e3e8..69ce57f 100644
--- a/futility/futility.c
+++ b/futility/futility.c
@@ -4,7 +4,6 @@
  * found in the LICENSE file.
  */
 
-#define _GNU_SOURCE
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c
index 23a3bce..85c5c6b 100644
--- a/host/arch/x86/lib/crossystem_arch.c
+++ b/host/arch/x86/lib/crossystem_arch.c
@@ -7,6 +7,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <linux/nvram.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/ioctl.h>
@@ -14,10 +15,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "host_common.h"
-
 #include "crossystem.h"
 #include "crossystem_arch.h"
+#include "host_common.h"
 #include "utility.h"
 #include "vboot_common.h"
 #include "vboot_nvstorage.h"
diff --git a/host/include/cgpt_params.h b/host/include/cgpt_params.h
new file mode 100644
index 0000000..c8567e5
--- /dev/null
+++ b/host/include/cgpt_params.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
+#define VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
+#include <stdint.h>
+
+#include "gpt.h"
+
+enum {
+  CGPT_OK = 0,
+  CGPT_FAILED,
+};
+
+typedef struct CgptCreateParams {
+  char *drive_name;
+  int zap;
+} CgptCreateParams;
+
+typedef struct CgptAddParams {
+  char *drive_name;
+  uint32_t partition;
+  uint64_t begin;
+  uint64_t size;
+  Guid type_guid;
+  Guid unique_guid;
+  char *label;
+  int successful;
+  int tries;
+  int priority;
+  uint16_t raw_value;
+  int set_begin;
+  int set_size;
+  int set_type;
+  int set_unique;
+  int set_successful;
+  int set_tries;
+  int set_priority;
+  int set_raw;
+} CgptAddParams;
+
+typedef struct CgptShowParams {
+  char *drive_name;
+  int numeric;
+  int verbose;
+  int quick;
+  uint32_t partition;
+  int single_item;
+  int debug;
+  int num_partitions;
+} CgptShowParams;
+
+typedef struct CgptRepairParams {
+  char *drive_name;
+  int verbose;
+} CgptRepairParams;
+
+typedef struct CgptBootParams {
+  char *drive_name;
+  uint32_t partition;
+  char *bootfile;
+  int create_pmbr;
+} CgptBootParams;
+
+typedef struct CgptPrioritizeParams {
+  char *drive_name;
+  uint32_t set_partition;
+  int set_friends;
+  int max_priority;
+  int orig_priority;
+} CgptPrioritizeParams;
+
+typedef struct CgptFindParams {
+  char *drive_name;
+  int verbose;
+  int set_unique;
+  int set_type;
+  int set_label;
+  int oneonly;
+  int numeric;
+  uint8_t *matchbuf;
+  uint64_t matchlen;
+  uint64_t matchoffset;
+  uint8_t *comparebuf;
+  Guid unique_guid;
+  Guid type_guid;
+  char *label;
+  int hits;
+  int match_partnum;           /* 1-based; 0 means no match */
+} CgptFindParams;
+
+typedef struct CgptLegacyParams {
+  char *drive_name;
+  int efipart;
+} CgptLegacyParams;
+
+#endif  // VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
diff --git a/host/include/crossystem.h b/host/include/crossystem.h
index 70e51d1..71acc84 100644
--- a/host/include/crossystem.h
+++ b/host/include/crossystem.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
diff --git a/host/include/vboot_host.h b/host/include/vboot_host.h
new file mode 100644
index 0000000..b22eea2
--- /dev/null
+++ b/host/include/vboot_host.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * vboot-related functions exported for use by userspace programs
+ */
+
+#ifndef VBOOT_HOST_H_
+#define VBOOT_HOST_H_
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/****************************************************************************/
+/* EFI GPT manipulation */
+
+#include "cgpt_params.h"
+
+/* partition table manipulation */
+int CgptCreate(CgptCreateParams *params);
+int CgptAdd(CgptAddParams *params);
+int CgptSetAttributes(CgptAddParams *params);
+int CgptGetPartitionDetails(CgptAddParams *params);
+int CgptBoot(CgptBootParams *params);
+int CgptGetBootPartitionNumber(CgptBootParams *params);
+int CgptShow(CgptShowParams *params);
+int CgptGetNumNonEmptyPartitions(CgptShowParams *params);
+int CgptRepair(CgptRepairParams *params);
+int CgptPrioritize(CgptPrioritizeParams *params);
+void CgptFind(CgptFindParams *params);
+int CgptLegacy(CgptLegacyParams *params);
+
+/* GUID conversion functions. Accepted format:
+ *
+ *   "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
+ *
+ * At least GUID_STRLEN bytes should be reserved in 'str' (included the tailing
+ * '\0').
+ */
+#define GUID_STRLEN 37
+int StrToGuid(const char *str, Guid *guid);
+void GuidToStr(const Guid *guid, char *str, unsigned int buflen);
+int GuidEqual(const Guid *guid1, const Guid *guid2);
+int GuidIsZero(const Guid *guid);
+
+
+/****************************************************************************/
+/* Kernel command line */
+
+/* TODO(wfrichar): This needs a better location */
+#define MAX_KERNEL_CONFIG_SIZE     4096
+
+/* Use this to obtain the body load address from the kernel preamble */
+#define USE_PREAMBLE_LOAD_ADDR     (~0)
+
+/* Returns a new copy of the kernel cmdline. The caller must free it. */
+char *FindKernelConfig(const char *filename,
+                       uint64_t kernel_body_load_address);
+
+/****************************************************************************/
+
+#endif  /* VBOOT_HOST_H_ */
diff --git a/host/include/crossystem_arch.h b/host/lib/include/crossystem_arch.h
similarity index 100%
rename from host/include/crossystem_arch.h
rename to host/lib/include/crossystem_arch.h
diff --git a/host/include/file_keys.h b/host/lib/include/file_keys.h
similarity index 100%
rename from host/include/file_keys.h
rename to host/lib/include/file_keys.h
diff --git a/host/include/fmap.h b/host/lib/include/fmap.h
similarity index 100%
rename from host/include/fmap.h
rename to host/lib/include/fmap.h
diff --git a/host/include/host_common.h b/host/lib/include/host_common.h
similarity index 100%
rename from host/include/host_common.h
rename to host/lib/include/host_common.h
diff --git a/host/include/host_key.h b/host/lib/include/host_key.h
similarity index 100%
rename from host/include/host_key.h
rename to host/lib/include/host_key.h
diff --git a/host/include/host_keyblock.h b/host/lib/include/host_keyblock.h
similarity index 100%
rename from host/include/host_keyblock.h
rename to host/lib/include/host_keyblock.h
diff --git a/host/include/host_misc.h b/host/lib/include/host_misc.h
similarity index 100%
rename from host/include/host_misc.h
rename to host/lib/include/host_misc.h
diff --git a/host/include/host_signature.h b/host/lib/include/host_signature.h
similarity index 100%
rename from host/include/host_signature.h
rename to host/lib/include/host_signature.h
diff --git a/host/include/signature_digest.h b/host/lib/include/signature_digest.h
similarity index 100%
rename from host/include/signature_digest.h
rename to host/lib/include/signature_digest.h
diff --git a/tests/big_firmware_tests.c b/tests/big_firmware_tests.c
index ca1dea8..efb81d1 100644
--- a/tests/big_firmware_tests.c
+++ b/tests/big_firmware_tests.c
@@ -6,6 +6,7 @@
  * is a quick and dirty test for detecting integer overflow issues.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/big_kernel_tests.c b/tests/big_kernel_tests.c
index cc4ceca..6d83aae 100644
--- a/tests/big_kernel_tests.c
+++ b/tests/big_kernel_tests.c
@@ -6,6 +6,7 @@
  * is a quick and dirty test for detecting integer overflow issues.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/firmware_image_tests.c b/tests/firmware_image_tests.c
index 96cf955..6201d47 100644
--- a/tests/firmware_image_tests.c
+++ b/tests/firmware_image_tests.c
@@ -5,6 +5,7 @@
  * Tests for firmware image library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/firmware_rollback_tests.c b/tests/firmware_rollback_tests.c
index 14c0475..09673a3 100644
--- a/tests/firmware_rollback_tests.c
+++ b/tests/firmware_rollback_tests.c
@@ -5,6 +5,7 @@
  * Tests for checking firmware rollback-prevention logic.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/firmware_splicing_tests.c b/tests/firmware_splicing_tests.c
index 97d16df..17c327f 100644
--- a/tests/firmware_splicing_tests.c
+++ b/tests/firmware_splicing_tests.c
@@ -5,6 +5,7 @@
  * Splicing tests for the firmware image verification library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/firmware_verify_benchmark.c b/tests/firmware_verify_benchmark.c
index 61f23ab..3cdceff 100644
--- a/tests/firmware_verify_benchmark.c
+++ b/tests/firmware_verify_benchmark.c
@@ -5,6 +5,7 @@
  * Timing benchmark for verifying a firmware image.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/kernel_image_tests.c b/tests/kernel_image_tests.c
index 4890de3..8125e68 100644
--- a/tests/kernel_image_tests.c
+++ b/tests/kernel_image_tests.c
@@ -5,6 +5,7 @@
  * Tests for kernel image library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/kernel_rollback_tests.c b/tests/kernel_rollback_tests.c
index 731d45c..2ecb05f 100644
--- a/tests/kernel_rollback_tests.c
+++ b/tests/kernel_rollback_tests.c
@@ -5,6 +5,7 @@
  * Tests for checking kernel rollback-prevention logic.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/kernel_splicing_tests.c b/tests/kernel_splicing_tests.c
index 241f109..296af47 100644
--- a/tests/kernel_splicing_tests.c
+++ b/tests/kernel_splicing_tests.c
@@ -5,6 +5,7 @@
  * Splicing tests for the kernel image verification library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/kernel_verify_benchmark.c b/tests/kernel_verify_benchmark.c
index c16dfcb..3ba113c 100644
--- a/tests/kernel_verify_benchmark.c
+++ b/tests/kernel_verify_benchmark.c
@@ -5,6 +5,7 @@
  * Timing benchmark for verifying a firmware image.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/rollback_index2_tests.c b/tests/rollback_index2_tests.c
index d5f2974..1a07cb0 100644
--- a/tests/rollback_index2_tests.c
+++ b/tests/rollback_index2_tests.c
@@ -5,6 +5,7 @@
  * Tests for rollback_index functions
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/rollback_index3_tests.c b/tests/rollback_index3_tests.c
index 30af89d..9434a5a 100644
--- a/tests/rollback_index3_tests.c
+++ b/tests/rollback_index3_tests.c
@@ -5,6 +5,7 @@
  * Tests for do-nothing rollback_index functions with disabled TPM
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/rollback_index_test.c b/tests/rollback_index_test.c
index a86ebde..d84b8ea 100644
--- a/tests/rollback_index_test.c
+++ b/tests/rollback_index_test.c
@@ -35,6 +35,7 @@
 #include "utility.h"
 
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
diff --git a/tests/rsa_padding_test.c b/tests/rsa_padding_test.c
index fa04dac..2f2423b 100644
--- a/tests/rsa_padding_test.c
+++ b/tests/rsa_padding_test.c
@@ -4,6 +4,7 @@
  */
 
 
+#include <stdint.h>
 #include <stdio.h>
 
 #include "cryptolib.h"
diff --git a/tests/rsa_utility_tests.c b/tests/rsa_utility_tests.c
index 8944652..47c483b 100644
--- a/tests/rsa_utility_tests.c
+++ b/tests/rsa_utility_tests.c
@@ -4,6 +4,7 @@
  */
 
 
+#include <stdint.h>
 #include <stdio.h>
 
 #define _STUB_IMPLEMENTATION_
diff --git a/tests/rsa_verify_benchmark.c b/tests/rsa_verify_benchmark.c
index b359b62..7b27f9e 100644
--- a/tests/rsa_verify_benchmark.c
+++ b/tests/rsa_verify_benchmark.c
@@ -3,6 +3,7 @@
  * found in the LICENSE file.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/sha_benchmark.c b/tests/sha_benchmark.c
index a5bfc53..2193b78 100644
--- a/tests/sha_benchmark.c
+++ b/tests/sha_benchmark.c
@@ -3,6 +3,7 @@
  * found in the LICENSE file.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/sha_tests.c b/tests/sha_tests.c
index b462ccc..ad85b9e 100644
--- a/tests/sha_tests.c
+++ b/tests/sha_tests.c
@@ -5,6 +5,7 @@
 
 /* FIPS 180-2 Tests for message digest functions. */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/stateful_util_tests.c b/tests/stateful_util_tests.c
index e41feac..9a306d5 100644
--- a/tests/stateful_util_tests.c
+++ b/tests/stateful_util_tests.c
@@ -5,6 +5,7 @@
  * Tests for statful_util functions.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/test_common.c b/tests/test_common.c
index e57fe21..2fa445f 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -7,6 +7,7 @@
 
 #include "test_common.h"
 
+#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 
diff --git a/tests/tlcl_tests.c b/tests/tlcl_tests.c
index 4765cff..ef543d4 100644
--- a/tests/tlcl_tests.c
+++ b/tests/tlcl_tests.c
@@ -5,6 +5,7 @@
  * Tests for TPM lite library
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/tpm_bootmode_tests.c b/tests/tpm_bootmode_tests.c
index 48552c5..c39094d 100644
--- a/tests/tpm_bootmode_tests.c
+++ b/tests/tpm_bootmode_tests.c
@@ -5,6 +5,7 @@
  * Tests for tpm_bootmode functions
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/tpm_lite/tlcl_tests.c b/tests/tpm_lite/tlcl_tests.c
index 59180e4..f36021f 100644
--- a/tests/tpm_lite/tlcl_tests.c
+++ b/tests/tpm_lite/tlcl_tests.c
@@ -6,6 +6,8 @@
 /* Shared code for tests.
  */
 
+#include "sysincludes.h"
+
 #include "tlcl.h"
 #include "tlcl_tests.h"
 
diff --git a/tests/utility_string_tests.c b/tests/utility_string_tests.c
index fe11d70..d760193 100644
--- a/tests/utility_string_tests.c
+++ b/tests/utility_string_tests.c
@@ -5,6 +5,7 @@
  * Tests for string utility functions.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/utility_tests.c b/tests/utility_tests.c
index 7e21c77..978f768 100644
--- a/tests/utility_tests.c
+++ b/tests/utility_tests.c
@@ -5,6 +5,7 @@
  * Tests for utility functions
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index af20030..b10bba6 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -6,6 +6,7 @@
  */
 
 #include <stddef.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_firmware_tests.c b/tests/vboot_api_firmware_tests.c
index a31b532..9e7c441 100644
--- a/tests/vboot_api_firmware_tests.c
+++ b/tests/vboot_api_firmware_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_api_firmware
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_init_tests.c b/tests/vboot_api_init_tests.c
index 7834b90..e04554a 100644
--- a/tests/vboot_api_init_tests.c
+++ b/tests/vboot_api_init_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_api_init
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index 9b921cd..aa3e20d 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_api_kernel, part 2
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_kernel3_tests.c b/tests/vboot_api_kernel3_tests.c
index 9ec6f19..5b69845 100644
--- a/tests/vboot_api_kernel3_tests.c
+++ b/tests/vboot_api_kernel3_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_api_kernel, part 3 - software sync
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c
index 414279e..af8d2b6 100644
--- a/tests/vboot_api_kernel4_tests.c
+++ b/tests/vboot_api_kernel4_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_api_kernel, part 4 - select and load kernel
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c
index 8c04814..56cb210 100644
--- a/tests/vboot_api_kernel_tests.c
+++ b/tests/vboot_api_kernel_tests.c
@@ -6,6 +6,7 @@
  */
 
 #include <stddef.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_audio_tests.c b/tests/vboot_audio_tests.c
index a1ecf71..23667b1 100644
--- a/tests/vboot_audio_tests.c
+++ b/tests/vboot_audio_tests.c
@@ -6,6 +6,7 @@
  */
 
 #include <stddef.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_common2_tests.c b/tests/vboot_common2_tests.c
index b154e50..564518a 100644
--- a/tests/vboot_common2_tests.c
+++ b/tests/vboot_common2_tests.c
@@ -5,6 +5,7 @@
  * Tests for firmware image library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/vboot_common3_tests.c b/tests/vboot_common3_tests.c
index c4f81cd..b5499f6 100644
--- a/tests/vboot_common3_tests.c
+++ b/tests/vboot_common3_tests.c
@@ -5,6 +5,7 @@
  * Tests for firmware image library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c
index df4fdc2..852be79 100644
--- a/tests/vboot_common_tests.c
+++ b/tests/vboot_common_tests.c
@@ -5,6 +5,7 @@
  * Tests for firmware vboot_common.c
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c
index 3093534..8e4a3a2 100644
--- a/tests/vboot_display_tests.c
+++ b/tests/vboot_display_tests.c
@@ -5,6 +5,7 @@
  * Tests for firmware display library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/vboot_firmware_tests.c b/tests/vboot_firmware_tests.c
index 24a6c28..f6b96fe 100644
--- a/tests/vboot_firmware_tests.c
+++ b/tests/vboot_firmware_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_firmware library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tests/vboot_kernel_tests.c b/tests/vboot_kernel_tests.c
index 1ee1528..6992e94 100644
--- a/tests/vboot_kernel_tests.c
+++ b/tests/vboot_kernel_tests.c
@@ -5,6 +5,7 @@
  * Tests for vboot_kernel.c
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/vboot_nvstorage_test.c b/tests/vboot_nvstorage_test.c
index 91e8a89..7ffec61 100644
--- a/tests/vboot_nvstorage_test.c
+++ b/tests/vboot_nvstorage_test.c
@@ -5,6 +5,7 @@
  * Tests for firmware NV storage library.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tests/verify_firmware_fuzz_driver.c b/tests/verify_firmware_fuzz_driver.c
index f04a7d5..3868d74 100644
--- a/tests/verify_firmware_fuzz_driver.c
+++ b/tests/verify_firmware_fuzz_driver.c
@@ -5,6 +5,7 @@
  * Utility for aiding fuzz testing of firmware image verification code.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 
 #include "file_keys.h"
diff --git a/tests/verify_kernel_fuzz_driver.c b/tests/verify_kernel_fuzz_driver.c
index 1027263..e429f5e 100644
--- a/tests/verify_kernel_fuzz_driver.c
+++ b/tests/verify_kernel_fuzz_driver.c
@@ -5,6 +5,7 @@
  * Utility for aiding fuzz testing of kernel image verification code.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 
 #include "file_keys.h"
diff --git a/utility/bmpblk_font.c b/utility/bmpblk_font.c
index 493e87f..75c3385 100644
--- a/utility/bmpblk_font.c
+++ b/utility/bmpblk_font.c
@@ -7,6 +7,7 @@
 #include <getopt.h>
 #include <limits.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -17,6 +18,7 @@
 
 #include "bmpblk_font.h"
 #include "image_types.h"
+#include "vboot_api.h"
 
 static char *progname;
 
diff --git a/utility/bmpblk_util.c b/utility/bmpblk_util.c
index 49573af..abcac0d 100644
--- a/utility/bmpblk_util.c
+++ b/utility/bmpblk_util.c
@@ -6,6 +6,8 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <lzma.h>
+#include <stdint.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -15,7 +17,7 @@
 
 #include "bmpblk_util.h"
 #include "eficompress.h"
-
+#include "vboot_api.h"
 
 // Returns pointer to buffer containing entire file, sets length.
 static void *read_entire_file(const char *filename, size_t *length) {
diff --git a/utility/bmpblk_utility.cc b/utility/bmpblk_utility.cc
index ea04c22..b3af141 100644
--- a/utility/bmpblk_utility.cc
+++ b/utility/bmpblk_utility.cc
@@ -5,19 +5,21 @@
 // Utility for manipulating firmware screen block (BMPBLOCK) in GBB.
 //
 
-#include "bmpblk_utility.h"
-#include "image_types.h"
-
 #include <assert.h>
 #include <errno.h>
 #include <getopt.h>
 #include <lzma.h>
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <yaml.h>
 
+#include "bmpblk_utility.h"
+#include "image_types.h"
+#include "vboot_api.h"
+
 extern "C" {
 #include "eficompress.h"
 }
diff --git a/utility/dump_kernel_config.c b/utility/dump_kernel_config.c
index e733a0d..ec0ee5a 100644
--- a/utility/dump_kernel_config.c
+++ b/utility/dump_kernel_config.c
@@ -11,9 +11,7 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
-#include "dump_kernel_config.h"
-#include "kernel_blob.h"
-#include "vboot_api.h"
+#include "vboot_host.h"
 
 enum {
   OPT_KLOADADDR = 1000,
@@ -76,7 +74,7 @@
     return PrintHelp();
 
   if (!infile || !*infile) {
-    VbExError("Must specify filename\n");
+    fprintf(stderr, "Must specify filename\n");
     return 1;
   }
 
diff --git a/utility/dump_kernel_config_lib.c b/utility/dump_kernel_config_lib.c
index 464e349..819ca92 100644
--- a/utility/dump_kernel_config_lib.c
+++ b/utility/dump_kernel_config_lib.c
@@ -9,10 +9,10 @@
 #include <string.h>
 #include <sys/mman.h>
 
-#include "dump_kernel_config.h"
 #include "host_common.h"
 #include "kernel_blob.h"
 #include "vboot_api.h"
+#include "vboot_host.h"
 
 static uint8_t* GetKernelConfig(uint8_t* blob, size_t blob_size,
                                 uint64_t kernel_body_load_address) {
diff --git a/utility/gbb_utility.cc b/utility/gbb_utility.cc
index e68bd9b..980521c 100644
--- a/utility/gbb_utility.cc
+++ b/utility/gbb_utility.cc
@@ -5,10 +5,9 @@
 // Utility for manipulating Google Binary Block (GBB)
 //
 
-#include "gbb_utility.h"
-
 #include <assert.h>
 #include <getopt.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -17,6 +16,8 @@
 #include <vector>
 #include <algorithm>
 
+#include "gbb_utility.h"
+
 using std::string;
 
 ///////////////////////////////////////////////////////////////////////
diff --git a/utility/include/dump_kernel_config.h b/utility/include/dump_kernel_config.h
deleted file mode 100644
index cacc561..0000000
--- a/utility/include/dump_kernel_config.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Exports the kernel commandline from a given partition/image file.
- */
-
-#ifndef DUMP_KERNEL_CONFIG_UTILITY_H_
-#define DUMP_KERNEL_CONFIG_UTILITY_H_
-
-#include <inttypes.h>
-#include <stdlib.h>
-
-/* TODO(wfrichar): This needs a better location */
-#define MAX_KERNEL_CONFIG_SIZE     4096
-
-/* Use this to obtain the body load address from the kernel preamble */
-#define USE_PREAMBLE_LOAD_ADDR     (~0)
-
-/* Returns a new copy of the kernel cmdline. The caller must free it. */
-char *FindKernelConfig(const char *filename,
-                       uint64_t kernel_body_load_address);
-
-#endif  // DUMP_KERNEL_CONFIG_UTILITY_H_
diff --git a/utility/tpm_init_temp_fix.c b/utility/tpm_init_temp_fix.c
index d3004a6..8964bee 100644
--- a/utility/tpm_init_temp_fix.c
+++ b/utility/tpm_init_temp_fix.c
@@ -17,6 +17,7 @@
  * "success" when everything worked.
  */
 
+#include <stdint.h>
 #include <stdio.h>
 #include <syslog.h>
 
diff --git a/utility/tpmc.c b/utility/tpmc.c
index 9302dd1..98004e8 100644
--- a/utility/tpmc.c
+++ b/utility/tpmc.c
@@ -9,6 +9,8 @@
  * for other errors.
  */
 
+#include <stdint.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <syslog.h>