Copyright (c) Hyperion Entertainment and contributors.
Difference between revisions of "Obsolete Exec Memory Allocation"
Jump to navigation
Jump to search
Steven Solie (talk | contribs) |
Steven Solie (talk | contribs) |
||
Line 4: | Line 4: | ||
The purpose of this section is to describe the obsolete techniques in detail so that it may be easier to port those applications to [[Exec_Memory_Allocation|Exec's modern memory system]]. |
The purpose of this section is to describe the obsolete techniques in detail so that it may be easier to port those applications to [[Exec_Memory_Allocation|Exec's modern memory system]]. |
||
+ | |||
+ | = Memory Attributes = |
||
+ | |||
+ | When asking the system for memory, an application can ask for memory with certain attributes. The currently supported flags are listed below. |
||
+ | |||
+ | {| class="wikitable" |
||
+ | ! Attribute Flag |
||
+ | ! Meaning |
||
+ | |- |
||
+ | | MEMF_ANY |
||
+ | | This indicates that there is no requirement for the memory. Exec will always try to allocate faster memory before slower memory (if available). This is the default and should be used as often as possible. A typical implementation of malloc() would use MEMF_ANY as the memory flag. |
||
+ | |- |
||
+ | | MEMF_CHIP |
||
+ | | '''Deprecated.''' This indicates the application wants a block of chip memory, meaning it wants memory addressable by the classic Amiga custom chips. Chip memory is required for any data that will be accessed by custom chip DMA. This includes screen memory, images that will be blitted, sprite data, copper lists and audio data. Only useful on classic machines and should be avoided. |
||
+ | |- |
||
+ | | MEMF_FAST |
||
+ | | '''Deprecated.''' This indicates a memory block outside of the range that the classic Amiga special purpose chips can access. "FAST" means that the special-purpose chips do not have access to the memory and thus cannot cause processor bus contention, therefore processor access will likely be faster. Since the flag specifies memory that the custom chips cannot access, this flag is mutually exclusive with the MEMF_CHIP flag. Only useful on classic machines, and should be avoided |
||
+ | |- |
||
+ | | MEMF_VIRTUAL |
||
+ | | Use virtual memory in any case. This will fail if only public memory is available. Usually, you should not use this flag but use MEMF_ANY instead. |
||
+ | |- |
||
+ | | MEMF_EXECUTABLE |
||
+ | | Allocate memory that can hold executable code. Executable code must be placed in a specifically marked segment in memory to prevent buffer overflow exploits and for the automatic code type determination (PowerPC native vs. emulated 68k) to work. Failure to do so will result in an ISI exception. |
||
+ | |- |
||
+ | | MEMF_PUBLIC |
||
+ | | '''Deprecated.''' This indicates that the memory should be accessible to other tasks. Deprecated. See the discussion below why you should avoid it. |
||
+ | |- |
||
+ | | MEMF_SHARED |
||
+ | | Memory of this type is sharable between tasks. See the discussion below for details. |
||
+ | |- |
||
+ | | MEMF_PRIVATE |
||
+ | | Memory allocated with this flag is private for this task only. No other task can access it and any attempt to do so will result in a DSI exception. |
||
+ | |} |
||
+ | |||
+ | Several flags are available that modifies or augments the memory allocation in a specific way. They can usually be used together with other flags listed above. |
||
+ | |||
+ | {| class="wikitable" |
||
+ | ! Modifier Flag |
||
+ | ! Meaning |
||
+ | |- |
||
+ | | MEMF_CLEAR |
||
+ | | This indicates that the memory should be initialized with zeros. |
||
+ | |- |
||
+ | | MEMF_LOCAL |
||
+ | | '''Deprecated.''' This indicates memory which is located on the motherboard which is not initialized on reset. |
||
+ | |- |
||
+ | | MEMF_24BITDMA |
||
+ | | '''Deprecated.''' This indicates that the memory should be allocated within the 24 bit address space, so that the memory can be used in Zorro-II expansion device DMA transactions. This bit is for use by Zorro-II DMA devices only. It is not for general use by applications. |
||
+ | |- |
||
+ | | MEMF_REVERSE |
||
+ | | '''Deprecated.''' Indicates that the memory list should be searched backwards for the highest address memory chunk which can be used for the memory allocation. |
||
+ | |- |
||
+ | | MEMF_NO_EXPUNGE |
||
+ | | Prevents expunging from happening if set. Expunge is the process of freeing unused system resources. |
||
+ | |- |
||
+ | | MEMF_HWALIGNED |
||
+ | | Causes memory to be aligned to the hardware's physical page size. This flag is useful if you want to use the MMU to, for example, write protect memory. |
||
+ | |- |
||
+ | | MEMF_DELAYED |
||
+ | | Delay actual allocation of physical pages until they are accessed. See the discussion below for details. |
||
+ | |} |
Revision as of 22:23, 8 June 2012
Introduction
Prior to AmigaOS 4.0, Exec's memory system was implemented as a simple linked list. Many older applications may have used the obsolete techniques described in this section to handle memory resources.
The purpose of this section is to describe the obsolete techniques in detail so that it may be easier to port those applications to Exec's modern memory system.
Memory Attributes
When asking the system for memory, an application can ask for memory with certain attributes. The currently supported flags are listed below.
Attribute Flag | Meaning |
---|---|
MEMF_ANY | This indicates that there is no requirement for the memory. Exec will always try to allocate faster memory before slower memory (if available). This is the default and should be used as often as possible. A typical implementation of malloc() would use MEMF_ANY as the memory flag. |
MEMF_CHIP | Deprecated. This indicates the application wants a block of chip memory, meaning it wants memory addressable by the classic Amiga custom chips. Chip memory is required for any data that will be accessed by custom chip DMA. This includes screen memory, images that will be blitted, sprite data, copper lists and audio data. Only useful on classic machines and should be avoided. |
MEMF_FAST | Deprecated. This indicates a memory block outside of the range that the classic Amiga special purpose chips can access. "FAST" means that the special-purpose chips do not have access to the memory and thus cannot cause processor bus contention, therefore processor access will likely be faster. Since the flag specifies memory that the custom chips cannot access, this flag is mutually exclusive with the MEMF_CHIP flag. Only useful on classic machines, and should be avoided |
MEMF_VIRTUAL | Use virtual memory in any case. This will fail if only public memory is available. Usually, you should not use this flag but use MEMF_ANY instead. |
MEMF_EXECUTABLE | Allocate memory that can hold executable code. Executable code must be placed in a specifically marked segment in memory to prevent buffer overflow exploits and for the automatic code type determination (PowerPC native vs. emulated 68k) to work. Failure to do so will result in an ISI exception. |
MEMF_PUBLIC | Deprecated. This indicates that the memory should be accessible to other tasks. Deprecated. See the discussion below why you should avoid it. |
MEMF_SHARED | Memory of this type is sharable between tasks. See the discussion below for details. |
MEMF_PRIVATE | Memory allocated with this flag is private for this task only. No other task can access it and any attempt to do so will result in a DSI exception. |
Several flags are available that modifies or augments the memory allocation in a specific way. They can usually be used together with other flags listed above.
Modifier Flag | Meaning |
---|---|
MEMF_CLEAR | This indicates that the memory should be initialized with zeros. |
MEMF_LOCAL | Deprecated. This indicates memory which is located on the motherboard which is not initialized on reset. |
MEMF_24BITDMA | Deprecated. This indicates that the memory should be allocated within the 24 bit address space, so that the memory can be used in Zorro-II expansion device DMA transactions. This bit is for use by Zorro-II DMA devices only. It is not for general use by applications. |
MEMF_REVERSE | Deprecated. Indicates that the memory list should be searched backwards for the highest address memory chunk which can be used for the memory allocation. |
MEMF_NO_EXPUNGE | Prevents expunging from happening if set. Expunge is the process of freeing unused system resources. |
MEMF_HWALIGNED | Causes memory to be aligned to the hardware's physical page size. This flag is useful if you want to use the MMU to, for example, write protect memory. |
MEMF_DELAYED | Delay actual allocation of physical pages until they are accessed. See the discussion below for details. |