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

📄 hal_arch.h

📁 eCos操作系统源码
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef CYGONCE_HAL_ARCH_H#define CYGONCE_HAL_ARCH_H//==========================================================================////      hal_arch.h////      Architecture specific abstractions////==========================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):    nickg, gthomas, hmt// Contributors: nickg, gthomas, hmt// Date:         1999-02-20// Purpose:      Define architecture abstractions// Usage:        #include <cyg/hal/hal_arch.h>// //####DESCRIPTIONEND####////==========================================================================#include <pkgconf/hal.h>#include <pkgconf/hal_sparc.h>#include <cyg/infra/cyg_type.h>#include <cyg/hal/hal_intr.h>           // HAL_DISABLE_INTERRUPTS//--------------------------------------------------------------------------// Processor saved states://// All these structures must be doubleword (64 bit) aligned.// The code that creates them on the stack will ensure this is so.#define HAL_THREAD_CONTEXT_GLOBAL_BASE 0#define HAL_THREAD_CONTEXT_OUT_BASE    8#define HAL_THREAD_CONTEXT_LOCAL_BASE 16#define HAL_THREAD_CONTEXT_IN_BASE    24typedef struct {    // this is the save structure found at *(stack_ptr) always, note that    // i[6] is the frame pointer is the previous stack pointer, and    // o[6] is the stack pointer is the next frame pointer,    // so they form a linked list back up the call stack.    cyg_uint32  l[8];                                   /* Locals r16-r23 */    cyg_uint32  i[8];                                   /* Ins    r24-r31 */} HAL_SavedWindow;typedef struct {    // Window save at stack pointer    HAL_SavedWindow li;//16    // This is the rest of the save state:    //   NOTE: g[0] is used for the CWP, for %g0 == 0.  Also note that the    //   assembler routines must load/store it in the right order.    cyg_uint32  g[8] ;                                  /* Globals r0- r7 */    cyg_uint32  o[8] ;                                  /* Outs    r8-r15 *///32 words in size// There is no need to save any other state; for example, condition codes,// the PC and NextPC, and Y, are preserved in local registers in the trap// handling window and so preserved in the caller stack frame as viewed// from an ISR.  Note that the VSR is jumped to with those locals being set// up (and Y in situ), and it must preserve them itself before calling any// subsequent handlers (ISRs).} HAL_SavedRegisters;typedef struct {    // Window save at stack pointer    HAL_SavedWindow li;    cyg_uint32      composite_return_ptr;          /* structure returns */    cyg_uint32      spill_args[6];                 /* for callee to store */    cyg_uint32      spare;                         /* keep this 64-bits   */} HAL_FrameStructure;//--------------------------------------------------------------------------// Exception handling function.// This function is defined by the kernel according to this prototype. It is// invoked from the HAL to deal with any CPU exceptions that the HAL does// not want to deal with itself. It usually invokes the kernel's exception// delivery mechanism.externC void cyg_hal_deliver_exception( CYG_WORD code, CYG_ADDRWORD data );//--------------------------------------------------------------------------// Bit manipulation macros#ifndef CYGPKG_HAL_SPARC_SCAN/* Most sparc's does not have 'scan' instruction */externC cyg_uint32 hal_lsbit_index(cyg_uint32 mask);externC cyg_uint32 hal_msbit_index(cyg_uint32 mask);#define HAL_LSBIT_INDEX(index, mask) index = hal_lsbit_index(mask);#define HAL_MSBIT_INDEX(index, mask) index = hal_msbit_index(mask);#else#define HAL_LSBIT_INDEX(index, mask)            \    CYG_MACRO_START                             \    asm volatile (                              \        "scan   %1, 0, %%l7;"                   \        "mov    31, %0;"                        \        "sub    %0, %%l7, %0"                   \        : "=r"(index)                           \        : "r"(mask & ~(mask-1))                 \        : "l7"                                  \        );                                      \CYG_MACRO_END#define HAL_MSBIT_INDEX(index, mask)            \    CYG_MACRO_START                             \    asm volatile (                              \        "scan   %1, 0, %%l7;"                   \        "mov    31, %0;"                        \        "sub    %0, %%l7, %0"                   \        : "=r"(index)                           \        : "r"(mask)                             \        : "l7"                                  \        );                                      \CYG_MACRO_END#endif//--------------------------------------------------------------------------// Context Initialization// Initialize the context of a thread.// Arguments:// _sparg_ name of variable containing current sp, will be written with new sp// _thread_ thread object address, passed as argument to entry point// _entry_ entry point address.// _id_ bit pattern used in initializing registers, for debugging.externC CYG_ADDRESShal_thread_init_context(  CYG_WORD sparg,                          CYG_WORD thread,                          CYG_WORD entry,                          CYG_WORD id ); #define HAL_THREAD_INIT_CONTEXT( _sparg_, _thread_, _entry_, _id_ )         \CYG_MACRO_START                                                             \    _sparg_ = hal_thread_init_context( (CYG_WORD)(_sparg_),                 \                                       (CYG_WORD)(_thread_),                \                                       (CYG_WORD)(_entry_),                 \                                       (CYG_WORD)(_id_) );                  \CYG_MACRO_END//---------------------------------------------------------------------------// Context switch macros.// The arguments are pointers to locations where the stack pointer// of the current thread is to be stored, and from where the sp of the// next thread is to be fetched.

⌨️ 快捷键说明

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