#include "../../kernel/config.h"
#include "../../kernel/type.h"
-#include <sys/vm.h>
-
#include "assert.h"
#define NR_DEVS 6 /* number of minor devices */
dv->dv_size = cvul64(ramdev_size);
break;
}
- case MIOCMAP:
- case MIOCUNMAP: {
- int r, do_map;
- struct mapreq mapreq;
-
- if (m_device != MEM_DEV)
- return ENOTTY;
-
- do_map= (m_ptr->REQUEST == MIOCMAP); /* else unmap */
-
- /* Get request structure */
- r= sys_vircopy(m_ptr->PROC_NR, D, (vir_bytes)m_ptr->ADDRESS,
- SELF, D, (vir_bytes)&mapreq, sizeof(mapreq));
- if (r != OK)
- return r;
- r= sys_vm_map(m_ptr->PROC_NR, do_map,
- (phys_bytes)mapreq.base, mapreq.size, mapreq.offset);
- return r;
- }
default:
return(do_diocntl(&m_dtab, m_ptr));
# define SYS_GETINFO (KERNEL_CALL + 26) /* sys_getinfo() */
# define SYS_ABORT (KERNEL_CALL + 27) /* sys_abort() */
# define SYS_IOPENABLE (KERNEL_CALL + 28) /* sys_enable_iop() */
-# define SYS_VM_SETBUF (KERNEL_CALL + 29) /* sys_vm_setbuf() */
-# define SYS_VM_MAP (KERNEL_CALL + 30) /* sys_vm_map() */
-#define NR_SYS_CALLS 31 /* number of system calls */
+#define NR_SYS_CALLS 29 /* number of system calls */
/* Field names for SYS_MEMSET, SYS_SEGCTL. */
#define MEM_PTR m2_p1 /* base */
_PROTOTYPE( int sys_nice, (int proc, int priority));
_PROTOTYPE( int sys_int86, (struct reg86u *reg86p));
-_PROTOTYPE( int sys_vm_setbuf, (phys_bytes base, phys_bytes size,
- phys_bytes high));
-_PROTOTYPE( int sys_vm_map, (int proc_nr, int do_map,
- phys_bytes base, phys_bytes size, phys_bytes offset));
/* Shorthands for sys_sdevio() system call. */
#define sys_insb(port, proc_nr, buffer, count) \
#include <minix/ioctl.h>
#define MIOCRAMSIZE _IOW('m', 3, u32_t)
-#define MIOCMAP _IOR('m', 4, struct mapreq)
-#define MIOCUNMAP _IOR('m', 5, struct mapreq)
#endif /* _S_I_MEMORY_H */
+++ /dev/null
-/*
-sys/vm.h
-*/
-
-#define PAGE_SIZE 4096
-
-/* MIOCMAP */
-struct mapreq
-{
- void *base;
- size_t size;
- off_t offset;
- int readonly;
-};
-
-/* i386 paging constants */
-#define I386_VM_PRESENT 0x001 /* Page is present */
-#define I386_VM_WRITE 0x002 /* Read/write access allowed */
-#define I386_VM_USER 0x004 /* User access allowed */
-#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
-
-#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
-#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
-#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
-#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
-#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
-
-#define I386_CR0_PG 0x80000000 /* Enable paging */
EXTERN int mon_return; /* true if we can return to monitor */
EXTERN int do_serial_debug;
-/* VM */
-EXTERN phys_bytes vm_base;
-EXTERN phys_bytes vm_size;
-EXTERN phys_bytes vm_mem_high;
-
/* Variables that are initialized elsewhere are just extern here. */
extern struct boot_image image[]; /* system image processes */
extern char *t_stack[]; /* task stack space */
_PROTOTYPE( void enable_iop, (struct proc *pp) );
_PROTOTYPE( void alloc_segments, (struct proc *rp) );
-/* system/do_vm.c */
-_PROTOTYPE( void vm_map_default, (struct proc *pp) );
-
#endif /* (CHIP == INTEL) */
#if (CHIP == M68000)
map(SYS_NEWMAP, do_newmap); /* set up a process memory map */
map(SYS_SEGCTL, do_segctl); /* add segment and get selector */
map(SYS_MEMSET, do_memset); /* write char to memory area */
- map(SYS_VM_SETBUF, do_vm_setbuf); /* PM passes buffer for page tables */
- map(SYS_VM_MAP, do_vm_map); /* Map/unmap physical (device) memory */
/* Copying. */
map(SYS_UMAP, do_umap); /* map virtual to physical address */
#define do_memset do_unused
#endif
-_PROTOTYPE( int do_vm_setbuf, (message *m_ptr) );
-_PROTOTYPE( int do_vm_map, (message *m_ptr) );
-
_PROTOTYPE( int do_abort, (message *m_ptr) );
#if ! USE_ABORT
#define do_abort do_unused
$(SYSTEM)(do_sigreturn.o) \
$(SYSTEM)(do_abort.o) \
$(SYSTEM)(do_getinfo.o) \
- $(SYSTEM)(do_iopenable.o) \
- $(SYSTEM)(do_vm.o) \
- $(SYSTEM)(do_vm_setbuf.o) \
+ $(SYSTEM)(do_iopenable.o)
$(SYSTEM): $(OBJECTS)
aal cr $@ *.o
$(SYSTEM)(do_iopenable.o): do_iopenable.c
$(CC) do_iopenable.c
-
-$(SYSTEM)(do_vm.o): do_vm.o
-do_vm.o: do_vm.c
- $(CC) do_vm.c
-
-$(SYSTEM)(do_vm_setbuf.o): do_vm_setbuf.c
- $(CC) do_vm_setbuf.c
irq_hooks[i].proc_nr = NONE; /* mark hook as free */
}
}
-
- /* Clean up virtual memory */
- if (rc->p_misc_flags & MF_VM)
- vm_map_default(rc);
}
#endif /* USE_EXIT */
+++ /dev/null
-/* The system call implemented in this file:
- * m_type: SYS_VM_MAP
- *
- * The parameters for this system call are:
- * m4_l1: Process that requests map
- * m4_l2: Map (TRUE) or unmap (FALSE)
- * m4_l3: Base address
- * m4_l4: Size
- * m4_l5: Memory address
- */
-#include "../system.h"
-
-#include <sys/vm.h>
-
-PRIVATE int vm_needs_init= 1;
-PRIVATE u32_t vm_cr3;
-
-FORWARD _PROTOTYPE( void vm_init, (void) );
-FORWARD _PROTOTYPE( void phys_put32, (phys_bytes addr, u32_t value) );
-FORWARD _PROTOTYPE( u32_t phys_get32, (phys_bytes addr) );
-FORWARD _PROTOTYPE( void vm_set_cr3, (u32_t value) );
-FORWARD _PROTOTYPE( void set_cr3, (void) );
-FORWARD _PROTOTYPE( void vm_enable_paging, (void) );
-FORWARD _PROTOTYPE( void map_range, (u32_t base, u32_t size,
- u32_t offset) );
-
-#define VM_DEBUG 0 /* enable/ disable debug output */
-
-/*===========================================================================*
- * do_vm_setbuf *
- *===========================================================================*/
-PUBLIC int do_vm_map(m_ptr)
-message *m_ptr; /* pointer to request message */
-{
- int proc_nr, do_map;
- phys_bytes base, size, offset, p_phys;
- struct proc *pp;
-
- /* do_serial_debug= 1; */
-
-#if VM_DEBUG
- kprintf("in do_vm_map\n");
-#endif
-
- if (vm_needs_init)
- {
- vm_needs_init= 0;
- vm_init();
- }
-
- proc_nr= m_ptr->m4_l1;
- do_map= m_ptr->m4_l2;
- base= m_ptr->m4_l3;
- size= m_ptr->m4_l4;
- offset= m_ptr->m4_l5;
-
- pp= proc_addr(proc_nr);
- p_phys= umap_local(pp, D, base, size);
- if (p_phys == 0)
- return EFAULT;
-#if VM_DEBUG
- kprintf("got 0x%x for 0x%x [D].mem_start = 0x%x\n",
- p_phys, base, pp->p_memmap[D].mem_phys);
-#endif
-
- if (do_map)
- {
-#if VM_DEBUG
- kprintf(
- "do_vm_map: mapping 0x%x @ 0x%x to 0x%x @ proc %d\n",
- size, offset, base, proc_nr);
-#endif
- pp->p_misc_flags |= MF_VM;
-
- map_range(p_phys, size, offset);
- }
- else
- {
- map_range(p_phys, size, p_phys);
- }
- vm_set_cr3(vm_cr3);
-
- return OK;
-}
-
-/*===========================================================================*
- * vm_map_default *
- *===========================================================================*/
-PUBLIC void vm_map_default(pp)
-struct proc *pp;
-{
- phys_bytes base_clicks, size_clicks;
-
- if (vm_needs_init)
- panic("vm_map_default: VM not initialized?", NO_NUM);
- pp->p_misc_flags &= ~MF_VM;
- base_clicks= pp->p_memmap[D].mem_phys;
- size_clicks= pp->p_memmap[S].mem_phys+pp->p_memmap[S].mem_len -
- base_clicks;
- map_range(base_clicks << CLICK_SHIFT, size_clicks << CLICK_SHIFT,
- base_clicks << CLICK_SHIFT);
- vm_set_cr3(vm_cr3);
-}
-
-PRIVATE void vm_init(void)
-{
- int o;
- phys_bytes p, pt_size;
- phys_bytes vm_dir_base, vm_pt_base, phys_mem;
- u32_t entry;
- unsigned pages;
-
-#if VM_DEBUG
- kprintf("in vm_init\n");
- kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
- if (!vm_size)
- panic("vm_init: no space for page tables", NO_NUM);
-
- /* Align page directory */
- o= (vm_base % PAGE_SIZE);
- if (o != 0)
- o= PAGE_SIZE-o;
- vm_dir_base= vm_base+o;
-
- /* Page tables start after the page directory */
- vm_pt_base= vm_dir_base+PAGE_SIZE;
-
- pt_size= (vm_base+vm_size)-vm_pt_base;
- pt_size -= (pt_size % PAGE_SIZE);
-
- /* Compute the number of pages based on vm_mem_high */
- pages= (vm_mem_high-1)/PAGE_SIZE + 1;
-
- if (pages * I386_VM_PT_ENT_SIZE > pt_size)
- panic("vm_init: page table too small", NO_NUM);
-
-#if VM_DEBUG
- kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
-
- for (p= 0; p*I386_VM_PT_ENT_SIZE < pt_size; p++)
- {
- phys_mem= p*PAGE_SIZE;
- entry= phys_mem | I386_VM_USER | I386_VM_WRITE |
- I386_VM_PRESENT;
- if (phys_mem >= vm_mem_high)
- entry= 0;
- phys_put32(vm_pt_base + p*I386_VM_PT_ENT_SIZE, entry);
- }
-
- for (p= 0; p < I386_VM_DIR_ENTRIES; p++)
- {
- phys_mem= vm_pt_base + p*PAGE_SIZE;
- entry= phys_mem | I386_VM_USER | I386_VM_WRITE |
- I386_VM_PRESENT;
- if (phys_mem >= vm_pt_base + pt_size)
- entry= 0;
- phys_put32(vm_dir_base + p*I386_VM_PT_ENT_SIZE, entry);
- }
-#if VM_DEBUG
- kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
- vm_set_cr3(vm_dir_base);
- level0(vm_enable_paging);
-}
-
-PRIVATE void phys_put32(addr, value)
-phys_bytes addr;
-u32_t value;
-{
-#if VM_DEBUG
-kprintf("%s, %d: %d bytes from 0x%x to 0x%x\n", __FILE__, __LINE__,
- sizeof(value), vir2phys((vir_bytes)&value), addr);
-#endif
-
- phys_copy(vir2phys((vir_bytes)&value), addr, sizeof(value));
-}
-
-PRIVATE u32_t phys_get32(addr)
-phys_bytes addr;
-{
- u32_t value;
-
- phys_copy(addr, vir2phys((vir_bytes)&value), sizeof(value));
-
- return value;
-}
-
-PRIVATE void vm_set_cr3(value)
-u32_t value;
-{
-#if VM_DEBUG
-kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
- vm_cr3= value;
-#if VM_DEBUG
-kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
- level0(set_cr3);
-#if VM_DEBUG
-kprintf("%s, %d\n", __FILE__, __LINE__);
-#endif
-}
-
-PRIVATE void set_cr3()
-{
- write_cr3(vm_cr3);
-}
-
-PRIVATE void vm_enable_paging(void)
-{
- u32_t cr0;
-
- cr0= read_cr0();
- write_cr0(cr0 | I386_CR0_PG);
-}
-
-PRIVATE void map_range(base, size, offset)
-u32_t base;
-u32_t size;
-u32_t offset;
-{
- u32_t curr_pt, curr_pt_addr, entry;
- int dir_ent, pt_ent;
-
- if (base % PAGE_SIZE != 0)
- panic("map_range: bad base", base);
- if (size % PAGE_SIZE != 0)
- panic("map_range: bad size", size);
- if (offset % PAGE_SIZE != 0)
- panic("map_range: bad offset", offset);
-
- curr_pt= -1;
- curr_pt_addr= 0;
- while (size != 0)
- {
- dir_ent= (base >> I386_VM_DIR_ENT_SHIFT);
- pt_ent= (base >> I386_VM_PT_ENT_SHIFT) & I386_VM_PT_ENT_MASK;
- if (dir_ent != curr_pt)
- {
- /* Get address of page table */
- curr_pt= dir_ent;
- curr_pt_addr= phys_get32(vm_cr3 +
- dir_ent * I386_VM_PT_ENT_SIZE);
- curr_pt_addr &= I386_VM_ADDR_MASK;
-#if VM_DEBUG
- kprintf("got address 0x%x for page table 0x%x\n",
- curr_pt_addr, curr_pt);
-#endif
- }
- entry= offset | I386_VM_USER | I386_VM_WRITE |
- I386_VM_PRESENT;
-#if VM_DEBUG
- kprintf(
- "putting 0x%x at dir_ent 0x%x, pt_ent 0x%x (addr 0x%x)\n",
- entry, dir_ent, pt_ent,
- curr_pt_addr + pt_ent * I386_VM_PT_ENT_SIZE);
-#endif
- phys_put32(curr_pt_addr + pt_ent * I386_VM_PT_ENT_SIZE, entry);
- offset += PAGE_SIZE;
- base += PAGE_SIZE;
- size -= PAGE_SIZE;
- }
-}
+++ /dev/null
-/* The system call implemented in this file:
- * m_type: SYS_VM_SETBUF
- *
- * The parameters for this system call are:
- * m4_l1: Start of the buffer
- * m4_l2: Length of the buffer
- * m4_l3: End of main memory
- */
-#include "../system.h"
-
-#define VM_DEBUG 0 /* enable/ disable debug output */
-
-/*===========================================================================*
- * do_vm_setbuf *
- *===========================================================================*/
-PUBLIC int do_vm_setbuf(m_ptr)
-message *m_ptr; /* pointer to request message */
-{
- vm_base= m_ptr->m4_l1;
- vm_size= m_ptr->m4_l2;
- vm_mem_high= m_ptr->m4_l3;
-
-#if VM_DEBUG
- kprintf("do_vm_setbuf: got 0x%x @ 0x%x for 0x%x\n",
- vm_size, vm_base, vm_mem_high);
-#endif
-
- return OK;
-}
#define FS_C (c(SYS_KILL) | c(SYS_VIRCOPY) | c(SYS_VIRVCOPY) | c(SYS_UMAP) | c(SYS_GETINFO) | c(SYS_EXIT) | c(SYS_TIMES) | c(SYS_SETALARM))
#define DRV_C (FS_C | c(SYS_SEGCTL) | c(SYS_IRQCTL) | c(SYS_INT86) | c(SYS_DEVIO) | c(SYS_VDEVIO) | c(SYS_SDEVIO))
#define TTY_C (DRV_C | c(SYS_ABORT))
-#define MEM_C (DRV_C | c(SYS_PHYSCOPY) | c(SYS_PHYSVCOPY) | c(SYS_VM_MAP))
+#define MEM_C (DRV_C | c(SYS_PHYSCOPY) | c(SYS_PHYSVCOPY))
/* The system image table lists all programs that are part of the boot image.
* The order of the entries here MUST agree with the order of the programs
sys_voutl.o \
sys_setalarm.o \
sys_memset.o \
- taskcall.o \
- sys_vm_setbuf.o \
- sys_vm_map.o \
+ taskcall.o
include ../Makefile.inc
+++ /dev/null
-#include "syslib.h"
-
-/*===========================================================================*
- * sys_vm_map *
- *===========================================================================*/
-PUBLIC int sys_vm_map(proc_nr, do_map, base, size, offset)
-int proc_nr;
-int do_map;
-phys_bytes base;
-phys_bytes size;
-phys_bytes offset;
-{
- message m;
- int result;
-
- m.m4_l1= proc_nr;
- m.m4_l2= do_map;
- m.m4_l3= base;
- m.m4_l4= size;
- m.m4_l5= offset;
-
- result = _taskcall(SYSTASK, SYS_VM_MAP, &m);
- return(result);
-}
-
+++ /dev/null
-#include "syslib.h"
-
-/*===========================================================================*
- * sys_vm_setbuf *
- *===========================================================================*/
-PUBLIC int sys_vm_setbuf(base, size, high)
-phys_bytes base;
-phys_bytes size;
-phys_bytes high;
-{
- message m;
- int result;
-
- m.m4_l1= base;
- m.m4_l2= size;
- m.m4_l3= high;
-
- result = _taskcall(SYSTASK, SYS_VM_SETBUF, &m);
- return(result);
-}
-
FORWARD _PROTOTYPE( void get_mem_chunks, (struct memory *mem_chunks) );
FORWARD _PROTOTYPE( void patch_mem_chunks, (struct memory *mem_chunks,
struct mem_map *map_ptr) );
-FORWARD _PROTOTYPE( void do_x86_vm, (struct memory mem_chunks[NR_MEMS]) );
#define click_to_round_k(n) \
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
}
#endif /* ENABLE_BOOTDEV */
- /* Withhold some memory from x86 VM */
- do_x86_vm(mem_chunks);
-
/* Initialize tables to all physical memory and print memory information. */
printf("Physical memory:");
mem_init(mem_chunks, &free_clicks);
}
}
-#define PAGE_SIZE 4096
-#define PAGE_TABLE_COVER (1024*PAGE_SIZE)
-/*=========================================================================*
- * do_x86_vm *
- *=========================================================================*/
-PRIVATE void do_x86_vm(mem_chunks)
-struct memory mem_chunks[NR_MEMS];
-{
- phys_bytes high, bytes;
- phys_clicks clicks, base_click;
- unsigned pages;
- int i, r;
-
- /* Compute the highest memory location */
- high= 0;
- for (i= 0; i<NR_MEMS; i++)
- {
- if (mem_chunks[i].size == 0)
- continue;
- if (mem_chunks[i].base + mem_chunks[i].size > high)
- high= mem_chunks[i].base + mem_chunks[i].size;
- }
-
- high <<= CLICK_SHIFT;
-#if VERBOSE_VM
- printf("do_x86_vm: found high 0x%x\n", high);
-#endif
-
- /* The number of pages we need is one for the page directory, enough
- * page tables to cover the memory, and one page for alignement.
- */
- pages= 1 + (high + PAGE_TABLE_COVER-1)/PAGE_TABLE_COVER + 1;
- bytes= pages*PAGE_SIZE;
- clicks= (bytes + CLICK_SIZE-1) >> CLICK_SHIFT;
-
-#if VERBOSE_VM
- printf("do_x86_vm: need %d pages\n", pages);
- printf("do_x86_vm: need %d bytes\n", bytes);
- printf("do_x86_vm: need %d clicks\n", clicks);
-#endif
-
- for (i= 0; i<NR_MEMS; i++)
- {
- if (mem_chunks[i].size <= clicks)
- continue;
- break;
- }
- if (i >= NR_MEMS)
- panic("PM", "not enough memory for VM page tables?", NO_NUM);
- base_click= mem_chunks[i].base;
- mem_chunks[i].base += clicks;
- mem_chunks[i].size -= clicks;
-
-#if VERBOSE_VM
- printf("do_x86_vm: using 0x%x clicks @ 0x%x\n", clicks, base_click);
-#endif
- r= sys_vm_setbuf(base_click << CLICK_SHIFT, clicks << CLICK_SHIFT,
- high);
- if (r != 0)
- printf("do_x86_vm: sys_vm_setbuf failed: %d\n", r);
-}
mount $TMPDISK2 $RELEASEDIR/tmp
echo " * Zeroing $TMPDISK"
-dd if=/dev/zero of=$TMPDISK bs=$BS count=$USRBLOCKS
+#dd if=/dev/zero of=$TMPDISK bs=$BS count=$USRBLOCKS
mkfs -B $BS -b $USRBLOCKS $TMPDISK || exit
echo " * Mounting $TMPDISK as $RELEASEDIR/usr"
mount $TMPDISK $RELEASEDIR/usr || exit