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

📄 type.h

📁 一个MIPS虚拟机的源码
💻 H
字号:
#ifndef TYPE_H
#define TYPE_H



/*Hardcode. This is true for IA-32*/
#define SIZEOF_CHAR 1
#define SIZEOFSHORT 2
#define SIZEOFLONG 4



#if SIZEOFLONG == 4
typedef	unsigned long UINT32;
typedef long	INT32;
#endif

#if SIZEOFSHORT ==2
typedef unsigned short UINT16;
typedef short INT16;
#endif

#if SIZEOF_CHAR == 1
typedef unsigned char UINT8;
typedef char INT8;
#endif

typedef int boolean;



struct options_struct
{
	char * rom_file_path;
	boolean debug_mode; //is in debug mode
	char display[100];
	char keybord[100];
};
typedef struct options_struct  OPTIONS;



struct tlb_entry_struct
{	
	UINT32 entryhi;
	UINT32 entrylo;
	
};
typedef struct tlb_entry_struct TLB_ENTRY;

struct cache_struct
{
	UINT32 cache_line;
	UINT32 tag;
	UINT32 flag;  //bit 0:valid. other bits are not used.
	
} ;
typedef struct cache_struct CACHE;

enum delay_state_enum{DELAYING,NORMAL,DELAYSLOT};
typedef enum delay_state_enum DELAY_STATE;

enum tlb_miss_enum{KERNEL,USER};
typedef enum tlb_miss_enum TLB_MISS;



struct interrupt_line_struct
{
	UINT32 interrupt_word;
};
typedef struct interrupt_line_struct interrupt_line_type;

struct device_struct
{
	interrupt_line_type  interrupt_line;
	UINT32 control_reg;
	UINT32 data_reg;
	char device_name[255];
};
typedef struct device_struct device_type;






#define INTERRUPT_LINE_NUMBER  8
typedef struct interrupt_controller_struct
{
	interrupt_line_type interrupt_line[INTERRUPT_LINE_NUMBER];
	device_type device[INTERRUPT_LINE_NUMBER];
	int connected_devices;
} interrupt_controller_type;


struct console_struct
{

	device_type keybord;
	int keybord_fd;
	
	device_type display;
	int  display_fd;
	
};
typedef struct console_struct console_type;

enum task_category_enum{READY_KEYBORD,READY_DISPLAY};
struct task_struct
{
	UINT32 left_nsecond;
	enum task_category_enum  task_category;
	boolean is_processed;
};
typedef struct task_struct task_type;


/*for debug*/
#define VADDR 0
#define PHYADDR 1
typedef struct break_point_node_struct
{
	UINT32 addr;
	int addr_type;  
	struct break_point_node_struct * next;
	
}break_point_node;

#define STEP 1
#define RUN 2
#define DEBUG 3
typedef  struct debug_struct
{
	break_point_node * break_point_header;
	break_point_node * break_point_tail;
	int break_point_number;
	int current_mode;  //step or run
}debug_type;

#endif

⌨️ 快捷键说明

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