vpe.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
  7. * Copyright (C) 2013 Imagination Technologies Ltd.
  8. */
  9. #ifndef _ASM_VPE_H
  10. #define _ASM_VPE_H
  11. #include <linux/init.h>
  12. #include <linux/list.h>
  13. #include <linux/smp.h>
  14. #include <linux/spinlock.h>
  15. #define VPE_MODULE_NAME "vpe"
  16. #define VPE_MODULE_MINOR 1
  17. /* grab the likely amount of memory we will need. */
  18. #ifdef CONFIG_MIPS_VPE_LOADER_TOM
  19. #define P_SIZE (2 * 1024 * 1024)
  20. #else
  21. /* add an overhead to the max kmalloc size for non-striped symbols/etc */
  22. #define P_SIZE (256 * 1024)
  23. #endif
  24. #define MAX_VPES 16
  25. #define VPE_PATH_MAX 256
  26. static inline int aprp_cpu_index(void)
  27. {
  28. #ifdef CONFIG_MIPS_CMP
  29. return setup_max_cpus;
  30. #else
  31. extern int tclimit;
  32. return tclimit;
  33. #endif
  34. }
  35. enum vpe_state {
  36. VPE_STATE_UNUSED = 0,
  37. VPE_STATE_INUSE,
  38. VPE_STATE_RUNNING
  39. };
  40. enum tc_state {
  41. TC_STATE_UNUSED = 0,
  42. TC_STATE_INUSE,
  43. TC_STATE_RUNNING,
  44. TC_STATE_DYNAMIC
  45. };
  46. struct vpe {
  47. enum vpe_state state;
  48. /* (device) minor associated with this vpe */
  49. int minor;
  50. /* elfloader stuff */
  51. void *load_addr;
  52. unsigned long len;
  53. char *pbuffer;
  54. unsigned long plen;
  55. char cwd[VPE_PATH_MAX];
  56. unsigned long __start;
  57. /* tc's associated with this vpe */
  58. struct list_head tc;
  59. /* The list of vpe's */
  60. struct list_head list;
  61. /* shared symbol address */
  62. void *shared_ptr;
  63. /* the list of who wants to know when something major happens */
  64. struct list_head notify;
  65. unsigned int ntcs;
  66. };
  67. struct tc {
  68. enum tc_state state;
  69. int index;
  70. struct vpe *pvpe; /* parent VPE */
  71. struct list_head tc; /* The list of TC's with this VPE */
  72. struct list_head list; /* The global list of tc's */
  73. };
  74. struct vpe_notifications {
  75. void (*start)(int vpe);
  76. void (*stop)(int vpe);
  77. struct list_head list;
  78. };
  79. struct vpe_control {
  80. spinlock_t vpe_list_lock;
  81. struct list_head vpe_list; /* Virtual processing elements */
  82. spinlock_t tc_list_lock;
  83. struct list_head tc_list; /* Thread contexts */
  84. };
  85. extern unsigned long physical_memsize;
  86. extern struct vpe_control vpecontrol;
  87. extern const struct file_operations vpe_fops;
  88. int vpe_notify(int index, struct vpe_notifications *notify);
  89. void *vpe_get_shared(int index);
  90. char *vpe_getcwd(int index);
  91. struct vpe *get_vpe(int minor);
  92. struct tc *get_tc(int index);
  93. struct vpe *alloc_vpe(int minor);
  94. struct tc *alloc_tc(int index);
  95. void release_vpe(struct vpe *v);
  96. void *alloc_progmem(unsigned long len);
  97. void release_progmem(void *ptr);
  98. int vpe_run(struct vpe *v);
  99. void cleanup_tc(struct tc *tc);
  100. int __init vpe_module_init(void);
  101. void __exit vpe_module_exit(void);
  102. #endif /* _ASM_VPE_H */