From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11112 invoked by alias); 28 Dec 2012 12:18:31 -0000 Received: (qmail 11063 invoked by uid 22791); 28 Dec 2012 12:18:26 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RCVD_IN_HOSTKARMA_YE,TW_NV X-Spam-Check-By: sourceware.org Received: from ch1ehsobe005.messaging.microsoft.com (HELO ch1outboundpool.messaging.microsoft.com) (216.32.181.185) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Dec 2012 12:18:18 +0000 Received: from mail238-ch1-R.bigfish.com (10.43.68.253) by CH1EHSOBE020.bigfish.com (10.43.70.77) with Microsoft SMTP Server id 14.1.225.23; Fri, 28 Dec 2012 12:18:17 +0000 Received: from mail238-ch1 (localhost [127.0.0.1]) by mail238-ch1-R.bigfish.com (Postfix) with ESMTP id E522E13A00A7; Fri, 28 Dec 2012 12:18:16 +0000 (UTC) X-Forefront-Antispam-Report: CIP:59.163.77.177;KIP:(null);UIP:(null);IPV:NLI;H:KCHJEXHC02.kpit.com;RD:59.163.77.177.static.vsnl.net.in;EFVD:NLI X-SpamScore: -3 X-BigFish: VPS-3(zz936eI154dI148cIzz1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h14ddh1504h1537h153bh15d0h162dh1631h1758h1155h) Received: from mail238-ch1 (localhost.localdomain [127.0.0.1]) by mail238-ch1 (MessageSwitch) id 1356697094756551_23889; Fri, 28 Dec 2012 12:18:14 +0000 (UTC) Received: from CH1EHSMHS003.bigfish.com (snatpool2.int.messaging.microsoft.com [10.43.68.232]) by mail238-ch1.bigfish.com (Postfix) with ESMTP id B62BA540051; Fri, 28 Dec 2012 12:18:14 +0000 (UTC) Received: from KCHJEXHC02.kpit.com (59.163.77.177) by CH1EHSMHS003.bigfish.com (10.43.70.3) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 28 Dec 2012 12:18:14 +0000 Received: from KCHJEXMB02.kpit.com ([169.254.2.126]) by KCHJEXHC02.kpit.com ([172.10.15.74]) with mapi id 14.02.0247.003; Fri, 28 Dec 2012 17:48:11 +0530 From: Kaushik Phatak To: Pedro Alves CC: "binutils@sourceware.org" , "gdb-patches@sourceware.org" , Joel Brobecker Subject: RE: [RFA] New port: CR16: BFD Changes required by the gdb port Date: Fri, 28 Dec 2012 12:18:00 -0000 Message-ID: References: <50CB6CA4.1060901@redhat.com> In-Reply-To: <50CB6CA4.1060901@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: kpitcummins.com Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00836.txt.bz2 Hi Pedro, Thanks for taking out time to review this. > It'd be nice if all these exported symbols were prefixed, to avoid > namespace collisions. I have added 'cr16_' as a prefix to all these exported symbols.=20 I have also fixed the 80-char limit for lines affected by this change. Please let me know if the below changes are ok. Thanks & Best Regards, Kaushik 2012-12-28 Kaushik Phatak opcodes/ChangeLog * cr16-dis.c (match_opcode,make_instruction: Remove static declaration. (dwordU,wordU): Moved typedefs to opcode/cr16.h (cr16_words,cr16_allWords,cr16_currInsn): Added prefix 'cr16_' bfd/Changelog=09 * config.bfd (cr16*-*-uclinux*): New target support.=09 include/opcode/ChangeLog * cr16.h (dwordU,wordU): Moved typedefs from cr16-dis.c (make_instruction,match_opcode): Added function prototypes. (cr16_words,cr16_allWords,cr16_currInsn): Declare as extern. =09 diff -uprN ./gdb_src.orig/opcodes/cr16-dis.c ./gdb_src/opcodes/cr16-dis.c --- ./gdb_src.orig/opcodes/cr16-dis.c 2012-05-17 20:43:25.000000000 +0530 +++ ./gdb_src/opcodes/cr16-dis.c 2012-12-28 17:24:14.000000000 +0530 @@ -36,9 +36,6 @@ /* Set Bit Mask - a mask to set all bits starting from offset 'offs'. */ #define SBM(offs) ((((1 << (32 - offs)) -1) << (offs))) =20 -typedef unsigned long dwordU; -typedef unsigned short wordU; - typedef struct { dwordU val; @@ -83,11 +80,11 @@ REG_ARG_TYPE; /* Current opcode table entry we're disassembling. */ const inst *instruction; /* Current instruction we're disassembling. */ -ins currInsn; +ins cr16_currInsn; /* The current instruction is read into 3 consecutive words. */ -wordU words[3]; +wordU cr16_words[3]; /* Contains all words in appropriate order. */ -ULONGLONG allWords; +ULONGLONG cr16_allWords; /* Holds the current processed argument number. */ int processing_argument_number; /* Nonzero means a IMM4 instruction. */ @@ -281,7 +278,7 @@ getprocpregname (int reg_index) return "ILLEGAL REGISTER"; } =20 -/* START and END are relating 'allWords' struct, which is 48 bits size. +/* START and END are relating 'cr16_allWords' struct, which is 48 bits siz= e. =20 START|--------|END +---------+---------+---------+---------+ @@ -317,12 +314,13 @@ build_mask (void) =20 /* Search for a matching opcode. Return 1 for success, 0 for failure. */ =20 -static int +int match_opcode (void) { unsigned long mask; /* The instruction 'constant' opcode doewsn't exceed 32 bits. */ - unsigned long doubleWord =3D (words[1] + (words[0] << 16)) & 0xffffffff; + unsigned long doubleWord =3D (cr16_words[1] + + (cr16_words[0] << 16)) & 0xffffffff; =20 /* Start searching from end of instruction table. */ instruction =3D &cr16_instruction[NUMOPCODES - 2]; @@ -360,38 +358,44 @@ make_argument (argument * a, int start_b switch (a->type) { case arg_r: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords,=20 + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->r =3D p.val; break; =20 case arg_rp: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->rp =3D p.val; break; =20 case arg_pr: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->pr =3D p.val; break; =20 case arg_prp: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->prp =3D p.val; break; =20 case arg_ic: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords,=20 + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->constant =3D p.val; break; =20 case arg_cc: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + a->= size), - inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); =20 a->cc =3D p.val; break; @@ -400,28 +404,30 @@ make_argument (argument * a, int start_b if ((IS_INSN_MNEMONIC ("cbitb")) || (IS_INSN_MNEMONIC ("sbitb")) || (IS_INSN_MNEMONIC ("tbitb"))) - p =3D makelongparameter (allWords, 8, 9); + p =3D makelongparameter (cr16_allWords, 8, 9); else - p =3D makelongparameter (allWords, 9, 10); + p =3D makelongparameter (cr16_allWords, 9, 10); a->i_r =3D p.val; - p =3D makelongparameter (allWords, inst_bit_size - a->size, inst_bit= _size); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - a->size, inst_bit_size); a->constant =3D p.val; break; =20 case arg_idxrp: - p =3D makelongparameter (allWords, start_bits + 12, start_bits + 13); + p =3D makelongparameter (cr16_allWords, start_bits + 12, start_bits = + 13); a->i_r =3D p.val; - p =3D makelongparameter (allWords, start_bits + 13, start_bits + 16); + p =3D makelongparameter (cr16_allWords, start_bits + 13, start_bits = + 16); a->rp =3D p.val; if (inst_bit_size > 32) { - p =3D makelongparameter (allWords, inst_bit_size - start_bits - 12, + p =3D makelongparameter (cr16_allWords, inst_bit_size - start_bits - 12, inst_bit_size); a->constant =3D ((p.val & 0xffff) | (p.val >> 8 & 0xf0000)); } else if (instruction->size =3D=3D 2) { - p =3D makelongparameter (allWords, inst_bit_size - 22, inst_bit_size); + p =3D makelongparameter (cr16_allWords, inst_bit_size - 22, + inst_bit_size); a->constant =3D (p.val & 0xf) | (((p.val >>20) & 0x3) << 4) | ((p.val >>14 & 0x3) << 6) | (((p.val >>7) & 0x1f) <<7); } @@ -431,41 +437,42 @@ make_argument (argument * a, int start_b break; case arg_rbase: - p =3D makelongparameter (allWords, inst_bit_size, inst_bit_size); + p =3D makelongparameter (cr16_allWords, inst_bit_size, inst_bit_size= ); a->constant =3D p.val; - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + 4), + p =3D makelongparameter (cr16_allWords, inst_bit_size - (start_bits = + 4), inst_bit_size - start_bits); a->r =3D p.val; break; =20 case arg_cr: - p =3D makelongparameter (allWords, start_bits + 12, start_bits + 16); + p =3D makelongparameter (cr16_allWords, start_bits + 12, start_bits = + 16); a->r =3D p.val; - p =3D makelongparameter (allWords, inst_bit_size - 16, inst_bit_size= ); + p =3D makelongparameter (cr16_allWords, inst_bit_size - 16, inst_bit= _size); a->constant =3D p.val; break; =20 case arg_crp: if (instruction->size =3D=3D 1) - p =3D makelongparameter (allWords, 12, 16); + p =3D makelongparameter (cr16_allWords, 12, 16); else - p =3D makelongparameter (allWords, start_bits + 12, start_bits + 16); + p =3D makelongparameter (cr16_allWords, start_bits + 12, start_bits + 16); a->rp =3D p.val; =20 if (inst_bit_size > 32) { - p =3D makelongparameter (allWords, inst_bit_size - start_bits - 12, + p =3D makelongparameter (cr16_allWords, inst_bit_size - start_bits - 12, inst_bit_size); a->constant =3D ((p.val & 0xffff) | (p.val >> 8 & 0xf0000)); } else if (instruction->size =3D=3D 2) { - p =3D makelongparameter (allWords, inst_bit_size - 16, inst_bit_size); + p =3D makelongparameter (cr16_allWords, inst_bit_size - 16,=20 + inst_bit_size); a->constant =3D p.val; } else if (instruction->size =3D=3D 1 && a->size !=3D 0) { - p =3D makelongparameter (allWords, 4, 8); + p =3D makelongparameter (cr16_allWords, 4, 8); if (IS_INSN_MNEMONIC ("loadw") || IS_INSN_MNEMONIC ("loadd") || IS_INSN_MNEMONIC ("storw") @@ -489,36 +496,37 @@ make_argument (argument * a, int start_b switch (a->size) { case 8 : - p =3D makelongparameter (allWords, 0, start_bits); + p =3D makelongparameter (cr16_allWords, 0, start_bits); a->constant =3D ((((p.val&0xf00)>>4)) | (p.val&0xf)); break; =20 case 24: if (instruction->size =3D=3D 3) { - p =3D makelongparameter (allWords, 16, inst_bit_size); + p =3D makelongparameter (cr16_allWords, 16, inst_bit_size); a->constant =3D ((((p.val>>16)&0xf) << 20) | (((p.val>>24)&0xf) << 16) | (p.val & 0xffff)); } else if (instruction->size =3D=3D 2) { - p =3D makelongparameter (allWords, 8, inst_bit_size); + p =3D makelongparameter (cr16_allWords, 8, inst_bit_size); a->constant =3D p.val; } break; =20 default: - p =3D makelongparameter (allWords, inst_bit_size - (start_bits + - a->size), inst_bit_size - start_bits); + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), + inst_bit_size - start_bits); a->constant =3D p.val; break; } } else { - p =3D makelongparameter (allWords, inst_bit_size - - (start_bits + a->size), + p =3D makelongparameter (cr16_allWords, + inst_bit_size - (start_bits + a->size), inst_bit_size - start_bits); a->constant =3D p.val; } @@ -734,13 +742,13 @@ print_arguments (ins *currentInsn, bfd_v =20 /* Build the instruction's arguments. */ =20 -static void +void make_instruction (void) { int i; unsigned int shift; =20 - for (i =3D 0; i < currInsn.nargs; i++) + for (i =3D 0; i < cr16_currInsn.nargs; i++) { argument a; =20 @@ -750,13 +758,13 @@ make_instruction (void) shift =3D instruction->operands[i].shift; =20 make_argument (&a, shift); - currInsn.arg[i] =3D a; + cr16_currInsn.arg[i] =3D a; } =20 /* Calculate instruction size (in bytes). */ - currInsn.size =3D instruction->size + (size_changed ? 1 : 0); + cr16_currInsn.size =3D instruction->size + (size_changed ? 1 : 0); /* Now in bits. */ - currInsn.size *=3D 2; + cr16_currInsn.size *=3D 2; } =20 /* Retrieve a single word from a given memory address. */ @@ -785,10 +793,10 @@ get_words_at_PC (bfd_vma memaddr, struct bfd_vma mem; =20 for (i =3D 0, mem =3D memaddr; i < 3; i++, mem +=3D 2) - words[i] =3D get_word_at_PC (mem, info); + cr16_words[i] =3D get_word_at_PC (mem, info); =20 - allWords =3D - ((ULONGLONG) words[0] << 32) + ((unsigned long) words[1] << 16) + word= s[2]; + cr16_allWords =3D ((ULONGLONG) cr16_words[0] << 32)=20 + + ((unsigned long) cr16_words[1] << 16) + cr16_words[2]; } =20 /* Prints the instruction by calling print_arguments after proper matching= . */ @@ -807,22 +815,22 @@ print_insn_cr16 (bfd_vma memaddr, struct /* Find a matching opcode in table. */ is_decoded =3D match_opcode (); /* If found, print the instruction's mnemonic and arguments. */ - if (is_decoded > 0 && (words[0] << 16 || words[1]) !=3D 0) + if (is_decoded > 0 && (cr16_words[0] << 16 || cr16_words[1]) !=3D 0) { if (strneq (instruction->mnemonic, "cinv", 4)) info->fprintf_func (info->stream,"%s", getcinvstring (instruction-= >mnemonic)); else info->fprintf_func (info->stream, "%s", instruction->mnemonic); =20 - if (((currInsn.nargs =3D get_number_of_operands ()) !=3D 0) + if (((cr16_currInsn.nargs =3D get_number_of_operands ()) !=3D 0) && ! (IS_INSN_MNEMONIC ("b"))) info->fprintf_func (info->stream, "\t"); make_instruction (); /* For push/pop/pushrtn with RA instructions. */ - if ((INST_HAS_REG_LIST) && ((words[0] >> 7) & 0x1)) - currInsn.nargs +=3D1; - print_arguments (&currInsn, memaddr, info); - return currInsn.size; + if ((INST_HAS_REG_LIST) && ((cr16_words[0] >> 7) & 0x1)) + cr16_currInsn.nargs +=3D1; + print_arguments (&cr16_currInsn, memaddr, info); + return cr16_currInsn.size; } =20 /* No match found. */ --- ./gdb_src.orig/bfd/config.bfd 2012-05-15 18:25:34.000000000 +0530 +++ ./gdb_src/bfd/config.bfd 2012-10-23 15:09:08.000000000 +0530 @@ -345,6 +345,11 @@ case "${targ}" in targ_underscore=3Dyes ;; =20 + cr16*-*-uclinux*) + targ_defvec=3Dbfd_elf32_cr16_vec + targ_underscore=3Dyes + ;; + cr16c-*-elf*) targ_defvec=3Dbfd_elf32_cr16c_vec targ_underscore=3Dyes --- ./gdb_src.orig/include/opcode/cr16.h 2010-04-15 15:56:09.000000000 +0530 +++ ./gdb_src/include/opcode/cr16.h 2012-12-28 12:49:50.000000000 +0530 @@ -435,4 +435,17 @@ extern const inst *instruction; typedef long long int LONGLONG; typedef unsigned long long ULONGLONG; =20 +/* Data types for opcode handling. */ +typedef unsigned long dwordU; +typedef unsigned short wordU; + +/* Globals to store opcode data and build the instruction. */ +extern wordU cr16_words[3]; +extern ULONGLONG cr16_allWords; +extern ins cr16_currInsn; + +/* Prototypes for function in cr16-dis.c. */ +void make_instruction (void); +int match_opcode (void); + #endif /* _CR16_H_ */=09