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

📄 exception.h

📁 浙江大学的悟空嵌入式系统模拟器
💻 H
字号:
/**
 *  Copyright (c) 2005 Zhejiang University, P.R.China
 *
 *  This program 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 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

///==================================================
/**
 * @file        Exception.h
 * @brief       Exceptinon routines
 * @author      Chenfeng Zhou <ini_autumn@163.com> 
 *
 * Created    : <2005-03-07 19:50:41 by Cheney Chow>
 * Last update: <2005-03-07 19:59:13 by Cheney Chow>
 *
 * $Id: Exception.h,v 1.1 2005/06/16 06:01:44 qilj Exp $
 */
///==================================================

#ifndef _PPC_EXCEPTION_H_
#define _PPC_EXCEPTION_H_

#include "Utils/Singleton.h"
#include "Types.h"
#include "Exception_Handler.h"


namespace PPC
{
    
	class Exception_Handler;

    class Exception
    {
    public:
        typedef enum {
			EXC_DSI = 0,
			EXC_ISI,
			EXC_DEC,
			EXC_EXT_INT,
            EXC_SC,
			EXC_NO_FPU,
			EXC_PROGRAM,
			EXC_FLOAT_ASSIST,
			EXC_MACHINE_CHECK,
			EXC_TRACE,
			EXC_INSTR_TLB,
			EXC_DATA_TLB,
            EXC_NR
        } Exception_Type;

		//! PPC7xx have fixed interupt offset;
		typedef enum {
			VEC_DSI = 0x00300,
			VEC_ISI = 0x00400,
			VEC_DEC = 0x900/*0x6041e80x1000425c*/,
			VEC_EXT_INT = 0x00500,
			VEC_SC = 0xc00/*0x100043e4*/,
			VEC_NO_FPU = 0x00800,
			VEC_PROGRAM = 0x00700,
			VEC_FLOAT_ASSIST = 0x00e00,
			VEC_MACHINE_CHECK = 0x00200,
			VEC_TRACE = 0x00d00
		} Exception_Vector;

		static const int EXC_PROGRAM_PRIV = 1 << 18;
		static const int EXC_PROGRAM_TRAP = 1 << 17;
		static const int EXC_PROGRAM_NEXT = 1 << 16;

    public:
        Exception ();
        ~Exception () {}

		void handle (Exception::Exception_Type type, PPC_u32 flag = 0, PPC_u32 a = 0)
		{
			exception_handler_table_[type]->handle(flag, a);
		}

		void pend_exception (size_t exception_type);

		void handle_pending_exception ();

    private:
        static Exception_Handler *exception_handler_table_[EXC_NR];

		bool exception_pending_;
		std::bitset<EXC_NR> exception_flags_;
    };

	typedef PPC_Singleton<Exception> Exception_Mgr;


} // namespace PPC

#endif  // _PPC_EXCEPTION_H_

⌨️ 快捷键说明

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