📄 nosys3s.h
字号:
/******************************************************************************
* NORTi3 system definitions *
* *
* Copyright (c) 1995-2000, MiSPO Co., Ltd. *
* All rights reserved. *
* *
* 03/Apr/2000 *
* 30/Oct/2001 The semicolon of extern "C" { ... }; is deleted. *
******************************************************************************/
#ifndef NOSYS3S_H
#define NOSYS3S_H
#ifdef __cplusplus
extern "C" {
#endif
/************************************/
/* CPU-dependent definitions */
/************************************/
/* 8086 context */
#if defined(CPU_86)
typedef struct
{ int stkhqq;
int es;
int ds;
int di;
int si;
int bp;
int sp;
#if (SIZEOF_PTR==2)
VP ptr; /* BX */
int dx;
#else
VP ptr; /* DX:BX */
#endif
int ptn; /* CX */
int ercd; /* AX */
int filler[2];
FP pc; /* CS:IP */
int flag;
} T_CTX;
#define syssta_sub() IMASK = 0
#define unl_cpu_sub() IMASK = 0
#define chg_ims_sub(imask) IMASK = imask
#define ref_sys_sub(imask) imask
#define ref_ims_sub(ims) (UINT)(ims != 0)
#define cre_tsk_sub() stksz -= sizeof(T_CTX) + 6
#if (SIZEOF_PTR == 4)
#define sta_tsk_sub() \
ctx = (T_CTX *)((B *)ctx - 6); \
*((int *)(ctx + 1) + 2) = stacd; \
stktop = (B *)tcb->isp - tcb->ctsk->stksz; \
ctx->stkhqq = (int)((UW)stktop); \
ctx->es = ctx->ds = IDS; \
ctx->flag = IFLAG;
#else
#define sta_tsk_sub() \
ctx = (T_CTX *)((B *)ctx - 6); \
*((int *)(ctx + 1) + 2) = stacd; \
stktop = (B *)tcb->isp - tcb->ctsk->stksz; \
ctx->stkhqq = (int)stktop; \
ctx->es = ctx->ds = IDS; \
ctx->flag = IFLAG;
#endif
#define c_sysini_sub() \
if (pSTKMEM != NULL) \
{ stktop = (B *)pSTKMEM; \
sp = stktop + CFG.stkmsz; \
} \
else \
{ sp -= CFG.tstksz; \
} \
ISP = sp; \
i = CFG.istksz; \
while (i-- != 0) \
*--sp = 0x00;
/* other CPU */
#elif defined(CPU_68K)
#include "n3r68k.h"
#elif defined(CPU_H83)
#include "n3rh83.h"
#elif defined(CPU_H85)
#include "n3rh85.h"
#elif defined(CPU_H8S)
#include "n3rh8s.h"
#elif defined(CPU_SH)
#include "n3rsh.h"
#elif defined(CPU_V850)
#include "n3rv850.h"
#elif defined(CPU_PPC)
#include "n3rppc.h"
#elif (defined(CPU_ARM)||defined(CPU_THUMB))
#include "n3rarm.h"
#elif defined(CPU_KC160)
#include "n3r160.h"
#endif
/************************************/
/* control block definitions */
/************************************/
/* OS Memory Header */
typedef struct t_mem
{ struct t_mem *next;
unsigned size;
} T_MEM;
#if defined(CPU_86)
typedef struct t_nmem
{ struct t_nmem NEAR *next;
unsigned size;
} T_NMEM;
#else
#define T_NMEM T_MEM
#endif
/* Task Control Block */
typedef struct t_tcb
{ T_CTX *sp;
B pri;
UB sts;
UB nid;
UB pid;
B wup;
B sus;
UB ntm;
UB ptm;
DLYTIME tmo;
UB NEAR *que;
T_CTX *stk;
const T_CTSK *ctsk;
} T_TCB;
/* Cyclic Handler Control Block */
#if (SIZEOF_INT == 1)
typedef struct t_cyc
{ const T_DCYC *dcyc;
UB ntm;
UB ptm;
H utime;
UH ltime;
UINT cycact;
} T_CYC;
#else
typedef struct t_cyc
{ const T_DCYC *dcyc;
UB ntm;
UB ptm;
H utime;
UW ltime;
UINT cycact;
} T_CYC;
#endif
/* Alarm Handler Control Block */
#if (SIZEOF_INT == 1)
typedef struct t_alm
{ const T_DALM *dalm;
UB ntm;
UB ptm;
H utime;
UH ltime;
} T_ALM;
#else
typedef struct t_alm
{ const T_DALM *dalm;
UB ntm;
UB ptm;
H utime;
UW ltime;
} T_ALM;
#endif
/* Semaphore Control Block */
typedef struct t_sem
{ B cnt;
UB que[1];
} T_SEM;
/* EventFlag Control Block */
typedef struct t_flg
{ UINT ptn;
UB que;
} T_FLG;
/* Mailbox Control Block */
typedef struct t_mbx
{ T_MSG *top;
T_MSG *end;
UB que[1];
} T_MBX;
/* MessageBuffer Control Block */
typedef struct t_mbf
{ B *buf;
UH putp;
UH getp;
UH allsz;
UH frsz;
UH maxsz;
UB stsk;
UB wtsk[1];
} T_MBF;
typedef struct t_mbfctx
{ VP buf;
int *p_size;
} T_MBFCTX;
/* Fixed-size MemoryPool Control Block */
typedef struct t_mpf
{ B *top;
B *allad;
UH cnt;
UB que[1];
} T_MPF;
/************************************/
/* common constants */
/************************************/
/* T_TCB sts */
#define S_CLR 0x01 /* EventFlag clear specification */
#define S_ORW 0x02 /* EventFlag OR wait */
#define S_TMO 0x04 /* WAIT with timeout */
#define S_DMT 0x00 /* DORMANT */
#define S_RDY 0x10 /* RUN,READY */
#define S_SLP 0x20 /* wait due to slp_tsk or tslp_tsk */
#define S_DLY 0x30 /* wait due to dly_tsk */
#define S_RDV 0x40 /* wait for rendezvous completion */
#define S_FLG 0x50 /* wait due to wai_flg or twai_flg */
#define S_SMB 0x60 /* wait due to snd_mbf or tsnd_mbf */
#define S_CAL 0x70 /* wait for rendezvous call */
#define S_ACP 0x80 /* wait for rendezvous accept */
#define S_SEM 0x90 /* wait due to wai_sem or twai_sem */
#define S_MBX 0xa0 /* wait due to rcv_msg or trcv_msg */
#define S_MBF 0xb0 /* wait due to rcv_mbf or trcv_mbf */
#define S_MPL 0xc0 /* wait due to get_blk or tget_blk */
#define S_MPF 0xd0 /* wait due to get_blf or tget_blf */
/* control block */
extern T_TCB NEAR cdecl _TCB[];
extern T_SEM NEAR cdecl _SEM[];
extern T_FLG NEAR cdecl _FLG[];
extern T_MBX NEAR cdecl _MBX[];
extern T_MBF NEAR cdecl _MBF[];
extern T_MPF NEAR cdecl _MPF[];
extern T_CYC NEAR cdecl _CYC[];
extern T_ALM NEAR cdecl _ALM[];
#define TCB (_TCB-1)
#define SEM (_SEM-1)
#define FLG (_FLG-1)
#define MBX (_MBX-1)
#define MBF (_MBF-1)
#define MPF (_MPF-1)
#define CYC (_CYC-1)
#define ALM (_ALM-1)
/* limit */
#define WUPCNT_MAX 255
#define SUSCNT_MAX 255
#define SEMCNT_MAX 255
/* kernel constant data */
extern const T_RCFG cdecl CFG;
extern const T_VER FAR cdecl _NORTI_VER;
extern const T_VER FAR * const cdecl norti_ver;
extern int NEAR * const cdecl pSYSMEM;
extern int * const cdecl pMPLMEM;
extern int * const cdecl pSTKMEM;
/* kernel data */
extern SYSTIME NEAR cdecl SYSCK;
#if (SIZEOF_INT == 1)
extern UB NEAR IMASK;
#elif (defined(SH3)||defined(SH3E)||defined(SH4)||defined(CPU_R3000)||defined(CPU_PPC))
extern UW NEAR cdecl IMASK;
#else
extern UH NEAR cdecl IMASK;
#endif
extern UH NEAR cdecl IDLCNT;
extern ER NEAR cdecl SYSER;
extern volatile B NEAR cdecl NOWPRI;
extern volatile B NEAR cdecl DELAY;
extern volatile B NEAR cdecl INEST;
extern volatile B NEAR cdecl DDISP;
extern volatile B NEAR cdecl SDISP;
extern volatile B NEAR cdecl TMREQ;
extern UB NEAR cdecl TMQMS;
extern UB NEAR cdecl CHQMS;
extern UB NEAR cdecl AHQMS;
extern UINT NEAR cdecl CTXPTN;
extern VP NEAR cdecl CTXPTR;
extern B FAR * NEAR cdecl ISP;
extern T_NMEM NEAR * NEAR cdecl SYSTOP;
extern T_MEM * NEAR cdecl MPLTOP;
extern T_MEM * NEAR cdecl STKTOP;
#ifndef NOCFG3_H
extern UB NEAR cdecl RDQ[];
extern UB NEAR cdecl TMQ[];
extern UB NEAR cdecl CHQ[];
extern UB NEAR cdecl AHQ[];
#endif
#ifdef __cplusplus
}
#endif
#endif /* NOSYS3S_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -