CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${ARCH}
CPPFLAGS+= -I${MINIXSRCDIR}
+.if ${CC} == gcc
+CFLAGS+= -Wall -Werror
+.endif
.include "arch/${ARCH}/Makefile.inc"
.include <bsd.prog.mk>
int holelist;
};
-static int startpages;
-
#define _NR_HOLES (_NR_PROCS*2) /* No. of memory holes maintained by VM */
* always on a click boundary. This procedure is called when memory is
* needed for FORK or EXEC.
*/
- register struct hole *hp, *prev_ptr;
- phys_clicks old_base, mem = NO_MEM, align_clicks = 0;
- int s;
+ phys_clicks mem = NO_MEM, align_clicks = 0;
if(memflags & PAF_ALIGN64K) {
align_clicks = (64 * 1024) / CLICK_SIZE;
*/
int i, first = 0;
register struct hole *hp;
- int nodes, largest;
/* Put all holes on the free list. */
for (hp = &hole[0]; hp < &hole[_NR_HOLES]; hp++) {
PUBLIC void memstats(int *nodes, int *pages, int *largest)
{
- pagerange_t *p, *prevp = NULL;
+ pagerange_t *p;
addr_iter iter;
addr_start_iter_least(&addravl, &iter);
*nodes = 0;
PUBLIC int do_deldma(message *msg)
{
endpoint_t req_proc_e, target_proc_e;
- int i, j, proc_n;
+ int i, j;
phys_bytes base, size;
- struct vmproc *vmp;
req_proc_e= msg->VMDD_REQ;
target_proc_e= msg->VMDD_EP;
*===========================================================================*/
PUBLIC int do_getdma(message *msg)
{
- endpoint_t target_proc_e;
- int i, proc_n;
- phys_bytes base, size;
- struct vmproc *vmp;
+ int i;
/* Find slot to report */
for (i= 0; i<NR_DMA; i++)
*===========================================================================*/
PUBLIC void release_dma(struct vmproc *vmp)
{
- int i, found_one;
-
- panic("release_dma not done");
#if 0
+ int i, found_one;
found_one= FALSE;
for (i= 0; i<NR_DMA; i++)
free_mem(base, size);
msg->VMRD_FOUND = found_one;
+#else
+ panic("release_dma not done");
#endif
return;
* between page-aligned BYTE offsets vmin and vmax, to fit
* a page in. Return byte offset.
*/
- u32_t freefound = 0, curv;
+ u32_t curv;
int pde = 0, try_restart;
static u32_t lastv = 0;
assert(level <= 2);
if(level > 1 || !(vmprocess->vm_flags & VMF_HASPT) || !meminit_done) {
- int r;
void *s;
s=vm_getsparepage(phys);
level--;
* the destination process in the range specified.
*/
int pde, pte;
- int r;
- vir_bytes viraddr, mapaddr;
+ vir_bytes viraddr;
pt_t *pt, *dst_pt;
pt = &src_vmp->vm_pt;
{
/* Write mapping into page table. Allocate a new page table if necessary. */
/* Page directory and table entries for this virtual address. */
- int p, r, pages;
+ int p, pages;
int verify = 0;
int ret = OK;
PUBLIC int pt_checkrange(pt_t *pt, vir_bytes v, size_t bytes,
int write)
{
- int p, pages, pde;
+ int p, pages;
assert(!(bytes % I386_PAGE_SIZE));
pages = bytes / I386_PAGE_SIZE;
for(p = 0; p < pages; p++) {
- u32_t entry;
int pde = I386_VM_PDE(v);
int pte = I386_VM_PTE(v);
u32_t moveup = 0;
int global_bit_ok = 0;
int free_pde;
- int p;
struct vm_ep_data ep_data;
vir_bytes sparepages_mem;
phys_bytes sparepages_ph;
/* Set up mappings for VM process. */
for(v = lo; v < hi; v += I386_PAGE_SIZE) {
- phys_bytes addr;
- u32_t flags;
-
/* We have to write the new position in the PT,
* so we can move our segments.
*/
*===========================================================================*/
PUBLIC int pt_bind(pt_t *pt, struct vmproc *who)
{
- int slot, ispt;
+ int slot;
u32_t phys;
void *pdes;
*===========================================================================*/
PUBLIC int pt_mapkernel(pt_t *pt)
{
- int r, i;
+ int i;
/* Any i386 page table needs to map in the kernel address space. */
assert(vmproc[VMP_SYSTEM].vm_flags & VMF_INUSE);
{
static char bufstr[100];
vir_bytes textstart = CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_phys);
- vir_bytes textend = textstart + CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_len);
vir_bytes datastart = CLICK2ABS(vmp->vm_arch.vm_seg[D].mem_phys);
vir_bytes textsegbase = CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_phys -
vmp->vm_arch.vm_seg[T].mem_vir);
** Version: 1.5 Author: Walt Karas
*/
+#include <string.h>
+
#undef L__
#undef L__EST_LONG_BIT
#undef L__SIZE
#undef L__MASK_HIGH_BIT
#undef L__LONG_BIT
#undef L__BIT_ARR_DEFN
+#undef L__BIT_ARR_CLEAR
#undef L__BIT_ARR_VAL
#undef L__BIT_ARR_0
#undef L__BIT_ARR_1
#define L__BIT_ARR_DEFN(NAME) unsigned long NAME[L__BIT_ARR_LONGS];
+#define L__BIT_ARR_CLEAR(NAME) memset(NAME, 0, sizeof(NAME));
+
#define L__BIT_ARR_VAL(BIT_ARR, BIT_NUM) \
((BIT_ARR)[(BIT_NUM) / L__LONG_BIT] & (1L << ((BIT_NUM) % L__LONG_BIT)))
#define L__BIT_ARR_DEFN(NAME) unsigned long NAME;
+#define L__BIT_ARR_CLEAR(NAME) NAME = 0;
+
#define L__BIT_ARR_VAL(BIT_ARR, BIT_NUM) ((BIT_ARR) & (1L << (BIT_NUM)))
#define L__BIT_ARR_0(BIT_ARR, BIT_NUM) (BIT_ARR) &= ~(1L << (BIT_NUM));
AVL_HANDLE hh = L__tree->root;
AVL_HANDLE parent = AVL_NULL;
int cmp;
+
+ L__BIT_ARR_CLEAR(branch)
do
{
AVL_HANDLE parent = AVL_NULL;
AVL_HANDLE child;
AVL_HANDLE path;
- int cmp, cmp_shortened_sub_with_path;
+ int cmp, cmp_shortened_sub_with_path = 0;
int reduced_depth;
int bf;
AVL_HANDLE rm;
AVL_HANDLE parent_rm;
+ L__BIT_ARR_CLEAR(branch)
+
for ( ; ; )
{
if (h == AVL_NULL)
{
AVL_HANDLE h = L__tree->root;
AVL_HANDLE parent = AVL_NULL;
- int cmp, last_cmp;
+ int cmp, last_cmp = 0;
/* Search for node already in tree with same key. */
for ( ; ; )
return(1);
}
+ L__BIT_ARR_CLEAR(branch)
+ L__BIT_ARR_CLEAR(rem)
+
for ( ; ; )
{
while (num_sub > 2)
#undef L__MASK_HIGH_BIT
#undef L__LONG_BIT
#undef L__BIT_ARR_DEFN
+#undef L__BIT_ARR_CLEAR
#undef L__BIT_ARR_VAL
#undef L__BIT_ARR_0
#undef L__BIT_ARR_1
vir_bytes stk_bytes, phys_bytes tot_bytes, vir_bytes *stack_top,
int is_elf));
-static int failcount;
-
/*===========================================================================*
* exec_newmem *
*===========================================================================*/
*/
vir_clicks text_clicks, data_clicks, gap_clicks, stack_clicks, tot_clicks;
- phys_bytes bytes, base, bss_offset;
- int s, r2, r, hadpt = 0;
+ int r, hadpt = 0;
struct vmproc *vmpold = &vmproc[VMP_EXECTMP];
int ptok = 1;
{
int s;
vir_bytes hole_bytes;
- int prealloc;
struct vir_region *reg;
phys_bytes map_text_addr, map_data_addr, map_stack_addr;
*===========================================================================*/
PUBLIC int do_fork(message *msg)
{
- int r, proc, s, childproc, fullvm;
+ int r, proc, childproc, fullvm;
struct vmproc *vmp, *vmc;
pt_t origpt;
vir_bytes msgaddr;
{
message msg;
int result, who_e, rcv_sts;
- sigset_t sigset;
int caller_slot;
struct vmproc *vmp_caller;
{
/* Initialize the vm server. */
int s, i;
- int click, clicksforgotten = 0;
struct memory mem_chunks[NR_MEMS];
struct boot_image image[NR_BOOT_PROCS];
struct boot_image *ip;
/* Give these processes their own page table. */
for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) {
- int s;
struct vmproc *vmp;
vir_bytes old_stacktop, old_stacklen;
return ENXIO;
if(m->VMM_FD == -1 || (m->VMM_FLAGS & MAP_ANON)) {
- int s;
- vir_bytes v;
u32_t vrflags = VR_ANON | VR_WRITABLE;
size_t len = (vir_bytes) m->VMM_LEN;
int dn, sn;
vir_bytes da, sa, startv;
size_t size;
- struct vir_region *vr, *region;
+ struct vir_region *region;
struct vmproc *dvmp, *svmp;
int r;
u32_t addr = m->VPF_ADDR;
u32_t err = m->VPF_FLAGS;
struct vmproc *vmp;
- int r, s;
+ int s;
struct vir_region *region;
vir_bytes offset;
ep, arch_map2str(vmp, addr), pf_errstr(err));
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
- if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
+ if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
ep, arch_map2vir(vmp, addr), pf_errstr(err));
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
- if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
+ if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
offset = addr - region->vaddr;
/* Access is allowed; handle it. */
- if((r=map_pf(vmp, region, offset, wr)) != OK) {
+ if((map_pf(vmp, region, offset, wr)) != OK) {
printf("VM: pagefault: SIGSEGV %d pagefault not handled\n", ep);
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
- if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
+ if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
/* Pagefault is handled, so now reactivate the process. */
- if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
+ if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
}
{
struct vir_region *region;
vir_bytes o;
- vir_bytes v;
/* Page-align memory and length. */
o = mem % VM_PAGE_SIZE;
PUBLIC int do_query_exit(message *m)
{
int i, nr;
- endpoint_t ep;
+ endpoint_t ep = NONE;
for (i = 0; i < NR_PROCS; i++) {
if (!array[i].avail) {
vir_bytes minv, vir_bytes maxv, vir_bytes length)
{
struct vir_region *firstregion;
- vir_bytes startv;
+ vir_bytes startv = 0;
int foundflag = 0;
region_iter iter;
{
struct vir_region *newregion;
vir_bytes startv;
- struct phys_region *ph;
physr_avl *phavl;
assert(!(length % VM_PAGE_SIZE));
PUBLIC void pb_unreferenced(struct vir_region *region, struct phys_region *pr)
{
struct phys_block *pb;
- int remap = 0;
pb = pr->ph;
assert(pb->refcount > 0);
PRIVATE int map_subfree(struct vmproc *vmp,
struct vir_region *region, vir_bytes len)
{
- struct phys_region *pr, *nextpr;
+ struct phys_region *pr;
physr_iter iter;
assert(!(sublen % VM_PAGE_SIZE));
assert(sublen < pr->ph->length);
if(pr->ph->refcount > 1) {
- int r;
if(!(pr = map_clone_ph_block(vmp, region,
pr, &iter)))
return ENOMEM;
if((ph = physr_search(region->phys, offset, AVL_LESS_EQUAL)) &&
(ph->offset <= offset && offset < ph->offset + ph->ph->length)) {
- phys_bytes blockoffset = ph->offset;
/* Pagefault in existing block. Do copy-on-write. */
assert(write);
assert(region->flags & VR_WRITABLE);
if(r2) { \
end = MIN(end, r2->offset); } \
if(start < end) { \
- int r; \
SANITYCHECK(SCL_DETAIL); \
if(map_new_physblock(vmp, region, start, \
end-start, MAP_NONE, PAF_CLEAR, 0) != OK) { \
{
vir_bytes end;
struct vir_region *nextvr;
- region_iter v_iter;
assert(vr);
assert(vr->flags & VR_ANON);
*===========================================================================*/
PRIVATE int split_phys(struct phys_region *pr, vir_bytes point)
{
- struct phys_region *newpr, *q, *prev;
+ struct phys_region *newpr, *q, *prev = NULL;
struct phys_block *newpb;
struct phys_block *pb = pr->ph;
/* Split the phys region into 2 parts by @point. */
prev = newpr;
}
}
+ assert(prev);
prev->next_ph_list = NULL;
return OK;
*/
struct vmproc *vms, *vmd;
struct vir_region *vrs, *vrd;
- physr_iter iterd;
vir_bytes offset_s, offset_d;
int p;
int r;
/* If it's mapped more than once, make a copy. */
assert(ph->ph->refcount > 0);
if(ph->ph->refcount > 1) {
- int r;
if(!(ph = map_clone_ph_block(vmp, region,
ph, NULL))) {
printf("VM: get_clean_phys_region: ph copy failed\n");
vir_bytes vaddr, vir_bytes len, yielded_t **retyb)
{
yielded_t *newyb;
- vir_bytes mem_clicks, newmem, clicks;
+ vir_bytes mem_clicks, clicks;
struct vir_region *region;
struct phys_region *ph;
yielded_avl *avl;
PUBLIC int do_yieldblockgetblock(message *m)
{
u64_t yieldid, getid;
- int n, get = 0;
+ int n;
endpoint_t caller = m->m_source;
struct vmproc *vmp;
yielded_t *yb = NULL;
endpoint_t src_e, dst_e, reply_e;
int src_p, dst_p;
struct vmproc *src_vmp, *dst_vmp;
- struct vir_region *vr;
int r;
src_e = m_ptr->VM_RS_SRC_ENDPT;
*===========================================================================*/
PRIVATE int rs_memctl_make_vm_instance(struct vmproc *new_vm_vmp)
{
- int vm_p, r;
+ int r;
u32_t flags;
int verify;
struct vmproc *this_vm_vmp;
}
#endif
+#if SANITYCHECKS
static int nojunkwarning = 0;
+#endif
/*===========================================================================*
* void *slaballoc *
i = i % ITEMSPERPAGE(bytes);
if(!GETBIT(firstused, i)) {
- struct slabdata *f;
char *ret;
SETBIT(firstused, i);
SLABSANITYCHECK(SCL_DETAIL);