// File: /workspace/github_cpp_makefile_star2_O2/CMU-SAFARI[P]MQSim/src/ssd/NVM_PHY_ONFI_NVDDR2.cpp
// Function: SSD_Components::NVM_PHY_ONFI_NVDDR2::NVM_PHY_ONFI_NVDDR2(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, SSD_Components::ONFI_Channel_NVDDR2**, unsigned int, unsigned int, unsigned int, unsigned int)
NVM_PHY_ONFI_NVDDR2::NVM_PHY_ONFI_NVDDR2(const sim_object_id_type& id, ONFI_Channel_NVDDR2** channels,
		unsigned int ChannelCount, unsigned int chip_no_per_channel, unsigned int DieNoPerChip, unsigned int PlaneNoPerDie)
		: NVM_PHY_ONFI(id, ChannelCount, chip_no_per_channel, DieNoPerChip, PlaneNoPerDie), channels(channels)
	{
		WaitingReadTX = new Flash_Transaction_Queue[channel_count];
		WaitingGCRead_TX = new Flash_Transaction_Queue[channel_count];
		WaitingMappingRead_TX = new Flash_Transaction_Queue[channel_count];
		WaitingCopybackWrites = new std::list<DieBookKeepingEntry*>[channel_count];
		bookKeepingTable = new ChipBookKeepingEntry*[channel_count];
		for (unsigned int channelID = 0; channelID < channel_count; channelID++) {
			bookKeepingTable[channelID] = new ChipBookKeepingEntry[chip_no_per_channel];
			for (unsigned int chipID = 0; chipID < chip_no_per_channel; chipID++) {
				bookKeepingTable[channelID][chipID].Expected_command_exec_finish_time = T0; 
				bookKeepingTable[channelID][chipID].Last_transfer_finish_time = T0;
				bookKeepingTable[channelID][chipID].Die_book_keeping_records = new DieBookKeepingEntry[DieNoPerChip];
				bookKeepingTable[channelID][chipID].Status = ChipStatus::IDLE;
				bookKeepingTable[channelID][chipID].HasSuspend = false;
				bookKeepingTable[channelID][chipID].WaitingReadTXCount = 0;
				bookKeepingTable[channelID][chipID].No_of_active_dies = 0;
				for (unsigned int dieID = 0; dieID < DieNoPerChip; dieID++) {
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].ActiveCommand = NULL;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].ActiveTransactions.clear();
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].SuspendedCommand = NULL;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].SuspendedTransactions.clear();
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Free = true;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Suspended = false;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].DieInterleavedTime = INVALID_TIME;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].Expected_finish_time = INVALID_TIME;
					bookKeepingTable[channelID][chipID].Die_book_keeping_records[dieID].RemainingExecTime = INVALID_TIME;
				}
			}
		}
		_my_instance = this;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %ebp
