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

📄 oslesswmroam.c.new

📁 s3c2450 bsp for wince 5.0 PM_REL_0.04_080519 经验证,完全没问题
💻 NEW
📖 第 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>

// hmseo-061017 start
//#include "S5L8700.h"
//#include "Api_main.h"

//#include "tfs4_types_internal.h"
// hmseo-061017 end

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

/*****************************************************************************/
/* Local #defines                                                            */
/*****************************************************************************/
#define		OSLESS_MALLOC_POOL_SIZE_BY_KB	40
#define		LOCAL_MEM_SIZE		((OSLESS_MALLOC_POOL_SIZE_BY_KB * 1024) / sizeof(UINT32))

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

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

/*****************************************************************************/
/* Static variables definitions                                              */
/*****************************************************************************/
static UINT32  aMemBuf[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
//UINT8 szBuff[512];

// hmseo-061017 start
//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;
// hmseo-061017 end

#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 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                                                                      */
/*      WMR_GetRelatedChkSum                                                 */
/* DESCRIPTION                                                               */
/*      This function returns the sum of 0 count of pBuf1 & pBuf2.		     */
/* PARAMETERS                                                                */
/*      pBuf1   [IN] 	the pointer of buffer	                             */
/*      pBuf2   [IN] 	the pointer of buffer	                             */
/*      nSize	[IN] 	the size of buffer		                             */
/* RETURN VALUES                                                             */
/*		the sum of 1 count													 */
/* NOTES                                                                     */
/*                                                                           */
/*****************************************************************************/
#if (WMR_MLC_SUPPORT)
UINT32
WMR_GetRelatedChkSum(UINT8 *pBuf1, UINT8 *pBuf2, UINT32	nSize)
{
	UINT32 nIdx;
	UINT32 nSum = 0;

	for (nIdx = 0; nIdx < nSize; nIdx++)
	{
		UINT8 nValue0 = pBuf1[nIdx];
		UINT8 nValue2 = pBuf2[nIdx];
		UINT32 j;

		for (j = 0; j < 8; j++)
		{
			UINT8 nBit0 = (nValue0 >> j) & 0x1;
			UINT8 nBit2 = (nValue2 >> j) & 0x1;

			if (!nBit0 && !nBit2) 
			{
				nSum += 3;
			}
			else if (nBit0 && !nBit2)
			{
				nSum += 2;
			}
			else if (!nBit0 && nBit2)
			{
				nSum += 1;
			}
		}
		
	}

	return nSum;
}
#endif


/*****************************************************************************/
/*                                                                           */
/* 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)
{
	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;

⌨️ 快捷键说明

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