# System Memory Manager

## Detailed Description

This module contains routines to manage heaps of memory.

## Typedefs

typedef int | SceKernelSysMemAlloc_t

## Enumerations

enum | PspSysMemBlockTypes { PSP_SMEM_Low = 0, PSP_SMEM_High, PSP_SMEM_Addr }
| Specifies the type of allocation used for memory blocks. More...

## Functions

SceUID | sceKernelAllocPartitionMemory (SceUID partitionid, const char *name, int type, SceSize size, void *addr)
| Allocate a memory block from a memory partition.
int | sceKernelFreePartitionMemory (SceUID blockid)
| Free a memory block allocated with sceKernelAllocPartitionMemory.
void * | sceKernelGetBlockHeadAddr (SceUID blockid)
| Get the address of a memory block.
SceSize | sceKernelTotalFreeMemSize (void)
| Get the total amount of free memory.
SceSize | sceKernelMaxFreeMemSize (void)
| Get the size of the largest free memory block.
int | sceKernelDevkitVersion (void)
| Get the firmware version.

## Typedef Documentation

typedef int SceKernelSysMemAlloc_t

## Enumeration Type Documentation

enum PspSysMemBlockTypes

Specifies the type of allocation used for memory blocks.

Enumerator:

  PSP_SMEM_Low | Allocate from the lowest available address.
  PSP_SMEM_High | Allocate from the highest available address.
  PSP_SMEM_Addr | Allocate from the specified address.

## Function Documentation

SceUID sceKernelAllocPartitionMemory | ( | SceUID | partitionid,
|  | const char * | name,
|  | int | type,
|  | SceSize | size,
|  | void * | addr
| ) |

Allocate a memory block from a memory partition.

Parameters:

  | partitionid | - The UID of the partition to allocate from.
  | name | - Name assigned to the new block.
  | type | - Specifies how the block is allocated within the partition. One of PspSysMemBlockTypes.
  | size | - Size of the memory block, in bytes.
  | addr | - If type is PSP_SMEM_Addr, then addr specifies the lowest address allocate the block from.

Returns:
  The UID of the new block, or if less than 0 an error.

int sceKernelDevkitVersion | ( | void |  | ) |

Get the firmware version.

Returns:
  The firmware version. 0x01000300 on v1.00 unit 0x01050001 on v1.50 unit

int sceKernelFreePartitionMemory | ( | SceUID | blockid | ) |

Free a memory block allocated with sceKernelAllocPartitionMemory.

Parameters:

  | blockid | - UID of the block to free.

Returns:
  ? on success, less than 0 on error.

void* sceKernelGetBlockHeadAddr | ( | SceUID | blockid | ) |

Get the address of a memory block.

Parameters:

  | blockid | - UID of the memory block.

Returns:
  The lowest address belonging to the memory block.

SceSize sceKernelMaxFreeMemSize | ( | void |  | ) |

Get the size of the largest free memory block.

Returns:
  The size of the largest free memory block, in bytes.

SceSize sceKernelTotalFreeMemSize | ( | void |  | ) |

Get the total amount of free memory.

Returns:
  The total amount of free memory, in bytes.