mm_disk.cc (8623:8c410e1a551e) mm_disk.cc (8641:4d3ecac1abec)
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;

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

51 pioSize = image->size() * SectorSize;
52}
53
54Tick
55MmDisk::read(PacketPtr pkt)
56{
57 Addr accessAddr;
58 off_t sector;
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;

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

51 pioSize = image->size() * SectorSize;
52}
53
54Tick
55MmDisk::read(PacketPtr pkt)
56{
57 Addr accessAddr;
58 off_t sector;
59 off_t bytes_read;
60 uint16_t d16;
61 uint32_t d32;
62 uint64_t d64;
63
64 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
65 accessAddr = pkt->getAddr() - pioAddr;
66
67 sector = accessAddr / SectorSize;
68
69 if (sector != curSector) {
70 if (dirty) {
59 uint16_t d16;
60 uint32_t d32;
61 uint64_t d64;
62
63 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
64 accessAddr = pkt->getAddr() - pioAddr;
65
66 sector = accessAddr / SectorSize;
67
68 if (sector != curSector) {
69 if (dirty) {
71 bytes_read = image->write(diskData, curSector);
72 assert(bytes_read == SectorSize);
70#ifndef NDEBUG
71 off_t bytes_written =
72#endif
73 image->write(diskData, curSector);
74 assert(bytes_written == SectorSize);
73 }
75 }
74 bytes_read = image->read(diskData, sector);
76#ifndef NDEBUG
77 off_t bytes_read =
78#endif
79 image->read(diskData, sector);
75 assert(bytes_read == SectorSize);
76 curSector = sector;
77 }
78 switch (pkt->getSize()) {
79 case sizeof(uint8_t):
80 pkt->set(diskData[accessAddr % SectorSize]);
81 DPRINTF(IdeDisk, "reading byte %#x value= %#x\n", accessAddr, diskData[accessAddr %
82 SectorSize]);

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

104 return pioDelay;
105}
106
107Tick
108MmDisk::write(PacketPtr pkt)
109{
110 Addr accessAddr;
111 off_t sector;
80 assert(bytes_read == SectorSize);
81 curSector = sector;
82 }
83 switch (pkt->getSize()) {
84 case sizeof(uint8_t):
85 pkt->set(diskData[accessAddr % SectorSize]);
86 DPRINTF(IdeDisk, "reading byte %#x value= %#x\n", accessAddr, diskData[accessAddr %
87 SectorSize]);

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

109 return pioDelay;
110}
111
112Tick
113MmDisk::write(PacketPtr pkt)
114{
115 Addr accessAddr;
116 off_t sector;
112 off_t bytes_read;
113 uint16_t d16;
114 uint32_t d32;
115 uint64_t d64;
116
117 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
118 accessAddr = pkt->getAddr() - pioAddr;
119
120 sector = accessAddr / SectorSize;
121
122 if (sector != curSector) {
123 if (dirty) {
117 uint16_t d16;
118 uint32_t d32;
119 uint64_t d64;
120
121 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
122 accessAddr = pkt->getAddr() - pioAddr;
123
124 sector = accessAddr / SectorSize;
125
126 if (sector != curSector) {
127 if (dirty) {
124 bytes_read = image->write(diskData, curSector);
125 assert(bytes_read == SectorSize);
128#ifndef NDEBUG
129 off_t bytes_written =
130#endif
131 image->write(diskData, curSector);
132 assert(bytes_written == SectorSize);
126 }
133 }
127 bytes_read = image->read(diskData, sector);
134#ifndef NDEBUG
135 off_t bytes_read =
136#endif
137 image->read(diskData, sector);
128 assert(bytes_read == SectorSize);
129 curSector = sector;
130 }
131 dirty = true;
132
133 switch (pkt->getSize()) {
134 case sizeof(uint8_t):
135 diskData[accessAddr % SectorSize] = htobe(pkt->get<uint8_t>());

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

159 return pioDelay;
160}
161
162void
163MmDisk::serialize(std::ostream &os)
164{
165 // just write any dirty changes to the cow layer it will take care of
166 // serialization
138 assert(bytes_read == SectorSize);
139 curSector = sector;
140 }
141 dirty = true;
142
143 switch (pkt->getSize()) {
144 case sizeof(uint8_t):
145 diskData[accessAddr % SectorSize] = htobe(pkt->get<uint8_t>());

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

169 return pioDelay;
170}
171
172void
173MmDisk::serialize(std::ostream &os)
174{
175 // just write any dirty changes to the cow layer it will take care of
176 // serialization
167 int bytes_read;
168 if (dirty) {
177 if (dirty) {
169 bytes_read = image->write(diskData, curSector);
178#ifndef NDEBUG
179 int bytes_read =
180#endif
181 image->write(diskData, curSector);
170 assert(bytes_read == SectorSize);
171 }
172}
173
174MmDisk *
175MmDiskParams::create()
176{
177 return new MmDisk(this);
178}
182 assert(bytes_read == SectorSize);
183 }
184}
185
186MmDisk *
187MmDiskParams::create()
188{
189 return new MmDisk(this);
190}