HelenOS sources
This source file includes following definitions.
- cpu_spin_hint
- msr_read
- msr_write
- sr_set
- sr_get
- sdr1_get
- interrupts_enable
- interrupts_disable
- interrupts_restore
- interrupts_read
- interrupts_disabled
- cpu_interruptible_sleep
- pio_write_8
- pio_write_16
- pio_write_32
- pio_read_8
- pio_read_16
- pio_read_32
#ifndef KERN_ppc32_ASM_H_
#define KERN_ppc32_ASM_H_
#include <typedefs.h>
#include <config.h>
#include <arch/msr.h>
#include <arch/mm/asid.h>
#include <trace.h>
_NO_TRACE static inline void cpu_spin_hint(void)
{
}
_NO_TRACE static inline uint32_t msr_read(void)
{
uint32_t msr;
asm volatile (
"mfmsr %[msr]\n"
: [msr] "=r" (msr)
);
return msr;
}
_NO_TRACE static inline void msr_write(uint32_t msr)
{
asm volatile (
"mtmsr %[msr]\n"
"isync\n"
:: [msr] "r" (msr)
);
}
_NO_TRACE static inline void sr_set(uint32_t flags, asid_t asid, uint32_t sr)
{
asm volatile (
"mtsrin %[value], %[sr]\n"
"sync\n"
"isync\n"
:: [value] "r" ((flags << 16) + (asid << 4) + sr),
[sr] "r" (sr << 28)
);
}
_NO_TRACE static inline uint32_t sr_get(uint32_t vaddr)
{
uint32_t vsid;
asm volatile (
"mfsrin %[vsid], %[vaddr]\n"
: [vsid] "=r" (vsid)
: [vaddr] "r" (vaddr)
);
return vsid;
}
_NO_TRACE static inline uint32_t sdr1_get(void)
{
uint32_t sdr1;
asm volatile (
"mfsdr1 %[sdr1]\n"
: [sdr1] "=r" (sdr1)
);
return sdr1;
}
_NO_TRACE static inline ipl_t interrupts_enable(void)
{
ipl_t ipl = msr_read();
msr_write(ipl | MSR_EE);
return ipl;
}
_NO_TRACE static inline ipl_t interrupts_disable(void)
{
ipl_t ipl = msr_read();
msr_write(ipl & (~MSR_EE));
return ipl;
}
_NO_TRACE static inline void interrupts_restore(ipl_t ipl)
{
msr_write((msr_read() & (~MSR_EE)) | (ipl & MSR_EE));
}
_NO_TRACE static inline ipl_t interrupts_read(void)
{
return msr_read();
}
_NO_TRACE static inline bool interrupts_disabled(void)
{
return ((msr_read() & MSR_EE) == 0);
}
_NO_TRACE static inline void cpu_interruptible_sleep(void)
{
interrupts_enable();
interrupts_disable();
}
_NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
{
*port = v;
}
_NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
{
*port = v;
}
_NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
{
*port = v;
}
_NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
{
return *port;
}
_NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
{
return *port;
}
_NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
{
return *port;
}
extern void cpu_halt(void) __attribute__((noreturn));
extern void asm_delay_loop(uint32_t t);
extern void userspace_asm(uintptr_t uspace_uarg, uintptr_t stack, uintptr_t entry);
#endif
HelenOS homepage, sources at GitHub