HelenOS sources
This source file includes following definitions.
- cpu_spin_hint
- p2a
- pio_write_8
- pio_write_16
- pio_write_32
- pio_read_8
- pio_read_16
- pio_read_32
- psr_read
- iva_read
- iva_write
- ivr_read
- cr64_read
- itc_write
- itc_read
- itm_write
- itm_read
- itv_read
- itv_write
- eoi_write
- tpr_read
- tpr_write
- interrupts_disable
- interrupts_enable
- interrupts_restore
- interrupts_read
- interrupts_disabled
- pk_disable
- cpu_interruptible_sleep
#ifndef KERN_ia64_ASM_H_
#define KERN_ia64_ASM_H_
#include <config.h>
#include <typedefs.h>
#include <arch/register.h>
#include <arch/legacyio.h>
#include <trace.h>
#define IO_SPACE_BOUNDARY ((void *) (64 * 1024))
_NO_TRACE static inline void cpu_spin_hint(void)
{
}
_NO_TRACE static inline uintptr_t p2a(volatile void *p)
{
uintptr_t prt = (uintptr_t) p;
return legacyio_virt_base + (((prt >> 2) << 12) | (prt & 0xfff));
}
_NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
{
if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
*((ioport8_t *) p2a(port)) = v;
else
*port = v;
asm volatile (
"mf\n"
"mf.a\n"
::: "memory"
);
}
_NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
{
if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
*((ioport16_t *) p2a(port)) = v;
else
*port = v;
asm volatile (
"mf\n"
"mf.a\n"
::: "memory"
);
}
_NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
{
if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
*((ioport32_t *) p2a(port)) = v;
else
*port = v;
asm volatile (
"mf\n"
"mf.a\n"
::: "memory"
);
}
_NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
{
uint8_t v;
asm volatile (
"mf\n"
::: "memory"
);
if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
v = *((ioport8_t *) p2a(port));
else
v = *port;
asm volatile (
"mf.a\n"
::: "memory"
);
return v;
}
_NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
{
uint16_t v;
asm volatile (
"mf\n"
::: "memory"
);
if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
v = *((ioport16_t *) p2a(port));
else
v = *port;
asm volatile (
"mf.a\n"
::: "memory"
);
return v;
}
_NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
{
uint32_t v;
asm volatile (
"mf\n"
::: "memory"
);
if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
v = *((ioport32_t *) p2a(port));
else
v = *port;
asm volatile (
"mf.a\n"
::: "memory"
);
return v;
}
_NO_TRACE static inline uint64_t psr_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = psr\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t iva_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr.iva\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline void iva_write(uint64_t v)
{
asm volatile (
"mov cr.iva = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static inline uint64_t ivr_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr.ivr\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t cr64_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr64\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline void itc_write(uint64_t v)
{
asm volatile (
"mov ar.itc = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static inline uint64_t itc_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = ar.itc\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline void itm_write(uint64_t v)
{
asm volatile (
"mov cr.itm = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static inline uint64_t itm_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr.itm\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline uint64_t itv_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr.itv\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline void itv_write(uint64_t v)
{
asm volatile (
"mov cr.itv = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static inline void eoi_write(uint64_t v)
{
asm volatile (
"mov cr.eoi = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static inline uint64_t tpr_read(void)
{
uint64_t v;
asm volatile (
"mov %[value] = cr.tpr\n"
: [value] "=r" (v)
);
return v;
}
_NO_TRACE static inline void tpr_write(uint64_t v)
{
asm volatile (
"mov cr.tpr = %[value]\n"
:: [value] "r" (v)
);
}
_NO_TRACE static ipl_t interrupts_disable(void)
{
uint64_t v;
asm volatile (
"mov %[value] = psr\n"
"rsm %[mask]\n"
: [value] "=r" (v)
: [mask] "i" (PSR_I_MASK)
);
return (ipl_t) v;
}
_NO_TRACE static ipl_t interrupts_enable(void)
{
uint64_t v;
asm volatile (
"mov %[value] = psr\n"
"ssm %[mask]\n"
";;\n"
"srlz.d\n"
: [value] "=r" (v)
: [mask] "i" (PSR_I_MASK)
);
return (ipl_t) v;
}
_NO_TRACE static inline void interrupts_restore(ipl_t ipl)
{
if (ipl & PSR_I_MASK)
(void) interrupts_enable();
else
(void) interrupts_disable();
}
_NO_TRACE static inline ipl_t interrupts_read(void)
{
return (ipl_t) psr_read();
}
_NO_TRACE static inline bool interrupts_disabled(void)
{
return !(psr_read() & PSR_I_MASK);
}
_NO_TRACE static inline void pk_disable(void)
{
asm volatile (
"rsm %[mask]\n"
";;\n"
"srlz.d\n"
:: [mask] "i" (PSR_PK_MASK)
);
}
extern void cpu_halt(void) __attribute__((noreturn));
extern void cpu_sleep(void);
extern void asm_delay_loop(uint32_t t);
extern void switch_to_userspace(uintptr_t, uintptr_t, uintptr_t, uintptr_t,
uint64_t, uint64_t);
_NO_TRACE static inline void cpu_interruptible_sleep(void)
{
interrupts_enable();
cpu_sleep();
interrupts_disable();
}
#endif
HelenOS homepage, sources at GitHub