add eflags to basic_cpu

Stan Cox <[email protected]>
Newsgroups gmane.comp.emulators.sid.devel
Organization Red Hat, RDU, NC, USA
Message-ID <[email protected]>
This patch builds on Dave Brolley's machine extension to allow a
cgen-cpu component to access the eflags from the executable.  This
allows, for example, differentiating between different machine variants.
4181.patch (text/x-patch, 6.4 KB)
component/loader/ChangeLog

2004-06-29  Stan Cox  <[email protected]>

	* compLoader.cxx (generic_loader):  Add eflags_pin.
	(elf_loader): Add eflags.
	(load_it): Set eflags.
	* elfload.c (readElfFile): Add eflags.
 
Index: component/loader/compLoader.cxx
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/loader/compLoader.cxx,v
retrieving revision 1.46
diff -u -2 -p -r1.46 compLoader.cxx
--- component/loader/compLoader.cxx	28 Apr 2004 17:29:58 -0000	1.46
+++ component/loader/compLoader.cxx	29 Jun 2004 18:09:04 -0000
@@ -122,4 +122,6 @@ protected:
   // The value is one of sidutil::endian_*.
   output_pin endian_pin;
+  // eflags as specified in ELF header.
+  output_pin eflags_pin;
 
   // Provide address of write attempt to code section
@@ -165,4 +167,5 @@ public:
       add_pin("start-pc-set", & this->start_pc_pin);
       add_pin("endian-set", & this->endian_pin);
+      add_pin("eflags-set", &this->eflags_pin);
       add_pin("error", & this->error_pin);
       add_pin("write-to-code-address", & this->write_to_code_address_pin);
@@ -250,8 +253,10 @@ class elf_loader: public generic_loader
       unsigned entry_point;
       int little_endian_p;
+      unsigned eflags;
+
       const struct TextSection *section_table;
       int success_p = readElfFile(& elf_loader::load_function,
 				  & entry_point, & little_endian_p,
-				  & section_table);
+				  & eflags, & section_table);
       probe_upstream.set_section_table (section_table);
       elf_loader::freeloader = 0;
@@ -265,4 +270,5 @@ class elf_loader: public generic_loader
 	  else
 	    this->endian_pin.drive(sidutil::endian_big);
+	  this->eflags_pin.drive((host_int_4) eflags);
 
 	  if (this->verbose_p)
