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