// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movl %r9d, %r13d
movl %r8d, %ebx
movl %ecx, %r12d
movq %rdx, %r15
movq %rdi, %rbp
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0xaf32
movq %rbp, %rdi
movq %r14, %rsi
callq 0x44d0c
movl 0xb0(%rsp), %eax
leaq 0x298f7(%rip), %rcx     # 0x6eb40
movq %rcx, (%rbp)
movl %r12d, 0x2c(%rbp)
movl %ebx, 0xc(%rsp)
movl %ebx, 0x30(%rbp)
movl %r13d, 0x1c(%rsp)
movl %r13d, 0x34(%rbp)
movl %eax, 0x38(%rbp)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x40(%rbp)
movdqu %xmm0, 0x50(%rbp)
movdqu %xmm0, 0x60(%rbp)
movdqu %xmm0, 0x70(%rbp)
movq $0x0, 0x80(%rbp)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4529f
callq 0x7370
movl 0x2c(%rbp), %r12d
leaq 0x297f2(%rip), %rax     # 0x6ea98
movq %rax, (%rbp)
movq %r15, 0x88(%rbp)
movl %r12d, %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r12
testq %rbx, %rbx
movq %rbp, 0x10(%rsp)
je 0x45308
imulq $-0x108, %rbx, %r13     # imm = 0xFEF8
xorl %ebx, %ebx
movq %r12, %r14
movq %r14, %rdi
callq 0x3ddf4
addq $-0x108, %rbx           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %rbx, %r13
jne 0x452e8
movl 0x2c(%rbp), %eax
jmp 0x4530a
xorl %eax, %eax
movq %r12, 0x98(%rbp)
movl %eax, %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r12
testq %rbx, %rbx
je 0x45362
imulq $-0x108, %rbx, %r13     # imm = 0xFEF8
xorl %ebx, %ebx
movq %r12, %r14
movq %r14, %rdi
callq 0x3ddf4
addq $-0x108, %rbx           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %rbx, %r13
jne 0x45342
movl 0x2c(%rbp), %eax
jmp 0x45364
xorl %eax, %eax
movq %r12, 0xa0(%rbp)
movl %eax, %ebx
movq %rbx, %rax
shlq $0x8, %rax
leaq (%rax,%rbx,8), %rdi
addq $0x8, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
leaq 0x8(%rax), %r12
testq %rbx, %rbx
je 0x453bc
imulq $-0x108, %rbx, %r13     # imm = 0xFEF8
xorl %ebx, %ebx
movq %r12, %r14
movq %r14, %rdi
callq 0x3ddf4
addq $-0x108, %rbx           # imm = 0xFEF8
addq $0x108, %r14            # imm = 0x108
cmpq %rbx, %r13
jne 0x4539c
movl 0x2c(%rbp), %eax
jmp 0x453be
xorl %eax, %eax
movq %r12, 0xa8(%rbp)
movl %eax, %ebx
leaq (%rbx,%rbx,2), %r14
leaq 0x8(,%r14,8), %rdi
callq 0x7030
movq %rbx, (%rax)
addq $0x8, %rax
testq %rbx, %rbx
je 0x45403
leaq (%rax,%r14,8), %rcx
movq %rax, %rdx
movq %rdx, 0x8(%rdx)
movq %rdx, (%rdx)
movq $0x0, 0x10(%rdx)
addq $0x18, %rdx
cmpq %rcx, %rdx
jne 0x453eb
movq %rax, 0xb0(%rbp)
leaq (,%rbx,8), %rdi
callq 0x7030
movq %rax, 0x90(%rbp)
testl %ebx, %ebx
movl 0x1c(%rsp), %r12d
movl 0xc(%rsp), %ebx
je 0x456a0
movl %ebx, %eax
movq %rax, 0x28(%rsp)
shlq $0x7, %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movl %r12d, %ecx
movq %rcx, 0x30(%rsp)
imulq $0x68, %rcx, %rcx
movq %rcx, 0x40(%rsp)
addq $0x8, %rcx
movq %rcx, 0x48(%rsp)
negq %rax
movq %rax, 0x50(%rsp)
xorl %r13d, %r13d
movq 0x38(%rsp), %rdi
callq 0x7030
movq %rax, %rcx
leaq 0x8(%rax), %r15
movq 0x28(%rsp), %rax
movq %rax, (%rcx)
testl %ebx, %ebx
je 0x45682
movq %rcx, 0x20(%rsp)
leaq 0x30(%rcx), %r14
xorl %ebx, %ebx
pxor %xmm0, %xmm0
movdqu %xmm0, 0x40(%r14)
movdqu %xmm0, 0x30(%r14)
movdqu %xmm0, 0x20(%r14)
movdqu %xmm0, 0x10(%r14)
movdqu %xmm0, (%r14)
movq %r14, %rdi
xorl %esi, %esi
callq 0x47822
addq $-0x80, %rbx
subq $-0x80, %r14
cmpq %rbx, 0x50(%rsp)
jne 0x45494
movq 0x90(%rbp), %rax
movq %r15, (%rax,%r13,8)
cmpl $0x0, 0xc(%rsp)
je 0x4568d
movq 0x90(%rbp), %rbx
xorl %r15d, %r15d
movq (%rbx,%r13,8), %rax
movq %r15, %r14
shlq $0x7, %r14
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%rax,%r14)
movq 0x48(%rsp), %rdi
callq 0x7030
movq 0x30(%rsp), %rcx
movq %rcx, (%rax)
testl %r12d, %r12d
movl $0x0, %edi
je 0x4554e
leaq 0x30(%rax), %rcx
movq 0x40(%rsp), %rdx
leaq -0x20(%rcx), %rsi
movq %rsi, -0x18(%rcx)
movq %rsi, -0x20(%rcx)
movq %rdi, -0x10(%rcx)
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
movq %rdi, 0x10(%rcx)
addq $0x68, %rcx
addq $-0x68, %rdx
jne 0x45529
movq %r15, 0x20(%rsp)
addq $0x8, %rax
movq (%rbx,%r13,8), %rcx
movq %rax, 0x8(%rcx,%r14)
movq (%rbx,%r13,8), %rax
movl $0x0, (%rax,%r14)
movb $0x0, 0x20(%rax,%r14)
movq $0x0, 0x78(%rax,%r14)
testl %r12d, %r12d
je 0x45663
movq 0x8(%rax,%r14), %rax
xorl %r15d, %r15d
imulq $0x68, %r15, %r12
movq $0x0, (%rax,%r12)
movq (%rbx,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
leaq (%rax,%r12), %rbp
addq $0x8, %rbp
movq (%rbp), %rdi
cmpq %rbp, %rdi
je 0x455ce
movq (%rdi), %rbx
callq 0x7370
movq %rbx, %rdi
cmpq %rbp, %rbx
jne 0x455b2
movq 0x10(%rsp), %rax
movq 0x90(%rax), %rbx
movq %rbp, 0x8(%rbp)
movq %rbp, (%rbp)
xorl %ecx, %ecx
movq %rcx, 0x10(%rbp)
movq (%rbx,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
movq %rcx, 0x20(%rax,%r12)
movq (%rbx,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
leaq (%rax,%r12), %rbp
addq $0x28, %rbp
movq (%rbp), %rdi
cmpq %rbp, %rdi
je 0x45620
movq (%rdi), %rbx
callq 0x7370
movq %rbx, %rdi
cmpq %rbp, %rbx
jne 0x45604
movq 0x10(%rsp), %rax
movq 0x90(%rax), %rbx
movq %rbp, 0x8(%rbp)
movq %rbp, (%rbp)
movq $0x0, 0x10(%rbp)
movq (%rbx,%r13,8), %rax
movq 0x8(%rax,%r14), %rax
movw $0x1, 0x48(%rax,%r12)
incq %r15
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x50(%rax,%r12)
movq $-0x1, 0x60(%rax,%r12)
cmpq 0x30(%rsp), %r15
jne 0x4558c
movq 0x20(%rsp), %r15
incq %r15
cmpq 0x28(%rsp), %r15
movq 0x10(%rsp), %rbp
movl 0x1c(%rsp), %r12d
jne 0x454ee
jmp 0x4568d
movq 0x90(%rbp), %rax
movq %r15, (%rax,%r13,8)
incq %r13
movl 0x2c(%rbp), %eax
cmpq %rax, %r13
movl 0xc(%rsp), %ebx
jb 0x45468
movq %rbp, 0x29fd1(%rip)     # 0x6f678
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x457a2
callq 0x7370
jmp 0x457a2
jmp 0x45768
jmp 0x45768
movq %rax, %r14
testq %rbx, %rbx
je 0x45759
negq %rbx
movq %r15, %r12
addq $-0x100, %r12
leaq (%r12,%rbx), %rdi
callq 0x46b66
addq $-0x108, %rbx           # imm = 0xFEF8
jne 0x456f5
jmp 0x45759
movq %rax, %r14
testq %rbx, %rbx
je 0x45759
negq %rbx
movq %r15, %r12
addq $-0x100, %r12
leaq (%r12,%rbx), %rdi
callq 0x46b66
addq $-0x108, %rbx           # imm = 0xFEF8
jne 0x4571e
jmp 0x45759
movq %rax, %r14
testq %rbx, %rbx
je 0x45759
negq %rbx
movq %r15, %r12
addq $-0x100, %r12
leaq (%r12,%rbx), %rdi
callq 0x46b66
addq $-0x108, %rbx           # imm = 0xFEF8
jne 0x45747
movq %r15, %rdi
callq 0x7480
movq 0x10(%rsp), %rbp
jmp 0x4579a
movq %rax, %r14
jmp 0x4579a
movq %rax, %r14
testq %rbx, %rbx
je 0x45790
negq %rbx
movq 0x20(%rsp), %r15
addq $-0x50, %r15
leaq (%r15,%rbx), %rdi
callq 0x4798a
addq $-0x80, %rbx
jne 0x45781
movq 0x20(%rsp), %rdi
callq 0x7480
movq %rbp, %rdi
callq 0x46be0
movq %r14, %rdi
callq 0x7620