/*
    Copyright 2001 (c) by Claudio Jeker,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public 
    Licence. A full copy of the GNU GPL is provided in the file COPYING 
    found in the development root of Topsy.
*/
/*
	
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/VMemory/Attic/vm_calls.h,v $
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $  by: $Author: baderma $
 
*/
/* XXX XXX XXX XXX LOCKING XXX LOCKING XXX XXX XXX XXX */
/* XXX XXX XXX XXX XXX UPDATE HINT XXX XXX XXX XXX XXX */
#ifndef __VM_CALLS_H__
#define __VM_CALLS_H__

int vm_region_add(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                  RegionPtr_t region);
int vm_region_add_near(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                       RegionPtr_t region, address_t hint, int direction);

/* this function is only used during bootup to map the kernel memory */
int vm_region_map(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                  RegionPtr_t region, address_t start, address_t end, address_t phys);

int vm_region_free(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                   RegionPtr_t region);
int vm_region_free_all(struct vm_map* vm_map, struct vm_pmap* vm_pmap);

int vm_region_resize(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                     RegionPtr_t old, RegionPtr_t new);

int vm_region_share(
  struct vm_map* source_map, struct vm_pmap* source_pmap, RegionPtr_t source,
  struct vm_map* dest_map, struct vm_pmap* dest_pmap, RegionPtr_t dest,
  int flags);
int vm_region_share_near(
  struct vm_map* source_map, struct vm_pmap* source_pmap, RegionPtr_t source,
  struct vm_map* dest_map, struct vm_pmap* dest_pmap, address_t* hint,
  int flags, int direction);

int vm_region_chprot(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                     RegionPtr_t region, unsigned int cur, unsigned int max);

int vm_region_get(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                  address_t hint, RegionPtr_t region);

int vm_region_lookup(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                     address_t addr, int type);

/* loan out functions */
int vm_region_set_loan(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                       RegionPtr_t region, RegionPtr_t old);
int vm_region_loan_alloc(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                         address_t* pagestart, int flags);
int vm_region_loan_dealloc(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                           address_t pagestart);
int vm_region_loan_out(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                       address_t pagestart, struct vm_page** vm_page_ptr);
int vm_region_loan_in(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                      address_t* pagestart, struct vm_page* vm_page);

void vm_region_print_map(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                         int flags);
void vm_region_print_region(struct vm_map* vm_map, struct vm_pmap* vm_pmap,
                            struct vm_region* r, char* s, int flags);

#endif
