spu_run(2) System Calls Manual spu_run(2) spu_run - SPU LIBRARY Standard C library (libc, -lc) #include /* SPU_* */ #include /* SYS_* */ #include int syscall(SYS_spu_run, int fd, uint32_t *npc, uint32_t *event); Note: glibc provides no wrapper for spu_run(), necessitating the use of syscall(2). spu_run() PowerPC Cell Broadband Engine Synergistic Processor Unit (SPU). fd , spu_create(2) SPU. SPU, , npc. SPU , spu_run() SPU. SPU SPU, ( pthread_create(3)). spu_run() SPU npc, npc spu_run(). event . SPU SPU_CREATE_EVENTS_ENABLED, Linux spu_run(). ( ) : SPE_EVENT_DMA_ALIGNMENT DMA. SPE_EVENT_INVALID_DMA MFC DMA. SPE_EVENT_SPE_DATA_STORAGE DMA. SPE_EVENT_SPE_ERROR . event NULL. . On success, spu_run() returns the value of the spu_status register. On failure, it returns -1 and sets errno is set to indicate the error. spu_status 14- , stop-and-signal SPU. : 0x02 SPU stop-and-signal. 0x04 SPU halt. 0x08 SPU . 0x10 SPU . 0x20 SPU . 0x40 SPU . 0x3fff0000 , stop-and-signal. , 0x02. spu_run() , . EBADF fd . EFAULT npc event NULL . EINTR spu_run() ; . signal(7). , npc . EINVAL fd , spu_create(2). ENOMEM Memory Flow Controller (MFC). ENOSYS , SPU, spufs. Linux on PowerPC. Linux 2.6.16. spu_run() is meant to be used from libraries that implement a more abstract interface to SPUs, not to be used from regular applications. See for the recommended libraries. , SPU spu_run(). #include #include #include #include #include #include #include int main(void) { int context, fd, spu_status; uint32_t instruction, npc; context = syscall(SYS_spu_create, "/spu/example-context", 0, 0755); if (context == -1) err(EXIT_FAILURE, "spu_create"); /* * Write a 'stop 0x1234' instruction to the SPU's * local store memory. */ instruction = 0x00001234; fd = open("/spu/example-context/mem", O_RDWR); if (fd == -1) err(EXIT_FAILURE, "open"); write(fd, &instruction, sizeof(instruction)); /* * set npc to the starting instruction address of the * SPU program. Since we wrote the instruction at the * start of the mem file, the entry point will be 0x0. */ npc = 0; spu_status = syscall(SYS_spu_run, context, &npc, NULL); if (spu_status == -1) err(EXIT_FAILURE, "open"); /* * We should see a status code of 0x12340002: * 0x00000002 (spu was stopped due to stop-and-signal) * | 0x12340000 (the stop-and-signal code) */ printf("SPU Status: %#08x\n", spu_status); exit(EXIT_SUCCESS); } . close(2), spu_create(2), capabilities(7), spufs(7) Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . spu_run(2)