aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-bsp/grub/files/clanton.patch2676
-rw-r--r--recipes-bsp/grub/grub_0.97.bb2
2 files changed, 1355 insertions, 1323 deletions
diff --git a/recipes-bsp/grub/files/clanton.patch b/recipes-bsp/grub/files/clanton.patch
index 1862533..2c4041e 100644
--- a/recipes-bsp/grub/files/clanton.patch
+++ b/recipes-bsp/grub/files/clanton.patch
@@ -40,15 +40,15 @@ index 4e19579..7d5ec92 100644
+/netboot/Makefile
+/stage1/Makefile
+
-diff --git a/ChangeLog-clanton b/ChangeLog-clanton
+diff --git a/ChangeLog-quark b/ChangeLog-quark
new file mode 100644
-index 0000000..3ca2f6f
+index 0000000..be8c8e1
--- /dev/null
-+++ b/ChangeLog-clanton
++++ b/ChangeLog-quark
@@ -0,0 +1,4 @@
+2012-08-21 Josef Ahmad <josef.ahmad@intel.com>
+
-+ * Add Clanton-specific changelog.
++ * Add Quark-specific changelog.
+ * efi/Makefile.am: generate link map file (RTC 20693).
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
@@ -678,18 +678,18 @@ index 6cff007..0000000
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
-diff --git a/README-clanton b/README-clanton
+diff --git a/README-quark b/README-quark
new file mode 100644
-index 0000000..5b5a278
+index 0000000..5d19da9
--- /dev/null
-+++ b/README-clanton
++++ b/README-quark
@@ -0,0 +1,8 @@
-+-- How to build Clanton GRUB --
++-- How to build Quark GRUB --
+
+1. Add crosscompiler to your PATH
+2. $> autoreconf
+3. $> autoconf
-+4. $> ./configure-clanton.sh
++4. $> ./configure-quark.sh
+5. $> make
+
diff --git a/aclocal.m4 b/aclocal.m4
@@ -4736,11 +4736,11 @@ index 987b17d..0000000
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
-diff --git a/configure-clanton.sh b/configure-clanton.sh
+diff --git a/configure-quark.sh b/configure-quark.sh
new file mode 100755
-index 0000000..0a754fb
+index 0000000..963a7e9
--- /dev/null
-+++ b/configure-clanton.sh
++++ b/configure-quark.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
@@ -4765,7 +4765,7 @@ index 0000000..0a754fb
+
+# Append to generic CFLAGS from environment-setup-i586-poky-linux-uclibc
+# Just like the GRUB.bb recipe does
-+export CFLAGS="$CFLAGS -Os -fno-strict-aliasing -Wall -Werror -Wno-shadow -Wno-unused -Wno-pointer-sign -DGRUB_CLN_DEBUG=1 -DINTEL_CLN_TEST=1"
++export CFLAGS="$CFLAGS -Os -fno-strict-aliasing -Wall -Werror -Wno-shadow -Wno-unused -Wno-pointer-sign -DGRUB_QUARK_DEBUG=1 -DINTEL_QUARK_TEST=1"
+
+./configure --host=i586-poky-linux-uclibc --without-curses --disable-auto-linux-mem-opt --with-platform=efi --libdir="${GNUEFI_LIBDIR}"
diff --git a/configure.in b/configure.in
@@ -11867,7 +11867,7 @@ index bcd1e9d..0000000
-
-End Tag Table
diff --git a/efi/Makefile.am b/efi/Makefile.am
-index 1d5bd15..3ae0ca5 100644
+index 1d5bd15..dfed940 100644
--- a/efi/Makefile.am
+++ b/efi/Makefile.am
@@ -30,7 +30,7 @@ endif
@@ -11884,22 +11884,569 @@ index 1d5bd15..3ae0ca5 100644
eficon.c efidisk.c graphics.c efigraph.c efiuga.c efidp.c \
font_8x16.c efiserial.c $(EFI_ARCH)/loader/linux.c efichainloader.c \
- xpm.c pxe.c efitftp.c
-+ xpm.c pxe.c efitftp.c clanton/boot_settings.c clanton/recovery.c \
-+ clanton/sdio_program.c clanton/mfh.c clanton/iarom.c \
-+ clanton/intel_cln_sb.c clanton/imr.c clanton/perf_metrics.c \
-+ clanton/asset.c clanton/spi_program.c clanton/test_module.c \
-+ clanton/early_uart.c
++ xpm.c pxe.c efitftp.c quark/boot_settings.c quark/recovery.c \
++ quark/sdio_program.c quark/mfh.c quark/iarom.c \
++ quark/intel_quark_sb.c quark/imr.c quark/perf_metrics.c \
++ quark/asset.c quark/spi_program.c quark/test_module.c \
++ quark/early_uart.c
libgrubefi_a_CFLAGS = $(RELOC_FLAGS) -nostdinc
endif
-diff --git a/efi/clanton/asset.c b/efi/clanton/asset.c
+diff --git a/efi/efidisk.c b/efi/efidisk.c
+index 2192021..015c57a 100644
+--- a/efi/efidisk.c
++++ b/efi/efidisk.c
+@@ -192,6 +192,10 @@ name_devices (struct grub_efidisk_data *devices)
+ continue;
+
+ m = d->block_io->media;
++ if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE)
++ {
++ add_device (&hd_devices, d);
++ }
+ if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE)
+ {
+ /* XXX FIXME this won't work if we see write-protected disks with
+diff --git a/efi/efidp.c b/efi/efidp.c
+index d8ca03d..f4ca452 100644
+--- a/efi/efidp.c
++++ b/efi/efidp.c
+@@ -578,7 +578,10 @@ dpname_matches(char *str, char *candidate)
+ return rc;
+ }
+
+-static void
++extern void
++finish_param_parse(char *pos, char **end, char *tmp);
++
++void
+ finish_param_parse(char *pos, char **end, char *tmp)
+ {
+ if (!pos || !end || !tmp)
+diff --git a/efi/efimain.c b/efi/efimain.c
+index e1a1e66..3bc4543 100644
+--- a/efi/efimain.c
++++ b/efi/efimain.c
+@@ -26,6 +26,8 @@
+ #include <shared.h>
+ #include <efistubs.h>
+
++#include <quark/perf_metrics.h>
++
+ #include "pxe.h"
+
+ #define GRUB_SCRATCH_MEM_PAGES (GRUB_SCRATCH_MEM_SIZE >> 12)
+@@ -77,8 +79,15 @@ real_main (void)
+ grub_efi_status_t
+ efi_main (grub_efi_handle_t image_handle, grub_efi_system_table_t *sys_tab)
+ {
++ grub_efi_boot_services_t *b;
++ grub_efi_status_t status;
++
+ grub_efi_image_handle = image_handle;
+ grub_efi_system_table = sys_tab;
++
++ /* Timestamp entry point. */
++ grub_quark_event_append (__func__);
++
+ grub_efi_init ();
+
+ grub_scratch_mem = grub_efi_allocate_pages (0, GRUB_SCRATCH_MEM_PAGES);
+@@ -108,6 +117,13 @@ efi_main (grub_efi_handle_t image_handle, grub_efi_system_table_t *sys_tab)
+ #endif
+ }
+
++ /* Disable watchdog before prompting for any user input. */
++ b = grub_efi_system_table->boot_services;
++ status = Call_Service_4 (b->set_watchdog_timer,
++ 0, 0xFFFF + 1, 0, NULL);
++ if (GRUB_EFI_SUCCESS != status)
++ grub_printf ("%s: set_watchdog_timer() returned 0x%08x\n", __func__, status);
++
+ real_main ();
+
+ if (real_stack) {
+diff --git a/efi/ia32/loader/linux.c b/efi/ia32/loader/linux.c
+index d795d28..8e92a58 100644
+--- a/efi/ia32/loader/linux.c
++++ b/efi/ia32/loader/linux.c
+@@ -23,15 +23,22 @@
+ #include <grub/efi/api.h>
+ #include <grub/efi/efi.h>
+ #include <grub/efi/misc.h>
++#include <quark/asset.h>
++#include <quark/quark.h>
++#include <quark/early_uart.h>
++#include <quark/flash.h>
++#include <quark/iarom.h>
++#include <quark/imr.h>
++#include <quark/mfh.h>
++#include <quark/perf_metrics.h>
++#include <quark/sbh.h>
++#include <quark/test_module.h>
+
+ #include "switch.h"
+-
+ #include <shared.h>
+
+ #include "graphics.h"
+
+-#define grub_file_size() filemax
+-
+ #define NEXT_MEMORY_DESCRIPTOR(desc, size) \
+ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
+
+@@ -44,6 +51,8 @@
+ #define SECTOR_BITS 9
+ #endif /* defined(SECTOR_BITS) */
+
++#define PAGE_SIZE 0x1000
++
+ static unsigned long linux_mem_size;
+ static int loaded;
+ static void *real_mode_mem;
+@@ -54,6 +63,15 @@ static grub_efi_uintn_t prot_mode_pages;
+ static grub_efi_uintn_t initrd_pages;
+ static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GRAPHICS_OUTPUT_GUID;
+
++/* If modules are in SPI/Flash, follow MFH path.
++ Else follow file system path. */
++unsigned short int grub_quark_linux_spi = 0;
++unsigned short int grub_quark_initrd_spi = 0;
++
++/* The Quark Secure Boot Header. */
++static struct grub_quark_sbh quark_sbh;
++static grub_uint32_t sbh_len = 0;
++
+ static inline grub_size_t
+ page_align (grub_size_t size)
+ {
+@@ -114,9 +132,14 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
+ /* Initialize the memory pointers with NULL for convenience. */
+ real_mode_mem = 0;
+ prot_mode_mem = 0;
++ initrd_mem = 0;
+
+ if (grub_efi_get_memory_map (0, &desc_size, 0) <= 0)
+- grub_fatal ("cannot get memory map");
++ {
++ grub_printf ("cannot get memory map");
++ errnum = ERR_BOOT_FAILURE;
++ return 0;
++ }
+
+ addr = 0;
+ mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap_buf, mmap_size);
+@@ -144,7 +167,11 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
+ (unsigned) real_mode_pages, (unsigned) addr);
+ real_mode_mem = grub_efi_allocate_pages (addr, real_mode_pages);
+ if (! real_mode_mem)
+- grub_fatal ("cannot allocate pages");
++ {
++ grub_printf ("cannot allocate pages");
++ errnum = ERR_WONT_FIT;
++ goto fail;
++ }
+
+ desc->num_pages -= real_mode_pages;
+ break;
+@@ -160,9 +187,14 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
+
+ /* Next, find free pages for the protected mode code. */
+ /* XXX what happens if anything is using this address? */
+- prot_mode_mem = grub_efi_allocate_pages (0x100000, prot_mode_pages);
++ prot_mode_mem = grub_efi_allocate_pages
++ (GRUB_LINUX_BZIMAGE_ADDR, prot_mode_pages);
+ if (! prot_mode_mem)
+- grub_fatal("Cannot allocate pages for VMLINUZ");
++ {
++ grub_printf ("Cannot allocate pages for VMLINUZ");
++ errnum = ERR_WONT_FIT;
++ goto fail;
++ }
+
+ return 1;
+
+@@ -224,7 +256,11 @@ big_linux_boot (void)
+ graphics_set_kernel_params (params);
+
+ if (grub_efi_get_memory_map (&map_key, &desc_size, &desc_version) <= 0)
+- grub_fatal ("cannot get memory map");
++ {
++ grub_printf ("cannot get memory map");
++ errnum = ERR_BOOT_FAILURE;
++ return;
++ }
+
+ /* Pass e820 memmap. */
+ e820_map_from_efi_map ((struct e820_entry *) params->e820_map, &e820_nr_map,
+@@ -232,8 +268,14 @@ big_linux_boot (void)
+ params->e820_nr_map = e820_nr_map;
+
+ grub_dprintf(__func__,"got to ExitBootServices...\n");
++
+ if (! grub_efi_exit_boot_services (map_key))
+- grub_fatal ("cannot exit boot services");
++ {
++ grub_printf ("cannot exit boot services");
++ errnum = ERR_BOOT_FAILURE;
++ return;
++ }
++
+ /* Note that no boot services are available from here. */
+
+ lh = &params->hdr;
+@@ -278,6 +320,13 @@ big_linux_boot (void)
+ grub_memset((void *)gdt_addr.base, gdt_addr.limit, 0);
+ grub_memcpy((void *)gdt_addr.base, init_gdt, sizeof (init_gdt));
+
++ /* This is the very last stage we can timestamp.
++ Do it and append performance metrics to the linux command line. */
++ grub_quark_event_append ("jmp_code32");
++ grub_strncat ((char *) real_mode_mem + 0x1000,
++ grub_quark_event_get_metrics (),
++ GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + 1);
++
+ if (0) {
+ /* copy our real mode transition code to 0x7C00 */
+ memcpy ((void *) 0x7C00, switch_image, switch_size);
+@@ -311,28 +360,80 @@ big_linux_boot (void)
+ for (;;);
+ }
+
++/*
++ Lexer to detect early Quark's UART MMIO token.
++ If token is found, expand it with the actual MMIO address.
++ */
++static void
++quark_detect_early_uart (char **cmdline)
++{
++ char *p = NULL;
++ char *start = *cmdline;
++ grub_uint32_t mmio;
++ grub_uint32_t offs = 0;
++
++ p = strstr(*cmdline, QUARK_UART_MMIO_TOKEN);
++ *cmdline = start;
++
++ if (NULL == p)
++ {
++ /* Nothing to do. */
++ return;
++ }
++
++ mmio = (grub_uint32_t)quark_early_uart_init();
++ if (!mmio)
++ {
++ grub_printf("%s: couldn't find device. Skipping..\n", __func__);
++ return;
++ }
++
++ if (grub_quark_debug)
++ grub_printf("%s: MMIO addr @ 0x%x\n", __func__, mmio);
++
++ offs = grub_sprintf(p, "0x%x", mmio);
++ grub_sprintf(p + offs, "%s", p + sizeof(QUARK_UART_MMIO_TOKEN) - 1);
++}
++
+ int
+ grub_load_linux (char *kernel, char *arg)
+ {
+ struct grub_linux_kernel_header *lh;
+ struct linux_kernel_params *params;
+ static struct linux_kernel_params params_buf;
+- grub_uint8_t setup_sects;
+- grub_size_t real_size, prot_size;
+- grub_ssize_t len;
+- char *dest;
++ grub_uint8_t setup_sects = 0;
++ grub_size_t real_size = 0, prot_size = 0, img_size = 0;
++ grub_uint32_t code32_start_offs = 0x0, prot_mode_offs = 0x0;;
++ grub_ssize_t len = 0;
++
++ sbh_len = 0;
+
+- if (kernel == NULL)
++ __quark_test_setup(arg);
++
++ /* In SPI/Flash mode, file system path to kernel is not required. */
++ if (! grub_quark_linux_spi && kernel == NULL)
+ {
+ errnum = ERR_BAD_FILENAME;
+ grub_printf ("no kernel specified");
+ goto fail1;
+ }
+
+- if (! grub_open (kernel))
++ if (grub_quark_secure)
++ {
++ if (! grub_quark_fetch_sbh (GRUB_QUARK_ASSET_KERNEL_CSBH, kernel, &quark_sbh))
++ {
++ if(ERR_FILE_NOT_FOUND == errnum
++ && ! grub_quark_linux_spi)
++ errnum = ERR_SGN_FILE_NOT_FOUND;
++ goto fail1;
++ }
++ sbh_len = quark_sbh.security_header.header_len;
++ }
++
++ if (! grub_quark_asset_open (GRUB_QUARK_ASSET_KERNEL, kernel))
+ goto fail1;
+
+- if (grub_read ((char *) &params_buf, sizeof (params_buf))
++ if (grub_quark_asset_read (GRUB_QUARK_ASSET_KERNEL, (grub_uint8_t *) &params_buf, sizeof (params_buf))
+ != sizeof (params_buf))
+ {
+ errnum = ERR_EXEC_FORMAT;
+@@ -371,13 +472,48 @@ grub_load_linux (char *kernel, char *arg)
+
+ setup_sects = lh->setup_sects;
+
++ img_size = grub_quark_asset_size (GRUB_QUARK_ASSET_KERNEL);
+ real_size = 0x1000 + grub_strlen(arg);
+- prot_size = grub_file_size () - (setup_sects << SECTOR_BITS) - SECTOR_SIZE;
++
++ /* Grub allocates distinct memory regions for the so-called "real mode" and
++ "protected mode" portions of bzImage. The linux entry point is located
++ at the base address of the protected mode section
++ (GRUB_LINUX_BZIMAGE_ADDR).
++ In order to perform signature verification, Quark secure boot requires
++ the whole bzImage to be allocated contiguously, with its CSBH prepended.
++ Consequently, the signed image is placed in a contiguous region starting
++ from GRUB_LINUX_BZIMAGE_ADDR, and the entry point offset is updated
++ accordingly. */
++ if (grub_quark_secure)
++ {
++ prot_size = img_size + sbh_len;
++ code32_start_offs += (setup_sects << SECTOR_BITS) + SECTOR_SIZE
++ + sbh_len;
++ }
++
++ else
++ prot_size = img_size - (setup_sects << SECTOR_BITS) - SECTOR_SIZE;
+
+ if (! allocate_pages (real_size, prot_size))
+ goto fail;
+
+- /* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
++ errnum = intel_quark_imr_setup(IMR_RANGE_BOOT, (grub_addr_t)real_mode_mem, real_size);
++ if(errnum != ERR_NONE)
++ {
++ grub_printf("IMR boot params setup failed !\n");
++ goto fail;
++ }
++
++ errnum = intel_quark_imr_setup(IMR_RANGE_BZIMAGE, GRUB_LINUX_BZIMAGE_ADDR, prot_size);
++ if(errnum != ERR_NONE)
++ {
++ grub_printf("IMR bzimage setup failed !\n");
++ goto fail;
++ }
++
++ __quark_test_imr();
++
++ /* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
+ lh->type_of_loader = 0x50;
+
+ lh->cmd_line_ptr = (grub_uint32_t) (unsigned long) real_mode_mem + 0x1000;
+@@ -394,6 +530,11 @@ grub_load_linux (char *kernel, char *arg)
+
+ grub_memmove(&params->hdr, lh, 0x202 + lh->jump_off - 0x1f1);
+
++ /* Update offset for protected mode code entry point. Quark secure boot
++ requires real mode code to be allocated contiguously to protected mode
++ section. Hence the kernel entry point must be shifted accordingly. */
++ params->hdr.code32_start += code32_start_offs;
++
+ params->cl_magic = GRUB_LINUX_CL_MAGIC;
+ params->cl_offset = 0x1000;
+
+@@ -446,9 +587,13 @@ grub_load_linux (char *kernel, char *arg)
+ params->eddbuf_entries = 0;
+ params->edd_mbr_sig_buf_entries = 0;
+
++ /* Dump MFH layout.conf contents */
++ grub_quark_dump_layout ();
++
+ /* XXX there is no way to know if the kernel really supports EFI. */
+- grub_printf ("[Linux-EFI, setup=0x%x, size=0x%x]\n", (unsigned int)real_size,
+- (unsigned int)prot_size);
++ grub_printf ("[Linux-EFI%s, setup=0x%x, size=0x%x]\n",
++ grub_quark_linux_spi ? " SPI" : "",
++ (unsigned int) real_size, (unsigned int) prot_size);
+
+ /* Check the mem= option to limit memory used for initrd. */
+ {
+@@ -504,12 +649,41 @@ grub_load_linux (char *kernel, char *arg)
+ linux_mem_size = 0;
+ }
+
+- dest = grub_stpcpy ((char *) real_mode_mem + 0x1000, skip_to(0, arg));
++ /* Expand Intel Quark's UART MMIO address if requested */
++ quark_detect_early_uart(&arg);
++
++ /* Skip the path to the kernel only if in file system mode. */
++ grub_stpcpy ((char *) real_mode_mem + 0x1000,
++ grub_quark_linux_spi ? arg : skip_to (0, arg));
++
++ /* If Quark secure boot path, copy over CSBH + bzImage into "protected
++ mode" section. */
++ if (grub_quark_secure)
++ {
++ grub_quark_asset_seek (0);
++ prot_size -= sbh_len;
++ grub_memcpy (prot_mode_mem, &quark_sbh, sizeof (quark_sbh));
++ prot_mode_offs += sbh_len;
++ }
++ else
++ grub_quark_asset_seek ((setup_sects << SECTOR_BITS) + SECTOR_SIZE);
+
+- grub_seek ((setup_sects << SECTOR_BITS) + SECTOR_SIZE);
+ len = prot_size;
+- if (grub_read ((char *) GRUB_LINUX_BZIMAGE_ADDR, len) != len)
+- grub_printf ("Couldn't read file");
++ if (grub_quark_asset_read (GRUB_QUARK_ASSET_KERNEL,
++ (grub_uint8_t *) prot_mode_mem + prot_mode_offs,
++ len) != len)
++ {
++ errnum = ERR_EXEC_FORMAT;
++ grub_printf ("Couldn't read file");
++ goto fail;
++ }
++
++ /* Verify the kernel signature. */
++ if (grub_quark_secure &&
++ ! grub_quark_verify_asset_signature ((grub_uint8_t *) prot_mode_mem))
++ {
++ errnum = ERR_QUARK_VERIFICATION;
++ }
+
+ if (errnum == ERR_NONE)
+ {
+@@ -543,7 +717,10 @@ grub_load_initrd (char *initrd)
+ grub_efi_uint32_t desc_version;
+ struct linux_kernel_params *params;
+
+- if (initrd == NULL)
++ sbh_len = 0;
++
++ /* In SPI/Flash mode, file system path to initrd is not required. */
++ if (! grub_quark_initrd_spi && initrd == NULL)
+ {
+ errnum = ERR_BAD_FILENAME;
+ grub_printf ("No module specified");
+@@ -557,10 +734,28 @@ grub_load_initrd (char *initrd)
+ goto fail1;
+ }
+
+- if (! grub_open (initrd))
++
++ if (grub_quark_secure)
++ {
++ if (! grub_quark_fetch_sbh (GRUB_QUARK_ASSET_INITRD_CSBH, initrd, &quark_sbh))
++ {
++ if (ERR_FILE_NOT_FOUND == errnum
++ && ! grub_quark_initrd_spi)
++ errnum = ERR_SGN_FILE_NOT_FOUND;
++ goto fail1;
++ }
++ sbh_len = quark_sbh.security_header.header_len;
++ }
++
++ if (! grub_quark_asset_open (GRUB_QUARK_ASSET_INITRD, initrd))
+ goto fail1;
+
+- size = grub_file_size ();
++ size = grub_quark_asset_size (GRUB_QUARK_ASSET_INITRD);
++
++ /* If Quark secure boot, make room for CSBH (dedicated page). */
++ if (grub_quark_secure)
++ size += PAGE_SIZE;
++
+ initrd_pages = (page_align (size) >> 12);
+
+ params = (struct linux_kernel_params *) real_mode_mem;
+@@ -583,7 +778,11 @@ grub_load_initrd (char *initrd)
+
+ /* Find the highest address to put the initrd. */
+ if (grub_efi_get_memory_map (&map_key, &desc_size, &desc_version) <= 0)
+- grub_fatal ("cannot get memory map");
++ {
++ grub_printf ("cannot get memory map");
++ errnum = ERR_BOOT_FAILURE;
++ goto fail;
++ }
+
+ mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap_buf, mmap_size);
+ addr = 0;
+@@ -626,17 +825,54 @@ grub_load_initrd (char *initrd)
+
+ initrd_mem = grub_efi_allocate_pages (addr, initrd_pages);
+ if (! initrd_mem)
+- grub_fatal ("cannot allocate pages: %x@%x", (unsigned)initrd_pages,
+- (unsigned)addr);
++ {
++ grub_printf ("cannot allocate pages: %x@%x", (unsigned) initrd_pages,
++ (unsigned) addr);
++ errnum = ERR_WONT_FIT;
++ goto fail;
++ }
+
+- if (grub_read (initrd_mem, size) != size)
++ /*
++ Quark secure boot requires the CSBH to be prepended to the Initrd.
++ Since Linux requires the Initrd to be page-aligned, do the following:
++ 1. copy Initrd to the 2nd allocated page
++ 2. copy the CSBH to the 1st allocated page at an offset such that
++ CSBH and Initrd are adjacent
++ */
++ if (grub_quark_secure)
++ {
++ size -= PAGE_SIZE;
++ grub_memcpy ((grub_uint8_t *) initrd_mem + PAGE_SIZE - sbh_len,
++ &quark_sbh, sizeof (quark_sbh));
++ initrd_mem = (grub_uint8_t *) initrd_mem + PAGE_SIZE;
++ addr += PAGE_SIZE;
++ }
++
++ if (grub_quark_asset_read (GRUB_QUARK_ASSET_INITRD, initrd_mem, size) != size)
+ {
++ errnum = ERR_EXEC_FORMAT;
+ grub_printf ("Couldn't read file");
+ goto fail;
+ }
+
+- grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n", (unsigned int) addr,
+- (unsigned int) size);
++ grub_printf ("[Initrd%s, addr=0x%x, size=0x%x]\n",
++ grub_quark_initrd_spi ? " SPI" : "",
++ (unsigned int) addr, (unsigned int) size);
++
++ if (grub_quark_secure)
++ {
++ /* Verify the initrd signature. */
++ if (! grub_quark_verify_asset_signature ((grub_uint8_t *)
++ initrd_mem - sbh_len))
++ {
++ errnum = ERR_QUARK_VERIFICATION;
++ goto fail;
++ }
++
++ /* Free up page allocated to CSBH. */
++ grub_efi_free_pages ((grub_addr_t)
++ ((grub_uint8_t *) initrd_mem - PAGE_SIZE), 1);
++ }
+
+ params->hdr.ramdisk_image = addr;
+ params->hdr.ramdisk_size = size;
+diff --git a/efi/quark/asset.c b/efi/quark/asset.c
new file mode 100644
-index 0000000..1f21a6c
+index 0000000..60262a3
--- /dev/null
-+++ b/efi/clanton/asset.c
++++ b/efi/quark/asset.c
@@ -0,0 +1,415 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -11918,64 +12465,64 @@ index 0000000..1f21a6c
+ * Intel Corporation
+ */
+
-+#include <clanton/asset.h>
-+#include <clanton/clanton.h>
-+#include <clanton/flash.h>
-+#include <clanton/mfh.h>
-+#include <clanton/sbh.h>
-+#include <clanton/test_module.h>
++#include <quark/asset.h>
++#include <quark/quark.h>
++#include <quark/flash.h>
++#include <quark/mfh.h>
++#include <quark/sbh.h>
++#include <quark/test_module.h>
+#include <grub/types.h>
+#include <shared.h>
+
+#define grub_file_size() filemax
+
+/* Flash item MMIO address & length. */
-+static grub_uint8_t *cln_flash_item_addr = 0x0;
-+static grub_uint32_t cln_flash_item_len = 0x0;
++static grub_uint8_t *quark_flash_item_addr = 0x0;
++static grub_uint32_t quark_flash_item_len = 0x0;
+static unsigned int spi_offs_intra_module = 0x0;
+static grub_uint8_t skip_csbh = 0;
+
+/* The path to the CSBH file. */
-+static char cln_sbh_path[GRUB_CLN_SBH_FILE_PATHMAX] = "";
++static char quark_sbh_path[GRUB_QUARK_SBH_FILE_PATHMAX] = "";
+
+/* Return the path to the CSBH file matching the module. */
+static char *
-+cln_get_sbh_fs_path (char *string)
++quark_get_sbh_fs_path (char *string)
+{
+ char *pos = NULL;
+ int len = 0;
+ char *path = grub_strtok_r (string, " ", &pos);
+
-+ cln_sbh_path[0] = 0;
++ quark_sbh_path[0] = 0;
+
-+ len = grub_strlen (path) + grub_strlen (GRUB_CLN_SBH_FILE_EXT);
-+ if (len < GRUB_CLN_SBH_FILE_PATHMAX)
++ len = grub_strlen (path) + grub_strlen (GRUB_QUARK_SBH_FILE_EXT);
++ if (len < GRUB_QUARK_SBH_FILE_PATHMAX)
+ {
-+ grub_strncat (cln_sbh_path, path, GRUB_CLN_SBH_FILE_PATHMAX);
-+ grub_strncat (cln_sbh_path, GRUB_CLN_SBH_FILE_EXT,
-+ GRUB_CLN_SBH_FILE_PATHMAX);
++ grub_strncat (quark_sbh_path, path, GRUB_QUARK_SBH_FILE_PATHMAX);
++ grub_strncat (quark_sbh_path, GRUB_QUARK_SBH_FILE_EXT,
++ GRUB_QUARK_SBH_FILE_PATHMAX);
+ }
+ else
+ grub_printf ("%s error: path to CSBH file is too long\n", __func__);
+
-+ return cln_sbh_path;
++ return quark_sbh_path;
+}
+
+/* Sanity check offset and size of MFH item.
+ Minimum size is passed as an argument. Maximum size is determined by
+ boundary check of the flash part. */
+static int
-+cln_flash_item_is_sane (grub_uint32_t min_size)
++quark_flash_item_is_sane (grub_uint32_t min_size)
+{
-+ /* Take into account the Clanton SBH if in secure mode. */
-+ min_size += (grub_cln_secure ? sizeof (struct grub_cln_sbh) : 0);
++ /* Take into account the Quark SBH if in secure mode. */
++ min_size += (grub_quark_secure ? sizeof (struct grub_quark_sbh) : 0);
+
+ /* Check that:
+ 1. minimum size is satisfied
+ 2. extent of the asset doesn't wrap around the address space. */
-+ if (cln_flash_item_len < min_size
-+ || (grub_uint32_t) cln_flash_item_addr + cln_flash_item_len
-+ < (grub_uint32_t) cln_flash_item_addr)
++ if (quark_flash_item_len < min_size
++ || (grub_uint32_t) quark_flash_item_addr + quark_flash_item_len
++ < (grub_uint32_t) quark_flash_item_addr)
+ {
+ grub_printf ("flash item size is outside the accepted range\n");
+ errnum = ERR_FILELENGTH;
@@ -12000,119 +12547,119 @@ index 0000000..1f21a6c
+ switch (type)
+ {
+ case KERNEL:
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ grub_cln_secure ? CLN_MFH_ITEM_TYPE_KERNEL_SIGNED
-+ : CLN_MFH_ITEM_TYPE_KERNEL,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
-+ if (0 == grub_cln_secure && ERR_FILE_NOT_FOUND == errnum)
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ grub_quark_secure ? QUARK_MFH_ITEM_TYPE_KERNEL_SIGNED
++ : QUARK_MFH_ITEM_TYPE_KERNEL,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
++ if (0 == grub_quark_secure && ERR_FILE_NOT_FOUND == errnum)
+ {
+ errnum = ERR_NONE;
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ CLN_MFH_ITEM_TYPE_KERNEL_SIGNED,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ QUARK_MFH_ITEM_TYPE_KERNEL_SIGNED,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
+ if (ERR_NONE == errnum)
+ skip_csbh = 1;
+ }
+ if (ERR_NONE == errnum)
-+ cln_flash_item_is_sane (sizeof (struct linux_kernel_header));
++ quark_flash_item_is_sane (sizeof (struct linux_kernel_header));
+ break;
+ case INITRD:
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ grub_cln_secure ? CLN_MFH_ITEM_TYPE_RAMDISK_SIGNED
-+ : CLN_MFH_ITEM_TYPE_RAMDISK,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
-+ if (0 == grub_cln_secure && ERR_FILE_NOT_FOUND == errnum)
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ grub_quark_secure ? QUARK_MFH_ITEM_TYPE_RAMDISK_SIGNED
++ : QUARK_MFH_ITEM_TYPE_RAMDISK,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
++ if (0 == grub_quark_secure && ERR_FILE_NOT_FOUND == errnum)
+ {
+ errnum = ERR_NONE;
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ CLN_MFH_ITEM_TYPE_RAMDISK_SIGNED,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ QUARK_MFH_ITEM_TYPE_RAMDISK_SIGNED,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
+ if (ERR_NONE == errnum)
+ skip_csbh = 1;
+ }
+ if (ERR_NONE == errnum)
-+ cln_flash_item_is_sane (0);
++ quark_flash_item_is_sane (0);
+ break;
+ default:
+ /* case CONFIG */
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ grub_cln_secure ?
-+ CLN_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED
-+ : CLN_MFH_ITEM_TYPE_BOOTLOADER_CONFIG,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
-+ if (0 == grub_cln_secure && ERR_FILE_NOT_FOUND == errnum)
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ grub_quark_secure ?
++ QUARK_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED
++ : QUARK_MFH_ITEM_TYPE_BOOTLOADER_CONFIG,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
++ if (0 == grub_quark_secure && ERR_FILE_NOT_FOUND == errnum)
+ {
+ errnum = ERR_NONE;
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ CLN_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED,
-+ &cln_flash_item_addr,
-+ &cln_flash_item_len);
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ QUARK_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED,
++ &quark_flash_item_addr,
++ &quark_flash_item_len);
+ if (ERR_NONE == errnum)
+ skip_csbh = 1;
+ }
+ if (ERR_NONE == errnum)
-+ cln_flash_item_is_sane (0);
++ quark_flash_item_is_sane (0);
+ break;
+ }
+
+ /* If the asset is signed, seek past CSBH. */
-+ if (grub_cln_secure || skip_csbh)
++ if (grub_quark_secure || skip_csbh)
+ spi_offs_intra_module += SPI_CSBH_OFFS_HARDCODED;
+
+ return (ERR_NONE == errnum);
+}
+
+int
-+grub_cln_asset_open (grub_cln_asset_type type, char *filename)
++grub_quark_asset_open (grub_quark_asset_type type, char *filename)
+{
+ /* No error by default. */
+ int ret = 1;
+
-+ __cln_test_asset(type);
++ __quark_test_asset(type);
+
+ switch (type)
+ {
-+ case GRUB_CLN_ASSET_KERNEL:
-+ if (grub_cln_linux_spi)
++ case GRUB_QUARK_ASSET_KERNEL:
++ if (grub_quark_linux_spi)
+ ret = spi_open (KERNEL);
+ else
+ ret = grub_open (filename);
+ break;
-+ case GRUB_CLN_ASSET_INITRD:
-+ if (grub_cln_initrd_spi)
++ case GRUB_QUARK_ASSET_INITRD:
++ if (grub_quark_initrd_spi)
+ ret = spi_open (INITRD);
+ else
+ ret = grub_open (filename);
+ break;
-+ case GRUB_CLN_ASSET_CONFIG:
-+ if (grub_cln_loaded_from_spi)
++ case GRUB_QUARK_ASSET_CONFIG:
++ if (grub_quark_loaded_from_spi)
+ ret = spi_open (CONFIG);
+ else
+ ret = grub_open (filename);
+ break;
-+ case GRUB_CLN_ASSET_KERNEL_CSBH:
-+ if (grub_cln_linux_spi)
++ case GRUB_QUARK_ASSET_KERNEL_CSBH:
++ if (grub_quark_linux_spi)
+ ret = spi_open (KERNEL);
+ else
-+ ret = grub_open (cln_get_sbh_fs_path (filename));
++ ret = grub_open (quark_get_sbh_fs_path (filename));
+ break;
-+ case GRUB_CLN_ASSET_INITRD_CSBH:
-+ if (grub_cln_initrd_spi)
++ case GRUB_QUARK_ASSET_INITRD_CSBH:
++ if (grub_quark_initrd_spi)
+ ret = spi_open (INITRD);
+ else
-+ ret = grub_open (cln_get_sbh_fs_path (filename));
++ ret = grub_open (quark_get_sbh_fs_path (filename));
+ break;
+ default:
-+ /* case GRUB_CLN_ASSET_CONFIG_CSBH: */
-+ if (grub_cln_loaded_from_spi)
++ /* case GRUB_QUARK_ASSET_CONFIG_CSBH: */
++ if (grub_quark_loaded_from_spi)
+ ret = spi_open (CONFIG);
+ else
-+ ret = grub_open (cln_get_sbh_fs_path (filename));
++ ret = grub_open (quark_get_sbh_fs_path (filename));
+ break;
+ }
+
@@ -12120,17 +12667,17 @@ index 0000000..1f21a6c
+}
+
+int
-+grub_cln_asset_read (grub_cln_asset_type type, void *buf, int len)
++grub_quark_asset_read (grub_quark_asset_type type, void *buf, int len)
+{
+ int read = 0;
+
+ switch (type)
+ {
-+ case GRUB_CLN_ASSET_KERNEL:
-+ if (grub_cln_linux_spi)
++ case GRUB_QUARK_ASSET_KERNEL:
++ if (grub_quark_linux_spi)
+ {
+ grub_memcpy (buf,
-+ cln_flash_item_addr
++ quark_flash_item_addr
+ + spi_offs_intra_module, len);
+ read = len;
+ spi_offs_intra_module += read;
@@ -12138,20 +12685,20 @@ index 0000000..1f21a6c
+ else
+ read = grub_read (buf, len);
+ break;
-+ case GRUB_CLN_ASSET_KERNEL_CSBH:
-+ if (grub_cln_linux_spi)
++ case GRUB_QUARK_ASSET_KERNEL_CSBH:
++ if (grub_quark_linux_spi)
+ {
-+ grub_memcpy (buf, cln_flash_item_addr, len);
++ grub_memcpy (buf, quark_flash_item_addr, len);
+ read = len;
+ }
+ else
+ read = grub_read (buf, len);
+ break;
-+ case GRUB_CLN_ASSET_INITRD:
-+ if (grub_cln_initrd_spi)
++ case GRUB_QUARK_ASSET_INITRD:
++ if (grub_quark_initrd_spi)
+ {
+ grub_memcpy (buf,
-+ cln_flash_item_addr + spi_offs_intra_module,
++ quark_flash_item_addr + spi_offs_intra_module,
+ len);
+ read = len;
+ spi_offs_intra_module += read;
@@ -12159,20 +12706,20 @@ index 0000000..1f21a6c
+ else
+ read = grub_read (buf, len);
+ break;
-+ case GRUB_CLN_ASSET_INITRD_CSBH:
-+ if (grub_cln_initrd_spi)
++ case GRUB_QUARK_ASSET_INITRD_CSBH:
++ if (grub_quark_initrd_spi)
+ {
-+ grub_memcpy (buf, cln_flash_item_addr, len);
++ grub_memcpy (buf, quark_flash_item_addr, len);
+ read = len;
+ }
+ else
+ read = grub_read (buf, len);
+ break;
-+ case GRUB_CLN_ASSET_CONFIG:
-+ if (grub_cln_loaded_from_spi)
++ case GRUB_QUARK_ASSET_CONFIG:
++ if (grub_quark_loaded_from_spi)
+ {
+ grub_memcpy (buf,
-+ cln_flash_item_addr + spi_offs_intra_module,
++ quark_flash_item_addr + spi_offs_intra_module,
+ len);
+ read = len;
+ spi_offs_intra_module += read;
@@ -12181,10 +12728,10 @@ index 0000000..1f21a6c
+ read = grub_read (buf, len);
+ break;
+ default:
-+ /* case GRUB_CLN_ASSET_CONFIG_CSBH */
-+ if (grub_cln_loaded_from_spi)
++ /* case GRUB_QUARK_ASSET_CONFIG_CSBH */
++ if (grub_quark_loaded_from_spi)
+ {
-+ grub_memcpy (buf, cln_flash_item_addr, len);
++ grub_memcpy (buf, quark_flash_item_addr, len);
+ read = len;
+ }
+ else
@@ -12196,13 +12743,13 @@ index 0000000..1f21a6c
+}
+
+void
-+grub_cln_asset_seek (int offset)
++grub_quark_asset_seek (int offset)
+{
+ /* Note it doesn't differentiate between module types, as it's only used
+ by the linux loader routine. */
-+ if (grub_cln_linux_spi)
++ if (grub_quark_linux_spi)
+ {
-+ if (grub_cln_secure || skip_csbh)
++ if (grub_quark_secure || skip_csbh)
+ spi_offs_intra_module = offset + SPI_CSBH_OFFS_HARDCODED;
+ else
+ spi_offs_intra_module = offset;
@@ -12212,38 +12759,38 @@ index 0000000..1f21a6c
+}
+
+int
-+grub_cln_asset_size (grub_cln_asset_type type)
++grub_quark_asset_size (grub_quark_asset_type type)
+{
+ int size = -1;
+
+ switch (type)
+ {
-+ case GRUB_CLN_ASSET_KERNEL:
-+ if (grub_cln_linux_spi)
++ case GRUB_QUARK_ASSET_KERNEL:
++ if (grub_quark_linux_spi)
+ {
-+ size = cln_flash_item_len;
-+ if (grub_cln_secure || skip_csbh)
++ size = quark_flash_item_len;
++ if (grub_quark_secure || skip_csbh)
+ size -= SPI_CSBH_OFFS_HARDCODED;
+ }
+ else
+ size = grub_file_size ();
+ break;
-+ case GRUB_CLN_ASSET_INITRD:
-+ if (grub_cln_initrd_spi)
++ case GRUB_QUARK_ASSET_INITRD:
++ if (grub_quark_initrd_spi)
+ {
-+ size = cln_flash_item_len;
-+ if (grub_cln_secure || skip_csbh)
++ size = quark_flash_item_len;
++ if (grub_quark_secure || skip_csbh)
+ size -= SPI_CSBH_OFFS_HARDCODED;
+ }
+ else
+ size = grub_file_size ();
+ break;
+ default:
-+ /* case GRUB_CLN_ASSET_CONFIG */
-+ if (grub_cln_loaded_from_spi)
++ /* case GRUB_QUARK_ASSET_CONFIG */
++ if (grub_quark_loaded_from_spi)
+ {
-+ size = cln_flash_item_len;
-+ if (grub_cln_secure || skip_csbh)
++ size = quark_flash_item_len;
++ if (grub_quark_secure || skip_csbh)
+ size -= SPI_CSBH_OFFS_HARDCODED;
+ }
+ else
@@ -12254,26 +12801,26 @@ index 0000000..1f21a6c
+ return size;
+}
+
-+void grub_cln_asset_close (void)
++void grub_quark_asset_close (void)
+{
+ grub_close ();
+ return;
+}
+
+int
-+grub_cln_fetch_sbh (grub_cln_asset_type type, char *path,
-+ struct grub_cln_sbh *csbh)
++grub_quark_fetch_sbh (grub_quark_asset_type type, char *path,
++ struct grub_quark_sbh *csbh)
+{
+ int success = 1;
+
-+ /* Fetch the Clanton SBH. */
-+ if (! grub_cln_asset_open (type, path))
++ /* Fetch the Quark SBH. */
++ if (! grub_quark_asset_open (type, path))
+ success = 0;
-+ else if (sizeof (*csbh) != grub_cln_asset_read (type, csbh, sizeof (*csbh)))
++ else if (sizeof (*csbh) != grub_quark_asset_read (type, csbh, sizeof (*csbh)))
+ {
+ errnum = ERR_READ;
+ grub_close ();
-+ grub_printf ("cannot read the Clanton SBH");
++ grub_printf ("cannot read the Quark SBH");
+ success = 0;
+ }
+ grub_close ();
@@ -12281,7 +12828,7 @@ index 0000000..1f21a6c
+ /* Check for valid SBH. */
+ if (success)
+ {
-+ if (GRUB_CLN_SBH_MAGIC_NUMBER != csbh->security_header.magic_number)
++ if (GRUB_QUARK_SBH_MAGIC_NUMBER != csbh->security_header.magic_number)
+ {
+ errnum = ERR_EXEC_FORMAT;
+ grub_printf ("invalid CSBH magic number\n");
@@ -12293,14 +12840,14 @@ index 0000000..1f21a6c
+}
+
+/* Dump the contents of layout.conf encoded in flash image */
-+void grub_cln_dump_layout (void)
++void grub_quark_dump_layout (void)
+{
+ grub_uint8_t * data = 0x0;
+ grub_uint32_t len = 0x0;
+
+ errnum = ERR_NONE;
-+ grub_cln_mfh_entry_lookup (grub_cln_mfh_addr,
-+ CLN_MFH_ITEM_TYPE_BUILD_INFO,
++ grub_quark_mfh_entry_lookup (grub_quark_mfh_addr,
++ QUARK_MFH_ITEM_TYPE_BUILD_INFO,
+ &data,
+ &len);
+ if (errnum != ERR_NONE)
@@ -12313,14 +12860,14 @@ index 0000000..1f21a6c
+ grub_printf("Found layout.conf @ 0x%08x len 0x%08x\n", data, len);
+ grub_printf("%.*s\n", len, data);
+}
-diff --git a/efi/clanton/asset.h b/efi/clanton/asset.h
+diff --git a/efi/quark/asset.h b/efi/quark/asset.h
new file mode 100644
-index 0000000..8deb7b4
+index 0000000..f29eced
--- /dev/null
-+++ b/efi/clanton/asset.h
++++ b/efi/quark/asset.h
@@ -0,0 +1,54 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12339,10 +12886,10 @@ index 0000000..8deb7b4
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_ASSET_HEADER
-+#define GRUB_CLANTON_ASSET_HEADER 1
++#ifndef GRUB_QUARK_ASSET_HEADER
++#define GRUB_QUARK_ASSET_HEADER 1
+
-+#include <clanton/sbh.h>
++#include <quark/sbh.h>
+
+/* FIXME Quark software reference implementaion pads the CSBH to align to 1kB.
+ This is hardcoded for now. But needs to be read from CSBH lenght field. */
@@ -12350,37 +12897,37 @@ index 0000000..8deb7b4
+
+typedef enum
+{
-+ GRUB_CLN_ASSET_KERNEL,
-+ GRUB_CLN_ASSET_INITRD,
-+ GRUB_CLN_ASSET_KERNEL_CSBH,
-+ GRUB_CLN_ASSET_INITRD_CSBH,
-+ GRUB_CLN_ASSET_CONFIG,
-+ GRUB_CLN_ASSET_CONFIG_CSBH,
-+} grub_cln_asset_type;
++ GRUB_QUARK_ASSET_KERNEL,
++ GRUB_QUARK_ASSET_INITRD,
++ GRUB_QUARK_ASSET_KERNEL_CSBH,
++ GRUB_QUARK_ASSET_INITRD_CSBH,
++ GRUB_QUARK_ASSET_CONFIG,
++ GRUB_QUARK_ASSET_CONFIG_CSBH,
++} grub_quark_asset_type;
+
+/* Access to an asset in read-only mode. */
-+int grub_cln_asset_open (grub_cln_asset_type type, char *filename);
-+int grub_cln_asset_read (grub_cln_asset_type type, void *buf, int len);
-+void grub_cln_asset_seek (int offset);
-+int grub_cln_asset_size (grub_cln_asset_type type);
-+void grub_cln_asset_close (void);
++int grub_quark_asset_open (grub_quark_asset_type type, char *filename);
++int grub_quark_asset_read (grub_quark_asset_type type, void *buf, int len);
++void grub_quark_asset_seek (int offset);
++int grub_quark_asset_size (grub_quark_asset_type type);
++void grub_quark_asset_close (void);
+
-+/* Fetch and sanity check the Clanton Secure Boot Header. */
-+int grub_cln_fetch_sbh (grub_cln_asset_type type, char *path,
-+ struct grub_cln_sbh *csbh);
++/* Fetch and sanity check the Quark Secure Boot Header. */
++int grub_quark_fetch_sbh (grub_quark_asset_type type, char *path,
++ struct grub_quark_sbh *csbh);
+
+/* Dump the contents of layout.conf encoded in flash image */
-+void grub_cln_dump_layout (void);
++void grub_quark_dump_layout (void);
+
-+#endif /* ! GRUB_CLANTON_ASSET_HEADER */
-diff --git a/efi/clanton/boot_settings.c b/efi/clanton/boot_settings.c
++#endif /* ! GRUB_QUARK_ASSET_HEADER */
+diff --git a/efi/quark/boot_settings.c b/efi/quark/boot_settings.c
new file mode 100644
-index 0000000..4d3edf4
+index 0000000..8bbc586
--- /dev/null
-+++ b/efi/clanton/boot_settings.c
++++ b/efi/quark/boot_settings.c
@@ -0,0 +1,214 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12399,13 +12946,13 @@ index 0000000..4d3edf4
+ * Intel Corporation
+ */
+
-+#include <clanton/asset.h>
-+#include <clanton/clanton.h>
-+#include <clanton/flash.h>
-+#include <clanton/iarom.h>
-+#include <clanton/intel_cln_sb.h>
-+#include <clanton/target.h>
-+#include <clanton/sbh.h>
++#include <quark/asset.h>
++#include <quark/quark.h>
++#include <quark/flash.h>
++#include <quark/iarom.h>
++#include <quark/intel_quark_sb.h>
++#include <quark/target.h>
++#include <quark/sbh.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/misc.h>
+#include <grub/misc.h>
@@ -12416,10 +12963,10 @@ index 0000000..4d3edf4
+#define SPI_ROM_FUSE_REG_MASK 0x00000010
+
+/* Pointer to memory-mapped MFH address. */
-+grub_uint8_t *grub_cln_mfh_addr = (grub_uint8_t *) GRUB_CLN_MFH_ADDR;
++grub_uint8_t *grub_quark_mfh_addr = (grub_uint8_t *) GRUB_QUARK_MFH_ADDR;
+
+/* Indicate if the GRUB has been loaded from SPI or SDIO. */
-+unsigned short int grub_cln_loaded_from_spi = 0;
++unsigned short int grub_quark_loaded_from_spi = 0;
+
+/* The (signed) configuration file buffer. Its maximum size is limited to
+ 8kB. */
@@ -12432,15 +12979,15 @@ index 0000000..4d3edf4
+ Determine whether or not Secure Boot is enabled.
+ */
+void
-+grub_cln_detect_secure_sku (void)
++grub_quark_detect_secure_sku (void)
+{
+ grub_uint32_t spi_rom_fuse_range = 0x0;
+
+ /* Read the spi_rom_fuse_in 32-bit fuse range from Fuse Bank 0. */
-+ intel_cln_sb_read_reg (SB_ID_SEC_FUSE, CFG_READ_FUSE_OPCODE,
++ intel_quark_sb_read_reg (SB_ID_SEC_FUSE, CFG_READ_FUSE_OPCODE,
+ SPI_ROM_FUSE_REG_OFFS, &spi_rom_fuse_range);
+
-+/* FIXME On Clanton, spi_rom_fuse_in == 1 if Secure Boot is enabled. On
++/* FIXME On Quark, spi_rom_fuse_in == 1 if Secure Boot is enabled. On
+ emulation platform instead, the bit is swapped. The following #if's are
+ an emulation workaround. Restore when we transition to real silicon. */
+#if 0
@@ -12448,16 +12995,16 @@ index 0000000..4d3edf4
+#else
+ if (! (spi_rom_fuse_range & SPI_ROM_FUSE_REG_MASK))
+#endif
-+ grub_cln_secure = 1;
++ grub_quark_secure = 1;
+ else
-+ grub_cln_secure = 0;
++ grub_quark_secure = 0;
+
-+ if (grub_cln_debug)
-+ grub_printf("Detected %ssecure SKU\n", grub_cln_secure ? "" : "non-");
++ if (grub_quark_debug)
++ grub_printf("Detected %ssecure SKU\n", grub_quark_secure ? "" : "non-");
+}
+
+void
-+grub_cln_load_config_file (char **cfg_file_buffer, int *cfg_file_size)
++grub_quark_load_config_file (char **cfg_file_buffer, int *cfg_file_size)
+{
+ grub_efi_loaded_image_t *loaded_image = NULL;
+ unsigned long drive = 0, partition = 0;
@@ -12515,7 +13062,7 @@ index 0000000..4d3edf4
+ /* FIXME this logic needs to be moved earlier, to detect media as soon as
+ possible. Ideally to be moved in stage2.c */
+ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle);
-+ grub_cln_loaded_from_spi =
++ grub_quark_loaded_from_spi =
+ ! grub_get_drive_partition_from_bdev_handle (loaded_image->device_handle,
+ &drive, &partition);
+
@@ -12523,9 +13070,9 @@ index 0000000..4d3edf4
+ }
+
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ grub_printf ("GRUB loaded from %s\n",
-+ grub_cln_loaded_from_spi ? "SPI/Flash" : "file system device");
++ grub_quark_loaded_from_spi ? "SPI/Flash" : "file system device");
+
+}
+
@@ -12533,31 +13080,31 @@ index 0000000..4d3edf4
+do_load_config_file(char **cfg_file_buffer, int *cfg_file_size, char *source) // from SD or SPI
+{
+ int read = 0;
-+ struct grub_cln_sbh *sbh = NULL;
++ struct grub_quark_sbh *sbh = NULL;
+ grub_uint32_t sbh_len = 0;
+
+ *cfg_file_buffer = cfg_buffer;
+
-+ if (grub_cln_secure)
++ if (grub_quark_secure)
+ {
-+ sbh = (struct grub_cln_sbh *)cfg_buffer;
-+ if (! grub_cln_fetch_sbh (GRUB_CLN_ASSET_CONFIG_CSBH, config_file, sbh))
++ sbh = (struct grub_quark_sbh *)cfg_buffer;
++ if (! grub_quark_fetch_sbh (GRUB_QUARK_ASSET_CONFIG_CSBH, config_file, sbh))
+ {
+ errnum = ERR_SGN_FILE_NOT_FOUND;
-+ return 0;
++ return 1;
+ }
+ sbh_len = sbh->security_header.header_len;
+ }
+
+ /* Open the configuration file. */
-+ if (! grub_cln_asset_open (GRUB_CLN_ASSET_CONFIG, config_file))
++ if (! grub_quark_asset_open (GRUB_QUARK_ASSET_CONFIG, config_file))
+ {
+ errnum = ERR_FILE_NOT_FOUND;
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ grub_printf ("%s(): cannot open GRUB configuration from %s\n", __func__, source);
+ return 1;
+ }
-+ *cfg_file_size = grub_cln_asset_size (GRUB_CLN_ASSET_CONFIG);
++ *cfg_file_size = grub_quark_asset_size (GRUB_QUARK_ASSET_CONFIG);
+
+ /* Signed/unsigned configuration must fit into the buffer. */
+ if (*cfg_file_size > sizeof (cfg_buffer))
@@ -12569,87 +13116,38 @@ index 0000000..4d3edf4
+
+ /* Buffer configuration file. */
+ read =
-+ grub_cln_asset_read (GRUB_CLN_ASSET_CONFIG,
++ grub_quark_asset_read (GRUB_QUARK_ASSET_CONFIG,
+ cfg_buffer
+ + sbh_len,
+ *cfg_file_size);
-+ grub_cln_asset_close ();
++ grub_quark_asset_close ();
+ if (read != *cfg_file_size)
+ {
+ errnum = ERR_READ;
-+ if(grub_cln_debug)
++ if(grub_quark_debug)
+ grub_printf ("%s(): cannot read GRUB configuration from %s\n", __func__, source);
+ return 1;
+ }
+
-+ if (grub_cln_secure)
++ if (grub_quark_secure)
+ {
+ /* Validate configuration file. */
-+ if (! grub_cln_verify_asset_signature ((grub_uint8_t *) cfg_buffer))
-+ errnum = ERR_CLN_VERIFICATION;
++ if (! grub_quark_verify_asset_signature ((grub_uint8_t *) cfg_buffer))
++ errnum = ERR_QUARK_VERIFICATION;
+
+ /* Mask out the CSBH to the configuration file parser. */
+ *cfg_file_buffer += sbh_len;
+ }
+ return 0;
+}
-diff --git a/efi/clanton/clanton.h b/efi/clanton/clanton.h
-new file mode 100644
-index 0000000..643bb65
---- /dev/null
-+++ b/efi/clanton/clanton.h
-@@ -0,0 +1,43 @@
-+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of version 2 of the GNU General Public License as
-+ * published by the Free Software Foundation.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ * General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-+ *
-+ * Contact Information:
-+ * Intel Corporation
-+ */
-+
-+#ifndef GRUB_CLANTON_CLANTON_HEADER
-+#define GRUB_CLANTON_CLANTON_HEADER 1
-+
-+/*
-+ Kernel command line token to be expanded into Quark UART1 MMIO address.
-+ Note the length of the token MUST be > "0xcafebabe", so as to prevent the
-+ rest of the string from being overwritten.
-+ */
-+#define QUARK_UART_MMIO_TOKEN "$EARLY_CON_ADDR_REPLACE"
-+
-+/* Secure/non-secure boot switch. */
-+extern unsigned short int grub_cln_secure;
-+/* Debug/release switch. */
-+extern unsigned short int grub_cln_debug;
-+
-+/* State whether the Grub was loaded from SPI/flash or SDIO. */
-+extern unsigned short int grub_cln_loaded_from_spi;
-+/* State whether the Kernel must be fetched from SPI/flash or SDIO. */
-+extern unsigned short int grub_cln_linux_spi;
-+/* State whether the Initrd must be fetched from SPI/flash or SDIO. */
-+extern unsigned short int grub_cln_initrd_spi;
-+
-+#endif /* ! GRUB_CLANTON_CLANTON_HEADER */
-diff --git a/efi/clanton/early_uart.c b/efi/clanton/early_uart.c
+diff --git a/efi/quark/early_uart.c b/efi/quark/early_uart.c
new file mode 100644
-index 0000000..557dc7c
+index 0000000..db25998
--- /dev/null
-+++ b/efi/clanton/early_uart.c
-@@ -0,0 +1,137 @@
++++ b/efi/quark/early_uart.c
+@@ -0,0 +1,133 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12674,23 +13172,20 @@ index 0000000..557dc7c
+ * does not implement traditional 0x3f8 type UARTs
+ */
+
-+#include <clanton/clanton.h>
++#include <quark/quark.h>
+#include <grub/types.h>
+#include <netboot/linux-asm-io.h>
++#include <netboot/pci.h>
+#include <netboot/timer.h>
+#include <shared.h>
+#include <stage2/serial.h>
+#include "early_uart.h"
+
-+#define PCI_VENDOR_ID (0x00)
-+#define PCI_DEVICE_ID (0x02)
-+#define PCI_CLASS_DEVICE (0x0A)
++#define PCI_CLASS_DEVICE (0x0A)
+
-+#define PCI_VENDOR_ID_INTEL (0x8086)
-+#define PCI_DEVICE_CLNUART (0x0936)
-+#define UART_BARMAP_LEN (0x10)
++#define PCI_DEVICE_ID_QUARK_UART (0x0936)
+
-+static grub_uint32_t *pclnuart = NULL;
++static grub_uint32_t *p_uart = NULL;
+
+static grub_uint32_t read_pci_config(grub_uint8_t bus, grub_uint8_t slot,
+ grub_uint8_t func, grub_uint8_t offset)
@@ -12713,9 +13208,9 @@ index 0000000..557dc7c
+/**
+ * clnuart_early_setup
+ *
-+ * Sets up one of the Clanton UARTs as an early boot console
++ * Sets up one of the Quark UARTs as an early boot console
+ */
-+static void cln_uart_early_setup(int num, int slot, int func, int offset)
++static void quark_uart_early_setup(int num, int slot, int func, int offset)
+{
+ grub_uint32_t addr = 0;
+ addr = read_pci_config(num, slot, func, offset);
@@ -12730,15 +13225,15 @@ index 0000000..557dc7c
+ grub_printf("bailing.. driver expects 32 bit range\n");
+ return;
+ }
-+ pclnuart = (grub_uint32_t *) (addr&0xFFFFFFF0);
++ p_uart = (grub_uint32_t *) (addr&0xFFFFFFF0);
+}
+
+/**
+ * clnuart_early_probe
+ *
-+ * Do an early probe of the PCI bus - find Clanton UARTs
++ * Do an early probe of the PCI bus - find Quark UARTs
+ */
-+static int cln_early_uart_probe(int num, int slot, int func)
++static int quark_early_uart_probe(int num, int slot, int func)
+{
+ grub_uint16_t class;
+ grub_uint16_t vendor;
@@ -12756,43 +13251,42 @@ index 0000000..557dc7c
+ /* Do early PCI UART init */
+ if(vendor == PCI_VENDOR_ID_INTEL){
+ /* UART0 is F1, UART1 is F5. We're probing UART1. */
-+ if (device == PCI_DEVICE_CLNUART && 0x0005 == func){
-+ cln_uart_early_setup(num, slot, func, 0x10);
++ if (device == PCI_DEVICE_ID_QUARK_UART && 0x0005 == func){
++ quark_uart_early_setup(num, slot, func, 0x10);
+ return 0;
+ }
+ }
+ return -1;
+}
+
-+grub_uint32_t *cln_early_uart_init(void)
++grub_uint32_t *quark_early_uart_init(void)
+{
+ int bus = 0, slot = 0, func = 0;
+
+ for (slot = 0; slot < 32; slot++){
+ for (func = 0; func < 8; func++) {
+ /* Only probe function 0 on single fn devices */
-+ if(cln_early_uart_probe(bus, slot, func) == 0){
-+ if (grub_cln_debug) {
++ if(quark_early_uart_probe(bus, slot, func) == 0){
++ if (grub_quark_debug) {
+ grub_printf("%s: UART @ B/D/F "
+ "%d/%d/%d\n",
+ __func__, bus, slot, func);
+ }
-+ return pclnuart;
++ return p_uart;
+ }
+ }
+ }
-+ errnum = ERR_DEV_VALUES;
+ return NULL;
+}
+
-diff --git a/efi/clanton/early_uart.h b/efi/clanton/early_uart.h
+diff --git a/efi/quark/early_uart.h b/efi/quark/early_uart.h
new file mode 100644
-index 0000000..a09782d
+index 0000000..87bc2a0
--- /dev/null
-+++ b/efi/clanton/early_uart.h
++++ b/efi/quark/early_uart.h
@@ -0,0 +1,29 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12811,23 +13305,23 @@ index 0000000..a09782d
+ * Intel Corporation
+ */
+
-+#ifndef __INTEL_CLN_EARLY_UART_HEADER__
-+#define __INTEL_CLN_EARLY_UART_HEADER__
++#ifndef __INTEL_QUARK_EARLY_UART_HEADER__
++#define __INTEL_QUARK_EARLY_UART_HEADER__
+
+#include <grub/types.h>
+
-+grub_uint32_t *cln_early_uart_init(void);
++grub_uint32_t *quark_early_uart_init(void);
+
-+#endif /* __INTEL_CLN_EARLY_UART_HEADER__ */
++#endif /* __INTEL_QUARK_EARLY_UART_HEADER__ */
+
-diff --git a/efi/clanton/flash.h b/efi/clanton/flash.h
+diff --git a/efi/quark/flash.h b/efi/quark/flash.h
new file mode 100644
-index 0000000..db69e1b
+index 0000000..54483c4
--- /dev/null
-+++ b/efi/clanton/flash.h
++++ b/efi/quark/flash.h
@@ -0,0 +1,36 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12846,30 +13340,30 @@ index 0000000..db69e1b
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_FLASH_HEADER
-+#define GRUB_CLANTON_FLASH_HEADER 1
++#ifndef GRUB_QUARK_FLASH_HEADER
++#define GRUB_QUARK_FLASH_HEADER 1
+
-+#include <clanton/target.h>
++#include <quark/target.h>
+#include <grub/types.h>
+
+/* Pointer to MFH. */
-+extern grub_uint8_t *grub_cln_mfh_addr;
++extern grub_uint8_t *grub_quark_mfh_addr;
+
+/* MMIO address of MFH. */
-+#define GRUB_CLN_MFH_ADDR 0xFFF08000
++#define GRUB_QUARK_MFH_ADDR 0xFFF08000
+
+/* MMIO address of signed Key Module. */
-+#define GRUB_CLN_S_KEYMOD_ADDR 0xFFFD8000
++#define GRUB_QUARK_S_KEYMOD_ADDR 0xFFFD8000
+
-+#endif /* ! GRUB_CLANTON_FLASH_HEADER */
-diff --git a/efi/clanton/iarom.c b/efi/clanton/iarom.c
++#endif /* ! GRUB_QUARK_FLASH_HEADER */
+diff --git a/efi/quark/iarom.c b/efi/quark/iarom.c
new file mode 100644
-index 0000000..95c6f69
+index 0000000..73a570c
--- /dev/null
-+++ b/efi/clanton/iarom.c
++++ b/efi/quark/iarom.c
@@ -0,0 +1,121 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -12888,11 +13382,11 @@ index 0000000..95c6f69
+ * Intel Corporation
+ */
+
-+#include <clanton/clanton.h>
-+#include <clanton/flash.h>
-+#include <clanton/iarom.h>
-+#include <clanton/target.h>
-+#include <clanton/test_module.h>
++#include <quark/quark.h>
++#include <quark/flash.h>
++#include <quark/iarom.h>
++#include <quark/target.h>
++#include <quark/test_module.h>
+#include <shared.h>
+
+/* Structure used to help manage a "heap" for Crypto purposes.
@@ -12922,9 +13416,9 @@ index 0000000..95c6f69
+static grub_uint8_t memory_buf_array[CRYPTO_HEAP_SIZE];
+
+/* The OEM RSA Public Key for verifying signature. */
-+static struct grub_cln_sbh_key_hdr *oem_rsa_key =
-+ (struct grub_cln_sbh_key_hdr *) (GRUB_CLN_S_KEYMOD_ADDR +
-+ sizeof (struct grub_cln_sbh));
++static struct grub_quark_sbh_key_hdr *oem_rsa_key =
++ (struct grub_quark_sbh_key_hdr *) (GRUB_QUARK_S_KEYMOD_ADDR +
++ sizeof (struct grub_quark_sbh));
+
+/* Initialise the heap descriptor and the buffer. */
+static void
@@ -12940,34 +13434,34 @@ index 0000000..95c6f69
+ scratch_area_info->debug_code = 0;
+ scratch_area_info->fatal_code = 0;
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ grub_printf ("(%s) scratch_area_info = 0x%x\n", __func__, scratch_area_info);
+}
+
+/* The callback function signature. */
-+typedef grub_uint8_t (*callback_t) (struct grub_cln_sbh_security_hdr *,
-+ struct grub_cln_sbh_key_hdr *,
++typedef grub_uint8_t (*callback_t) (struct grub_quark_sbh_security_hdr *,
++ struct grub_quark_sbh_key_hdr *,
+ struct scratch_memory_t *);
+static grub_uint8_t
-+(*IAROM_validate_module) (struct grub_cln_sbh_security_hdr *sec_h,
-+ struct grub_cln_sbh_key_hdr *key_h,
++(*IAROM_validate_module) (struct grub_quark_sbh_security_hdr *sec_h,
++ struct grub_quark_sbh_key_hdr *key_h,
+ struct scratch_memory_t *scratch_area_info);
+
+int
-+grub_cln_verify_asset_signature (grub_uint8_t *addr)
++grub_quark_verify_asset_signature (grub_uint8_t *addr)
+{
+ grub_uint8_t valid = 0;
-+ struct grub_cln_sbh_security_hdr *sec_h =
-+ (struct grub_cln_sbh_security_hdr *) addr;
-+ grub_uint32_t *callback_ptr = (grub_uint32_t *) GRUB_CLN_IAROM_CALLBACK_PTR;
++ struct grub_quark_sbh_security_hdr *sec_h =
++ (struct grub_quark_sbh_security_hdr *) addr;
++ grub_uint32_t *callback_ptr = (grub_uint32_t *) GRUB_QUARK_IAROM_CALLBACK_PTR;
+
-+ __cln_test_signature();
++ __quark_test_signature();
+
+ init_heap ();
+
+ IAROM_validate_module = (callback_t) *callback_ptr;
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ grub_printf ("OEM key @ 0x%x\n", oem_rsa_key);
+ grub_printf ("Calling into IAROM @ 0x%x for validating module @ 0x%x.. ",
@@ -12976,7 +13470,7 @@ index 0000000..95c6f69
+
+ valid = IAROM_validate_module (sec_h, oem_rsa_key, scratch_area_info);
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ if (valid)
+ grub_printf ("done.");
@@ -12989,14 +13483,14 @@ index 0000000..95c6f69
+
+ return (int) valid;
+}
-diff --git a/efi/clanton/iarom.h b/efi/clanton/iarom.h
+diff --git a/efi/quark/iarom.h b/efi/quark/iarom.h
new file mode 100644
-index 0000000..b26bda7
+index 0000000..6dcd477
--- /dev/null
-+++ b/efi/clanton/iarom.h
++++ b/efi/quark/iarom.h
@@ -0,0 +1,33 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13015,27 +13509,27 @@ index 0000000..b26bda7
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_IAROM_HEADER
-+#define GRUB_CLANTON_IAROM_HEADER 1
++#ifndef GRUB_QUARK_IAROM_HEADER
++#define GRUB_QUARK_IAROM_HEADER 1
+
-+#include <clanton/clanton.h>
-+#include <clanton/sbh.h>
-+#include <clanton/target.h>
++#include <quark/quark.h>
++#include <quark/sbh.h>
++#include <quark/target.h>
+#include <grub/types.h>
+
+/* Perform signature verification.
+ TODO needs proper documentation. */
-+int grub_cln_verify_asset_signature (grub_uint8_t *addr);
++int grub_quark_verify_asset_signature (grub_uint8_t *addr);
+
-+#endif /* ! GRUB_CLANTON_IAROM_HEADER */
-diff --git a/efi/clanton/imr.c b/efi/clanton/imr.c
++#endif /* ! GRUB_QUARK_IAROM_HEADER */
+diff --git a/efi/quark/imr.c b/efi/quark/imr.c
new file mode 100644
-index 0000000..6e6d43b
+index 0000000..9db3914
--- /dev/null
-+++ b/efi/clanton/imr.c
-@@ -0,0 +1,228 @@
++++ b/efi/quark/imr.c
+@@ -0,0 +1,278 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13058,9 +13552,9 @@ index 0000000..6e6d43b
+#include <grub/types.h>
+#include <shared.h>
+#include <grub/cpu/linux.h>
-+#include <clanton/asset.h>
-+#include <clanton/intel_cln_sb.h>
-+#include <clanton/test_module.h>
++#include <quark/asset.h>
++#include <quark/intel_quark_sb.h>
++#include <quark/test_module.h>
+#include "imr.h"
+
+#define DRAM_IMR1L (0x44) /* IMR1L address */
@@ -13079,13 +13573,20 @@ index 0000000..6e6d43b
+#define LOCK true
+#define UNLOCK false
+#define IMR_MIN_SIZE (0x400)
-+#define IMR_LOCK_BIT (0x80000000)
++#define IMR_LOCK (1 << 31)
++#define IMR_EN (1 << 30)
+/* Mask of the last 2 bit of IMR address [23:2] */
+#define IMR_REG_MASK (0xFFFFFC)
+/* default register value */
+#define IMR_WRITE_ENABLE_ALL (0xFFFFFFFF)
+/* default register value */
+#define IMR_READ_ENABLE_ALL (0xBFFFFFFF)
++
++/*
++ Authorised agents: Non-SMM(0b), Host(30b), PUnit(29b).
++ NOTE: CPU snoop will be always writes
++ */
++
+/* Mask that enables IMR access for Non-SMM Core, Core Snoops Only.*/
+#define IMR_SNOOP_NON_SMM_ENABLE (0x40000001)
+/* Mask that enables IMR access for Non-SMM Core Only.*/
@@ -13096,6 +13597,9 @@ index 0000000..6e6d43b
+/* Right shift of 22-bit IMR addr to fit IMR Lo/Hi register addr field */
+#define IMR_ADDR_SHIFT 8
+
++static int probed;
++static grub_uint16_t dev_id;
++
+/**
+ * imr_align
+ *
@@ -13112,8 +13616,61 @@ index 0000000..6e6d43b
+ return addr;
+}
+
++static void
++sb_write_chk(quark_sb_id id, grub_uint8_t cmd, grub_uint8_t reg, grub_uint32_t d)
++{
++ grub_uint32_t data_verify = 0;
++ intel_quark_sb_write_reg(id, cmd, reg, d);
++ intel_quark_sb_read_reg(id, cmd, reg, &data_verify);
++
++ if (d != data_verify)
++ {
++ grub_printf("FATAL ERROR setting IMR!\n");
++ while(1)
++ {
++ __asm__ __volatile__("hlt\n");
++ }
++ }
++}
++
++static void
++x1000_imr_write(grub_uint32_t lo_addr, grub_uint32_t hi_addr,
++ grub_uint8_t imr_l, grub_uint8_t imr_h,
++ grub_uint8_t imr_rm, grub_uint8_t imr_wm)
++{
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_rm,
++ IMR_READ_ENABLE_ALL);
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_wm,
++ IMR_WRITE_ENABLE_ALL);
++
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_h, hi_addr);
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, lo_addr);
++
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_rm,
++ IMR_NON_SMM_ENABLE);
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_wm,
++ IMR_SNOOP_NON_SMM_ENABLE);
++}
++
++static void
++imr_write(grub_uint32_t lo_addr, grub_uint32_t hi_addr,
++ grub_uint8_t imr_l, grub_uint8_t imr_h,
++ grub_uint8_t imr_rm, grub_uint8_t imr_wm)
++{
++ grub_uint32_t val = 0;
++
++ intel_quark_sb_read_reg(SB_ID_ESRAM, CFG_READ_OPCODE, imr_l, &val);
++ val &= ~IMR_EN;
++ sb_write_chk(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, val);
++
++ sb_write_chk(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_rm, IMR_NON_SMM_ENABLE);
++ sb_write_chk(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_wm, IMR_SNOOP_NON_SMM_ENABLE);
++ sb_write_chk(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_h, hi_addr);
++ sb_write_chk(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, lo_addr);
++}
++
+/**
-+ * intel_cln_imr_write
++ * intel_quark_imr_write
+ *
+ * @param lo_addr: starting memory addr
+ * @param hi_addr: end memory addr
@@ -13125,7 +13682,7 @@ index 0000000..6e6d43b
+ * write in imr memory value to corresponding register addr.
+ */
+static void
-+intel_cln_imr_write(grub_uint32_t lo_addr, grub_uint32_t hi_addr,
++intel_quark_imr_write(grub_uint32_t lo_addr, grub_uint32_t hi_addr,
+ grub_uint8_t imr_l, grub_uint8_t imr_h,
+ grub_uint8_t imr_rm, grub_uint8_t imr_wm, bool lock)
+{
@@ -13138,51 +13695,38 @@ index 0000000..6e6d43b
+ * 3. assign IMR High address to where you want
+ * 4. apply read/write access masks
+ */
-+ intel_cln_sb_read_reg(SB_ID_ESRAM, CFG_READ_OPCODE, imr_l, &tmp_addr);
-+ if(tmp_addr & IMR_LOCK_BIT)
++ intel_quark_sb_read_reg(SB_ID_ESRAM, CFG_READ_OPCODE, imr_l, &tmp_addr);
++ if(tmp_addr & IMR_LOCK)
+ {
-+ grub_printf("%s IMR has already locked.\n ",__func__);
++ grub_printf("IMR already locked: will not set it up\n");
+ return;
+ }
+
-+ if(tmp_addr)
++ if (tmp_addr && grub_quark_debug)
++ grub_printf("Setting already used IMR (start=0x%08x)\n", tmp_addr);
++
++ if (grub_quark_debug)
+ {
-+ if (grub_cln_debug)
-+ grub_printf("%s IMR already in use, start at: 0x%08x \n",
-+ __func__, tmp_addr);
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_rm,
-+ IMR_READ_ENABLE_ALL );
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_wm,
-+ IMR_WRITE_ENABLE_ALL);
++ grub_printf("IMRXL 0x%08x\n", lo_addr);
++ grub_printf("IMRXH 0x%08x\n", hi_addr);
+ }
+
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_h, hi_addr);
-+ if (grub_cln_debug)
-+ grub_printf("%s IMRXH 0x%08x\n", __func__, hi_addr);
-+
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, lo_addr);
-+ if (grub_cln_debug)
-+ grub_printf("%s IMRXL 0x%08x\n", __func__, lo_addr);
-+
-+ /* authrised agents to access initrd: Non-SMM(0b), Host(30b), PUnit(29b) */
-+ /* NOTE. CPU snoop will be always writes */
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_rm,
-+ IMR_NON_SMM_ENABLE);
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_wm,
-+ IMR_SNOOP_NON_SMM_ENABLE);
++ if (PCI_DEVICE_ID_QUARK_X1000_HBRIDGE == dev_id)
++ x1000_imr_write(lo_addr, hi_addr, imr_l, imr_h, imr_rm, imr_wm);
++ else
++ imr_write(lo_addr, hi_addr, imr_l, imr_h, imr_rm, imr_wm);
+
+ if(lock)
+ {
-+ lo_addr |= IMR_LOCK_BIT;
-+ intel_cln_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, lo_addr);
-+ if (grub_cln_debug)
++ lo_addr |= IMR_LOCK;
++ intel_quark_sb_write_reg(SB_ID_ESRAM, CFG_WRITE_OPCODE, imr_l, lo_addr);
++ if (grub_quark_debug)
+ grub_printf("%s IMRXL locked 0x%08x\n", __func__, lo_addr);
+ }
-+
+}
+
+/**
-+ * intel_cln_imr_setup
++ * intel_quark_imr_setup
+ *
+ * @param id: IMR ID
+ * @param addr: starting addr
@@ -13191,9 +13735,8 @@ index 0000000..6e6d43b
+ * setup IMR protection of the specified memory region.
+ */
+grub_error_t
-+intel_cln_imr_setup(imr_range id, grub_addr_t addr, grub_size_t size)
++intel_quark_imr_setup(imr_range id, grub_addr_t addr, grub_size_t size)
+{
-+
+ /* The steps to setup IMR in Grub
+ * 1. calculate the memory address
+ * 2. memory alignment to 1k
@@ -13208,18 +13751,19 @@ index 0000000..6e6d43b
+
+ errnum = ERR_NONE;
+
++ if (!probed)
++ {
++ if (intel_quark_sb_probe(&dev_id))
++ return errnum;
++ probed = 1;
++ }
++
+ if(size < IMR_MIN_SIZE)
+ {
-+ grub_printf("Invalid input size! \n ");
++ grub_printf("Invalid IMR input size %d\n", size);
+ errnum = ERR_BAD_ARGUMENT;
+ return errnum;
+ }
-+ else
-+ {
-+ if (grub_cln_debug)
-+ grub_printf("setting imr with input: addr=0x%08x, size=0x%x \n",
-+ addr, (unsigned int)size);
-+ }
+
+ /* align to 1k boundary */
+ imr_lo_addr = imr_align(addr);
@@ -13239,7 +13783,7 @@ index 0000000..6e6d43b
+ /* IMR for boot params */
+ case IMR_RANGE_BOOT:
+ {
-+ intel_cln_imr_write(imr_lo_addr, imr_hi_addr, DRAM_IMR1L, DRAM_IMR1H,
++ intel_quark_imr_write(imr_lo_addr, imr_hi_addr, DRAM_IMR1L, DRAM_IMR1H,
+ DRAM_IMR1RM, DRAM_IMR1WM, UNLOCK);
+ break;
+ }
@@ -13247,7 +13791,7 @@ index 0000000..6e6d43b
+ /* IMR for bzImage */
+ case IMR_RANGE_BZIMAGE:
+ {
-+ intel_cln_imr_write(imr_lo_addr, imr_hi_addr, DRAM_IMR7L, DRAM_IMR7H,
++ intel_quark_imr_write(imr_lo_addr, imr_hi_addr, DRAM_IMR7L, DRAM_IMR7H,
+ DRAM_IMR7RM, DRAM_IMR7WM, UNLOCK);
+ break;
+ }
@@ -13262,14 +13806,14 @@ index 0000000..6e6d43b
+ return errnum;
+}
+/* EOL */
-diff --git a/efi/clanton/imr.h b/efi/clanton/imr.h
+diff --git a/efi/quark/imr.h b/efi/quark/imr.h
new file mode 100644
-index 0000000..38391cd
+index 0000000..653f5ee
--- /dev/null
-+++ b/efi/clanton/imr.h
++++ b/efi/quark/imr.h
@@ -0,0 +1,38 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13303,17 +13847,17 @@ index 0000000..38391cd
+
+
+/* setup IMR protection of the specified memory region */
-+grub_error_t intel_cln_imr_setup(imr_range id, grub_addr_t addr, grub_size_t size);
++grub_error_t intel_quark_imr_setup(imr_range id, grub_addr_t addr, grub_size_t size);
+
+#endif /*__IMR_H__*/
-diff --git a/efi/clanton/intel_cln_sb.c b/efi/clanton/intel_cln_sb.c
+diff --git a/efi/quark/intel_quark_sb.c b/efi/quark/intel_quark_sb.c
new file mode 100644
-index 0000000..3bbecfc
+index 0000000..6b193a9
--- /dev/null
-+++ b/efi/clanton/intel_cln_sb.c
-@@ -0,0 +1,210 @@
++++ b/efi/quark/intel_quark_sb.c
+@@ -0,0 +1,192 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13334,19 +13878,17 @@ index 0000000..3bbecfc
+
+#include <netboot/linux-asm-io.h>
+#include <stage2/shared.h>
-+#include "intel_cln_sb.h"
++#include "intel_quark_sb.h"
+
-+#define INTEL_CLN_SB_CMD_ADDR (0x000000D0)
-+#define INTEL_CLN_SB_DATA_ADDR (0x000000D4)
++#define INTEL_QUARK_SB_CMD_ADDR (0x000000D0)
++#define INTEL_QUARK_SB_DATA_ADDR (0x000000D4)
+
-+#define INTEL_CLN_SB_MCR_SHIFT (24)
-+#define INTEL_CLN_SB_PORT_SHIFT (16)
-+#define INTEL_CLN_SB_REG_SHIFT (8)
-+#define INTEL_CLN_SB_BYTEEN (0xF0) /* enable all 32 bits */
++#define INTEL_QUARK_SB_MCR_SHIFT (24)
++#define INTEL_QUARK_SB_PORT_SHIFT (16)
++#define INTEL_QUARK_SB_REG_SHIFT (8)
++#define INTEL_QUARK_SB_BYTEEN (0xF0) /* enable all 32 bits */
+
+/* PCI config space reg definitions */
-+#define PCI_VENDOR_ID (0x00)
-+#define PCI_DEVICE_ID (0x02)
+#define PCI_CLASS_DEVICE (0x0A)
+
+struct sb_pci_dev {
@@ -13411,11 +13953,11 @@ index 0000000..3bbecfc
+}
+
+/**
-+ * intel_cln_sb_read_reg
++ * intel_quark_sb_read_reg
+ *
-+ * @param cln_sb_id: Sideband identifier
++ * @param quark_sb_id: Sideband identifier
+ * @param command: Command to send to destination identifier
-+ * @param reg: Target register w/r to cln_sb_id
++ * @param reg: Target register w/r to quark_sb_id
+ * @return nothing
+ *
+ * Utility function to allow thread-safe read of side-band
@@ -13423,67 +13965,57 @@ index 0000000..3bbecfc
+ * hard-code this value directly into msg
+ */
+void
-+intel_cln_sb_read_reg(cln_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
++intel_quark_sb_read_reg(quark_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
+ grub_uint32_t *data)
+{
-+ grub_uint32_t msg = (cmd << INTEL_CLN_SB_MCR_SHIFT) |
-+ ((id << INTEL_CLN_SB_PORT_SHIFT) & 0xFF0000)|
-+ ((reg << INTEL_CLN_SB_REG_SHIFT) & 0xFF00)|
-+ INTEL_CLN_SB_BYTEEN;
++ grub_uint32_t msg = (cmd << INTEL_QUARK_SB_MCR_SHIFT) |
++ ((id << INTEL_QUARK_SB_PORT_SHIFT) & 0xFF0000)|
++ ((reg << INTEL_QUARK_SB_REG_SHIFT) & 0xFF00)|
++ INTEL_QUARK_SB_BYTEEN;
+
+ if(data == NULL)
+ return;
+
-+ pci_write_config_dword(&sb_pcidev, INTEL_CLN_SB_CMD_ADDR, msg);
-+ pci_read_config_dword(&sb_pcidev, INTEL_CLN_SB_DATA_ADDR, data);
++ pci_write_config_dword(&sb_pcidev, INTEL_QUARK_SB_CMD_ADDR, msg);
++ pci_read_config_dword(&sb_pcidev, INTEL_QUARK_SB_DATA_ADDR, data);
+
+}
+
+/**
-+ * intel_cln_sb_write_reg
++ * intel_quark_sb_write_reg
+ *
-+ * @param cln_sb_id: Sideband identifier
++ * @param quark_sb_id: Sideband identifier
+ * @param command: Command to send to destination identifier
-+ * @param reg: Target register w/r to cln_sb_id
++ * @param reg: Target register w/r to quark_sb_id
+ * @return nothing
+ *
+ * Utility function to allow thread-safe write of side-band
+ */
+void
-+intel_cln_sb_write_reg(cln_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
++intel_quark_sb_write_reg(quark_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
+ grub_uint32_t data)
+{
-+ grub_uint32_t msg = (cmd << INTEL_CLN_SB_MCR_SHIFT) |
-+ ((id << INTEL_CLN_SB_PORT_SHIFT) & 0xFF0000)|
-+ ((reg << INTEL_CLN_SB_REG_SHIFT) & 0xFF00)|
-+ INTEL_CLN_SB_BYTEEN;
++ grub_uint32_t msg = (cmd << INTEL_QUARK_SB_MCR_SHIFT) |
++ ((id << INTEL_QUARK_SB_PORT_SHIFT) & 0xFF0000)|
++ ((reg << INTEL_QUARK_SB_REG_SHIFT) & 0xFF00)|
++ INTEL_QUARK_SB_BYTEEN;
+
-+ pci_write_config_dword(&sb_pcidev, INTEL_CLN_SB_DATA_ADDR, data);
-+ pci_write_config_dword(&sb_pcidev, INTEL_CLN_SB_CMD_ADDR, msg);
++ pci_write_config_dword(&sb_pcidev, INTEL_QUARK_SB_DATA_ADDR, data);
++ pci_write_config_dword(&sb_pcidev, INTEL_QUARK_SB_CMD_ADDR, msg);
+}
+
-+
-+/* Clanton hardware */
-+#define PCI_VENDOR_ID_INTEL (0x8086)
-+#define PCI_DEVICE_ID_CLANTON_SB (0x0958)
-+
+/**
-+ * sb_probe
++ * intel_quark_sb_probe
+ *
-+ * @param dev: the PCI device matching
-+ * @param id: entry in the match table
-+ * @return 0
-+ *
-+ * Callback from PCI layer when dev/vendor ids match.
-+ * Sets up necessary resources
++ * @param found_devid: the found PCI device ID (if any)
++ * @return 0 if success, !0 otherwise
+ */
+int
-+intel_cln_sb_probe(void)
++intel_quark_sb_probe(grub_uint16_t *found_devid)
+{
+ int found = 0;
+ grub_uint16_t class;
+ grub_uint16_t device, vendor;
-+ grub_uint8_t type;
+
+ sb_pcidev.bus = 0;
+ for (sb_pcidev.dev_fn = 0; sb_pcidev.dev_fn < 0xFF; sb_pcidev.dev_fn++)
@@ -13494,42 +14026,36 @@ index 0000000..3bbecfc
+ if (class == 0xffff)
+ continue;
+
-+ pci_read_config_word(&sb_pcidev, PCI_VENDOR_ID, &vendor);
-+ pci_read_config_word(&sb_pcidev, PCI_DEVICE_ID, &device);
++ pci_read_config_word(&sb_pcidev, PCI_VENDOR_ID, &vendor);
++ pci_read_config_word(&sb_pcidev, PCI_DEVICE_ID, &device);
+
-+ /* Do early PCI UART init */
-+ if(vendor == PCI_VENDOR_ID_INTEL)
-+ {
-+ if (device == PCI_DEVICE_ID_CLANTON_SB)
-+ {
-+ /* Found */
-+ found = 1;
-+ grub_printf("%s b/d/f 0x%04x/0x%04x scan vendor 0x%04x device 0x%04x\n",
-+ __func__, sb_pcidev.bus, sb_pcidev.dev_fn, vendor, device);
-+ break;
-+ }
-+ }
-+ }
++ if(vendor != PCI_VENDOR_ID_INTEL)
++ continue;
+
-+ if(found == 0)
-+ {
-+ grub_printf("Unable to init side-band!\n");
-+ return -1;
++ if (device == PCI_DEVICE_ID_QUARK_X1000_HBRIDGE || device == 0x12C0)
++ {
++ found = 1;
++ *found_devid = device;
++ if (grub_quark_debug)
++ grub_printf("Host Bridge B/DF 0x%04x/0x%04x VID/DID 0x%04x/0x%04x\n",
++ sb_pcidev.bus, sb_pcidev.dev_fn, vendor, device);
++ return 0;
++ }
+ }
+
-+ grub_printf("Intel Clanton side-band driver registered\n");
++ grub_printf("Couldn't enumerate Host Bridge\n");
++ errnum = ERR_DEV_VALUES;
+
-+
-+ return 0;
++ return errnum;
+}
-diff --git a/efi/clanton/intel_cln_sb.h b/efi/clanton/intel_cln_sb.h
+diff --git a/efi/quark/intel_quark_sb.h b/efi/quark/intel_quark_sb.h
new file mode 100644
-index 0000000..dde6135
+index 0000000..7ee4924
--- /dev/null
-+++ b/efi/clanton/intel_cln_sb.h
-@@ -0,0 +1,47 @@
++++ b/efi/quark/intel_quark_sb.h
+@@ -0,0 +1,51 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13548,41 +14074,45 @@ index 0000000..dde6135
+ * Intel Corporation
+ */
+
-+#ifndef __INTEL_CLN_SB_HEADER__
-+#define __INTEL_CLN_SB_HEADER__
++#ifndef __INTEL_QUARK_SB_HEADER__
++#define __INTEL_QUARK_SB_HEADER__
+
-+#include <clanton/clanton.h>
-+#include <clanton/sbh.h>
-+#include <clanton/target.h>
++#include <quark/quark.h>
++#include <quark/sbh.h>
++#include <quark/target.h>
+#include <grub/types.h>
++#include <netboot/pci.h>
++
++/* Intel Quark Host Bridge PCI identifiers */
++#define PCI_DEVICE_ID_QUARK_X1000_HBRIDGE (0x0958)
+
+typedef enum {
+ SB_ID_HUNIT = 0x03,
-+ SB_ID_PUNIT = 0x04,
-+ SB_ID_ESRAM = 0x05,
-+ SB_ID_SEC_FUSE = 0x33, /* Fuse banks */
-+}cln_sb_id;
++ SB_ID_PUNIT = 0x04,
++ SB_ID_ESRAM = 0x05,
++ SB_ID_SEC_FUSE = 0x33, /* Fuse banks */
++}quark_sb_id;
+
+/* Sideband MCR opcodes */
+#define CFG_READ_FUSE_OPCODE (0x06) /* Fuse read */
+#define CFG_READ_OPCODE (0x10) /* Register read */
+#define CFG_WRITE_OPCODE (0x11) /* Register write */
+
-+int intel_cln_sb_probe (void);
-+void intel_cln_sb_read_reg(cln_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
++int intel_quark_sb_probe (grub_uint16_t *found_devid);
++void intel_quark_sb_read_reg(quark_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
+ grub_uint32_t *data);
-+void intel_cln_sb_write_reg(cln_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
++void intel_quark_sb_write_reg(quark_sb_id id, grub_uint8_t cmd, grub_uint8_t reg,
+ grub_uint32_t data);
-+#endif /* __INTEL_CLN_SB_HEADER__ */
++#endif /* __INTEL_QUARK_SB_HEADER__ */
+
-diff --git a/efi/clanton/mfh.c b/efi/clanton/mfh.c
+diff --git a/efi/quark/mfh.c b/efi/quark/mfh.c
new file mode 100644
-index 0000000..a1c3029
+index 0000000..f16efd7
--- /dev/null
-+++ b/efi/clanton/mfh.c
++++ b/efi/quark/mfh.c
@@ -0,0 +1,91 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13601,31 +14131,31 @@ index 0000000..a1c3029
+ * Intel Corporation
+ */
+
-+#include <clanton/clanton.h>
-+#include <clanton/flash.h>
-+#include <clanton/mfh.h>
++#include <quark/quark.h>
++#include <quark/flash.h>
++#include <quark/mfh.h>
+#include <shared.h>
+
+#define offsetof(st, m) \
+ ((unsigned int) ( (char *)&((st *)0)->m - (char *)0 ))
+
-+static struct grub_cln_mfh cln_mfh;
-+static int cln_mfh_loaded = 0;
++static struct grub_quark_mfh quark_mfh;
++static int quark_mfh_loaded = 0;
+
+void
-+grub_cln_mfh_load (const struct grub_cln_mfh *mfh)
++grub_quark_mfh_load (const struct grub_quark_mfh *mfh)
+{
-+ grub_memcpy (&cln_mfh, (grub_uint8_t *) mfh, sizeof (cln_mfh));
-+ cln_mfh_loaded = 1;
++ grub_memcpy (&quark_mfh, (grub_uint8_t *) mfh, sizeof (quark_mfh));
++ quark_mfh_loaded = 1;
+}
+
+grub_error_t
-+grub_cln_mfh_entry_lookup (const grub_uint8_t *mfh_addr, unsigned int entry_type,
++grub_quark_mfh_entry_lookup (const grub_uint8_t *mfh_addr, unsigned int entry_type,
+ grub_uint8_t **addr, grub_uint32_t *len)
+{
+ unsigned int offset = 0x0;
+ unsigned int i = 0;
-+ grub_cln_mfh_item_t item = 0x0;
++ grub_quark_mfh_item_t item = 0x0;
+
+ if (! mfh_addr || ! addr || ! len)
+ {
@@ -13635,29 +14165,29 @@ index 0000000..a1c3029
+ }
+
+ /* Fetch the MFH if not done yet. */
-+ if (! cln_mfh_loaded)
-+ grub_cln_mfh_load ((grub_cln_mfh_t) mfh_addr);
++ if (! quark_mfh_loaded)
++ grub_quark_mfh_load ((grub_quark_mfh_t) mfh_addr);
+
+ /* Sanity check. */
-+ if (GRUB_CLN_MFH_IDENTIFIER != cln_mfh.identifier)
++ if (GRUB_QUARK_MFH_IDENTIFIER != quark_mfh.identifier)
+ {
-+ cln_mfh_loaded = 0;
++ quark_mfh_loaded = 0;
+ grub_printf ("%s: invalid MFH identifier\n", __func__);
+ errnum = ERR_EXEC_FORMAT;
+ return errnum;
+ }
+
+ /* Look up. */
-+ offset = offsetof (struct grub_cln_mfh, padding)
-+ + sizeof (grub_uint32_t) * cln_mfh.boot_prio_list_count;
-+ for (i = 0; i < cln_mfh.flash_item_count; i ++, offset += sizeof (*item))
++ offset = offsetof (struct grub_quark_mfh, padding)
++ + sizeof (grub_uint32_t) * quark_mfh.boot_prio_list_count;
++ for (i = 0; i < quark_mfh.flash_item_count; i ++, offset += sizeof (*item))
+ {
-+ item = (grub_cln_mfh_item_t) ((grub_uint8_t *) &cln_mfh + offset);
++ item = (grub_quark_mfh_item_t) ((grub_uint8_t *) &quark_mfh + offset);
+ if (item->type == entry_type)
+ {
+ *len = item->flash_item_len;
+ *addr = (grub_uint8_t *) item->flash_item_addr;
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ grub_printf ("%s: found entry 0x%x @addr=0x%x, len=0x%x\n",
+ __func__, item->type, *addr, *len);
+ return errnum;
@@ -13665,21 +14195,21 @@ index 0000000..a1c3029
+ }
+
+ /* At this stage, we haven't found the item. */
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ grub_printf ("%s: flash item 0x%x not found\n", __func__, entry_type);
+ }
+ errnum = ERR_FILE_NOT_FOUND;
+ return errnum;
+}
-diff --git a/efi/clanton/mfh.h b/efi/clanton/mfh.h
+diff --git a/efi/quark/mfh.h b/efi/quark/mfh.h
new file mode 100644
-index 0000000..c20a7d1
+index 0000000..fa67b79
--- /dev/null
-+++ b/efi/clanton/mfh.h
++++ b/efi/quark/mfh.h
@@ -0,0 +1,96 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13698,17 +14228,17 @@ index 0000000..c20a7d1
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_MFH_HEADER
-+#define GRUB_CLANTON_MFH_HEADER 1
++#ifndef GRUB_QUARK_MFH_HEADER
++#define GRUB_QUARK_MFH_HEADER 1
+
+#include <grub/types.h>
+#include <shared.h>
+
+/* Magic number corresponds to "_MFH" in ASCII. */
-+#define GRUB_CLN_MFH_IDENTIFIER 0x5F4D4648
++#define GRUB_QUARK_MFH_IDENTIFIER 0x5F4D4648
+
-+/* Clanton Master Flash Header. */
-+typedef struct grub_cln_mfh
++/* Quark Master Flash Header. */
++typedef struct grub_quark_mfh
+{
+ grub_uint32_t identifier; /* 0x000 */
+ grub_uint32_t version; /* 0x004 */
@@ -13719,48 +14249,48 @@ index 0000000..c20a7d1
+ /* Pad to 512 bytes. */
+ grub_uint8_t padding[0x1E8]; /* 0x018 */
+}
-+*grub_cln_mfh_t;
++*grub_quark_mfh_t;
+
+
+/* Flash item types. */
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE1 0x00000000
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE1_SIGNED 0x00000001
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE1 0x00000000
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE1_SIGNED 0x00000001
+/* Reserved. */
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE2 0x00000003
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE2_SIGNED 0x00000004
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE2_CONFIG 0x00000005
-+#define CLN_MFH_ITEM_TYPE_FW_STAGE2_CONFIG_SIGNED 0x00000006
-+#define CLN_MFH_ITEM_TYPE_FW_PARAMS 0x00000007
-+#define CLN_MFH_ITEM_TYPE_FW_RECOVERY 0x00000008
-+#define CLN_MFH_ITEM_TYPE_FW_RECOVERY_SIGNED 0x00000009
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE2 0x00000003
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE2_SIGNED 0x00000004
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE2_CONFIG 0x00000005
++#define QUARK_MFH_ITEM_TYPE_FW_STAGE2_CONFIG_SIGNED 0x00000006
++#define QUARK_MFH_ITEM_TYPE_FW_PARAMS 0x00000007
++#define QUARK_MFH_ITEM_TYPE_FW_RECOVERY 0x00000008
++#define QUARK_MFH_ITEM_TYPE_FW_RECOVERY_SIGNED 0x00000009
+/* Reserved. */
-+#define CLN_MFH_ITEM_TYPE_BOOTLOADER 0x0000000B
-+#define CLN_MFH_ITEM_TYPE_BOOTLOADER_SIGNED 0x0000000C
-+#define CLN_MFH_ITEM_TYPE_BOOTLOADER_CONFIG 0x0000000D
-+#define CLN_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED 0x0000000E
++#define QUARK_MFH_ITEM_TYPE_BOOTLOADER 0x0000000B
++#define QUARK_MFH_ITEM_TYPE_BOOTLOADER_SIGNED 0x0000000C
++#define QUARK_MFH_ITEM_TYPE_BOOTLOADER_CONFIG 0x0000000D
++#define QUARK_MFH_ITEM_TYPE_BOOTLOADER_CONFIG_SIGNED 0x0000000E
+/* Reserved. */
-+#define CLN_MFH_ITEM_TYPE_KERNEL 0x00000010
-+#define CLN_MFH_ITEM_TYPE_KERNEL_SIGNED 0x00000011
-+#define CLN_MFH_ITEM_TYPE_RAMDISK 0x00000012
-+#define CLN_MFH_ITEM_TYPE_RAMDISK_SIGNED 0x00000013
++#define QUARK_MFH_ITEM_TYPE_KERNEL 0x00000010
++#define QUARK_MFH_ITEM_TYPE_KERNEL_SIGNED 0x00000011
++#define QUARK_MFH_ITEM_TYPE_RAMDISK 0x00000012
++#define QUARK_MFH_ITEM_TYPE_RAMDISK_SIGNED 0x00000013
+/* Reserved. */
-+#define CLN_MFH_ITEM_TYPE_LOADABLE_PROGRAM 0x00000015
-+#define CLN_MFH_ITEM_TYPE_LOADABLE_PROGRAM_SIGNED 0x00000016
++#define QUARK_MFH_ITEM_TYPE_LOADABLE_PROGRAM 0x00000015
++#define QUARK_MFH_ITEM_TYPE_LOADABLE_PROGRAM_SIGNED 0x00000016
+/* Reserved. */
-+#define CLN_MFH_ITEM_TYPE_BUILD_INFO 0x00000018
++#define QUARK_MFH_ITEM_TYPE_BUILD_INFO 0x00000018
+
+/* Flash item definition. */
-+typedef struct grub_cln_mfh_item
++typedef struct grub_quark_mfh_item
+{
+ grub_uint32_t type; /* 0x000 */
+ grub_uint32_t flash_item_addr; /* 0x004 */
+ grub_uint32_t flash_item_len; /* 0x008 */
+ grub_uint32_t reserved; /* 0x00C */
+}
-+*grub_cln_mfh_item_t;
++*grub_quark_mfh_item_t;
+
+/* Load the MFH into memory. */
-+void grub_cln_mfh_load (const struct grub_cln_mfh *mfh);
++void grub_quark_mfh_load (const struct grub_quark_mfh *mfh);
+
+/* Lookup the MFH for a specific entry_type.
+ The MMIO start address of the MFH is passed by *mfh_addr.
@@ -13768,20 +14298,20 @@ index 0000000..c20a7d1
+ into *len and return ERR_NONE.
+ Return error code if any error.
+ Note it automatically loads the MFH if not already done so. */
-+grub_error_t grub_cln_mfh_entry_lookup (const grub_uint8_t *mfh_addr,
++grub_error_t grub_quark_mfh_entry_lookup (const grub_uint8_t *mfh_addr,
+ unsigned int entry_type,
+ grub_uint8_t **addr,
+ grub_uint32_t *len);
+
-+#endif /* ! GRUB_CLANTON_MFH_HEADER */
-diff --git a/efi/clanton/perf_metrics.c b/efi/clanton/perf_metrics.c
++#endif /* ! GRUB_QUARK_MFH_HEADER */
+diff --git a/efi/quark/perf_metrics.c b/efi/quark/perf_metrics.c
new file mode 100644
-index 0000000..b6fced5
+index 0000000..b8b673a
--- /dev/null
-+++ b/efi/clanton/perf_metrics.c
++++ b/efi/quark/perf_metrics.c
@@ -0,0 +1,53 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13800,47 +14330,47 @@ index 0000000..b6fced5
+ * Intel Corporation
+ */
+
-+#include <clanton/perf_metrics.h>
-+#include <clanton/target.h>
++#include <quark/perf_metrics.h>
++#include <quark/target.h>
+#include <shared.h>
+
+/* String to be appended to the Linux command line. */
-+static char perf_metric_string[GRUB_CLN_PERF_METRIC_STRING_MAXLEN] = "";
++static char perf_metric_string[GRUB_QUARK_PERF_METRIC_STRING_MAXLEN] = "";
+
+void
-+grub_cln_event_reset (void)
++grub_quark_event_reset (void)
+{
-+ grub_memset (perf_metric_string, 0x0, GRUB_CLN_PERF_METRIC_STRING_MAXLEN);
++ grub_memset (perf_metric_string, 0x0, GRUB_QUARK_PERF_METRIC_STRING_MAXLEN);
+}
+
+void
-+grub_cln_event_append (const char *tag)
++grub_quark_event_append (const char *tag)
+{
+ /* Format is (ignore apostrophes): ' tag=0x%016x' plus string terminator,
-+ with length of tag string limited to GRUB_CLN_BOOT_EVENT_TAG_MAXLEN. */
-+ char buf[21 + GRUB_CLN_BOOT_EVENT_TAG_MAXLEN] = "";
-+ char tag_trimmed[GRUB_CLN_BOOT_EVENT_TAG_MAXLEN] = "";
++ with length of tag string limited to GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN. */
++ char buf[21 + GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN] = "";
++ char tag_trimmed[GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN] = "";
+
-+ grub_strncpy (tag_trimmed, tag, GRUB_CLN_BOOT_EVENT_TAG_MAXLEN);
++ grub_strncpy (tag_trimmed, tag, GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN);
+ grub_sprintf (buf, " %s=0x%016llx", tag_trimmed, grub_rdtsc ());
+
+ /* Append entry to performance metric string. */
-+ grub_strncat (perf_metric_string, buf, GRUB_CLN_PERF_METRIC_STRING_MAXLEN);
++ grub_strncat (perf_metric_string, buf, GRUB_QUARK_PERF_METRIC_STRING_MAXLEN);
+}
+
+char *
-+grub_cln_event_get_metrics (void)
++grub_quark_event_get_metrics (void)
+{
+ return perf_metric_string;
+}
-diff --git a/efi/clanton/perf_metrics.h b/efi/clanton/perf_metrics.h
+diff --git a/efi/quark/perf_metrics.h b/efi/quark/perf_metrics.h
new file mode 100644
-index 0000000..d3837c5
+index 0000000..837bd6b
--- /dev/null
-+++ b/efi/clanton/perf_metrics.h
++++ b/efi/quark/perf_metrics.h
@@ -0,0 +1,40 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13859,34 +14389,83 @@ index 0000000..d3837c5
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_TSC_HEADER
-+#define GRUB_CLANTON_TSC_HEADER 1
++#ifndef GRUB_QUARK_TSC_HEADER
++#define GRUB_QUARK_TSC_HEADER 1
+
-+#define GRUB_CLN_PERF_METRIC_STRING_MAXLEN 0x400
-+#define GRUB_CLN_BOOT_EVENT_TAG_MAXLEN 0x15
++#define GRUB_QUARK_PERF_METRIC_STRING_MAXLEN 0x400
++#define GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN 0x15
+
+/* Init/Reinit the performance metric string. */
-+void grub_cln_event_reset (void);
++void grub_quark_event_reset (void);
+
+/* Log an event along with the current timestamp and append it to the
+ performance metric string.
-+ Tag is limited to GRUB_CLN_BOOT_EVENT_TAG_MAXLEN.
-+ Performance metric string is limited to GRUB_CLN_PERF_METRIC_STRING_MAXLEN.
++ Tag is limited to GRUB_QUARK_BOOT_EVENT_TAG_MAXLEN.
++ Performance metric string is limited to GRUB_QUARK_PERF_METRIC_STRING_MAXLEN.
+ Any string overrun is dropped and no error code/message is thrown. */
-+void grub_cln_event_append (const char *tag);
++void grub_quark_event_append (const char *tag);
+
+/* Return the performance metric string */
-+char *grub_cln_event_get_metrics (void);
++char *grub_quark_event_get_metrics (void);
+
-+#endif /* ! GRUB_CLANTON_TSC_HEADER */
-diff --git a/efi/clanton/recovery.c b/efi/clanton/recovery.c
++#endif /* ! GRUB_QUARK_TSC_HEADER */
+diff --git a/efi/quark/quark.h b/efi/quark/quark.h
new file mode 100644
-index 0000000..97677dd
+index 0000000..e966189
--- /dev/null
-+++ b/efi/clanton/recovery.c
++++ b/efi/quark/quark.h
+@@ -0,0 +1,43 @@
++/*
++ * Copyright(c) 2013 Intel Corporation.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of version 2 of the GNU General Public License as
++ * published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Contact Information:
++ * Intel Corporation
++ */
++
++#ifndef GRUB_QUARK_QUARK_HEADER
++#define GRUB_QUARK_QUARK_HEADER 1
++
++/*
++ Kernel command line token to be expanded into Quark UART1 MMIO address.
++ Note the length of the token MUST be > "0xcafebabe", so as to prevent the
++ rest of the string from being overwritten.
++ */
++#define QUARK_UART_MMIO_TOKEN "$EARLY_CON_ADDR_REPLACE"
++
++/* Secure/non-secure boot switch. */
++extern unsigned short int grub_quark_secure;
++/* Debug/release switch. */
++extern unsigned short int grub_quark_debug;
++
++/* State whether the Grub was loaded from SPI/flash or SDIO. */
++extern unsigned short int grub_quark_loaded_from_spi;
++/* State whether the Kernel must be fetched from SPI/flash or SDIO. */
++extern unsigned short int grub_quark_linux_spi;
++/* State whether the Initrd must be fetched from SPI/flash or SDIO. */
++extern unsigned short int grub_quark_initrd_spi;
++
++#endif /* ! GRUB_QUARK_QUARK_HEADER */
+diff --git a/efi/quark/recovery.c b/efi/quark/recovery.c
+new file mode 100644
+index 0000000..88311f0
+--- /dev/null
++++ b/efi/quark/recovery.c
@@ -0,0 +1,164 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -13905,10 +14484,10 @@ index 0000000..97677dd
+ * Intel Corporation
+ */
+
-+#include <clanton/clanton.h>
++#include <quark/quark.h>
+#include <shared.h>
+
-+/* The table of builtin commands preserved in Clanton Recovery debug mode.
++/* The table of builtin commands preserved in Quark Recovery debug mode.
+ Sorted in dictionary order. */
+static char *debug_recovery_cmds[] =
+{
@@ -13924,7 +14503,7 @@ index 0000000..97677dd
+ 0
+};
+
-+/* The table of builtin commands preserved in Clanton Recovery release mode.
++/* The table of builtin commands preserved in Quark Recovery release mode.
+ Sorted in dictionary order. */
+static char *release_recovery_cmds[] =
+{
@@ -13966,37 +14545,37 @@ index 0000000..97677dd
+ }
+}
+
-+/* Clanton-specific recovery shell commands definition. */
++/* Quark-specific recovery shell commands definition. */
+
-+static struct builtin builtin_cln_sdio_program =
++static struct builtin builtin_quark_sdio_program =
+{
-+ .name = "cln_sdio_program",
-+ .func = grub_cln_sdio_program,
++ .name = "quark_sdio_program",
++ .func = grub_quark_sdio_program,
+ .flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
-+ .short_doc = "cln_sdio_program",
-+ .long_doc = "Initiate Clanton SDIO image recovery/installation.",
++ .short_doc = "quark_sdio_program",
++ .long_doc = "Initiate Quark SDIO image recovery/installation.",
+};
+
-+static struct builtin builtin_cln_spi_program =
++static struct builtin builtin_quark_spi_program =
+{
-+ .name = "cln_fw_recovery",
-+ .func = grub_cln_spi_program,
++ .name = "quark_fw_recovery",
++ .func = grub_quark_spi_program,
+ .flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
-+ .short_doc = "cln_fw_recovery",
-+ .long_doc = "Perform Firmware-based Clanton system recovery.",
++ .short_doc = "quark_fw_recovery",
++ .long_doc = "Perform Firmware-based Quark system recovery.",
+};
+
+static int
-+add_cln_recovery_command (unsigned short int is_spi_asset)
++add_quark_recovery_command (unsigned short int is_spi_asset)
+{
+ struct builtin **builtin = 0;
+ unsigned short int success = 0;
+
+ /* Make sure that function name and flags are never overwritten. */
-+ builtin_cln_sdio_program.func = &grub_cln_sdio_program;
-+ builtin_cln_sdio_program.flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST;
-+ builtin_cln_spi_program.func = &grub_cln_spi_program;
-+ builtin_cln_spi_program.flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST;
++ builtin_quark_sdio_program.func = &grub_quark_sdio_program;
++ builtin_quark_sdio_program.flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST;
++ builtin_quark_spi_program.func = &grub_quark_spi_program;
++ builtin_quark_spi_program.flags = BUILTIN_CMDLINE | BUILTIN_HELP_LIST;
+
+ /* Place recovery commands into free builtin_table[] entries.
+ This should never fail, provided that the original list of built-in
@@ -14005,11 +14584,11 @@ index 0000000..97677dd
+ {
+ if (NULL == (*builtin)->func)
+ {
-+ /* Clanton-specific commands are mutually exclusive. */
++ /* Quark-specific commands are mutually exclusive. */
+ if (is_spi_asset)
-+ (*builtin) = &builtin_cln_spi_program;
++ (*builtin) = &builtin_quark_spi_program;
+ else
-+ (*builtin) = &builtin_cln_sdio_program;
++ (*builtin) = &builtin_quark_sdio_program;
+
+ success = 1;
+ break;
@@ -14019,29 +14598,29 @@ index 0000000..97677dd
+ return success;
+}
+
-+/* Enter a Clanton recovery shell for error handling.
-+ The shell provides a set of restricted debug commands and Clanton-specific
++/* Enter a Quark recovery shell for error handling.
++ The shell provides a set of restricted debug commands and Quark-specific
+ commands for Grub-provided SDIO recovery and Firmware-provided SPI recovery.
+ The Firmware-provided recovery mechanism is exposed when the failing asset
+ resides in SPI/flash. Alternatively the SDIO program utility is made
+ available. */
+void
-+grub_cln_recovery_shell (unsigned short int is_spi_asset)
++grub_quark_recovery_shell (unsigned short int is_spi_asset)
+{
+ grub_error_t original_errnum = errnum;
+
-+ if (grub_cln_secure)
++ if (grub_quark_secure)
+ {
+ /* Restrict available commands. */
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ restrict_builtin_commands (debug_recovery_cmds); //XXX secure-debug recovery commands..
+ else
+ restrict_builtin_commands (release_recovery_cmds); //XXX ditto
+ }
+
-+ /* Add Clanton-specific recovery commands. */
-+ if (! add_cln_recovery_command (is_spi_asset))
-+ grub_printf ("%s() - failed adding Clanton-specific command\n", __func__);
++ /* Add Quark-specific recovery commands. */
++ if (! add_quark_recovery_command (is_spi_asset))
++ grub_printf ("%s() - failed adding Quark-specific command\n", __func__);
+
+ errnum = original_errnum;
+
@@ -14049,14 +14628,14 @@ index 0000000..97677dd
+ enter_cmdline (heap, 1, 1);
+ grub_printf ("BUG: %s() returning\n", __func__);
+}
-diff --git a/efi/clanton/sbh.h b/efi/clanton/sbh.h
+diff --git a/efi/quark/sbh.h b/efi/quark/sbh.h
new file mode 100644
-index 0000000..3311dc9
+index 0000000..51dbd33
--- /dev/null
-+++ b/efi/clanton/sbh.h
++++ b/efi/quark/sbh.h
@@ -0,0 +1,73 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14075,19 +14654,19 @@ index 0000000..3311dc9
+ * Intel Corporation
+ */
+
-+#ifndef GRUB_CLANTON_SBH_HEADER
-+#define GRUB_CLANTON_SBH_HEADER 1
++#ifndef GRUB_QUARK_SBH_HEADER
++#define GRUB_QUARK_SBH_HEADER 1
+
+#include <grub/types.h>
+
-+/* Clanton Secure Boot Header. */
++/* Quark Secure Boot Header. */
+
+/* Magic number corresponds to "_CSH" in ASCII. */
-+#define GRUB_CLN_SBH_MAGIC_NUMBER 0x5F435348
++#define GRUB_QUARK_SBH_MAGIC_NUMBER 0x5F435348
+
-+typedef struct grub_cln_sbh
++typedef struct grub_quark_sbh
+{
-+ struct grub_cln_sbh_security_hdr
++ struct grub_quark_sbh_security_hdr
+ {
+ grub_uint32_t magic_number; /* 0x000 */
+ grub_uint32_t version; /* 0x004 */
@@ -14105,7 +14684,7 @@ index 0000000..3311dc9
+ grub_uint32_t next_header_ptr; /* 0x034 */
+ grub_uint8_t reserved[0x8]; /* 0x038 */
+ } security_header;
-+ struct grub_cln_csh_key_hdr
++ struct grub_quark_csh_key_hdr
+ {
+ grub_uint32_t key_modulus_size; /* 0x040 */
+ grub_uint32_t key_exponent_size; /* 0x044 */
@@ -14116,26 +14695,26 @@ index 0000000..3311dc9
+ /* Currently we only support RSA. Hence size is hardcoded. */
+ grub_uint8_t signature[0x100]; /* 0x14C */
+}
-+*grub_cln_csh_t;
++*grub_quark_csh_t;
+
+
-+/* Settings for Clanton SBH on filesystem. */
++/* Settings for Quark SBH on filesystem. */
+
-+#define GRUB_CLN_SBH_FILE_EXT ".csbh"
++#define GRUB_QUARK_SBH_FILE_EXT ".csbh"
+/* Be as conservative as possible about the max path length. Use the minimum
+ value allowed by the file systems supported by GRUB. */
-+#define GRUB_CLN_SBH_FILE_PATHMAX 1024 /* FIXME */
++#define GRUB_QUARK_SBH_FILE_PATHMAX 1024 /* FIXME */
+
+
-+#endif /* ! GRUB_CLANTON_SBH_HEADER */
-diff --git a/efi/clanton/sdio_program.c b/efi/clanton/sdio_program.c
++#endif /* ! GRUB_QUARK_SBH_HEADER */
+diff --git a/efi/quark/sdio_program.c b/efi/quark/sdio_program.c
new file mode 100644
-index 0000000..762386b
+index 0000000..3f0dbcc
--- /dev/null
-+++ b/efi/clanton/sdio_program.c
++++ b/efi/quark/sdio_program.c
@@ -0,0 +1,35 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14159,9 +14738,9 @@ index 0000000..762386b
+/* SDIO filesystem installation/recovery utility.
+ Perform eMMC programming. */
+int
-+grub_cln_sdio_program (char *s, int i)
++grub_quark_sdio_program (char *s, int i)
+{
-+ grub_printf ("Clanton SDIO program utility\n");
++ grub_printf ("Quark SDIO program utility\n");
+
+ /* Not implemented yet. */
+
@@ -14169,14 +14748,14 @@ index 0000000..762386b
+
+ return 0;
+}
-diff --git a/efi/clanton/spi_program.c b/efi/clanton/spi_program.c
+diff --git a/efi/quark/spi_program.c b/efi/quark/spi_program.c
new file mode 100644
-index 0000000..bf2d6dd
+index 0000000..9d8891f
--- /dev/null
-+++ b/efi/clanton/spi_program.c
++++ b/efi/quark/spi_program.c
@@ -0,0 +1,33 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14199,7 +14778,7 @@ index 0000000..bf2d6dd
+
+/* Trigger a FW-initiated recovery session. */
+int
-+grub_cln_spi_program (char *s, int i)
++grub_quark_spi_program (char *s, int i)
+{
+ grub_printf ("%s()\n", __func__);
+
@@ -14208,14 +14787,14 @@ index 0000000..bf2d6dd
+
+ return 0;
+}
-diff --git a/efi/clanton/target.h b/efi/clanton/target.h
+diff --git a/efi/quark/target.h b/efi/quark/target.h
new file mode 100644
-index 0000000..6610473
+index 0000000..da047bb
--- /dev/null
-+++ b/efi/clanton/target.h
++++ b/efi/quark/target.h
@@ -0,0 +1,37 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14234,11 +14813,11 @@ index 0000000..6610473
+ * Intel Corporation
+ */
+
-+#ifndef CLANTON_TARGET_HEADER
-+#define CLANTON_TARGET_HEADER
++#ifndef QUARK_TARGET_HEADER
++#define QUARK_TARGET_HEADER
+
+/* Pointer to IAROM callback address for signature verification. */
-+#define GRUB_CLN_IAROM_CALLBACK_PTR 0xFFFFFFE0
++#define GRUB_QUARK_IAROM_CALLBACK_PTR 0xFFFFFFE0
+
+/* Read the time-stamp counter. */
+static inline unsigned long long int
@@ -14250,15 +14829,15 @@ index 0000000..6610473
+ return (unsigned long long) hi << 32 | lo;
+}
+
-+#endif /* CLANTON_TARGET_HEADER */
-diff --git a/efi/clanton/test_module.c b/efi/clanton/test_module.c
++#endif /* QUARK_TARGET_HEADER */
+diff --git a/efi/quark/test_module.c b/efi/quark/test_module.c
new file mode 100644
-index 0000000..cebc115
+index 0000000..50ae4c9
--- /dev/null
-+++ b/efi/clanton/test_module.c
++++ b/efi/quark/test_module.c
@@ -0,0 +1,156 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14277,14 +14856,14 @@ index 0000000..cebc115
+ * Intel Corporation
+ */
+
-+#include <clanton/flash.h>
-+#include <clanton/intel_cln_sb.h>
-+#include <clanton/test_module.h>
++#include <quark/flash.h>
++#include <quark/intel_quark_sb.h>
++#include <quark/test_module.h>
+#include <grub/cpu/linux.h>
+#include <shared.h>
+
+/* Test-specific parameters from kernel command line */
-+#define TEST_PARAM_ID "__cln_drive_failure="
++#define TEST_PARAM_ID "__quark_drive_failure="
+#define TEST_PARAM_NO_KERNEL "no-kernel"
+#define TEST_PARAM_NO_RAMDISK "no-ramdisk"
+#define TEST_PARAM_NO_KERNEL_SIG "no-kernel-signature"
@@ -14294,7 +14873,7 @@ index 0000000..cebc115
+#define TEST_PARAM_BAD_IMR "bad-imr"
+
+/* Test setup and state */
-+struct __cln_error_trigger_struct __cln_err = {
++struct __quark_error_trigger_struct __quark_err = {
+ .no_kernel = 0,
+ .no_ramdisk = 0,
+ .no_kernel_sig = 0,
@@ -14321,19 +14900,19 @@ index 0000000..cebc115
+spi_dma_read (grub_uint32_t *src, grub_uint32_t *dst,
+ grub_uint32_t dma_block_count)
+{
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ grub_printf ("%s: src=%p, dst=%p, count=%u\n", __func__, src, dst,
+ dma_block_count);
+ }
+
+ /* Setup source and destination addresses. */
-+ intel_cln_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_SRC_REG,
++ intel_quark_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_SRC_REG,
+ (grub_uint32_t) src);
-+ intel_cln_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_DEST_REG,
++ intel_quark_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_DEST_REG,
+ (grub_uint32_t) dst);
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ grub_printf ("%s: starting transaction\n", __func__);
+ }
@@ -14342,17 +14921,17 @@ index 0000000..cebc115
+ Setup the number of block to be copied over. Transaction will start as
+ soon as the register is filled with value.
+ */
-+ intel_cln_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_COUNT_REG,
++ intel_quark_sb_write_reg (SB_ID_PUNIT, CFG_WRITE_OPCODE, PUNIT_SPI_DMA_COUNT_REG,
+ dma_block_count);
+
+ /* Poll for completion. */
+ while (dma_block_count > 0)
+ {
-+ intel_cln_sb_read_reg (SB_ID_PUNIT, CFG_READ_OPCODE, PUNIT_SPI_DMA_COUNT_REG,
++ intel_quark_sb_read_reg (SB_ID_PUNIT, CFG_READ_OPCODE, PUNIT_SPI_DMA_COUNT_REG,
+ &dma_block_count);
+ }
+
-+ if (grub_cln_debug)
++ if (grub_quark_debug)
+ {
+ grub_printf ("%s: transaction completed\n", __func__);
+ }
@@ -14363,7 +14942,7 @@ index 0000000..cebc115
+ variable accordingly.
+ */
+void
-+__cln_test_setup (char *arg)
++__quark_test_setup (char *arg)
+{
+ char *test_param = grub_strstr (arg, TEST_PARAM_ID);
+ if (test_param)
@@ -14371,19 +14950,19 @@ index 0000000..cebc115
+ test_param += grub_strlen(TEST_PARAM_ID);
+
+ if (grub_strstr(test_param, TEST_PARAM_NO_KERNEL))
-+ __cln_err.no_kernel = 1;
++ __quark_err.no_kernel = 1;
+ if (grub_strstr(test_param, TEST_PARAM_NO_RAMDISK))
-+ __cln_err.no_ramdisk = 1;
++ __quark_err.no_ramdisk = 1;
+ if (grub_strstr(test_param, TEST_PARAM_NO_KERNEL_SIG))
-+ __cln_err.no_kernel_sig = 1;
++ __quark_err.no_kernel_sig = 1;
+ if (grub_strstr(test_param, TEST_PARAM_NO_RAMDISK_SIG))
-+ __cln_err.no_ramdisk_sig = 1;
++ __quark_err.no_ramdisk_sig = 1;
+ if (grub_strstr(test_param, TEST_PARAM_BAD_KERNEL_SIG))
-+ __cln_err.kernel_sig_fail = 1;
++ __quark_err.kernel_sig_fail = 1;
+ if (grub_strstr(test_param, TEST_PARAM_BAD_RAMDISK_SIG))
-+ __cln_err.ramdisk_sig_fail = 1;
++ __quark_err.ramdisk_sig_fail = 1;
+ if (grub_strstr(test_param, TEST_PARAM_BAD_IMR))
-+ __cln_err.bad_imr = 1;
++ __quark_err.bad_imr = 1;
+ }
+}
+
@@ -14396,31 +14975,31 @@ index 0000000..cebc115
+ IMR.
+ */
+void
-+__cln_test_imr (void)
++__quark_test_imr (void)
+{
+ grub_uint32_t *p = (grub_uint32_t *) GRUB_LINUX_BZIMAGE_ADDR;
+
-+ if (! __cln_err.bad_imr)
++ if (! __quark_err.bad_imr)
+ return;
+
-+ spi_dma_read ((grub_uint32_t *) GRUB_CLN_MFH_ADDR, spi_buffer, 1);
++ spi_dma_read ((grub_uint32_t *) GRUB_QUARK_MFH_ADDR, spi_buffer, 1);
+ grub_printf ("%s: PUnit DMAing %uB into temp buffer passed\n", __func__,
+ SPI_DMA_BLOCK_SIZE);
+
+ grub_printf ("%s: PUnit DMAing %uB into non-PUnit IMR @%p\n", __func__,
+ SPI_DMA_BLOCK_SIZE, p);
-+ spi_dma_read ((grub_uint32_t *) GRUB_CLN_MFH_ADDR, p, 1);
++ spi_dma_read ((grub_uint32_t *) GRUB_QUARK_MFH_ADDR, p, 1);
+ grub_printf ("%s: BUG: PUnit DMA to non-PUnit IMR didn't fail!\n", __func__);
+}
+
-diff --git a/efi/clanton/test_module.h b/efi/clanton/test_module.h
+diff --git a/efi/quark/test_module.h b/efi/quark/test_module.h
new file mode 100644
-index 0000000..4c0fa28
+index 0000000..013d2ea
--- /dev/null
-+++ b/efi/clanton/test_module.h
++++ b/efi/quark/test_module.h
@@ -0,0 +1,92 @@
+/*
-+ * Copyright(c) 2013 Intel Corporation. All rights reserved.
++ * Copyright(c) 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
@@ -14439,11 +15018,11 @@ index 0000000..4c0fa28
+ * Intel Corporation
+ */
+
-+#include <clanton/asset.h>
++#include <quark/asset.h>
+#include <grub/types.h>
+
+/* Keep track of error triggering condition. */
-+struct __cln_error_trigger_struct {
++struct __quark_error_trigger_struct {
+ int no_kernel;
+ int no_ramdisk;
+ int no_kernel_sig;
@@ -14455,609 +15034,62 @@ index 0000000..4c0fa28
+ int state_sign_verify;
+};
+
-+extern struct __cln_error_trigger_struct __cln_err;
++extern struct __quark_error_trigger_struct __quark_err;
+
-+void __cln_test_setup (char *);
-+void __cln_test_imr (void);
++void __quark_test_setup (char *);
++void __quark_test_imr (void);
+
-+#ifdef INTEL_CLN_TEST
++#ifdef INTEL_QUARK_TEST
+
+/*
+ Failure in fetching an asset results in function returning 0 and errnum
+ being set.
+ */
-+#define INTEL_CLN_ERR_NO_ASSET \
++#define INTEL_QUARK_ERR_NO_ASSET \
+ (! (errnum = ERR_FILE_NOT_FOUND))
+
-+#define __cln_test_asset(x) \
-+ if (GRUB_CLN_ASSET_KERNEL == x && __cln_err.no_kernel) \
-+ return INTEL_CLN_ERR_NO_ASSET; \
-+ if (GRUB_CLN_ASSET_INITRD == x && __cln_err.no_ramdisk) \
-+ return INTEL_CLN_ERR_NO_ASSET; \
-+ if (GRUB_CLN_ASSET_KERNEL_CSBH == x && __cln_err.no_kernel_sig) \
-+ return INTEL_CLN_ERR_NO_ASSET; \
-+ if (GRUB_CLN_ASSET_INITRD_CSBH == x && __cln_err.no_ramdisk_sig) \
-+ return INTEL_CLN_ERR_NO_ASSET;
++#define __quark_test_asset(x) \
++ if (GRUB_QUARK_ASSET_KERNEL == x && __quark_err.no_kernel) \
++ return INTEL_QUARK_ERR_NO_ASSET; \
++ if (GRUB_QUARK_ASSET_INITRD == x && __quark_err.no_ramdisk) \
++ return INTEL_QUARK_ERR_NO_ASSET; \
++ if (GRUB_QUARK_ASSET_KERNEL_CSBH == x && __quark_err.no_kernel_sig) \
++ return INTEL_QUARK_ERR_NO_ASSET; \
++ if (GRUB_QUARK_ASSET_INITRD_CSBH == x && __quark_err.no_ramdisk_sig) \
++ return INTEL_QUARK_ERR_NO_ASSET;
+
+/*
+ Upon failure in verifying signature, IAROM callback only returns 0.
-+ Possible values for __cln_err.state_sign_verify:
++ Possible values for __quark_err.state_sign_verify:
+ - 0: we are currently verifying grub.conf
+ - 1: we are currently verifying kernel
+ - 2: we are currently verifying ramdisk
+ */
-+#define __cln_test_signature(x) \
-+ switch (__cln_err.state_sign_verify ++) { \
++#define __quark_test_signature(x) \
++ switch (__quark_err.state_sign_verify ++) { \
+ case 0: /* grub.conf - this is out of scope */ \
+ break; \
+ case 1: /* Kernel */ \
-+ if (__cln_err.kernel_sig_fail) \
++ if (__quark_err.kernel_sig_fail) \
+ return 0; \
+ break; \
+ case 2: /* Ramdisk */ \
-+ if (__cln_err.ramdisk_sig_fail) \
++ if (__quark_err.ramdisk_sig_fail) \
+ return 0; \
+ break; \
+ default: \
+ break; \
+ }
+
-+#else /* !INTEL_CLN_TEST */
++#else /* !INTEL_QUARK_TEST */
+
-+#define __cln_test_asset(x) \
++#define __quark_test_asset(x) \
+ do {} while(0);
-+#define __cln_test_signature(x) \
++#define __quark_test_signature(x) \
+ do {} while(0);
+
-+#endif /* INTEL_CLN_TEST */
++#endif /* INTEL_QUARK_TEST */
+
-diff --git a/efi/efidisk.c b/efi/efidisk.c
-index 2192021..015c57a 100644
---- a/efi/efidisk.c
-+++ b/efi/efidisk.c
-@@ -192,6 +192,10 @@ name_devices (struct grub_efidisk_data *devices)
- continue;
-
- m = d->block_io->media;
-+ if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE)
-+ {
-+ add_device (&hd_devices, d);
-+ }
- if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE)
- {
- /* XXX FIXME this won't work if we see write-protected disks with
-diff --git a/efi/efidp.c b/efi/efidp.c
-index d8ca03d..f4ca452 100644
---- a/efi/efidp.c
-+++ b/efi/efidp.c
-@@ -578,7 +578,10 @@ dpname_matches(char *str, char *candidate)
- return rc;
- }
-
--static void
-+extern void
-+finish_param_parse(char *pos, char **end, char *tmp);
-+
-+void
- finish_param_parse(char *pos, char **end, char *tmp)
- {
- if (!pos || !end || !tmp)
-diff --git a/efi/efimain.c b/efi/efimain.c
-index e1a1e66..ace710c 100644
---- a/efi/efimain.c
-+++ b/efi/efimain.c
-@@ -26,6 +26,8 @@
- #include <shared.h>
- #include <efistubs.h>
-
-+#include <clanton/perf_metrics.h>
-+
- #include "pxe.h"
-
- #define GRUB_SCRATCH_MEM_PAGES (GRUB_SCRATCH_MEM_SIZE >> 12)
-@@ -77,8 +79,15 @@ real_main (void)
- grub_efi_status_t
- efi_main (grub_efi_handle_t image_handle, grub_efi_system_table_t *sys_tab)
- {
-+ grub_efi_boot_services_t *b;
-+ grub_efi_status_t status;
-+
- grub_efi_image_handle = image_handle;
- grub_efi_system_table = sys_tab;
-+
-+ /* Timestamp entry point. */
-+ grub_cln_event_append (__func__);
-+
- grub_efi_init ();
-
- grub_scratch_mem = grub_efi_allocate_pages (0, GRUB_SCRATCH_MEM_PAGES);
-@@ -108,6 +117,13 @@ efi_main (grub_efi_handle_t image_handle, grub_efi_system_table_t *sys_tab)
- #endif
- }
-
-+ /* Disable watchdog before prompting for any user input. */
-+ b = grub_efi_system_table->boot_services;
-+ status = Call_Service_4 (b->set_watchdog_timer,
-+ 0, 0xFFFF + 1, 0, NULL);
-+ if (GRUB_EFI_SUCCESS != status)
-+ grub_printf ("%s: set_watchdog_timer() returned 0x%08x\n", __func__, status);
-+
- real_main ();
-
- if (real_stack) {
-diff --git a/efi/ia32/loader/linux.c b/efi/ia32/loader/linux.c
-index d795d28..52ce6cb 100644
---- a/efi/ia32/loader/linux.c
-+++ b/efi/ia32/loader/linux.c
-@@ -23,15 +23,22 @@
- #include <grub/efi/api.h>
- #include <grub/efi/efi.h>
- #include <grub/efi/misc.h>
-+#include <clanton/asset.h>
-+#include <clanton/clanton.h>
-+#include <clanton/early_uart.h>
-+#include <clanton/flash.h>
-+#include <clanton/iarom.h>
-+#include <clanton/imr.h>
-+#include <clanton/mfh.h>
-+#include <clanton/perf_metrics.h>
-+#include <clanton/sbh.h>
-+#include <clanton/test_module.h>
-
- #include "switch.h"
--
- #include <shared.h>
-
- #include "graphics.h"
-
--#define grub_file_size() filemax
--
- #define NEXT_MEMORY_DESCRIPTOR(desc, size) \
- ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
-
-@@ -44,6 +51,8 @@
- #define SECTOR_BITS 9
- #endif /* defined(SECTOR_BITS) */
-
-+#define PAGE_SIZE 0x1000
-+
- static unsigned long linux_mem_size;
- static int loaded;
- static void *real_mode_mem;
-@@ -54,6 +63,15 @@ static grub_efi_uintn_t prot_mode_pages;
- static grub_efi_uintn_t initrd_pages;
- static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GRAPHICS_OUTPUT_GUID;
-
-+/* If modules are in SPI/Flash, follow MFH path.
-+ Else follow file system path. */
-+unsigned short int grub_cln_linux_spi = 0;
-+unsigned short int grub_cln_initrd_spi = 0;
-+
-+/* The Clanton Secure Boot Header. */
-+static struct grub_cln_sbh cln_sbh;
-+static grub_uint32_t sbh_len = 0;
-+
- static inline grub_size_t
- page_align (grub_size_t size)
- {
-@@ -114,9 +132,14 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
- /* Initialize the memory pointers with NULL for convenience. */
- real_mode_mem = 0;
- prot_mode_mem = 0;
-+ initrd_mem = 0;
-
- if (grub_efi_get_memory_map (0, &desc_size, 0) <= 0)
-- grub_fatal ("cannot get memory map");
-+ {
-+ grub_printf ("cannot get memory map");
-+ errnum = ERR_BOOT_FAILURE;
-+ return 0;
-+ }
-
- addr = 0;
- mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap_buf, mmap_size);
-@@ -144,7 +167,11 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
- (unsigned) real_mode_pages, (unsigned) addr);
- real_mode_mem = grub_efi_allocate_pages (addr, real_mode_pages);
- if (! real_mode_mem)
-- grub_fatal ("cannot allocate pages");
-+ {
-+ grub_printf ("cannot allocate pages");
-+ errnum = ERR_WONT_FIT;
-+ goto fail;
-+ }
-
- desc->num_pages -= real_mode_pages;
- break;
-@@ -160,9 +187,14 @@ allocate_pages (grub_size_t real_size, grub_size_t prot_size)
-
- /* Next, find free pages for the protected mode code. */
- /* XXX what happens if anything is using this address? */
-- prot_mode_mem = grub_efi_allocate_pages (0x100000, prot_mode_pages);
-+ prot_mode_mem = grub_efi_allocate_pages
-+ (GRUB_LINUX_BZIMAGE_ADDR, prot_mode_pages);
- if (! prot_mode_mem)
-- grub_fatal("Cannot allocate pages for VMLINUZ");
-+ {
-+ grub_printf ("Cannot allocate pages for VMLINUZ");
-+ errnum = ERR_WONT_FIT;
-+ goto fail;
-+ }
-
- return 1;
-
-@@ -224,7 +256,11 @@ big_linux_boot (void)
- graphics_set_kernel_params (params);
-
- if (grub_efi_get_memory_map (&map_key, &desc_size, &desc_version) <= 0)
-- grub_fatal ("cannot get memory map");
-+ {
-+ grub_printf ("cannot get memory map");
-+ errnum = ERR_BOOT_FAILURE;
-+ return;
-+ }
-
- /* Pass e820 memmap. */
- e820_map_from_efi_map ((struct e820_entry *) params->e820_map, &e820_nr_map,
-@@ -232,8 +268,14 @@ big_linux_boot (void)
- params->e820_nr_map = e820_nr_map;
-
- grub_dprintf(__func__,"got to ExitBootServices...\n");
-+
- if (! grub_efi_exit_boot_services (map_key))
-- grub_fatal ("cannot exit boot services");
-+ {
-+ grub_printf ("cannot exit boot services");
-+ errnum = ERR_BOOT_FAILURE;
-+ return;
-+ }
-+
- /* Note that no boot services are available from here. */
-
- lh = &params->hdr;
-@@ -278,6 +320,13 @@ big_linux_boot (void)
- grub_memset((void *)gdt_addr.base, gdt_addr.limit, 0);
- grub_memcpy((void *)gdt_addr.base, init_gdt, sizeof (init_gdt));
-
-+ /* This is the very last stage we can timestamp.
-+ Do it and append performance metrics to the linux command line. */
-+ grub_cln_event_append ("jmp_code32");
-+ grub_strncat ((char *) real_mode_mem + 0x1000,
-+ grub_cln_event_get_metrics (),
-+ GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET + 1);
-+
- if (0) {
- /* copy our real mode transition code to 0x7C00 */
- memcpy ((void *) 0x7C00, switch_image, switch_size);
-@@ -311,28 +360,80 @@ big_linux_boot (void)
- for (;;);
- }
-
-+/*
-+ Lexer to detect early Quark's UART MMIO token.
-+ If token is found, expand it with the actual MMIO address.
-+ */
-+static void
-+cln_detect_early_uart (char **cmdline)
-+{
-+ char *p = NULL;
-+ char *start = *cmdline;
-+ grub_uint32_t mmio;
-+ grub_uint32_t offs = 0;
-+
-+ p = strstr(*cmdline, QUARK_UART_MMIO_TOKEN);
-+ *cmdline = start;
-+
-+ if (NULL == p)
-+ {
-+ /* Nothing to do. */
-+ return;
-+ }
-+
-+ mmio = (grub_uint32_t)cln_early_uart_init();
-+ if (!mmio)
-+ {
-+ grub_printf("%s: couldn't find device. Skipping..\n", __func__);
-+ return;
-+ }
-+
-+ if (grub_cln_debug)
-+ grub_printf("%s: MMIO addr @ 0x%x\n", __func__, mmio);
-+
-+ offs = grub_sprintf(p, "0x%x", mmio);
-+ grub_sprintf(p + offs, "%s", p + sizeof(QUARK_UART_MMIO_TOKEN) - 1);
-+}
-+
- int
- grub_load_linux (char *kernel, char *arg)
- {
- struct grub_linux_kernel_header *lh;
- struct linux_kernel_params *params;
- static struct linux_kernel_params params_buf;
-- grub_uint8_t setup_sects;
-- grub_size_t real_size, prot_size;
-- grub_ssize_t len;
-- char *dest;
-+ grub_uint8_t setup_sects = 0;
-+ grub_size_t real_size = 0, prot_size = 0, img_size = 0;
-+ grub_uint32_t code32_start_offs = 0x0, prot_mode_offs = 0x0;;
-+ grub_ssize_t len = 0;
-+
-+ sbh_len = 0;
-
-- if (kernel == NULL)
-+ __cln_test_setup(arg);
-+
-+ /* In SPI/Flash mode, file system path to kernel is not required. */
-+ if (! grub_cln_linux_spi && kernel == NULL)
- {
- errnum = ERR_BAD_FILENAME;
- grub_printf ("no kernel specified");
- goto fail1;
- }
-
-- if (! grub_open (kernel))
-+ if (grub_cln_secure)
-+ {
-+ if (! grub_cln_fetch_sbh (GRUB_CLN_ASSET_KERNEL_CSBH, kernel, &cln_sbh))
-+ {
-+ if(ERR_FILE_NOT_FOUND == errnum
-+ && ! grub_cln_linux_spi)
-+ errnum = ERR_SGN_FILE_NOT_FOUND;
-+ goto fail1;
-+ }
-+ sbh_len = cln_sbh.security_header.header_len;
-+ }
-+
-+ if (! grub_cln_asset_open (GRUB_CLN_ASSET_KERNEL, kernel))
- goto fail1;
-
-- if (grub_read ((char *) &params_buf, sizeof (params_buf))
-+ if (grub_cln_asset_read (GRUB_CLN_ASSET_KERNEL, (grub_uint8_t *) &params_buf, sizeof (params_buf))
- != sizeof (params_buf))
- {
- errnum = ERR_EXEC_FORMAT;
-@@ -371,13 +472,48 @@ grub_load_linux (char *kernel, char *arg)
-
- setup_sects = lh->setup_sects;
-
-+ img_size = grub_cln_asset_size (GRUB_CLN_ASSET_KERNEL);
- real_size = 0x1000 + grub_strlen(arg);
-- prot_size = grub_file_size () - (setup_sects << SECTOR_BITS) - SECTOR_SIZE;
-+
-+ /* Grub allocates distinct memory regions for the so-called "real mode" and
-+ "protected mode" portions of bzImage. The linux entry point is located
-+ at the base address of the protected mode section
-+ (GRUB_LINUX_BZIMAGE_ADDR).
-+ In order to perform signature verification, Clanton secure boot requires
-+ the whole bzImage to be allocated contiguously, with its CSBH prepended.
-+ Consequently, the signed image is placed in a contiguous region starting
-+ from GRUB_LINUX_BZIMAGE_ADDR, and the entry point offset is updated
-+ accordingly. */
-+ if (grub_cln_secure)
-+ {
-+ prot_size = img_size + sbh_len;
-+ code32_start_offs += (setup_sects << SECTOR_BITS) + SECTOR_SIZE
-+ + sbh_len;
-+ }
-+
-+ else
-+ prot_size = img_size - (setup_sects << SECTOR_BITS) - SECTOR_SIZE;
-
- if (! allocate_pages (real_size, prot_size))
- goto fail;
-
-- /* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
-+ errnum = intel_cln_imr_setup(IMR_RANGE_BOOT, (grub_addr_t)real_mode_mem, real_size);
-+ if(errnum != ERR_NONE)
-+ {
-+ grub_printf("IMR boot params setup failed !\n");
-+ goto fail;
-+ }
-+
-+ errnum = intel_cln_imr_setup(IMR_RANGE_BZIMAGE, GRUB_LINUX_BZIMAGE_ADDR, prot_size);
-+ if(errnum != ERR_NONE)
-+ {
-+ grub_printf("IMR bzimage setup failed !\n");
-+ goto fail;
-+ }
-+
-+ __cln_test_imr();
-+
-+ /* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
- lh->type_of_loader = 0x50;
-
- lh->cmd_line_ptr = (grub_uint32_t) (unsigned long) real_mode_mem + 0x1000;
-@@ -394,6 +530,11 @@ grub_load_linux (char *kernel, char *arg)
-
- grub_memmove(&params->hdr, lh, 0x202 + lh->jump_off - 0x1f1);
-
-+ /* Update offset for protected mode code entry point. Clanton secure boot
-+ requires real mode code to be allocated contiguously to protected mode
-+ section. Hence the kernel entry point must be shifted accordingly. */
-+ params->hdr.code32_start += code32_start_offs;
-+
- params->cl_magic = GRUB_LINUX_CL_MAGIC;
- params->cl_offset = 0x1000;
-
-@@ -446,9 +587,13 @@ grub_load_linux (char *kernel, char *arg)
- params->eddbuf_entries = 0;
- params->edd_mbr_sig_buf_entries = 0;
-
-+ /* Dump MFH layout.conf contents */
-+ grub_cln_dump_layout ();
-+
- /* XXX there is no way to know if the kernel really supports EFI. */
-- grub_printf ("[Linux-EFI, setup=0x%x, size=0x%x]\n", (unsigned int)real_size,
-- (unsigned int)prot_size);
-+ grub_printf ("[Linux-EFI%s, setup=0x%x, size=0x%x]\n",
-+ grub_cln_linux_spi ? " SPI" : "",
-+ (unsigned int) real_size, (unsigned int) prot_size);
-
- /* Check the mem= option to limit memory used for initrd. */
- {
-@@ -504,12 +649,41 @@ grub_load_linux (char *kernel, char *arg)
- linux_mem_size = 0;
- }
-
-- dest = grub_stpcpy ((char *) real_mode_mem + 0x1000, skip_to(0, arg));
-+ /* Expand Intel Quark's UART MMIO address if requested */
-+ cln_detect_early_uart(&arg);
-+
-+ /* Skip the path to the kernel only if in file system mode. */
-+ grub_stpcpy ((char *) real_mode_mem + 0x1000,
-+ grub_cln_linux_spi ? arg : skip_to (0, arg));
-+
-+ /* If Clanton secure boot path, copy over CSBH + bzImage into "protected
-+ mode" section. */
-+ if (grub_cln_secure)
-+ {
-+ grub_cln_asset_seek (0);
-+ prot_size -= sbh_len;
-+ grub_memcpy (prot_mode_mem, &cln_sbh, sizeof (cln_sbh));
-+ prot_mode_offs += sbh_len;
-+ }
-+ else
-+ grub_cln_asset_seek ((setup_sects << SECTOR_BITS) + SECTOR_SIZE);
-
-- grub_seek ((setup_sects << SECTOR_BITS) + SECTOR_SIZE);
- len = prot_size;
-- if (grub_read ((char *) GRUB_LINUX_BZIMAGE_ADDR, len) != len)
-- grub_printf ("Couldn't read file");
-+ if (grub_cln_asset_read (GRUB_CLN_ASSET_KERNEL,
-+ (grub_uint8_t *) prot_mode_mem + prot_mode_offs,
-+ len) != len)
-+ {
-+ errnum = ERR_EXEC_FORMAT;
-+ grub_printf ("Couldn't read file");
-+ goto fail;
-+ }
-+
-+ /* Verify the kernel signature. */
-+ if (grub_cln_secure &&
-+ ! grub_cln_verify_asset_signature ((grub_uint8_t *) prot_mode_mem))
-+ {
-+ errnum = ERR_CLN_VERIFICATION;
-+ }
-
- if (errnum == ERR_NONE)
- {
-@@ -543,7 +717,10 @@ grub_load_initrd (char *initrd)
- grub_efi_uint32_t desc_version;
- struct linux_kernel_params *params;
-
-- if (initrd == NULL)
-+ sbh_len = 0;
-+
-+ /* In SPI/Flash mode, file system path to initrd is not required. */
-+ if (! grub_cln_initrd_spi && initrd == NULL)
- {
- errnum = ERR_BAD_FILENAME;
- grub_printf ("No module specified");
-@@ -557,10 +734,28 @@ grub_load_initrd (char *initrd)
- goto fail1;
- }
-
-- if (! grub_open (initrd))
-+
-+ if (grub_cln_secure)
-+ {
-+ if (! grub_cln_fetch_sbh (GRUB_CLN_ASSET_INITRD_CSBH, initrd, &cln_sbh))
-+ {
-+ if (ERR_FILE_NOT_FOUND == errnum
-+ && ! grub_cln_initrd_spi)
-+ errnum = ERR_SGN_FILE_NOT_FOUND;
-+ goto fail1;
-+ }
-+ sbh_len = cln_sbh.security_header.header_len;
-+ }
-+
-+ if (! grub_cln_asset_open (GRUB_CLN_ASSET_INITRD, initrd))
- goto fail1;
-
-- size = grub_file_size ();
-+ size = grub_cln_asset_size (GRUB_CLN_ASSET_INITRD);
-+
-+ /* If Clanton secure boot, make room for CSBH (dedicated page). */
-+ if (grub_cln_secure)
-+ size += PAGE_SIZE;
-+
- initrd_pages = (page_align (size) >> 12);
-
- params = (struct linux_kernel_params *) real_mode_mem;
-@@ -583,7 +778,11 @@ grub_load_initrd (char *initrd)
-
- /* Find the highest address to put the initrd. */
- if (grub_efi_get_memory_map (&map_key, &desc_size, &desc_version) <= 0)
-- grub_fatal ("cannot get memory map");
-+ {
-+ grub_printf ("cannot get memory map");
-+ errnum = ERR_BOOT_FAILURE;
-+ goto fail;
-+ }
-
- mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap_buf, mmap_size);
- addr = 0;
-@@ -626,17 +825,54 @@ grub_load_initrd (char *initrd)
-
- initrd_mem = grub_efi_allocate_pages (addr, initrd_pages);
- if (! initrd_mem)
-- grub_fatal ("cannot allocate pages: %x@%x", (unsigned)initrd_pages,
-- (unsigned)addr);
-+ {
-+ grub_printf ("cannot allocate pages: %x@%x", (unsigned) initrd_pages,
-+ (unsigned) addr);
-+ errnum = ERR_WONT_FIT;
-+ goto fail;
-+ }
-
-- if (grub_read (initrd_mem, size) != size)
-+ /*
-+ Clanton secure boot requires the CSBH to be prepended to the Initrd.
-+ Since Linux requires the Initrd to be page-aligned, do the following:
-+ 1. copy Initrd to the 2nd allocated page
-+ 2. copy the CSBH to the 1st allocated page at an offset such that
-+ CSBH and Initrd are adjacent
-+ */
-+ if (grub_cln_secure)
-+ {
-+ size -= PAGE_SIZE;
-+ grub_memcpy ((grub_uint8_t *) initrd_mem + PAGE_SIZE - sbh_len,
-+ &cln_sbh, sizeof (cln_sbh));
-+ initrd_mem = (grub_uint8_t *) initrd_mem + PAGE_SIZE;
-+ addr += PAGE_SIZE;
-+ }
-+
-+ if (grub_cln_asset_read (GRUB_CLN_ASSET_INITRD, initrd_mem, size) != size)
- {
-+ errnum = ERR_EXEC_FORMAT;
- grub_printf ("Couldn't read file");
- goto fail;
- }
-
-- grub_printf (" [Initrd, addr=0x%x, size=0x%x]\n", (unsigned int) addr,
-- (unsigned int) size);
-+ grub_printf ("[Initrd%s, addr=0x%x, size=0x%x]\n",
-+ grub_cln_initrd_spi ? " SPI" : "",
-+ (unsigned int) addr, (unsigned int) size);
-+
-+ if (grub_cln_secure)
-+ {
-+ /* Verify the initrd signature. */
-+ if (! grub_cln_verify_asset_signature ((grub_uint8_t *)
-+ initrd_mem - sbh_len))
-+ {
-+ errnum = ERR_CLN_VERIFICATION;
-+ goto fail;
-+ }
-+
-+ /* Free up page allocated to CSBH. */
-+ grub_efi_free_pages ((grub_addr_t)
-+ ((grub_uint8_t *) initrd_mem - PAGE_SIZE), 1);
-+ }
-
- params->hdr.ramdisk_image = addr;
- params->hdr.ramdisk_size = size;
diff --git a/grub/Makefile.in b/grub/Makefile.in
deleted file mode 100644
index 0e40e1b..0000000
@@ -15513,17 +15545,17 @@ index 0e40e1b..0000000
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/grub/asmstub.c b/grub/asmstub.c
-index 818be75..e797bbc 100644
+index 818be75..71251b5 100644
--- a/grub/asmstub.c
+++ b/grub/asmstub.c
@@ -82,6 +82,11 @@ char *linux_data_real_addr = 0;
unsigned short io_map[IO_MAP_SIZE];
struct apm_info apm_bios_info;
-+/* Clanton-specific. */
-+unsigned short int grub_cln_loaded_from_spi = 0;
-+unsigned short int grub_cln_linux_spi = 0;
-+unsigned short int grub_cln_initrd_spi = 0;
++/* Quark-specific. */
++unsigned short int grub_quark_loaded_from_spi = 0;
++unsigned short int grub_quark_linux_spi = 0;
++unsigned short int grub_quark_initrd_spi = 0;
+
/* Emulation requirements. */
void *grub_scratch_mem = 0;
@@ -15534,26 +15566,26 @@ index 818be75..e797bbc 100644
}
+
+void
-+grub_cln_recovery_shell (unsigned short int asset_in_spi)
++grub_quark_recovery_shell (unsigned short int asset_in_spi)
+{
+ grub_printf ("%s ()\n", __func__);
+ while (1);
+}
+
+void
-+grub_cln_event_append (const char *tag)
++grub_quark_event_append (const char *tag)
+{
+ /* Nothing to do in the simulator. */
+}
+
+void
-+grub_cln_load_config_file (char **buf, int *size)
++grub_quark_load_config_file (char **buf, int *size)
+{
+ /* Nothing to do in the simulator. */
+}
+
+void
-+grub_cln_detect_secure_sku (void)
++grub_quark_detect_secure_sku (void)
+{
+ /* Nothing to do in the simulator. */
+}
@@ -21151,14 +21183,14 @@ index 66e7465..0000000
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/stage2/boot.c b/stage2/boot.c
-index e30daf8..6a8648f 100644
+index e30daf8..ce0e5f3 100644
--- a/stage2/boot.c
+++ b/stage2/boot.c
@@ -25,6 +25,8 @@
#include "imgact_aout.h"
#include "i386-elf.h"
-+#include <../efi/clanton/clanton.h>
++#include <../efi/quark/quark.h>
+
#ifndef PLATFORM_EFI
static int cur_addr;
@@ -21170,14 +21202,14 @@ index e30daf8..6a8648f 100644
- return grub_load_linux (kernel, arg);
+ int ret = KERNEL_TYPE_NONE;
+ /* If SPI/Flash option is passed, update the global variable. */
-+ grub_cln_linux_spi = 0;
++ grub_quark_linux_spi = 0;
+ if (load_flags & KERNEL_SPI)
-+ grub_cln_linux_spi = 1;
++ grub_quark_linux_spi = 1;
+
+ ret = grub_load_linux (kernel, arg);
+
+ if (ERR_NONE != errnum)
-+ grub_cln_recovery_shell (grub_cln_linux_spi);
++ grub_quark_recovery_shell (grub_quark_linux_spi);
+
+ return ret;
#else
@@ -21197,28 +21229,28 @@ index e30daf8..6a8648f 100644
- return grub_load_initrd (initrd);
+ int ret = 0;
+ /* If SPI/Flash option is passed, update the global variable. */
-+ grub_cln_initrd_spi = 0;
++ grub_quark_initrd_spi = 0;
+ if (load_flags & INITRD_SPI)
-+ grub_cln_initrd_spi = 1;
++ grub_quark_initrd_spi = 1;
+
+ ret = grub_load_initrd (initrd);
+
+ if (ERR_NONE != errnum)
-+ grub_cln_recovery_shell (grub_cln_initrd_spi);
++ grub_quark_recovery_shell (grub_quark_initrd_spi);
+
+ return ret;
#else
int len, next_addr;
char *singleimage, *pos;
diff --git a/stage2/builtins.c b/stage2/builtins.c
-index fe6a622..074bb18 100644
+index fe6a622..c2ebfe5 100644
--- a/stage2/builtins.c
+++ b/stage2/builtins.c
@@ -24,6 +24,7 @@
# include <stdio.h>
#endif
-+#include <../efi/clanton/clanton.h>
++#include <../efi/quark/quark.h>
#include <shared.h>
#include <filesys.h>
#include <term.h>
@@ -21226,9 +21258,9 @@ index fe6a622..074bb18 100644
case KERNEL_TYPE_BIG_LINUX:
/* Big Linux */
big_linux_boot ();
-+ /* Clanton: drop to recovery shell if any error. */
++ /* Quark: drop to recovery shell if any error. */
+ /* Errors here are all Firmware-related. */
-+ grub_cln_recovery_shell (1);
++ grub_quark_recovery_shell (1);
break;
case KERNEL_TYPE_CHAINLOADER:
@@ -21312,8 +21344,8 @@ index fe6a622..074bb18 100644
"Display grub version."
};
-+/* Placeholder for Clanton Recovery command. */
-+static struct builtin builtin_cln_recovery_placeholder =
++/* Placeholder for Quark Recovery command. */
++static struct builtin builtin_quark_recovery_placeholder =
+{
+ "",
+ NULL,
@@ -21329,18 +21361,18 @@ index fe6a622..074bb18 100644
#endif
&builtin_verbose,
&builtin_version,
-+ &builtin_cln_recovery_placeholder,
++ &builtin_quark_recovery_placeholder,
0
};
diff --git a/stage2/char_io.c b/stage2/char_io.c
-index 073201a..92804b4 100644
+index 073201a..117083a 100644
--- a/stage2/char_io.c
+++ b/stage2/char_io.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-+#include <../efi/clanton/clanton.h>
++#include <../efi/quark/quark.h>
#include <shared.h>
#include <term.h>
@@ -21476,18 +21508,18 @@ index 073201a..92804b4 100644
void
-init_page (void)
-+init_page (int cln_recovery)
++init_page (int quark_recovery)
{
cls ();
- grub_printf ("\n GNU GRUB version %s (%dK lower / %dK upper memory)\n\n",
- version_string, mbi.mem_lower, mbi.mem_upper);
-+ if (cln_recovery)
++ if (quark_recovery)
+ {
+ /* Different banner for Recovery shell. */
+ print_error ();
+ errnum = 0;
-+ grub_printf ("\n\n Clanton GRUB Recovery shell\n\n");
++ grub_printf ("\n\n Quark GRUB Recovery shell\n\n");
+ }
+ else
+ grub_printf ("\n GNU GRUB version %s (%dK lower / %dK upper memory)\n\n",
@@ -21500,9 +21532,9 @@ index 073201a..92804b4 100644
{
case 27: /* ESC immediately return 1 */
- return 1;
-+ /* Recovery shell under Clanton Secure mode
++ /* Recovery shell under Quark Secure mode
+ does not allow returning. */
-+ if (! grub_cln_secure)
++ if (! grub_quark_secure)
+ return 1;
case 4: /* C-d delete character under cursor */
if (lpos == llen)
@@ -21512,20 +21544,20 @@ index 073201a..92804b4 100644
{
/* Return immediately if ESC is pressed. */
- if (c == 27)
-+ /* Unless we're in Clanton Secure mode of course... */
-+ if (! grub_cln_secure && c == 27)
++ /* Unless we're in Quark Secure mode of course... */
++ if (! grub_quark_secure && c == 27)
{
setcursor (old_cursor);
return 1;
diff --git a/stage2/cmdline.c b/stage2/cmdline.c
-index cb41eda..714f2b6 100644
+index cb41eda..22238d8 100644
--- a/stage2/cmdline.c
+++ b/stage2/cmdline.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-+#include <../efi/clanton/clanton.h>
++#include <../efi/quark/quark.h>
#include <shared.h>
#ifdef SUPPORT_DISKLESS
@@ -21533,7 +21565,7 @@ index cb41eda..714f2b6 100644
*ptr = c;
return *builtin;
}
-+ /* Clanton recovery commands violate the alphabetical order. */
++ /* Quark recovery commands violate the alphabetical order. */
+ /*
else if (ret < 0)
break;
@@ -21546,7 +21578,7 @@ index cb41eda..714f2b6 100644
/* Initialize the data for the command-line. */
static void
-init_cmdline (void)
-+init_cmdline (int cln_recovery)
++init_cmdline (int quark_recovery)
{
/* Initialization. */
saved_drive = boot_drive;
@@ -21554,7 +21586,7 @@ index cb41eda..714f2b6 100644
current_drive = GRUB_INVALID_DRIVE;
- errnum = 0;
+ /* If in recovery mode, you want to print out the error code. */
-+ if (! cln_recovery)
++ if (! quark_recovery)
+ errnum = 0;
count_lines = -1;
@@ -21564,14 +21596,14 @@ index cb41eda..714f2b6 100644
nonzero (ESC is pushed). */
void
-enter_cmdline (char *heap, int forever)
-+enter_cmdline (char *heap, int forever, int cln_recovery)
++enter_cmdline (char *heap, int forever, int quark_recovery)
{
/* Initialize the data and print a message. */
- init_cmdline ();
-+ init_cmdline (cln_recovery);
++ init_cmdline (quark_recovery);
grub_setjmp (restart_cmdline_env);
- init_page ();
-+ init_page (cln_recovery);
++ init_page (quark_recovery);
#ifdef SUPPORT_DISKLESS
print_network_configuration ();
grub_putchar ('\n');
@@ -21599,25 +21631,25 @@ index cb41eda..714f2b6 100644
- }
-
- return 1;
-+ grub_cln_recovery_shell (grub_cln_loaded_from_spi);
++ grub_quark_recovery_shell (grub_quark_loaded_from_spi);
}
/* Copy the first string in CUR_ENTRY to HEAP. */
diff --git a/stage2/common.c b/stage2/common.c
-index e96bec2..c208f68 100644
+index e96bec2..e122745 100644
--- a/stage2/common.c
+++ b/stage2/common.c
@@ -88,6 +88,8 @@ char *err_list[] =
[ERR_UNRECOGNIZED] = "Unrecognized command",
[ERR_WONT_FIT] = "Selected item cannot fit into memory",
[ERR_WRITE] = "Disk write error",
-+ [ERR_CLN_VERIFICATION] = "Clanton signature verification failed",
-+ [ERR_SGN_FILE_NOT_FOUND] = "Clanton signature file not found",
++ [ERR_QUARK_VERIFICATION] = "Quark signature verification failed",
++ [ERR_SGN_FILE_NOT_FOUND] = "Quark signature file not found",
};
diff --git a/stage2/shared.h b/stage2/shared.h
-index a82067b..09b0451 100644
+index a82067b..b05caf4 100644
--- a/stage2/shared.h
+++ b/stage2/shared.h
@@ -167,6 +167,8 @@ extern void *grub_scratch_mem;
@@ -21633,7 +21665,7 @@ index a82067b..09b0451 100644
ERR_DEV_NEED_INIT,
ERR_NO_DISK_SPACE,
ERR_NUMBER_OVERFLOW,
-+ ERR_CLN_VERIFICATION,
++ ERR_QUARK_VERIFICATION,
+ ERR_SGN_FILE_NOT_FOUND,
MAX_ERR_NUM
@@ -21643,7 +21675,7 @@ index a82067b..09b0451 100644
/* do some funky stuff, then boot bzImage linux */
-void big_linux_boot (void) __attribute__ ((noreturn));
-+/* Clanton: return if something goes wrong. */
++/* Quark: return if something goes wrong. */
+void big_linux_boot (void);
/* booting a multiboot executable */
@@ -21653,7 +21685,7 @@ index a82067b..09b0451 100644
char *skip_to (int after_equal, char *cmdline);
struct builtin *find_command (char *command);
-void enter_cmdline (char *heap, int forever);
-+void enter_cmdline (char *heap, int forever, int cln_recovery);
++void enter_cmdline (char *heap, int forever, int quark_recovery);
int run_script (char *script, char *heap);
/* the flags for the cmdline message */
@@ -21662,7 +21694,7 @@ index a82067b..09b0451 100644
/* misc */
-void init_page (void);
-+void init_page (int cln_recovery);
++void init_page (int quark_recovery);
void print_error (void);
char *convert_to_ascii (char *buf, int c, unsigned int num);
int get_cmdline (char *prompt, char *cmdline, int maxlen,
@@ -21691,26 +21723,26 @@ index a82067b..09b0451 100644
int grub_load_initrd (char *initrd);
int grub_chainloader (char *filename);
+
-+/* Clanton-specific. */
-+void grub_cln_recovery_shell (unsigned short int);
-+int grub_cln_sdio_program (char *s, int i);
-+int grub_cln_spi_program (char *s, int i);
-+void grub_cln_event_append (const char *tag);
-+void grub_cln_load_config_file (char **buf, int *size);
-+void grub_cln_detect_secure_sku (void);
++/* Quark-specific. */
++void grub_quark_recovery_shell (unsigned short int);
++int grub_quark_sdio_program (char *s, int i);
++int grub_quark_spi_program (char *s, int i);
++void grub_quark_event_append (const char *tag);
++void grub_quark_load_config_file (char **buf, int *size);
++void grub_quark_detect_secure_sku (void);
+
#endif /* ASM_FILE */
#endif /* ! GRUB_SHARED_HEADER */
diff --git a/stage2/stage2.c b/stage2/stage2.c
-index cca4332..289b43f 100644
+index cca4332..b62d434 100644
--- a/stage2/stage2.c
+++ b/stage2/stage2.c
@@ -17,6 +17,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-+#include <../efi/clanton/clanton.h>
++#include <../efi/quark/quark.h>
+#include <../netboot/timer.h>
#include <shared.h>
#include <term.h>
@@ -21719,20 +21751,20 @@ index cca4332..289b43f 100644
int silent_grub = 0;
-+/* Clanton secure/non-secure global variable.
++/* Quark secure/non-secure global variable.
+ Secure Boot is enabled by default. The value is then refreshed at run-time
+ by reading a fuse. */
-+unsigned short int grub_cln_secure = 1;
++unsigned short int grub_quark_secure = 1;
+
-+/* Clanton build-time debug/release switch. */
-+#ifndef GRUB_CLN_DEBUG
-+#define GRUB_CLN_DEBUG 0
++/* Quark build-time debug/release switch. */
++#ifndef GRUB_QUARK_DEBUG
++#define GRUB_QUARK_DEBUG 0
+#endif
-+unsigned short int grub_cln_debug = GRUB_CLN_DEBUG;
++unsigned short int grub_quark_debug = GRUB_QUARK_DEBUG;
+
-+/* Clanton-Secure config file buffer. */
-+static char *cln_cfg_file_buffer = NULL;
-+static int cln_cfg_file_size = 0;
++/* Quark-Secure config file buffer. */
++static char *quark_cfg_file_buffer = NULL;
++static int quark_cfg_file_size = 0;
+
#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
@@ -21832,7 +21864,7 @@ index cca4332..289b43f 100644
DISP_UP, DISP_DOWN);
- if (! auth && password)
-+ if (grub_cln_secure && ! grub_cln_debug)
++ if (grub_quark_secure && ! grub_quark_debug)
+ {
+ /* Don't show menu choices that are unavailable in secure mode. */
+ grub_printf ("\
@@ -21883,7 +21915,7 @@ index cca4332..289b43f 100644
}
- if (! auth && password)
-+ if (grub_cln_secure && ! grub_cln_debug)
++ if (grub_quark_secure && ! grub_quark_debug)
+ {
+ /* Prevent the user from interacting with boot settings. */
+ }
@@ -21905,7 +21937,7 @@ index cca4332..289b43f 100644
{
int pos = 0, literal = 0, comment = 0;
- char c; /* since we're loading it a byte at a time! */
-+ static int cln_index;
++ static int quark_index;
+ char c = 0; /* since we're loading it a byte at a time! */
while (1)
@@ -21915,12 +21947,12 @@ index cca4332..289b43f 100644
- if (! grub_read (&c, 1))
- break;
+ /* Config file is already buffered. */
-+ if (cln_index == cln_cfg_file_size)
++ if (quark_index == quark_cfg_file_size)
+ {
-+ cln_index = 0;
++ quark_index = 0;
+ break;
+ }
-+ c = cln_cfg_file_buffer[cln_index ++];
++ c = quark_cfg_file_buffer[quark_index ++];
}
else
{
@@ -21937,11 +21969,11 @@ index cca4332..289b43f 100644
*kill_buf = 0;
+ /* Initialise the configuration file buffer. */
-+ cln_cfg_file_buffer = NULL;
-+ cln_cfg_file_size = 0;
++ quark_cfg_file_buffer = NULL;
++ quark_cfg_file_size = 0;
+
-+ /* Check if Clanton Secure Boot is enabled on this SKU. */
-+ grub_cln_detect_secure_sku ();
++ /* Check if Quark Secure Boot is enabled on this SKU. */
++ grub_quark_detect_secure_sku ();
+
/* Never return. */
for (;;)
@@ -21954,12 +21986,12 @@ index cca4332..289b43f 100644
- errnum = ERR_NONE;
+ /* Buffer configuration file and validate it if in Secure
+ mode. */
-+ grub_cln_load_config_file (&cln_cfg_file_buffer,
-+ &cln_cfg_file_size);
++ grub_quark_load_config_file (&quark_cfg_file_buffer,
++ &quark_cfg_file_size);
+ if (ERR_NONE == errnum)
+ is_opened = 1;
+ else
-+ grub_cln_recovery_shell (grub_cln_loaded_from_spi);
++ grub_quark_recovery_shell (grub_quark_loaded_from_spi);
}
if (! is_opened)
diff --git a/recipes-bsp/grub/grub_0.97.bb b/recipes-bsp/grub/grub_0.97.bb
index 9dab31b..d76d66a 100644
--- a/recipes-bsp/grub/grub_0.97.bb
+++ b/recipes-bsp/grub/grub_0.97.bb
@@ -21,7 +21,7 @@ SRC_URI = "git://github.com/vathpela/grub-fedora.git"
SRC_URI += "file://clanton.patch"
CFLAGS_append = " -Os -fno-strict-aliasing -Wall -Werror -Wno-shadow -Wno-unused -Wno-pointer-sign \
- -DINTEL_CLN_TEST=1"
+ -DINTEL_QUARK_TEST=1"
S = "${WORKDIR}/git"
SEPB = "${S}"