⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oslesswmroam.c

📁 6410BSP3
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************/
/*                                                                           */
/* PROJECT : Rainbow	                                                     */
/* MODULE  : OS Adaptation Module                                            */
/* NAME    : OSLess OAM                                                      */
/* FILE    : WMROAM.c                                                        */
/* PURPOSE : This file contain the OS Adaptation Modules for OSless platform */
/*           such as BootLoader                                              */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/*          COPYRIGHT 2003-2005 SAMSUNG ELECTRONICS CO., LTD.                */
/*                          ALL RIGHTS RESERVED                              */
/*                                                                           */
/*   Permission is hereby granted to licenses of Samsung Electronics         */
/*   Co., Ltd. products to use or abstract this computer program only in     */
/*   accordance with the terms of the NAND FLASH MEMORY SOFTWARE LICENSE     */
/*   AGREEMENT for the sole purpose of implementing a product based on       */
/*   Samsung Electronics Co., Ltd. products. No other rights to reproduce,   */
/*   use, or disseminate this computer program, whether in part or in whole, */
/*   are granted.                                                            */
/*                                                                           */
/*   Samsung Electronics Co., Ltd. makes no representation or warranties     */
/*   with respect to the performance of this computer program, and           */
/*   specifically disclaims any responsibility for any damages,              */
/*   special or consequential, connected with the use of this program.       */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*                                                                           */
/* REVISION HISTORY                                                          */
/*                                                                           */
/*   18-AUG-2005 [Yangsup Lee]  : first writing                              */
/*                                                                           */
/*****************************************************************************/
#include <windows.h>
#include "WMRConfig.h"
#include "WMRTypes.h"
#include "OSLessWMROAM.h"

//#include <stdarg.h>
//#include <stdio.h>

//#include "S5L8700.h"

/*****************************************************************************/
/* Global variables definitions                                              */
/*****************************************************************************/

/*****************************************************************************/
/* Local #defines                                                            */
/*****************************************************************************/
#define		OSLESS_MALLOC_POOL_SIZE_BY_KB	50
#define		WMR_LOCAL_MEM_SIZE		((OSLESS_MALLOC_POOL_SIZE_BY_KB * 1024) / sizeof(UINT32))

/*****************************************************************************/
/* Local typedefs                                                            */
/*****************************************************************************/

/*****************************************************************************/
/* Local constant definitions                                                */
/*****************************************************************************/

/*****************************************************************************/
/* Static variables definitions                                              */
/*****************************************************************************/
static UINT32  aMemBuf[WMR_LOCAL_MEM_SIZE];
static UINT32  nMallocPtr = 0;

static	BYTE	memAddr[OSLESS_MALLOC_POOL_SIZE_BY_KB];
static	BOOL	firstMemalloc = TRUE;

typedef struct _MEMARRAY {
    DWORD startAddress;     // starting sector number
	DWORD size;   // number of sectors
} MEMARRAY, * PMEMARRAY;

static	MEMARRAY	memarray[OSLESS_MALLOC_POOL_SIZE_BY_KB];

#define USED	1
#define	FREE	0

/* for Blues LLD */
//UINT8 	aTempSBuf[512];
//UINT8 	aMakeSECCBuf[512];
//UINT8 	aTempEccBuf[12];
//BOOL32	aNeedSync[WMR_MAX_DEVICE * 2];

//UINT8 TestMBuf[2];
//UINT8 TestMBuf[2048];
//UINT8 TestSBuf[512];


// for TFS4
#if 0
UINT8 szBuff[512];

t_char sBuff[2];
t_uint8	usBuffer[2];
t_char      *pArg[2];
t_kfat_string       sTmp;
t_kfat_string           strUnicode;
t_kfat_string strChild, strChildShort, strRead;
t_dir_entry             stDE[2];
t_file_table_entry stParent, stChild;
#endif

#if 0
extern UINT8 aChecksumTable[];
#else
/*****************************************************************************/
/* Static variables definitions                                              */
/*****************************************************************************/
PRIVATE const UINT8 aChecksumTable[256]  =
   { 8, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4,
      7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
      7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
      7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
      6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
      5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
      5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
      4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0
    };

