file.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /*
  2. * SPU file system -- file contents
  3. *
  4. * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
  5. *
  6. * Author: Arnd Bergmann <arndb@de.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2, or (at your option)
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <linux/fs.h>
  23. #include <linux/ioctl.h>
  24. #include <linux/module.h>
  25. #include <linux/pagemap.h>
  26. #include <linux/poll.h>
  27. #include <linux/ptrace.h>
  28. #include <asm/io.h>
  29. #include <asm/semaphore.h>
  30. #include <asm/spu.h>
  31. #include <asm/uaccess.h>
  32. #include "spufs.h"
  33. static int
  34. spufs_mem_open(struct inode *inode, struct file *file)
  35. {
  36. struct spufs_inode_info *i = SPUFS_I(inode);
  37. file->private_data = i->i_ctx;
  38. file->f_mapping = i->i_ctx->local_store;
  39. return 0;
  40. }
  41. static ssize_t
  42. spufs_mem_read(struct file *file, char __user *buffer,
  43. size_t size, loff_t *pos)
  44. {
  45. struct spu_context *ctx = file->private_data;
  46. char *local_store;
  47. int ret;
  48. spu_acquire(ctx);
  49. local_store = ctx->ops->get_ls(ctx);
  50. ret = simple_read_from_buffer(buffer, size, pos, local_store, LS_SIZE);
  51. spu_release(ctx);
  52. return ret;
  53. }
  54. static ssize_t
  55. spufs_mem_write(struct file *file, const char __user *buffer,
  56. size_t size, loff_t *pos)
  57. {
  58. struct spu_context *ctx = file->private_data;
  59. char *local_store;
  60. int ret;
  61. size = min_t(ssize_t, LS_SIZE - *pos, size);
  62. if (size <= 0)
  63. return -EFBIG;
  64. *pos += size;
  65. spu_acquire(ctx);
  66. local_store = ctx->ops->get_ls(ctx);
  67. ret = copy_from_user(local_store + *pos - size,
  68. buffer, size) ? -EFAULT : size;
  69. spu_release(ctx);
  70. return ret;
  71. }
  72. #ifdef CONFIG_SPARSEMEM
  73. static struct page *
  74. spufs_mem_mmap_nopage(struct vm_area_struct *vma,
  75. unsigned long address, int *type)
  76. {
  77. struct page *page = NOPAGE_SIGBUS;
  78. struct spu_context *ctx = vma->vm_file->private_data;
  79. unsigned long offset = address - vma->vm_start;
  80. offset += vma->vm_pgoff << PAGE_SHIFT;
  81. spu_acquire(ctx);
  82. if (ctx->state == SPU_STATE_SAVED)
  83. page = vmalloc_to_page(ctx->csa.lscsa->ls + offset);
  84. else
  85. page = pfn_to_page((ctx->spu->local_store_phys + offset)
  86. >> PAGE_SHIFT);
  87. spu_release(ctx);
  88. if (type)
  89. *type = VM_FAULT_MINOR;
  90. page_cache_get(page);
  91. return page;
  92. }
  93. static struct vm_operations_struct spufs_mem_mmap_vmops = {
  94. .nopage = spufs_mem_mmap_nopage,
  95. };
  96. static int
  97. spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
  98. {
  99. if (!(vma->vm_flags & VM_SHARED))
  100. return -EINVAL;
  101. /* FIXME: */
  102. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  103. | _PAGE_NO_CACHE);
  104. vma->vm_ops = &spufs_mem_mmap_vmops;
  105. return 0;
  106. }
  107. #endif
  108. static struct file_operations spufs_mem_fops = {
  109. .open = spufs_mem_open,
  110. .read = spufs_mem_read,
  111. .write = spufs_mem_write,
  112. .llseek = generic_file_llseek,
  113. #ifdef CONFIG_SPARSEMEM
  114. .mmap = spufs_mem_mmap,
  115. #endif
  116. };
  117. static int
  118. spufs_regs_open(struct inode *inode, struct file *file)
  119. {
  120. struct spufs_inode_info *i = SPUFS_I(inode);
  121. file->private_data = i->i_ctx;
  122. return 0;
  123. }
  124. static ssize_t
  125. spufs_regs_read(struct file *file, char __user *buffer,
  126. size_t size, loff_t *pos)
  127. {
  128. struct spu_context *ctx = file->private_data;
  129. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  130. int ret;
  131. spu_acquire_saved(ctx);
  132. ret = simple_read_from_buffer(buffer, size, pos,
  133. lscsa->gprs, sizeof lscsa->gprs);
  134. spu_release(ctx);
  135. return ret;
  136. }
  137. static ssize_t
  138. spufs_regs_write(struct file *file, const char __user *buffer,
  139. size_t size, loff_t *pos)
  140. {
  141. struct spu_context *ctx = file->private_data;
  142. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  143. int ret;
  144. size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
  145. if (size <= 0)
  146. return -EFBIG;
  147. *pos += size;
  148. spu_acquire_saved(ctx);
  149. ret = copy_from_user(lscsa->gprs + *pos - size,
  150. buffer, size) ? -EFAULT : size;
  151. spu_release(ctx);
  152. return ret;
  153. }
  154. static struct file_operations spufs_regs_fops = {
  155. .open = spufs_regs_open,
  156. .read = spufs_regs_read,
  157. .write = spufs_regs_write,
  158. .llseek = generic_file_llseek,
  159. };
  160. static ssize_t
  161. spufs_fpcr_read(struct file *file, char __user * buffer,
  162. size_t size, loff_t * pos)
  163. {
  164. struct spu_context *ctx = file->private_data;
  165. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  166. int ret;
  167. spu_acquire_saved(ctx);
  168. ret = simple_read_from_buffer(buffer, size, pos,
  169. &lscsa->fpcr, sizeof(lscsa->fpcr));
  170. spu_release(ctx);
  171. return ret;
  172. }
  173. static ssize_t
  174. spufs_fpcr_write(struct file *file, const char __user * buffer,
  175. size_t size, loff_t * pos)
  176. {
  177. struct spu_context *ctx = file->private_data;
  178. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  179. int ret;
  180. size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
  181. if (size <= 0)
  182. return -EFBIG;
  183. *pos += size;
  184. spu_acquire_saved(ctx);
  185. ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
  186. buffer, size) ? -EFAULT : size;
  187. spu_release(ctx);
  188. return ret;
  189. }
  190. static struct file_operations spufs_fpcr_fops = {
  191. .open = spufs_regs_open,
  192. .read = spufs_fpcr_read,
  193. .write = spufs_fpcr_write,
  194. .llseek = generic_file_llseek,
  195. };
  196. /* generic open function for all pipe-like files */
  197. static int spufs_pipe_open(struct inode *inode, struct file *file)
  198. {
  199. struct spufs_inode_info *i = SPUFS_I(inode);
  200. file->private_data = i->i_ctx;
  201. return nonseekable_open(inode, file);
  202. }
  203. static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
  204. size_t len, loff_t *pos)
  205. {
  206. struct spu_context *ctx = file->private_data;
  207. u32 mbox_data;
  208. int ret;
  209. if (len < 4)
  210. return -EINVAL;
  211. spu_acquire(ctx);
  212. ret = ctx->ops->mbox_read(ctx, &mbox_data);
  213. spu_release(ctx);
  214. if (!ret)
  215. return -EAGAIN;
  216. if (copy_to_user(buf, &mbox_data, sizeof mbox_data))
  217. return -EFAULT;
  218. return 4;
  219. }
  220. static struct file_operations spufs_mbox_fops = {
  221. .open = spufs_pipe_open,
  222. .read = spufs_mbox_read,
  223. };
  224. static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
  225. size_t len, loff_t *pos)
  226. {
  227. struct spu_context *ctx = file->private_data;
  228. u32 mbox_stat;
  229. if (len < 4)
  230. return -EINVAL;
  231. spu_acquire(ctx);
  232. mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
  233. spu_release(ctx);
  234. if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
  235. return -EFAULT;
  236. return 4;
  237. }
  238. static struct file_operations spufs_mbox_stat_fops = {
  239. .open = spufs_pipe_open,
  240. .read = spufs_mbox_stat_read,
  241. };
  242. /* low-level ibox access function */
  243. size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
  244. {
  245. return ctx->ops->ibox_read(ctx, data);
  246. }
  247. static int spufs_ibox_fasync(int fd, struct file *file, int on)
  248. {
  249. struct spu_context *ctx = file->private_data;
  250. return fasync_helper(fd, file, on, &ctx->ibox_fasync);
  251. }
  252. /* interrupt-level ibox callback function. */
  253. void spufs_ibox_callback(struct spu *spu)
  254. {
  255. struct spu_context *ctx = spu->ctx;
  256. wake_up_all(&ctx->ibox_wq);
  257. kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
  258. }
  259. static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
  260. size_t len, loff_t *pos)
  261. {
  262. struct spu_context *ctx = file->private_data;
  263. u32 ibox_data;
  264. ssize_t ret;
  265. if (len < 4)
  266. return -EINVAL;
  267. spu_acquire(ctx);
  268. ret = 0;
  269. if (file->f_flags & O_NONBLOCK) {
  270. if (!spu_ibox_read(ctx, &ibox_data))
  271. ret = -EAGAIN;
  272. } else {
  273. ret = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
  274. }
  275. spu_release(ctx);
  276. if (ret)
  277. return ret;
  278. ret = 4;
  279. if (copy_to_user(buf, &ibox_data, sizeof ibox_data))
  280. ret = -EFAULT;
  281. return ret;
  282. }
  283. static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
  284. {
  285. struct spu_context *ctx = file->private_data;
  286. unsigned int mask;
  287. poll_wait(file, &ctx->ibox_wq, wait);
  288. spu_acquire(ctx);
  289. mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
  290. spu_release(ctx);
  291. return mask;
  292. }
  293. static struct file_operations spufs_ibox_fops = {
  294. .open = spufs_pipe_open,
  295. .read = spufs_ibox_read,
  296. .poll = spufs_ibox_poll,
  297. .fasync = spufs_ibox_fasync,
  298. };
  299. static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
  300. size_t len, loff_t *pos)
  301. {
  302. struct spu_context *ctx = file->private_data;
  303. u32 ibox_stat;
  304. if (len < 4)
  305. return -EINVAL;
  306. spu_acquire(ctx);
  307. ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
  308. spu_release(ctx);
  309. if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
  310. return -EFAULT;
  311. return 4;
  312. }
  313. static struct file_operations spufs_ibox_stat_fops = {
  314. .open = spufs_pipe_open,
  315. .read = spufs_ibox_stat_read,
  316. };
  317. /* low-level mailbox write */
  318. size_t spu_wbox_write(struct spu_context *ctx, u32 data)
  319. {
  320. return ctx->ops->wbox_write(ctx, data);
  321. }
  322. static int spufs_wbox_fasync(int fd, struct file *file, int on)
  323. {
  324. struct spu_context *ctx = file->private_data;
  325. int ret;
  326. ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
  327. return ret;
  328. }
  329. /* interrupt-level wbox callback function. */
  330. void spufs_wbox_callback(struct spu *spu)
  331. {
  332. struct spu_context *ctx = spu->ctx;
  333. wake_up_all(&ctx->wbox_wq);
  334. kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
  335. }
  336. static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
  337. size_t len, loff_t *pos)
  338. {
  339. struct spu_context *ctx = file->private_data;
  340. u32 wbox_data;
  341. int ret;
  342. if (len < 4)
  343. return -EINVAL;
  344. if (copy_from_user(&wbox_data, buf, sizeof wbox_data))
  345. return -EFAULT;
  346. spu_acquire(ctx);
  347. ret = 0;
  348. if (file->f_flags & O_NONBLOCK) {
  349. if (!spu_wbox_write(ctx, wbox_data))
  350. ret = -EAGAIN;
  351. } else {
  352. ret = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
  353. }
  354. spu_release(ctx);
  355. return ret ? ret : sizeof wbox_data;
  356. }
  357. static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
  358. {
  359. struct spu_context *ctx = file->private_data;
  360. unsigned int mask;
  361. poll_wait(file, &ctx->wbox_wq, wait);
  362. spu_acquire(ctx);
  363. mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
  364. spu_release(ctx);
  365. return mask;
  366. }
  367. static struct file_operations spufs_wbox_fops = {
  368. .open = spufs_pipe_open,
  369. .write = spufs_wbox_write,
  370. .poll = spufs_wbox_poll,
  371. .fasync = spufs_wbox_fasync,
  372. };
  373. static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
  374. size_t len, loff_t *pos)
  375. {
  376. struct spu_context *ctx = file->private_data;
  377. u32 wbox_stat;
  378. if (len < 4)
  379. return -EINVAL;
  380. spu_acquire(ctx);
  381. wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
  382. spu_release(ctx);
  383. if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
  384. return -EFAULT;
  385. return 4;
  386. }
  387. static struct file_operations spufs_wbox_stat_fops = {
  388. .open = spufs_pipe_open,
  389. .read = spufs_wbox_stat_read,
  390. };
  391. static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
  392. size_t len, loff_t *pos)
  393. {
  394. struct spu_context *ctx = file->private_data;
  395. u32 data;
  396. if (len < 4)
  397. return -EINVAL;
  398. spu_acquire(ctx);
  399. data = ctx->ops->signal1_read(ctx);
  400. spu_release(ctx);
  401. if (copy_to_user(buf, &data, 4))
  402. return -EFAULT;
  403. return 4;
  404. }
  405. static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
  406. size_t len, loff_t *pos)
  407. {
  408. struct spu_context *ctx;
  409. u32 data;
  410. ctx = file->private_data;
  411. if (len < 4)
  412. return -EINVAL;
  413. if (copy_from_user(&data, buf, 4))
  414. return -EFAULT;
  415. spu_acquire(ctx);
  416. ctx->ops->signal1_write(ctx, data);
  417. spu_release(ctx);
  418. return 4;
  419. }
  420. static struct file_operations spufs_signal1_fops = {
  421. .open = spufs_pipe_open,
  422. .read = spufs_signal1_read,
  423. .write = spufs_signal1_write,
  424. };
  425. static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
  426. size_t len, loff_t *pos)
  427. {
  428. struct spu_context *ctx;
  429. u32 data;
  430. ctx = file->private_data;
  431. if (len < 4)
  432. return -EINVAL;
  433. spu_acquire(ctx);
  434. data = ctx->ops->signal2_read(ctx);
  435. spu_release(ctx);
  436. if (copy_to_user(buf, &data, 4))
  437. return -EFAULT;
  438. return 4;
  439. }
  440. static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
  441. size_t len, loff_t *pos)
  442. {
  443. struct spu_context *ctx;
  444. u32 data;
  445. ctx = file->private_data;
  446. if (len < 4)
  447. return -EINVAL;
  448. if (copy_from_user(&data, buf, 4))
  449. return -EFAULT;
  450. spu_acquire(ctx);
  451. ctx->ops->signal2_write(ctx, data);
  452. spu_release(ctx);
  453. return 4;
  454. }
  455. static struct file_operations spufs_signal2_fops = {
  456. .open = spufs_pipe_open,
  457. .read = spufs_signal2_read,
  458. .write = spufs_signal2_write,
  459. };
  460. static void spufs_signal1_type_set(void *data, u64 val)
  461. {
  462. struct spu_context *ctx = data;
  463. spu_acquire(ctx);
  464. ctx->ops->signal1_type_set(ctx, val);
  465. spu_release(ctx);
  466. }
  467. static u64 spufs_signal1_type_get(void *data)
  468. {
  469. struct spu_context *ctx = data;
  470. u64 ret;
  471. spu_acquire(ctx);
  472. ret = ctx->ops->signal1_type_get(ctx);
  473. spu_release(ctx);
  474. return ret;
  475. }
  476. DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
  477. spufs_signal1_type_set, "%llu");
  478. static void spufs_signal2_type_set(void *data, u64 val)
  479. {
  480. struct spu_context *ctx = data;
  481. spu_acquire(ctx);
  482. ctx->ops->signal2_type_set(ctx, val);
  483. spu_release(ctx);
  484. }
  485. static u64 spufs_signal2_type_get(void *data)
  486. {
  487. struct spu_context *ctx = data;
  488. u64 ret;
  489. spu_acquire(ctx);
  490. ret = ctx->ops->signal2_type_get(ctx);
  491. spu_release(ctx);
  492. return ret;
  493. }
  494. DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
  495. spufs_signal2_type_set, "%llu");
  496. static void spufs_npc_set(void *data, u64 val)
  497. {
  498. struct spu_context *ctx = data;
  499. spu_acquire(ctx);
  500. ctx->ops->npc_write(ctx, val);
  501. spu_release(ctx);
  502. }
  503. static u64 spufs_npc_get(void *data)
  504. {
  505. struct spu_context *ctx = data;
  506. u64 ret;
  507. spu_acquire(ctx);
  508. ret = ctx->ops->npc_read(ctx);
  509. spu_release(ctx);
  510. return ret;
  511. }
  512. DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set, "%llx\n")
  513. static void spufs_decr_set(void *data, u64 val)
  514. {
  515. struct spu_context *ctx = data;
  516. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  517. spu_acquire_saved(ctx);
  518. lscsa->decr.slot[0] = (u32) val;
  519. spu_release(ctx);
  520. }
  521. static u64 spufs_decr_get(void *data)
  522. {
  523. struct spu_context *ctx = data;
  524. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  525. u64 ret;
  526. spu_acquire_saved(ctx);
  527. ret = lscsa->decr.slot[0];
  528. spu_release(ctx);
  529. return ret;
  530. }
  531. DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
  532. "%llx\n")
  533. static void spufs_decr_status_set(void *data, u64 val)
  534. {
  535. struct spu_context *ctx = data;
  536. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  537. spu_acquire_saved(ctx);
  538. lscsa->decr_status.slot[0] = (u32) val;
  539. spu_release(ctx);
  540. }
  541. static u64 spufs_decr_status_get(void *data)
  542. {
  543. struct spu_context *ctx = data;
  544. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  545. u64 ret;
  546. spu_acquire_saved(ctx);
  547. ret = lscsa->decr_status.slot[0];
  548. spu_release(ctx);
  549. return ret;
  550. }
  551. DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
  552. spufs_decr_status_set, "%llx\n")
  553. static void spufs_spu_tag_mask_set(void *data, u64 val)
  554. {
  555. struct spu_context *ctx = data;
  556. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  557. spu_acquire_saved(ctx);
  558. lscsa->tag_mask.slot[0] = (u32) val;
  559. spu_release(ctx);
  560. }
  561. static u64 spufs_spu_tag_mask_get(void *data)
  562. {
  563. struct spu_context *ctx = data;
  564. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  565. u64 ret;
  566. spu_acquire_saved(ctx);
  567. ret = lscsa->tag_mask.slot[0];
  568. spu_release(ctx);
  569. return ret;
  570. }
  571. DEFINE_SIMPLE_ATTRIBUTE(spufs_spu_tag_mask_ops, spufs_spu_tag_mask_get,
  572. spufs_spu_tag_mask_set, "%llx\n")
  573. static void spufs_event_mask_set(void *data, u64 val)
  574. {
  575. struct spu_context *ctx = data;
  576. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  577. spu_acquire_saved(ctx);
  578. lscsa->event_mask.slot[0] = (u32) val;
  579. spu_release(ctx);
  580. }
  581. static u64 spufs_event_mask_get(void *data)
  582. {
  583. struct spu_context *ctx = data;
  584. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  585. u64 ret;
  586. spu_acquire_saved(ctx);
  587. ret = lscsa->event_mask.slot[0];
  588. spu_release(ctx);
  589. return ret;
  590. }
  591. DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
  592. spufs_event_mask_set, "%llx\n")
  593. static void spufs_srr0_set(void *data, u64 val)
  594. {
  595. struct spu_context *ctx = data;
  596. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  597. spu_acquire_saved(ctx);
  598. lscsa->srr0.slot[0] = (u32) val;
  599. spu_release(ctx);
  600. }
  601. static u64 spufs_srr0_get(void *data)
  602. {
  603. struct spu_context *ctx = data;
  604. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  605. u64 ret;
  606. spu_acquire_saved(ctx);
  607. ret = lscsa->srr0.slot[0];
  608. spu_release(ctx);
  609. return ret;
  610. }
  611. DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
  612. "%llx\n")
  613. struct tree_descr spufs_dir_contents[] = {
  614. { "mem", &spufs_mem_fops, 0666, },
  615. { "regs", &spufs_regs_fops, 0666, },
  616. { "mbox", &spufs_mbox_fops, 0444, },
  617. { "ibox", &spufs_ibox_fops, 0444, },
  618. { "wbox", &spufs_wbox_fops, 0222, },
  619. { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
  620. { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
  621. { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
  622. { "signal1", &spufs_signal1_fops, 0666, },
  623. { "signal2", &spufs_signal2_fops, 0666, },
  624. { "signal1_type", &spufs_signal1_type, 0666, },
  625. { "signal2_type", &spufs_signal2_type, 0666, },
  626. { "npc", &spufs_npc_ops, 0666, },
  627. { "fpcr", &spufs_fpcr_fops, 0666, },
  628. { "decr", &spufs_decr_ops, 0666, },
  629. { "decr_status", &spufs_decr_status_ops, 0666, },
  630. { "spu_tag_mask", &spufs_spu_tag_mask_ops, 0666, },
  631. { "event_mask", &spufs_event_mask_ops, 0666, },
  632. { "srr0", &spufs_srr0_ops, 0666, },
  633. {},
  634. };