vm: make WARNS=5 proof
Change-Id: I737ded223daf04f1c0c85a2e8e6b36c8fdcd07db
This commit is contained in:
parent
eabd293152
commit
b538531449
28 changed files with 134 additions and 160 deletions
|
@ -1,4 +1,4 @@
|
||||||
int env_parse(char *env, char *fmt, int field, long *param, long min,
|
int env_parse(const char *env, const char *fmt, int field, long *param, long min,
|
||||||
long max);
|
long max);
|
||||||
void env_panic(char *env);
|
void env_panic(const char *env);
|
||||||
int env_prefix(char *env, char *prefix);
|
int env_prefix(char *env, char *prefix);
|
||||||
|
|
|
@ -35,11 +35,11 @@ extern int env_argc;
|
||||||
extern char **env_argv;
|
extern char **env_argv;
|
||||||
|
|
||||||
void env_setargs(int argc, char *argv[]);
|
void env_setargs(int argc, char *argv[]);
|
||||||
int env_get_param(char *key, char *value, int max_size);
|
int env_get_param(const char *key, char *value, int max_size);
|
||||||
int env_prefix(char *env, char *prefix);
|
int env_prefix(char *env, char *prefix);
|
||||||
void env_panic(char *key);
|
void env_panic(const char *key);
|
||||||
int env_parse(char *env, char *fmt, int field, long *param, long min,
|
int env_parse(const char *env, const char *fmt, int field,
|
||||||
long max);
|
long *param, long min, long max);
|
||||||
|
|
||||||
#define fkey_map(fkeys, sfkeys) fkey_ctl(FKEY_MAP, (fkeys), (sfkeys))
|
#define fkey_map(fkeys, sfkeys) fkey_ctl(FKEY_MAP, (fkeys), (sfkeys))
|
||||||
#define fkey_unmap(fkeys, sfkeys) fkey_ctl(FKEY_UNMAP, (fkeys), (sfkeys))
|
#define fkey_unmap(fkeys, sfkeys) fkey_ctl(FKEY_UNMAP, (fkeys), (sfkeys))
|
||||||
|
|
|
@ -20,10 +20,7 @@ char *arg_v[];
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* env_get_param *
|
* env_get_param *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int env_get_param(key, value, max_len)
|
int env_get_param(const char *key, char *value, int max_len)
|
||||||
char *key; /* which key to look up */
|
|
||||||
char *value; /* where to store value */
|
|
||||||
int max_len; /* maximum length of value */
|
|
||||||
{
|
{
|
||||||
message m;
|
message m;
|
||||||
static char mon_params[MULTIBOOT_PARAM_BUF_SIZE]; /* copy parameters here */
|
static char mon_params[MULTIBOOT_PARAM_BUF_SIZE]; /* copy parameters here */
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
/*=========================================================================*
|
/*=========================================================================*
|
||||||
* env_panic *
|
* env_panic *
|
||||||
*=========================================================================*/
|
*=========================================================================*/
|
||||||
void env_panic(key)
|
void env_panic(const char *key)
|
||||||
char *key; /* environment variable whose value is bogus */
|
|
||||||
{
|
{
|
||||||
static char value[EP_BUF_SIZE] = "<unknown>";
|
static char value[EP_BUF_SIZE] = "<unknown>";
|
||||||
int s;
|
int s;
|
||||||
|
|
|
@ -8,12 +8,8 @@
|
||||||
/*=========================================================================*
|
/*=========================================================================*
|
||||||
* env_parse *
|
* env_parse *
|
||||||
*=========================================================================*/
|
*=========================================================================*/
|
||||||
int env_parse(env, fmt, field, param, min, max)
|
int env_parse(const char *env, const char *fmt,
|
||||||
char *env; /* environment variable to inspect */
|
int field, long *param, long min, long max)
|
||||||
char *fmt; /* template to parse it with */
|
|
||||||
int field; /* field number of value to return */
|
|
||||||
long *param; /* address of parameter to get */
|
|
||||||
long min, max; /* minimum and maximum values for the parameter */
|
|
||||||
{
|
{
|
||||||
/* Parse an environment variable setting, something like "DPETH0=300:3".
|
/* Parse an environment variable setting, something like "DPETH0=300:3".
|
||||||
* Panic if the parsing fails. Return EP_UNSET if the environment variable
|
* Panic if the parsing fails. Return EP_UNSET if the environment variable
|
||||||
|
|
|
@ -15,6 +15,8 @@ LDFLAGS+= -T ${.CURDIR}/arch/${MACHINE_ARCH}/vm.lds
|
||||||
DPADD+= ${LIBSYS} ${LIBEXEC}
|
DPADD+= ${LIBSYS} ${LIBEXEC}
|
||||||
LDADD+= -lsys -lexec
|
LDADD+= -lsys -lexec
|
||||||
|
|
||||||
|
WARNS=5
|
||||||
|
|
||||||
MAN=
|
MAN=
|
||||||
|
|
||||||
BINDIR?= /usr/sbin
|
BINDIR?= /usr/sbin
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "memlist.h"
|
#include "memlist.h"
|
||||||
|
|
||||||
/* Number of physical pages in a 32-bit address space */
|
/* Number of physical pages in a 32-bit address space */
|
||||||
#define NUMBER_PHYSICAL_PAGES (0x100000000ULL/VM_PAGE_SIZE)
|
#define NUMBER_PHYSICAL_PAGES (int)(0x100000000ULL/VM_PAGE_SIZE)
|
||||||
#define PAGE_BITMAP_CHUNKS BITMAP_CHUNKS(NUMBER_PHYSICAL_PAGES)
|
#define PAGE_BITMAP_CHUNKS BITMAP_CHUNKS(NUMBER_PHYSICAL_PAGES)
|
||||||
static bitchunk_t free_pages_bitmap[PAGE_BITMAP_CHUNKS];
|
static bitchunk_t free_pages_bitmap[PAGE_BITMAP_CHUNKS];
|
||||||
#define PAGE_CACHE_MAX 10000
|
#define PAGE_CACHE_MAX 10000
|
||||||
|
@ -78,7 +78,7 @@ static void sanitycheck_queues(void)
|
||||||
struct reserved_pages *mrq;
|
struct reserved_pages *mrq;
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
|
||||||
for(mrq = first_reserved_inuse; mrq > 0; mrq = mrq->next) {
|
for(mrq = first_reserved_inuse; mrq; mrq = mrq->next) {
|
||||||
assert(mrq->max_available > 0);
|
assert(mrq->max_available > 0);
|
||||||
assert(mrq->max_available >= mrq->n_available);
|
assert(mrq->max_available >= mrq->n_available);
|
||||||
m += mrq->max_available - mrq->n_available;
|
m += mrq->max_available - mrq->n_available;
|
||||||
|
@ -188,7 +188,7 @@ void reservedqueue_add(void *rq_v, void *vir, phys_bytes ph)
|
||||||
reservedqueue_fillslot(rq, rps, ph, vir);
|
reservedqueue_fillslot(rq, rps, ph, vir);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reservedqueue_fill(void *rq_v)
|
static int reservedqueue_fill(void *rq_v)
|
||||||
{
|
{
|
||||||
struct reserved_pages *rq = rq_v;
|
struct reserved_pages *rq = rq_v;
|
||||||
int r;
|
int r;
|
||||||
|
@ -303,8 +303,7 @@ void free_mem(phys_clicks base, phys_clicks clicks)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* mem_init *
|
* mem_init *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void mem_init(chunks)
|
void mem_init(struct memory *chunks)
|
||||||
struct memory *chunks; /* list of free memory chunks */
|
|
||||||
{
|
{
|
||||||
/* Initialize hole lists. There are two lists: 'hole_head' points to a linked
|
/* Initialize hole lists. There are two lists: 'hole_head' points to a linked
|
||||||
* list of all the holes (unused memory) in the system; 'free_slots' points to
|
* list of all the holes (unused memory) in the system; 'free_slots' points to
|
||||||
|
@ -406,8 +405,8 @@ static phys_bytes alloc_pages(int pages, int memflags)
|
||||||
{
|
{
|
||||||
phys_bytes boundary16 = 16 * 1024 * 1024 / VM_PAGE_SIZE;
|
phys_bytes boundary16 = 16 * 1024 * 1024 / VM_PAGE_SIZE;
|
||||||
phys_bytes boundary1 = 1 * 1024 * 1024 / VM_PAGE_SIZE;
|
phys_bytes boundary1 = 1 * 1024 * 1024 / VM_PAGE_SIZE;
|
||||||
phys_bytes mem = NO_MEM;
|
phys_bytes mem = NO_MEM, i; /* page number */
|
||||||
int maxpage = NUMBER_PHYSICAL_PAGES - 1, i;
|
int maxpage = NUMBER_PHYSICAL_PAGES - 1;
|
||||||
static int lastscan = -1;
|
static int lastscan = -1;
|
||||||
int startscan, run_length;
|
int startscan, run_length;
|
||||||
|
|
||||||
|
|
|
@ -565,7 +565,7 @@ int pt_ptalloc_in_range(pt_t *pt, vir_bytes start, vir_bytes end,
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *ptestr(u32_t pte)
|
static const char *ptestr(u32_t pte)
|
||||||
{
|
{
|
||||||
#define FLAG(constant, name) { \
|
#define FLAG(constant, name) { \
|
||||||
if(pte & (constant)) { strcat(str, name); strcat(str, " "); } \
|
if(pte & (constant)) { strcat(str, name); strcat(str, " "); } \
|
||||||
|
@ -626,7 +626,7 @@ int pt_map_in_range(struct vmproc *src_vmp, struct vmproc *dst_vmp,
|
||||||
assert(start % VM_PAGE_SIZE == 0);
|
assert(start % VM_PAGE_SIZE == 0);
|
||||||
assert(end % VM_PAGE_SIZE == 0);
|
assert(end % VM_PAGE_SIZE == 0);
|
||||||
|
|
||||||
assert(ARCH_VM_PDE(start) >= 0 && start <= end);
|
assert( /* ARCH_VM_PDE(start) >= 0 && */ start <= end);
|
||||||
assert(ARCH_VM_PDE(end) < ARCH_VM_DIR_ENTRIES);
|
assert(ARCH_VM_PDE(end) < ARCH_VM_DIR_ENTRIES);
|
||||||
|
|
||||||
#if LU_DEBUG
|
#if LU_DEBUG
|
||||||
|
@ -1107,54 +1107,54 @@ void pt_init(void)
|
||||||
{
|
{
|
||||||
int kernmap_pde;
|
int kernmap_pde;
|
||||||
phys_bytes addr, len;
|
phys_bytes addr, len;
|
||||||
int flags, index = 0;
|
int flags, pindex = 0;
|
||||||
u32_t offset = 0;
|
u32_t offset = 0;
|
||||||
|
|
||||||
kernmap_pde = freepde();
|
kernmap_pde = freepde();
|
||||||
offset = kernmap_pde * ARCH_BIG_PAGE_SIZE;
|
offset = kernmap_pde * ARCH_BIG_PAGE_SIZE;
|
||||||
|
|
||||||
while(sys_vmctl_get_mapping(index, &addr, &len,
|
while(sys_vmctl_get_mapping(pindex, &addr, &len,
|
||||||
&flags) == OK) {
|
&flags) == OK) {
|
||||||
int usedpde;
|
int usedpde;
|
||||||
vir_bytes vir;
|
vir_bytes vir;
|
||||||
if(index >= MAX_KERNMAPPINGS)
|
if(pindex >= MAX_KERNMAPPINGS)
|
||||||
panic("VM: too many kernel mappings: %d", index);
|
panic("VM: too many kernel mappings: %d", pindex);
|
||||||
kern_mappings[index].phys_addr = addr;
|
kern_mappings[pindex].phys_addr = addr;
|
||||||
kern_mappings[index].len = len;
|
kern_mappings[pindex].len = len;
|
||||||
kern_mappings[index].flags = flags;
|
kern_mappings[pindex].flags = flags;
|
||||||
kern_mappings[index].vir_addr = offset;
|
kern_mappings[pindex].vir_addr = offset;
|
||||||
kern_mappings[index].flags =
|
kern_mappings[pindex].flags =
|
||||||
ARCH_VM_PTE_PRESENT;
|
ARCH_VM_PTE_PRESENT;
|
||||||
if(flags & VMMF_UNCACHED)
|
if(flags & VMMF_UNCACHED)
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
kern_mappings[index].flags |= PTF_NOCACHE;
|
kern_mappings[pindex].flags |= PTF_NOCACHE;
|
||||||
#elif defined(__arm__)
|
#elif defined(__arm__)
|
||||||
kern_mappings[index].flags |= ARM_VM_PTE_DEVICE;
|
kern_mappings[pindex].flags |= ARM_VM_PTE_DEVICE;
|
||||||
#endif
|
#endif
|
||||||
if(flags & VMMF_USER)
|
if(flags & VMMF_USER)
|
||||||
kern_mappings[index].flags |= ARCH_VM_PTE_USER;
|
kern_mappings[pindex].flags |= ARCH_VM_PTE_USER;
|
||||||
#if defined(__arm__)
|
#if defined(__arm__)
|
||||||
else
|
else
|
||||||
kern_mappings[index].flags |= ARM_VM_PTE_SUPER;
|
kern_mappings[pindex].flags |= ARM_VM_PTE_SUPER;
|
||||||
#endif
|
#endif
|
||||||
if(flags & VMMF_WRITE)
|
if(flags & VMMF_WRITE)
|
||||||
kern_mappings[index].flags |= ARCH_VM_PTE_RW;
|
kern_mappings[pindex].flags |= ARCH_VM_PTE_RW;
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
if(flags & VMMF_GLO)
|
if(flags & VMMF_GLO)
|
||||||
kern_mappings[index].flags |= I386_VM_GLOBAL;
|
kern_mappings[pindex].flags |= I386_VM_GLOBAL;
|
||||||
#elif defined(__arm__)
|
#elif defined(__arm__)
|
||||||
else
|
else
|
||||||
kern_mappings[index].flags |= ARCH_VM_PTE_RO;
|
kern_mappings[pindex].flags |= ARCH_VM_PTE_RO;
|
||||||
#endif
|
#endif
|
||||||
if(addr % VM_PAGE_SIZE)
|
if(addr % VM_PAGE_SIZE)
|
||||||
panic("VM: addr unaligned: %lu", addr);
|
panic("VM: addr unaligned: %lu", addr);
|
||||||
if(len % VM_PAGE_SIZE)
|
if(len % VM_PAGE_SIZE)
|
||||||
panic("VM: len unaligned: %lu", len);
|
panic("VM: len unaligned: %lu", len);
|
||||||
vir = offset;
|
vir = offset;
|
||||||
if(sys_vmctl_reply_mapping(index, vir) != OK)
|
if(sys_vmctl_reply_mapping(pindex, vir) != OK)
|
||||||
panic("VM: reply failed");
|
panic("VM: reply failed");
|
||||||
offset += len;
|
offset += len;
|
||||||
index++;
|
pindex++;
|
||||||
kernmappings++;
|
kernmappings++;
|
||||||
|
|
||||||
usedpde = ARCH_VM_PDE(offset);
|
usedpde = ARCH_VM_PDE(offset);
|
||||||
|
|
|
@ -61,9 +61,7 @@ int do_brk(message *msg)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* real_brk *
|
* real_brk *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int real_brk(vmp, v)
|
int real_brk(struct vmproc *vmp, vir_bytes v)
|
||||||
struct vmproc *vmp;
|
|
||||||
vir_bytes v;
|
|
||||||
{
|
{
|
||||||
if(map_region_extend_upto_v(vmp, v) == OK) {
|
if(map_region_extend_upto_v(vmp, v) == OK) {
|
||||||
return OK;
|
return OK;
|
||||||
|
|
|
@ -167,7 +167,7 @@ typedef struct
|
||||||
L__BIT_ARR_DEFN(branch)
|
L__BIT_ARR_DEFN(branch)
|
||||||
|
|
||||||
/* Zero-based depth of path into tree. */
|
/* Zero-based depth of path into tree. */
|
||||||
unsigned depth;
|
int depth;
|
||||||
|
|
||||||
/* Handles of nodes in path from root to current node (returned by *). */
|
/* Handles of nodes in path from root to current node (returned by *). */
|
||||||
AVL_HANDLE path_h[(AVL_MAX_DEPTH) - 1];
|
AVL_HANDLE path_h[(AVL_MAX_DEPTH) - 1];
|
||||||
|
|
|
@ -192,7 +192,7 @@ L__SC int L__(is_empty)(L__(avl) *L__tree)
|
||||||
|
|
||||||
/* Balances subtree, returns handle of root node of subtree after balancing.
|
/* Balances subtree, returns handle of root node of subtree after balancing.
|
||||||
*/
|
*/
|
||||||
L__SC AVL_HANDLE L__(balance)(L__BALANCE_PARAM_DECL_PREFIX AVL_HANDLE bal_h)
|
static L__SC AVL_HANDLE L__(balance)(L__BALANCE_PARAM_DECL_PREFIX AVL_HANDLE bal_h)
|
||||||
{
|
{
|
||||||
AVL_HANDLE deep_h;
|
AVL_HANDLE deep_h;
|
||||||
|
|
||||||
|
|
|
@ -92,18 +92,18 @@ void fdref_sanitycheck(void)
|
||||||
|
|
||||||
struct fdref *fdref_new(struct vmproc *owner, ino_t ino, dev_t dev, int fd)
|
struct fdref *fdref_new(struct vmproc *owner, ino_t ino, dev_t dev, int fd)
|
||||||
{
|
{
|
||||||
struct fdref *fdref;
|
struct fdref *nfdref;
|
||||||
|
|
||||||
if(!SLABALLOC(fdref)) return NULL;
|
if(!SLABALLOC(nfdref)) return NULL;
|
||||||
|
|
||||||
fdref->fd = fd;
|
nfdref->fd = fd;
|
||||||
fdref->refcount = 0;
|
nfdref->refcount = 0;
|
||||||
fdref->dev = dev;
|
nfdref->dev = dev;
|
||||||
fdref->ino = ino;
|
nfdref->ino = ino;
|
||||||
fdref->next = fdrefs;
|
nfdref->next = fdrefs;
|
||||||
fdrefs = fdref;
|
fdrefs = nfdref;
|
||||||
|
|
||||||
return fdref;
|
return nfdref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fdref_ref(struct fdref *ref, struct vir_region *region)
|
void fdref_ref(struct fdref *ref, struct vir_region *region)
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct fdref {
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
struct fdref *next;
|
struct fdref *next;
|
||||||
int counting; /* sanity check */
|
int counting; /* sanity check */
|
||||||
} *fdref;
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern int missing_spares;
|
||||||
/* Table of calls and a macro to test for being in range. */
|
/* Table of calls and a macro to test for being in range. */
|
||||||
struct {
|
struct {
|
||||||
int (*vmc_func)(message *); /* Call handles message. */
|
int (*vmc_func)(message *); /* Call handles message. */
|
||||||
char *vmc_name; /* Human-readable string. */
|
const char *vmc_name; /* Human-readable string. */
|
||||||
} vm_calls[NR_VM_CALLS];
|
} vm_calls[NR_VM_CALLS];
|
||||||
|
|
||||||
/* Macro to verify call range and map 'high' range to 'base' range
|
/* Macro to verify call range and map 'high' range to 'base' range
|
||||||
|
@ -88,7 +88,7 @@ int main(void)
|
||||||
/* This is VM's main loop. */
|
/* This is VM's main loop. */
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
int r, c;
|
int r, c;
|
||||||
u32_t type, param;
|
int type, param;
|
||||||
|
|
||||||
SANITYCHECK(SCL_TOP);
|
SANITYCHECK(SCL_TOP);
|
||||||
if(missing_spares > 0) {
|
if(missing_spares > 0) {
|
||||||
|
@ -181,7 +181,7 @@ static int do_rs_init(message *m)
|
||||||
return(SUSPEND);
|
return(SUSPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vmproc *init_proc(endpoint_t ep_nr)
|
static struct vmproc *init_proc(endpoint_t ep_nr)
|
||||||
{
|
{
|
||||||
static struct boot_image *ip;
|
static struct boot_image *ip;
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ static int libexec_alloc_vm_ondemand(struct exec_info *execi,
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_bootproc(struct vmproc *vmp, struct boot_image *ip)
|
static void exec_bootproc(struct vmproc *vmp, struct boot_image *ip)
|
||||||
{
|
{
|
||||||
struct vm_exec_info vmexeci;
|
struct vm_exec_info vmexeci;
|
||||||
struct exec_info *execi = &vmexeci.execi;
|
struct exec_info *execi = &vmexeci.execi;
|
||||||
|
@ -392,12 +392,12 @@ void init_vm(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up table of calls. */
|
/* Set up table of calls. */
|
||||||
#define CALLMAP(code, func) { int i; \
|
#define CALLMAP(code, func) { int _cmi; \
|
||||||
i=CALLNUMBER(code); \
|
_cmi=CALLNUMBER(code); \
|
||||||
assert(i >= 0); \
|
assert(_cmi >= 0); \
|
||||||
assert(i < NR_VM_CALLS); \
|
assert(_cmi < NR_VM_CALLS); \
|
||||||
vm_calls[i].vmc_func = (func); \
|
vm_calls[_cmi].vmc_func = (func); \
|
||||||
vm_calls[i].vmc_name = #code; \
|
vm_calls[_cmi].vmc_name = #code; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set call table to 0. This invalidates all calls (clear
|
/* Set call table to 0. This invalidates all calls (clear
|
||||||
|
@ -483,8 +483,7 @@ static void sef_cb_signal_handler(int signo)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_service *
|
* map_service *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static int map_service(rpub)
|
static int map_service(struct rprocpub *rpub)
|
||||||
struct rprocpub *rpub;
|
|
||||||
{
|
{
|
||||||
/* Map a new service by initializing its call mask. */
|
/* Map a new service by initializing its call mask. */
|
||||||
int r, proc_nr;
|
int r, proc_nr;
|
||||||
|
|
|
@ -40,7 +40,7 @@ static int anon_contig_new(struct vir_region *region)
|
||||||
{
|
{
|
||||||
u32_t allocflags;
|
u32_t allocflags;
|
||||||
phys_bytes new_pages, new_page_cl, cur_ph;
|
phys_bytes new_pages, new_page_cl, cur_ph;
|
||||||
int p, pages;
|
phys_bytes p, pages;
|
||||||
|
|
||||||
allocflags = vrallocflags(region->flags);
|
allocflags = vrallocflags(region->flags);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ do_mapcache(message *msg)
|
||||||
u64_t dev_off = (u64_t) msg->m_u.m_vmmcp.dev_offset_pages * VM_PAGE_SIZE;
|
u64_t dev_off = (u64_t) msg->m_u.m_vmmcp.dev_offset_pages * VM_PAGE_SIZE;
|
||||||
u64_t ino_off = (u64_t) msg->m_u.m_vmmcp.ino_offset_pages * VM_PAGE_SIZE;
|
u64_t ino_off = (u64_t) msg->m_u.m_vmmcp.ino_offset_pages * VM_PAGE_SIZE;
|
||||||
int n;
|
int n;
|
||||||
int bytes = msg->m_u.m_vmmcp.pages * VM_PAGE_SIZE;
|
phys_bytes bytes = msg->m_u.m_vmmcp.pages * VM_PAGE_SIZE;
|
||||||
struct vir_region *vr;
|
struct vir_region *vr;
|
||||||
struct vmproc *caller;
|
struct vmproc *caller;
|
||||||
vir_bytes offset;
|
vir_bytes offset;
|
||||||
|
@ -159,8 +159,8 @@ do_setcache(message *msg)
|
||||||
u64_t ino_off = (u64_t) msg->m_u.m_vmmcp.ino_offset_pages * VM_PAGE_SIZE;
|
u64_t ino_off = (u64_t) msg->m_u.m_vmmcp.ino_offset_pages * VM_PAGE_SIZE;
|
||||||
int n;
|
int n;
|
||||||
struct vmproc *caller;
|
struct vmproc *caller;
|
||||||
vir_bytes offset;
|
phys_bytes offset;
|
||||||
int bytes = msg->m_u.m_vmmcp.pages * VM_PAGE_SIZE;
|
phys_bytes bytes = msg->m_u.m_vmmcp.pages * VM_PAGE_SIZE;
|
||||||
|
|
||||||
if(bytes < VM_PAGE_SIZE) return EINVAL;
|
if(bytes < VM_PAGE_SIZE) return EINVAL;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
#include "proto.h"
|
||||||
|
|
||||||
/* These functions are static so as to not pollute the
|
/* These functions are static so as to not pollute the
|
||||||
* global namespace, and are accessed through their function
|
* global namespace, and are accessed through their function
|
||||||
|
|
|
@ -10,7 +10,7 @@ typedef void (*vfs_callback_t)(struct vmproc *vmp, message *m,
|
||||||
void *, void *);
|
void *, void *);
|
||||||
|
|
||||||
typedef struct mem_type {
|
typedef struct mem_type {
|
||||||
char *name; /* human-readable name */
|
const char *name; /* human-readable name */
|
||||||
int (*ev_new)(struct vir_region *region);
|
int (*ev_new)(struct vir_region *region);
|
||||||
void (*ev_delete)(struct vir_region *region);
|
void (*ev_delete)(struct vir_region *region);
|
||||||
int (*ev_reference)(struct phys_region *pr, struct phys_region *newpr);
|
int (*ev_reference)(struct phys_region *pr, struct phys_region *newpr);
|
||||||
|
|
|
@ -288,7 +288,7 @@ int do_mmap(message *m)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_perm_check *
|
* map_perm_check *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int map_perm_check(endpoint_t caller, endpoint_t target,
|
static int map_perm_check(endpoint_t caller, endpoint_t target,
|
||||||
phys_bytes physaddr, phys_bytes len)
|
phys_bytes physaddr, phys_bytes len)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
|
@ -278,7 +278,7 @@ int handle_memory(struct vmproc *vmp, vir_bytes mem, vir_bytes len, int wrflag,
|
||||||
sublen, wrflag, NULL, NULL, 0);
|
sublen, wrflag, NULL, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
r = map_handle_memory(vmp, region, offset,
|
r = map_handle_memory(vmp, region, offset,
|
||||||
sublen, wrflag, callback, state, sizeof(*state));
|
sublen, wrflag, callback, state, sizeof(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
len -= sublen;
|
len -= sublen;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void pb_unreferenced(struct vir_region *region, struct phys_region *pr, int rm)
|
||||||
pb = pr->ph;
|
pb = pr->ph;
|
||||||
assert(pb->refcount > 0);
|
assert(pb->refcount > 0);
|
||||||
USE(pb, pb->refcount--;);
|
USE(pb, pb->refcount--;);
|
||||||
assert(pb->refcount >= 0);
|
/* assert(pb->refcount >= 0); */ /* always true */
|
||||||
|
|
||||||
if(pb->firstregion == pr) {
|
if(pb->firstregion == pr) {
|
||||||
USE(pb, pb->firstregion = pr->next_ph_list;);
|
USE(pb, pb->firstregion = pr->next_ph_list;);
|
||||||
|
|
|
@ -88,7 +88,7 @@ int handle_memory(struct vmproc *vmp, vir_bytes mem, vir_bytes len, int
|
||||||
wrflag, vfs_callback_t cb, void *state, int statelen);
|
wrflag, vfs_callback_t cb, void *state, int statelen);
|
||||||
|
|
||||||
/* $(ARCH)/pagetable.c */
|
/* $(ARCH)/pagetable.c */
|
||||||
void pt_init();
|
void pt_init(void);
|
||||||
void vm_freepages(vir_bytes vir, int pages);
|
void vm_freepages(vir_bytes vir, int pages);
|
||||||
void pt_init_mem(void);
|
void pt_init_mem(void);
|
||||||
void pt_check(struct vmproc *vmp);
|
void pt_check(struct vmproc *vmp);
|
||||||
|
@ -175,7 +175,7 @@ void map_region_set_tag(struct vir_region *vr, u32_t tag);
|
||||||
u32_t map_region_get_tag(struct vir_region *vr);
|
u32_t map_region_get_tag(struct vir_region *vr);
|
||||||
int map_get_phys(struct vmproc *vmp, vir_bytes addr, phys_bytes *r);
|
int map_get_phys(struct vmproc *vmp, vir_bytes addr, phys_bytes *r);
|
||||||
int map_get_ref(struct vmproc *vmp, vir_bytes addr, u8_t *cnt);
|
int map_get_ref(struct vmproc *vmp, vir_bytes addr, u8_t *cnt);
|
||||||
int physregions(struct vir_region *vr);
|
unsigned int physregions(struct vir_region *vr);
|
||||||
|
|
||||||
void get_usage_info(struct vmproc *vmp, struct vm_usage_info *vui);
|
void get_usage_info(struct vmproc *vmp, struct vm_usage_info *vui);
|
||||||
void get_usage_info_kernel(struct vm_usage_info *vui);
|
void get_usage_info_kernel(struct vm_usage_info *vui);
|
||||||
|
|
|
@ -37,9 +37,9 @@ void map_region_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_printregion(struct vir_region *vr)
|
static void map_printregion(struct vir_region *vr)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
struct phys_region *ph;
|
struct phys_region *ph;
|
||||||
printf("map_printmap: map_name: %s\n", vr->def_memtype->name);
|
printf("map_printmap: map_name: %s\n", vr->def_memtype->name);
|
||||||
printf("\t%lx (len 0x%lx, %lukB), %p, %s\n",
|
printf("\t%lx (len 0x%lx, %lukB), %p, %s\n",
|
||||||
|
@ -62,7 +62,7 @@ struct phys_region *physblock_get(struct vir_region *region, vir_bytes offset)
|
||||||
int i;
|
int i;
|
||||||
struct phys_region *foundregion;
|
struct phys_region *foundregion;
|
||||||
assert(!(offset % VM_PAGE_SIZE));
|
assert(!(offset % VM_PAGE_SIZE));
|
||||||
assert(offset >= 0 && offset < region->length);
|
assert( /* offset >= 0 && */ offset < region->length);
|
||||||
i = offset/VM_PAGE_SIZE;
|
i = offset/VM_PAGE_SIZE;
|
||||||
if((foundregion = region->physblocks[i]))
|
if((foundregion = region->physblocks[i]))
|
||||||
assert(foundregion->offset == offset);
|
assert(foundregion->offset == offset);
|
||||||
|
@ -75,7 +75,7 @@ void physblock_set(struct vir_region *region, vir_bytes offset,
|
||||||
int i;
|
int i;
|
||||||
struct vmproc *proc;
|
struct vmproc *proc;
|
||||||
assert(!(offset % VM_PAGE_SIZE));
|
assert(!(offset % VM_PAGE_SIZE));
|
||||||
assert(offset >= 0 && offset < region->length);
|
assert( /* offset >= 0 && */ offset < region->length);
|
||||||
i = offset/VM_PAGE_SIZE;
|
i = offset/VM_PAGE_SIZE;
|
||||||
proc = region->parent;
|
proc = region->parent;
|
||||||
assert(proc);
|
assert(proc);
|
||||||
|
@ -95,8 +95,7 @@ void physblock_set(struct vir_region *region, vir_bytes offset,
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_printmap *
|
* map_printmap *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void map_printmap(vmp)
|
void map_printmap(struct vmproc *vmp)
|
||||||
struct vmproc *vmp;
|
|
||||||
{
|
{
|
||||||
struct vir_region *vr;
|
struct vir_region *vr;
|
||||||
region_iter iter;
|
region_iter iter;
|
||||||
|
@ -128,7 +127,7 @@ static struct vir_region *getnextvr(struct vir_region *vr)
|
||||||
return nextvr;
|
return nextvr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pr_writable(struct vir_region *vr, struct phys_region *pr)
|
static int pr_writable(struct vir_region *vr, struct phys_region *pr)
|
||||||
{
|
{
|
||||||
assert(pr->memtype->writable);
|
assert(pr->memtype->writable);
|
||||||
return ((vr->flags & VR_WRITABLE) && pr->memtype->writable(pr));
|
return ((vr->flags & VR_WRITABLE) && pr->memtype->writable(pr));
|
||||||
|
@ -420,17 +419,17 @@ static vir_bytes region_find_slot(struct vmproc *vmp,
|
||||||
return region_find_slot_range(vmp, minv, maxv, length);
|
return region_find_slot_range(vmp, minv, maxv, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int phys_slot(vir_bytes len)
|
static unsigned int phys_slot(vir_bytes len)
|
||||||
{
|
{
|
||||||
assert(!(len % VM_PAGE_SIZE));
|
assert(!(len % VM_PAGE_SIZE));
|
||||||
return len / VM_PAGE_SIZE;
|
return len / VM_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vir_region *region_new(struct vmproc *vmp, vir_bytes startv, vir_bytes length,
|
static struct vir_region *region_new(struct vmproc *vmp, vir_bytes startv, vir_bytes length,
|
||||||
int flags, mem_type_t *memtype)
|
int flags, mem_type_t *memtype)
|
||||||
{
|
{
|
||||||
struct vir_region *newregion;
|
struct vir_region *newregion;
|
||||||
struct phys_region **physregions;
|
struct phys_region **newphysregions;
|
||||||
static u32_t id;
|
static u32_t id;
|
||||||
int slots = phys_slot(length);
|
int slots = phys_slot(length);
|
||||||
|
|
||||||
|
@ -451,13 +450,13 @@ USE(newregion,
|
||||||
newregion->lower = newregion->higher = NULL;
|
newregion->lower = newregion->higher = NULL;
|
||||||
newregion->parent = vmp;);
|
newregion->parent = vmp;);
|
||||||
|
|
||||||
if(!(physregions = calloc(slots, sizeof(struct phys_region *)))) {
|
if(!(newphysregions = calloc(slots, sizeof(struct phys_region *)))) {
|
||||||
printf("VM: region_new: allocating phys blocks failed\n");
|
printf("VM: region_new: allocating phys blocks failed\n");
|
||||||
SLABFREE(newregion);
|
SLABFREE(newregion);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
USE(newregion, newregion->physblocks = physregions;);
|
USE(newregion, newregion->physblocks = newphysregions;);
|
||||||
|
|
||||||
return newregion;
|
return newregion;
|
||||||
}
|
}
|
||||||
|
@ -465,15 +464,9 @@ USE(newregion,
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_page_region *
|
* map_page_region *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vir_region *map_page_region(vmp, minv, maxv, length,
|
struct vir_region *map_page_region(struct vmproc *vmp, vir_bytes minv,
|
||||||
flags, mapflags, memtype)
|
vir_bytes maxv, vir_bytes length, u32_t flags, int mapflags,
|
||||||
struct vmproc *vmp;
|
mem_type_t *memtype)
|
||||||
vir_bytes minv;
|
|
||||||
vir_bytes maxv;
|
|
||||||
vir_bytes length;
|
|
||||||
u32_t flags;
|
|
||||||
int mapflags;
|
|
||||||
mem_type_t *memtype;
|
|
||||||
{
|
{
|
||||||
struct vir_region *newregion;
|
struct vir_region *newregion;
|
||||||
vir_bytes startv;
|
vir_bytes startv;
|
||||||
|
@ -600,8 +593,7 @@ int map_free(struct vir_region *region)
|
||||||
/*========================================================================*
|
/*========================================================================*
|
||||||
* map_free_proc *
|
* map_free_proc *
|
||||||
*========================================================================*/
|
*========================================================================*/
|
||||||
int map_free_proc(vmp)
|
int map_free_proc(struct vmproc *vmp)
|
||||||
struct vmproc *vmp;
|
|
||||||
{
|
{
|
||||||
struct vir_region *r;
|
struct vir_region *r;
|
||||||
|
|
||||||
|
@ -628,10 +620,8 @@ struct vmproc *vmp;
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_lookup *
|
* map_lookup *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
struct vir_region *map_lookup(vmp, offset, physr)
|
struct vir_region *map_lookup(struct vmproc *vmp,
|
||||||
struct vmproc *vmp;
|
vir_bytes offset, struct phys_region **physr)
|
||||||
vir_bytes offset;
|
|
||||||
struct phys_region **physr;
|
|
||||||
{
|
{
|
||||||
struct vir_region *r;
|
struct vir_region *r;
|
||||||
|
|
||||||
|
@ -678,22 +668,21 @@ u32_t vrallocflags(u32_t flags)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* map_pf *
|
* map_pf *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int map_pf(vmp, region, offset, write, pf_callback, state, len, io)
|
int map_pf(struct vmproc *vmp,
|
||||||
struct vmproc *vmp;
|
struct vir_region *region,
|
||||||
struct vir_region *region;
|
vir_bytes offset,
|
||||||
vir_bytes offset;
|
int write,
|
||||||
int write;
|
vfs_callback_t pf_callback,
|
||||||
vfs_callback_t pf_callback;
|
void *state,
|
||||||
void *state;
|
int len,
|
||||||
int len;
|
int *io)
|
||||||
int *io;
|
|
||||||
{
|
{
|
||||||
struct phys_region *ph;
|
struct phys_region *ph;
|
||||||
int r = OK;
|
int r = OK;
|
||||||
|
|
||||||
offset -= offset % VM_PAGE_SIZE;
|
offset -= offset % VM_PAGE_SIZE;
|
||||||
|
|
||||||
assert(offset >= 0);
|
/* assert(offset >= 0); */ /* always true */
|
||||||
assert(offset < region->length);
|
assert(offset < region->length);
|
||||||
|
|
||||||
assert(!(region->vaddr % VM_PAGE_SIZE));
|
assert(!(region->vaddr % VM_PAGE_SIZE));
|
||||||
|
@ -769,16 +758,9 @@ int *io;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int map_handle_memory(vmp, region, start_offset, length, write,
|
int map_handle_memory(struct vmproc *vmp,
|
||||||
cb, state, statelen)
|
struct vir_region *region, vir_bytes start_offset, vir_bytes length,
|
||||||
struct vmproc *vmp;
|
int write, vfs_callback_t cb, void *state, int statelen)
|
||||||
struct vir_region *region;
|
|
||||||
vir_bytes start_offset;
|
|
||||||
vir_bytes length;
|
|
||||||
int write;
|
|
||||||
vfs_callback_t cb;
|
|
||||||
void *state;
|
|
||||||
int statelen;
|
|
||||||
{
|
{
|
||||||
vir_bytes offset, lim;
|
vir_bytes offset, lim;
|
||||||
int r;
|
int r;
|
||||||
|
@ -878,7 +860,7 @@ struct vir_region *map_copy_region(struct vmproc *vmp, struct vir_region *vr)
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* copy_abs2region *
|
* copy_abs2region *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int copy_abs2region(phys_bytes abs, struct vir_region *destregion,
|
int copy_abs2region(phys_bytes absaddr, struct vir_region *destregion,
|
||||||
phys_bytes offset, phys_bytes len)
|
phys_bytes offset, phys_bytes len)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -909,11 +891,11 @@ int copy_abs2region(phys_bytes abs, struct vir_region *destregion,
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sys_abscopy(abs, ph->ph->phys + suboffset, sublen) != OK) {
|
if(sys_abscopy(absaddr, ph->ph->phys + suboffset, sublen) != OK) {
|
||||||
printf("VM: copy_abs2region: abscopy failed.\n");
|
printf("VM: copy_abs2region: abscopy failed.\n");
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
abs += sublen;
|
absaddr += sublen;
|
||||||
offset += sublen;
|
offset += sublen;
|
||||||
len -= sublen;
|
len -= sublen;
|
||||||
}
|
}
|
||||||
|
@ -951,9 +933,7 @@ int map_writept(struct vmproc *vmp)
|
||||||
/*========================================================================*
|
/*========================================================================*
|
||||||
* map_proc_copy *
|
* map_proc_copy *
|
||||||
*========================================================================*/
|
*========================================================================*/
|
||||||
int map_proc_copy(dst, src)
|
int map_proc_copy(struct vmproc *dst, struct vmproc *src)
|
||||||
struct vmproc *dst;
|
|
||||||
struct vmproc *src;
|
|
||||||
{
|
{
|
||||||
/* Copy all the memory regions from the src process to the dst process. */
|
/* Copy all the memory regions from the src process to the dst process. */
|
||||||
region_init(&dst->vm_regions_avl);
|
region_init(&dst->vm_regions_avl);
|
||||||
|
@ -964,10 +944,8 @@ struct vmproc *src;
|
||||||
/*========================================================================*
|
/*========================================================================*
|
||||||
* map_proc_copy_from *
|
* map_proc_copy_from *
|
||||||
*========================================================================*/
|
*========================================================================*/
|
||||||
int map_proc_copy_from(dst, src, start_src_vr)
|
int map_proc_copy_from(struct vmproc *dst, struct vmproc *src,
|
||||||
struct vmproc *dst;
|
struct vir_region *start_src_vr)
|
||||||
struct vmproc *src;
|
|
||||||
struct vir_region *start_src_vr;
|
|
||||||
{
|
{
|
||||||
struct vir_region *vr;
|
struct vir_region *vr;
|
||||||
region_iter v_iter;
|
region_iter v_iter;
|
||||||
|
@ -1166,7 +1144,7 @@ int map_unmap_region(struct vmproc *vmp, struct vir_region *r,
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int split_region(struct vmproc *vmp, struct vir_region *vr,
|
static int split_region(struct vmproc *vmp, struct vir_region *vr,
|
||||||
struct vir_region **vr1, struct vir_region **vr2, vir_bytes split_len)
|
struct vir_region **vr1, struct vir_region **vr2, vir_bytes split_len)
|
||||||
{
|
{
|
||||||
struct vir_region *r1 = NULL, *r2 = NULL;
|
struct vir_region *r1 = NULL, *r2 = NULL;
|
||||||
|
@ -1279,7 +1257,6 @@ int map_unmap_range(struct vmproc *vmp, vir_bytes unmap_start, vir_bytes length)
|
||||||
if(this_unmap_start >= this_unmap_limit) continue;
|
if(this_unmap_start >= this_unmap_limit) continue;
|
||||||
|
|
||||||
if(this_unmap_start > vr->vaddr && this_unmap_limit < thislimit) {
|
if(this_unmap_start > vr->vaddr && this_unmap_limit < thislimit) {
|
||||||
int r;
|
|
||||||
struct vir_region *vr1, *vr2;
|
struct vir_region *vr1, *vr2;
|
||||||
vir_bytes split_len = this_unmap_limit - vr->vaddr;
|
vir_bytes split_len = this_unmap_limit - vr->vaddr;
|
||||||
assert(split_len > 0);
|
assert(split_len > 0);
|
||||||
|
@ -1504,9 +1481,9 @@ void map_setparent(struct vmproc *vmp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int physregions(struct vir_region *vr)
|
unsigned int physregions(struct vir_region *vr)
|
||||||
{
|
{
|
||||||
int n = 0;
|
unsigned int n = 0;
|
||||||
vir_bytes voffset;
|
vir_bytes voffset;
|
||||||
for(voffset = 0; voffset < vr->length; voffset += VM_PAGE_SIZE) {
|
for(voffset = 0; voffset < vr->length; voffset += VM_PAGE_SIZE) {
|
||||||
if(physblock_get(vr, voffset))
|
if(physblock_get(vr, voffset))
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct vir_region {
|
||||||
struct vmproc *parent; /* Process that owns this vir_region. */
|
struct vmproc *parent; /* Process that owns this vir_region. */
|
||||||
mem_type_t *def_memtype; /* Default instantiated memory type. */
|
mem_type_t *def_memtype; /* Default instantiated memory type. */
|
||||||
int remaps;
|
int remaps;
|
||||||
u32_t id; /* unique id */
|
int id; /* unique id */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
phys_bytes phys; /* VR_DIRECT */
|
phys_bytes phys; /* VR_DIRECT */
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#define SLABSIZES 200
|
#define SLABSIZES 200
|
||||||
|
|
||||||
#define ITEMSPERPAGE(bytes) (DATABYTES / (bytes))
|
#define ITEMSPERPAGE(bytes) (int)(DATABYTES / (bytes))
|
||||||
|
|
||||||
#define ELBITS (sizeof(element_t)*8)
|
#define ELBITS (sizeof(element_t)*8)
|
||||||
#define BITPAT(b) (1UL << ((b) % ELBITS))
|
#define BITPAT(b) (1UL << ((b) % ELBITS))
|
||||||
|
@ -128,12 +128,12 @@ static int objstats(void *, int, struct slabheader **, struct slabdata
|
||||||
**, int *);
|
**, int *);
|
||||||
|
|
||||||
#define GETSLAB(b, s) { \
|
#define GETSLAB(b, s) { \
|
||||||
int i; \
|
int _gsi; \
|
||||||
assert((b) >= MINSIZE); \
|
assert((b) >= MINSIZE); \
|
||||||
i = (b) - MINSIZE; \
|
_gsi = (b) - MINSIZE; \
|
||||||
assert((i) < SLABSIZES); \
|
assert((_gsi) < SLABSIZES); \
|
||||||
assert((i) >= 0); \
|
assert((_gsi) >= 0); \
|
||||||
s = &slabs[i]; \
|
s = &slabs[_gsi]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move slabdata nw to slabheader sl under list number l. */
|
/* move slabdata nw to slabheader sl under list number l. */
|
||||||
|
@ -156,7 +156,7 @@ static int objstats(void *, int, struct slabheader **, struct slabdata
|
||||||
if(next) { SLABDATAUSE(next, next->sdh.prev = prev;); } \
|
if(next) { SLABDATAUSE(next, next->sdh.prev = prev;); } \
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct slabdata *newslabdata()
|
static struct slabdata *newslabdata(void)
|
||||||
{
|
{
|
||||||
struct slabdata *n;
|
struct slabdata *n;
|
||||||
phys_bytes p;
|
phys_bytes p;
|
||||||
|
@ -457,6 +457,7 @@ void slabfree(void *mem, int bytes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MEMPROTECT
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* void *slablock *
|
* void *slablock *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -494,6 +495,7 @@ void slabunlock(void *mem, int bytes)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SANITYCHECKS
|
#if SANITYCHECKS
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "glo.h"
|
#include "glo.h"
|
||||||
|
|
||||||
#define ELEMENTS(a) (sizeof(a)/sizeof((a)[0]))
|
#define ELEMENTS(a) (int)(sizeof(a)/sizeof((a)[0]))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#define _SYSTEM 1
|
#define _SYSTEM 1
|
||||||
|
|
||||||
|
#define brk _brk /* get rid of no previous prototype warning */
|
||||||
|
|
||||||
#include <minix/callnr.h>
|
#include <minix/callnr.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/config.h>
|
#include <minix/config.h>
|
||||||
|
@ -80,14 +82,14 @@ struct memory *mem_chunks) /* store mem chunks here */
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* vm_isokendpt *
|
* vm_isokendpt *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
int vm_isokendpt(endpoint_t endpoint, int *proc)
|
int vm_isokendpt(endpoint_t endpoint, int *procn)
|
||||||
{
|
{
|
||||||
*proc = _ENDPOINT_P(endpoint);
|
*procn = _ENDPOINT_P(endpoint);
|
||||||
if(*proc < 0 || *proc >= NR_PROCS)
|
if(*procn < 0 || *procn >= NR_PROCS)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if(*proc >= 0 && endpoint != vmproc[*proc].vm_endpoint)
|
if(*procn >= 0 && endpoint != vmproc[*procn].vm_endpoint)
|
||||||
return EDEADEPT;
|
return EDEADEPT;
|
||||||
if(*proc >= 0 && !(vmproc[*proc].vm_flags & VMF_INUSE))
|
if(*procn >= 0 && !(vmproc[*procn].vm_flags & VMF_INUSE))
|
||||||
return EDEADEPT;
|
return EDEADEPT;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +293,7 @@ int minix_munmap(void * addr, size_t len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _brk(void *addr)
|
int brk(void *addr)
|
||||||
{
|
{
|
||||||
vir_bytes target = roundup((vir_bytes)addr, VM_PAGE_SIZE), v;
|
vir_bytes target = roundup((vir_bytes)addr, VM_PAGE_SIZE), v;
|
||||||
extern char _end;
|
extern char _end;
|
||||||
|
|
|
@ -36,7 +36,7 @@ static struct vfs_request_node {
|
||||||
char reqstate[STATELEN];
|
char reqstate[STATELEN];
|
||||||
void *opaque;
|
void *opaque;
|
||||||
endpoint_t who;
|
endpoint_t who;
|
||||||
u32_t req_id;
|
int req_id;
|
||||||
vfs_callback_t callback;
|
vfs_callback_t callback;
|
||||||
struct vfs_request_node *next;
|
struct vfs_request_node *next;
|
||||||
} *first_queued, *active;
|
} *first_queued, *active;
|
||||||
|
@ -53,6 +53,8 @@ static void activate(void)
|
||||||
panic("VM: asynsend to VFS failed");
|
panic("VM: asynsend to VFS failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ID_MAX LONG_MAX
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* vfs_request *
|
* vfs_request *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
|
@ -65,7 +67,7 @@ int vfs_request(int reqno, int fd, struct vmproc *vmp, u64_t offset, u32_t len,
|
||||||
* and then handle the reply as it if were a VM_VFS_REPLY request.
|
* and then handle the reply as it if were a VM_VFS_REPLY request.
|
||||||
*/
|
*/
|
||||||
message *m;
|
message *m;
|
||||||
static u32_t reqid = 0;
|
static int reqid = 0;
|
||||||
struct vfs_request_node *reqnode;
|
struct vfs_request_node *reqnode;
|
||||||
|
|
||||||
reqid++;
|
reqid++;
|
||||||
|
|
Loading…
Reference in a new issue