Subversion Repositories HelenOS-historic

Rev

Rev 1757 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1757 Rev 1760
Line 132... Line 132...
132
         * can be more instantions of the same memory ELF image
132
         * can be more instantions of the same memory ELF image
133
         * used at a time. Note that this could be later done
133
         * used at a time. Note that this could be later done
134
         * as COW.
134
         * as COW.
135
         */
135
         */
136
        if (entry->p_flags & PF_W) {
136
        if (entry->p_flags & PF_W) {
137
            frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
137
            frame = (__address)frame_alloc(ONE_FRAME, 0);
138
            memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE);
138
            memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE);
139
           
139
           
140
            if (area->sh_info) {
140
            if (area->sh_info) {
141
                frame_reference_add(ADDR2PFN(frame));
141
                frame_reference_add(ADDR2PFN(frame));
142
                btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
142
                btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
Line 151... Line 151...
151
         * This is the uninitialized portion of the segment.
151
         * This is the uninitialized portion of the segment.
152
         * It is not physically present in the ELF image.
152
         * It is not physically present in the ELF image.
153
         * To resolve the situation, a frame must be allocated
153
         * To resolve the situation, a frame must be allocated
154
         * and cleared.
154
         * and cleared.
155
         */
155
         */
156
        frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
156
        frame = (__address)frame_alloc(ONE_FRAME, 0);
157
        memsetb(PA2KA(frame), FRAME_SIZE, 0);
157
        memsetb(PA2KA(frame), FRAME_SIZE, 0);
158
 
158
 
159
        if (area->sh_info) {
159
        if (area->sh_info) {
160
            frame_reference_add(ADDR2PFN(frame));
160
            frame_reference_add(ADDR2PFN(frame));
161
            btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
161
            btree_insert(&area->sh_info->pagemap, ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
Line 168... Line 168...
168
         * The mixed case.
168
         * The mixed case.
169
         * The lower part is backed by the ELF image and
169
         * The lower part is backed by the ELF image and
170
         * the upper part is anonymous memory.
170
         * the upper part is anonymous memory.
171
         */
171
         */
172
        size = entry->p_filesz - (i<<PAGE_WIDTH);
172
        size = entry->p_filesz - (i<<PAGE_WIDTH);
173
        frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));
173
        frame = (__address)frame_alloc(ONE_FRAME, 0);
174
        memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0);
174
        memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0);
175
        memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size);
175
        memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size);
176
 
176
 
177
        if (area->sh_info) {
177
        if (area->sh_info) {
178
            frame_reference_add(ADDR2PFN(frame));
178
            frame_reference_add(ADDR2PFN(frame));
Line 216... Line 216...
216
    if (page + PAGE_SIZE < ALIGN_UP(entry->p_vaddr + entry->p_filesz, PAGE_SIZE)) {
216
    if (page + PAGE_SIZE < ALIGN_UP(entry->p_vaddr + entry->p_filesz, PAGE_SIZE)) {
217
        if (entry->p_flags & PF_W) {
217
        if (entry->p_flags & PF_W) {
218
            /*
218
            /*
219
             * Free the frame with the copy of writable segment data.
219
             * Free the frame with the copy of writable segment data.
220
             */
220
             */
221
            frame_free(ADDR2PFN(frame));
221
            frame_free(frame);
222
        }
222
        }
223
    } else {
223
    } else {
224
        /*
224
        /*
225
         * The frame is either anonymous memory or the mixed case (i.e. lower
225
         * The frame is either anonymous memory or the mixed case (i.e. lower
226
         * part is backed by the ELF image and the upper is anonymous).
226
         * part is backed by the ELF image and the upper is anonymous).
227
         * In any case, a frame needs to be freed.
227
         * In any case, a frame needs to be freed.
228
         */
228
         */
229
        frame_free(ADDR2PFN(frame));
229
        frame_free(frame);
230
    }
230
    }
231
}
231
}
232
 
232
 
233
/** Share ELF image backed address space area.
233
/** Share ELF image backed address space area.
234
 *
234
 *