process.cc (8794:e2ac2b7164dd) process.cc (8795:0909f8ed7aa0)
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 145 unchanged lines hidden (view full) ---

154 // mark remaining fds as free
155 for (int i = 3; i <= MAX_FD; ++i) {
156 Process::FdMap *fdo = &fd_map[i];
157 fdo->fd = -1;
158 }
159
160 mmap_start = mmap_end = 0;
161 nxm_start = nxm_end = 0;
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 145 unchanged lines hidden (view full) ---

154 // mark remaining fds as free
155 for (int i = 3; i <= MAX_FD; ++i) {
156 Process::FdMap *fdo = &fd_map[i];
157 fdo->fd = -1;
158 }
159
160 mmap_start = mmap_end = 0;
161 nxm_start = nxm_end = 0;
162 pTable = new PageTable(this);
162 pTable = new PageTable(name(), M5_pid);
163 // other parameters will be initialized when the program is loaded
164}
165
166
167void
168Process::regStats()
169{
170 using namespace Stats;

--- 142 unchanged lines hidden (view full) ---

313Process::sim_fd_obj(int tgt_fd)
314{
315 if (tgt_fd < 0 || tgt_fd > MAX_FD)
316 return NULL;
317
318 return &fd_map[tgt_fd];
319}
320
163 // other parameters will be initialized when the program is loaded
164}
165
166
167void
168Process::regStats()
169{
170 using namespace Stats;

--- 142 unchanged lines hidden (view full) ---

313Process::sim_fd_obj(int tgt_fd)
314{
315 if (tgt_fd < 0 || tgt_fd > MAX_FD)
316 return NULL;
317
318 return &fd_map[tgt_fd];
319}
320
321void
322Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
323{
324 int npages = divCeil(size, (int64_t)VMPageSize);
325 Addr paddr = system->allocPhysPages(npages);
326 pTable->map(vaddr, paddr, size, clobber);
327}
328
321bool
322Process::fixupStackFault(Addr vaddr)
323{
324 // Check if this is already on the stack and there's just no page there
325 // yet.
326 if (vaddr >= stack_min && vaddr < stack_base) {
329bool
330Process::fixupStackFault(Addr vaddr)
331{
332 // Check if this is already on the stack and there's just no page there
333 // yet.
334 if (vaddr >= stack_min && vaddr < stack_base) {
327 pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
335 allocateMem(roundDown(vaddr, VMPageSize), VMPageSize);
328 return true;
329 }
330
331 // We've accessed the next page of the stack, so extend it to include
332 // this address.
333 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
334 while (vaddr < stack_min) {
335 stack_min -= TheISA::PageBytes;
336 if (stack_base - stack_min > max_stack_size)
337 fatal("Maximum stack size exceeded\n");
338 if (stack_base - stack_min > 8 * 1024 * 1024)
339 fatal("Over max stack size for one thread\n");
336 return true;
337 }
338
339 // We've accessed the next page of the stack, so extend it to include
340 // this address.
341 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
342 while (vaddr < stack_min) {
343 stack_min -= TheISA::PageBytes;
344 if (stack_base - stack_min > max_stack_size)
345 fatal("Maximum stack size exceeded\n");
346 if (stack_base - stack_min > 8 * 1024 * 1024)
347 fatal("Over max stack size for one thread\n");
340 pTable->allocate(stack_min, TheISA::PageBytes);
348 allocateMem(stack_min, TheISA::PageBytes);
341 inform("Increasing stack size by one page.");
342 };
343 return true;
344 }
345 warn("Not extending stack: address %#x isn't at the end of the stack.",
346 vaddr);
347 return false;
348}

--- 376 unchanged lines hidden ---
349 inform("Increasing stack size by one page.");
350 };
351 return true;
352 }
353 warn("Not extending stack: address %#x isn't at the end of the stack.",
354 vaddr);
355 return false;
356}

--- 376 unchanged lines hidden ---