the following patch was just integrated into master:
commit c800199007757656aa3a3c6e712117ecc96ff25e
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Mon Jan 5 00:29:36 2015 +1100
northbridge/via/vx800/examples: Remove rotting source
This is just bit-rotting and its likely this will continue to rot
by the time someone notices it exits it will be too late (i.e., today).
Change-Id: I40ef2cd8e3d563079b086f51dabab0960a0a13b3
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Reviewed-on: http://review.coreboot.org/8087
Tested-by: build bot (Jenkins)
Reviewed-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
See http://review.coreboot.org/8087 for details.
-gerrit
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8084
-gerrit
commit 252d815a2415b7566e1fd555f61a8d6af6e66649
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Sun Jan 4 17:21:52 2015 +1100
superio/smsc/lpc47n207: Hook into build system
Provide proper Makefile and Kconfig components so
that this superio is built as object code. Select
superio component in mainboard Kconfig's to bring
in the link-time symbols and thereby removing the
need for .c inclusion.
N.B. The LPC47N207 Super I/O does not physically exist
on these boards. The Super I/O is found on external LPC
debug card hardware and so should really be made selectable.
However, this is beyond the scope of this specific fix, that
rids us of .c inclusions in romstage.c
Change-Id: I451c3a81c4b5beca1ed65e27467a7393d2521dae
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/mainboard/samsung/lumpy/Kconfig | 3 +++
src/mainboard/samsung/lumpy/romstage.c | 1 -
src/mainboard/samsung/stumpy/Kconfig | 3 +++
src/mainboard/samsung/stumpy/romstage.c | 1 -
src/superio/smsc/Kconfig | 2 ++
src/superio/smsc/Makefile.inc | 1 +
src/superio/smsc/lpc47n207/Makefile.inc | 21 +++++++++++++++++++++
src/superio/smsc/lpc47n207/early_serial.c | 6 ++++++
src/superio/smsc/lpc47n207/lpc47n207.h | 11 +++++++----
9 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/src/mainboard/samsung/lumpy/Kconfig b/src/mainboard/samsung/lumpy/Kconfig
index baf0eee..1b20452 100644
--- a/src/mainboard/samsung/lumpy/Kconfig
+++ b/src/mainboard/samsung/lumpy/Kconfig
@@ -13,6 +13,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select NORTHBRIDGE_INTEL_SANDYBRIDGE
select SOUTHBRIDGE_INTEL_BD82X6X
select SUPERIO_SMSC_MEC1308
+# LPC47N207 selected for external LPC card
+# not on board, should be made selectable.
+ select SUPERIO_SMSC_LPC47N207
select DRIVERS_GENERIC_IOAPIC
select INTEL_INT15
select HAVE_MRC
diff --git a/src/mainboard/samsung/lumpy/romstage.c b/src/mainboard/samsung/lumpy/romstage.c
index b356fa8..8568f84 100644
--- a/src/mainboard/samsung/lumpy/romstage.c
+++ b/src/mainboard/samsung/lumpy/romstage.c
@@ -45,7 +45,6 @@
#include "gpio.h"
#if CONFIG_DRIVERS_UART_8250IO
#include <superio/smsc/lpc47n207/lpc47n207.h>
-#include "superio/smsc/lpc47n207/early_serial.c"
#endif
#if CONFIG_CHROMEOS
#include <vendorcode/google/chromeos/chromeos.h>
diff --git a/src/mainboard/samsung/stumpy/Kconfig b/src/mainboard/samsung/stumpy/Kconfig
index 17484a9..1b65eae 100644
--- a/src/mainboard/samsung/stumpy/Kconfig
+++ b/src/mainboard/samsung/stumpy/Kconfig
@@ -11,6 +11,9 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select NORTHBRIDGE_INTEL_SANDYBRIDGE
select SOUTHBRIDGE_INTEL_BD82X6X
select SUPERIO_ITE_IT8772F
+# LPC47N207 selected for external LPC card
+# not on board, should be made selectable.
+ select SUPERIO_SMSC_LPC47N207
select HAVE_MRC
select INTEL_INT15
diff --git a/src/mainboard/samsung/stumpy/romstage.c b/src/mainboard/samsung/stumpy/romstage.c
index 1462132..2ed185b 100644
--- a/src/mainboard/samsung/stumpy/romstage.c
+++ b/src/mainboard/samsung/stumpy/romstage.c
@@ -45,7 +45,6 @@
#include "gpio.h"
#if CONFIG_DRIVERS_UART_8250IO
#include <superio/smsc/lpc47n207/lpc47n207.h>
-#include "superio/smsc/lpc47n207/early_serial.c"
#endif
#if CONFIG_CHROMEOS
#include <vendorcode/google/chromeos/chromeos.h>
diff --git a/src/superio/smsc/Kconfig b/src/superio/smsc/Kconfig
index 6aaa112..34bc60c 100644
--- a/src/superio/smsc/Kconfig
+++ b/src/superio/smsc/Kconfig
@@ -30,6 +30,8 @@ config SUPERIO_SMSC_LPC47M10X
bool
config SUPERIO_SMSC_LPC47M15X
bool
+config SUPERIO_SMSC_LPC47N207
+ bool
config SUPERIO_SMSC_LPC47N217
bool
config SUPERIO_SMSC_LPC47N227
diff --git a/src/superio/smsc/Makefile.inc b/src/superio/smsc/Makefile.inc
index a89b6ac..caa2c72 100644
--- a/src/superio/smsc/Makefile.inc
+++ b/src/superio/smsc/Makefile.inc
@@ -24,6 +24,7 @@ subdirs-y += lpc47b272
subdirs-y += lpc47b397
subdirs-y += lpc47m10x
subdirs-y += lpc47m15x
+subdirs-y += lpc47n207
subdirs-y += lpc47n217
subdirs-y += lpc47n227
subdirs-y += sio10n268
diff --git a/src/superio/smsc/lpc47n207/Makefile.inc b/src/superio/smsc/lpc47n207/Makefile.inc
new file mode 100644
index 0000000..08e1387
--- /dev/null
+++ b/src/superio/smsc/lpc47n207/Makefile.inc
@@ -0,0 +1,21 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2014 Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## 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
+##
+
+romstage-$(CONFIG_SUPERIO_SMSC_LPC47N207) += early_serial.c
diff --git a/src/superio/smsc/lpc47n207/early_serial.c b/src/superio/smsc/lpc47n207/early_serial.c
index e2ae49d..847fe97 100644
--- a/src/superio/smsc/lpc47n207/early_serial.c
+++ b/src/superio/smsc/lpc47n207/early_serial.c
@@ -17,6 +17,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <arch/io.h>
+#include <device/pnp.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "lpc47n207.h"
+
/*
* This code tries to discover the SMSC LPC47N207 superio chip which can be
* connected over an LPC dongle. The chip could be bootstrap mapped to one of
diff --git a/src/superio/smsc/lpc47n207/lpc47n207.h b/src/superio/smsc/lpc47n207/lpc47n207.h
index 69689a4..a122465 100644
--- a/src/superio/smsc/lpc47n207/lpc47n207.h
+++ b/src/superio/smsc/lpc47n207/lpc47n207.h
@@ -17,9 +17,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef SUPERIO_SMSC_LPC47N207_LPC47N207_H
-#define SUPERIO_SMSC_LPC47N207_LPC47N207_H
+#ifndef SUPERIO_SMSC_LPC47N207_H
+#define SUPERIO_SMSC_LPC47N207_H
-extern void try_enabling_LPC47N207_uart(void);
+#include <arch/io.h>
+#include <stdint.h>
-#endif
+void try_enabling_LPC47N207_uart(void);
+
+#endif /* SUPERIO_SMSC_LPC47N207_H */
Edward O'Callaghan (eocallaghan(a)alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8102
-gerrit
commit 05066db0da9f7474a9e327dce024487c82627431
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Mon Jan 5 21:21:16 2015 +1100
superio/smsc/lpc47n207: Remove poorly implemented SIO support
We remove the final superio .c includes here. The 'lpc47n207'
was never properly hooked into the build system and the
corresponding boards do not actually contain this superio necessarily.
The support was for add-on lpc debug cards however we have better ways
to handle this now.
Change-Id: I9e2bc4677fe2198123a0f4c3e0ad8928cae97296
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
---
src/mainboard/samsung/lumpy/romstage.c | 15 -----
src/mainboard/samsung/stumpy/romstage.c | 15 -----
src/superio/smsc/lpc47n207/early_serial.c | 97 -------------------------------
src/superio/smsc/lpc47n207/lpc47n207.h | 25 --------
4 files changed, 152 deletions(-)
diff --git a/src/mainboard/samsung/lumpy/romstage.c b/src/mainboard/samsung/lumpy/romstage.c
index 93cc068..85553fd 100644
--- a/src/mainboard/samsung/lumpy/romstage.c
+++ b/src/mainboard/samsung/lumpy/romstage.c
@@ -43,10 +43,6 @@
#include <halt.h>
#include "option_table.h"
#include "gpio.h"
-#if CONFIG_DRIVERS_UART_8250IO
-#include <superio/smsc/lpc47n207/lpc47n207.h>
-#include "superio/smsc/lpc47n207/early_serial.c"
-#endif
#if CONFIG_CHROMEOS
#include <vendorcode/google/chromeos/chromeos.h>
#endif
@@ -56,20 +52,9 @@ static void pch_enable_lpc(void)
/* Set COM1/COM2 decode range */
pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
-#if CONFIG_DRIVERS_UART_8250IO
- /* Enable SuperIO + EC + KBC + COM1 + lpc47n207 config*/
- pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | MC_LPC_EN |
- KBC_LPC_EN | CNF2_LPC_EN | COMA_LPC_EN);
-
- /* map full 256 bytes at 0x1600 to the LPC bus */
- pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0xfc1601);
-
- try_enabling_LPC47N207_uart();
-#else
/* Enable SuperIO + EC + KBC */
pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | MC_LPC_EN |
KBC_LPC_EN);
-#endif
}
static void rcba_config(void)
diff --git a/src/mainboard/samsung/stumpy/romstage.c b/src/mainboard/samsung/stumpy/romstage.c
index abaf48e..bbbefc3 100644
--- a/src/mainboard/samsung/stumpy/romstage.c
+++ b/src/mainboard/samsung/stumpy/romstage.c
@@ -43,10 +43,6 @@
#include <cpu/x86/msr.h>
#include <halt.h>
#include "gpio.h"
-#if CONFIG_DRIVERS_UART_8250IO
-#include <superio/smsc/lpc47n207/lpc47n207.h>
-#include "superio/smsc/lpc47n207/early_serial.c"
-#endif
#if CONFIG_CHROMEOS
#include <vendorcode/google/chromeos/chromeos.h>
#endif
@@ -69,19 +65,8 @@ static void pch_enable_lpc(void)
/* Set COM1/COM2 decode range */
pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
-#if CONFIG_DRIVERS_UART_8250IO
- /* Enable SuperIO + PS/2 Keyboard/Mouse + COM1 + lpc47n207 config*/
- pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | KBC_LPC_EN |\
- CNF2_LPC_EN | COMA_LPC_EN);
-
- /* map full 256 bytes at 0x1600 to the LPC bus */
- pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0xfc1601);
-
- try_enabling_LPC47N207_uart();
-#else
/* Enable SuperIO + PS/2 Keyboard/Mouse */
pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | KBC_LPC_EN);
-#endif
}
static void rcba_config(void)
diff --git a/src/superio/smsc/lpc47n207/early_serial.c b/src/superio/smsc/lpc47n207/early_serial.c
deleted file mode 100644
index e2ae49d..0000000
--- a/src/superio/smsc/lpc47n207/early_serial.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * 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
- */
-
-/*
- * This code tries to discover the SMSC LPC47N207 superio chip which can be
- * connected over an LPC dongle. The chip could be bootstrap mapped to one of
- * four LPC addresses: 0x2e, 0x4e, 0x162e, and 0x164e.
- *
- * Initializing the UART requires accesses to a few control registers. This
- * structure includes the register offset and the value to write (along with
- * the mask).
- */
-typedef struct {
- u8 conf_reg;
- u8 value;
- u8 mask;
-} uart_conf;
-
-/* All regs/values to write to initialize the LPC47N207 UART */
-static const uart_conf uart_conf_data [] = {
- {2, (1 << 3), (1 << 3)}, /* cr02, enable Primary UART power */
- {0xc, (1 << 6), (1 << 6)}, /* cr0c, enable Primary UART high speed */
- {0x24, (CONFIG_TTYS0_BASE >> 3) << 1, 0xff}, /* cr24, base addr */
-};
-
-void try_enabling_LPC47N207_uart(void)
-{
- u8 reg_value;
- const uart_conf* conf_item;
- u16 lpc_ports[] = {0x2e, 0x4e, 0x162e, 0x164e};
- u16 lpc_port;
- int i, j;
-
-#define CONFIG_ENABLE 0x55
-#define CONFIG_DISABLE 0xaa
-
- for (j = 0; j < ARRAY_SIZE(lpc_ports); j++) {
- lpc_port = lpc_ports[j];
-
- /* enable CONFIG mode */
- outb(CONFIG_ENABLE, lpc_port);
- reg_value=inb(lpc_port);
- if (reg_value != CONFIG_ENABLE) {
- continue; /* There is no LPC device at this address */
- }
-
- do {
- /*
- * Registers 12 and 13 hold config address, look for a
- * match.
- */
- outb(0x12, lpc_port);
- reg_value=inb(lpc_port + 1);
- if (reg_value != (lpc_port & 0xff))
- break;
-
- outb(0x13, lpc_port);
- reg_value=inb(lpc_port + 1);
- if (reg_value != (lpc_port >> 8))
- break;
-
- /* This must be the SMSC LPC 47N207, enable the UART. */
- for (i = 0; i < ARRAY_SIZE(uart_conf_data); i++) {
- u8 reg, value, mask;
-
- conf_item = uart_conf_data + i;
-
- reg = conf_item->conf_reg;
- value = conf_item->value;
- mask = conf_item->mask;
-
- outb(reg, lpc_port);
- reg_value = inb(lpc_port + 1);
- reg_value &= ~mask;
- reg_value |= (value & mask);
- outb(reg_value, lpc_port + 1);
- }
- } while (0);
- outb(CONFIG_DISABLE, lpc_port);
- }
-}
diff --git a/src/superio/smsc/lpc47n207/lpc47n207.h b/src/superio/smsc/lpc47n207/lpc47n207.h
deleted file mode 100644
index 69689a4..0000000
--- a/src/superio/smsc/lpc47n207/lpc47n207.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * 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
- */
-
-#ifndef SUPERIO_SMSC_LPC47N207_LPC47N207_H
-#define SUPERIO_SMSC_LPC47N207_LPC47N207_H
-
-extern void try_enabling_LPC47N207_uart(void);
-
-#endif
Martin Roth (gaumless(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8066
-gerrit
commit 25bc49a1db0256ee89b5d490c014ef67a7b395e7
Author: Martin Roth <martin.roth(a)se-eng.com>
Date: Sat Jan 3 17:18:58 2015 -0700
drivers/intel/fsp: Add HOB tools to work with GUIDs
Add new functions to:
- Compare two GUIDs
- Find a hob based on its GUID
- Print information about GUID_EXTENSION type HOBs
- Print a GUID's address and value
Change-Id: I89377ec8ab7d98fe7dc129097e643aac061ab3a3
Signed-off-by: Martin Roth <martin.roth(a)se-eng.com>
---
src/drivers/intel/fsp/fsp_util.h | 4 ++
src/drivers/intel/fsp/hob.c | 97 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/src/drivers/intel/fsp/fsp_util.h b/src/drivers/intel/fsp/fsp_util.h
index a8b89b3..ff6daca 100644
--- a/src/drivers/intel/fsp/fsp_util.h
+++ b/src/drivers/intel/fsp/fsp_util.h
@@ -43,7 +43,11 @@ uint8_t find_saved_temp_mem(void *hob_list_ptr, void **location, uint32_t *lengt
void print_hob_mem_attributes(void *Hobptr);
void print_hob_type_structure(u16 Hobtype, void *Hoblistptr);
void print_hob_resource_attributes(void *Hobptr);
+void print_guid_type_attributes(void *Hobptr);
const char * get_hob_type_string(void *Hobptr);
+void * find_hob_by_guid(void *Hoblistptr, EFI_GUID *guid1);
+uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2);
+void printguid(EFI_GUID *guid);
/* Additional HOB types not included in the FSP:
* #define EFI_HOB_TYPE_HANDOFF 0x0001
diff --git a/src/drivers/intel/fsp/hob.c b/src/drivers/intel/fsp/hob.c
index 4537ffb..99c4ba1 100644
--- a/src/drivers/intel/fsp/hob.c
+++ b/src/drivers/intel/fsp/hob.c
@@ -20,8 +20,26 @@
#include <types.h>
#include <string.h>
#include <console/console.h>
+#include <lib.h> // hexdump
#include "fsp_util.h"
+
+/** Displays a GUID's address and value
+ *
+ * @param guid pointer to the GUID to display
+ */
+void printguid(EFI_GUID *guid)
+{
+ printk(BIOS_SPEW,"Address: %p Guid: %08lx-%04x-%04x-",
+ guid, (unsigned long)guid->Data1,
+ guid->Data2, guid->Data3);
+ printk(BIOS_SPEW,"%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ guid->Data4[0], guid->Data4[1],
+ guid->Data4[2], guid->Data4[3],
+ guid->Data4[4], guid->Data4[5],
+ guid->Data4[6], guid->Data4[7] );
+}
+
void print_hob_mem_attributes(void *Hobptr)
{
EFI_HOB_MEMORY_ALLOCATION *HobMemoryPtr = (EFI_HOB_MEMORY_ALLOCATION *)Hobptr;
@@ -118,6 +136,27 @@ const char * get_hob_type_string(void *Hobptr)
return Hobtypestring;
}
+/** Displays the length, location, and GUID value of a GUID extension
+ *
+ * The EFI_HOB_GUID_TYPE is very basic - it just contains the standard
+ * HOB header containing the HOB type and length, and a GUID for
+ * identification. The rest of the data is undefined and must be known
+ * based on the GUID.
+ *
+ * This displays the entire HOB length, and the location of the start
+ * of the HOB, *NOT* the length of or the start of the data inside the HOB.
+ *
+ * @param Hobptr
+ */
+void print_guid_type_attributes(void *Hobptr)
+{
+ printk(BIOS_SPEW, " at location %p with length0x%0lx\n ",
+ Hobptr, (unsigned long)(((EFI_PEI_HOB_POINTERS *) \
+ Hobptr)->Guid->Header.HobLength));
+ printguid(&(((EFI_HOB_GUID_TYPE *)Hobptr)->Name));
+
+}
+
/* Print out a structure of all the HOBs
* that match a certain type:
* Print all types (0x0000)
@@ -159,6 +198,8 @@ void print_hob_type_structure(u16 Hobtype, void *Hoblistptr)
print_hob_mem_attributes(Currenthob); break;
case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR:
print_hob_resource_attributes(Currenthob); break;
+ case EFI_HOB_TYPE_GUID_EXTENSION:
+ print_guid_type_attributes(Currenthob); break;
}
}
@@ -170,3 +211,59 @@ void print_hob_type_structure(u16 Hobtype, void *Hoblistptr)
} while (!Lasthob);
printk(BIOS_DEBUG, "=== End of FSP HOB Data Structure ===\n\n");
}
+
+
+/** Finds a HOB entry based on type and guid
+ *
+ * @param current_hob pointer to the start of the HOB list
+ * @param guid the GUID of the HOB entry to find
+ * @return pointer to the start of the requested HOB or NULL if not found.
+ */
+void * find_hob_by_guid(void *current_hob, EFI_GUID *guid)
+{
+ do {
+ switch (((EFI_HOB_GENERIC_HEADER *)current_hob)->HobType) {
+
+ case EFI_HOB_TYPE_MEMORY_ALLOCATION:
+ if (guids_are_equal(guid, &(((EFI_HOB_MEMORY_ALLOCATION *) \
+ current_hob)->AllocDescriptor.Name)))
+ return current_hob;
+ break;
+ case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR:
+ if (guids_are_equal(guid,
+ &(((EFI_HOB_RESOURCE_DESCRIPTOR *) \
+ current_hob)->Owner)))
+ return current_hob;
+ break;
+ case EFI_HOB_TYPE_GUID_EXTENSION:
+ if (guids_are_equal(guid, &(((EFI_HOB_GUID_TYPE *) \
+ current_hob)->Name)))
+ return current_hob;
+ break;
+ }
+
+ if (!END_OF_HOB_LIST(current_hob))
+ current_hob = GET_NEXT_HOB(current_hob); /* Get next HOB pointer */
+ } while (!END_OF_HOB_LIST(current_hob));
+
+ return NULL;
+}
+
+/** Compares a pair of GUIDs to see if they are equal
+ *
+ * GUIDs are 128 bits long, so compare them as pairs of quadwords.
+ *
+ * @param guid1 pointer to the first of the GUIDs to compare
+ * @param guid2 pointer to the second of the GUIDs to compare
+ * @return 1 if the GUIDs were equal, 0 if GUIDs were not equal
+ */
+uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2)
+{
+ uint64_t* guid_1 = (void *) guid1;
+ uint64_t* guid_2 = (void *) guid2;
+
+ if ((*(guid_1) != *(guid_2)) || (*(guid_1 + 1) != *(guid_2 + 1)))
+ return 0;
+
+ return 1;
+}
Martin Roth (gaumless(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8066
-gerrit
commit 75e2707e43b66e8402901a0c927bcfd652f36212
Author: Martin Roth <martin.roth(a)se-eng.com>
Date: Sat Jan 3 17:18:58 2015 -0700
drivers/intel/fsp: Add HOB tools to work with GUIDs
Add new functions to:
- Compare two GUIDs
- Find a hob based on its GUID
- Print information about GUID_EXTENSION type HOBs
- Print a GUID's address and value
Change-Id: I89377ec8ab7d98fe7dc129097e643aac061ab3a3
Signed-off-by: Martin Roth <martin.roth(a)se-eng.com>
---
src/drivers/intel/fsp/fsp_util.h | 4 ++
src/drivers/intel/fsp/hob.c | 97 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+)
diff --git a/src/drivers/intel/fsp/fsp_util.h b/src/drivers/intel/fsp/fsp_util.h
index cb667dc..3c72f24 100644
--- a/src/drivers/intel/fsp/fsp_util.h
+++ b/src/drivers/intel/fsp/fsp_util.h
@@ -42,7 +42,11 @@ void ChipsetFspReturnPoint(EFI_STATUS Status, VOID *HobListPtr);
void print_hob_mem_attributes(void *Hobptr);
void print_hob_type_structure(u16 Hobtype, void *Hoblistptr);
void print_hob_resource_attributes(void *Hobptr);
+void print_guid_type_attributes(void *Hobptr);
const char * get_hob_type_string(void *Hobptr);
+void * find_hob_by_guid(void *Hoblistptr, EFI_GUID *guid1);
+uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2);
+void printguid(EFI_GUID *guid);
/* Additional HOB types not included in the FSP:
* #define EFI_HOB_TYPE_HANDOFF 0x0001
diff --git a/src/drivers/intel/fsp/hob.c b/src/drivers/intel/fsp/hob.c
index 4537ffb..fbb6868 100644
--- a/src/drivers/intel/fsp/hob.c
+++ b/src/drivers/intel/fsp/hob.c
@@ -20,8 +20,26 @@
#include <types.h>
#include <string.h>
#include <console/console.h>
+#include <lib.h> // hexdump
#include "fsp_util.h"
+
+/** Displays a GUID's address and value
+ *
+ * @param guid pointer to the GUID to display
+ */
+void printguid(EFI_GUID *guid)
+{
+ printk(BIOS_SPEW,"Address: %p Guid: %08lx-%04x-%04x-",
+ guid, (unsigned long)guid->Data1,
+ guid->Data2, guid->Data3,
+ printk(BIOS_SPEW,"%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ guid->Data4[0], guid->Data4[1]);
+ guid->Data4[2], guid->Data4[3],
+ guid->Data4[4], guid->Data4[5],
+ guid->Data4[6], guid->Data4[7] );
+}
+
void print_hob_mem_attributes(void *Hobptr)
{
EFI_HOB_MEMORY_ALLOCATION *HobMemoryPtr = (EFI_HOB_MEMORY_ALLOCATION *)Hobptr;
@@ -118,6 +136,27 @@ const char * get_hob_type_string(void *Hobptr)
return Hobtypestring;
}
+/** Displays the length, location, and GUID value of a GUID extension
+ *
+ * The EFI_HOB_GUID_TYPE is very basic - it just contains the standard
+ * HOB header containing the HOB type and length, and a GUID for
+ * identification. The rest of the data is undefined and must be known
+ * based on the GUID.
+ *
+ * This displays the entire HOB length, and the location of the start
+ * of the HOB, *NOT* the length of or the start of the data inside the HOB.
+ *
+ * @param Hobptr
+ */
+void print_guid_type_attributes(void *Hobptr)
+{
+ printk(BIOS_SPEW, " at location %p with length0x%0lx\n ",
+ Hobptr, (unsigned long)(((EFI_PEI_HOB_POINTERS *) \
+ Hobptr)->Guid->Header.HobLength));
+ printguid(&(((EFI_HOB_GUID_TYPE *)Hobptr)->Name));
+
+}
+
/* Print out a structure of all the HOBs
* that match a certain type:
* Print all types (0x0000)
@@ -159,6 +198,8 @@ void print_hob_type_structure(u16 Hobtype, void *Hoblistptr)
print_hob_mem_attributes(Currenthob); break;
case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR:
print_hob_resource_attributes(Currenthob); break;
+ case EFI_HOB_TYPE_GUID_EXTENSION:
+ print_guid_type_attributes(Currenthob); break;
}
}
@@ -170,3 +211,59 @@ void print_hob_type_structure(u16 Hobtype, void *Hoblistptr)
} while (!Lasthob);
printk(BIOS_DEBUG, "=== End of FSP HOB Data Structure ===\n\n");
}
+
+
+/** Finds a HOB entry based on type and guid
+ *
+ * @param current_hob pointer to the start of the HOB list
+ * @param guid the GUID of the HOB entry to find
+ * @return pointer to the start of the requested HOB or NULL if not found.
+ */
+void * find_hob_by_guid(void *current_hob, EFI_GUID *guid)
+{
+ do {
+ switch (((EFI_HOB_GENERIC_HEADER *)current_hob)->HobType) {
+
+ case EFI_HOB_TYPE_MEMORY_ALLOCATION:
+ if (guids_are_equal(guid, &(((EFI_HOB_MEMORY_ALLOCATION *) \
+ current_hob)->AllocDescriptor.Name)))
+ return current_hob;
+ break;
+ case EFI_HOB_TYPE_RESOURCE_DESCRIPTOR:
+ if (guids_are_equal(guid,
+ &(((EFI_HOB_RESOURCE_DESCRIPTOR *) \
+ current_hob)->Owner)))
+ return current_hob;
+ break;
+ case EFI_HOB_TYPE_GUID_EXTENSION:
+ if (guids_are_equal(guid, &(((EFI_HOB_GUID_TYPE *) \
+ current_hob)->Name)))
+ return current_hob;
+ break;
+ }
+
+ if (!END_OF_HOB_LIST(current_hob))
+ current_hob = GET_NEXT_HOB(current_hob); /* Get next HOB pointer */
+ } while (!END_OF_HOB_LIST(current_hob));
+
+ return NULL;
+}
+
+/** Compares a pair of GUIDs to see if they are equal
+ *
+ * GUIDs are 128 bits long, so compare them as pairs of quadwords.
+ *
+ * @param guid1 pointer to the first of the GUIDs to compare
+ * @param guid2 pointer to the second of the GUIDs to compare
+ * @return 1 if the GUIDs were equal, 0 if GUIDs were not equal
+ */
+uint8_t guids_are_equal(EFI_GUID *guid1, EFI_GUID *guid2)
+{
+ uint64_t* guid_1 = (void *) guid1;
+ uint64_t* guid_2 = (void *) guid2;
+
+ if ((*(guid_1) != *(guid_2)) || (*(guid_1 + 1) != *(guid_2 + 1)))
+ return 0;
+
+ return 1;
+}