Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
0007  * Copyright (C) 2013 Imagination Technologies Ltd.
0008  */
0009 #ifndef _ASM_VPE_H
0010 #define _ASM_VPE_H
0011 
0012 #include <linux/init.h>
0013 #include <linux/list.h>
0014 #include <linux/smp.h>
0015 #include <linux/spinlock.h>
0016 
0017 #define VPE_MODULE_NAME "vpe"
0018 #define VPE_MODULE_MINOR 1
0019 
0020 /* grab the likely amount of memory we will need. */
0021 #ifdef CONFIG_MIPS_VPE_LOADER_TOM
0022 #define P_SIZE (2 * 1024 * 1024)
0023 #else
0024 /* add an overhead to the max kmalloc size for non-striped symbols/etc */
0025 #define P_SIZE (256 * 1024)
0026 #endif
0027 
0028 #define MAX_VPES 16
0029 
0030 static inline int aprp_cpu_index(void)
0031 {
0032 #ifdef CONFIG_MIPS_CMP
0033     return setup_max_cpus;
0034 #else
0035     extern int tclimit;
0036     return tclimit;
0037 #endif
0038 }
0039 
0040 enum vpe_state {
0041     VPE_STATE_UNUSED = 0,
0042     VPE_STATE_INUSE,
0043     VPE_STATE_RUNNING
0044 };
0045 
0046 enum tc_state {
0047     TC_STATE_UNUSED = 0,
0048     TC_STATE_INUSE,
0049     TC_STATE_RUNNING,
0050     TC_STATE_DYNAMIC
0051 };
0052 
0053 struct vpe {
0054     enum vpe_state state;
0055 
0056     /* (device) minor associated with this vpe */
0057     int minor;
0058 
0059     /* elfloader stuff */
0060     void *load_addr;
0061     unsigned long len;
0062     char *pbuffer;
0063     unsigned long plen;
0064 
0065     unsigned long __start;
0066 
0067     /* tc's associated with this vpe */
0068     struct list_head tc;
0069 
0070     /* The list of vpe's */
0071     struct list_head list;
0072 
0073     /* shared symbol address */
0074     void *shared_ptr;
0075 
0076     /* the list of who wants to know when something major happens */
0077     struct list_head notify;
0078 
0079     unsigned int ntcs;
0080 };
0081 
0082 struct tc {
0083     enum tc_state state;
0084     int index;
0085 
0086     struct vpe *pvpe;   /* parent VPE */
0087     struct list_head tc;    /* The list of TC's with this VPE */
0088     struct list_head list;  /* The global list of tc's */
0089 };
0090 
0091 struct vpe_notifications {
0092     void (*start)(int vpe);
0093     void (*stop)(int vpe);
0094 
0095     struct list_head list;
0096 };
0097 
0098 struct vpe_control {
0099     spinlock_t vpe_list_lock;
0100     struct list_head vpe_list;      /* Virtual processing elements */
0101     spinlock_t tc_list_lock;
0102     struct list_head tc_list;       /* Thread contexts */
0103 };
0104 
0105 extern unsigned long physical_memsize;
0106 extern struct vpe_control vpecontrol;
0107 extern const struct file_operations vpe_fops;
0108 
0109 int vpe_notify(int index, struct vpe_notifications *notify);
0110 
0111 void *vpe_get_shared(int index);
0112 
0113 struct vpe *get_vpe(int minor);
0114 struct tc *get_tc(int index);
0115 struct vpe *alloc_vpe(int minor);
0116 struct tc *alloc_tc(int index);
0117 void release_vpe(struct vpe *v);
0118 
0119 void *alloc_progmem(unsigned long len);
0120 void release_progmem(void *ptr);
0121 
0122 int vpe_run(struct vpe *v);
0123 void cleanup_tc(struct tc *tc);
0124 
0125 int __init vpe_module_init(void);
0126 void __exit vpe_module_exit(void);
0127 #endif /* _ASM_VPE_H */