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) 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
22
23#include <zephyr/irq.h>
24#include <zephyr/sw_isr_table.h>
25#include <soc.h>
26#include <zephyr/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 <zephyr/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
104
105static inline uint64_t arch_k_cycle_get_64(void)
106{
107 return sys_clock_cycle_get_64();
108}
109
110struct __esf {
111 uint32_t out[8];
112 uint32_t global[8];
113 uint32_t psr;
114 uint32_t pc;
115 uint32_t npc;
116 uint32_t wim;
117 uint32_t tbr;
118 uint32_t y;
119};
120
121typedef struct __esf z_arch_esf_t;
122
123#define ARCH_EXCEPT(reason_p) \
124do { \
125 register uint32_t _g1 __asm__("g1") = reason_p; \
126 \
127 __asm__ volatile ( \
128 "ta %[vector]\n\t" \
129 : \
130 : [vector] "i" (SPARC_SW_TRAP_EXCEPT), "r" (_g1) \
131 : "memory" \
132 ); \
133 CODE_UNREACHABLE; \
134} while (false)
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif /*_ASMLANGUAGE */
141
142#endif /* ZEPHYR_INCLUDE_ARCH_SPARC_ARCH_H_ */
static ALWAYS_INLINE void arch_nop(void)
Definition: arch.h:348
Per-arch thread definition.
#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
#define SPARC_SW_TRAP_SET_PIL
Definition: arch.h:36
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
Software-managed ISR table.
Misc utilities.