| 260 | } |
| 261 | |
| 262 | int Port::WriteDiskBlock(uint64_t lba, uint32_t count, void* _buffer){ |
| 263 | uint64_t blockCount = ((count + (blocksize - 1)) / blocksize); |
| 264 | uint8_t* buffer = reinterpret_cast<uint8_t*>(_buffer); |
| 265 | |
| 266 | unsigned buf = AcquireBuffer(); |
| 267 | if(buf >= 8){ |
| 268 | return 4; // Should not happen |
| 269 | } |
| 270 | |
| 271 | while(blockCount-- && count){ |
| 272 | uint64_t size; |
| 273 | if(count < 512) size = count; |
| 274 | else size = 512; |
| 275 | |
| 276 | if(!size) break; |
| 277 | |
| 278 | memcpy(buffers[buf], buffer, size); |
| 279 | |
| 280 | if(Access(lba, 1, physBuffers[buf], 1)){ // LBA, 1 block, write |
| 281 | ReleaseBuffer(buf); |
| 282 | return 1; // Error Reading Sectors |
| 283 | } |
| 284 | |
| 285 | |
| 286 | buffer += size; |
| 287 | lba++; |
| 288 | } |
| 289 | ReleaseBuffer(buf); |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | int Port::Access(uint64_t lba, uint32_t count, uintptr_t physBuffer, int write){ |
| 295 | //portLock.Wait(); |
no test coverage detected