1 /* 2 * Copyright 2015, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "Jobs.h" 7 8 #include "Team.h" 9 #include "TeamMemory.h" 10 11 12 WriteMemoryJob::WriteMemoryJob(Team* team, 13 TeamMemory* teamMemory, target_addr_t address, void* data, 14 target_size_t size) 15 : 16 fKey(data, JOB_TYPE_WRITE_MEMORY), 17 fTeam(team), 18 fTeamMemory(teamMemory), 19 fTargetAddress(address), 20 fData(data), 21 fSize(size) 22 { 23 fTeamMemory->AcquireReference(); 24 } 25 26 27 WriteMemoryJob::~WriteMemoryJob() 28 { 29 fTeamMemory->ReleaseReference(); 30 } 31 32 33 const JobKey& 34 WriteMemoryJob::Key() const 35 { 36 return fKey; 37 } 38 39 40 status_t 41 WriteMemoryJob::Do() 42 { 43 ssize_t result = fTeamMemory->WriteMemory(fTargetAddress, fData, fSize); 44 if (result < 0) 45 return result; 46 47 fTeam->NotifyMemoryChanged(fTargetAddress, fSize); 48 49 return B_OK; 50 } 51