General purpose resource allocator. Based on tinyvmem and on Bonwick’s paper
| Functions | |
| _vmem_hashtable_hash | |
| _vmem_hashtable_addr | |
| _vmem_segfree | |
| _vmem_segalloc | |
| _vmem_refill | |
| _vmem_segfit | Check if a VmemSegment meet restrictions. |
| _vmem_add_to_freelist | Add segment to Vmem freelist. |
| _vmem_insert_segment | |
| _vmem_hashtable_insert | |
| _vmem_add | |
| _vmem_import |
_vmem_segfit
Check if a VmemSegment meet restrictions.
| EAX | seg |
| EDX | size |
| ECX | align |
| ESP[4] | phase |
| ESP[8] | nocross |
| ESP[12] | minaddr |
| ESP[16] | macaddr |
| ESP[20] | addrp |
_vmem_add_to_freelist
Add segment to Vmem freelist.
| EAX | Pointer to Vmem object. |
| EDX | Pointer to VmemSegment object. |
_vmem_add
| EAX | Pointer to Vmem object. |
| EDX | Address. |
| ECX | Size in bytes. |
| ESP[4] | Flags. (VMEM_VM_SLEEP or VMEM_VM_NOSLEEP) |
| ESP[8] | Span type (VMEM_SEGMENT_SPAN or VMEM_SEGMENT_STATIC_SPAN) |
| EAX | 0 on success. |
| Functions | |
| vmem_create | Creates a new Vmem arena whose initial span is [Base, Base + Size). |
| vmem_destroy | Destroys an arena |
| vmem_alloc | Allocates n-bytes from arena. |
| vmem_free | Free n-bytes at address to arena |
| vmem_xalloc | |
| vmem_xfree | Frees n-bytes at address. |
| vmem_add | Adds a span [Address, Address + Size) to an arena. |
| vmem_size | Return information about arenas size |
| vmem_dump | |
| vmem_bootstrap | Initialize static segments |
vmem_create
Creates a new Vmem arena whose initial span is [Base, Base + Size).
| EAX | Pointer to a Vmem object. |
| EDX | String. |
| ECX | Base. |
| ESP[4] | Size in bytes. |
| ESP[8] | Quantum. |
| ESP[12] | Alloc function. |
| ESP[16] | Free function. |
| ESP[20] | Source. |
| ESP[24] | Flags. (VMEM_VM_SLEEP or VMEM_VM_NOSLEEP) |
vmem_alloc
Allocates n-bytes from arena.
| EAX | Pointer to a Vmem object. |
| EDX | Size in bytes. |
| ECX | Flags |
| EAX | Allocated address on succes, 0 on failure. |
vmem_xalloc
| EAX | Pointer to a Vmem object. |
| EDX | Size in bytes. |
| ECX | Alignment boundary. |
| ESP[4] | Phase. |
| ESP[8] | Nocross. |
| ESP[12] | Min address. |
| ESP[16] | Max address. |
| ESP[20] | Flags. (VMEM_VM_BESTFIT, VMEM_VM_INSTANTFIT, VMEM_VM_SLEEP, VMEM_VM_NOSLEEP) |
| EAX | Allocated address on succes, 0 on failure. |
vmem_add
Adds a span [Address, Address + Size) to an arena.
| EAX | Pointer to Vmem object. |
| EDX | Address. |
| ECX | Size in bytes. |
| ESP[4] | Flags. (VMEM_VM_SLEEP or VMEM_VM_NOSLEEP) |
| EAX | Return Address on success, 0 on failure. |
vmem_size
Return information about arenas size
| EAX | Pointer to Vmem object. |
| EDX | Type mask. |
| EAX | Free/allocated size in arena. |
macro VMEM_GET_LIST_FROM_SIZE reg, N
_vmem_hashtable_hash
_vmem_hashtable_addr
_vmem_segfree
_vmem_segalloc
_vmem_refill
Check if a VmemSegment meet restrictions.
_vmem_segfit
Add segment to Vmem freelist.
_vmem_add_to_freelist
_vmem_insert_segment
_vmem_hashtable_insert
_vmem_add
_vmem_import
Creates a new Vmem arena whose initial span is [Base, Base + Size).
vmem_create
Destroys an arena
vmem_destroy
Allocates n-bytes from arena.
vmem_alloc
Free n-bytes at address to arena
vmem_free
vmem_xalloc
Frees n-bytes at address.
vmem_xfree
Adds a span [Address, Address + Size) to an arena.
vmem_add
Return information about arenas size
vmem_size
vmem_dump
Initialize static segments
vmem_bootstrap
aVmemStaticSegs db VMEM_STATIC_SEG_COUNT*sizeof.VmemSegment dup( )
pVmemFreeSegHead dd 0
iVmemFreeSegCount dd 0