summaryrefslogtreecommitdiff
path: root/core/nds32/cpu.h
blob: 3bd5a93efce1eb6b58701a85d39b9d8266a0d153 (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
/* Copyright 2013 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 Andes cores
 */

#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H

/*
 * This is the space required by both irq_x_ and __switch_task to store all
 * of the caller and callee registers for each task context before switching.
 */
#define TASK_SCRATCHPAD_SIZE (18)

/* Process Status Word bits */
#define PSW_GIE		BIT(0) /* Global Interrupt Enable */
#define PSW_INTL_SHIFT	1        /* Interrupt Stack Level */
#define PSW_INTL_MASK	(0x3 << PSW_INTL_SHIFT)

#ifndef __ASSEMBLER__

#include <stdint.h>

/* write Process Status Word privileged register */
static inline void set_psw(uint32_t val)
{
	asm volatile ("mtsr %0, $PSW" : : "r"(val));
}

/* read Process Status Word privileged register */
static inline uint32_t get_psw(void)
{
	uint32_t ret;
	asm volatile ("mfsr %0, $PSW" : "=r"(ret));
	return ret;
}

/* write Interruption Program Counter privileged register */
static inline void set_ipc(uint32_t val)
{
	asm volatile ("mtsr %0, $IPC" : : "r"(val));
}

/* read Interruption Program Counter privileged register */
static inline uint32_t get_ipc(void)
{
	uint32_t ret;
	asm volatile ("mfsr %0, $IPC" : "=r"(ret));
	return ret;
}

/* read Interruption Type privileged register */
static inline uint32_t get_itype(void)
{
	uint32_t ret;
	asm volatile ("mfsr %0, $ITYPE" : "=r"(ret));
	return ret;
}

/* Generic CPU core initialization */
void cpu_init(void);

extern uint32_t ilp;
extern uint32_t ec_reset_lp;

#endif /* !__ASSEMBLER__ */

#endif /* __CROS_EC_CPU_H */