Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
arch.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019-2020 Cobham Gaisler AB
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14#ifndef ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_
15#define ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_
16
17#include <arch/sparc/thread.h>
18#include <arch/sparc/sparc.h>
20#include <arch/common/sys_io.h>
21#include <arch/common/ffs.h>
22
23#include <irq.h>
24#include <sw_isr_table.h>
25#include <soc.h>
26#include <devicetree.h>
27
28/* stacks, for SPARC architecture stack shall be 8byte-aligned */
29#define ARCH_STACK_PTR_ALIGN 8
30
31/*
32 * Software trap numbers.
33 * Assembly usage: "ta SPARC_SW_TRAP_<TYPE>"
34 */
35#define SPARC_SW_TRAP_FLUSH_WINDOWS 0x03
36#define SPARC_SW_TRAP_SET_PIL 0x09
37#define SPARC_SW_TRAP_EXCEPT 0x0F
38
39#ifndef _ASMLANGUAGE
40#include <sys/util.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#define STACK_ROUND_UP(x) ROUND_UP(x, ARCH_STACK_PTR_ALIGN)
47
48/*
49 * SOC specific function to translate from processor interrupt request level
50 * (1..15) to logical interrupt source number. For example by probing the
51 * interrupt controller.
52 */
53int z_sparc_int_get_source(int irl);
54void z_irq_spurious(const void *unused);
55
56
57#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
58 { \
59 Z_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
60 }
61
62
63static ALWAYS_INLINE unsigned int z_sparc_set_pil_inline(unsigned int newpil)
64{
65 register uint32_t oldpil __asm__ ("o0") = newpil;
66
67 __asm__ volatile (
68 "ta %1\nnop\n" :
69 "=r" (oldpil) :
70 "i" (SPARC_SW_TRAP_SET_PIL), "r" (oldpil) :
71 "memory"
72 );
73 return oldpil;
74}
75
76static ALWAYS_INLINE unsigned int arch_irq_lock(void)
77{
78 return z_sparc_set_pil_inline(15);
79}
80
81static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
82{
83 z_sparc_set_pil_inline(key);
84}
85
86static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
87{
88 return key == 0;
89}
90
91static ALWAYS_INLINE void arch_nop(void)
92{
93 __asm__ volatile ("nop");
94}
95
97
98static inline uint32_t arch_k_cycle_get_32(void)
99{
100 return sys_clock_cycle_get_32();
101}
102
103
104struct __esf {
105 uint32_t out[8];
106 uint32_t global[8];
107 uint32_t psr;
108 uint32_t pc;
109 uint32_t npc;
110 uint32_t wim;
111 uint32_t tbr;
112 uint32_t y;
113};
114
115typedef struct __esf z_arch_esf_t;
116
117#define ARCH_EXCEPT(reason_p) \
118do { \
119 register uint32_t _g1 __asm__("g1") = reason_p; \
120 \
121 __asm__ volatile ( \
122 "ta %[vector]\n\t" \
123 : \
124 : [vector] "i" (SPARC_SW_TRAP_EXCEPT), "r" (_g1) \
125 : "memory" \
126 ); \
127 CODE_UNREACHABLE; \
128} while (false)
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif /*_ASMLANGUAGE */
135
136#endif /* ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_ */
Per-arch thread definition.
#define ALWAYS_INLINE
Definition: common.h:116
Devicetree main header.
uint32_t sys_clock_cycle_get_32(void)
static ALWAYS_INLINE void arch_nop(void)
Definition: arch.h:91
#define SPARC_SW_TRAP_SET_PIL
Definition: arch.h:36
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition: arch.h:76
static ALWAYS_INLINE void arch_irq_unlock(unsigned int key)
Definition: arch.h:81
static uint32_t arch_k_cycle_get_32(void)
Definition: arch.h:98
static ALWAYS_INLINE bool arch_irq_unlocked(unsigned int key)
Definition: arch.h:86
static k_spinlock_key_t key
Definition: spinlock_error_case.c:14
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
Software-managed ISR table.
Misc utilities.