movl %r8d, %r12d
movl %ecx, %r14d
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x38(%rsp), %r13
movq %r13, %rdi
callq 0x7480
movq %rbx, %rdi
movq %r13, %rsi
movl %r14d, %edx
movl %r12d, (%rsp)
movl %r12d, %ecx
movl %ebp, 0x4(%rsp)
movl %ebp, %r8d
movl 0x90(%rsp), %r9d
callq 0x38c60
leaq 0x38(%rsp), %rdi
callq 0x7678
leaq 0x2a125(%rip), %rax     # 0x61a78
movq %rax, (%rbx)
movq %r15, 0x88(%rbx)
movl 0x2c(%rbx), %r14d
imulq $0x108, %r14, %rdi      # imm = 0x108
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %r14, (%rax)
leaq 0x8(%rax), %r13
testq %r14, %r14
je 0x379ad
imulq $-0x108, %r14, %rbp     # imm = 0xFEF8
xorl %r12d, %r12d
movq %r13, %r14
movq %r14, %rdi
callq 0x32340
addq $-0x108, %r12           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %r12, %rbp
jne 0x3798d
movl 0x2c(%rbx), %eax
jmp 0x379af
xorl %eax, %eax
movq %r13, 0x98(%rbx)
movl %eax, %r14d
imulq $0x108, %r14, %rdi      # imm = 0x108
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %r14, (%rax)
leaq 0x8(%rax), %r13
testq %r14, %r14
je 0x37a05
imulq $-0x108, %r14, %rbp     # imm = 0xFEF8
xorl %r12d, %r12d
movq %r13, %r14
movq %r14, %rdi
callq 0x32340
addq $-0x108, %r12           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %r12, %rbp
jne 0x379e5
movl 0x2c(%rbx), %eax
jmp 0x37a07
xorl %eax, %eax
movq %r13, 0xa0(%rbx)
movl %eax, %r14d
imulq $0x108, %r14, %rdi      # imm = 0x108
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %r14, (%rax)
leaq 0x8(%rax), %r13
testq %r14, %r14
je 0x37a5e
imulq $-0x108, %r14, %rbp     # imm = 0xFEF8
xorl %r12d, %r12d
movq %r13, %r14
movq %r14, %rdi
callq 0x32340
addq $-0x108, %r12           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %r12, %rbp
jne 0x37a3d
movl 0x2c(%rbx), %r14d
jmp 0x37a61
xorl %r14d, %r14d
movq %r13, 0xa8(%rbx)
movl %r14d, %r15d
imulq $0x18, %r15, %r12
leaq 0x8(%r12), %rdi
callq 0x7030
movq %r15, (%rax)
addq $0x8, %rax
testl %r14d, %r14d
je 0x37aa0
addq %rax, %r12
movq %rax, %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
andq $0x0, 0x10(%rcx)
addq $0x18, %rcx
cmpq %r12, %rcx
jne 0x37a8b
movq %rax, 0xb0(%rbx)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x7030
movq %rax, 0x90(%rbx)
movl (%rsp), %eax
movq %rax, 0x8(%rsp)
shlq $0x7, %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x10(%rsp)
movl 0x4(%rsp), %ecx
movq %rcx, 0x20(%rsp)
imulq $0x68, %rcx, %rbp
leaq 0x8(%rbp), %rcx
movq %rcx, 0x28(%rsp)
negq %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movl %r14d, %eax
cmpq %rax, %r13
jae 0x37c7b
movq 0x10(%rsp), %rdi
callq 0x7030
movq %rax, %r12
movq 0x8(%rsp), %rax
movq %rax, (%r12)
cmpl $0x0, (%rsp)
je 0x37b37
leaq 0x30(%r12), %r14
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x396f8
addq $-0x80, %r15
subq $-0x80, %r14
cmpq %r15, 0x18(%rsp)
jne 0x37b20
addq $0x8, %r12
movq 0x90(%rbx), %rax
movq %r12, (%rax,%r13,8)
xorl %r12d, %r12d
cmpq 0x8(%rsp), %r12
je 0x37c6f
movq 0x90(%rbx), %r15
movq (%r15,%r13,8), %rax
movq %r12, %r14
shlq $0x7, %r14
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax,%r14)
movq 0x28(%rsp), %rdi
callq 0x7030
movq %r12, 0x30(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, (%rax)
cmpl $0x0, 0x4(%rsp)
je 0x37bbd
leaq 0x30(%rax), %rcx
movq %rbp, %rdx
leaq -0x20(%rcx), %rsi
movq %rsi, -0x18(%rcx)
movq %rsi, -0x20(%rcx)
andq $0x0, -0x10(%rcx)
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
andq $0x0, 0x10(%rcx)
addq $0x68, %rcx
addq $-0x68, %rdx
jne 0x37b96
addq $0x8, %rax
movq (%r15,%r13,8), %rcx
movq %rax, 0x8(%rcx,%r14)
movq (%r15,%r13,8), %rax
andl $0x0, (%rax,%r14)
movb $0x0, 0x20(%rax,%r14)
andq $0x0, 0x78(%rax,%r14)
xorl %r12d, %r12d
cmpq %r12, %rbp
je 0x37c62
movq 0x8(%rax,%r14), %rax
andq $0x0, (%rax,%r12)
movq (%r15,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
leaq (%rax,%r12), %rdi
addq $0x8, %rdi
callq 0x27258
movq 0x90(%rbx), %rax
movq (%rax,%r13,8), %rcx
movq 0x8(%rcx,%r14), %rcx
andq $0x0, 0x20(%rcx,%r12)
movq (%rax,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
leaq (%rax,%r12), %rdi
addq $0x28, %rdi
callq 0x27258
movq 0x90(%rbx), %r15
movq (%r15,%r13,8), %rax
movq 0x8(%rax,%r14), %rcx
movw $0x1, 0x48(%rcx,%r12)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x50(%rcx,%r12)
orq $-0x1, 0x60(%rcx,%r12)
addq $0x68, %r12
jmp 0x37be2
movq 0x30(%rsp), %r12
incq %r12
jmp 0x37b49
incq %r13
movl 0x2c(%rbx), %r14d
jmp 0x37af0
movq %rbx, 0x2a9c6(%rip)     # 0x62648
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x7678
jmp 0x37d61
jmp 0x37d56
movq %rax, %r14
testq %r12, %r12
je 0x37d21
negq %r12
movq %r15, %r13
addq $-0x100, %r13
leaq (%r12,%r13), %rdi
callq 0x38cc8
addq $-0x108, %r12           # imm = 0xFEF8
jne 0x37cbd
jmp 0x37d21
movq %rax, %r14
testq %r12, %r12
je 0x37d21
negq %r12
movq %r15, %r13
addq $-0x100, %r13
leaq (%r12,%r13), %rdi
callq 0x38cc8
addq $-0x108, %r12           # imm = 0xFEF8
jne 0x37ce6
jmp 0x37d21
movq %rax, %r14
testq %r12, %r12
je 0x37d21
negq %r12
movq %r15, %r13
addq $-0x100, %r13
leaq (%r12,%r13), %rdi
callq 0x38cc8
addq $-0x108, %r12           # imm = 0xFEF8
jne 0x37d0f
movq %r15, %rdi
jmp 0x37d4f
jmp 0x37d56
movq %r12, %r13
movq %rax, %r14
testq %r15, %r15
je 0x37d4c
negq %r15
movq %r13, %r12
addq $-0x50, %r12
leaq (%r12,%r15), %rdi
callq 0x39910
addq $-0x80, %r15
jne 0x37d3d
movq %r13, %rdi
callq 0x7430
jmp 0x37d59
movq %rax, %r14
movq %rbx, %rdi
callq 0x38cfa
movq %r14, %rdi
callq 0x75d0
nop