platform.h
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C头文件 代码 · 共 251 行
H
251 行
/******************************************************************************
* File: platform.h
* Author: Naresh Gupta (nkgupta@hotmail.com)
* Date: Wednesday Feb 17, 1999
* Organization: Hitachi Semiconductor America Inc.
* Purpose: Will contain all platform specific stuff.
*
* Copyright (c) 1999 Hitachi Semiconductor America Inc.
******************************************************************************/
/******************************************************************************
* Important Note:-
* ===============
*
* To properly view this file, you need to set tabstop=4 in your editor
*****************************************************************************/
#ifndef _PLATFORM_H
#define _PLATFORM_H
/*****************************************************************************
* User Modifiable Stuff
****************************************************************************/
/*
* Define REG_ACCESS_WAIT if you want to wait for some time on every register
* access.
*/
#define REG_ACCESS_WAIT
/*
* Define STAND_ALONE if you want to test the debug monitor on NT before running
* it on SH.
*/
// #define STAND_ALONE
/*
* DEBUG should ideally be defined in Makefile. The definition of various
* values of DEBUG is given below. (search for DEB_ )
*/
// #define DEBUG 0xff // 0x20
/*****************************************************************************
* End of User Modifiable Stuff
****************************************************************************/
/* Additional data types */
typedef unsigned char * ADDR;
typedef unsigned (*func_ptr_t)();
typedef unsigned long SIZE_T;
//
// this is likely redefining these, but that is OK because they are the same
// as the windef ones (and if they are not we *really* want to get an error
// becasue someone maliciously changed windef.h
//
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef short SHORT;
typedef unsigned short USHORT;
typedef unsigned long DWORD;
typedef long LONG;
typedef unsigned long ULONG;
typedef volatile BYTE *PVBYTE;
typedef volatile SHORT *PVSHORT;
typedef volatile USHORT *PVUSHORT;
typedef volatile ULONG *PVULONG;
typedef volatile DWORD *PVDWORD;
#ifndef NULL
#define NULL (VOID *) 0
#endif // NULL
#define printf OutputFormatString
/******************************************************************************
* Various platforms that this software would support.
* For each of these platforms, the respective header file is included
*****************************************************************************/
#define PLATFORM_S1 1
#define PLATFORM_ASPEN 2
#define PLATFORM_KEYWEST 3
#define PLATFORM_BIGSUR 4
// Appropriate include files for each of the platforms.
#if (SH_PLATFORM == PLATFORM_ASPEN)
# include "aspen.h"
#elif (SH_PLATFORM == PLATFORM_BIGSUR)
# include "bigsur.h"
#elif (SH_PLATFORM == PLATFORM_S1)
# define ALPHA_LED 0xA3c60000
# define SMC_BASE 0xA6800000
// Dummy values for S1 platform to get the debugger up and running.
# define PAR_CONTROL_REG 0xA4020000
# define PAR_DATA_REG 0xA4020000
# define FLASH_SIZE 0x1000
# include "s1.h"
#endif (SH_PLATFORM == PLATFORM_ASPEN)
/******************************************************************************
* convenience macros used in every driver
*****************************************************************************/
#ifdef REG_ACCESS_WAIT
__inline static int RegWait()
{
int i;
for(i=0;i<20;i++);
return i;
}
#define REG_WAIT RegWait()
/* Functions for Reading and Writing Memory/Registers. */
#define READ_REGISTER_ULONG(reg) (REG_WAIT,(*(volatile unsigned long * const)(reg)))
#define WRITE_REGISTER_ULONG(reg, val) (REG_WAIT,(*(volatile unsigned long * const)(reg)) = (val))
#define READ_REGISTER_USHORT(reg) (REG_WAIT,(*(volatile unsigned short * const)(reg)))
#define WRITE_REGISTER_USHORT(reg, val) (REG_WAIT,(*(volatile unsigned short * const)(reg)) = (val))
#define READ_REGISTER_UCHAR(reg) (REG_WAIT,(*(volatile unsigned char * const)(reg)))
#define WRITE_REGISTER_UCHAR(reg, val) (REG_WAIT,(*(volatile unsigned char * const)(reg)) = (val))
#define MASK_REGISTER_ULONG(reg, val, mask) \
WRITE_REGISTER_ULONG((reg),(READ_REGISTER_ULONG(reg) & (mask)) | (val) )
#define MASK_REGISTER_USHORT(reg, val, mask) \
WRITE_REGISTER_USHORT((reg),(READ_REGISTER_USHORT(reg) & (mask)) | (val) )
#define MASK_REGISTER_UCHAR(reg, val, mask) \
WRITE_REGISTER_UCHAR((reg),(READ_REGISTER_UCHAR(reg) & (mask)) | (val) )
#else REG_ACCESS_WAIT
#define READ_REGISTER_ULONG(reg) (*(volatile unsigned long * const)(reg))
#define WRITE_REGISTER_ULONG(reg, val) (*(volatile unsigned long * const)(reg)) = (val)
#define READ_REGISTER_USHORT(reg) (*(volatile unsigned short * const)(reg))
#define WRITE_REGISTER_USHORT(reg, val) (*(volatile unsigned short * const)(reg)) = (val)
#define READ_REGISTER_UCHAR(reg) (*(volatile unsigned char * const)(reg))
#define WRITE_REGISTER_UCHAR(reg, val) (*(volatile unsigned char * const)(reg)) = (val)
#define MASK_REGISTER_ULONG(reg, val, mask) \
WRITE_REGISTER_ULONG((reg),(READ_REGISTER_ULONG(reg) & (mask)) | (val) )
#define MASK_REGISTER_USHORT(reg, val, mask) \
WRITE_REGISTER_USHORT((reg),(READ_REGISTER_USHORT(reg) & (mask)) | (val) )
#define MASK_REGISTER_UCHAR(reg, val, mask) \
WRITE_REGISTER_UCHAR((reg),(READ_REGISTER_UCHAR(reg) & (mask)) | (val) )
#endif REG_ACCESS_WAIT
// Be careful to do pointer arithmetic as chars.
#define REG32(base, id) (*((PVULONG)(((char*)(base))+(id))))
#define REG16(base, id) (*((PVUSHORT)(((char*)(base))+(id))))
#define REG8(base, id) (*((PVBYTE)(((char*)(base))+(id))))
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* MACRO : InlineDelay
* DESCRIPTION : tight assembly loop for a busy wait
* INPUTS : DWORD dwLoopCount - the number of iterations to loop
* OUTPUTS : void
* DESIGN NOTES :
* CAUTIONS : INLINE ASSEMBLY - different compilers may require changing!
* (R4 is passed as the parameter)
* Thie delay is proportional to REAL time (with some overhead)!
* defining the __asm 'function' may effect older code
* (a very small chance, but possible)
* A task switch will render the delay time invalid!
******************************************************************************/
void __asm(const char *, ...);
#define InlineBusyWait( dwLoopCount ) \
__asm( " tst r4,r4 ; delay already zero?\n" \
"dloop: bf/s dloop ; delayed slot branch (2/1clocks)\n" \
" dt r4 ; decrement count & test for 0 (1 clock)" \
,dwLoopCount \
)
#define Delay( dwMicroSeconds ) \
BusyWait(AdjustMicroSecondsToLoopCount( dwMicroSeconds ))
DWORD AdjustMicroSecondsToLoopCount( DWORD dwMicroSeconds );
DWORD BusyWait( DWORD dwLoopCount );
#ifdef __cplusplus
}
#endif
#ifdef DEBUG
# define DEB_MSGS 1
#else DEBUG
# define DEB_MSGS 0
#endif DEBUG
// What are the debugging messages that you want to see.
// 0: No message printed
// 1: message printed
#define DEB_FLOW (DEB_MSGS & 0x01) // Flow of control
#define DEB_INFO (DEB_MSGS & 0x02) // General information messages
#define DEB_ERR (DEB_MSGS & 0x04) // Error messages.
#define DEB_PPSH (DEB_MSGS & 0x08) // PPSH messages.
#define DEB_KBD (DEB_MSGS & 0x10)
#define DEB_ETH (DEB_MSGS & 0x20) // Ethernet Messages
#ifdef DEBUG
# define WriteDbgOutput(a,b) { if(a) OutputFormatString b; }
#else
# define WriteDbgOutput(a,b) // Do nothing if DEBUG is not defined.
#endif
#ifdef STAND_ALONE
# define WriteOutput printf
# define OutputFormatString printf
extern int printf();
extern char *gets();
char Buf[512]; // Dummy buffer of 512 bytes to do read/write operations.
#else
// NKCH: Check this out. This was giving a problem while compiling the
// display driver. So i removed this declaration. Anyway this should come
// from windows.h
// int __cdecl OutputFormatString(const char *, ...);
# define WriteOutput OutputFormatString
#endif
/* Various format for printf. */
/* This was needed because Windows CE version of printf gives me a different
* Set of format strings than those given by standard C compiler.
*/
#ifdef STAND_ALONE
# define F_L "%08x"
# define F_S "%04x"
# define F_B "%02x"
#else STAND_ALONE
# define F_L "%X"
# define F_S "%H"
# define F_B "%B"
#endif STAND_ALONE
// Define PUT_PCI_DELAYS if you want to put a delay between every two PCI
// IO/Memory transactions.
// #define PUT_PCI_DELAY
#endif _PLATFORM_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?