vpe.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. static inline int aprp_cpu_index(void)
  26. {
  27. #ifdef CONFIG_MIPS_CMP
  28. return setup_max_cpus;
  29. #else
  30. extern int tclimit;
  31. return tclimit;
  32. #endif
  33. }
  34. enum vpe_state {
  35. VPE_STATE_UNUSED = 0,
  36. VPE_STATE_INUSE,
  37. VPE_STATE_RUNNING
  38. };
  39. enum tc_state {
  40. TC_STATE_UNUSED = 0,
  41. TC_STATE_INUSE,
  42. TC_STATE_RUNNING,
  43. TC_STATE_DYNAMIC
  44. };
  45. struct vpe {
  46. enum vpe_state state;
  47. /* (device) minor associated with this vpe */
  48. int minor;
  49. /* elfloader stuff */
  50. void *load_addr;
  51. unsigned long len;
  52. char *pbuffer;
  53. unsigned long plen;
  54. unsigned long __start;
  55. /* tc's associated with this vpe */
  56. struct list_head tc;
  57. /* The list of vpe's */
  58. struct list_head list;
  59. /* shared symbol address */
  60. void *shared_ptr;
  61. /* the list of who wants to know when something major happens */
  62. struct list_head notify;
  63. unsigned int ntcs;
  64. };
  65. struct tc {
  66. enum tc_state state;
  67. int index;
  68. struct vpe *pvpe; /* parent VPE */
  69. struct list_head tc; /* The list of TC's with this VPE */
  70. struct list_head list; /* The global list of tc's */
  71. };
  72. struct vpe_notifications {
  73. void (*start)(int vpe);
  74. void (*stop)(int vpe);
  75. struct list_head list;
  76. };
  77. struct vpe_control {
  78. spinlock_t vpe_list_lock;
  79. struct list_head vpe_list; /* Virtual processing elements */
  80. spinlock_t tc_list_lock;
  81. struct list_head tc_list; /* Thread contexts */
  82. };
  83. extern unsigned long physical_memsize;
  84. extern struct vpe_control vpecontrol;
  85. extern const struct file_operations vpe_fops;
  86. int vpe_notify(int index, struct vpe_notifications *notify);
  87. void *vpe_get_shared(int index);
  88. struct vpe *get_vpe(int minor);
  89. struct tc *get_tc(int index);
  90. struct vpe *alloc_vpe(int minor);
  91. struct tc *alloc_tc(int index);
  92. void release_vpe(struct vpe *v);
  93. void *alloc_progmem(unsigned long len);
  94. void release_progmem(void *ptr);
  95. int vpe_run(struct vpe *v);
  96. void cleanup_tc(struct tc *tc);
  97. int __init vpe_module_init(void);
  98. void __exit vpe_module_exit(void);
  99. #endif /* _ASM_VPE_H */