Subversion Repositories HelenOS-historic

Rev

Rev 1702 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <arch/mm/vhpt.h>
  2. #include <mm/frame.h>
  3. #include <print.h>
  4.  
  5.  
  6. static vhpt_entry_t* vhpt_base;
  7.  
  8. __address vhpt_set_up(void)
  9. {
  10.     vhpt_base=(vhpt_entry_t*) PA2KA(PFN2ADDR(frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA)));
  11.     if(!vhpt_base) panic("Kernel configured with VHPT but no memory for table.");
  12.     vhpt_invalidate_all();
  13.     return (__address) vhpt_base;
  14. }
  15.  
  16.  
  17. void vhpt_mapping_insert(__address va, asid_t asid, tlb_entry_t entry)
  18. {
  19.     region_register rr_save, rr;
  20.     index_t vrn;
  21.     rid_t rid;
  22.     __u64 tag;
  23.  
  24.     vhpt_entry_t *ventry;
  25.  
  26.  
  27.     vrn = va >> VRN_SHIFT;
  28.     rid = ASID2RID(asid, vrn);
  29.                                                                                                                
  30.   rr_save.word = rr_read(vrn);
  31.   rr.word = rr_save.word;
  32.   rr.map.rid = rid;
  33.   rr_write(vrn, rr.word);
  34.   srlz_i();
  35.    
  36.     ventry = (vhpt_entry_t *) thash(va);
  37.   tag = ttag(va);
  38.   rr_write(vrn, rr_save.word);
  39.   srlz_i();
  40.   srlz_d();
  41.  
  42.     ventry->word[0]=entry.word[0];
  43.     ventry->word[1]=entry.word[1];
  44.     ventry->present.tag.tag_word = tag;
  45.    
  46.  
  47. }
  48.  
  49. void vhpt_invalidate_all()
  50. {
  51.     memsetb((__address)vhpt_base,1<<VHPT_WIDTH,0);
  52. }
  53.  
  54. void vhpt_invalidate_asid(asid_t asid)
  55. {
  56.     vhpt_invalidate_all();
  57. }
  58.  
  59.  
  60.