blob: becd5554cf5bd2a6c6876de1ee28031dd4ff3cf7 [file] [log] [blame]
Ralf Baechle26009902006-04-05 09:45:45 +01001/*
2 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -05003 * Copyright (C) 2013 Imagination Technologies Ltd.
Ralf Baechle26009902006-04-05 09:45:45 +01004 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 */
19
20#ifndef _ASM_VPE_H
21#define _ASM_VPE_H
22
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -050023#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/smp.h>
26#include <linux/spinlock.h>
27
28#define VPE_MODULE_NAME "vpe"
29#define VPE_MODULE_MINOR 1
30
31/* grab the likely amount of memory we will need. */
32#ifdef CONFIG_MIPS_VPE_LOADER_TOM
33#define P_SIZE (2 * 1024 * 1024)
34#else
35/* add an overhead to the max kmalloc size for non-striped symbols/etc */
36#define P_SIZE (256 * 1024)
37#endif
38
39#define MAX_VPES 16
40#define VPE_PATH_MAX 256
41
42static inline int aprp_cpu_index(void)
43{
44#ifdef CONFIG_MIPS_CMP
45 return setup_max_cpus;
46#else
47 extern int tclimit;
48 return tclimit;
49#endif
50}
51
52enum vpe_state {
53 VPE_STATE_UNUSED = 0,
54 VPE_STATE_INUSE,
55 VPE_STATE_RUNNING
56};
57
58enum tc_state {
59 TC_STATE_UNUSED = 0,
60 TC_STATE_INUSE,
61 TC_STATE_RUNNING,
62 TC_STATE_DYNAMIC
63};
64
65struct vpe {
66 enum vpe_state state;
67
68 /* (device) minor associated with this vpe */
69 int minor;
70
71 /* elfloader stuff */
72 void *load_addr;
73 unsigned long len;
74 char *pbuffer;
75 unsigned long plen;
76 unsigned int uid, gid;
77 char cwd[VPE_PATH_MAX];
78
79 unsigned long __start;
80
81 /* tc's associated with this vpe */
82 struct list_head tc;
83
84 /* The list of vpe's */
85 struct list_head list;
86
87 /* shared symbol address */
88 void *shared_ptr;
89
90 /* the list of who wants to know when something major happens */
91 struct list_head notify;
92
93 unsigned int ntcs;
94};
95
96struct tc {
97 enum tc_state state;
98 int index;
99
100 struct vpe *pvpe; /* parent VPE */
101 struct list_head tc; /* The list of TC's with this VPE */
102 struct list_head list; /* The global list of tc's */
103};
104
Ralf Baechle26009902006-04-05 09:45:45 +0100105struct vpe_notifications {
106 void (*start)(int vpe);
107 void (*stop)(int vpe);
108
109 struct list_head list;
110};
111
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500112struct vpe_control {
113 spinlock_t vpe_list_lock;
114 struct list_head vpe_list; /* Virtual processing elements */
115 spinlock_t tc_list_lock;
116 struct list_head tc_list; /* Thread contexts */
117};
Ralf Baechle26009902006-04-05 09:45:45 +0100118
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500119extern unsigned long physical_memsize;
120extern struct vpe_control vpecontrol;
121extern const struct file_operations vpe_fops;
Ralf Baechle26009902006-04-05 09:45:45 +0100122
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500123int vpe_notify(int index, struct vpe_notifications *notify);
Ralf Baechle26009902006-04-05 09:45:45 +0100124
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500125void *vpe_get_shared(int index);
126int vpe_getuid(int index);
127int vpe_getgid(int index);
128char *vpe_getcwd(int index);
129
130struct vpe *get_vpe(int minor);
131struct tc *get_tc(int index);
132struct vpe *alloc_vpe(int minor);
133struct tc *alloc_tc(int index);
134void release_vpe(struct vpe *v);
135
136void *alloc_progmem(unsigned long len);
137void release_progmem(void *ptr);
138
139int __weak vpe_run(struct vpe *v);
140void cleanup_tc(struct tc *tc);
141
142int __init vpe_module_init(void);
143void __exit vpe_module_exit(void);
Ralf Baechle26009902006-04-05 09:45:45 +0100144#endif /* _ASM_VPE_H */