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