summaryrefslogtreecommitdiff
path: root/ports/risc-v64/gnu/example_build/erbium/entry.S
blob: 201f986e412895c91f52b2bc8e705eb2ecf97d32 (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
50
/***************************************************************************
 * 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
 **************************************************************************/

/* Reset entry for the Erbium example.  Hart 0 sets up the global pointer,
   the system stack and .bss, then calls main().  Any other hart is parked.  */

    .section .text.entry, "ax", @progbits
    .align 2
    .global _start
    .extern main
    .extern _sysstack_end
    .extern _bss_start
    .extern _bss_end
_start:
    csrr    t0, mhartid
    bnez    t0, _park

.option push
.option norelax
    la      gp, __global_pointer$           // norelax keeps this load absolute
.option pop

    la      sp, _sysstack_end

    la      t0, _bss_start                  // .bss is 16-byte aligned in link.lds
    la      t1, _bss_end
_bss_clear:
    bgeu    t0, t1, _bss_done
    sd      zero, 0(t0)
    addi    t0, t0, 8
    j       _bss_clear
_bss_done:

    call    main

    /* The example never executes WFI; a parked hart spins.  */
_park:
    j       _park