From b1fb2d55c598d89e5a29c569da546b74f99a8bbc Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 1 Oct 2019 20:17:06 -0700 Subject: [PATCH] arch-mips,arch-riscv,base: Get rid of the unused HexFile class. A pointer to it was set up in the MIPS and RISCV system classes, but nothing ever set that pointer. The class was put in base/loader, but didn't have anything to do (as far as I can see) with loading anything it had a loadSegments method, but was not a subclass of ObjectFile. Change-Id: I4b711a31df20e20ffc306709227f60aa020fca15 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21464 Tested-by: kokoro Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- src/arch/mips/system.cc | 1 - src/arch/mips/system.hh | 4 - src/arch/riscv/system.cc | 1 - src/arch/riscv/system.hh | 4 - src/base/SConscript | 1 - src/base/loader/hex_file.cc | 141 ------------------------------------ src/base/loader/hex_file.hh | 58 --------------- 7 files changed, 210 deletions(-) delete mode 100644 src/base/loader/hex_file.cc delete mode 100644 src/base/loader/hex_file.hh diff --git a/src/arch/mips/system.cc b/src/arch/mips/system.cc index 815674702..9967aa82c 100644 --- a/src/arch/mips/system.cc +++ b/src/arch/mips/system.cc @@ -34,7 +34,6 @@ #include "arch/mips/system.hh" #include "arch/vtophys.hh" -#include "base/loader/hex_file.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" #include "base/trace.hh" diff --git a/src/arch/mips/system.hh b/src/arch/mips/system.hh index 6b74ac1e5..eb28b3b2f 100644 --- a/src/arch/mips/system.hh +++ b/src/arch/mips/system.hh @@ -37,7 +37,6 @@ #include #include -#include "base/loader/hex_file.hh" #include "base/loader/symtab.hh" #include "cpu/pc_event.hh" #include "kern/system_events.hh" @@ -67,9 +66,6 @@ class MipsSystem : public System /** Object pointer for the console code */ ObjectFile *console; - /** Used by some Bare Iron Configurations */ - HexFile *hexFile; - #ifndef NDEBUG /** Event to halt the simulator if the console calls panic() */ BreakPCEvent *consolePanicEvent; diff --git a/src/arch/riscv/system.cc b/src/arch/riscv/system.cc index fbfd9d2f5..88d6251cc 100644 --- a/src/arch/riscv/system.cc +++ b/src/arch/riscv/system.cc @@ -35,7 +35,6 @@ #include "arch/riscv/system.hh" #include "arch/vtophys.hh" -#include "base/loader/hex_file.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" #include "base/trace.hh" diff --git a/src/arch/riscv/system.hh b/src/arch/riscv/system.hh index 85b8d6a4b..7bff5cd45 100644 --- a/src/arch/riscv/system.hh +++ b/src/arch/riscv/system.hh @@ -38,7 +38,6 @@ #include #include -#include "base/loader/hex_file.hh" #include "base/loader/symtab.hh" #include "cpu/pc_event.hh" #include "kern/system_events.hh" @@ -80,9 +79,6 @@ class RiscvSystem : public System /** Object pointer for the console code */ ObjectFile *console; - /** Used by some Bare Iron Configurations */ - HexFile *hexFile; - #ifndef NDEBUG /** Event to halt the simulator if the console calls panic() */ BreakPCEvent *consolePanicEvent; diff --git a/src/base/SConscript b/src/base/SConscript index 2c8f73371..ba17f6725 100644 --- a/src/base/SConscript +++ b/src/base/SConscript @@ -76,7 +76,6 @@ Source('loader/aout_object.cc') Source('loader/dtb_object.cc') Source('loader/ecoff_object.cc') Source('loader/elf_object.cc') -Source('loader/hex_file.cc') Source('loader/object_file.cc') Source('loader/raw_object.cc') Source('loader/symtab.cc') diff --git a/src/base/loader/hex_file.cc b/src/base/loader/hex_file.cc deleted file mode 100644 index 4c9ffa516..000000000 --- a/src/base/loader/hex_file.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2007 MIPS Technologies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: Jaidev Patwardhan - */ - -#include "base/loader/hex_file.hh" - -#include -#include -#include -#include - -#include "base/cprintf.hh" -#include "base/loader/symtab.hh" -#include "mem/port_proxy.hh" - -using namespace std; -/* - * Load a Hex File into memory. Currently only used with MIPS - * BARE_IRON mode. A hex file consists of [Address Data] tuples that - * get directly loaded into physical memory. The address specified is - * a word address (i.e., to get the byte address, shift left by 2) The - * data is a full 32-bit hex value. -*/ -HexFile::HexFile(const string _filename) - : filename(_filename) -{ - fp = fopen(filename.c_str(), "r"); - if (fp == NULL) - panic("Unable to open %s\n", filename.c_str()); -} - -HexFile::~HexFile() -{ - if (fp != NULL) - fclose(fp); -} - -bool -HexFile::loadSegments(PortProxy& memProxy) -{ - char Line[64]; - Addr MemAddr; - uint32_t Data; - while (!feof(fp)) { - char *ret = fgets(Line, sizeof(Line), fp); - if (!ret) - panic("malformed file"); - parseLine(Line, &MemAddr, &Data); - if (MemAddr != 0) { - // Now, write to memory - memProxy.writeBlob(MemAddr << 2, &Data, sizeof(Data)); - } - } - return true; -} - -void -HexFile::parseLine(char *Str, Addr *A, uint32_t *D) -{ - int i = 0; - bool Flag = false; - *A = 0; - *D = 0; - int Digit = 0; - unsigned Number = 0; - - /* Skip white spaces */ - while (Str[i] != '\0' && Str[i]==' ') - i++; - - /* Ok, we're at some character...process things */ - while (Str[i] != '\0') { - if (Str[i] >= '0' && Str[i] <= '9') { - Digit = Str[i] - '0'; - } else if (Str[i] >= 'a' && Str[i] <= 'f') { - Digit = Str[i] - 'a' + 10; - } else if (Str[i] >= 'A' && Str[i] <= 'F') { - Digit=Str[i]-'A'+10; - } else if (Str[i] == ' ' || Str[i] == '\n') { - if (Number == 0) - return; - if (!Flag) { - *A = Number; - Number = 0; - Flag = true; - } else { - *D = Number; - return; - } - } else { - // Ok, we've encountered a non-hex character, cannot be a - // valid line, skip and return 0's - *A = 0; - *D = 0; - return; - } - - Number <<= 4; - Number += Digit; - i++; - } - - if (!Flag) { - *A = 0; - *D = 0; - } else { - *D = Number; - } -} - -void -HexFile::close() -{ - fclose(fp); -} diff --git a/src/base/loader/hex_file.hh b/src/base/loader/hex_file.hh deleted file mode 100644 index befd7f320..000000000 --- a/src/base/loader/hex_file.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2002-2004 The Regents of The University of Michigan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: Jaidev Patwardhan - */ - -#ifndef __BASE_LOADER_HEX_FILE_HH__ -#define __BASE_LOADER_HEX_FILE_HH__ - -#include -#include -#include - -#include "base/types.hh" - -class PortProxy; - -class HexFile -{ - protected: - const std::string filename; - FILE *fp; - - void parseLine(char *, Addr *, uint32_t *); - - public: - HexFile(const std::string _filename); - virtual ~HexFile(); - - void close(); - bool loadSegments(PortProxy& memProxy); -}; - -#endif // __BASE_LOADER_HEX_FILE_HH__ -- 2.30.2