#endif

/*****************************************************************************/
/* Code Implementation                                                       */
/*****************************************************************************/
/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      WMR_GetChkSum                                                        */
/* DESCRIPTION                                                               */
/*      This function returns the sum of 0 count of pBuf.				     */
/* PARAMETERS                                                                */
/*      pBuf    [IN] 	the pointer of buffer	                             */
/*      nSize	[IN] 	the size of buffer		                             */
/* RETURN VALUES                                                             */
/*		the sum of 0 count													 */
/* NOTES                                                                     */
/*                                                                           */
/*****************************************************************************/
UINT16
WMR_GetChkSum(UINT8 *pBuf, UINT32 nSize)
{
	register UINT32 nIdx;
	register const UINT8 *pD8;
	register const UINT8 *pCheckSum;
	register UINT32 nSum = 0;

	pD8 = pBuf;

	pCheckSum = aChecksumTable;

	if(nSize < 512)
	{
		for (nIdx = 0; nIdx < nSize; nIdx++)
		{
			nSum += *(pCheckSum + *(pD8++));
		}
	}
	else
	{
		for (nIdx = 0; nIdx < nSize / 8; nIdx++)
		{
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
			nSum += *(pCheckSum + *(pD8++));
		}
	}

	return (UINT16)nSum;
}


/*****************************************************************************/
/*                                                                           */
/* NAME                                                                      */
/*      OAM_Malloc                                                           */
/* DESCRIPTION                                                               */
/*      This function allocates memory for Whimory                           */
/*                                                                           */
/* PARAMETERS                                                                */
/*      nSize       [IN]                                                     */
/*            Size to be allocated                                           */
/*                                                                           */
/* RETURN VALUES                                                             */
/*      Pointer of allocated memory                                          */
/*                                                                           */
/* NOTES                                                                     */
/*      This function is called by function that wants to use memory         */
/*                                                                           */
/*****************************************************************************/
VOID *
OAM_Malloc(UINT32 nSize)
{
#ifdef NO_MALLOC	// by dodan2 061216
	WMR_RTL_PRINT((TEXT("[FTL:ERR]  OAM_Malloc() : NO_MALLOC defined\r\n")));
	while(1);
#else
	UINT32  nAlignSize;
	UINT32	nAlignArrayStart;
	UINT32	nAlignArrayNumber;
	UINT32	i;
	UINT32	j;

//	RETAILMSG(1, (L"OAM_Malloc : nSize=0x%x \n", nSize));

	if ( firstMemalloc == TRUE )
	{
		for ( i = 0; i < OSLESS_MALLOC_POOL_SIZE_BY_KB; i++ )
		{
			memAddr[i] = FREE;
			memarray[i].startAddress = 0;
			memarray[i].size = 0;
		}
		firstMemalloc = FALSE;
	}

	nAlignArrayNumber = nSize/1024+(nSize%1024==0?0:1);
//	RETAILMSG(1, (L"OAM_Malloc : nAlignArrayNumber=%d \n", nAlignArrayNumber));
	nAlignSize = nAlignArrayNumber*1024;
//	RETAILMSG(1, (L"OAM_Malloc : nAlignSize=%d \n", nAlignSize));

	for ( i = 0; i < OSLESS_MALLOC_POOL_SIZE_BY_KB; i++ )
	{
//		RETAILMSG(1, (L"OAM_Malloc : i=%d, memAddr[%d]=0x%x \n", i, i, memAddr[i]));
		if ( memAddr[i] == USED ) continue;
		for (j = 0; j < nAlignArrayNumber; j++)
		{
//			RETAILMSG(1, (L"OAM_Malloc : i+j=%d, memAddr[%d]=0x%x \n", i+j, i+j, memAddr[i+j]));
			if ( memAddr[i+j] == FREE )
				continue;
			else
				break;
		}
//		RETAILMSG(1, (L"OAM_Malloc : j=%d, nAlignArrayNumber=%d \n", j, nAlignArrayNumber));
		if ( j == nAlignArrayNumber )	// found
		{
			nAlignArrayStart = i;
			nMallocPtr = i*1024/sizeof(UINT32);
			break;
		}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -