Marty E. Plummer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
arch/ppc64: add arch_timer
Based on code from hostboot's timemgr.C file. looks right and the resultant assembly looks correct.
Change-Id: I65d7be0fd384e69a069fe8278c313db914763b80 Signed-off-by: Marty E. Plummer hanetzer@startmail.com --- M src/arch/ppc64/Kconfig M src/arch/ppc64/Makefile.inc A src/arch/ppc64/arch_timer.c A src/arch/ppc64/include/arch/asm.h 4 files changed, 101 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/35171/1
diff --git a/src/arch/ppc64/Kconfig b/src/arch/ppc64/Kconfig index 0f65c0c..41ff074 100644 --- a/src/arch/ppc64/Kconfig +++ b/src/arch/ppc64/Kconfig @@ -20,3 +20,9 @@ select ARCH_PPC64
source "src/arch/ppc64/power8/Kconfig" +source "src/arch/ppc64/power9/Kconfig" + +config PPC64_USE_ARCH_TIMER + bool + default n + diff --git a/src/arch/ppc64/Makefile.inc b/src/arch/ppc64/Makefile.inc index 7a069cd..d6f0b77 100644 --- a/src/arch/ppc64/Makefile.inc +++ b/src/arch/ppc64/Makefile.inc @@ -30,6 +30,7 @@ bootblock-y += stages.c bootblock-y += boot.c bootblock-y += rom_media.c +bootblock-$(CONFIG_PPC64_USE_ARCH_TIMER) += arch_timer.c bootblock-y += \ $(top)/src/lib/memchr.c \ $(top)/src/lib/memcmp.c \ @@ -55,6 +56,7 @@ romstage-y += boot.c romstage-y += stages.c romstage-y += rom_media.c +romstage-$(CONFIG_PPC64_USE_ARCH_TIMER) += arch_timer.c romstage-y += \ $(top)/src/lib/memchr.c \ $(top)/src/lib/memcmp.c \ @@ -84,6 +86,7 @@ ramstage-y += stages.c ramstage-y += boot.c ramstage-y += tables.c +ramstage-$(CONFIG_PPC64_USE_ARCH_TIMER) += arch_timer.c ramstage-y += \ $(top)/src/lib/memchr.c \ $(top)/src/lib/memcmp.c \ diff --git a/src/arch/ppc64/arch_timer.c b/src/arch/ppc64/arch_timer.c new file mode 100644 index 0000000..c988a34 --- /dev/null +++ b/src/arch/ppc64/arch_timer.c @@ -0,0 +1,25 @@ +/* + * This file is part of the coreboot project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * 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. + */ + +#include <timer.h> +#include <arch/asm.h> + +void timer_monotonic_get(struct mono_time *mt) +{ + // TODO: see src/kernel/timemgr.C + // looks right for now... + uint64_t value = raw_read_tb(); + uint64_t freq = 512000000ULL; + long usecs = (value * 1000000) / freq; + mono_time_set_usecs(mt, usecs); +} diff --git a/src/arch/ppc64/include/arch/asm.h b/src/arch/ppc64/include/arch/asm.h new file mode 100644 index 0000000..4692f87 --- /dev/null +++ b/src/arch/ppc64/include/arch/asm.h @@ -0,0 +1,67 @@ +/* + * This file is part of the coreboot project. + * + * 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. + */ + +#ifndef __PPC_PPC64_ASM_H +#define __PPC_PPC64_ASM_H + +#define ENDPROC(name) \ + .type name, % function; \ + END(name) + +#define ENTRY_WITH_ALIGN(name, bits) \ + .section.text.name, "ax", % progbits; \ + .global name; \ + .align bits; \ + name: + +#define ENTRY(name) ENTRY_WITH_ALIGN(name, 2) + +#define END(name) .size name, .- name + +/* Special Purpose Registers */ +#define SPRN_TBRL 268 +#define SPRN_TBRU 269 + + +#ifndef __ASSEMBLER__ + +#include <stdint.h> + +#define MAKE_REGISTER_READ(reg) \ + static inline uint64_t raw_read_##reg(void) \ + { \ + uint64_t value; \ + __asm__ __volatile__("mfspr %0, " #reg "\n\t" : "=r"(value)); \ + return value; \ + } + +#define MAKE_REGISTER_WRITE(reg) \ + static inline void raw_write_##reg(uint64_t value) \ + { \ + __asm__ __volatile__("mtspr " #reg ", %0\n\t" : : "r"(value) : "memory"); \ + } + +#define MAKE_REGISTER_ACCESSORS(reg) \ + MAKE_REGISTER_READ(##reg) \ + MAKE_REGISTER_WRITE(##reg) + +static inline uint64_t raw_read_tb(void) +{ + uint64_t value; + __asm__ __volatile__("mfspr %0, %1\n\t" : "=r"(value) : "i"(SPRN_TBRL)); + return value; +} + +#endif /* __ASSEMBLER__ */ + +#endif /* __PPC_PPC64_ASM_H */
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
Patch Set 1:
(7 comments)
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... File src/arch/ppc64/include/arch/asm.h:
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 17: #define ENDPROC(name) \ Macros with multiple statements should be enclosed in a do - while loop
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 21: #define ENTRY_WITH_ALIGN(name, bits) \ Macros with multiple statements should be enclosed in a do - while loop
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 25: name: labels should not be indented
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 29: #define END(name) .size name, .- name space required before that '-' (ctx:VxW)
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 29: #define END(name) .size name, .- name space prohibited after that '-' (ctx:VxW)
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 29: #define END(name) .size name, .- name Macros with complex values should be enclosed in parentheses
https://review.coreboot.org/c/coreboot/+/35171/1/src/arch/ppc64/include/arch... PS1, Line 54: #define MAKE_REGISTER_ACCESSORS(reg) \ Macros with complex values should be enclosed in parentheses
Marty E. Plummer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
Patch Set 1:
This is not how I wanted to write stuff, but the commit hook would not take the code as I wrote it. If someone knows how to override it so the code is accepted in an actually good layout/format, please do tell.
Marty E. Plummer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
Patch Set 1: Code-Review-1
This change is ready for review.
Marty E. Plummer has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
Patch Set 3:
This change is ready for review.
Hello Timothy Pearson, ron minnich, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/35171
to look at the new patch set (#4).
Change subject: arch/ppc64: add arch_timer ......................................................................
arch/ppc64: add arch_timer
Based on code from hostboot's timemgr.C file. looks right and the resultant assembly looks correct.
Change-Id: I65d7be0fd384e69a069fe8278c313db914763b80 Signed-off-by: Marty E. Plummer hanetzer@startmail.com --- M src/arch/ppc64/Kconfig M src/arch/ppc64/Makefile.inc A src/arch/ppc64/arch_timer.c A src/arch/ppc64/include/arch/asm.h 4 files changed, 101 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/35171/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35171 )
Change subject: arch/ppc64: add arch_timer ......................................................................
Patch Set 4:
(6 comments)
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... File src/arch/ppc64/include/arch/asm.h:
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 17: #define ENDPROC(name) \ Macros with multiple statements should be enclosed in a do - while loop
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 21: #define ENTRY_WITH_ALIGN(name, bits) \ Macros with multiple statements should be enclosed in a do - while loop
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 25: name: labels should not be indented
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 29: #define END(name) \ Macros with complex values should be enclosed in parentheses
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 30: .size name, .-name space required before that '-' (ctx:VxV)
https://review.coreboot.org/c/coreboot/+/35171/4/src/arch/ppc64/include/arch... PS4, Line 55: #define MAKE_REGISTER_ACCESSORS(reg) \ Macros with complex values should be enclosed in parentheses