001 // ImmortalPhysicalMemoryFactory.java, created by wbeebee 002 // Copyright (C) 2001 Wes Beebee <wbeebee@mit.edu> 003 // Licensed under the terms of the GNU GPL; see COPYING for details. 004 package javax.realtime; 005 006 /** 007 * @author Wes Beebee <<a href="mailto:wbeebee@mit.edu">wbeebee@mit.edu</a>> 008 */ 009 010 /** An instance of <code>ImmortalPhysicalMemory</code> allows objects to be 011 * allocated from a range of physical memory with particular attributes, 012 * determined by their memory type. This memory area has the same restrictive 013 * set of assignment rules as <code>ImmoratMemory</code> memory areas, and 014 * may be used in any context where <code>ImmortalMemory</code> is appropriate. 015 * Objects allocated in immortal physical memory have a lifetime greater 016 * than the application as do objects allocated in immortal memory. 017 */ 018 public class ImmortalPhysicalMemory extends MemoryArea { 019 private long base, size; 020 private Runnable logic; 021 022 /** Create an instance with the given parameters. 023 * 024 * @param type An instance of <code>Object</code> representing the type of 025 * memory required (e.g. <i>dma, share</i>) -used to define 026 * the base address and control the mapping. 027 * @param size The size of the area in bytes. 028 * @throws java.lang.SecurityException The application doesn't have 029 * permissions to access physical memory 030 * of the given type of memory. 031 * @throws SizeOutOfBoundsException The size is negative or extends into an 032 * invalid range of memory. 033 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 034 * does not support the given type. 035 * @throws MemoryTypeConflictException The specified base does not point to 036 * memory that matches the request type, or 037 * if <code>type</code> specifies attirbutes 038 * with a conflict. 039 */ 040 public ImmortalPhysicalMemory(Object type, long size) 041 throws SecurityException, SizeOutOfBoundsException, 042 UnsupportedPhysicalMemoryException, 043 MemoryTypeConflictException { 044 // TODO 045 046 // This line inserted only to make everything compile! 047 super(size); 048 } 049 050 /** Create an instance with the given parameters. 051 * 052 * @param type An instance of <code>Object</code> representing the type of 053 * memory required (e.g. <i>dma, share</i>) -used to define 054 * the base address and control the mapping. 055 * @param base The physical memory adress of the area. 056 * @param size The size of the area in bytes. 057 * @throws java.lang.SecurityException The application doesn't have 058 * permissions to access physical memory 059 * of the given type of memory. 060 * @throws SizeOutOfBoundsException The size is negative or extends into an 061 * invalid range of memory. 062 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 063 * does not support the given type. 064 * @throws MemoryTypeConflictException The specified base does not point to 065 * memory that matches the request type, or 066 * if <code>type</code> specifies attirbutes 067 * with a conflict. 068 * @throws MemoryInUseException The specified memory is already in use. 069 */ 070 public ImmortalPhysicalMemory(Object type, long base, long size) 071 throws SecurityException, SizeOutOfBoundsException, 072 OffsetOutOfBoundsException, 073 UnsupportedPhysicalMemoryException, 074 MemoryTypeConflictException, MemoryInUseException { 075 this(type, size); 076 this.base = base; 077 } 078 079 /** Create an instance with the given parameters. 080 * 081 * @param type An instance of <code>Object</code> representing the type of 082 * memory required (e.g. <i>dma, share</i>) -used to define 083 * the base address and control the mapping. 084 * @param base The physical memory adress of the area. 085 * @param size The size of the area in bytes. 086 * @param logic The <code>run()</code> method of this object will be called 087 * whenever <code>MemoryArea.enter()</code> is called. 088 * @throws java.lang.SecurityException The application doesn't have 089 * permissions to access physical memory 090 * of the given type of memory. 091 * @throws SizeOutOfBoundsException The size is negative or extends into an 092 * invalid range of memory. 093 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 094 * does not support the given type. 095 * @throws MemoryTypeConflictException The specified base does not point to 096 * memory that matches the request type, or 097 * if <code>type</code> specifies attirbutes 098 * with a conflict. 099 * @throws MemoryInUseException The specified memory is already in use. 100 */ 101 public ImmortalPhysicalMemory(Object type, long base, long size, 102 Runnable logic) 103 throws SecurityException, SizeOutOfBoundsException, 104 OffsetOutOfBoundsException, 105 UnsupportedPhysicalMemoryException, 106 MemoryTypeConflictException, MemoryInUseException { 107 this(type, base, size); 108 this.logic = logic; 109 } 110 111 /** Create an instance with the given parameters. 112 * 113 * @param type An instance of <code>Object</code> representing the type of 114 * memory required (e.g. <i>dma, share</i>) -used to define 115 * the base address and control the mapping. 116 * @param size The size of the area in bytes. 117 * @param logic The <code>run()</code> method of this object will be called 118 * whenever <code>MemoryArea.enter()</code> is called. 119 * @throws java.lang.SecurityException The application doesn't have 120 * permissions to access physical memory 121 * of the given type of memory. 122 * @throws SizeOutOfBoundsException The size is negative or extends into an 123 * invalid range of memory. 124 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 125 * does not support the given type. 126 * @throws MemoryTypeConflictException The specified base does not point to 127 * memory that matches the request type, or 128 * if <code>type</code> specifies attirbutes 129 * with a conflict. 130 */ 131 public ImmortalPhysicalMemory(Object type, long size, Runnable logic) 132 throws SecurityException, SizeOutOfBoundsException, 133 UnsupportedPhysicalMemoryException, 134 MemoryTypeConflictException { 135 this(type, size); 136 this.logic = logic; 137 } 138 139 /** Create an instance with the given parameters. 140 * 141 * @param type An instance of <code>Object</code> representing the type of 142 * memory required (e.g. <i>dma, share</i>) -used to define 143 * the base address and control the mapping. 144 * @param base The physical memory address of the area. 145 * @param size A size estimator for this memory area. 146 * @throws java.lang.SecurityException The application doesn't have 147 * permissions to access physical memory 148 * of the given type of memory. 149 * @throws SizeOutOfBoundsException The size is negative or extends into an 150 * invalid range of memory. 151 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 152 * does not support the given type. 153 * @throws MemoryTypeConflictException The specified base does not point to 154 * memory that matches the request type, or 155 * if <code>type</code> specifies attirbutes 156 * with a conflict. 157 * @throws MemoryInUseException The specified memory is already in use. 158 */ 159 public ImmortalPhysicalMemory(Object type, long base, 160 SizeEstimator size) 161 throws SecurityException, SizeOutOfBoundsException, 162 OffsetOutOfBoundsException, 163 UnsupportedPhysicalMemoryException, 164 MemoryTypeConflictException, MemoryInUseException { 165 this(type, size); 166 this.base = base; 167 } 168 169 /** Create an instance with the given parameters. 170 * 171 * @param type An instance of <code>Object</code> representing the type of 172 * memory required (e.g. <i>dma, share</i>) -used to define 173 * the base address and control the mapping. 174 * @param base The physical memory address of the area. 175 * @param size A size estimator for this memory area. 176 * @param logic The <code>run()</code> method of this object will be called 177 * whenever <code>MemoryArea.enter()</code> is called. 178 * @throws java.lang.SecurityException The application doesn't have 179 * permissions to access physical memory 180 * of the given type of memory. 181 * @throws SizeOutOfBoundsException The size is negative or extends into an 182 * invalid range of memory. 183 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 184 * does not support the given type. 185 * @throws MemoryTypeConflictException The specified base does not point to 186 * memory that matches the request type, or 187 * if <code>type</code> specifies attirbutes 188 * with a conflict. 189 * @throws MemoryInUseException The specified memory is already in use. 190 */ 191 public ImmortalPhysicalMemory(Object type, long base, 192 SizeEstimator size, Runnable logic) 193 throws SecurityException, SizeOutOfBoundsException, 194 OffsetOutOfBoundsException, 195 UnsupportedPhysicalMemoryException, 196 MemoryTypeConflictException, MemoryInUseException { 197 this(type, base, size); 198 this.logic = logic; 199 } 200 201 /** Create an instance with the given parameters. 202 * 203 * @param type An instance of <code>Object</code> representing the type of 204 * memory required (e.g. <i>dma, share</i>) -used to define 205 * the base address and control the mapping. 206 * @param size A size estimator for this memory area. 207 * whenever <code>MemoryArea.enter()</code> is called. 208 * @throws java.lang.SecurityException The application doesn't have 209 * permissions to access physical memory 210 * of the given type of memory. 211 * @throws SizeOutOfBoundsException The size is negative or extends into an 212 * invalid range of memory. 213 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 214 * does not support the given type. 215 * @throws MemoryTypeConflictException The specified base does not point to 216 * memory that matches the request type, or 217 * if <code>type</code> specifies attirbutes 218 * with a conflict. 219 * @throws MemoryInUseException The specified memory is already in use. 220 */ 221 public ImmortalPhysicalMemory(Object type, SizeEstimator size) 222 throws SecurityException, SizeOutOfBoundsException, 223 UnsupportedPhysicalMemoryException, 224 MemoryTypeConflictException { 225 this(type, size.getEstimate()); 226 } 227 228 /** Create an instance with the given parameters. 229 * 230 * @param type An instance of <code>Object</code> representing the type of 231 * memory required (e.g. <i>dma, share</i>) -used to define 232 * the base address and control the mapping. 233 * @param size A size estimator for this memory area. 234 * whenever <code>MemoryArea.enter()</code> is called. 235 * @param logic The <code>run()</code> method of this object will be called 236 * whenever <code>MemoryArea.enter()</code> is called. 237 * @throws java.lang.SecurityException The application doesn't have 238 * permissions to access physical memory 239 * of the given type of memory. 240 * @throws SizeOutOfBoundsException The size is negative or extends into an 241 * invalid range of memory. 242 * @throws UnsupportedPhysicalMemoryException Thrown if the underlying hardware 243 * does not support the given type. 244 * @throws MemoryTypeConflictException The specified base does not point to 245 * memory that matches the request type, or 246 * if <code>type</code> specifies attirbutes 247 * with a conflict. 248 * @throws MemoryInUseException The specified memory is already in use. 249 */ 250 public ImmortalPhysicalMemory(Object type, SizeEstimator size, 251 Runnable logic) 252 throws SecurityException, SizeOutOfBoundsException, 253 UnsupportedPhysicalMemoryException, 254 MemoryTypeConflictException { 255 this(type, size); 256 this.logic = logic; 257 } 258 259 /** Create an instance with the given parameters. 260 * 261 * @param base The physical memory address of the area. 262 * @param size A size estimator for this memory area. 263 */ 264 public ImmortalPhysicalMemory(long base, long size) { 265 super(size); 266 this.base = base; 267 this.size = size; 268 } 269 270 /** */ 271 272 protected native void initNative(long sizeInBytes); 273 }