~dannf/qemu-linaro/qemu-highbank-ppa

« back to all changes in this revision

Viewing changes to linux-user/mmap.c

  • Committer: Steve Langasek
  • Date: 2012-03-15 21:13:19 UTC
  • mfrom: (0.1.15)
  • Revision ID: steve.langasek@canonical.com-20120315211319-f1j3ot1ihx30b2s9
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
212
212
#else
213
213
# define TASK_UNMAPPED_BASE  0x40000000
214
214
#endif
215
 
static abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
 
215
abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;
216
216
 
217
217
unsigned long last_brk;
218
218
 
222
222
static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
223
223
{
224
224
    abi_ulong addr;
225
 
    abi_ulong last_addr;
 
225
    abi_ulong end_addr;
226
226
    int prot;
227
227
    int looped = 0;
228
228
 
230
230
        return (abi_ulong)-1;
231
231
    }
232
232
 
233
 
    last_addr = start;
234
 
    for (addr = start; last_addr + size != addr; addr += qemu_host_page_size) {
235
 
        if (last_addr + size >= RESERVED_VA
236
 
            || (abi_ulong)(last_addr + size) < last_addr) {
 
233
    size = HOST_PAGE_ALIGN(size);
 
234
    end_addr = start + size;
 
235
    if (end_addr > RESERVED_VA) {
 
236
        end_addr = RESERVED_VA;
 
237
    }
 
238
    addr = end_addr - qemu_host_page_size;
 
239
 
 
240
    while (1) {
 
241
        if (addr > end_addr) {
237
242
            if (looped) {
238
243
                return (abi_ulong)-1;
239
244
            }
240
 
            last_addr = qemu_host_page_size;
241
 
            addr = 0;
 
245
            end_addr = RESERVED_VA;
 
246
            addr = end_addr - qemu_host_page_size;
242
247
            looped = 1;
243
248
            continue;
244
249
        }
245
250
        prot = page_get_flags(addr);
246
251
        if (prot) {
247
 
            last_addr = addr + qemu_host_page_size;
248
 
        }
249
 
    }
250
 
    mmap_next_start = addr;
251
 
    return last_addr;
 
252
            end_addr = addr;
 
253
        }
 
254
        if (addr + size == end_addr) {
 
255
            break;
 
256
        }
 
257
        addr -= qemu_host_page_size;
 
258
    }
 
259
 
 
260
    if (start == mmap_next_start) {
 
261
        mmap_next_start = addr;
 
262
    }
 
263
 
 
264
    return addr;
252
265
}
253
266
#endif
254
267