/*
    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_bootup.h,v $
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2994 $
    Last Date of Change:   $Date: 2007-03-30 22:30:57 +0200 (Fre, 30 Mär 2007) $  by: $Author: sryffel $
 
*/
#ifndef __VM_BOOTUP_H__
#define __VM_BOOTUP_H__
#include "vm.h"

struct vm_segmap
{
  struct vm_physmap *physmap; /* hint to the physmap, we need this to steal pages */
  int physcnt;
  address_t	text;
  size_t	textsize;
  address_t data;
  size_t	datasize;
  address_t bss;
  size_t	bsssize;
  address_t bootstackbottom; /* XXX probably not needed (see defines) */
  size_t bootstacksize;
  address_t optsegment;
  size_t optsegmentsize;
  int bootalloccnt;
  struct
  {
    address_t virt;
    address_t phys;
    size_t size;
    int type;
  }
  bootalloc[1];
};

typedef struct vm_segmap  *vm_segmap_ptr;


#define VM_TYPE_VM_STATIC 0x01 /* pmap and page structures */
#define VM_TYPE_HEAP			0x02 /* kernel heap */

struct vm_segmap* vm_init(address_t* mmStack, address_t* tmStack);

size_t vm_allocate_bootup_memory(struct vm_segmap* segmap, address_t* address, size_t size, int type);
void vm_print_segmap(struct vm_segmap* s);

/* HAL functions in vm_bootup_hal.c ... */
struct vm_pmap;

void vm_MMU_or_HELL(struct vm_pmap *vm_pmap);
int vm_get_physmap(struct vm_physmap **p);
struct vm_segmap* vm_get_segmap(struct vm_physmap* physmap, int physcnt);

/* ... and from various other places */
struct vm_pmap;

void vm_install_exception_handlers(void);
void km_boot_init(struct vm_segmap *segmap);
void steal_init(struct vm_pmap *vm_pmap, address_t start, int numpages);
void km_init(struct vm_segmap* segmap, struct vm_pmap* vm_pmap);

#endif
