^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) spu_create
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) spu_create - create a new spu context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <sys/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <sys/spu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int spu_create(const char *pathname, int flags, mode_t mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) The spu_create system call is used on PowerPC machines that implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) the Cell Broadband Engine Architecture in order to access Synergistic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Processor Units (SPUs). It creates a new logical context for an SPU in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) pathname and returns a handle to associated with it. pathname must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) point to a non-existing directory in the mount point of the SPU file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) system (spufs). When spu_create is successful, a directory gets cre-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ated on pathname and it is populated with files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) The returned file handle can only be passed to spu_run(2) or closed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) other operations are not defined on it. When it is closed, all associ-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ated directory entries in spufs are removed. When the last file handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) pointing either inside of the context directory or to this file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) descriptor is closed, the logical SPU context is destroyed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) The parameter flags can be zero or any bitwise or'd combination of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) following constants:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) SPU_RAWIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Allow mapping of some of the hardware registers of the SPU into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) user space. This flag requires the CAP_SYS_RAWIO capability, see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) capabilities(7).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) The mode parameter specifies the permissions used for creating the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) directory in spufs. mode is modified with the user's umask(2) value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) and then used for both the directory and the files contained in it. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) file permissions mask out some more bits of mode because they typically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) support only read or write access. See stat(2) for a full list of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) possible mode values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) spu_create returns a new file descriptor. It may return -1 to indicate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) an error condition and set errno to one of the error codes listed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) Errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) EACCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) The current user does not have write access on the spufs mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) EEXIST An SPU context already exists at the given path name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) EFAULT pathname is not a valid string pointer in the current address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) EINVAL pathname is not a directory in the spufs mount point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ELOOP Too many symlinks were found while resolving pathname.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) EMFILE The process has reached its maximum open file limit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) ENAMETOOLONG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) pathname was too long.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ENFILE The system has reached the global open file limit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) ENOENT Part of pathname could not be resolved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ENOMEM The kernel could not allocate all resources required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ENOSPC There are not enough SPU resources available to create a new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) context or the user specific limit for the number of SPU con-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) texts has been reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ENOSYS the functionality is not provided by the current system, because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) either the hardware does not provide SPUs or the spufs module is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) not loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ENOTDIR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) A part of pathname is not a directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) Notes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) =====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) spu_create is meant to be used from libraries that implement a more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) abstract interface to SPUs, not to be used from regular applications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) See http://www.bsc.es/projects/deepcomputing/linuxoncell/ for the rec-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ommended libraries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) =====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) pathname must point to a location beneath the mount point of spufs. By
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) convention, it gets mounted in /spu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) Conforming to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) This call is Linux specific and only implemented by the ppc64 architec-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ture. Programs using this system call are not portable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Bugs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) The code does not yet fully implement all features lined out here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) Author
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) Arnd Bergmann <arndb@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) See Also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) capabilities(7), close(2), spu_run(2), spufs(7)