Advertisement
Guest User

Additions to addressspace.h

a guest
Apr 8th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.36 KB | None | 0 0
  1. #ifndef _ADDRSPACE_H_
  2. #define _ADDRSPACE_H_
  3.  
  4. #include <vm.h>
  5. #include "opt-dumbvm.h"
  6. #include <machine/spl.h>
  7.  
  8. #define PT_SIZE 1024
  9.  
  10. struct vnode;
  11.  
  12. /*
  13.  * Address space - data structure associated with the virtual memory
  14.  * space of a process.
  15.  *
  16.  * You write this.
  17.  */
  18.  
  19. struct as_pagetable{
  20.     u_int32_t PTE [PT_SIZE];
  21. };
  22.  
  23. struct as_region{
  24.     vaddr_t bottom_vm;
  25.     size_t npgs;
  26.     unsigned int region_permis;
  27.     unsigned int old_perm;
  28. };
  29.  
  30. struct addrspace {
  31. #if OPT_DUMBVM
  32.     vaddr_t as_vbase1;
  33.     paddr_t as_pbase1;
  34.     size_t as_npages1;
  35.     vaddr_t as_vbase2;
  36.     paddr_t as_pbase2;
  37.     size_t as_npages2;
  38.     paddr_t as_stackpbase;
  39. #else
  40.     /* Put stuff here for your VM system */
  41.     struct array* as_regions;
  42.     u_int32_t permissions;
  43.     vaddr_t start_heap; // user heap start
  44.     vaddr_t end_heap; // user heap end
  45.     paddr_t as_stackpbase; // necessary?
  46.     struct vnode *vm_obj; // needed?
  47.     // vaddr_t as_vbase1;
  48.     struct as_pagetable *as_ptes[PT_SIZE];
  49. #endif
  50. };
  51.  
  52. /*
  53.  * Functions in addrspace.c:
  54.  *
  55.  *    as_create - create a new empty address space. You need to make
  56.  *                sure this gets called in all the right places. You
  57.  *                may find you want to change the argument list. May
  58.  *                return NULL on out-of-memory error.
  59.  *
  60.  *    as_copy   - create a new address space that is an exact copy of
  61.  *                an old one. Probably calls as_create to get a new
  62.  *                empty address space and fill it in, but that's up to
  63.  *                you.
  64.  *
  65.  *    as_activate - make the specified address space the one currently
  66.  *                "seen" by the processor. Argument might be NULL,
  67.  *        meaning "no particular address space".
  68.  *
  69.  *    as_destroy - dispose of an address space. You may need to change
  70.  *                the way this works if implementing user-level threads.
  71.  *
  72.  *    as_define_region - set up a region of memory within the address
  73.  *                space.
  74.  *
  75.  *    as_prepare_load - this is called before actually loading from an
  76.  *                executable into the address space.
  77.  *
  78.  *    as_complete_load - this is called when loading from an executable
  79.  *                is complete.
  80.  *
  81.  *    as_define_stack - set up the stack region in the address space.
  82.  *                (Normally called *after* as_complete_load().) Hands
  83.  *                back the initial stack pointer for the new process.
  84.  */
  85.  
  86. struct addrspace *as_create(void);
  87. int               as_copy(struct addrspace *src, struct addrspace **ret);
  88. void              as_activate(struct addrspace *);
  89. void              as_destroy(struct addrspace *);
  90.  
  91. int               as_define_region(struct addrspace *as,
  92.                    vaddr_t vaddr, size_t sz,
  93.                    int readable,
  94.                    int writeable,
  95.                    int executable);
  96. int       as_prepare_load(struct addrspace *as);
  97. int       as_complete_load(struct addrspace *as);
  98. int               as_define_stack(struct addrspace *as, vaddr_t *initstackptr);
  99.  
  100. /*
  101.  * Functions in loadelf.c
  102.  *    load_elf - load an ELF user program executable into the current
  103.  *               address space. Returns the entry point (initial PC)
  104.  *               in the space pointed to by ENTRYPOINT.
  105.  */
  106.  
  107. int load_elf(struct vnode *v, vaddr_t *entrypoint);
  108.  
  109.  
  110. #endif /* _ADDRSPACE_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement