mm_disk.cc (12544:6a4c3acc4289) mm_disk.cc (13231:c6c133f9e007)
1/*
2 * Copyright (c) 2006 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;

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

78 off_t bytes_read =
79#endif
80 image->read(diskData, sector);
81 assert(bytes_read == SectorSize);
82 curSector = sector;
83 }
84 switch (pkt->getSize()) {
85 case sizeof(uint8_t):
1/*
2 * Copyright (c) 2006 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;

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

78 off_t bytes_read =
79#endif
80 image->read(diskData, sector);
81 assert(bytes_read == SectorSize);
82 curSector = sector;
83 }
84 switch (pkt->getSize()) {
85 case sizeof(uint8_t):
86 pkt->set(diskData[accessAddr % SectorSize]);
87 DPRINTF(IdeDisk, "reading byte %#x value= %#x\n", accessAddr, diskData[accessAddr %
88 SectorSize]);
86 pkt->setRaw(diskData[accessAddr % SectorSize]);
87 DPRINTF(IdeDisk, "reading byte %#x value= %#x\n",
88 accessAddr, diskData[accessAddr % SectorSize]);
89 break;
90 case sizeof(uint16_t):
91 memcpy(&d16, diskData + (accessAddr % SectorSize), 2);
89 break;
90 case sizeof(uint16_t):
91 memcpy(&d16, diskData + (accessAddr % SectorSize), 2);
92 pkt->set(htobe(d16));
92 pkt->setRaw(d16);
93 DPRINTF(IdeDisk, "reading word %#x value= %#x\n", accessAddr, d16);
94 break;
95 case sizeof(uint32_t):
96 memcpy(&d32, diskData + (accessAddr % SectorSize), 4);
93 DPRINTF(IdeDisk, "reading word %#x value= %#x\n", accessAddr, d16);
94 break;
95 case sizeof(uint32_t):
96 memcpy(&d32, diskData + (accessAddr % SectorSize), 4);
97 pkt->set(htobe(d32));
97 pkt->setRaw(d32);
98 DPRINTF(IdeDisk, "reading dword %#x value= %#x\n", accessAddr, d32);
99 break;
100 case sizeof(uint64_t):
101 memcpy(&d64, diskData + (accessAddr % SectorSize), 8);
98 DPRINTF(IdeDisk, "reading dword %#x value= %#x\n", accessAddr, d32);
99 break;
100 case sizeof(uint64_t):
101 memcpy(&d64, diskData + (accessAddr % SectorSize), 8);
102 pkt->set(htobe(d64));
102 pkt->setRaw(d64);
103 DPRINTF(IdeDisk, "reading qword %#x value= %#x\n", accessAddr, d64);
104 break;
105 default:
106 panic("Invalid access size\n");
107 }
108
109 pkt->makeAtomicResponse();
110 return pioDelay;

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

138 image->read(diskData, sector);
139 assert(bytes_read == SectorSize);
140 curSector = sector;
141 }
142 dirty = true;
143
144 switch (pkt->getSize()) {
145 case sizeof(uint8_t):
103 DPRINTF(IdeDisk, "reading qword %#x value= %#x\n", accessAddr, d64);
104 break;
105 default:
106 panic("Invalid access size\n");
107 }
108
109 pkt->makeAtomicResponse();
110 return pioDelay;

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

138 image->read(diskData, sector);
139 assert(bytes_read == SectorSize);
140 curSector = sector;
141 }
142 dirty = true;
143
144 switch (pkt->getSize()) {
145 case sizeof(uint8_t):
146 diskData[accessAddr % SectorSize] = htobe(pkt->get());
147 DPRINTF(IdeDisk, "writing byte %#x value= %#x\n", accessAddr, diskData[accessAddr %
148 SectorSize]);
146 diskData[accessAddr % SectorSize] = htobe(pkt->getRaw<uint8_t>());
147 DPRINTF(IdeDisk, "writing byte %#x value= %#x\n",
148 accessAddr, diskData[accessAddr % SectorSize]);
149 break;
150 case sizeof(uint16_t):
149 break;
150 case sizeof(uint16_t):
151 d16 = htobe(pkt->get<uint16_t>());
151 d16 = pkt->getRaw<uint16_t>();
152 memcpy(diskData + (accessAddr % SectorSize), &d16, 2);
153 DPRINTF(IdeDisk, "writing word %#x value= %#x\n", accessAddr, d16);
154 break;
155 case sizeof(uint32_t):
152 memcpy(diskData + (accessAddr % SectorSize), &d16, 2);
153 DPRINTF(IdeDisk, "writing word %#x value= %#x\n", accessAddr, d16);
154 break;
155 case sizeof(uint32_t):
156 d32 = htobe(pkt->get<uint32_t>());
156 d32 = pkt->getRaw<uint32_t>();
157 memcpy(diskData + (accessAddr % SectorSize), &d32, 4);
158 DPRINTF(IdeDisk, "writing dword %#x value= %#x\n", accessAddr, d32);
159 break;
160 case sizeof(uint64_t):
157 memcpy(diskData + (accessAddr % SectorSize), &d32, 4);
158 DPRINTF(IdeDisk, "writing dword %#x value= %#x\n", accessAddr, d32);
159 break;
160 case sizeof(uint64_t):
161 d64 = htobe(pkt->get<uint64_t>());
161 d64 = pkt->getRaw<uint64_t>();
162 memcpy(diskData + (accessAddr % SectorSize), &d64, 8);
163 DPRINTF(IdeDisk, "writing qword %#x value= %#x\n", accessAddr, d64);
164 break;
165 default:
166 panic("Invalid access size\n");
167 }
168
169 pkt->makeAtomicResponse();

--- 23 unchanged lines hidden ---
162 memcpy(diskData + (accessAddr % SectorSize), &d64, 8);
163 DPRINTF(IdeDisk, "writing qword %#x value= %#x\n", accessAddr, d64);
164 break;
165 default:
166 panic("Invalid access size\n");
167 }
168
169 pkt->makeAtomicResponse();

--- 23 unchanged lines hidden ---