From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 641 invoked by alias); 14 May 2002 08:52:14 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 526 invoked from network); 14 May 2002 08:52:01 -0000 Received: from unknown (HELO sohm.kpit.com) (203.129.230.82) by sources.redhat.com with SMTP; 14 May 2002 08:52:01 -0000 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [PATCH] Add support for scanf, gets in h8300 simulator X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 Date: Tue, 14 May 2002 01:52:00 -0000 Message-ID: <69595093233BB547BB70CF5E492B63F22C51E1@sohm.kpit.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: "Dhananjay R. Deshpande" To: , X-SW-Source: 2002-05/txt/msg00533.txt.bz2 Hi, This patch to gdb and newlib adds support for reading from STDIN in h8300 s= imulator. Currently functions like scanf and gets are not working with h830= 0 simulator, this patch shall provide that functionality. For Simulator - 2002-05-14 Dhananjay Deshpande * include/opcode/h8300.h: Add #define for SYSCALL_READ * sim/h8300/compile.c: Convert magic trap 0xC8 into SYSCALL_READ For Newlib -=20 2002-05-14 Dhananjay Deshpande * newlib/libc/sys/h8300hms/syscalls.c: Moved _read() to read.c * newlib/libc/sys/h8300hms/read.c: New file. Magic trap 0xC8 for Simulator * newlib/libc/sys/h8300hms/Makeile.in: include new file read.c in lib.a =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *** include/opcode/h8300.h Tue May 14 11:25:29 2002 --- include/opcode/h8300.h.new Tue May 14 11:25:19 2002 *************** *** 296,300 **** #define O_ILL 76 #define O_ADDS 77 ! #define O_SYSCALL 78 #define O_MOV_TO_REG 79 #define O_TAS 80 --- 296,300 ---- #define O_ILL 76 #define O_ADDS 77 ! #define O_SYSCALL_WRITE 78 #define O_MOV_TO_REG 79 #define O_TAS 80 *************** *** 305,309 **** #define O_STM 86 #define O_STMAC 87 ! #define O_LAST 88 #define SB 0 #define SW 1 --- 305,310 ---- #define O_STM 86 #define O_STMAC 87 ! #define O_SYSCALL_READ 88 ! #define O_LAST 89 #define SB 0 #define SW 1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *** sim/h8300/compile.c Tue May 14 11:19:24 2002 --- sim/h8300/compile.c.new Tue May 14 11:19:19 2002 *************** *** 433,437 **** dst->cycles =3D q->time; =20=20 ! /* And a jsr to 0xc4 is turned into a magic trap. */ =20=20 if (dst->opcode =3D=3D O (O_JSR, SB)) --- 433,437 ---- dst->cycles =3D q->time; =20=20 ! /* And a jsr to 0xc4 and 0xc8 is turned into a magic trap. */ =20=20 if (dst->opcode =3D=3D O (O_JSR, SB)) *************** *** 439,443 **** if (dst->src.literal =3D=3D 0xc4) { ! dst->opcode =3D O (O_SYSCALL, SB); } } --- 439,448 ---- if (dst->src.literal =3D=3D 0xc4) { ! dst->opcode =3D O (O_SYSCALL_WRITE, SB); ! } ! else ! if (dst->src.literal =3D=3D 0xc8) ! { ! dst->opcode =3D O (O_SYSCALL_READ, SB); } } *************** *** 1267,1274 **** goto next; =20=20 ! case O (O_SYSCALL, SB): { char c =3D cpu.regs[2]; sim_callback->write_stdout (sim_callback, &c, 1); } goto next; --- 1272,1292 ---- goto next; =20=20 ! case O (O_SYSCALL_WRITE, SB): { char c =3D cpu.regs[2]; sim_callback->write_stdout (sim_callback, &c, 1); + } + goto next; +=20 + case O (O_SYSCALL_READ, SB): + { + if (h8300hmode) + { + cpu.regs[0] =3D sim_callback->read (sim_callback, cpu.regs[1], (cha= r *) (cpu.regs[2] + cpu.memory) , cpu.regs[3]); + } + else + { + cpu.regs[0] =3D sim_callback->read (sim_callback, cpu.regs[1], (cha= r *) ((unsigned short)cpu.regs[2] + cpu.memory) , cpu.regs[3]); + } } goto next; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *** newlib/libc/sys/h8300hms/syscalls.c Fri May 10 12:20:53 2002 --- newlib/libc/sys/h8300hms/syscalls.c.new Tue May 14 10:49:33 2002 *************** *** 4,16 **** #include #include - #include -=20 - int _DEFUN(_read,(file, ptr, len), - int file _AND - char *ptr _AND - int len) - { - return 0; - } =20=20 =20=20 --- 4,7 ---- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *** newlib/libc/sys/h8300hms/read.c Tue May 14 10:50:53 2002 --- newlib/libc/sys/h8300hms/read.c.new Tue May 14 10:52:34 2002 *************** *** 0 **** --- 1,25 ---- +=20 + int _read(file, ptr, len) + int file; + char *ptr; + int len; + { + register int ret asm("r0") ; +=20 + // Type cast int as short so that we can copy values into 16 bit=20 + // registers in case of -mint32 switch is given. + // This is not going to affect data as file =3D 0 for stdin and len=3D10= 24=20 +=20 + asm("mov.w %0, r1" :: "r"((short)file) :"r1", "r2", "r3") ; + asm("mov.w %0, r3" :: "r"((short)len) :"r1", "r2", "r3") ; + #ifdef __H8300__ + asm("mov.w %0, r2" :: "r"(ptr) :"r1", "r2", "r3") ; + #else + asm("mov.l %0, er2" :: "r"(ptr) :"r1", "er2", "r3") ; + #endif + // This is magic trap similar to _write for simulator + asm("jsr @@0xc8") ; + return ret; + } +=20 +=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *** newlib/libc/sys/h8300hms/Makefile.in Fri May 10 12:20:53 2002 --- newlib/libc/sys/h8300hms/Makefile.in.new Tue May 14 10:54:46 2002 *************** *** 85,89 **** noinst_LIBRARIES =3D lib.a =20=20 ! lib_a_SOURCES =3D syscalls.c write.c _exit.c sbrk.c misc.c crt1.c =20=20 ACLOCAL_AMFLAGS =3D -I ../../.. --- 85,89 ---- noinst_LIBRARIES =3D lib.a =20=20 ! lib_a_SOURCES =3D syscalls.c write.c read.c _exit.c sbrk.c misc.c crt1.c =20=20 ACLOCAL_AMFLAGS =3D -I ../../.. *************** *** 99,103 **** LIBS =3D @LIBS@ lib_a_LIBADD =3D=20 ! lib_a_OBJECTS =3D syscalls.o write.o _exit.o sbrk.o misc.o crt1.o CFLAGS =3D @CFLAGS@ COMPILE =3D $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFL= AGS) $(CFLAGS) --- 99,103 ---- LIBS =3D @LIBS@ lib_a_LIBADD =3D=20 ! lib_a_OBJECTS =3D syscalls.o write.o read.o _exit.o sbrk.o misc.o crt1.o CFLAGS =3D @CFLAGS@ COMPILE =3D $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFL= AGS) $(CFLAGS) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Regards, Dhananjay ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Free download of GNUSH and GNUH8 tool chains for Hitachi's SH and H8 Series. The following site also offers free support to European customers. Read more at http://www.kpit.com/products/support.htm Latest versions of GNUSH and GNUH8 are released on Apr 1, 2002. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=20