/* @(#) $Revision: 1.40.98.4 $ */    
/* $Source: /usr/local/kcs/sys.DAVIS_800/machine/RCS/param.h,v $
 * $Revision: 1.40.98.4 $	$Author: jsm $
 * $State: Exp $   	$Locker: BERT $
 */

#ifndef _MACHINE_PARAM_INCLUDED /* allow multiple inclusions */
#define _MACHINE_PARAM_INCLUDED

#ifdef _KERNEL_BUILD
#include "../h/sysmacros.h"
#include "../machine/param_shm.h"
#else  /* ! _KERNEL_BUILD */
#include <sys/sysmacros.h>
#include <machine/param_shm.h>
#endif /* _KERNEL_BUILD */

/*	param.h	6.1	83/07/29	*/

/*
 * Machine dependent constants for HP Precision Architecture.
 */

#ifndef PGSHIFT			/* avoid redefining with assym.s */
#  ifdef KLUDGE_TLB_MP
#    define PGSHIFT  11			/* LOG2(NBPG = 4096) */
#    define HPGSHIFT 11
#  else 
#    define PGSHIFT  12			/* LOG2(NBPG = 2048) */
#    define HPGSHIFT 12
#  endif 
#  define NBPG		(1<<PGSHIFT)	/* bytes/page */
#  define NBHPG 	(1<<HPGSHIFT)   /* bytes/hardware page */
#  define PGOFSET	(NBPG-1)	/* byte offset into page */
#  define BYTESHIFT	2		/* LOG2(bytes/word) */
#  define PGNDXWDTH	(32-PGSHIFT)	/* bit width of a physical page no
				         * (page index)	*/
#  define NBPG_PA83 2048		/* 2k page size for PA-RISC 1.0 */
#endif /* not PGSHIFT */

#define	MAXPHYS	(256 * 1024)	/* Maximum size of physical I/O transfer */

#define	_BIG_ENDIAN		/* Memory storage (bytes in word) */

/*
 * At 8.0 on HP-PA when the address of a function is taken in a process that
 * uses shared libraries an indirect plabel is created.  The address points
 * to a two word entry; the actual address of the function followed by the
 * r19 value when executing in that function.  An indirect plabel is 
 * indicated by the 2nd least significant bit being set in a text pointer.
 */

#define INDIRECT_PLABEL	0x02

/*
 * Define the start of the various segments.  In HP Precision Architecture, 
 * a segment is equal to a quadrant. 
 */
#define SEG_SIZE	0x40000000	/* size of a quadrant (segment) */

#define KERN_ADDR	0x00000000	/* system quadrant */
#define LASTV_FRSTQUAD	0x3fffffff	/* last addr in system quad */
#define FIRSTV_THIRDQUAD 0x80000000     /* first addr in buffer cache quad */
#define LASTV_THIRDQUAD 0xbfffffff      /* last addr in buffer cache quad */
#define SIZEV_THIRDQUAD 0x40000000      /* size of buffer cache quad */
#define TEXT_ADDR	0x00000000	/* shared text quadrant */
#define DATA_ADDR	0x40000000	/* user private data quadrant */
#define	SHARED_ADDR	0x80000000	/* shared objects go in quad 3 & 4 */
#define QUAD1_BEG_ADDR	0x00000000
#define QUAD2_BEG_ADDR	0x40000000
#define QUAD3_BEG_ADDR	0x80000000
#define QUAD4_BEG_ADDR	0xc0000000

/*
 * Parameters controlling pre-allocated memory in the shared memory
 * quadrant.
 */
#define QUAD4_BEG_FREE (2*NBPG)
#define SHARED_QUAD4_BEG (QUAD4_BEG_ADDR + QUAD4_BEG_FREE)
#define SHARED_QUAD4_END_FREE (SEG_SIZE/4)	/* Must not be > SEG_SIZE/2 */
#define SHARED_QUAD4_END_BEG (QUAD4_BEG_ADDR + \
			      (SEG_SIZE - SHARED_QUAD4_END_FREE))

#ifndef	LOCORE
/*
 * Most of the machine dependent macros are now in ../h/sysmacros.h.
 */

/* bytes to word and backwards */
#define	btowr(x) (btow(((u_int)(x))+(WORD_SIZE-1))) /* round up # bytes to
					       		# words */
#define wtob(x) ( ( unsigned ) (x) << BYTESHIFT )


#define	DELAY(n)	{ register int N = (n); while (--N > 0); }

#define	lkernacc(sid, off, bcnt, rw)	lacc((sid), (off), (bcnt), (rw), 0)
#define	luseracc(sid, off, bcnt, rw)	lacc((sid), (off), (bcnt), (rw), 3)
#define	useracc(addr, bcnt, rw)		lacc(ldusid(addr), (addr), (bcnt), (rw), 3)

#define	kernacc(addr, bcnt, rw)		acc((addr), (bcnt), (rw), 0)

#define	fuibyte(base)		fubyte(base)
#define	fuiword(base)		fuword(base)
#define ovbcopy			bcopy
#endif /* not LOCORE */

#endif /* _MACHINE_PARAM_INCLUDED */
