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

📄 qk_port.h

📁 事件驱动程序设计很好的框架
💻 H
字号:
/****************************************************************************** Product:  QK/C, port to 80x86, QK, Turbo C++ 1.01, Large memory model* Last Updated for Version: 4.0.00* Date of the Last Update:  Apr 07, 2008**                    Q u a n t u m     L e a P s*                    ---------------------------*                    innovating embedded systems** Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved.** This software may be distributed and modified under the terms of the GNU* General Public License version 2 (GPL) as published by the Free Software* Foundation and appearing in the file GPL.TXT included in the packaging of* this file. Please note that GPL Section 2[b] requires that all works based* on this software must also be made publicly available under the terms of* the GPL ("Copyleft").** Alternatively, this software may be distributed and modified under the* terms of Quantum Leaps commercial licenses, which expressly supersede* the GPL and are specifically designed for licensees interested in* retaining the proprietary status of their code.** Contact information:* Quantum Leaps Web site:  http://www.quantum-leaps.com* e-mail:                  info@quantum-leaps.com*****************************************************************************/#ifndef qk_port_h#define qk_port_h                                          /* QF critical section entry/exit *//* QF_INT_KEY_TYPE not defined */#define QF_INT_LOCK(dummy)   disable()#define QF_INT_UNLOCK(dummy) enable()                                          /* QK-specific ISR entry and exit */#define QK_ISR_ENTRY() do { \    ++QK_intNest_; \    QF_QS_ISR_ENTRY(QK_intNest_, QK_currPrio_); \    enable(); \} while (0)#define QK_ISR_EXIT() do { \    disable(); \    outportb(0x20, 0x20); \    QF_QS_ISR_EXIT(QK_intNest_, QK_currPrio_); \    --QK_intNest_; \    if (QK_intNest_ == (uint8_t)0) { \        QK_scheduleExt_(); \    } \} while (0)/* demonstration of advanced QK features: TLS and extended context switch   */typedef struct Lib1_contextTag {         /* an example of a library context */    double  x;} Lib1_context;typedef struct Lib2_contextTag {         /* an example of a library context */    double  y;} Lib2_context;typedef union FPU_contextTag {    uint32_t align;    uint8_t  x87[108];               /* the x87 FPU context takes 108-bytes */} FPU_context;typedef struct ThreadContextTag {    Lib1_context lib1;                                  /* library1 context */    Lib2_context lib2;                                  /* library2 context */    FPU_context  fpu;                                    /* the FPU context */} ThreadContext;enum QKTaskFlags {    QK_LIB1_THREAD = 0x01,    QK_LIB2_THREAD = 0x02,    QK_FPU_THREAD  = 0x04};                                                 /* QK thread-local storage */#define QK_TLS(act_) \    impure_ptr1 = &((ThreadContext *)(act_)->thread)->lib1; \    impure_ptr2 = &((ThreadContext *)(act_)->thread)->lib2extern Lib1_context * volatile impure_ptr1;extern Lib2_context * volatile impure_ptr2;                                  /* QK extended context (FPU) save/restore */#define QK_EXT_SAVE(act_)    \    if (((act_)->osObject & QK_FPU_THREAD) != 0) \        FPU_save(&((ThreadContext *)(act_)->thread)->fpu)#define QK_EXT_RESTORE(act_) \    if (((act_)->osObject & QK_FPU_THREAD) != 0) \        FPU_restore(&((ThreadContext *)(act_)->thread)->fpu)void FPU_save(FPU_context *fpu);                     /* defined in assembly */void FPU_restore(FPU_context *fpu);                  /* defined in assembly */#include <dos.h>                                              /* see NOTE01 */#undef outportb /*don't use the macro because it has a bug in Turbo C++ 1.01*/#include "qk.h"                 /* QK platform-independent public interface */#include "qf.h"                 /* QF platform-independent public interface */#endif                                                         /* qk_port_h *//****************************************************************************** NOTE01:* The QK port on x86 is not a pure play, but rather, QK is based in this* case on DOS.*/

⌨️ 快捷键说明

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