/*
- * Copyright (c) 2018 ARM Limited
+ * Copyright (c) 2018, 2019 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
timeBase([p]{ struct tm t = p->time; return mkutctime(&t); }()),
tickShift(calcTickShift()),
semiErrno(0),
+ filesRootDir(!p->files_root_dir.empty() &&
+ p->files_root_dir.back() != '/' ?
+ p->files_root_dir + '/' : p->files_root_dir),
stdin(getSTDIO("stdin", p->stdin, "r")),
stdout(getSTDIO("stdout", p->stdout, "w")),
stderr(p->stderr == p->stdout ?
std::vector<char> buf(len + 1);
buf[len] = '\0';
- physProxy(tc).readBlob(ptr, (uint8_t *)buf.data(), len);
+ physProxy(tc).readBlob(ptr, buf.data(), len);
return std::string(buf.data());
}
return retError(EINVAL);
std::string fname = readString(tc, name_base, name_size);
+ if (!fname.empty() && fname.front() != '/')
+ fname = filesRootDir + fname;
std::unique_ptr<ArmSemihosting::FileBase> file =
FileBase::create(*this, fname, mode);
if (argv[1] > files.size() || !files[argv[1]])
return retError(EBADF);
- int64_t ret = files[argv[1]]->isTTY();
+ int64_t ret = files[argv[1]]->flen();
if (ret < 0) {
return retError(-ret);
} else {
- return retOK(0);
+ return retOK(ret);
}
}
if (path_len >= max_len)
return retError(ENOSPC);
- physProxy(tc).writeBlob(
- guest_buf, (const uint8_t *)path, path_len + 1);
+ physProxy(tc).writeBlob(guest_buf, path, path_len + 1);
return retOK(0);
}
if (cmdLine.size() + 1 < argv[2]) {
PortProxy &proxy = physProxy(tc);
ByteOrder endian = ArmISA::byteOrder(tc);
- proxy.writeBlob(
- (Addr)argv[1],
- (const uint8_t *)cmdLine.c_str(), cmdLine.size() + 1);
+ proxy.writeBlob((Addr)argv[1], cmdLine.c_str(), cmdLine.size() + 1);
if (aarch64)
proxy.write<uint64_t>(argv[0] + 1 * 8, cmdLine.size(), endian);