Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arch.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Antony Pavlov <[email protected]>
3 *
4 * based on include/arch/sparc/arch.h
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#ifndef ZEPHYR_INCLUDE_ARCH_MIPS_ARCH_H_
10#define ZEPHYR_INCLUDE_ARCH_MIPS_ARCH_H_
11
17
18#include <zephyr/irq.h>
19#include <zephyr/sw_isr_table.h>
20#include <zephyr/devicetree.h>
21#include <mips/mipsregs.h>
22
23#define ARCH_STACK_PTR_ALIGN 16
24
25#define OP_LOADREG lw
26#define OP_STOREREG sw
27
28#define CP0_STATUS_DEF_RESTORE (ST0_EXL | ST0_IE)
29
30#ifndef _ASMLANGUAGE
31#include <zephyr/sys/util.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define STACK_ROUND_UP(x) ROUND_UP(x, ARCH_STACK_PTR_ALIGN)
38
39void arch_irq_enable(unsigned int irq);
40void arch_irq_disable(unsigned int irq);
41int arch_irq_is_enabled(unsigned int irq);
42void z_irq_spurious(const void *unused);
43
58#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
59 { \
60 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
61 }
62
63static ALWAYS_INLINE unsigned int arch_irq_lock(void)
64{
65 uint32_t status = read_c0_status();
66
67 if (status & ST0_IE) {
68 write_c0_status(status & ~ST0_IE);
69 return 1;
70 }
71 return 0;
72}
73
74static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
75{
76 uint32_t status = read_c0_status();
77
78 if (key) {
79 status |= ST0_IE;
80 } else {
81 status &= ~ST0_IE;
82 }
83
84 write_c0_status(status);
85}
86
87static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
88{
89 return key != 0;
90}
91
92static ALWAYS_INLINE void arch_nop(void)
93{
94 __asm__ volatile ("nop");
95}
96
98
99static inline uint32_t arch_k_cycle_get_32(void)
100{
101 return sys_clock_cycle_get_32();
102}
103
105
106static inline uint64_t arch_k_cycle_get_64(void)
107{
108 return sys_clock_cycle_get_64();
109}
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* _ASMLANGUAGE */
116
117#endif /* ZEPHYR_INCLUDE_ARCH_MIPS_ARCH_H_ */
static ALWAYS_INLINE void arch_nop(void)
Definition: arch.h:348
Per-arch thread definition.
#define arch_irq_disable(irq)
Definition: irq.h:107
#define arch_irq_enable(irq)
Definition: irq.h:106
#define arch_irq_is_enabled(irq)
Definition: irq.h:109
#define ALWAYS_INLINE
Definition: common.h:129
Devicetree main header.
Public interface for configuring interrupts.
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition: arch.h:63
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition: arch.h:74
uint64_t sys_clock_cycle_get_64(void)
uint32_t sys_clock_cycle_get_32(void)
static uint32_t arch_k_cycle_get_32(void)
Definition: arch.h:99
static uint64_t arch_k_cycle_get_64(void)
Definition: arch.h:106
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition: arch.h:87
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
Software-managed ISR table.
Misc utilities.