summaryrefslogtreecommitdiff
path: root/libcpu/rh850/common/rh850_cpu.h
blob: 546204b2c00fdf68cb6f8dec4bfd9884ad85b4b3 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2026, Linumiz
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2026-11-06     Parthiban    first version
 */

#ifndef __RH850_CPU_H__
#define __RH850_CPU_H__

#include <rtdef.h>
#include "rh850_sysreg.h"

#define rh850_stsr_(id, sel)                                                \
    ({                                                                      \
        rt_uint32_t v_;                                                     \
        __asm__ volatile("stsr %1, %0, %2" : "=r"(v_) : "i"(id), "i"(sel)); \
        v_;                                                                 \
    })
#define RH850_STSR(sr) rh850_stsr_(sr)

rt_inline void rh850_di(void)
{
    __asm__ volatile("di" ::: "memory");
}

rt_inline void rh850_ei(void)
{
    __asm__ volatile("ei" ::: "memory");
}

rt_inline void rh850_syncp(void)
{
    __asm__ volatile("syncp" ::: "memory");
}

rt_inline void rh850_halt(void)
{
    __asm__ volatile("halt" ::: "memory");
}

/* Layout of SAVE_CONTEXT in context_gcc.S and of the fault entries */
struct rt_hw_stack_frame
{
    rt_ubase_t eipc;
    rt_ubase_t eipsw;
    rt_ubase_t fpsr;
    rt_ubase_t fpepc;
    rt_ubase_t r31_r4[28];
    rt_ubase_t r2;
    rt_ubase_t r1;
};

#define FRAME_GPR(n) r31_r4[31 - (n)]

extern volatile rt_ubase_t rt_interrupt_from_thread;
extern volatile rt_ubase_t rt_interrupt_to_thread;
extern volatile rt_ubase_t rt_thread_switch_interrupt_flag;

void rt_hw_interrupt_dispatch(rt_uint32_t eiic);

#endif