summaryrefslogtreecommitdiff
path: root/bsp/qemu-virt64-riscv/applications/test/test_vector/vector_context_gcc.S
blob: 42e60f323df1a06333e5cd78af3ee2b8f3e1da79 (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
/*
 * Copyright (c) 2006-2026, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef __ASSEMBLY__
#define __ASSEMBLY__
#endif
#define REGBYTES 8
#define STORE sd
#define LOAD ld

#include <rtconfig.h>
#include "vector_encoding.h"
#include "rvv_context.h"

    .text
    .align 2

    /* Test-only helpers; SAVE_VECTOR must not change the caller's controls. */
    .globl rt_hw_vector_ctx_save
    .type rt_hw_vector_ctx_save, @function
rt_hw_vector_ctx_save:
    csrrci  a3, sstatus, 2
    li      t0, SSTATUS_VS
    csrs    sstatus, t0
    SAVE_VECTOR a0
    RESTORE_VECTOR a0
    csrw    sstatus, a3
    ret
    .size rt_hw_vector_ctx_save, . - rt_hw_vector_ctx_save

    .globl rt_hw_vector_ctx_restore
    .type rt_hw_vector_ctx_restore, @function
rt_hw_vector_ctx_restore:
    csrrci  a3, sstatus, 2
    li      t0, SSTATUS_VS
    csrs    sstatus, t0
    RESTORE_VECTOR a0
    csrw    sstatus, a3
    ret
    .size rt_hw_vector_ctx_restore, . - rt_hw_vector_ctx_restore