This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The way to merge LinuxPpc64.java into frysk cvs


Any comment on this?  Thanks.

On Mon, 22 May 2006, Wu Zhou wrote:

> Hello all,
> 
> As you might know, I ever coded a file named LinuxPpc64.java based on 
> LinuxIa32.java some time before.  It works basically ok.  But I changed 
> the hard-wired sendrecIsa from calling LinuxIa32.isaSingleton () to 
> LinuxPpc64.isaSingleton ().  You can see, it is hard-wired too, but bound 
> to a different platform though.  :-)
> 
> I am now thinking of what is the best way to eliminate this kind 
> of hard-wire?
> 
> 1. use some kind of macro to choose the responsive class, such as:
> 
> #ifdef IA32
>   return LinuxIa32.isaSingleton ();
> #endif
> 
> #ifdef PPC64
>   return LinuxPpc64.isaSingleton ();
> #endif
> 
> #ifdef X86-64
>   return LinuxX86-64.isaSingleton ();
> #endif
> 
> 2. Use the same kind of reverse engineering in AuxvBuilder.java.  But this 
> can only get the wordSize and bigEndian.  What if two architectures have 
> the same pair of wordSize and bigEndian?
> 
> 3. Add some code in the process control module in the kernel to let it 
> report the ISA when get a GET_ISA ptrace command (or any other command)?
> 
> Any other ways?  Anyone is better?  Your comments are highly appreciated!
> 
> Regards
> - Wu Zhou
> 
> P.S: Appended is the LinuxPpc64.java I created.  Just FYI.
> 
> // This file is part of the program FRYSK.
> //
> // Copyright 2006, Red Hat Inc.
> //
> //
> // FRYSK is free software; you can redistribute it and/or modify it
> // under the terms of the GNU General Public License as published by
> // the Free Software Foundation; version 2 of the License.
> //
> // FRYSK is distributed in the hope that it will be useful, but
> // WITHOUT ANY WARRANTY; without even the implied warranty of
> // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> // General Public License for more details.
> // 
> // You should have received a copy of the GNU General Public License
> // along with FRYSK; if not, write to the Free Software Foundation,
> // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> // 
> // In addition, as a special exception, Red Hat, Inc. gives You the
> // additional right to link the code of FRYSK with code not covered
> // under the GNU General Public License ("Non-GPL Code") and to
> // distribute linked combinations including the two, subject to the
> // limitations in this paragraph. Non-GPL Code permitted under this
> // exception must only link to the code of FRYSK through those well
> // defined interfaces identified in the file named EXCEPTION found in
> // the source code files (the "Approved Interfaces"). The files of
> // Non-GPL Code may instantiate templates or use macros or inline
> // functions from the Approved Interfaces without causing the
> // resulting work to be covered by the GNU General Public
> // License. Only Red Hat, Inc. may make changes or additions to the
> // list of Approved Interfaces. You must obey the GNU General Public
> // License in all respects for all of the FRYSK code and other code
> // used in conjunction with FRYSK except the Non-GPL Code covered by
> // this exception. If you modify this file, you may extend this
> // exception to your version of the file, but you are not obligated to
> // do so. If you do not wish to provide this exception without
> // modification, you must delete this exception statement from your
> // version and license this file solely under the GPL without
> // exception.
> 
> package frysk.proc;
> 
> import inua.eio.ByteOrder;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import frysk.Config;
> 
> class LinuxPpc64
>     extends Isa
> {
>     private static Logger logger = Logger.getLogger (Config.FRYSK_LOG_ID);
>     static final int GPRS_OFFSET = 0;
>     
>     private Register[] gprs ()
>     {
> 	Register[] gprs = new Register[32];
> 	for (int i = 0; i < gprs.length; i++) {
> 	    gprs[i] = new Register (this, 0, GPRS_OFFSET + i*8, 
> 				    8, "gpr" + i);
> 	}
> 	return gprs;
>     }
>     Register[] gpr = gprs ();  // general purpose registers 
>     
>     Register nip = new Register (this, 0, 32*8, 8, "nip");
>     Register msr = new Register (this, 0, 33*8, 8, "msr");
>     Register orig_r3 = new Register (this, 0, 34*8, 8, "orig_r3");
>     Register ctr = new Register (this, 0, 35*8, 8, "ctr");
>     Register lnk = new Register (this, 0, 36*8, 8, "lnk");
>     Register xer = new Register (this, 0, 37*8, 8, "xer");
>     Register ccr = new Register (this, 0, 38*8, 8, "ccr");
>     Register mq = new Register (this, 0, 39*8, 8, "mq");
>     Register trap = new Register (this, 0, 40*8, 8, "trap");
>     Register dar = new Register (this, 0, 41*8, 8, "dar");
>     Register dsisr = new Register (this, 0, 42*8, 8, "dsisr");
>     Register result = new Register (this, 0, 43*8, 8, "result");
>     
>     long pc (Task task)
>     {
> 	return nip.get (task);
>     }
> 
>     LinuxPpc64 ()
>     {
> 	wordSize = 4;
> 	byteOrder = ByteOrder.BIG_ENDIAN;
>     }
> 
>     private static LinuxPpc64 isa;
>     static LinuxPpc64 isaSingleton ()
>     {
>         if (isa == null)
>             isa = new LinuxPpc64 ();
>         return isa;
>     }
> 
>     private SyscallEventInfo info;
>     SyscallEventInfo getSyscallEventInfo ()
>     {
> 	if (info == null)
> 	    info = new SyscallEventInfo ()
> 		{
> 		    int number (Task task)
> 		    {
> 			logger.log (Level.FINE, "Get GPR[0] {0}\n", gpr[0]); 
> 			return (int)gpr[0].get (task);
> 		    }
> 		    long returnCode (Task task)
> 		    {
> 			return gpr[3].get (task);
> 		    }
> 		    long arg (Task task, int n)
> 		    {
> 			switch (n) {
> 			case 0:
> 			    return (long)number (task);
> 			case 1:
> 			    return orig_r3.get (task);
> 			case 2:
> 			    return gpr[4].get (task);
> 			case 3:
> 			    return gpr[5].get (task);
> 			case 4:
> 			    return gpr[6].get (task);
> 			case 5:
> 			    return gpr[7].get (task);
> 			case 6:
> 			    return gpr[8].get (task);
> 			default:
> 			    throw new RuntimeException ("unknown syscall arg");
> 			}
> 		    }
> 		};
> 	return info;
>     }
> }
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]