summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorKorey Sewell <ksewell@umich.edu>2006-03-15 16:26:40 -0500
committerKorey Sewell <ksewell@umich.edu>2006-03-15 16:26:40 -0500
commitc32b4ecac1090cc4885c8d4e529b4ade4686058e (patch)
treeb4f15e4226b8f3d2870a796d5be3c5a095d96e4f /base
parent0d8cfed042cbd987fd5b9c5d9307d8c34225c90e (diff)
downloadgem5-c32b4ecac1090cc4885c8d4e529b4ade4686058e.tar.xz
infinitesimal small baby steps toward MIPS actually working
arch/mips/isa/formats/branch.isa: let user know that we alter r31 in disassembly arch/mips/isa_traits.cc: add copyRegs function ... comment out serialize float code for now arch/mips/isa_traits.hh: make FloatRegFile a class ... change values of architectural regs arch/mips/process.cc: change MIPS to Mips base/loader/elf_object.cc: get global pointer initialized to a value base/loader/elf_object.hh: Add global_ptr to elf_object constructor base/loader/object_file.hh: MIPS to Mips base/traceflags.py: SimpleCPU trace flag cpu/simple/cpu.cc: DPRINTF flags for SimpleCPU cpu/static_inst.hh: Add Decoder functions to static_inst.hh --HG-- extra : convert_revision : 0544a8524d3fe4229428cb06822f7da208c72459
Diffstat (limited to 'base')
-rw-r--r--base/loader/elf_object.cc43
-rw-r--r--base/loader/elf_object.hh2
-rw-r--r--base/loader/object_file.hh4
-rw-r--r--base/traceflags.py1
4 files changed, 45 insertions, 5 deletions
diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc
index 2925817cd..b9636b454 100644
--- a/base/loader/elf_object.cc
+++ b/base/loader/elf_object.cc
@@ -92,7 +92,7 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
arch = ObjectFile::SPARC;
} else if (ehdr.e_machine == EM_MIPS
&& ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
- arch = ObjectFile::MIPS;
+ arch = ObjectFile::Mips;
} else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
arch = ObjectFile::Alpha;
} else {
@@ -156,14 +156,49 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
section = elf_getscn(elf, ++secIdx);
} // while sections
}
+
+ int32_t global_ptr;
+ if (arch == ObjectFile::Mips) {
+ Elf_Scn *section;
+ GElf_Shdr shdr;
+ Elf_Data *rdata;
+ int secIdx = 1;
+
+ // Get the first section
+ section = elf_getscn(elf, secIdx);
+
+ // While there are no more sections
+ while (section != NULL) {
+ gelf_getshdr(section, &shdr);
+ /*shdr.sh_type == SHT_MIPS_REGINFO && */
+ if (!strcmp(".reginfo",elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name))) {
+ // We have found MIPS reginfo section:
+ // -------------------------------
+ // Check the 6th 32bit word for the initialized global pointer value
+ // -------------------------------
+ rdata = elf_rawdata(section, NULL);
+ assert(rdata->d_buf);
+
+ if(ehdr.e_ident[EI_DATA] == ELFDATA2LSB)
+ global_ptr = htole(((int32_t*)rdata->d_buf)[5]);
+ else
+ global_ptr = htobe(((int32_t*)rdata->d_buf)[5]);
+ break;
+ }
+
+ section = elf_getscn(elf, ++secIdx);
+ } // if section found
+
+ }
+
elf_end(elf);
- return new ElfObject(fname, fd, len, data, arch, opSys);
+ return new ElfObject(fname, fd, len, data, global_ptr,arch, opSys);
}
}
ElfObject::ElfObject(const string &_filename, int _fd,
- size_t _len, uint8_t *_data,
+ size_t _len, uint8_t *_data,Addr global_ptr,
Arch _arch, OpSys _opSys)
: ObjectFile(_filename, _fd, _len, _data, _arch, _opSys)
@@ -187,6 +222,8 @@ ElfObject::ElfObject(const string &_filename, int _fd,
entry = ehdr.e_entry;
+ globalPtr = global_ptr;
+
// initialize segment sizes to 0 in case they're not present
text.size = data.size = bss.size = 0;
diff --git a/base/loader/elf_object.hh b/base/loader/elf_object.hh
index 72c265edd..d1fd32fd0 100644
--- a/base/loader/elf_object.hh
+++ b/base/loader/elf_object.hh
@@ -39,7 +39,7 @@ class ElfObject : public ObjectFile
bool loadSomeSymbols(SymbolTable *symtab, int binding);
ElfObject(const std::string &_filename, int _fd,
- size_t _len, uint8_t *_data,
+ size_t _len, uint8_t *_data,Addr global_ptr,
Arch _arch, OpSys _opSys);
public:
diff --git a/base/loader/object_file.hh b/base/loader/object_file.hh
index 08a51863e..309089728 100644
--- a/base/loader/object_file.hh
+++ b/base/loader/object_file.hh
@@ -44,7 +44,7 @@ class ObjectFile
UnknownArch,
Alpha,
SPARC,
- MIPS
+ Mips
};
enum OpSys {
@@ -95,9 +95,11 @@ class ObjectFile
Section bss;
bool loadSection(Section *sec, TranslatingPort *memPort, bool loadPhys);
+ void setGlobalPointer(Addr global_ptr) { globalPtr = global_ptr; }
public:
Addr entryPoint() const { return entry; }
+
Addr globalPointer() const { return globalPtr; }
Addr textBase() const { return text.baseAddr; }
diff --git a/base/traceflags.py b/base/traceflags.py
index e814a00fb..c3b878027 100644
--- a/base/traceflags.py
+++ b/base/traceflags.py
@@ -142,6 +142,7 @@ baseFlags = [
'OoOCPU',
'HWPrefetch',
'Stack',
+ 'SimpleCPU',
]
#