Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved. |
Deng-Cheng Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 3 | * Copyright (C) 2013 Imagination Technologies Ltd. |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 4 | * |
| 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 Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 23 | #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 | |
| 42 | static 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 | |
| 52 | enum vpe_state { |
| 53 | VPE_STATE_UNUSED = 0, |
| 54 | VPE_STATE_INUSE, |
| 55 | VPE_STATE_RUNNING |
| 56 | }; |
| 57 | |
| 58 | enum tc_state { |
| 59 | TC_STATE_UNUSED = 0, |
| 60 | TC_STATE_INUSE, |
| 61 | TC_STATE_RUNNING, |
| 62 | TC_STATE_DYNAMIC |
| 63 | }; |
| 64 | |
| 65 | struct 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 | |
| 96 | struct 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 Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 105 | struct vpe_notifications { |
| 106 | void (*start)(int vpe); |
| 107 | void (*stop)(int vpe); |
| 108 | |
| 109 | struct list_head list; |
| 110 | }; |
| 111 | |
Deng-Cheng Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 112 | struct 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 Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 118 | |
Deng-Cheng Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 119 | extern unsigned long physical_memsize; |
| 120 | extern struct vpe_control vpecontrol; |
| 121 | extern const struct file_operations vpe_fops; |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 122 | |
Deng-Cheng Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 123 | int vpe_notify(int index, struct vpe_notifications *notify); |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 124 | |
Deng-Cheng Zhu | 1a2a6d7 | 2013-10-30 15:52:06 -0500 | [diff] [blame^] | 125 | void *vpe_get_shared(int index); |
| 126 | int vpe_getuid(int index); |
| 127 | int vpe_getgid(int index); |
| 128 | char *vpe_getcwd(int index); |
| 129 | |
| 130 | struct vpe *get_vpe(int minor); |
| 131 | struct tc *get_tc(int index); |
| 132 | struct vpe *alloc_vpe(int minor); |
| 133 | struct tc *alloc_tc(int index); |
| 134 | void release_vpe(struct vpe *v); |
| 135 | |
| 136 | void *alloc_progmem(unsigned long len); |
| 137 | void release_progmem(void *ptr); |
| 138 | |
| 139 | int __weak vpe_run(struct vpe *v); |
| 140 | void cleanup_tc(struct tc *tc); |
| 141 | |
| 142 | int __init vpe_module_init(void); |
| 143 | void __exit vpe_module_exit(void); |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 144 | #endif /* _ASM_VPE_H */ |