blob: e0684f5f0054aa33b762606fd386479fe64513dd [file] [log] [blame]
Ralf Baechle26009902006-04-05 09:45:45 +01001/*
Steven J. Hill5792bf62014-01-01 16:35:32 +01002 * 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 *
Ralf Baechle26009902006-04-05 09:45:45 +01006 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -05007 * Copyright (C) 2013 Imagination Technologies Ltd.
Ralf Baechle26009902006-04-05 09:45:45 +01008 */
Ralf Baechle26009902006-04-05 09:45:45 +01009#ifndef _ASM_VPE_H
10#define _ASM_VPE_H
11
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -050012#include <linux/init.h>
13#include <linux/list.h>
14#include <linux/smp.h>
15#include <linux/spinlock.h>
16
17#define VPE_MODULE_NAME "vpe"
18#define VPE_MODULE_MINOR 1
19
20/* grab the likely amount of memory we will need. */
21#ifdef CONFIG_MIPS_VPE_LOADER_TOM
22#define P_SIZE (2 * 1024 * 1024)
23#else
24/* add an overhead to the max kmalloc size for non-striped symbols/etc */
25#define P_SIZE (256 * 1024)
26#endif
27
28#define MAX_VPES 16
29#define VPE_PATH_MAX 256
30
31static inline int aprp_cpu_index(void)
32{
33#ifdef CONFIG_MIPS_CMP
34 return setup_max_cpus;
35#else
36 extern int tclimit;
37 return tclimit;
38#endif
39}
40
41enum vpe_state {
42 VPE_STATE_UNUSED = 0,
43 VPE_STATE_INUSE,
44 VPE_STATE_RUNNING
45};
46
47enum tc_state {
48 TC_STATE_UNUSED = 0,
49 TC_STATE_INUSE,
50 TC_STATE_RUNNING,
51 TC_STATE_DYNAMIC
52};
53
54struct vpe {
55 enum vpe_state state;
56
57 /* (device) minor associated with this vpe */
58 int minor;
59
60 /* elfloader stuff */
61 void *load_addr;
62 unsigned long len;
63 char *pbuffer;
64 unsigned long plen;
65 unsigned int uid, gid;
66 char cwd[VPE_PATH_MAX];
67
68 unsigned long __start;
69
70 /* tc's associated with this vpe */
71 struct list_head tc;
72
73 /* The list of vpe's */
74 struct list_head list;
75
76 /* shared symbol address */
77 void *shared_ptr;
78
79 /* the list of who wants to know when something major happens */
80 struct list_head notify;
81
82 unsigned int ntcs;
83};
84
85struct tc {
86 enum tc_state state;
87 int index;
88
89 struct vpe *pvpe; /* parent VPE */
90 struct list_head tc; /* The list of TC's with this VPE */
91 struct list_head list; /* The global list of tc's */
92};
93
Ralf Baechle26009902006-04-05 09:45:45 +010094struct vpe_notifications {
95 void (*start)(int vpe);
96 void (*stop)(int vpe);
97
98 struct list_head list;
99};
100
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500101struct vpe_control {
102 spinlock_t vpe_list_lock;
103 struct list_head vpe_list; /* Virtual processing elements */
104 spinlock_t tc_list_lock;
105 struct list_head tc_list; /* Thread contexts */
106};
Ralf Baechle26009902006-04-05 09:45:45 +0100107
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500108extern unsigned long physical_memsize;
109extern struct vpe_control vpecontrol;
110extern const struct file_operations vpe_fops;
Ralf Baechle26009902006-04-05 09:45:45 +0100111
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500112int vpe_notify(int index, struct vpe_notifications *notify);
Ralf Baechle26009902006-04-05 09:45:45 +0100113
Deng-Cheng Zhu1a2a6d72013-10-30 15:52:06 -0500114void *vpe_get_shared(int index);
115int vpe_getuid(int index);
116int vpe_getgid(int index);
117char *vpe_getcwd(int index);
118
119struct vpe *get_vpe(int minor);
120struct tc *get_tc(int index);
121struct vpe *alloc_vpe(int minor);
122struct tc *alloc_tc(int index);
123void release_vpe(struct vpe *v);
124
125void *alloc_progmem(unsigned long len);
126void release_progmem(void *ptr);
127
128int __weak vpe_run(struct vpe *v);
129void cleanup_tc(struct tc *tc);
130
131int __init vpe_module_init(void);
132void __exit vpe_module_exit(void);
Ralf Baechle26009902006-04-05 09:45:45 +0100133#endif /* _ASM_VPE_H */