Changeset 482826d in mainline
- Timestamp:
- 2006-05-31T16:23:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 39031cc
- Parents:
- 343fc179
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/include/mm/asid.h
r343fc179 r482826d 41 41 42 42 #define asid_get() (ASID_START+1) 43 #define asid_put(asid) 43 44 44 45 #endif -
genarch/src/mm/as_ht.c
r343fc179 r482826d 43 43 44 44 static pte_t *ht_create(int flags); 45 static void ht_destroy(pte_t *page_table); 45 46 46 47 static void ht_lock(as_t *as, bool lock); … … 49 50 as_operations_t as_ht_operations = { 50 51 .page_table_create = ht_create, 52 .page_table_destroy = ht_destroy, 51 53 .page_table_lock = ht_lock, 52 54 .page_table_unlock = ht_unlock, … … 70 72 } 71 73 return NULL; 74 } 75 76 /** Destroy page table. 77 * 78 * Actually do nothing as the global page hash table is used. 79 * 80 * @param page_table This parameter is ignored. 81 */ 82 void ht_destroy(pte_t *page_table) 83 { 84 /* No-op. */ 72 85 } 73 86 -
genarch/src/mm/as_pt.c
r343fc179 r482826d 45 45 46 46 static pte_t *ptl0_create(int flags); 47 static void ptl0_destroy(pte_t *page_table); 47 48 48 49 static void pt_lock(as_t *as, bool lock); … … 51 52 as_operations_t as_pt_operations = { 52 53 .page_table_create = ptl0_create, 54 .page_table_destroy = ptl0_destroy, 53 55 .page_table_lock = pt_lock, 54 56 .page_table_unlock = pt_unlock … … 95 97 } 96 98 99 /** Destroy page table. 100 * 101 * Destroy PTL0, other levels are expected to be already deallocated. 102 * 103 * @param page_table Physical address of PTL0. 104 */ 105 void ptl0_destroy(pte_t *page_table) 106 { 107 frame_free(ADDR2PFN((__address) page_table)); 108 } 109 97 110 /** Lock page tables. 98 111 * -
generic/include/mm/as.h
r343fc179 r482826d 76 76 mutex_t lock; 77 77 78 /** Number of references (i.e tasks that reference this as). */ 79 count_t refcount; 80 78 81 /** Number of processors on wich is this address space active. */ 79 82 count_t cpu_refcount; … … 91 94 struct as_operations { 92 95 pte_t *(* page_table_create)(int flags); 96 void (* page_table_destroy)(pte_t *page_table); 93 97 void (* page_table_lock)(as_t *as, bool lock); 94 98 void (* page_table_unlock)(as_t *as, bool unlock); … … 159 163 160 164 extern void as_init(void); 165 161 166 extern as_t *as_create(int flags); 167 extern void as_destroy(as_t *as); 168 extern void as_switch(as_t *old, as_t *new); 169 extern int as_page_fault(__address page, pf_access_t access, istate_t *istate); 170 162 171 extern as_area_t *as_area_create(as_t *as, int flags, size_t size, __address base, int attrs, 163 172 mem_backend_t *backend, mem_backend_data_t *backend_data); 173 extern int as_area_destroy(as_t *as, __address address); 164 174 extern int as_area_resize(as_t *as, __address address, size_t size, int flags); 165 extern int as_area_destroy(as_t *as, __address address); 175 int as_area_share(as_t *src_as, __address src_base, size_t acc_size, 176 as_t *dst_as, __address dst_base, int dst_flags_mask); 177 166 178 extern int as_area_get_flags(as_area_t *area); 167 179 extern bool as_area_check_access(as_area_t *area, pf_access_t access); 168 extern int as_page_fault(__address page, pf_access_t access, istate_t *istate);169 extern void as_switch(as_t *old, as_t *new);170 extern void as_free(as_t *as);171 int as_area_share(as_t *src_as, __address src_base, size_t acc_size,172 as_t *dst_as, __address dst_base, int dst_flags_mask);173 180 extern size_t as_get_size(__address base); 174 181 extern int used_space_insert(as_area_t *a, __address page, count_t count); -
generic/include/mm/page.h
r343fc179 r482826d 86 86 extern pte_t *page_mapping_find(as_t *as, __address page); 87 87 extern pte_t *page_table_create(int flags); 88 extern void page_table_destroy(pte_t *page_table); 88 89 extern void map_structure(__address s, size_t size); 89 90 extern __address hw_map(__address physaddr, size_t size); -
generic/include/proc/task.h
r343fc179 r482826d 57 57 58 58 /** 59 60 61 59 * Serializes access to the B+tree of task's futexes. This mutex is 60 * independent on the task spinlock. 61 */ 62 62 mutex_t futexes_lock; 63 63 btree_t futexes; /**< B+tree of futexes referenced by this task. */ -
generic/src/mm/as.c
r343fc179 r482826d 122 122 as->asid = ASID_INVALID; 123 123 124 as->refcount = 0; 124 125 as->cpu_refcount = 0; 125 126 as->page_table = page_table_create(flags); … … 128 129 } 129 130 130 /** Free Adress space */ 131 void as_free(as_t *as) 132 { 133 ASSERT(as->cpu_refcount == 0); 134 135 /* TODO: free as_areas and other resources held by as */ 136 /* TODO: free page table */ 131 /** Destroy adress space. 132 * 133 * When there are no tasks referencing this address space (i.e. its refcount is zero), 134 * the address space can be destroyed. 135 */ 136 void as_destroy(as_t *as) 137 { 138 ipl_t ipl; 139 bool cond; 140 141 ASSERT(as->refcount == 0); 142 143 /* 144 * Since there is no reference to this area, 145 * it is safe not to lock its mutex. 146 */ 147 148 ipl = interrupts_disable(); 149 spinlock_lock(&inactive_as_with_asid_lock); 150 if (as->asid != ASID_INVALID && as->asid != ASID_KERNEL) { 151 list_remove(&as->inactive_as_with_asid_link); 152 asid_put(as->asid); 153 } 154 spinlock_unlock(&inactive_as_with_asid_lock); 155 156 /* 157 * Destroy address space areas of the address space. 158 */ 159 for (cond = true; cond; ) { 160 btree_node_t *node; 161 162 ASSERT(!list_empty(&as->as_area_btree.leaf_head)); 163 node = list_get_instance(&as->as_area_btree.leaf_head.next, btree_node_t, leaf_link); 164 if ((cond = node->keys)) { 165 as_area_destroy(as, node->key[0]); 166 btree_remove(&as->as_area_btree, node->key[0], node); 167 } 168 } 169 170 page_table_destroy(as->page_table); 171 172 interrupts_restore(ipl); 173 137 174 free(as); 138 175 } … … 841 878 } 842 879 880 /** Destroy page table. 881 * 882 * Destroy page table in architecture specific way. 883 * 884 * @param page_table Physical address of PTL0. 885 */ 886 void page_table_destroy(pte_t *page_table) 887 { 888 ASSERT(as_operations); 889 ASSERT(as_operations->page_table_destroy); 890 891 as_operations->page_table_destroy(page_table); 892 } 893 843 894 /** Lock page table. 844 895 * -
generic/src/proc/task.c
r343fc179 r482826d 108 108 109 109 ipl = interrupts_disable(); 110 111 /* 112 * Increment address space reference count. 113 * TODO: Reconsider the locking scheme. 114 */ 115 mutex_lock(&as->lock); 116 as->refcount++; 117 mutex_unlock(&as->lock); 118 110 119 spinlock_lock(&tasks_lock); 111 120 … … 140 149 rc = elf_load((elf_header_t *) program_addr, as); 141 150 if (rc != EE_OK) { 142 as_ free(as);151 as_destroy(as); 143 152 return NULL; 144 153 }
Note:
See TracChangeset
for help on using the changeset viewer.