^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * MIPS-specific debug support for pre-boot environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * NOTE: putc() is board specific, if your board have a 16550 compatible uart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * please select SYS_SUPPORTS_ZBOOT_UART16550 for your machine. othewise, you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * need to implement your own putc().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) void __weak putc(char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) void puts(const char *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) while ((c = *s++) != '\0') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) putc(c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) if (c == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) putc('\r');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) void puthex(unsigned long long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned char buf[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) for (i = 7; i >= 0; i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) buf[i] = "0123456789ABCDEF"[val & 0x0F];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) val >>= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) buf[8] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) puts(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }