Blame rse.h

Packit bf408e
#ifndef _ASM_IA64_RSE_H
Packit bf408e
#define _ASM_IA64_RSE_H
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * Copyright (C) 1998, 1999 Hewlett-Packard Co
Packit bf408e
 * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com>
Packit bf408e
 */
Packit bf408e
Packit bf408e
/*
Packit bf408e
 *  rse.h
Packit bf408e
 *
Packit bf408e
 *  Copyright (C) 2002, 2003, 2004, 2005 David Anderson
Packit bf408e
 *  Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. All rights reserved.
Packit bf408e
 *
Packit bf408e
 *  This program is free software; you can redistribute it and/or modify
Packit bf408e
 *  it under the terms of the GNU General Public License as published by
Packit bf408e
 *  the Free Software Foundation; either version 2 of the License, or
Packit bf408e
 *  (at your option) any later version.
Packit bf408e
 *
Packit bf408e
 *  This program is distributed in the hope that it will be useful,
Packit bf408e
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit bf408e
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit bf408e
 *  GNU General Public License for more details.
Packit bf408e
 *
Packit bf408e
 *  Adapted from:
Packit bf408e
 *
Packit bf408e
 *    include/asm-ia64/rse.h  (2.4.9-e.3)
Packit bf408e
 */
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * Register stack engine related helper functions.  This file may be
Packit bf408e
 * used in applications, so be careful about the name-space and give
Packit bf408e
 * some consideration to non-GNU C compilers (though __inline__ is
Packit bf408e
 * fine).
Packit bf408e
 */
Packit bf408e
Packit bf408e
static __inline__ unsigned long
Packit bf408e
ia64_rse_slot_num (unsigned long *addr)
Packit bf408e
{
Packit bf408e
	return (((unsigned long) addr) >> 3) & 0x3f;
Packit bf408e
}
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * Return TRUE if ADDR is the address of an RNAT slot.
Packit bf408e
 */
Packit bf408e
static __inline__ unsigned long
Packit bf408e
ia64_rse_is_rnat_slot (unsigned long *addr)
Packit bf408e
{
Packit bf408e
	return ia64_rse_slot_num(addr) == 0x3f;
Packit bf408e
}
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * Returns the address of the RNAT slot that covers the slot at
Packit bf408e
 * address SLOT_ADDR.
Packit bf408e
 */
Packit bf408e
static __inline__ unsigned long *
Packit bf408e
ia64_rse_rnat_addr (unsigned long *slot_addr)
Packit bf408e
{
Packit bf408e
	return (unsigned long *) ((unsigned long) slot_addr | (0x3f << 3));
Packit bf408e
}
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * Calcuate the number of registers in the dirty partition starting at
Packit bf408e
 * BSPSTORE with a size of DIRTY bytes.  This isn't simply DIRTY
Packit bf408e
 * divided by eight because the 64th slot is used to store ar.rnat.
Packit bf408e
 */
Packit bf408e
static __inline__ unsigned long
Packit bf408e
ia64_rse_num_regs (unsigned long *bspstore, unsigned long *bsp)
Packit bf408e
{
Packit bf408e
	unsigned long slots = (bsp - bspstore);
Packit bf408e
Packit bf408e
	return slots - (ia64_rse_slot_num(bspstore) + slots)/0x40;
Packit bf408e
}
Packit bf408e
Packit bf408e
/*
Packit bf408e
 * The inverse of the above: given bspstore and the number of
Packit bf408e
 * registers, calculate ar.bsp.
Packit bf408e
 */
Packit bf408e
static __inline__ unsigned long *
Packit bf408e
ia64_rse_skip_regs (unsigned long *addr, long num_regs)
Packit bf408e
{
Packit bf408e
	long delta = ia64_rse_slot_num(addr) + num_regs;
Packit bf408e
Packit bf408e
	if (num_regs < 0)
Packit bf408e
		delta -= 0x3e;
Packit bf408e
	return addr + num_regs + delta/0x3f;
Packit bf408e
}
Packit bf408e
Packit bf408e
#endif /* _ASM_IA64_RSE_H */