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

📄 osapiarch.c

📁 osapi 2.0 操作系统抽象层 "系统抽象层"使得你可以实现一种对于RTOS、CPU和所运行产品物理特性完全透明的软件。使用这种公共通用接口
💻 C
📖 第 1 页 / 共 2 页
字号:
/*** File   :	osapiarch.c**** Author :	Ezra Yeheskeli**** Purpose: **         This file  contains some of the OS APIs abstraction layer.**         It contains the processor architecture specific calls.**** $Revision: 1.7 $ **** $Date: 2005/07/08 19:28:55 $**** $Log: osapiarch.c,v $** Revision 1.7  2005/07/08 19:28:55  nyanchik** cleaned out "u_byte" from the osapiarch.c files and fixed parameters in VxWorks osapi.c**** Revision 1.6  2005/07/06 18:04:18  nyanchik** I had to change all of the memory functions to return int32 from uint32 because I noticed they were returning OS return codes. I also updated the API document.**** Revision 1.5  2005/07/05 18:34:05  nyanchik** fixed issues found in code walkthrogh. Also removed the OS_Info* functions that are going in the BSP**** Revision 1.4  2005/06/15 16:43:06  nyanchik** added extra parenthesis for the .h file # defines**** Revision 1.3  2005/06/07 16:48:51  nyanchik** changed returns code for osapi.c to all int32 from uint32**** Revision 1.2  2005/03/15 18:23:52  nyanchik** *** empty log message ******* Revision 1.1.1.1  2004/08/31 17:12:57  acudmore** Initial CVS Import**** Revision 1.1.1.1  2004/07/25 12:59:46  acudmore** Initial import**** Revision 1.1.1.1  2004/07/06 15:10:06  acudmore** Initial import of cFE Prototype**** Revision 1.11  2004/07/01 19:59:05  acudmore** Added OS_IntGet/SetMask, it was hardware specific**** Revision 1.10  2004/06/29 20:47:44  acudmore** Updated os exceptions and mode log**** Revision 1.9  2004/06/26 12:22:40  acudmore** added exception handlers and restarts**** Revision 1.8  2004/06/18 15:28:58  pkutt** Added OS API function for checking memory ranges.**** Revision 1.7  2004/06/09 18:18:50  eyeheskeli** added a Note in OS_EepromWriteEnable, added include string.h**** Revision 1.6  2004/06/09 17:41:40  eyeheskeli** in OS_EepromPowerDown changed RHCF5208_PP_DAT1 to  RHCF5208_PP_DAT2****  16-Nov-2003 Ezra Yeheskeli**          - First Creation.  ****  26-May-2004 Alan Cudmore**     - As per discussion, removed alignment checks for coldfire memory write and read routines.**  09-June-2004 Ezra Yeheskeli**     - in OS_EepromPowerDown changed RHCF5208_PP_DAT1 to  RHCF5208_PP_DAT2**     - added a Note in OS_EepromWriteEnable**     - added include string.h**  18-June-2004 Peter Kutt**     - added OS_MemBankTbl and OS_MemCheckRange.*//*** Include section*/#include <sys/types.h>#include <time.h>#include <pthread.h>#include <unistd.h>#include <errno.h> /* checking ETIMEDOUT */#include <string.h> /* memcpy *//*** User defined include files*/#include "common_types.h"#include "osapi.h"#include "osprocessor.h"#include "osplatform.h"/*** Internal defines*/#define EEPROM_WRITE_TIMEOUT	0x0000FFFF/*** Internal typedefs*//* Address range of a memory bank. */typedef struct {   uint32   FirstAddr;    /* first address in memory bank */   uint32   LastAddr;     /* last address (inclusive) in memory bank */} OS_MemBank_t;/*** Name:  OS_MemBankTbl**** Purpose:**  Specify ranges of all valid address ranges that can be read by normal data**  references in the code.  The ranges are defined in osplatform.h.*/OS_MemBank_t  OS_MemBankTbl [OS_MAX_MEMORY_BANKS] = {   {OS_SRAM_BANK_START_ADDRESS,    OS_SRAM_BANK_END_ADDRESS},    {OS_EEPROM1_BANK_START_ADDRESS, OS_EEPROM1_BANK_END_ADDRESS},   {OS_EEPROM2_BANK_START_ADDRESS, OS_EEPROM2_BANK_END_ADDRESS},   {OS_PROM_BANK_START_ADDRESS,    OS_PROM_BANK_END_ADDRESS},};/*** Name: OS_MemRead8**** Purpose:**         Read one byte of memory.** **** Parameters:**	Address : Address to be read**      Value8  : The address content will be copied to the location pointed by this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: OS_SUCCESS*/int32 OS_MemRead8( uint32 Address, uint8 *Value8 ) {	  (*Value8) = (uint8)*((uint8 *)Address) ;	  return(OS_SUCCESS) ;}/*** Name: OS_MemWrite8**** Purpose:**         Write one byte of memory.** **** Parameters:**	Address : Address to be written to**      Value8  : The content pointed by this argument will be copied to the address **** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS*/int32 OS_MemWrite8 ( uint32 Address, uint8 Value8 ) {  *((uint8 *)Address) = Value8;  return(OS_SUCCESS) ;	}/*** Name: OS_MemRead16**** Purpose:**         Read  2 bytes of memory.** **** Parameters:**	Address : Address to be read**      Value16 : The address content will be copied to the location pointed by **            this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **              addressing scheme. */int32 OS_MemRead16( uint32 Address, uint16 *Value16 ){  (*Value16) = (uint16)*((uint16 *)Address) ;  return(OS_SUCCESS) ;	}/*** Name: OS_MemWrite16**** Purpose:**         Write 2 byte of memory.** **** Parameters:**	Address : Address to be written to**      Value16 : The content pointed by this argument will be copied to the **                address **** Global Inputs: None**** Global Outputs: None******** Return Values: **      OS_SUCCESS**      OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **      addressing scheme. */int32 OS_MemWrite16 ( uint32 Address, uint16 Value16 ) {  *((uint16 *)Address) = Value16;  return(OS_SUCCESS) ;	}/*** Name: OS_MemRead32**** Purpose:**         Read 4 bytes of memory.** **** Parameters:**	Address : Address to be read**      Value32 : The address content will be copied to the location pointed by **                this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **      addressing scheme. */int32 OS_MemRead32( uint32 Address, uint32 *Value32 ){  (*Value32) = *((uint32 *)Address) ;  return(OS_SUCCESS) ;	}/*** Name: OS_MemWrite32**** Purpose:**         Write 4 byte of memory.** **** Parameters:**	Address : Address to be written to**      Value32 : The content pointed by this argument will be copied to the **                address **** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **              addressing scheme. */int32 OS_MemWrite32 ( uint32 Address, uint32 Value32 ) {  *((uint32 *)Address) = Value32;  return(OS_SUCCESS) ;	}/*** Name: OS_PortRead8**** Purpose:**         Read one byte of memory.** **** Parameters:**	Address : Address to be read**      Value8  : The address content will be copied to the location pointed by**                this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: OS_SUCCESS*/int32 OS_PortRead8( uint32 Address, uint8 *Value8 ) {	  (*Value8) = (uint8)*((uint8 *)Address) ;	  return(OS_SUCCESS) ;}/*** Name: OS_PortWrite8**** Purpose:**         Write one byte of memory.** **** Parameters:**	Address : Address to be written to**      Value8  : The content pointed by this argument will be copied to the **                address **** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS*/int32 OS_PortWrite8 ( uint32 Address, uint8 Value8 ) {  *((uint8 *)Address) = Value8;  return(OS_SUCCESS) ;	}/*** Name: OS_PortRead16**** Purpose:**         Read  2 bytes of memory.** **** Parameters:**	Address : Address to be read**      Value16 : The address content will be copied to the location pointed by **                this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **              addressing scheme. */int32 OS_PortRead16( uint32 Address, uint16 *Value16 ){  /* check 16 bit alignment  , check the 1st lsb */  if( Address & 0x00000001)    {      return(OS_ERROR_ADDRESS_MISALIGNED) ;    }  (*Value16) = (uint16)*((uint16 *)Address) ;  return(OS_SUCCESS) ;	}/*** Name: OS_PortWrite16**** Purpose:**         Write 2 byte of memory.** **** Parameters:**	Address : Address to be written to**      Value16 : The content pointed by this argument will be copied to the **                address **** Global Inputs: None**** Global Outputs: None******** Return Values: **      OS_SUCCESS**	OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **      addressing scheme. */int32 OS_PortWrite16 ( uint32 Address, uint16 Value16 ) {  /* check 16 bit alignment  , check the 1st lsb */  if( Address & 0x00000001)    {      return(OS_ERROR_ADDRESS_MISALIGNED) ;    }  *((uint16 *)Address) = Value16;  return(OS_SUCCESS) ;	}/*** Name: OS_PortRead32**** Purpose:**         Read 4 bytes of memory.** **** Parameters:**	Address : Address to be read**      Value32 : The address content will be copied to the location pointed by **                this argument**** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **              addressing scheme. */int32 OS_PortRead32( uint32 Address, uint32 *Value32 ){  /* check 32 bit alignment  */  if( Address & 0x00000003)    {      return(OS_ERROR_ADDRESS_MISALIGNED) ;    }  (*Value32) = *((uint32 *)Address) ;  return(OS_SUCCESS) ;	}/*** Name: OS_PortWrite32**** Purpose:**         Write 4 byte of memory.** **** Parameters:**	Address : Address to be written to**      Value32 : The content pointed by this argument will be copied to the **                address **** Global Inputs: None**** Global Outputs: None******** Return Values: **		OS_SUCCESS**		OS_ERROR_ADD_MISALIGNED The Address is not aligned to 16 bit **              addressing scheme. */int32 OS_PortWrite32 ( uint32 Address, uint32 Value32 ) {  /* check 32 bit alignment  */  if( Address & 0x00000003)    {      return(OS_ERROR_ADDRESS_MISALIGNED) ;    }  *((uint32 *)Address) = Value32;  return(OS_SUCCESS) ;	}/*** Name: OS_MemCpy**** Purpose:**	Copies 'size' byte from memory address pointed by 'src' to memory **  address pointed by ' dst' For now we are using the standard c library **  call 'memcpy' but if we find we need to make it more efficient then**  we'll implement it in assembly.**** Assumptions and Notes:**** Parameters:**	dst : pointer to an address to copy to**      src : pointer address to copy from**** Global Inputs: None**** Global Outputs: None****** Return Values: OS_SUCCESS*/int32 OS_MemCpy ( void *dst, void *src, uint32 size){  memcpy( dst, src, size);  return(OS_SUCCESS) ;} ;

⌨️ 快捷键说明

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