📄 mk_cpu.c
字号:
/*+MHDR*/
/*
# clearcase: CmicroRel2.3
+------------------------------------------------------------------------------+
| Modulname : MK_CPU.C |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This module is a template for functions, which are to be filled up |
| by the user of the Cmicro Kernel. |
| |
| 1.Character read / write on hardware / OS-level |
| xmk_PutString () Unblocking function to write a string to display. |
| Called within this module only (xmk_printf). |
| xmk_GetChar () Unblocking Character read function. Used by the |
| Cmicro Tester in some cases. |
| xmk_TermInit () Terminal initialization |
| xmk_TermDeinit () Terminal deinitialization |
| xmk_printf () Same as usual printf known from ANSI C compiler. |
| Can be used if C compiler does not support printf |
| or sprintf function. Used by the Cmicro Tester in |
| some cases. |
| |
| Cmicro Tester |
| ! |
| calls |
| ! |
| V |
| xmk_printf |
| ! |
| calls |
| ! |
| V |
| xmk_PutString |
| |
| 2.Functions for dynamic memory handling. |
| This is an intermediate layer to the compiler function library |
| The following functions exists |
| xAlloc () Used for xAlloc_SDL_Charstring |
| xFree () Used for xFree_SDL_Charstring |
| xAlloc_SDL_Charstring () Dynamic allocation of SDL Charstrings |
| xFree_SDL_Charstring () Release of dynamic allocated Charstrings |
| xAlloc_SDL_Bit_String () Dynamic allocation of SDL Bitstrings |
| xFree_SDL_Bit_String () Release of dynamic allocated Bitstrings |
| |
| |
+------------------------------------------------------------------------------+
*/
/*-MHDR*/
/*
+------------------------------------------------------------------------------+
| |
| Copyright by Telelogic AB 1993 - 1998 |
| Copyright by S&P Media GmbH Germany 1993 - 1998 |
| |
| This Program is owned by Telelogic and is protected by national |
| copyright laws and international copyright treaties. Telelogic |
| grants you the right to use this Program on one computer or in |
| one local computer network at any one time. |
| Under this License you may only modify the source code for the purpose |
| of adapting it to your environment. You must reproduce and include |
| any copyright and trademark notices on all copies of the source code. |
| You may not use, copy, merge, modify or transfer the Program except as |
| provided in this License. |
| Telelogic does not warrant that the Program will meet your |
| requirements or that the operation of the Program will be |
| uninterrupted and error free. You are solely responsible that the |
| selection of the Program and the modification of the source code |
| will achieve your intended results and that the results are actually |
| obtained. |
| |
+------------------------------------------------------------------------------+
*/
#ifndef __MK_CPU_C_
#define __MK_CPU_C_
/*+IMPORT*/
/*==================== I M P O R T =========================================*/
#include "ml_typw.h"
#ifdef XMK_UNIX
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#endif
#if defined(XMK_UNIX)
#include <varargs.h>
#endif
#if defined(BORLAND_C)
#include <stdarg.h>
#endif
#if defined(MICROSOFT_C)
#include <stdarg.h>
#endif
#if defined (LOG_INTERNAL)
#include "aapiclnt.h"
#endif
#include "cmmnrsrc.h"
/*============================================================================*/
/*-IMPORT*/
/*+MGG*/
/*==================== V A L U E S O F T H I S M O D U L E =============*/
/*-------------------- Constants, Macros ----------------------------------*/
#ifdef XSYSID
/*
** CAUTION !
** ============
** This module cannot be used when partitioning is used. The reason
** for this is that the functions of this module operate on global
** variables and partitioned systems may preempt each other when
** an Real Time Operating System is used.
** However, users can use this module as a basis for implementing
** their own terminal and memory management functions.
*/
#error "ERROR_in_mk_cpu_c_Module_cannot_be_used_for_Partitioning"
#endif /* ... XSYSID */
#ifdef P
#undef P
#endif
/*-------------------- Typedefinitions ----------------------------------*/
#define xmk_exit exit
/*-------------------- Functions -----------------------------------------*/
#ifdef XMK_UNIX
static void sig_catch(int);
#endif
/*-------------------- Variables -----------------------------------------*/
#ifdef XMK_UNIX
struct termios tty_buf, xmk_OldTTYSettings;
#endif
/*============================================================================*/
/*-MGG*/
#ifndef XMK_USE_NO_ERR_CHECK
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_PutString |
+------------------------------------------------------------------------------+
| |
| Description : |
| A template for how to print out a character string, terminated with 0. |
| |
| CAUTION |
| ========== |
| The function must return immediately, i.e.may not be blocking on the |
| output device. If the user does not care about this restriction, the correct|
| function of other program parts cannot be guaranteed. |
| |
| Parameter : char * Param1 Pointer to string, terminated with 0 |
| int length string length |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
void xmk_PutString ( char * Param1 )
#else
void xmk_PutString ( Param1 )
char *Param1;
#endif
/*-FDEF E*/
{
/* Added by GBU,990516, to get rid of IAR warning */
Param1 = Param1;
/*
** NEVER CALL xmk_printf here !!!!!
** NEITHER USE XMK_PRINTF macros !!!!!
*/
#if defined(XMK_UNIX)
(void)fprintf (stdout,"%s", Param1);
#elif defined(BORLAND_C)
#ifdef XMK_WINDOWS
(void)fprintf (stdout,"%s", Param1);
#else
/* Non Console applications do not support fprintf in Windows !!! */
xmk_PutString_is_not_filled_yet = 0;
#endif
#elif defined(MICROSOFT_C)
#ifdef XMK_WINDOWS
(void)fprintf (stdout,"%s", Param1);
#else
/* Non Console applications do not support fprintf in Windows !!! */
xmk_PutString_is_not_filled_yet = 0;
#endif
#else
#if defined (LOG_INTERNAL)
CLNTa_log(0, 0, "SDL kernel: %s\n", Param1);
#endif
#endif
return ;
}
#endif
#ifndef XMK_USE_NO_ERR_CHECK
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_GetChar |
+------------------------------------------------------------------------------+
| |
| Description : |
| A template to ask the OS, if the user has typed any key and which one. |
| If the user has pressed no key, the function returns with EOF. |
| If any key was pressed, the function returns with the key value. |
| |
| CAUTION |
| ========== |
| The function must return immediately, i.e.may not be blocking on the |
| input device. If the user does not care about this restriction, the correct |
| function of other program parts cannot be guaranteed. |
| |
| |
| Parameter : - |
| |
| Return : int - character or XMK_EOF |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
int xmk_GetChar ( void )
#else
int xmk_GetChar ( )
#endif
/*-FDEF E*/
{
#ifdef XMK_UNIX
int cnt;
static char c;
#endif
#if defined(BORLAND_C) || defined(MICROSOFT_C)
int c;
#endif
#ifdef XMK_ADD_PRINTF_CPU
XMK_FUNCTION("xmk_GetChar");
#endif
#if defined(XMK_UNIX)
cnt = read ( STDIN_FILENO , (void *) &c, 1 );
if (cnt < 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -