aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/Makefile.inc1
-rw-r--r--hw/fsp/fsp-op-panel.c4
-rw-r--r--hw/lpc-port80h.c99
-rw-r--r--hw/test/Makefile.check13
-rw-r--r--hw/test/run-port80h.c79
-rw-r--r--include/op-panel.h2
6 files changed, 195 insertions, 3 deletions
diff --git a/hw/Makefile.inc b/hw/Makefile.inc
index a4d5cb3..fbafd82 100644
--- a/hw/Makefile.inc
+++ b/hw/Makefile.inc
@@ -10,6 +10,7 @@ HW_OBJS += fake-nvram.o lpc-mbox.o npu2.o npu2-hw-procedures.o
HW_OBJS += npu2-common.o phys-map.o sbe-p9.o capp.o occ-sensor.o vas.o
HW_OBJS += npu2-opencapi.o phys-map.o sbe-p9.o capp.o occ-sensor.o
HW_OBJS += vas.o sbe-p8.o
+HW_OBJS += lpc-port80h.o
HW=hw/built-in.a
include $(SRC)/hw/fsp/Makefile.inc
diff --git a/hw/fsp/fsp-op-panel.c b/hw/fsp/fsp-op-panel.c
index 7063cbb..6477e73 100644
--- a/hw/fsp/fsp-op-panel.c
+++ b/hw/fsp/fsp-op-panel.c
@@ -55,8 +55,10 @@ void op_display(enum op_severity sev, enum op_module mod, uint16_t code)
uint32_t w0;
uint32_t w1;
- if (!fsp_present())
+ if (!fsp_present()) {
+ op_display_lpc(sev, mod, code);
return;
+ }
w0 = sev << 16 | mod;
diff --git a/hw/lpc-port80h.c b/hw/lpc-port80h.c
new file mode 100644
index 0000000..72ac8b2
--- /dev/null
+++ b/hw/lpc-port80h.c
@@ -0,0 +1,99 @@
+/* Copyright 2018 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define pr_fmt(fmt) "Port80h: " fmt
+
+#include <lpc.h>
+#include <op-panel.h>
+
+/*
+ * Convert our detailed op_display() call into 1 byte for LPC port 80h
+ *
+ * Our layout looks like this:
+ * MSB (bit 7): 1 = Comes from OPAL
+ * bit 6 : 0 = OP_MOD_INIT (the main one), 1 = (see bit 5)
+ * bit 5432 : (if bit 6=0, low nibble of op-panel code)
+ * bit 5432 : (if bit 6=1, other OP_MOD_ values in bits 54:
+ * 00b=OP_MOD_CPU, 01b=OP_MOD_LOCK,
+ * 10b=OP_MOD_MEM, 11b=OP_MOD_CHIPTOD
+ * bits 0,1 from code in bits 32)
+ *
+ * bit 1,0: 00b=OP_LOG, 10b=OP_WARN, 01b=OP_ERROR, 11b=OP_FATAL
+ * i.e. bit 0 indicates ERROR or FATAL.
+ *
+ * If port 80h number has the MSB and LSB set, then you died in OPAL.
+ * Any *odd* number with the MSB set (i.e. > 0x80) indicates error.
+ */
+static inline uint8_t op_display_to_port80(uint8_t last_value, enum op_severity s, enum op_module m, uint16_t c)
+{
+ uint8_t r = 0x80; /* Start with top bit set indicating in OPAL */
+
+ switch(m) {
+ case OP_MOD_INIT:
+ /* bit 6 is zero */
+ /* bits 5432 have low nibble of c */
+ r |= (c & 0x0f) << 2;
+ break;
+ case OP_MOD_CPU:
+ r |= 0x40 | (c & 0x03) << 2;
+ break;
+ case OP_MOD_LOCK:
+ r |= 0x50 | (c & 0x03) << 2;
+ break;
+ case OP_MOD_MEM:
+ r |= 0x60 | (c & 0x03) << 2;
+ break;
+ case OP_MOD_CHIPTOD:
+ r |= 0x70 | (c & 0x03) << 2;
+ break;
+ case OP_MOD_CORE:
+ /*
+ * Only current OP_MOD_CORE is where we're OP_FATAL,
+ * So let's go for the last value set and tweak the
+ * bits for OP_FATAL.
+ */
+ r = last_value & 0xFC;
+ break;
+ case OP_MOD_FSP:
+ case OP_MOD_FSPCON:
+ /* Should never be hit, port80h only used on non-FSP! */
+ break;
+ }
+
+ switch(s) {
+ case OP_LOG:
+ break;
+ case OP_WARN:
+ r |= 0x02;
+ break;
+ case OP_ERROR:
+ r |= 0x01;
+ break;
+ case OP_FATAL:
+ r |= 0x03;
+ }
+
+ return r;
+}
+
+void op_display_lpc(enum op_severity s, enum op_module m, uint16_t c)
+{
+ static uint8_t port80_val = 0x80;
+
+ port80_val = op_display_to_port80(port80_val, s, m, c);
+ lpc_outb(port80_val, 0x80);
+}
+
diff --git a/hw/test/Makefile.check b/hw/test/Makefile.check
index f722ff6..1681027 100644
--- a/hw/test/Makefile.check
+++ b/hw/test/Makefile.check
@@ -1,10 +1,18 @@
# -*-Makefile-*-
-HW_TEST := hw/test/phys-map-test
+SUBDIRS += hw/test/
+HW_TEST := hw/test/phys-map-test hw/test/run-port80h
.PHONY : hw-check
hw-check: $(HW_TEST:%=%-check)
+.PHONY : hw-coverage
+hw-coverage: $(HW_TEST:%=%-gcov-run)
+
check: hw-check
+coverage: hw-coverage
+
+$(HW_TEST:%=%-gcov-run) : %-run: %
+ $(call QTEST, TEST-COVERAGE ,$< , $<)
$(HW_TEST:%=%-check) : %-check: %
$(call Q, RUN-TEST ,$(VALGRIND) $<, $<)
@@ -12,6 +20,9 @@ $(HW_TEST:%=%-check) : %-check: %
$(HW_TEST) : % : %.c hw/phys-map.o
$(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -O0 -g -I include -I . -o $@ $<, $<)
+$(HW_TEST:%=%-gcov): %-gcov : %.c %
+ $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) $(HOSTGCOVCFLAGS) -I include -I . -lgcov -o $@ $<, $<)
+
clean: hw-clean
hw-clean:
diff --git a/hw/test/run-port80h.c b/hw/test/run-port80h.c
new file mode 100644
index 0000000..60f6986
--- /dev/null
+++ b/hw/test/run-port80h.c
@@ -0,0 +1,79 @@
+/* Copyright 2018 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <assert.h>
+
+#define __LPC_H
+
+uint8_t port80;
+
+static inline void lpc_outb(uint8_t data, uint32_t addr)
+{
+ assert(addr == 0x80);
+ port80 = data;
+}
+
+#include "op-panel.h"
+
+void op_display_lpc(enum op_severity s, enum op_module m, uint16_t c);
+
+#include "../lpc-port80h.c"
+#include "../../core/test/stubs.c"
+
+int main(void)
+{
+ op_display_lpc(OP_LOG, OP_MOD_INIT, 0x00);
+ assert(port80 == 0x80);
+ op_display_lpc(OP_WARN, OP_MOD_INIT, 0x00);
+ assert(port80 == 0x82);
+ op_display_lpc(OP_ERROR, OP_MOD_INIT, 0x00);
+ assert(port80 == 0x81);
+ op_display_lpc(OP_FATAL, OP_MOD_INIT, 0x00);
+ assert(port80 == 0x83);
+ op_display_lpc(OP_FATAL, OP_MOD_INIT, 0x0f);
+ assert(port80 == 0xBF);
+ op_display_lpc(OP_LOG, OP_MOD_INIT, 0x0f);
+ assert(port80 == 0xBC);
+ op_display_lpc(OP_FATAL, OP_MOD_CORE, 0x6666);
+ assert(port80 == 0xBF);
+ op_display_lpc(OP_LOG, OP_MOD_INIT, 0x01);
+ assert(port80 == 0x84);
+ op_display_lpc(OP_LOG, OP_MOD_CPU, 0x05);
+ assert(port80 == 0xC4);
+ op_display_lpc(OP_LOG, OP_MOD_LOCK, 0x07);
+ assert(port80 == 0xDC);
+ op_display_lpc(OP_FATAL, OP_MOD_LOCK, 0x07);
+ assert(port80 == 0xDF);
+ op_display_lpc(OP_FATAL, OP_MOD_MEM, 0x07);
+ assert(port80 == 0xEF);
+ op_display_lpc(OP_WARN, OP_MOD_MEM, 0x02);
+ assert(port80 == 0xEA);
+ op_display_lpc(OP_WARN, OP_MOD_CHIPTOD, 0x02);
+ assert(port80 == 0xFA);
+
+ /*
+ * We can't assert that OP_MOD_FSP is invalid as we'd end up
+ * trying to set port80 in the assert parth
+ */
+ op_display_lpc(OP_LOG, OP_MOD_FSP, 0x00);
+ assert(port80 == 0x80);
+ op_display_lpc(OP_LOG, OP_MOD_FSPCON, 0x00);
+ assert(port80 == 0x80);
+ return 0;
+}
diff --git a/include/op-panel.h b/include/op-panel.h
index 6a935b8..557e750 100644
--- a/include/op-panel.h
+++ b/include/op-panel.h
@@ -41,7 +41,6 @@ enum op_module {
OP_MOD_CHIPTOD = 0x3035, /* '05' - ChipTOP */
OP_MOD_CPU = 0x3036, /* '06' - CPU bringup */
OP_MOD_MEM = 0x3037, /* '07' - Memory */
- OP_MOD_XSCOM = 0x3038, /* '08' - XSCOM */
};
/* Common codes:
@@ -63,6 +62,7 @@ enum op_module {
*/
extern void op_display(enum op_severity, enum op_module, uint16_t code);
+extern void op_display_lpc(enum op_severity s, enum op_module m, uint16_t c);
extern void op_panel_disable_src_echo(void);
extern void op_panel_clear_src(void);