Deleted Added
sdiff udiff text old ( 12533:a5b047f55eb6 ) new ( 12698:cef1e0e7a368 )
full compact
1/*
2 * Copyright (c) 2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

116};
117
118
119const std::vector<uint8_t> ArmSemihosting::features{
120 0x53, 0x48, 0x46, 0x42, // Magic
121 0x3, // EXT_EXIT_EXTENDED, EXT_STDOUT_STDERR
122};
123
124ArmSemihosting::ArmSemihosting(const ArmSemihostingParams *p)
125 : SimObject(p),
126 cmdLine(p->cmd_line),
127 memReserve(p->mem_reserve),
128 stackSize(p->stack_size),
129 timeBase([p]{ struct tm t = p->time; return mkutctime(&t); }()),
130 tickShift(calcTickShift()),
131 semiErrno(0)
132{
133 // Create an empty place-holder file for position 0 as semi-hosting
134 // calls typically expect non-zero file handles.
135 files.push_back(nullptr);
136
137 if (tickShift > 0)
138 inform("Semihosting: Shifting elapsed ticks by %i bits.",
139 tickShift);

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

676 auto it = calls.find(op);
677 if (it == calls.end())
678 return nullptr;
679 else {
680 return &it->second;
681 }
682}
683
684std::unique_ptr<ArmSemihosting::FileBase>
685ArmSemihosting::FileBase::create(
686 ArmSemihosting &parent, const std::string &fname, const char *mode)
687{
688 std::unique_ptr<FileBase> file;
689 if (fname == ":semihosting-features") {
690 file.reset(new FileFeatures(parent, fname.c_str(), mode));
691 } else {

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

814
815int64_t
816ArmSemihosting::File::openImpl(bool in_cpt)
817{
818 panic_if(file, "Trying to open an already open file.\n");
819
820 if (_name == ":tt") {
821 if (mode[0] == 'r') {
822 file = stdin;
823 } else if (mode[0] == 'w') {
824 file = stdout;
825 } else if (mode[0] == 'a') {
826 file = stderr;
827 } else {
828 warn("Unknown file mode for the ':tt' special file");
829 return -EINVAL;
830 }
831 } else {
832 std::string real_mode(this->mode);
833 // Avoid truncating the file if we are restoring from a
834 // checkpoint.

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

852 file = nullptr;
853
854 return 0;
855}
856
857bool
858ArmSemihosting::File::isTTY() const
859{
860 return file == stdout || file == stderr || file == stdin;
861}
862
863int64_t
864ArmSemihosting::File::read(uint8_t *buffer, uint64_t size)
865{
866 panic_if(!file, "Trying to read from a closed file");
867
868 size_t ret = fread(buffer, 1, size, file);

--- 95 unchanged lines hidden ---