summary refs log tree commit diff stats
path: root/tests/tcg/mips/mips64-dsp/printf.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-01-25 16:31:02 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-01-25 16:31:02 +0000
commit2dc2f10de3e20854f8b7cbada9622d699a41f106 (patch)
tree3fcfeffc70449d59fbae27987d7caee6898250b2 /tests/tcg/mips/mips64-dsp/printf.c
parent9dd0d8111fbb8015db75a38933aee1d45f9e64a3 (diff)
parente5a5b1bb7cfa2da3762f947003cba6a16fa242a1 (diff)
downloadfocaccia-qemu-2dc2f10de3e20854f8b7cbada9622d699a41f106.tar.gz
focaccia-qemu-2dc2f10de3e20854f8b7cbada9622d699a41f106.zip
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-january-25-2019' into staging
MIPS queue for January 25, 2019

# gpg: Signature made Fri 25 Jan 2019 13:25:57 GMT
# gpg:                using RSA key D4972A8967F75A65
# gpg: Good signature from "Aleksandar Markovic <amarkovic@wavecomp.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8526 FBF1 5DA3 811F 4A01  DD75 D497 2A89 67F7 5A65

* remotes/amarkovic/tags/mips-queue-january-25-2019:
  docs/qemu-cpu-models: Add MIPS/nanoMIPS QEMU supported CPU models
  qemu-doc: Add nanoMIPS ISA information
  tests: tcg: mips: Remove old directories
  tests: tcg: mips: Add two new Makefiles
  tests: tcg: mips: Move source files to new locations
  MAINTAINERS: Update MIPS sections
  target/mips: Add I6500 core configuration
  target/mips: nanoMIPS: Fix branch handling
  disas: nanoMIPS: Amend DSP instructions related comments
  target/mips: Extend gen_scwp() functionality to support EVA
  target/mips: Correct the second argument type of cpu_supports_isa()
  target/mips: nanoMIPS: Rename macros for extracting 3-bit-coded GPR numbers
  target/mips: nanoMIPS: Remove an unused macro
  target/mips: nanoMIPS: Remove duplicate macro definitions

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/tcg/mips/mips64-dsp/printf.c')
-rw-r--r--tests/tcg/mips/mips64-dsp/printf.c266
1 files changed, 0 insertions, 266 deletions
diff --git a/tests/tcg/mips/mips64-dsp/printf.c b/tests/tcg/mips/mips64-dsp/printf.c
deleted file mode 100644
index cf8676d390..0000000000
--- a/tests/tcg/mips/mips64-dsp/printf.c
+++ /dev/null
@@ -1,266 +0,0 @@
-
-typedef unsigned long va_list;
-
-#define ACC    4
-#define __read(source)                    \
-({ va_list __res;                    \
-    __asm__ __volatile__(                \
-        "move\t%0, " #source "\n\t"        \
-        : "=r" (__res));            \
-    __res;                        \
-})
-
-enum format_type {
-    FORMAT_TYPE_NONE,
-    FORMAT_TYPE_HEX,
-    FORMAT_TYPE_ULONG,
-    FORMAT_TYPE_FLOAT
-};
-
-struct printf_spec {
-    char    type;
-};
-
-static int format_decode(char *fmt, struct printf_spec *spec)
-{
-    char *start = fmt;
-
-    for (; *fmt ; ++fmt) {
-        if (*fmt == '%') {
-            break;
-        }
-    }
-
-    switch (*++fmt) {
-    case 'x':
-        spec->type = FORMAT_TYPE_HEX;
-        break;
-
-    case 'd':
-        spec->type = FORMAT_TYPE_ULONG;
-        break;
-
-    case 'f':
-        spec->type = FORMAT_TYPE_FLOAT;
-        break;
-
-    default:
-        spec->type = FORMAT_TYPE_NONE;
-    }
-
-    return ++fmt - start;
-}
-
-void *memcpy(void *dest, void *src, int n)
-{
-    int i;
-    char *s = src;
-    char *d = dest;
-
-    for (i = 0; i < n; i++) {
-        d[i] = s[i];
-    }
-    return dest;
-}
-
-char *number(char *buf, va_list num)
-{
-    int i;
-    char *str = buf;
-    static char digits[16] = "0123456789abcdef";
-    str = str + sizeof(num) * 2;
-
-    for (i = 0; i < sizeof(num) * 2; i++) {
-        *--str = digits[num & 15];
-        num >>= 4;
-    }
-
-    return buf + sizeof(num) * 2;
-}
-
-char *__number(char *buf, va_list num)
-{
-    int i;
-    va_list mm = num;
-    char *str = buf;
-
-    if (!num) {
-        *str++ = '0';
-        return str;
-    }
-
-    for (i = 0; mm; mm = mm/10, i++) {
-        /* Do nothing. */
-    }
-
-    str = str + i;
-
-    while (num) {
-        *--str = num % 10 + 48;
-        num = num / 10;
-    }
-
-    return str + i;
-}
-
-va_list modf(va_list args, va_list *integer, va_list *num)
-{
-    int i;
-    double dot_v = 0;
-    va_list E, DOT, DOT_V;
-
-    if (!args) {
-        return 0;
-    }
-
-    for (i = 0, args = args << 1 >> 1; i < 52; i++) {
-        if ((args >> i) & 0x1) {
-            break;
-        }
-    }
-
-    *integer = 0;
-
-    if ((args >> 56 != 0x3f) || (args >> 52 == 0x3ff)) {
-        E = (args >> 52) - 1023;
-        DOT = 52 - E - i;
-        DOT_V = args << (12 + E) >> (12 + E) >> i;
-        *integer = ((args << 12 >> 12) >> (i + DOT)) | (1 << E);
-    } else {
-        E = ~((args >> 52) - 1023) + 1;
-        DOT_V = args << 12 >> 12;
-
-        dot_v += 1.0 / (1 << E);
-
-        for (i = 1; i <= 16; i++) {
-            if ((DOT_V >> (52 - i)) & 0x1) {
-                dot_v += 1.0 / (1 << E + i);
-            }
-        }
-
-        for (i = 1, E = 0; i <= ACC; i++) {
-            dot_v *= 10;
-            if (!(va_list)dot_v) {
-                E++;
-            }
-    }
-
-    *num = E;
-
-    return dot_v;
-    }
-
-    if (args & 0xf) {
-        for (i = 1; i <= 16; i++) {
-            if ((DOT_V >> (DOT - i)) & 0x1) {
-                dot_v += 1.0 / (1 << i);
-            }
-        }
-
-        for (i = 1, E = 0; i <= ACC; i++) {
-            dot_v *= 10;
-            if (!(va_list)dot_v) {
-                E++;
-            }
-        }
-
-        *num = E;
-
-        return dot_v;
-    } else if (DOT) {
-        for (i = 1; i <= DOT; i++) {
-            if ((DOT_V >> (DOT - i)) & 0x1) {
-                dot_v += 1.0 / (1 << i);
-            }
-        }
-
-        for (i = 1; i <= ACC; i++) {
-            dot_v = dot_v * 10;
-        }
-
-    return dot_v;
-    }
-
-    return 0;
-}
-
-int vsnprintf(char *buf, int size, char *fmt, va_list args)
-{
-    char *str, *mm;
-    struct printf_spec spec = {0};
-
-    str = mm = buf;
-
-    while (*fmt) {
-        char *old_fmt = fmt;
-        int read = format_decode(fmt, &spec);
-
-        fmt += read;
-
-        switch (spec.type) {
-        case FORMAT_TYPE_NONE: {
-            memcpy(str, old_fmt, read);
-            str += read;
-            break;
-        }
-        case FORMAT_TYPE_HEX: {
-            memcpy(str, old_fmt, read);
-            str = number(str + read, args);
-            for (; *mm ; ++mm) {
-                if (*mm == '%') {
-                    *mm = '0';
-                break;
-                }
-            }
-        break;
-        }
-        case FORMAT_TYPE_ULONG: {
-            memcpy(str, old_fmt, read - 2);
-            str = __number(str + read - 2, args);
-            break;
-        }
-        case FORMAT_TYPE_FLOAT: {
-            va_list integer, dot_v, num;
-            dot_v = modf(args, &integer, &num);
-            memcpy(str, old_fmt, read - 2);
-            str += read - 2;
-            if ((args >> 63 & 0x1)) {
-                *str++ = '-';
-            }
-            str = __number(str, integer);
-            if (dot_v) {
-                *str++ = '.';
-                while (num--) {
-                    *str++ = '0';
-                }
-                str = __number(str, dot_v);
-            }
-            break;
-        }
-        }
-    }
-    *str = '\0';
-
-    return str - buf;
-}
-
-static void serial_out(char *str)
-{
-    while (*str) {
-        *(char *)0xffffffffb80003f8 = *str++;
-    }
-}
-
-int vprintf(char *fmt, va_list args)
-{
-    int printed_len = 0;
-    static char printf_buf[512];
-    printed_len = vsnprintf(printf_buf, sizeof(printf_buf), fmt, args);
-    serial_out(printf_buf);
-    return printed_len;
-}
-
-int printf(char *fmt, ...)
-{
-    return vprintf(fmt, __read($5));
-}