diff options
author | Stewart Smith <stewart@linux.ibm.com> | 2019-04-26 11:59:57 -0500 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2019-05-02 09:57:15 +1000 |
commit | b877a4e8b9eaafcacd2ed31ebcf47b769929e68d (patch) | |
tree | 3800af8139ceb1409d5453df331abf7722517a3c /hw/test | |
parent | c51914b87b48a7b836b5048961e891e23cba457c (diff) | |
download | skiboot-b877a4e8b9eaafcacd2ed31ebcf47b769929e68d.zip skiboot-b877a4e8b9eaafcacd2ed31ebcf47b769929e68d.tar.gz skiboot-b877a4e8b9eaafcacd2ed31ebcf47b769929e68d.tar.bz2 |
Write boot progress to LPC port 80h
This is an adaptation of what we currently do for op_display() on FSP
machines, inventing an encoding for what we can write into the single
byte at LPC port 80h.
Port 80h is often used on x86 systems to indicate boot progress/status
and dates back a decent amount of time. Since a byte isn't exactly very
expressive for everything that can go on (and wrong) during boot, it's
all about compromise.
Some systems (such as Zaius/Barreleye G2) have a physical dual 7 segment
display that display these codes. So far, this has only been driven by
hostboot (see hostboot commit 90ec2e65314c).
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'hw/test')
-rw-r--r-- | hw/test/Makefile.check | 13 | ||||
-rw-r--r-- | hw/test/run-port80h.c | 79 |
2 files changed, 91 insertions, 1 deletions
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; +} |