summaryrefslogtreecommitdiff
path: root/ports/risc-v64/gnu/example_build/erbium/board.c
blob: b801b55d48d30e42dc71ff7fa183d9838ffaf749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/***************************************************************************
 * Copyright (c) 2026 Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * AI Disclosure: This file was largely AI-generated by Claude Code (Opus 5.5).
 * The AI-generated portions may be considered public domain (CC0-1.0)
 * and not subject to the project's licence. The human contributor has
 * reviewed and verified that the code is correct.
 *
 * SPDX-License-Identifier: MIT and CC0-1.0
 **************************************************************************/

#include "plic.h"
#include "hwtimer.h"
#include "uart.h"
#include <stdint.h>
#include <stddef.h>

/* The example links without a C library; ThreadX needs memset.  */
void *memset(void *des, int c, size_t n)
{
    unsigned char *target = des;

    for (size_t i = 0; i < n; i++)
        target[i] = (unsigned char)c;
    return des;
}

int board_init(void)
{
    int ret;

    ret = plic_init();
    if (ret)
        return ret;

    ret = uart_init();
    if (ret)
        return ret;

    ret = hwtimer_init();
    if (ret)
        return ret;

    return 0;
}