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

📄 zfsosdep.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
/*
 * File       : ZFSOsDep.c
 * Description: This file contains the implementation of wrappers for 
				OS calls
 * Author     : Mahadev K C
 * Created on : 30-APR-2003
 *
 * Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
 *
 * This file contains unpublished confidential and proprietary information
 * of ZiLOG, Inc.
 * NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
 * IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
 * This is not a license and no use of any kind of this work is authorized
 * in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
 * sole discretion 
 */
 



#include "glextern.h"
#include "ZSysgen.h"
#include "ZThread.h"
#include "ZSemaphore.h"

#include "Zdevice.h"
#include "rtc.h"

UINT8 g_rtcinited = ZFS_FALSE;
RZK_DEVICE_CB_t *g_rtc_handle ;

// OS dependent

UINT DisablePreemption( void )
{
	return RZKDisablePreemption() ;
//	return 0 ;
}


void EnablePreemption( UINT status )
{
	RZKRestorePreemption( ( RZK_STATE_t ) status ) ;
	return ;
}


ZFS_THD_HANDLE_t GetCurrentThread( void )
{
	return RZKGetCurrentThread() ;
//	return NULL ;
}


//CWD_IMPLEMENTATION
INT8 *GetCwdPathForHandle( VOID *handle )
{
	RZK_STATUS_t status ;
	INT8 *pstring ;

	status = RZKGetCwd( handle, ( VOID **) &pstring ) ;
	if( status != RZKERR_SUCCESS )
		return ( INT8 * ) NULL ;
	else
		return pstring ;
}



INT8 SetCwdPath( INT8 *pcwd_path )
{
	RZK_STATUS_t status ;

	status = RZKSetCwd( pcwd_path ) ;
	if( status != RZKERR_SUCCESS )
		return ZFS_FALSE ;
	else
		return ZFS_TRUE ;
}


ZFS_THD_HANDLE_t GetThreadHandleFromId( UINT id )
{
	ZFS_THD_HANDLE_t handle ;
	RZK_STATUS_t status ;

	status = RZKGetHandleByIndex( id, &handle ) ;
	if( status != RZKERR_SUCCESS )
		return NULL ;
	else
		return handle ;
}

	
void SetFSData( ZFS_STATUS_t status )
{
	RZKSetFSData( status ) ;
}

ZFS_STATUS_t GetFSData()
{
	return RZKGetFSData() ;
}

extern UINT8 g_rtcinited ;
extern RZK_DEVICE_CB_t *g_rtc_handle ;

UINT8 GetTimeData( UINT32 *date_time, UINT8 *time_century  )
{

	UINT preempt_status ;
	UINT retval ;
	TIME time_struct ;

	preempt_status = DisablePreemption() ;

	// get the date and time from RTC driver
	if( !g_rtcinited )
		{
		retval = ZFSERR_SUCCESS ;
		goto _end_gettimedata_err ;
		}

	// read the date and time
	if( RZKDevRead( g_rtc_handle, (RZK_DEV_BUFFER_t*)&time_struct, sizeof( TIME ) ) != RZKERR_SUCCESS )
		{
		// error in reading the date and time, then keep the same date and time.
		retval = ZFSERR_DEVICE ;
		goto _end_gettimedata_err ;
		}

	// got the date and time, just format according to the ZFS format.
	*date_time = (time_struct.sec >> 1) & 0x1F ;
	*date_time |= ((UINT32)( time_struct.minutes & 0x3F )) << 5 ;
	*date_time |= ((UINT32)( time_struct.hrs & 0x1F )) << 11 ;
	*date_time |= ((UINT32)( time_struct.dayOfMonth & 0x1F )) << 16 ;
	*date_time |= ((UINT32)( time_struct.mon & 0x0F )) << 21 ;
	*date_time |= ((UINT32)( time_struct.year & 0x7F )) << 25 ;

	*time_century = time_struct.cent ;
	retval = ZFSERR_SUCCESS ;
	goto _end_gettimedata ;

_end_gettimedata_err:
	*date_time = 0xFFFFFFFFUL ;
	*time_century = 0xFF ;
_end_gettimedata:
	EnablePreemption( preempt_status ) ;
	return retval ;
}


UINT8 InitializeRTC( void )
{
	if( !g_rtcinited )
		{
		// no need to call RZKDevOpen, directly call the read.
		// initialize the RTC:

		g_rtc_handle = RZKDevOpen( ( INT8 * ) "RTC", ( INT8 * ) NULL ) ;
		if( g_rtc_handle == NULL )
			{
			// error in opening the driver.
			return ZFS_FALSE ;
			}
		g_rtcinited = ZFS_TRUE ;
		}

	return ZFS_TRUE ;
}






⌨️ 快捷键说明

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