view gsm-fw/gpf/osl/os_mem_ir.c @ 438:0eb7c6389717

os_mem_ir.c: os_DeallocatePartition() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 22 Jun 2014 21:07:51 +0000
parents 1d78af921a5a
children c2da9dd01f85
line wrap: on
line source

/*
 * This C module is a reconstruction based on the disassembly of
 * os_mem.obj in frame_na7_db_ir.lib from the Leonardo package.
 */

/* set of included headers from COFF symtab: */
#include <stdio.h>
#include <string.h>
#include "gpfconf.h"	/* FreeCalypso addition */
#include "../../nucleus/nucleus.h"
#include "typedefs.h"
#include "os.h"
#include "gdi.h"
#include "os_types.h"
#include "os_glob.h"

extern T_OS_PART_GRP_TABLE_ENTRY PartGrpTable[];
extern T_OS_POOL_BORDER PoolBorder[];

GLOBAL LONG
os_is_valid_partition(T_VOID_STRUCT *Buffer)
{
	int i;

	for (i = 0; i <= MaxPoolGroups; i++) {
		if (PoolBorder[i].End == 0)
			return(OS_ERROR);
		if ((char *)Buffer < PoolBorder[i].Start)
			continue;
		if ((char *)Buffer >= PoolBorder[i].End)
			continue;
		return(OS_OK);
	}
	return(OS_ERROR);
}

GLOBAL LONG
os_PartitionCheck(ULONG *ptr)
{
	PM_HEADER *phdr;
	PM_PCB *pool;

	phdr = (PM_HEADER *)(ptr - 2);
	if (phdr->pm_next_available)
		return(OS_PARTITION_FREE);
	pool = phdr->pm_partition_pool;
	if (ptr[(pool->pm_partition_size - 4) >> 2] == GUARD_PATTERN)
		return(OS_OK);
	else
		return(OS_PARTITION_GUARD_PATTERN_DESTROYED);
}

GLOBAL LONG
os_DeallocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT *Buffer)
{
	if (os_is_valid_partition(Buffer) != OS_OK)
		return(OS_ERROR);
	if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS)
		return(OS_ERROR);
	return(OS_OK);
}