HelenOS sources
This source file includes following definitions.
- cpu_spin_hint
- pio_write_8
- pio_write_16
- pio_write_32
- pio_read_8
- pio_read_16
- pio_read_32
- pstate_read
- pstate_write
- tick_compare_read
- tick_compare_write
- stick_compare_read
- stick_compare_write
- tick_read
- tick_write
- fprs_read
- fprs_write
- softint_read
- softint_write
- clear_softint_write
- set_softint_write
- interrupts_enable
- interrupts_disable
- interrupts_restore
- interrupts_read
- interrupts_disabled
- ver_read
- tpc_read
- tl_read
- tba_read
- tba_write
- asi_u64_read
- asi_u64_write
- flushw
- nucleus_enter
- nucleus_leave
- cpu_interruptible_sleep
#ifndef KERN_sparc64_ASM_H_
#define KERN_sparc64_ASM_H_
#include <typedefs.h>
#include <align.h>
#include <arch/register.h>
#include <config.h>
#include <arch/stack.h>
#include <barrier.h>
#include <trace.h>
_NO_TRACE static inline void cpu_spin_hint(void)
{
}
_NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
{
*port = v;
memory_barrier();
}
_NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
{
*port = v;
memory_barrier();
}
_NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
{
*port = v;
memory_barrier();
}
_NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
{
uint8_t rv = *port;
memory_barrier();
return rv;
}
_NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
{
uint16_t rv = *port;
memory_barrier();
return rv;
}
_NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
{
uint32_t rv = *port;
memory_barrier();
return rv;
}
_NO_TRACE static inline uint64_t pstate_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%pstate, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void pstate_write(uint64_t v)
{
asm volatile (
"wrpr %[v], %[zero], %%pstate\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t tick_compare_read(void)
{
uint64_t v;
asm volatile (
"rd %%tick_cmpr, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void tick_compare_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%tick_cmpr\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t stick_compare_read(void)
{
uint64_t v;
asm volatile (
"rd %%asr25, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void stick_compare_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%asr25\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t tick_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%tick, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void tick_write(uint64_t v)
{
asm volatile (
"wrpr %[v], %[zero], %%tick\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t fprs_read(void)
{
uint64_t v;
asm volatile (
"rd %%fprs, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void fprs_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%fprs\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t softint_read(void)
{
uint64_t v;
asm volatile (
"rd %%softint, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void softint_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%softint\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline void clear_softint_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%clear_softint\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline void set_softint_write(uint64_t v)
{
asm volatile (
"wr %[v], %[zero], %%set_softint\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline ipl_t interrupts_enable(void)
{
pstate_reg_t pstate;
uint64_t value = pstate_read();
pstate.value = value;
pstate.ie = true;
pstate_write(pstate.value);
return (ipl_t) value;
}
_NO_TRACE static inline ipl_t interrupts_disable(void)
{
pstate_reg_t pstate;
uint64_t value = pstate_read();
pstate.value = value;
pstate.ie = false;
pstate_write(pstate.value);
return (ipl_t) value;
}
_NO_TRACE static inline void interrupts_restore(ipl_t ipl)
{
pstate_reg_t pstate;
pstate.value = pstate_read();
pstate.ie = ((pstate_reg_t)(uint64_t) ipl).ie;
pstate_write(pstate.value);
}
_NO_TRACE static inline ipl_t interrupts_read(void)
{
return (ipl_t) pstate_read();
}
_NO_TRACE static inline bool interrupts_disabled(void)
{
pstate_reg_t pstate;
pstate.value = pstate_read();
return !pstate.ie;
}
_NO_TRACE static inline uint64_t ver_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%ver, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t tpc_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%tpc, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t tl_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%tl, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t tba_read(void)
{
uint64_t v;
asm volatile (
"rdpr %%tba, %[v]\n"
: [v] "=r" (v)
);
return v;
}
_NO_TRACE static inline void tba_write(uint64_t v)
{
asm volatile (
"wrpr %[v], %[zero], %%tba\n"
:: [v] "r" (v),
[zero] "i" (0)
);
}
_NO_TRACE static inline uint64_t asi_u64_read(asi_t asi, uintptr_t va)
{
uint64_t v;
asm volatile (
"ldxa [%[va]] %[asi], %[v]\n"
: [v] "=r" (v)
: [va] "r" (va),
[asi] "i" ((unsigned int) asi)
);
return v;
}
_NO_TRACE static inline void asi_u64_write(asi_t asi, uintptr_t va, uint64_t v)
{
asm volatile (
"stxa %[v], [%[va]] %[asi]\n"
:: [v] "r" (v),
[va] "r" (va),
[asi] "i" ((unsigned int) asi)
: "memory"
);
}
_NO_TRACE static inline void flushw(void)
{
asm volatile ("flushw\n");
}
_NO_TRACE static inline void nucleus_enter(void)
{
asm volatile ("wrpr %g0, 1, %tl\n");
}
_NO_TRACE static inline void nucleus_leave(void)
{
asm volatile ("wrpr %g0, %g0, %tl\n");
}
extern void cpu_halt(void) __attribute__((noreturn));
extern void cpu_sleep(void);
extern void asm_delay_loop(const uint32_t usec);
extern uint64_t read_from_ag_g6(void);
extern uint64_t read_from_ag_g7(void);
extern void write_to_ag_g6(uint64_t val);
extern void write_to_ag_g7(uint64_t val);
extern void write_to_ig_g6(uint64_t val);
extern void switch_to_userspace(uint64_t pc, uint64_t sp, uint64_t uarg);
_NO_TRACE static inline void cpu_interruptible_sleep(void)
{
interrupts_enable();
cpu_sleep();
interrupts_disable();
}
#endif
HelenOS homepage, sources at GitHub