physical.cc (3879:1712a36b22cb) physical.cc (3918:1f9a98d198e8)
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;

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

54PhysicalMemory::PhysicalMemory(Params *p)
55 : MemObject(p->name), pmemAddr(NULL), port(NULL), lat(p->latency), _params(p)
56{
57 if (params()->addrRange.size() % TheISA::PageBytes != 0)
58 panic("Memory Size not divisible by page size\n");
59
60 int map_flags = MAP_ANON | MAP_PRIVATE;
61 pmemAddr = (uint8_t *)mmap(NULL, params()->addrRange.size(), PROT_READ | PROT_WRITE,
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;

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

54PhysicalMemory::PhysicalMemory(Params *p)
55 : MemObject(p->name), pmemAddr(NULL), port(NULL), lat(p->latency), _params(p)
56{
57 if (params()->addrRange.size() % TheISA::PageBytes != 0)
58 panic("Memory Size not divisible by page size\n");
59
60 int map_flags = MAP_ANON | MAP_PRIVATE;
61 pmemAddr = (uint8_t *)mmap(NULL, params()->addrRange.size(), PROT_READ | PROT_WRITE,
62 map_flags, -1, 0);
62 map_flags, -1, 0);
63
64 if (pmemAddr == (void *)MAP_FAILED) {
65 perror("mmap");
66 fatal("Could not mmap!\n");
67 }
68
69 //If requested, initialize all the memory to 0
70 if(params()->zero)

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

79 if (!port)
80 panic("PhysicalMemory not connected to anything!");
81 port->sendStatusChange(Port::RangeChange);
82}
83
84PhysicalMemory::~PhysicalMemory()
85{
86 if (pmemAddr)
63
64 if (pmemAddr == (void *)MAP_FAILED) {
65 perror("mmap");
66 fatal("Could not mmap!\n");
67 }
68
69 //If requested, initialize all the memory to 0
70 if(params()->zero)

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

79 if (!port)
80 panic("PhysicalMemory not connected to anything!");
81 port->sendStatusChange(Port::RangeChange);
82}
83
84PhysicalMemory::~PhysicalMemory()
85{
86 if (pmemAddr)
87 munmap(pmemAddr, params()->addrRange.size());
87 munmap((char*)pmemAddr, params()->addrRange.size());
88 //Remove memPorts?
89}
90
91Addr
92PhysicalMemory::new_page()
93{
94 Addr return_addr = pagePtr << LogVMPageSize;
95 return_addr += params()->addrRange.start;

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

425 compressedMem = gzdopen(fd, "rb");
426 if (compressedMem == NULL)
427 fatal("Insufficient memory to allocate compression state for %s\n",
428 filename);
429
430 // unmap file that was mmaped in the constructor
431 // This is done here to make sure that gzip and open don't muck with our
432 // nice large space of memory before we reallocate it
88 //Remove memPorts?
89}
90
91Addr
92PhysicalMemory::new_page()
93{
94 Addr return_addr = pagePtr << LogVMPageSize;
95 return_addr += params()->addrRange.start;

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

425 compressedMem = gzdopen(fd, "rb");
426 if (compressedMem == NULL)
427 fatal("Insufficient memory to allocate compression state for %s\n",
428 filename);
429
430 // unmap file that was mmaped in the constructor
431 // This is done here to make sure that gzip and open don't muck with our
432 // nice large space of memory before we reallocate it
433 munmap(pmemAddr, params()->addrRange.size());
433 munmap((char*)pmemAddr, params()->addrRange.size());
434
435 pmemAddr = (uint8_t *)mmap(NULL, params()->addrRange.size(), PROT_READ | PROT_WRITE,
436 MAP_ANON | MAP_PRIVATE, -1, 0);
437
438 if (pmemAddr == (void *)MAP_FAILED) {
439 perror("mmap");
440 fatal("Could not mmap physical memory!\n");
441 }

--- 64 unchanged lines hidden ---
434
435 pmemAddr = (uint8_t *)mmap(NULL, params()->addrRange.size(), PROT_READ | PROT_WRITE,
436 MAP_ANON | MAP_PRIVATE, -1, 0);
437
438 if (pmemAddr == (void *)MAP_FAILED) {
439 perror("mmap");
440 fatal("Could not mmap physical memory!\n");
441 }

--- 64 unchanged lines hidden ---