2000-09-29 13:46:07 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Doug Rabson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MACHINE_CPUFUNC_H_
|
|
|
|
#define _MACHINE_CPUFUNC_H_
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2001-09-15 12:30:56 +00:00
|
|
|
#include <machine/ia64_cpu.h>
|
2002-05-19 04:42:19 +00:00
|
|
|
#include <machine/vmparam.h>
|
2000-09-29 13:46:07 +00:00
|
|
|
|
2005-03-02 21:33:29 +00:00
|
|
|
#ifndef _SYS_CDEFS_H_
|
|
|
|
#error this file needs sys/cdefs.h as a prerequisite
|
|
|
|
#endif
|
|
|
|
|
2002-03-27 05:39:23 +00:00
|
|
|
struct thread;
|
2001-12-18 00:27:18 +00:00
|
|
|
|
2004-03-21 01:41:29 +00:00
|
|
|
#define IA64_FIXED_BREAK 0x84B5D
|
|
|
|
|
2005-03-02 21:33:29 +00:00
|
|
|
#ifdef __GNUCLIKE_ASM
|
2000-09-29 13:46:07 +00:00
|
|
|
|
|
|
|
static __inline void
|
|
|
|
breakpoint(void)
|
|
|
|
{
|
2004-03-21 01:41:29 +00:00
|
|
|
__asm __volatile("break.m %0" :: "i"(IA64_FIXED_BREAK));
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2004-01-13 15:30:36 +00:00
|
|
|
#define HAVE_INLINE_FFS
|
2004-07-30 07:56:53 +00:00
|
|
|
#define ffs(x) __builtin_ffs(x)
|
2003-12-10 22:51:40 +00:00
|
|
|
|
2003-04-29 09:50:03 +00:00
|
|
|
#define __MEMIO_ADDR(x) (__volatile void*)(IA64_PHYS_TO_RR6(x))
|
2007-06-10 16:53:01 +00:00
|
|
|
extern __volatile void *ia64_ioport_address(u_int);
|
|
|
|
#define __PIO_ADDR(x) ia64_ioport_address(x)
|
2001-09-15 12:30:56 +00:00
|
|
|
|
2003-04-29 09:50:03 +00:00
|
|
|
/*
|
|
|
|
* I/O port reads with ia32 semantics.
|
|
|
|
*/
|
|
|
|
static __inline uint8_t
|
|
|
|
inb(unsigned int port)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
__volatile uint8_t *p;
|
|
|
|
uint8_t v;
|
|
|
|
p = __PIO_ADDR(port);
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
v = *p;
|
|
|
|
ia64_mf_a();
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
return (v);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2003-04-29 09:50:03 +00:00
|
|
|
static __inline uint16_t
|
|
|
|
inw(unsigned int port)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
__volatile uint16_t *p;
|
|
|
|
uint16_t v;
|
|
|
|
p = __PIO_ADDR(port);
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
v = *p;
|
|
|
|
ia64_mf_a();
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
return (v);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2003-04-29 09:50:03 +00:00
|
|
|
static __inline uint32_t
|
|
|
|
inl(unsigned int port)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
volatile uint32_t *p;
|
|
|
|
uint32_t v;
|
|
|
|
p = __PIO_ADDR(port);
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
v = *p;
|
|
|
|
ia64_mf_a();
|
2001-09-15 12:30:56 +00:00
|
|
|
ia64_mf();
|
2003-04-29 09:50:03 +00:00
|
|
|
return (v);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
insb(unsigned int port, void *addr, size_t count)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
uint8_t *buf = addr;
|
2000-09-29 13:46:07 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
*buf++ = inb(port);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
insw(unsigned int port, void *addr, size_t count)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
uint16_t *buf = addr;
|
2000-09-29 13:46:07 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
*buf++ = inw(port);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
insl(unsigned int port, void *addr, size_t count)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
uint32_t *buf = addr;
|
2000-09-29 13:46:07 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
*buf++ = inl(port);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outb(unsigned int port, uint8_t data)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
volatile uint8_t *p;
|
|
|
|
p = __PIO_ADDR(port);
|
|
|
|
ia64_mf();
|
2001-09-22 19:51:18 +00:00
|
|
|
*p = data;
|
2003-04-29 09:50:03 +00:00
|
|
|
ia64_mf_a();
|
2001-09-22 19:51:18 +00:00
|
|
|
ia64_mf();
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outw(unsigned int port, uint16_t data)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
volatile uint16_t *p;
|
|
|
|
p = __PIO_ADDR(port);
|
|
|
|
ia64_mf();
|
2001-09-22 19:51:18 +00:00
|
|
|
*p = data;
|
2003-04-29 09:50:03 +00:00
|
|
|
ia64_mf_a();
|
2001-09-22 19:51:18 +00:00
|
|
|
ia64_mf();
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outl(unsigned int port, uint32_t data)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
volatile uint32_t *p;
|
|
|
|
p = __PIO_ADDR(port);
|
|
|
|
ia64_mf();
|
2001-09-22 19:51:18 +00:00
|
|
|
*p = data;
|
2003-04-29 09:50:03 +00:00
|
|
|
ia64_mf_a();
|
2001-09-22 19:51:18 +00:00
|
|
|
ia64_mf();
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2001-10-06 09:31:43 +00:00
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outsb(unsigned int port, const void *addr, size_t count)
|
2001-10-06 09:31:43 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
const uint8_t *buf = addr;
|
2001-10-06 09:31:43 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
outb(port, *buf++);
|
2001-10-06 09:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outsw(unsigned int port, const void *addr, size_t count)
|
2001-10-06 09:31:43 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
const uint16_t *buf = addr;
|
2001-10-06 09:31:43 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
outw(port, *buf++);
|
2001-10-06 09:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-04-29 09:50:03 +00:00
|
|
|
outsl(unsigned int port, const void *addr, size_t count)
|
2001-10-06 09:31:43 +00:00
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
const uint32_t *buf = addr;
|
2001-10-06 09:31:43 +00:00
|
|
|
while (count--)
|
2003-04-29 09:50:03 +00:00
|
|
|
outl(port, *buf++);
|
2001-10-06 09:31:43 +00:00
|
|
|
}
|
|
|
|
|
2000-09-29 13:46:07 +00:00
|
|
|
static __inline void
|
|
|
|
disable_intr(void)
|
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
__asm __volatile ("rsm psr.i");
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
enable_intr(void)
|
|
|
|
{
|
2003-04-29 09:50:03 +00:00
|
|
|
__asm __volatile ("ssm psr.i;; srlz.d");
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 09:50:11 +00:00
|
|
|
static __inline register_t
|
2002-03-20 10:00:05 +00:00
|
|
|
intr_disable(void)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2002-03-21 09:50:11 +00:00
|
|
|
register_t psr;
|
2003-04-29 09:50:03 +00:00
|
|
|
__asm __volatile ("mov %0=psr;;" : "=r"(psr));
|
2001-03-28 02:31:54 +00:00
|
|
|
disable_intr();
|
2003-05-24 21:44:24 +00:00
|
|
|
return ((psr & IA64_PSR_I) ? 1 : 0);
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2003-05-24 21:44:24 +00:00
|
|
|
intr_restore(register_t ie)
|
2000-09-29 13:46:07 +00:00
|
|
|
{
|
2003-05-24 21:44:24 +00:00
|
|
|
if (ie)
|
|
|
|
enable_intr();
|
2000-09-29 13:46:07 +00:00
|
|
|
}
|
|
|
|
|
2005-03-02 21:33:29 +00:00
|
|
|
#endif /* __GNUCLIKE_ASM */
|
|
|
|
|
2000-09-29 13:46:07 +00:00
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
|
|
|
#endif /* !_MACHINE_CPUFUNC_H_ */
|