2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
#ifndef _REGION_H
|
|
|
|
#define _REGION_H 1
|
|
|
|
|
2009-09-21 16:49:49 +02:00
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/config.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
#include <minix/ds.h>
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#include <minix/keymap.h>
|
|
|
|
#include <minix/minlib.h>
|
|
|
|
#include <minix/type.h>
|
|
|
|
#include <minix/ipc.h>
|
|
|
|
#include <minix/sysutil.h>
|
|
|
|
#include <minix/syslib.h>
|
|
|
|
#include <minix/const.h>
|
|
|
|
|
2010-05-05 13:35:04 +02:00
|
|
|
#include "phys_region.h"
|
2012-10-11 15:15:49 +02:00
|
|
|
#include "memtype.h"
|
|
|
|
#include "vm.h"
|
2013-05-07 14:36:09 +02:00
|
|
|
#include "fdref.h"
|
2010-05-05 13:35:04 +02:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
struct phys_block {
|
|
|
|
#if SANITYCHECKS
|
|
|
|
u32_t seencount;
|
|
|
|
#endif
|
|
|
|
phys_bytes phys; /* physical memory */
|
2012-10-11 15:15:49 +02:00
|
|
|
|
2009-04-22 14:39:29 +02:00
|
|
|
/* first in list of phys_regions that reference this block */
|
|
|
|
struct phys_region *firstregion;
|
2013-03-20 20:09:01 +01:00
|
|
|
u8_t refcount; /* Refcount of these pages */
|
|
|
|
u8_t flags;
|
2008-11-19 13:26:10 +01:00
|
|
|
};
|
|
|
|
|
2013-03-20 20:18:52 +01:00
|
|
|
#define PBF_INCACHE 0x01
|
|
|
|
|
2010-10-04 13:41:10 +02:00
|
|
|
typedef struct vir_region {
|
2008-11-19 13:26:10 +01:00
|
|
|
vir_bytes vaddr; /* virtual address, offset from pagetable */
|
|
|
|
vir_bytes length; /* length in bytes */
|
2012-12-17 19:26:52 +01:00
|
|
|
struct phys_region **physblocks;
|
2008-11-19 13:26:10 +01:00
|
|
|
u16_t flags;
|
2009-04-22 14:39:29 +02:00
|
|
|
struct vmproc *parent; /* Process that owns this vir_region. */
|
2013-03-20 20:09:01 +01:00
|
|
|
mem_type_t *def_memtype; /* Default instantiated memory type. */
|
2012-10-11 15:15:49 +02:00
|
|
|
int remaps;
|
2013-08-20 14:02:33 +02:00
|
|
|
int id; /* unique id */
|
2012-10-11 15:15:49 +02:00
|
|
|
|
|
|
|
union {
|
2013-03-20 20:18:52 +01:00
|
|
|
phys_bytes phys; /* VR_DIRECT */
|
2012-10-11 15:15:49 +02:00
|
|
|
struct {
|
|
|
|
endpoint_t ep;
|
|
|
|
vir_bytes vaddr;
|
|
|
|
int id;
|
|
|
|
} shared;
|
2013-03-20 20:18:52 +01:00
|
|
|
struct phys_block *pb_cache;
|
|
|
|
struct {
|
|
|
|
int inited;
|
2013-05-07 14:36:09 +02:00
|
|
|
struct fdref *fdref;
|
|
|
|
u64_t offset;
|
2013-03-20 20:18:52 +01:00
|
|
|
u16_t clearend;
|
|
|
|
} file;
|
2012-10-11 15:15:49 +02:00
|
|
|
} param;
|
2010-10-04 13:41:10 +02:00
|
|
|
|
|
|
|
/* AVL fields */
|
|
|
|
struct vir_region *lower, *higher;
|
|
|
|
int factor;
|
|
|
|
} region_t;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
/* Mapping flags: */
|
2009-09-21 16:49:49 +02:00
|
|
|
#define VR_WRITABLE 0x001 /* Process may write here. */
|
|
|
|
#define VR_PHYS64K 0x004 /* Physical memory must be 64k aligned. */
|
|
|
|
#define VR_LOWER16MB 0x008
|
|
|
|
#define VR_LOWER1MB 0x010
|
2010-05-05 13:35:04 +02:00
|
|
|
#define VR_SHARED 0x040
|
2012-06-06 19:05:28 +02:00
|
|
|
#define VR_UNINITIALIZED 0x080 /* Do not clear after allocation */
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
/* Mapping type: */
|
2009-09-21 16:49:49 +02:00
|
|
|
#define VR_ANON 0x100 /* Memory to be cleared and allocated */
|
|
|
|
#define VR_DIRECT 0x200 /* Mapped, but not managed by VM */
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
/* map_page_region flags */
|
|
|
|
#define MF_PREALLOC 0x01
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|