Changeset 6843a9c in mainline for kernel/generic/src/mm/page.c
- Timestamp:
- 2012-06-29T13:02:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 722912e
- Parents:
- ba72f2b (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
rba72f2b r6843a9c 53 53 * We assume that the other processors are either not using the mapping yet 54 54 * (i.e. during the bootstrap) or are executing the TLB shootdown code. While 55 * we don't care much about the former case, the processors in the latter case 55 * we don't care much about the former case, the processors in the latter case 56 56 * will do an implicit serialization by virtue of running the TLB shootdown 57 57 * interrupt handler. … … 74 74 #include <syscall/copy.h> 75 75 #include <errno.h> 76 #include <align.h> 76 77 77 78 /** Virtual operations for page subsystem. */ … … 81 82 { 82 83 page_arch_init(); 83 }84 85 /** Map memory structure86 *87 * Identity-map memory structure88 * considering possible crossings89 * of page boundaries.90 *91 * @param addr Address of the structure.92 * @param size Size of the structure.93 *94 */95 void map_structure(uintptr_t addr, size_t size)96 {97 size_t length = size + (addr - (addr & ~(PAGE_SIZE - 1)));98 size_t cnt = length / PAGE_SIZE + (length % PAGE_SIZE > 0);99 100 size_t i;101 for (i = 0; i < cnt; i++)102 page_mapping_insert(AS_KERNEL, addr + i * PAGE_SIZE,103 addr + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);104 105 /* Repel prefetched accesses to the old mapping. */106 memory_barrier();107 84 } 108 85 … … 176 153 } 177 154 155 /** Make the mapping shared by all page tables (not address spaces). 156 * 157 * @param base Starting virtual address of the range that is made global. 158 * @param size Size of the address range that is made global. 159 */ 160 void page_mapping_make_global(uintptr_t base, size_t size) 161 { 162 ASSERT(page_mapping_operations); 163 ASSERT(page_mapping_operations->mapping_make_global); 164 165 return page_mapping_operations->mapping_make_global(base, size); 166 } 167 168 int page_find_mapping(uintptr_t virt, void **phys) 169 { 170 page_table_lock(AS, true); 171 172 pte_t *pte = page_mapping_find(AS, virt, false); 173 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 174 page_table_unlock(AS, true); 175 return ENOENT; 176 } 177 178 *phys = (void *) PTE_GET_FRAME(pte) + 179 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 180 181 page_table_unlock(AS, true); 182 183 return EOK; 184 } 185 178 186 /** Syscall wrapper for getting mapping of a virtual page. 179 * 180 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node 181 * contains correct values. 182 * @retval ENOENT Virtual address has no mapping. 183 */ 184 sysarg_t sys_page_find_mapping(uintptr_t virt_address, 185 uintptr_t *uspace_frame) 186 { 187 mutex_lock(&AS->lock); 188 189 pte_t *pte = page_mapping_find(AS, virt_address, false); 190 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 191 mutex_unlock(&AS->lock); 192 193 return (sysarg_t) ENOENT; 194 } 195 196 uintptr_t phys_address = PTE_GET_FRAME(pte); 197 198 mutex_unlock(&AS->lock); 199 200 int rc = copy_to_uspace(uspace_frame, 201 &phys_address, sizeof(phys_address)); 202 if (rc != EOK) { 203 return (sysarg_t) rc; 204 } 205 206 return EOK; 187 * 188 * @return EOK on success. 189 * @return ENOENT if no virtual address mapping found. 190 * 191 */ 192 sysarg_t sys_page_find_mapping(uintptr_t virt, void *phys_ptr) 193 { 194 void *phys; 195 int rc = page_find_mapping(virt, &phys); 196 if (rc != EOK) 197 return rc; 198 199 rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys)); 200 return (sysarg_t) rc; 207 201 } 208 202
Note:
See TracChangeset
for help on using the changeset viewer.