xref: /linux/arch/mips/include/asm/vpe.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1384740dcSRalf Baechle /*
25792bf64SSteven J. Hill  * This file is subject to the terms and conditions of the GNU General Public
35792bf64SSteven J. Hill  * License.  See the file "COPYING" in the main directory of this archive
4384740dcSRalf Baechle  * for more details.
5384740dcSRalf Baechle  *
65792bf64SSteven J. Hill  * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
75792bf64SSteven J. Hill  * Copyright (C) 2013 Imagination Technologies Ltd.
8384740dcSRalf Baechle  */
9384740dcSRalf Baechle #ifndef _ASM_VPE_H
10384740dcSRalf Baechle #define _ASM_VPE_H
11384740dcSRalf Baechle 
121a2a6d7eSDeng-Cheng Zhu #include <linux/init.h>
131a2a6d7eSDeng-Cheng Zhu #include <linux/list.h>
141a2a6d7eSDeng-Cheng Zhu #include <linux/smp.h>
151a2a6d7eSDeng-Cheng Zhu #include <linux/spinlock.h>
161a2a6d7eSDeng-Cheng Zhu 
171a2a6d7eSDeng-Cheng Zhu #define VPE_MODULE_NAME "vpe"
181a2a6d7eSDeng-Cheng Zhu #define VPE_MODULE_MINOR 1
191a2a6d7eSDeng-Cheng Zhu 
201a2a6d7eSDeng-Cheng Zhu /* grab the likely amount of memory we will need. */
211a2a6d7eSDeng-Cheng Zhu #ifdef CONFIG_MIPS_VPE_LOADER_TOM
221a2a6d7eSDeng-Cheng Zhu #define P_SIZE (2 * 1024 * 1024)
231a2a6d7eSDeng-Cheng Zhu #else
241a2a6d7eSDeng-Cheng Zhu /* add an overhead to the max kmalloc size for non-striped symbols/etc */
251a2a6d7eSDeng-Cheng Zhu #define P_SIZE (256 * 1024)
261a2a6d7eSDeng-Cheng Zhu #endif
271a2a6d7eSDeng-Cheng Zhu 
281a2a6d7eSDeng-Cheng Zhu #define MAX_VPES 16
291a2a6d7eSDeng-Cheng Zhu 
aprp_cpu_index(void)301a2a6d7eSDeng-Cheng Zhu static inline int aprp_cpu_index(void)
311a2a6d7eSDeng-Cheng Zhu {
321a2a6d7eSDeng-Cheng Zhu 	extern int tclimit;
331a2a6d7eSDeng-Cheng Zhu 	return tclimit;
341a2a6d7eSDeng-Cheng Zhu }
351a2a6d7eSDeng-Cheng Zhu 
361a2a6d7eSDeng-Cheng Zhu enum vpe_state {
371a2a6d7eSDeng-Cheng Zhu 	VPE_STATE_UNUSED = 0,
381a2a6d7eSDeng-Cheng Zhu 	VPE_STATE_INUSE,
391a2a6d7eSDeng-Cheng Zhu 	VPE_STATE_RUNNING
401a2a6d7eSDeng-Cheng Zhu };
411a2a6d7eSDeng-Cheng Zhu 
421a2a6d7eSDeng-Cheng Zhu enum tc_state {
431a2a6d7eSDeng-Cheng Zhu 	TC_STATE_UNUSED = 0,
441a2a6d7eSDeng-Cheng Zhu 	TC_STATE_INUSE,
451a2a6d7eSDeng-Cheng Zhu 	TC_STATE_RUNNING,
461a2a6d7eSDeng-Cheng Zhu 	TC_STATE_DYNAMIC
471a2a6d7eSDeng-Cheng Zhu };
481a2a6d7eSDeng-Cheng Zhu 
491a2a6d7eSDeng-Cheng Zhu struct vpe {
501a2a6d7eSDeng-Cheng Zhu 	enum vpe_state state;
511a2a6d7eSDeng-Cheng Zhu 
521a2a6d7eSDeng-Cheng Zhu 	/* (device) minor associated with this vpe */
531a2a6d7eSDeng-Cheng Zhu 	int minor;
541a2a6d7eSDeng-Cheng Zhu 
551a2a6d7eSDeng-Cheng Zhu 	/* elfloader stuff */
561a2a6d7eSDeng-Cheng Zhu 	void *load_addr;
571a2a6d7eSDeng-Cheng Zhu 	unsigned long len;
581a2a6d7eSDeng-Cheng Zhu 	char *pbuffer;
591a2a6d7eSDeng-Cheng Zhu 	unsigned long plen;
601a2a6d7eSDeng-Cheng Zhu 
611a2a6d7eSDeng-Cheng Zhu 	unsigned long __start;
621a2a6d7eSDeng-Cheng Zhu 
631a2a6d7eSDeng-Cheng Zhu 	/* tc's associated with this vpe */
641a2a6d7eSDeng-Cheng Zhu 	struct list_head tc;
651a2a6d7eSDeng-Cheng Zhu 
661a2a6d7eSDeng-Cheng Zhu 	/* The list of vpe's */
671a2a6d7eSDeng-Cheng Zhu 	struct list_head list;
681a2a6d7eSDeng-Cheng Zhu 
691a2a6d7eSDeng-Cheng Zhu 	/* shared symbol address */
701a2a6d7eSDeng-Cheng Zhu 	void *shared_ptr;
711a2a6d7eSDeng-Cheng Zhu 
721a2a6d7eSDeng-Cheng Zhu 	/* the list of who wants to know when something major happens */
731a2a6d7eSDeng-Cheng Zhu 	struct list_head notify;
741a2a6d7eSDeng-Cheng Zhu 
751a2a6d7eSDeng-Cheng Zhu 	unsigned int ntcs;
761a2a6d7eSDeng-Cheng Zhu };
771a2a6d7eSDeng-Cheng Zhu 
781a2a6d7eSDeng-Cheng Zhu struct tc {
791a2a6d7eSDeng-Cheng Zhu 	enum tc_state state;
801a2a6d7eSDeng-Cheng Zhu 	int index;
811a2a6d7eSDeng-Cheng Zhu 
821a2a6d7eSDeng-Cheng Zhu 	struct vpe *pvpe;	/* parent VPE */
831a2a6d7eSDeng-Cheng Zhu 	struct list_head tc;	/* The list of TC's with this VPE */
841a2a6d7eSDeng-Cheng Zhu 	struct list_head list;	/* The global list of tc's */
851a2a6d7eSDeng-Cheng Zhu };
861a2a6d7eSDeng-Cheng Zhu 
87384740dcSRalf Baechle struct vpe_notifications {
88384740dcSRalf Baechle 	void (*start)(int vpe);
89384740dcSRalf Baechle 	void (*stop)(int vpe);
90384740dcSRalf Baechle 
91384740dcSRalf Baechle 	struct list_head list;
92384740dcSRalf Baechle };
93384740dcSRalf Baechle 
941a2a6d7eSDeng-Cheng Zhu struct vpe_control {
951a2a6d7eSDeng-Cheng Zhu 	spinlock_t vpe_list_lock;
961a2a6d7eSDeng-Cheng Zhu 	struct list_head vpe_list;      /* Virtual processing elements */
971a2a6d7eSDeng-Cheng Zhu 	spinlock_t tc_list_lock;
981a2a6d7eSDeng-Cheng Zhu 	struct list_head tc_list;       /* Thread contexts */
991a2a6d7eSDeng-Cheng Zhu };
100384740dcSRalf Baechle 
1011a2a6d7eSDeng-Cheng Zhu extern struct vpe_control vpecontrol;
1021a2a6d7eSDeng-Cheng Zhu extern const struct file_operations vpe_fops;
103384740dcSRalf Baechle 
1041a2a6d7eSDeng-Cheng Zhu int vpe_notify(int index, struct vpe_notifications *notify);
105384740dcSRalf Baechle 
1061a2a6d7eSDeng-Cheng Zhu void *vpe_get_shared(int index);
1071a2a6d7eSDeng-Cheng Zhu 
1081a2a6d7eSDeng-Cheng Zhu struct vpe *get_vpe(int minor);
1091a2a6d7eSDeng-Cheng Zhu struct tc *get_tc(int index);
1101a2a6d7eSDeng-Cheng Zhu struct vpe *alloc_vpe(int minor);
1111a2a6d7eSDeng-Cheng Zhu struct tc *alloc_tc(int index);
1121a2a6d7eSDeng-Cheng Zhu void release_vpe(struct vpe *v);
1131a2a6d7eSDeng-Cheng Zhu 
1141a2a6d7eSDeng-Cheng Zhu void *alloc_progmem(unsigned long len);
1151a2a6d7eSDeng-Cheng Zhu void release_progmem(void *ptr);
1161a2a6d7eSDeng-Cheng Zhu 
117*c60f9944SBjorn Helgaas int vpe_run(struct vpe *v);
1181a2a6d7eSDeng-Cheng Zhu void cleanup_tc(struct tc *tc);
1191a2a6d7eSDeng-Cheng Zhu 
1201a2a6d7eSDeng-Cheng Zhu int __init vpe_module_init(void);
1211a2a6d7eSDeng-Cheng Zhu void __exit vpe_module_exit(void);
122384740dcSRalf Baechle #endif /* _ASM_VPE_H */
123