This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib 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: PATCH : H8300 Simulator File I/O Implementation


Hi All,

Attached are patches and some new files that should add 
basic File I/O support to the H8300 simulator. This work 
is in continuation of the message I posted earlier :

http://sources.redhat.com/ml/gdb-patches/2002-12/msg00679.html

Based on some suggestions from Kazu Hirata, I have made some 
changes. The patch to binutils has already been applied so I am 
not attaching the same. The file newlib_patch.txt contains the 
changes required in newlib/libc/sys/h8300hms/syscalls.c and 
newlib/libc/sys/h8300hms/Makefile.in. the file 
simulator_patch.txt contains the changes required in 
sim/h8300/compile.c.

Some changes that were to be made to include/opcode/h8300.h have 
already been applied, hence that is not attached.

A listing of the major changes made are listed at the end of the 
mail. Two files read.c and write.c in newlib/libc/sys/h8300hms/ 
may be removed.

Any suggestions on these patches and how it could be improved are 
welcome. Please apply the patches if they are found appropriate.

Thanks Kazu for your invaluable suggestions.

Thanks and Regards,

Venky



ChangeLog entries :

Simulator Directory : sim/h8300/

2002-12-31  D.Venkatasubramanian <dvenkat@noida.hcltech.com>

	* compile.c (decode): Added code for some more magic traps.
	* compile.c (sim_resume): Added support for File I/O system
	calls through callback to host_system.
	System calls provided support for :
	open, read, write, lseek, close, stat, fstat
	Only basic support for stat and fstat.

Newlib Directory : newlib

2002-12-31   D.Venkatasubramanian <dvenkat@noida.hcltech.com>

        * /libc/sys/h8300hms/syscalls.c: Removed functions _open,
        _lseek, _close, _stat, _fstat.
        * /libc/sys/h8300hms/read.c: Removed.
        * /libc/sys/h8300hms/write.c: Removed.
        * /libc/sys/h8300hms/open.S: Hand coded assembly for
        implementing _open removed from syscalls.c.
        * /libc/sys/h8300hms/read.S: Hand coded assembly for
        implementing _read removed from read.c.
        * /libc/sys/h8300hms/write.S: Hand coded assembly for
        implementing _write removed from write.c.
        * /libc/sys/h8300hms/lseek.S: Hand coded assembly for
        implementing _lseek removed from syscalls.c.
        * /libc/sys/h8300hms/close.S: Hand coded assembly for
        implementing _close removed from syscalls.c.
        * /libc/sys/h8300hms/fstat.S: Hand coded assembly for
        implementing _fstat removed from syscalls.c.
        * /libc/sys/h8300hms/stat.S: Hand coded assembly for
        implementing _stat removed from syscalls.c.



PS:

Major changes made :

1) In newlib, the functions _open, _read, etc. present in 
newlib/libc/sys/h8300hms/syscalls.c have been removed from there.

2) These functiong are implemented directly in assembly as 
suggested by Kazu Hirata. The sizeof integers on H8300H and H8300S 
depends on whether -mint32 was given or not during compilation. And, 
also, to make sure that the contents of r0, r1, r2 are propagated
unchanged to the syscall even if the compiler optimization is not
turned on, the functions are implemented in assembly.
These files should be added to newlib/libc/sys/h8300hms/ directory.

Assembly files included :
open.S - implementation of _open
read.S - implementation of _read
write.S - implementation of _write
lseek.S - implementation of _lseek
close.S - implementation of _close
fstat.S - implementation of _fstat
stat.S - implementation of _stat

Once syscalls.c is removed, we could combine all the functions into a 
single syscalls.S file.

3) Change has to be made to Makefile.in in newlib/libc/sys/h8300hms/ 
directory.

Instead of the earlier entry:

lib_a_SOURCES = syscalls.c write.c _exit.c read.c sbrk.c misc.c crt1.c

It has been changed to:

lib_a_SOURCES = syscalls.c open.s read.s write.s lseek.s close.s stat.s \
fstat.s _exit.c sbrk.c misc.c crt1.c

Somehow, I have to specify open.s instead of open.S, even though the 
assembly files are named as open.S etc. Is this correct?

4) Files read.c and write.c are rendered redundant and hence should be 
removed.


Reading specs from
/export/venkat/gcc_release/h8300-elf/tools/bin/../lib/gcc-lib/h8300-elf/3.3/
specs
Configured with: /home/venkat/gcc_3_3/combined/configure
--prefix=/export/venkat/gcc_release/h8300-elf/tools/ --target=h8300-elf
--with-newlib --enable-languages=c,c++ --with-gnu-ld --with-gnu-as
--with-ld=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/ld
--with-as=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/as
--with-headers=/home/venkat/gcc_3_3/combined/newlib/libc/include/ :
(reconfigured) /home/venkat/gcc_3_3/combined/configure
--prefix=/export/venkat/gcc_release/h8300-elf/tools/ --target=h8300-elf
--with-newlib --enable-languages=c,c++ --with-gnu-ld --with-gnu-as
--with-ld=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/ld
--with-as=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/as
--with-headers=/home/venkat/gcc_3_3/combined/newlib/libc/include/ :
(reconfigured) /home/venkat/gcc_3_3/combined/configure
--prefix=/export/venkat/gcc_release/h8300-elf/tools/ --target=h8300-elf
--with-newlib --enable-languages=c,c++ --with-gnu-ld --with-gnu-as
--with-ld=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/ld
--with-as=/export/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/as
--with-headers=/home/venkat/gcc_3_3/combined/newlib/libc/include/
Thread model: single
gcc version 3.3 20020925 (experimental)

Attachment: close.S
Description: Binary data

Attachment: fstat.S
Description: Binary data

Attachment: lseek.S
Description: Binary data

Attachment: open.S
Description: Binary data

Attachment: read.S
Description: Binary data

Attachment: stat.S
Description: Binary data

Attachment: write.S
Description: Binary data

Attachment: simulator_patch.txt
Description: Text document

Attachment: newlib_patch.txt
Description: Text document

Attachment: ChangeLog.txt
Description: Text document


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