* RE: tdep/983: PATCH : H8300 Simulator File I/O Implementation
@ 2003-03-13 11:25 D.Venkatasubramanian, Noida
2003-03-13 17:35 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: D.Venkatasubramanian, Noida @ 2003-03-13 11:25 UTC (permalink / raw)
To: cagney, Kazu Hirata, gdb-patches; +Cc: D.Venkatasubramanian, Noida
[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]
Hi All,
Based on suggestions from various people and
changes to the patch, here is the final patch.
Andrew, did you approve the latest one?
Attaching the regenerated patch, as there
were some offsets.
Newlib part of the patch has already been
checked in, so this needs to be applied
for the simulator to work correctly.
OK to apply?
http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&databas
e=gdb&pr=983
Thanks and Regards,
Venky :-)
2003-03-13 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.
>-----Original Message-----
>From: cagney@redhat.com [mailto:cagney@redhat.com]
>Sent: Saturday, March 08, 2003 5:32 AM
>To: D.Venkatasubramanian, Noida; gdb-prs@sources.redhat.com;
>nobody@sources.redhat.com
>Subject: Re: tdep/983: PATCH : H8300 Simulator File I/O Implementation
>
>
>Synopsis: PATCH : H8300 Simulator File I/O Implementation
>
>State-Changed-From-To: analyzed->feedback
>State-Changed-By: cagney
>State-Changed-When: Sat Mar 8 00:01:57 2003
>State-Changed-Why:
> yes ok, approved.
> you're correctly using the callback-> methods so that it
>will work both with gdb and standalone sim.
>
>http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-
trail&database=gdb&pr=983
[-- Attachment #2: compile_fileio_patch.txt --]
[-- Type: text/plain, Size: 11868 bytes --]
Index: compile.c
===================================================================
RCS file: /cvs/src/src/sim/h8300/compile.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 compile.c
*** compile.c 27 Feb 2003 23:26:33 -0000 1.23
--- compile.c 13 Mar 2003 11:09:08 -0000
***************
*** 35,40 ****
--- 35,42 ----
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/sim-h8300.h"
+ #include "sys/stat.h"
+ #include "sys/types.h"
#ifndef SIGTRAP
# define SIGTRAP 5
*************** decode (int addr, unsigned char *data, d
*** 447,460 ****
dst->opcode = q->how;
dst->cycles = q->time;
! /* And a jsr to 0xc4 is turned into a magic trap. */
if (dst->opcode == O (O_JSR, SB))
{
! if (dst->src.literal == 0xc4)
{
! dst->opcode = O (O_SYSCALL, SB);
}
}
dst->next_pc = addr + len / 2;
--- 449,484 ----
dst->opcode = q->how;
dst->cycles = q->time;
! /* And a jsr to these locations are turned into magic
! traps. */
if (dst->opcode == O (O_JSR, SB))
{
! switch (dst->src.literal)
{
! case 0xc5:
! dst->opcode = O (O_SYS_OPEN, SB);
! break;
! case 0xc6:
! dst->opcode = O (O_SYS_READ, SB);
! break;
! case 0xc7:
! dst->opcode = O (O_SYS_WRITE, SB);
! break;
! case 0xc8:
! dst->opcode = O (O_SYS_LSEEK, SB);
! break;
! case 0xc9:
! dst->opcode = O (O_SYS_CLOSE, SB);
! break;
! case 0xca:
! dst->opcode = O (O_SYS_STAT, SB);
! break;
! case 0xcb:
! dst->opcode = O (O_SYS_FSTAT, SB);
! break;
}
+ /* End of Processing for system calls. */
}
dst->next_pc = addr + len / 2;
*************** sim_resume (SIM_DESC sd, int step, int s
*** 1386,1397 ****
goto condtrue;
goto next;
! case O (O_SYSCALL, SB):
{
! char c = cpu.regs[2];
! sim_callback->write_stdout (sim_callback, &c, 1);
}
goto next;
ONOT (O_NOT, rd = ~rd; v = 0;);
OSHIFTS (O_SHLL,
--- 1410,1698 ----
goto condtrue;
goto next;
! /* System call processing starts. */
! case O (O_SYS_OPEN, SB):
{
! int len = 0; /* Length of filename. */
! char *filename; /* Filename would go here. */
! char temp_char; /* Temporary character */
! int mode = 0; /* Mode bits for the file. */
! int open_return; /* Return value of open, file descriptor. */
! int i; /* Loop counter */
! int filename_ptr; /* Pointer to filename in cpu memory. */
!
! /* Setting filename_ptr to first argument of open. */
! filename_ptr = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
!
! /* Trying to get mode. */
! if (h8300hmode || h8300smode)
! {
! mode = GET_MEMORY_L (cpu.regs[7] + 4);
! }
! else
! {
! mode = GET_MEMORY_W (cpu.regs[7] + 2);
! }
!
! /* Trying to find the length of the filename. */
! temp_char = GET_MEMORY_B (cpu.regs[0]);
!
! len = 1;
! while (temp_char != '\0')
! {
! temp_char = GET_MEMORY_B (filename_ptr + len);
! len++;
! }
!
! /* Allocating space for the filename. */
! filename = (char *) malloc (sizeof (char) * len);
!
! /* String copying the filename from memory. */
! for (i = 0; i < len; i++)
! {
! temp_char = GET_MEMORY_B (filename_ptr + i);
! filename[i] = temp_char;
! }
!
! /* Callback to open and return the file descriptor. */
! open_return = sim_callback->open (sim_callback, filename, mode);
!
! /* Return value in register 0. */
! cpu.regs[0] = open_return;
!
! /* Freeing memory used for filename. */
! free (filename);
! }
! goto next;
!
! case O (O_SYS_READ, SB):
! {
! char *char_ptr; /* Where characters read would be stored. */
! int fd; /* File descriptor */
! int buf_size; /* BUF_SIZE parameter in read. */
! int i = 0; /* Temporary Loop counter */
! int read_return = 0; /* Return value from callback to
! read. */
!
! fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
! buf_size = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
!
! char_ptr = (char *) malloc (sizeof (char) * buf_size);
!
! /* Callback to read and return the no. of characters read. */
! read_return =
! sim_callback->read (sim_callback, fd, char_ptr, buf_size);
!
! /* The characters read are stored in cpu memory. */
! for (i = 0; i < buf_size; i++)
! {
! SET_MEMORY_B ((cpu.regs[1] + (sizeof (char) * i)),
! *(char_ptr + (sizeof (char) * i)));
! }
!
! /* Return value in Register 0. */
! cpu.regs[0] = read_return;
!
! /* Freeing memory used as buffer. */
! free (char_ptr);
! }
! goto next;
!
! case O (O_SYS_WRITE, SB):
! {
! int fd; /* File descriptor */
! char temp_char; /* Temporary character */
! int len; /* Length of write, Parameter II to write. */
! int char_ptr; /* Character Pointer, Parameter I of write. */
! char *ptr; /* Where characters to be written are stored.
! */
! int write_return; /* Return value from callback to write. */
! int i = 0; /* Loop counter */
!
! fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
! char_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
! len = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
!
! /* Allocating space for the characters to be written. */
! ptr = (char *) malloc (sizeof (char) * len);
!
! /* Fetching the characters from cpu memory. */
! for (i = 0; i < len; i++)
! {
! temp_char = GET_MEMORY_B (char_ptr + i);
! ptr[i] = temp_char;
! }
!
! /* Callback write and return the no. of characters written. */
! write_return = sim_callback->write (sim_callback, fd, ptr, len);
!
! /* Return value in Register 0. */
! cpu.regs[0] = write_return;
!
! /* Freeing memory used as buffer. */
! free (ptr);
! }
! goto next;
!
! case O (O_SYS_LSEEK, SB):
! {
! int fd; /* File descriptor */
! int offset; /* Offset */
! int origin; /* Origin */
! int lseek_return; /* Return value from callback to lseek. */
!
! fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
! offset = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
! origin = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);
!
! /* Callback lseek and return offset. */
! lseek_return =
! sim_callback->lseek (sim_callback, fd, offset, origin);
!
! /* Return value in register 0. */
! cpu.regs[0] = lseek_return;
! }
! goto next;
!
! case O (O_SYS_CLOSE, SB):
! {
! int fd; /* File descriptor */
! int close_return; /* Return value from callback to close. */
!
! fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
!
! /* Callback close and return. */
! close_return = sim_callback->close (sim_callback, fd);
!
! /* Return value in register 0. */
! cpu.regs[0] = close_return;
! }
! goto next;
!
! case O (O_SYS_FSTAT, SB):
! {
! int fd; /* File descriptor */
! struct stat stat_rec; /* Stat record */
! int fstat_return; /* Return value from callback to stat. */
! int stat_ptr; /* Pointer to stat record. */
! char *temp_stat_ptr; /* Temporary stat_rec pointer. */
!
! fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
!
! /* Setting stat_ptr to second argument of stat. */
! stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
!
! /* Callback stat and return. */
! fstat_return = sim_callback->fstat (sim_callback, fd, &stat_rec);
!
! /* Have stat_ptr point to starting of stat_rec. */
! temp_stat_ptr = (char *) (&stat_rec);
!
! /* Setting up the stat structure returned. */
! SET_MEMORY_W (stat_ptr, stat_rec.st_dev);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_ino);
! stat_ptr += 2;
! SET_MEMORY_L (stat_ptr, stat_rec.st_mode);
! stat_ptr += 4;
! SET_MEMORY_W (stat_ptr, stat_rec.st_nlink);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_uid);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_gid);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_rdev);
! stat_ptr += 2;
! SET_MEMORY_L (stat_ptr, stat_rec.st_size);
! stat_ptr += 4;
! SET_MEMORY_L (stat_ptr, stat_rec.st_atime);
! stat_ptr += 8;
! SET_MEMORY_L (stat_ptr, stat_rec.st_mtime);
! stat_ptr += 8;
! SET_MEMORY_L (stat_ptr, stat_rec.st_ctime);
!
! /* Return value in register 0. */
! cpu.regs[0] = fstat_return;
! }
! goto next;
!
! case O (O_SYS_STAT, SB):
! {
! int len = 0; /* Length of filename. */
! char *filename; /* Filename would go here. */
! char temp_char; /* Temporary character */
! int filename_ptr; /* Pointer to filename in cpu memory. */
! struct stat stat_rec; /* Stat record */
! int stat_return; /* Return value from callback to stat */
! int stat_ptr; /* Pointer to stat record. */
! char *temp_stat_ptr; /* Temporary stat_rec pointer. */
! int i = 0; /* Loop Counter */
!
! /* Setting filename_ptr to first argument of open. */
! filename_ptr = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);
!
! /* Trying to find the length of the filename. */
! temp_char = GET_MEMORY_B (cpu.regs[0]);
!
! len = 1;
! while (temp_char != '\0')
! {
! temp_char = GET_MEMORY_B (filename_ptr + len);
! len++;
! }
!
! /* Allocating space for the filename. */
! filename = (char *) malloc (sizeof (char) * len);
!
! /* String copying the filename from memory. */
! for (i = 0; i < len; i++)
! {
! temp_char = GET_MEMORY_B (filename_ptr + i);
! filename[i] = temp_char;
! }
!
! /* Setting stat_ptr to second argument of stat. */
! /* stat_ptr = cpu.regs[1]; */
! stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);
!
! /* Callback stat and return. */
! stat_return =
! sim_callback->stat (sim_callback, filename, &stat_rec);
!
! /* Have stat_ptr point to starting of stat_rec. */
! temp_stat_ptr = (char *) (&stat_rec);
!
! /* Freeing memory used for filename. */
! free (filename);
!
! /* Setting up the stat structure returned. */
! SET_MEMORY_W (stat_ptr, stat_rec.st_dev);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_ino);
! stat_ptr += 2;
! SET_MEMORY_L (stat_ptr, stat_rec.st_mode);
! stat_ptr += 4;
! SET_MEMORY_W (stat_ptr, stat_rec.st_nlink);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_uid);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_gid);
! stat_ptr += 2;
! SET_MEMORY_W (stat_ptr, stat_rec.st_rdev);
! stat_ptr += 2;
! SET_MEMORY_L (stat_ptr, stat_rec.st_size);
! stat_ptr += 4;
! SET_MEMORY_L (stat_ptr, stat_rec.st_atime);
! stat_ptr += 8;
! SET_MEMORY_L (stat_ptr, stat_rec.st_mtime);
! stat_ptr += 8;
! SET_MEMORY_L (stat_ptr, stat_rec.st_ctime);
!
! /* Return value in register 0. */
! cpu.regs[0] = stat_return;
}
goto next;
+ /* End of system call processing. */
ONOT (O_NOT, rd = ~rd; v = 0;);
OSHIFTS (O_SHLL,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: tdep/983: PATCH : H8300 Simulator File I/O Implementation
2003-03-13 11:25 tdep/983: PATCH : H8300 Simulator File I/O Implementation D.Venkatasubramanian, Noida
@ 2003-03-13 17:35 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-03-13 17:35 UTC (permalink / raw)
To: D.Venkatasubramanian, Noida; +Cc: cagney, Kazu Hirata, gdb-patches
> Hi All,
>
> Based on suggestions from various people and
> changes to the patch, here is the final patch.
>
> Andrew, did you approve the latest one?
>
> Attaching the regenerated patch, as there
> were some offsets.
>
> Newlib part of the patch has already been
> checked in, so this needs to be applied
> for the simulator to work correctly.
>
> OK to apply?
Yes, (you forgot to re-post the changelog, don't forget to update it's
date before committing).
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: tdep/983: PATCH : H8300 Simulator File I/O Implementation
@ 2003-03-14 4:24 D.Venkatasubramanian, Noida
0 siblings, 0 replies; 3+ messages in thread
From: D.Venkatasubramanian, Noida @ 2003-03-14 4:24 UTC (permalink / raw)
To: gdb-patches
>-----Original Message-----
>From: Andrew Cagney [mailto:ac131313@redhat.com]
>Sent: Thursday, March 13, 2003 11:06 PM
>To: D.Venkatasubramanian, Noida
>Cc: cagney@redhat.com; Kazu Hirata; gdb-patches@sources.redhat.com
>Subject: Re: tdep/983: PATCH : H8300 Simulator File I/O Implementation
>
>
>> Hi All,
>>
-- snip
>>
>> OK to apply?
>
>Yes, (you forgot to re-post the changelog, don't forget to update it's
>date before committing).
Applied.
2003-03-14 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.
>
>Andrew
>
>
Venky
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-03-14 4:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 11:25 tdep/983: PATCH : H8300 Simulator File I/O Implementation D.Venkatasubramanian, Noida
2003-03-13 17:35 ` Andrew Cagney
2003-03-14 4:24 D.Venkatasubramanian, Noida
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox