aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Eiderman <shmuel.eiderman@oracle.com>2019-06-12 12:37:01 +0300
committerGerd Hoffmann <kraxel@redhat.com>2019-11-06 10:56:00 +0100
commitb3d21205b7f5cd94e5e34277226c4289b6f65746 (patch)
treea13a740389d530d0439731f44f6a733ca2755ef0
parent7c66a439c07536b525ff9d5ce230775975e9c072 (diff)
downloadseabios-b3d21205b7f5cd94e5e34277226c4289b6f65746.tar.gz
boot: Reorder functions in boot.c
Currently glob_prefix() and build_pci_path() are under the "Boot priority ordering" section. Move them to a new "Helper search functions" section since we will reuse them in the next commit. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-3-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--src/boot.c94
1 files changed, 49 insertions, 45 deletions
diff --git a/src/boot.c b/src/boot.c
index 461de86e..b3d49304 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -22,6 +22,55 @@
#include "util.h" // irqtimer_calc
#include "tcgbios.h" // tpm_*
+/****************************************************************
+ * Helper search functions
+ ****************************************************************/
+
+// See if 'str' starts with 'glob' - if glob contains an '*' character
+// it will match any number of characters in str that aren't a '/' or
+// the next glob character.
+static char *
+glob_prefix(const char *glob, const char *str)
+{
+ for (;;) {
+ if (!*glob && (!*str || *str == '/'))
+ return (char*)str;
+ if (*glob == '*') {
+ if (!*str || *str == '/' || *str == glob[1])
+ glob++;
+ else
+ str++;
+ continue;
+ }
+ if (*glob != *str)
+ return NULL;
+ glob++;
+ str++;
+ }
+}
+
+#define FW_PCI_DOMAIN "/pci@i0cf8"
+
+static char *
+build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci)
+{
+ // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2
+ char *p = buf;
+ if (pci->parent) {
+ p = build_pci_path(p, max, "pci-bridge", pci->parent);
+ } else {
+ p += snprintf(p, buf+max-p, "%s", FW_PCI_DOMAIN);
+ if (pci->rootbus)
+ p += snprintf(p, buf+max-p, ",%x", pci->rootbus);
+ }
+
+ int dev = pci_bdf_to_dev(pci->bdf), fn = pci_bdf_to_fn(pci->bdf);
+ p += snprintf(p, buf+max-p, "/%s@%x", devname, dev);
+ if (fn)
+ p += snprintf(p, buf+max-p, ",%x", fn);
+ return p;
+}
+
/****************************************************************
* Boot device parameters
@@ -154,29 +203,6 @@ loadBootOrder(void)
} while (f);
}
-// See if 'str' starts with 'glob' - if glob contains an '*' character
-// it will match any number of characters in str that aren't a '/' or
-// the next glob character.
-static char *
-glob_prefix(const char *glob, const char *str)
-{
- for (;;) {
- if (!*glob && (!*str || *str == '/'))
- return (char*)str;
- if (*glob == '*') {
- if (!*str || *str == '/' || *str == glob[1])
- glob++;
- else
- str++;
- continue;
- }
- if (*glob != *str)
- return NULL;
- glob++;
- str++;
- }
-}
-
// Search the bootorder list for the given glob pattern.
static int
find_prio(const char *glob)
@@ -189,28 +215,6 @@ find_prio(const char *glob)
return -1;
}
-#define FW_PCI_DOMAIN "/pci@i0cf8"
-
-static char *
-build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci)
-{
- // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2
- char *p = buf;
- if (pci->parent) {
- p = build_pci_path(p, max, "pci-bridge", pci->parent);
- } else {
- p += snprintf(p, buf+max-p, "%s", FW_PCI_DOMAIN);
- if (pci->rootbus)
- p += snprintf(p, buf+max-p, ",%x", pci->rootbus);
- }
-
- int dev = pci_bdf_to_dev(pci->bdf), fn = pci_bdf_to_fn(pci->bdf);
- p += snprintf(p, buf+max-p, "/%s@%x", devname, dev);
- if (fn)
- p += snprintf(p, buf+max-p, ",%x", fn);
- return p;
-}
-
int bootprio_find_pci_device(struct pci_device *pci)
{
if (CONFIG_CSM)