Beispiel #1
0
void
read_swap_into_page (struct page_table_entry *pte, void *pg) {
  int i;
  size_t swap_sector_idx = pte->swap_location.swap_index;
  for (i = 0; i < SECTORS_PER_SWAP; i++) {
    block_read (swap_partition, swap_sector_idx + i, pg);
    pg += BLOCK_SECTOR_SIZE;
  }

  free_swap_slot (swap_sector_idx); 
}
Beispiel #2
0
void pt_cleanup(int pid) {
    assert(pid > 0 && pid <= MAX_PROCESSES);
    //free all the pages + revoke/delete the corresponding cap 
    //9242_TODO unmark swapped out pages
    printf("Starting pt_cleanup\n");
    seL4_Word** pd = proc_table[pid]->page_directory;
    seL4_ARM_PageTable **ct = proc_table[pid]->cap_table;
    if (pd) {
        for (int i = 0; i < PD_MAX_ENTRIES; i++) {
            if (pd[i]) {
                for (int j = 0; j < PT_MAX_ENTRIES; j++) {
                    if (pd[i][j]) {
                        if (pd[i][j] & SWAPPED) {
                            printf("freeing a swap slot: %d\n", pd[i][j] & SWAP_SLOT_MASK);
                            free_swap_slot(pd[i][j] & SWAP_SLOT_MASK); 
                        } else {
                            int index = pd[i][j] & FRAME_INDEX_MASK;
                            int page_pid = (frametable[index].frame_status & PROCESS_MASK) >> PROCESS_BIT_SHIFT;
                            //if (page_pid == pid) {
                            printf("page_pid = %d, pid = %d\n", page_pid, pid);
                            frame_free(index);
                            //} 
                        }
                    }
                }
                frame_free(vaddr_to_index((seL4_Word) pd[i]));
            }
        }
        frame_free(vaddr_to_index((seL4_Word) pd));
    }

    //free the cap table 
    if (ct) {
        for (int i = 0; i < CAP_TABLE_PAGES; i++) {
            for (int j = 0; j < CT_MAX_ENTRIES; j++) {
                if ((seL4_Word) ct[i][j]) {
                    seL4_ARM_Page_Unmap(ct[i][j]);
                }
            }
            frame_free(vaddr_to_index((seL4_Word) ct[i])); 
        }
    }
    printf("pt cleanup ended\n");
}