blob: e46b893ad66018ca07aaac6a8b9108f3d99e879c (
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
|
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Registers map and definitions for RISC-V cores
*/
#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H
/*
* This is the space required by both __irq_isr and __switch_task to store all
* of the caller and callee registers for each task context before switching.
*/
#ifdef CONFIG_FPU
/* additional space to save FP registers (fcsr, ft0-11, fa0-7, fs0-11) */
#define TASK_SCRATCHPAD_SIZE (62)
#else
#define TASK_SCRATCHPAD_SIZE (29)
#endif
#ifndef __ASSEMBLER__
#include <stdint.h>
/* write Exception Program Counter register */
static inline void set_mepc(uint32_t val)
{
asm volatile ("csrw mepc, %0" : : "r"(val));
}
/* read Exception Program Counter register */
static inline uint32_t get_mepc(void)
{
uint32_t ret;
asm volatile ("csrr %0, mepc" : "=r"(ret));
return ret;
}
/* read Trap cause register */
static inline uint32_t get_mcause(void)
{
uint32_t ret;
asm volatile ("csrr %0, mcause" : "=r"(ret));
return ret;
}
/* Generic CPU core initialization */
void cpu_init(void);
extern uint32_t ec_reset_lp;
extern uint32_t ira;
#endif
#endif /* __CROS_EC_CPU_H */
|