syscall_emul.cc (13569:47a2291177a7) | syscall_emul.cc (13570:b6484720c6a9) |
---|---|
1/* 2 * Copyright (c) 2003-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; --- 265 unchanged lines hidden (view full) --- 274closeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 275{ 276 int index = 0; 277 int tgt_fd = p->getSyscallArg(tc, index); 278 279 return p->fds->closeFDEntry(tgt_fd); 280} 281 | 1/* 2 * Copyright (c) 2003-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; --- 265 unchanged lines hidden (view full) --- 274closeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 275{ 276 int index = 0; 277 int tgt_fd = p->getSyscallArg(tc, index); 278 279 return p->fds->closeFDEntry(tgt_fd); 280} 281 |
282 | |
283SyscallReturn | 282SyscallReturn |
284readFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 285{ 286 int index = 0; 287 int tgt_fd = p->getSyscallArg(tc, index); 288 Addr buf_ptr = p->getSyscallArg(tc, index); 289 int nbytes = p->getSyscallArg(tc, index); 290 291 auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[tgt_fd]); 292 if (!hbfdp) 293 return -EBADF; 294 int sim_fd = hbfdp->getSimFD(); 295 296 BufferArg bufArg(buf_ptr, nbytes); 297 int bytes_read = read(sim_fd, bufArg.bufferPtr(), nbytes); 298 299 if (bytes_read > 0) 300 bufArg.copyOut(tc->getMemProxy()); 301 302 return bytes_read; 303} 304 305SyscallReturn 306writeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 307{ 308 int index = 0; 309 int tgt_fd = p->getSyscallArg(tc, index); 310 Addr buf_ptr = p->getSyscallArg(tc, index); 311 int nbytes = p->getSyscallArg(tc, index); 312 313 auto hbfdp = std::dynamic_pointer_cast<HBFDEntry>((*p->fds)[tgt_fd]); 314 if (!hbfdp) 315 return -EBADF; 316 int sim_fd = hbfdp->getSimFD(); 317 318 BufferArg bufArg(buf_ptr, nbytes); 319 bufArg.copyIn(tc->getMemProxy()); 320 321 int bytes_written = write(sim_fd, bufArg.bufferPtr(), nbytes); 322 323 fsync(sim_fd); 324 325 return bytes_written; 326} 327 328 329SyscallReturn | |
330lseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 331{ 332 int index = 0; 333 int tgt_fd = p->getSyscallArg(tc, index); 334 uint64_t offs = p->getSyscallArg(tc, index); 335 int whence = p->getSyscallArg(tc, index); 336 337 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]); --- 1279 unchanged lines hidden --- | 283lseekFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) 284{ 285 int index = 0; 286 int tgt_fd = p->getSyscallArg(tc, index); 287 uint64_t offs = p->getSyscallArg(tc, index); 288 int whence = p->getSyscallArg(tc, index); 289 290 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]); --- 1279 unchanged lines hidden --- |