/*
 * $Header: /smsa/bsd:include/sys/region.h:bsd  1.5  $
 * $Source: /smsa/bsd:include/sys/region.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 *
 */
/* @(#)region.h 1.0 12-Apr-88 4.3BSD ARMSRC */
/*
 * Copyright (c) 1988 Acorn Computers Ltd.  All rights reserved.
 *
 *	@(#)region.h	1.0 (Acorn) 12-Apr-88
 */

#ifndef	__sys_region_h
#define	__sys_region_h

/*
 * This header defines the 'region' structure for virtual memory segments. 
 * Currently used only for shared memory.
 */

#ifndef	__machine_pte_h
#include "../machine/pte.h"
#endif

/* The next definitions need centralising if regions are used other than */
/* for shared memory segments.                                           */
#define MAXREGIONS  (NSHMID)
#define MAXREGPAGES (SHMMAXPAGES)

struct region
{
#ifdef __notdef
  struct vnode *reg_lvp;	/* Vnode for loading this region */
  struct vnode *reg_pvp;	/* Vnode for paging this region */
#endif
  int          reg_type;         /* Text, data, stack or shared memory */
  int          reg_npages;       /* Size of region in pages */
  int          reg_status;       /* Status of region */
  int          reg_refcount;     /* No. of references to this region      */
                                 /* i.e. no. of times attached at present */
  /* The page table for this region. Note that one page table is          */
  /* sufficient, even if this region is mapped into several processes:    */
  /* since a region is contiguous in virtual address space, only the base */
  /* address and access are recorded separately for each mapping.         */
  struct pte   reg_pt[MAXREGPAGES]; 
};

/* Region status flags */

#define REGST_FREE	0001	/* Unused entry in region table */
#define REGST_LOCKED	0002	/* Region structure is locked   */
#define REGST_KEEP	0004	/* Keep even if refcount falls to 0  */
                                /* (used for shared memory segments) */
#define REGST_RONLY	0010	/* Read-only region (no-one may write) */
#define REGST_COW	0020	/* Copy on write */

/* Region types */

#define REG_TEXT	1	/* Text region */
#define REG_DATA	2	/* Data region */
#define REG_STACK	3	/* Stack region */
#define REG_SHM		4	/* Shared memory region */

#ifdef _KERNEL
extern struct region *allocreg();
extern struct pte    *reg_get_pte();
#endif

#endif/*__sys_region_h*/

/* EOF region.h */
