Bryant Ou has uploaded this change for review.

View Change

mb/ocp/deltalake: Insert IO port in linux command line

Search "uart8250,io," string in CONFIG_LINUX_COMMAND_LINE, then
insert uart base address which defined in VPD.

Tested=On OCP Delta Lake, payload use correct uart base address
to output messages via VPD variable.

Signed-off-by: Bryant Ou <Bryant.Ou.Q@gmail.com>
Change-Id: I8747a23c7246aabe8c01ad5be668e1672b586f2c
---
M src/mainboard/ocp/deltalake/Kconfig
M src/mainboard/ocp/deltalake/ramstage.c
2 files changed, 76 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/10/45410/1
diff --git a/src/mainboard/ocp/deltalake/Kconfig b/src/mainboard/ocp/deltalake/Kconfig
index 5671664..0ab8bbb 100644
--- a/src/mainboard/ocp/deltalake/Kconfig
+++ b/src/mainboard/ocp/deltalake/Kconfig
@@ -54,4 +54,10 @@
bool
default y

+config LINUX_COMMAND_LINE_OVERRIDE
+ bool
+ default y
+ help
+ Override linux command line by using VPD.
+
endif # BOARD_OCP_DELTALAKE
diff --git a/src/mainboard/ocp/deltalake/ramstage.c b/src/mainboard/ocp/deltalake/ramstage.c
index e00f1c3..115f7d3 100644
--- a/src/mainboard/ocp/deltalake/ramstage.c
+++ b/src/mainboard/ocp/deltalake/ramstage.c
@@ -10,6 +10,7 @@
#include <soc/ramstage.h>
#include <soc/soc_util.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <smbios.h>
#include <device/pci_def.h>
@@ -18,10 +19,13 @@
#include <hob_iiouds.h>
#include <hob_memmap.h>
#include <cpxsp_dl_gpio.h>
-
+#include <program_loading.h>
+#include <drivers/vpd/vpd.h>
+#include "vpd.h"
#include "ipmi.h"

#define SLOT_ID_LEN 2
+#define COMMAND_LINE_LOC 0x91000

extern struct fru_info_str fru_strings;
static char slot_id_str[SLOT_ID_LEN];
@@ -285,3 +289,68 @@
}

BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, pull_post_complete_pin, NULL);
+
+#if (CONFIG(LINUX_COMMAND_LINE_OVERRIDE))
+void platform_segment_loaded(uintptr_t start, size_t size, int flags)
+{
+ char *port;
+ char *dupstr = strdup((char*)start);
+ const char s[] = {"uart8250,io,"};
+ char *new = NULL;
+ char *p;
+ char *slice[10];
+ char *found;
+ char *pre;
+ char *t1;
+ char *t2;
+ int count = 0;
+ int i;
+ int c;
+ int len;
+ int pos;
+
+ /* Add IO port into linux command line */
+ if (start == COMMAND_LINE_LOC) {
+ port = malloc(VPD_LEN);
+ if (vpd_gets(UART_IOPORT, port, VPD_LEN, VPD_RW_THEN_RO)) {
+ port = strconcat(port, ",");
+ } else {
+ printk(BIOS_ERR, "UART_IOPORT is not found in VPD\n");
+ port = strconcat(UART_IOPORT_DEFAULT, ",");
+ }
+ strcpy(new, "");
+ for (p = strtok(dupstr, " "); p; p = strtok(NULL, " ")) {
+ slice[count] = p;
+ count++;
+ }
+ for (i = 0; i < count; i++) {
+ len = strlen(slice[i]);
+ found = strstr(slice[i], s);
+ if (found != NULL) {
+ pos = found - slice[i] + strlen(s);
+ t1 = malloc(pos);
+ for (c = 0; c < pos; c++) {
+ *(t1 + c) = *(slice[i] + c);
+ }
+ *(t1 + c) = '\0';
+ pre = strconcat(t1, port);
+ free(t1);
+ t2 = malloc(len - pos + 2);
+ for (c = 0; c < (len - pos + 1); c++) {
+ *(t2 + c) = *((slice[i] + pos) + c);
+ }
+ *(t2 + c) = '\0';
+ pre = strconcat(pre, t2);
+ free(t2);
+ slice[i] = strdup(pre);
+ }
+ new = strconcat(new, slice[i]);
+ if (i < count - 1)
+ new = strconcat(new, " ");
+ }
+ free(port);
+ memset((uint8_t*)start, 0, size);
+ memcpy((uint8_t*)start, new, strlen(new));
+ }
+}
+#endif

To view, visit change 45410. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I8747a23c7246aabe8c01ad5be668e1672b586f2c
Gerrit-Change-Number: 45410
Gerrit-PatchSet: 1
Gerrit-Owner: Bryant Ou <bryant.ou.q@gmail.com>
Gerrit-MessageType: newchange