Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Assembly.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: SS_Assembly.cc
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
//
// The above named program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License version 2 as published by the Free Software Foundation.
//
// The above named 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 work; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// ========== Copyright Header End ============================================
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "SS_Strand.h"
int main()
{
SS_Strand* s = 0;
SS_Instr* i = 0;
if (ptr_ofs(SS_Strand,irf) != 0)
{
fprintf(stderr,"SS_Strand::irf needs to be first member of SS_Strand (no virtuals allowed)\n");
exit(-1);
}
printf("#ifndef __SS_Assembly_h__\n");
printf("#define __SS_Assembly_h__\n");
printf("\n");
printf("#ifdef ARCH_V9\n");
printf("#define ldptr ldx\n");
printf("#define PTR_SIZE 8\n");
printf("#define PTR_SIZE_BITS 3\n");
printf("#else\n");
printf("#define ldptr ld\n");
printf("#define PTR_SIZE 4\n");
printf("#define PTR_SIZE_BITS 2\n");
printf("#endif\n");
printf("\n");
printf("#define R_PC %%o0\n");
printf("#define R_NPC %%o1\n");
printf("\n");
printf("#define S_PTR %%o2\n");
printf("#define S_PC %d\n",ptr_ofs(SS_Strand,pc));
printf("#define S_NPC %d\n",ptr_ofs(SS_Strand,npc));
printf("#define S_CCR %d\n",ptr_ofs(SS_Strand,ccr));
printf("#define S_FSR %d\n",ptr_ofs(SS_Strand,fsr));
printf("#define S_FSR_RUN %d\n",ptr_ofs(SS_Strand,fsr_run));
printf("#define S_FSR_TEM %d\n",ptr_ofs(SS_Strand,fsr_tem));
printf("#define S_FSR_EXC %d\n",ptr_ofs(SS_Strand,fsr_exc));
printf("#define S_FSR_CPU %d\n",ptr_ofs(SS_Strand,fsr_cpu));
printf("#define S_FSR_TMP %d\n",ptr_ofs(SS_Strand,fsr_tmp));
printf("#define S_GSR %d\n",ptr_ofs(SS_Strand,gsr));
printf("#define S_FPRS %d\n",ptr_ofs(SS_Strand,fprs));
printf("#define S_PSTATE %d\n",ptr_ofs(SS_Strand,pstate));
printf("#define S_SIM_STATE %d\n",ptr_ofs(SS_Strand,sim_state));
printf("#define S_Y %d\n",ptr_ofs(SS_Strand,y));
printf("#define S_ASI %d\n",ptr_ofs(SS_Strand,asi));
printf("#define S_INST_DEC %d\n",ptr_ofs(SS_Strand,inst_dec));
printf("#define S_V8_INST_DEC %d\n",ptr_ofs(SS_Strand,v8_inst_dec));
printf("#define S_TRAP %d\n",ptr_ofs(SS_Strand,trap));
printf("#define S_V8_TRAP %d\n",ptr_ofs(SS_Strand,v8_trap));
printf("#define S_INST_TRAP %d\n",ptr_ofs(SS_Strand,inst_trap));
printf("#define S_V8_INST_TRAP %d\n",ptr_ofs(SS_Strand,v8_inst_trap));
printf("#define S_INST_MMU %d\n",ptr_ofs(SS_Strand,inst_mmu));
printf("#define S_DATA_TRAP %d\n",ptr_ofs(SS_Strand,data_trap));
printf("#define S_V8_DATA_TRAP %d\n",ptr_ofs(SS_Strand,v8_data_trap));
printf("#define S_INVALID_ASI %d\n",ptr_ofs(SS_Strand,invalid_asi));
printf("#define S_V8_INVALID_ASI %d\n",ptr_ofs(SS_Strand,v8_invalid_asi));
printf("#define S_DATA_MMU %d\n",ptr_ofs(SS_Strand,data_mmu));
printf("#define S_V8_DATA_MMU %d\n",ptr_ofs(SS_Strand,v8_data_mmu));
printf("#define S_EXE_TABLE %d\n",ptr_ofs(SS_Strand,exe_table));
printf("#define S_V8_EXE_TABLE %d\n",ptr_ofs(SS_Strand,v8_exe_table));
printf("#define S_MEM_TABLE %d\n",ptr_ofs(SS_Strand,mem_table));
printf("#define S_FRF %d\n",ptr_ofs(SS_Strand,drf));
printf("#define S_WRF %d\n",ptr_ofs(SS_Strand,wrf));
printf("#define S_INST_CACHE %d\n",ptr_ofs(SS_Strand,inst_cache));
printf("#define S_INST_TTE %d\n",ptr_ofs(SS_Strand,inst_tte));
printf("#define S_FAIL_TTE %d\n",ptr_ofs(SS_Strand,fail_tte));
printf("#define S_STPARTIAL16 %d\n",ptr_ofs(SS_Strand,stpartial16[0]));
printf("#define S_STPARTIAL32 %d\n",ptr_ofs(SS_Strand,stpartial32[0]));
printf("#define S_MEM_MASK %d\n",ptr_ofs(SS_Strand,mem_mask));
printf("#define S_MASK_PSTATE_AM %d\n",ptr_ofs(SS_Strand,mask_pstate_am));
printf("\n");
printf("#define S_G0 %d\n",ptr_ofs(SS_Strand,irf[0]));
printf("#define S_G1 %d\n",ptr_ofs(SS_Strand,irf[1]));
printf("#define S_G2 %d\n",ptr_ofs(SS_Strand,irf[2]));
printf("#define S_G3 %d\n",ptr_ofs(SS_Strand,irf[3]));
printf("#define S_G4 %d\n",ptr_ofs(SS_Strand,irf[4]));
printf("#define S_G5 %d\n",ptr_ofs(SS_Strand,irf[5]));
printf("#define S_G6 %d\n",ptr_ofs(SS_Strand,irf[6]));
printf("#define S_G7 %d\n",ptr_ofs(SS_Strand,irf[7]));
printf("#define S_O0 %d\n",ptr_ofs(SS_Strand,irf[8]));
printf("#define S_O1 %d\n",ptr_ofs(SS_Strand,irf[9]));
printf("#define S_O2 %d\n",ptr_ofs(SS_Strand,irf[10]));
printf("#define S_O3 %d\n",ptr_ofs(SS_Strand,irf[11]));
printf("#define S_O4 %d\n",ptr_ofs(SS_Strand,irf[12]));
printf("#define S_O5 %d\n",ptr_ofs(SS_Strand,irf[13]));
printf("#define S_O6 %d\n",ptr_ofs(SS_Strand,irf[14]));
printf("#define S_O7 %d\n",ptr_ofs(SS_Strand,irf[15]));
printf("#define S_L0 %d\n",ptr_ofs(SS_Strand,irf[16]));
printf("#define S_L1 %d\n",ptr_ofs(SS_Strand,irf[17]));
printf("#define S_L2 %d\n",ptr_ofs(SS_Strand,irf[18]));
printf("#define S_L3 %d\n",ptr_ofs(SS_Strand,irf[19]));
printf("#define S_L4 %d\n",ptr_ofs(SS_Strand,irf[20]));
printf("#define S_L5 %d\n",ptr_ofs(SS_Strand,irf[21]));
printf("#define S_L6 %d\n",ptr_ofs(SS_Strand,irf[22]));
printf("#define S_L7 %d\n",ptr_ofs(SS_Strand,irf[23]));
printf("#define S_I0 %d\n",ptr_ofs(SS_Strand,irf[24]));
printf("#define S_I1 %d\n",ptr_ofs(SS_Strand,irf[25]));
printf("#define S_I2 %d\n",ptr_ofs(SS_Strand,irf[26]));
printf("#define S_I3 %d\n",ptr_ofs(SS_Strand,irf[27]));
printf("#define S_I4 %d\n",ptr_ofs(SS_Strand,irf[28]));
printf("#define S_I5 %d\n",ptr_ofs(SS_Strand,irf[20]));
printf("#define S_I6 %d\n",ptr_ofs(SS_Strand,irf[30]));
printf("#define S_I7 %d\n",ptr_ofs(SS_Strand,irf[31]));
printf("\n");
printf("#define I_PTR %%o3\n");
printf("#define I_EXE %d\n",ptr_ofs(SS_Instr,exe));
printf("#define I_OPC %d\n",ptr_ofs(SS_Instr,opc));
printf("#define I_FLG %d\n",ptr_ofs(SS_Instr,flg));
printf("#define I_RS1 %d\n",ptr_ofs(SS_Instr,rs1));
printf("#define I_RS2 %d\n",ptr_ofs(SS_Instr,rs2));
printf("#define I_RS3 %d\n",ptr_ofs(SS_Instr,rs3));
printf("#define I_ASI %d\n",ptr_ofs(SS_Instr,asi));
printf("#define I_RD %d\n",ptr_ofs(SS_Instr,rd));
printf("#define I_TTE %d\n",ptr_ofs(SS_Instr,tte));
printf("#define I_EXE_TBL_IDX %d\n",ptr_ofs(SS_Instr,exe_tbl_idx));
printf("#define I_SIZE %d\n",SS_Instr::SIZE);
printf("#define I_BITS %d\n",SS_Instr::BITS);
printf("\n");
printf("#if defined(ARCH_V9)\n");
printf("#define TRAP S_TRAP\n");
printf("#define INST_TRAP S_INST_TRAP\n");
printf("#define DATA_TRAP S_DATA_TRAP\n");
printf("#define DATA_MMU S_DATA_MMU\n");
printf("#define INVALID_ASI S_INVALID_ASI\n");
printf("#define INST_DEC S_INST_DEC\n");
printf("#elif defined(ARCH_V8)\n");
printf("#define TRAP S_V8_TRAP\n");
printf("#define INST_TRAP S_V8_INST_TRAP\n");
printf("#define DATA_TRAP S_V8_DATA_TRAP\n");
printf("#define DATA_MMU S_V8_DATA_MMU\n");
printf("#define INVALID_ASI S_V8_INVALID_ASI\n");
printf("#define INST_DEC S_V8_INST_DEC\n");
printf("#else\n");
printf("#error \"Oops\"\n");
printf("#endif\n");
printf("\n");
SS_SimState fp_dis;
fp_dis = 0;
fp_dis.fp_disabled(1);
printf("#define F_FP_DISABLED 0x%llx\n",fp_dis());
SS_Pstate pstate;
pstate = 0;
pstate.am(1);
printf("#define F_PSTATE_AM 0x%x\n",pstate());
printf("\n");
printf("#define X_VIRT_MASK %d\n",ptr_ofs(SS_Tte,virt_mask));
printf("#define X_VIRT_PAGE %d\n",ptr_ofs(SS_Tte,virt_page));
printf("#define X_PHYS_MASK %d\n",ptr_ofs(SS_Tte,phys_mask));
printf("#define X_PHYS_PAGE %d\n",ptr_ofs(SS_Tte,phys_page));
printf("\n");
printf("#define T_MEM_ADDRESS_NOT_ALIGNED %d\n",SS_Trap::MEM_ADDRESS_NOT_ALIGNED);
printf("#define T_MEM_ADDRESS_RANGE %d\n",SS_Trap::MEM_ADDRESS_RANGE);
printf("#define T_LDDF_MEM_ADDRESS_NOT_ALIGNED %d\n",SS_Trap::LDDF_MEM_ADDRESS_NOT_ALIGNED);
printf("#define T_STDF_MEM_ADDRESS_NOT_ALIGNED %d\n",SS_Trap::STDF_MEM_ADDRESS_NOT_ALIGNED);
printf("#define T_PRIVILEGED_ACTION %d\n",SS_Trap::PRIVILEGED_ACTION);
printf("#define T_DAE_INVALID_ASI %d\n",SS_Trap::DAE_INVALID_ASI);
printf("#define T_FP_EXCEPTION_IEEE_754 %d\n",SS_Trap::FP_EXCEPTION_IEEE_754);
printf("#define T_FP_DISABLED %d\n",SS_Trap::FP_DISABLED);
printf("#define T_TAG_OVERFLOW %d\n",SS_Trap::TAG_OVERFLOW);
printf("#define T_VA_WATCHPOINT %d\n",SS_Trap::VA_WATCHPOINT);
printf("#define T_PA_WATCHPOINT %d\n",SS_Trap::PA_WATCHPOINT);
printf("#define T_DIVISION_BY_ZERO %d\n",SS_Trap::DIVISION_BY_ZERO);
printf("#define T_CONTROL_TRANSFER_INSTRUCTION %d\n",SS_Trap::CONTROL_TRANSFER_INSTRUCTION);
printf("\n");
printf("#define C_INST_CACHE_MASK %d\n",SS_InstrCache::MASK);
printf("#define C_INST_CACHE_BITS %d\n",SS_InstrCache::BITS);
printf("#define C_INST_CACHE_LINE_BITS %d\n",SS_InstrCache::LINE_BITS);
printf("#define C_LINE_TAG_MASK %d\n",-SS_InstrCache::LINE_SIZE * 4);
printf("#define C_LINE_IDX_MASK %d\n",SS_InstrCache::LINE_MASK << (SS_Instr::BITS - 1));
printf("\n");
printf("#endif\n");
exit(0);
}