[PATCH] spu syscalls

Jeff Johnston jjohnstn@redhat.com
Thu Aug 24 02:50:00 GMT 2006


Patch checked in.

-- Jeff J.

Kazunori Asayama wrote:
> Hi,
> 
> The attached patch divides single SPU system call implementation file
> "syscalls.c" into individual files to avoid linking unused code.
> 
> 2006-08-23  Kazunori Asayama  <asayama@sm.sony.co.jp>
> 
> 	* spu/Makefile.in: Add new object files.
> 	* spu/syscalls.c: Move each system call to individual file.
> 	* spu/jsre.h: Add declaration of _send_to_ppe_0x2101().
> 	* spu/close.c: New file. Moved from spu/syscalls.c.
> 	* spu/fstat.c: Likewise.
> 	* spu/getpid.c: Likewise.
> 	* spu/isatty.c: Likewise.
> 	* spu/kill.c: Likewise.
> 	* spu/lseek.c: Likewise.
> 	* spu/open.c: Likewise.
> 	* spu/read.c: Likewise.
> 	* spu/stat.c: Likewise.
> 	* spu/unlink.c: Likewise.
> 	* spu/write.c: Likewise.
> 
> 
> Index: newlib-1.14.0/libgloss/spu/Makefile.in
> ===================================================================
> --- newlib-1.14.0.orig/libgloss/spu/Makefile.in	2006-08-16 14:32:24.000000000 +0900
> +++ newlib-1.14.0/libgloss/spu/Makefile.in	2006-08-16 19:18:22.000000000 +0900
> @@ -54,7 +54,8 @@
>  OBJCOPY = `t='$(program_transform_name)'; echo objcopy | sed -e $$t`
>  
>  # object files needed
> -OBJS = syscalls.o init.o exit.o sbrk.o
> +OBJS = syscalls.o init.o exit.o sbrk.o close.o fstat.o getpid.o isatty.o \
> +	kill.o lseek.o open.o read.o unlink.o write.o stat.o
>  
>  # Object files specific to particular targets.
>  EVALOBJS = ${OBJS}
> Index: newlib-1.14.0/libgloss/spu/close.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/close.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,49 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +close (int file)
> +{
> +        syscall_close_t sys ;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +	sys.file = file;
> +
> +        _send_to_ppe_0x2101 (JSRE_CLOSE, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/fstat.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/fstat.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,67 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <sys/stat.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +fstat (int file, struct stat *pstat)
> +{
> +        syscall_fstat_t sys;
> +        syscall_out_t   *psys_out = ( syscall_out_t* )&sys;
> +        jsre_stat_t pjstat;
> +
> +        sys.file = file;
> +        sys.ptr = ( unsigned int )&pjstat;
> +
> +        _send_to_ppe_0x2101 (JSRE_FSTAT, &sys);
> +
> +        pstat->st_dev = pjstat.dev;
> +        pstat->st_ino = pjstat.ino;
> +        pstat->st_mode = pjstat.mode;
> +        pstat->st_nlink = pjstat.nlink;
> +        pstat->st_uid = pjstat.uid;
> +        pstat->st_gid = pjstat.gid;
> +        pstat->st_rdev = pjstat.rdev;
> +        pstat->st_size = pjstat.size;
> +        pstat->st_blksize = pjstat.blksize;
> +        pstat->st_blocks = pjstat.blocks;
> +        pstat->st_atime = pjstat.atime;
> +        pstat->st_mtime = pjstat.mtime;
> +        pstat->st_ctime = pjstat.ctime;
> +
> +
> +        errno = psys_out->err;
> +        return( psys_out->rc );
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/getpid.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/getpid.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,38 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +int
> +getpid ()
> +{
> +	return (1);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/isatty.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/isatty.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,38 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +int
> +isatty (int fd)
> +{
> +	return (0);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/jsre.h
> ===================================================================
> --- newlib-1.14.0.orig/libgloss/spu/jsre.h	2006-08-16 14:32:24.000000000 +0900
> +++ newlib-1.14.0/libgloss/spu/jsre.h	2006-08-16 14:35:31.000000000 +0900
> @@ -152,5 +152,6 @@
>      unsigned int ctime;
>  } jsre_stat_t;
>  
> +void _send_to_ppe_0x2101 (int opcode, void *data);
>  
>  #endif
> Index: newlib-1.14.0/libgloss/spu/kill.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/kill.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,43 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <unistd.h>
> +
> +int
> +kill (int pid, int sig)
> +{
> +	if (pid == 1)
> +	  {
> +		  _exit (sig);
> +	  }
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/lseek.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/lseek.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,63 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <unistd.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +off_t
> +lseek (int file, off_t offset, int whence)
> +{
> +        syscall_lseek_t sys;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +	sys.file = file;
> +	sys.offset = offset;
> +
> +	switch( whence ){
> +		case SEEK_SET:
> +			sys.whence = JSRE_SEEK_SET;
> +			break;
> +		case SEEK_CUR:
> +			sys.whence = JSRE_SEEK_CUR;
> +			break;
> +		case SEEK_END:
> +			sys.whence = JSRE_SEEK_END;
> +			break;
> +	}
> +
> +	_send_to_ppe_0x2101 (JSRE_LSEEK, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/open.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/open.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,89 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <stdarg.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +open (const char *filename, int flags, ...)
> +{
> +        syscall_open_t sys ;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +        sys.pathname = ( unsigned int )filename;
> +
> +	sys.flags = 0;
> +
> +	sys.flags |= ( ( flags & O_CREAT ) ? JSRE_O_CREAT : 0 );
> +	sys.flags |= ( ( flags & O_EXCL ) ? JSRE_O_EXCL : 0 );
> +	sys.flags |= ( ( flags & O_NOCTTY ) ? JSRE_O_NOCTTY : 0 );
> +	sys.flags |= ( ( flags & O_TRUNC ) ? JSRE_O_TRUNC : 0 );
> +	sys.flags |= ( ( flags & O_APPEND ) ? JSRE_O_APPEND : 0 );
> +//	sys.flags |= ( ( flags & O_NOBLOCK ) ? JSRE_O_NOBLOCK : 0 );
> +//	sys.flags |= ( ( flags & O_NDELAY ) ? JSRE_O_NDELAY : 0 );
> +	sys.flags |= ( ( flags & O_SYNC ) ? JSRE_O_SYNC : 0 );
> +//	sys.flags |= ( ( flags & O_NOFOLLOW ) ? JSRE_O_NOFOLLOW : 0 );
> +//	sys.flags |= ( ( flags & O_DIRECTORY ) ? JSRE_O_DIRECTORY : 0 );
> +//	sys.flags |= ( ( flags & O_DIRECT ) ? JSRE_O_DIRECT : 0 );
> +//	sys.flags |= ( ( flags & O_ASYNC ) ? JSRE_O_ASYNC : 0 );
> +//	sys.flags |= ( ( flags & O_LARGEFILE ) ? JSRE_O_LARGEFILE : 0 );
> +
> +
> +	sys.flags |= ( ( flags & O_RDONLY ) ? JSRE_O_RDONLY : 0 );
> +	sys.flags |= ( ( flags & O_WRONLY ) ? JSRE_O_WRONLY : 0 );
> +	sys.flags |= ( ( flags & O_RDWR )  ? JSRE_O_RDWR  : 0 );
> +
> +
> +	/* FIXME: we have to check/map all flags */
> +
> +        if ((sys.flags & O_CREAT))
> +          {
> +                  va_list ap;
> +
> +                  va_start (ap, flags);
> +                  sys.mode = va_arg (ap, int);
> +                  va_end (ap);
> +
> +          }
> +        else
> +          {
> +                  sys.mode = 0;
> +          }
> +
> +        _send_to_ppe_0x2101 ( JSRE_OPEN, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/read.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/read.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,52 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <fcntl.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +read (int file, void *ptr, size_t len)
> +{
> +        syscall_write_t sys;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +	sys.file = file;
> +	sys.ptr = ( unsigned int )ptr;
> +	sys.len = len;
> +
> +	_send_to_ppe_0x2101 (JSRE_READ, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/stat.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/stat.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,67 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <stdarg.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +stat (const char *pathname, struct stat *pstat)
> +{
> +	syscall_stat_t sys;
> +	syscall_out_t   *psys_out = ( syscall_out_t* )&sys;
> +	jsre_stat_t pjstat;
> +
> +	sys.pathname = pathname;
> +	sys.ptr = ( unsigned int )&pjstat;
> +
> +	_send_to_ppe_0x2101 (JSRE_STAT, &sys);
> +
> +	pstat->st_dev = pjstat.dev;
> +	pstat->st_ino = pjstat.ino;
> +	pstat->st_mode = pjstat.mode;
> +	pstat->st_nlink = pjstat.nlink;
> +	pstat->st_uid = pjstat.uid;
> +	pstat->st_gid = pjstat.gid;
> +	pstat->st_rdev = pjstat.rdev;
> +	pstat->st_size = pjstat.size;
> +	pstat->st_blksize = pjstat.blksize;
> +	pstat->st_blocks = pjstat.blocks;
> +	pstat->st_atime = pjstat.atime;
> +	pstat->st_mtime = pjstat.mtime;
> +	pstat->st_ctime = pjstat.ctime;
> +
> +	errno = psys_out->err;
> +	return( psys_out->rc );
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/syscalls.c
> ===================================================================
> --- newlib-1.14.0.orig/libgloss/spu/syscalls.c	2006-08-16 14:32:24.000000000 +0900
> +++ newlib-1.14.0/libgloss/spu/syscalls.c	2006-08-16 19:18:53.000000000 +0900
> @@ -30,19 +30,8 @@
>  Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
>  */
>  
> -#include <spu_intrinsics.h>
> -#include <stdarg.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <fcntl.h>
> -#include <unistd.h>
> -#include <errno.h>
> -#include "../syscall.h"
> -
> -#include "jsre.h"
> -
> -static void
> -send_to_ppe_0x2101 (int opcode, void *data)
> +void
> +_send_to_ppe_0x2101 (int opcode, void *data)
>  {
>  
>  	unsigned int	combined = ( ( opcode<<24 )&0xff000000 ) | ( ( unsigned int )data & 0x00ffffff );
> @@ -59,233 +48,3 @@
>          return (f ());
>  }
>  
> -
> -int
> -isatty (int fd)
> -{
> -	return (0);
> -}
> -
> -int
> -getpid ()
> -{
> -	return (1);
> -}
> -
> -int
> -kill (int pid, int sig)
> -{
> -	if (pid == 1)
> -	  {
> -		  _exit (sig);
> -	  }
> -}
> -
> -int
> -read (int file, void *ptr, size_t len)
> -{
> -        syscall_write_t sys;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -	sys.file = file;
> -	sys.ptr = ( unsigned int )ptr;
> -	sys.len = len;
> -
> -	send_to_ppe_0x2101 (JSRE_READ, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> -off_t
> -lseek (int file, off_t offset, int whence)
> -{
> -        syscall_lseek_t sys;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -	sys.file = file;
> -	sys.offset = offset;
> -
> -	switch( whence ){
> -		case SEEK_SET:
> -			sys.whence = JSRE_SEEK_SET;
> -			break;
> -		case SEEK_CUR:
> -			sys.whence = JSRE_SEEK_CUR;
> -			break;
> -		case SEEK_END:
> -			sys.whence = JSRE_SEEK_END;
> -			break;
> -	}
> -
> -	send_to_ppe_0x2101 (JSRE_LSEEK, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> -int
> -write (int file, const void *ptr, size_t len)
> -{
> -        syscall_write_t sys;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -	sys.file = file;
> -	sys.ptr = ( unsigned int )ptr;
> -	sys.len = len;
> -
> -	send_to_ppe_0x2101 (JSRE_WRITE, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> -int
> -open (const char *filename, int flags, ...)
> -{
> -        int rc;
> -        int len;
> -
> -        syscall_open_t sys ;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -        sys.pathname = ( unsigned int )filename;
> -
> -	sys.flags = 0;
> -
> -	sys.flags |= ( ( flags & O_CREAT ) ? JSRE_O_CREAT : 0 );
> -	sys.flags |= ( ( flags & O_EXCL ) ? JSRE_O_EXCL : 0 );
> -	sys.flags |= ( ( flags & O_NOCTTY ) ? JSRE_O_NOCTTY : 0 );
> -	sys.flags |= ( ( flags & O_TRUNC ) ? JSRE_O_TRUNC : 0 );
> -	sys.flags |= ( ( flags & O_APPEND ) ? JSRE_O_APPEND : 0 );
> -//	sys.flags |= ( ( flags & O_NOBLOCK ) ? JSRE_O_NOBLOCK : 0 );
> -//	sys.flags |= ( ( flags & O_NDELAY ) ? JSRE_O_NDELAY : 0 );
> -	sys.flags |= ( ( flags & O_SYNC ) ? JSRE_O_SYNC : 0 );
> -//	sys.flags |= ( ( flags & O_NOFOLLOW ) ? JSRE_O_NOFOLLOW : 0 );
> -//	sys.flags |= ( ( flags & O_DIRECTORY ) ? JSRE_O_DIRECTORY : 0 );
> -//	sys.flags |= ( ( flags & O_DIRECT ) ? JSRE_O_DIRECT : 0 );
> -//	sys.flags |= ( ( flags & O_ASYNC ) ? JSRE_O_ASYNC : 0 );
> -//	sys.flags |= ( ( flags & O_LARGEFILE ) ? JSRE_O_LARGEFILE : 0 );
> -
> -
> -	sys.flags |= ( ( flags & O_RDONLY ) ? JSRE_O_RDONLY : 0 );
> -	sys.flags |= ( ( flags & O_WRONLY ) ? JSRE_O_WRONLY : 0 );
> -	sys.flags |= ( ( flags & O_RDWR )  ? JSRE_O_RDWR  : 0 );
> -
> -
> -	/* FIXME: we have to check/map all flags */
> -
> -        if ((sys.flags & O_CREAT))
> -          {
> -                  va_list ap;
> -
> -                  va_start (ap, flags);
> -                  sys.mode = va_arg (ap, int);
> -                  va_end (ap);
> -
> -          }
> -        else
> -          {
> -                  sys.mode = 0;
> -          }
> -
> -        send_to_ppe_0x2101 ( JSRE_OPEN, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> -int
> -close (int file)
> -{
> -        int rc;
> -
> -        syscall_close_t sys ;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -	sys.file = file;
> -
> -        send_to_ppe_0x2101 (JSRE_CLOSE, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> -int
> -fstat (int file, struct stat *pstat)
> -{
> -        syscall_fstat_t sys;
> -        syscall_out_t   *psys_out = ( syscall_out_t* )&sys;
> -        jsre_stat_t pjstat;
> -
> -        sys.file = file;
> -        sys.ptr = ( unsigned int )&pjstat;
> -
> -        send_to_ppe_0x2101 (JSRE_FSTAT, &sys);
> -
> -        pstat->st_dev = pjstat.dev;
> -        pstat->st_ino = pjstat.ino;
> -        pstat->st_mode = pjstat.mode;
> -        pstat->st_nlink = pjstat.nlink;
> -        pstat->st_uid = pjstat.uid;
> -        pstat->st_gid = pjstat.gid;
> -        pstat->st_rdev = pjstat.rdev;
> -        pstat->st_size = pjstat.size;
> -        pstat->st_blksize = pjstat.blksize;
> -        pstat->st_blocks = pjstat.blocks;
> -        pstat->st_atime = pjstat.atime;
> -        pstat->st_mtime = pjstat.mtime;
> -        pstat->st_ctime = pjstat.ctime;
> -
> -
> -        errno = psys_out->err;
> -        return( psys_out->rc );
> -}
> -
> -int
> -stat (const char *pathname, struct stat *pstat)
> -{
> -        syscall_stat_t sys;
> -        syscall_out_t   *psys_out = ( syscall_out_t* )&sys;
> -        jsre_stat_t pjstat;
> -
> -        sys.pathname = pathname;
> -        sys.ptr = ( unsigned int )&pjstat;
> -
> -        send_to_ppe_0x2101 (JSRE_STAT, &sys);
> -
> -        pstat->st_dev = pjstat.dev;
> -        pstat->st_ino = pjstat.ino;
> -        pstat->st_mode = pjstat.mode;
> -        pstat->st_nlink = pjstat.nlink;
> -        pstat->st_uid = pjstat.uid;
> -        pstat->st_gid = pjstat.gid;
> -        pstat->st_rdev = pjstat.rdev;
> -        pstat->st_size = pjstat.size;
> -        pstat->st_blksize = pjstat.blksize;
> -        pstat->st_blocks = pjstat.blocks;
> -        pstat->st_atime = pjstat.atime;
> -        pstat->st_mtime = pjstat.mtime;
> -        pstat->st_ctime = pjstat.ctime;
> -
> -        errno = psys_out->err;
> -        return( psys_out->rc );
> -}
> -
> -
> -int
> -unlink (const char *pathname)
> -{
> -        int rc;
> -
> -        syscall_unlink_t sys ;
> -	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> -
> -	sys.pathname = ( unsigned int )pathname;
> -
> -        send_to_ppe_0x2101 (JSRE_UNLINK, &sys);
> -
> -        errno = psys_out->err;
> -        return ( psys_out->rc);
> -}
> -
> Index: newlib-1.14.0/libgloss/spu/unlink.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/unlink.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,49 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +unlink (const char *pathname)
> +{
> +        syscall_unlink_t sys ;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +	sys.pathname = ( unsigned int )pathname;
> +
> +        _send_to_ppe_0x2101 (JSRE_UNLINK, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +
> Index: newlib-1.14.0/libgloss/spu/write.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ newlib-1.14.0/libgloss/spu/write.c	2006-08-16 14:35:31.000000000 +0900
> @@ -0,0 +1,52 @@
> +/*
> +(C) Copyright IBM Corp. 2005, 2006
> +
> +All rights reserved.
> +
> +Redistribution and use in source and binary forms, with or without 
> +modification, are permitted provided that the following conditions are met:
> +
> +    * Redistributions of source code must retain the above copyright notice, 
> +this list of conditions and the following disclaimer.
> +    * Redistributions in binary form must reproduce the above copyright 
> +notice, this list of conditions and the following disclaimer in the 
> +documentation and/or other materials provided with the distribution.
> +    * Neither the name of IBM nor the names of its contributors may be 
> +used to endorse or promote products derived from this software without 
> +specific prior written permission.
> +
> +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
> +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
> +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
> +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
> +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
> +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
> +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
> +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
> +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> +POSSIBILITY OF SUCH DAMAGE.
> +
> +Author: Andreas Neukoetter (ti95neuk@de.ibm.com)
> +*/
> +
> +#include <fcntl.h>
> +#include <errno.h>
> +#include "jsre.h"
> +
> +int
> +write (int file, const void *ptr, size_t len)
> +{
> +        syscall_write_t sys;
> +	syscall_out_t	*psys_out = ( syscall_out_t* )&sys;
> +
> +	sys.file = file;
> +	sys.ptr = ( unsigned int )ptr;
> +	sys.len = len;
> +
> +	_send_to_ppe_0x2101 (JSRE_WRITE, &sys);
> +
> +        errno = psys_out->err;
> +        return ( psys_out->rc);
> +}
> +



More information about the Newlib mailing list