1/*
2 * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <camkes.h>
8#include <stdio.h>
9
10/* Print a string starting at (0,0) in our region. */
11static void print(const char *msg) {
12    int i = 0;
13    while (*msg != '\0') {
14        if (d_put_char(i++, 0, *msg++) != 0) {
15            /* Failed. Potentially the string was too wide for our region. */
16            return;
17        }
18    }
19}
20
21int run(void) {
22    /* XXX: This is a hack to make sure client 1 executes after client 2. If
23     * they execute in parallel there is a race condition and, with no lock on
24     * d_put_char, the escape characters corrupt the terminal.
25     */
26    if (ID == 1) {
27        for (int i = 0; i < 10000; ++i) {
28            asm volatile ("");
29        }
30    }
31
32    /* MESSAGE comes as an attribute. */
33    print(MESSAGE);
34    return 0;
35}
36