blob: 6f4c0859c182fc63eb818c215b5d49fbd6ca1293 (
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
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* Copyright (c) 2026, Linumiz
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2026-11-06 Parthiban first version
*/
#include <rthw.h>
#include <rtthread.h>
#include "rh850_cpu.h"
#include "rh850_core.h"
#ifdef RT_USING_FPU
#define THREAD_PSW (RH850_PSW_EBV | RH850_PSW_CU0)
#else
#define THREAD_PSW RH850_PSW_EBV
#endif
volatile rt_ubase_t rt_interrupt_from_thread;
volatile rt_ubase_t rt_interrupt_to_thread;
volatile rt_ubase_t rt_thread_switch_interrupt_flag;
rt_uint32_t rh850_irq_nest;
rt_ubase_t rh850_thread_sp;
rt_weak int rt_hw_cpu_id(void)
{
return 0;
}
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint8_t *stack_addr, void *texit)
{
struct rt_hw_stack_frame *frame;
rt_ubase_t stk;
stk = RT_ALIGN_DOWN((rt_ubase_t)stack_addr + sizeof(rt_ubase_t), 8);
frame = (struct rt_hw_stack_frame *)(stk - sizeof(*frame));
rt_memset(frame, 0, sizeof(*frame));
frame->eipc = (rt_ubase_t)tentry;
frame->eipsw = THREAD_PSW;
#ifdef RT_USING_FPU
frame->fpsr = RH850_FPSR_FS;
#endif
frame->FRAME_GPR(6) = (rt_ubase_t)parameter;
frame->FRAME_GPR(31) = (rt_ubase_t)texit;
return (rt_uint8_t *)frame;
}
void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to,
rt_thread_t from_thread,
rt_thread_t to_thread)
{
RT_UNUSED(from_thread);
RT_UNUSED(to_thread);
if (rt_thread_switch_interrupt_flag == 0)
{
rt_interrupt_from_thread = from;
rt_thread_switch_interrupt_flag = 1;
}
rt_interrupt_to_thread = to;
}
void rh850_irq_handle(rt_uint32_t eiic)
{
rt_interrupt_enter();
rh850_ei();
rt_hw_interrupt_dispatch(eiic);
rh850_di();
rt_interrupt_leave();
}
|