Index: component/loader/elfload.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/loader/elfload.c,v
retrieving revision 1.16
diff -u -2 -p -r1.16 elfload.c
--- component/loader/elfload.c	16 May 2004 22:45:02 -0000	1.16
+++ component/loader/elfload.c	29 Jun 2004 18:09:04 -0000
@@ -83,5 +83,6 @@ textSectionAddress (unsigned long long a
 
 int
-readElfFile (PFLOAD func, unsigned* entry_point, int* little_endian, const struct TextSection **section_table)
+readElfFile (PFLOAD func, unsigned* entry_point, int* little_endian,
+	     unsigned* e_flags, const struct TextSection **section_table)
 {
   unsigned char fileHeader [64];
@@ -91,4 +92,5 @@ readElfFile (PFLOAD func, unsigned* entr
   int psymSize;
   int psymNum;
+  int eFlags;
   unsigned long long secOffset;
   int secSize;
@@ -126,4 +128,5 @@ readElfFile (PFLOAD func, unsigned* entr
       entryPoint = fetchQuad (fileHeader+24, littleEndian);
       psymOffset = fetchQuad (fileHeader+32, littleEndian);
+      eFlags = fetchWord (fileHeader+40, littleEndian);
       psymSize = fetchShort (fileHeader+54, littleEndian);
       psymNum = fetchShort (fileHeader+56, littleEndian);
@@ -133,4 +136,5 @@ readElfFile (PFLOAD func, unsigned* entr
       entryPoint = fetchWord (fileHeader+24, littleEndian);
       psymOffset = fetchWord (fileHeader+28, littleEndian);
+      eFlags = fetchWord (fileHeader+36, littleEndian);
       psymSize = fetchShort (fileHeader+42, littleEndian);
       psymNum = fetchShort (fileHeader+44, littleEndian);
@@ -267,4 +271,5 @@ readElfFile (PFLOAD func, unsigned* entr
   *little_endian = littleEndian;
   *section_table = textSections;
+  *e_flags = eFlags;
 
   return 1;
Index: component/loader/elfload.h
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/loader/elfload.h,v
retrieving revision 1.11
diff -u -2 -p -r1.11 elfload.h
--- component/loader/elfload.h	12 Feb 2004 20:43:28 -0000	1.11
+++ component/loader/elfload.h	29 Jun 2004 18:09:04 -0000
@@ -49,5 +49,5 @@ extern int textSectionAddress(unsigned l
 /* Load an ELF executable into memory. FUNC is used to actually read the
    file. */
-extern int readElfFile(PFLOAD func, unsigned*, int*, const struct TextSection **);
+extern int readElfFile(PFLOAD func, unsigned*, int*, unsigned*, const struct TextSection **);
 
 #define EI_CLASS 4

include/ChangeLog

2004-06-29  Stan Cox  <[email protected]>

	* sidcpuutil.h (basic_cpu): Add eflags_set_pin, set_eflags.
 
Index: include/sidcpuutil.h
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/include/sidcpuutil.h,v
retrieving revision 1.49
diff -u -2 -p -r1.49 sidcpuutil.h
--- include/sidcpuutil.h	22 Mar 2004 22:16:17 -0000	1.49
+++ include/sidcpuutil.h	29 Jun 2004 18:09:04 -0000
@@ -408,4 +408,7 @@ namespace sidutil
     virtual void set_endian(sid::host_int_4) = 0;
     void endian_set_pin_handler(sid::host_int_4 v) { this->set_endian (v); }
+    callback_pin<basic_cpu> eflags_set_pin;
+    virtual void set_eflags(sid::host_int_4) {}
+    void eflags_set_pin_handler(sid::host_int_4 v) { this->set_eflags (v); }
 
     // Signal trap type code and argument
@@ -551,4 +554,5 @@ public:
       pc_set_pin (this, & basic_cpu::pc_set_pin_handler),
       endian_set_pin (this, & basic_cpu::endian_set_pin_handler),
+      eflags_set_pin (this, & basic_cpu::eflags_set_pin_handler),
       debugger_bus (& this->data_bus),
       trace_stream (),
@@ -576,4 +580,5 @@ public:
 	add_pin ("print-insn-summary!", & this->print_insn_summary_pin);
 	add_pin ("endian-set!", & this->endian_set_pin);
+	add_pin ("eflags-set!", & this->eflags_set_pin);
 	add_watchable_pin ("trap", & this->trap_type_pin); // output side
 	add_watchable_pin ("trap-code", & this->trap_code_pin);
@@ -707,4 +712,5 @@ public:
   {
     void set_endian(sid::host_int_4) {}
+    void set_eflags(sid::host_int_4) {}
 
   protected:
@@ -803,4 +809,5 @@ public:
   {
     void set_endian(sid::host_int_4) {}
+    void set_eflags(sid::host_int_4) {}
 
   protected:

main/dynamic/ChangeLog

2004-06-29  Stan Cox  <[email protected]>

	* commonCfg.cxx (add_cpu):  Add eflags-set pin.
 
Index: main/dynamic/commonCfg.cxx
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/main/dynamic/commonCfg.cxx,v
retrieving revision 1.22
diff -u -2 -p -r1.22 commonCfg.cxx
--- main/dynamic/commonCfg.cxx	22 Mar 2004 22:17:31 -0000	1.22
+++ main/dynamic/commonCfg.cxx	29 Jun 2004 18:09:04 -0000
@@ -709,4 +709,5 @@ void LoaderCfg::add_cpu (CpuCfg *cpu) 
   conn_pin (this, "start-pc-set", cpu, "start-pc-set!");
   conn_pin (this, "endian-set", cpu, "endian-set!");
+  conn_pin (this, "eflags-set", cpu, "eflags-set!");
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.