// File: 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:
subq $0x1d8, %rsp            # imm = 0x1D8
movl 0x1e0(%rsp), %eax
movq %rdi, 0x1d0(%rsp)
movq %rsi, 0x1c8(%rsp)
movq %rdx, 0x1c0(%rsp)
movl %ecx, 0x1bc(%rsp)
movl %r8d, 0x1b8(%rsp)
movl %r9d, 0x1b4(%rsp)
movq 0x1d0(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x1c8(%rsp), %rsi
leaq 0x190(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0x81a0
movq 0x168(%rsp), %rdi
movq 0x170(%rsp), %rsi
movl 0x1bc(%rsp), %edx
movl 0x1b8(%rsp), %ecx
movl 0x1b4(%rsp), %r8d
movl 0x1e0(%rsp), %r9d
callq 0x90ea0
jmp 0x8d8bf
leaq 0x190(%rsp), %rdi
callq 0x8848
movq 0x168(%rsp), %rax
leaq 0x4c1c5(%rip), %rcx     # 0xd9aa0
movq %rcx, (%rax)
movq 0x1c0(%rsp), %rcx
movq %rcx, 0x88(%rax)
movl 0x2c(%rax), %eax
movl %eax, %ecx
movq %rcx, 0x158(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
leaq 0x8(%rax,%rcx,8), %rdi
callq 0x8030
movq %rax, 0x160(%rsp)
jmp 0x8d915
movq 0x158(%rsp), %rax
movq 0x160(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x150(%rsp)
cmpq $0x0, %rax
je 0x8d9a1
movq 0x150(%rsp), %rax
movq 0x158(%rsp), %rcx
imulq $0x108, %rcx, %rdx      # imm = 0x108
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x140(%rsp)
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rdi
movq %rdi, 0x138(%rsp)
callq 0x7ed90
jmp 0x8d97e
movq 0x140(%rsp), %rcx
movq 0x138(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
cmpq %rcx, %rax
movq %rax, 0x148(%rsp)
jne 0x8d967
movq 0x168(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x98(%rax)
movl 0x2c(%rax), %eax
movl %eax, %ecx
movq %rcx, 0x128(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
leaq 0x8(%rax,%rcx,8), %rdi
callq 0x8030
movq %rax, 0x130(%rsp)
jmp 0x8d9e0
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x120(%rsp)
cmpq $0x0, %rax
je 0x8da6c
movq 0x120(%rsp), %rax
movq 0x128(%rsp), %rcx
imulq $0x108, %rcx, %rdx      # imm = 0x108
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x110(%rsp)
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0x7ed90
jmp 0x8da49
movq 0x110(%rsp), %rcx
movq 0x108(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
cmpq %rcx, %rax
movq %rax, 0x118(%rsp)
jne 0x8da32
movq 0x168(%rsp), %rax
movq 0x120(%rsp), %rcx
movq %rcx, 0xa0(%rax)
movl 0x2c(%rax), %eax
movl %eax, %ecx
movq %rcx, 0xf8(%rsp)
movq %rcx, %rax
shlq $0x8, %rax
leaq 0x8(%rax,%rcx,8), %rdi
callq 0x8030
movq %rax, 0x100(%rsp)
jmp 0x8daab
movq 0xf8(%rsp), %rax
movq 0x100(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0xf0(%rsp)
cmpq $0x0, %rax
je 0x8db37
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rcx
imulq $0x108, %rcx, %rdx      # imm = 0x108
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0xe0(%rsp)
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x7ed90
jmp 0x8db14
movq 0xe0(%rsp), %rcx
movq 0xd8(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
cmpq %rcx, %rax
movq %rax, 0xe8(%rsp)
jne 0x8dafd
movq 0x168(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq %rcx, 0xa8(%rax)
movl 0x2c(%rax), %eax
movq %rax, 0xc8(%rsp)
leaq (%rax,%rax,2), %rax
leaq 0x8(,%rax,8), %rdi
callq 0x8030
movq %rax, 0xd0(%rsp)
jmp 0x8db74
movq 0xc8(%rsp), %rax
movq 0xd0(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0xc0(%rsp)
cmpq $0x0, %rax
je 0x8dbf9
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
imulq $0x18, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x90f80
movq 0xa8(%rsp), %rax
movq 0xb0(%rsp), %rcx
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, 0xb8(%rsp)
jne 0x8dbc3
movq 0x168(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq %rcx, 0xb0(%rax)
movl 0x2c(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x8030
movq %rax, 0xa0(%rsp)
jmp 0x8dc28
movq 0x168(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, 0x90(%rax)
movl $0x0, 0x180(%rsp)
movq 0x168(%rsp), %rcx
movl 0x180(%rsp), %eax
cmpl 0x2c(%rcx), %eax
jae 0x8e346
movl 0x1b8(%rsp), %eax
movl %eax, %edi
movq %rdi, 0x90(%rsp)
shlq $0x7, %rdi
orq $0x8, %rdi
callq 0x8030
movq %rax, 0x98(%rsp)
jmp 0x8dc8a
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x88(%rsp)
cmpq $0x0, %rax
je 0x8dd07
movq 0x88(%rsp), %rax
movq 0x90(%rsp), %rdx
shlq $0x7, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x90f90
jmp 0x8dcea
movq 0x78(%rsp), %rcx
movq 0x70(%rsp), %rax
addq $0x80, %rax
cmpq %rcx, %rax
movq %rax, 0x80(%rsp)
jne 0x8dcd6
movq 0x88(%rsp), %rdx
movq 0x168(%rsp), %rax
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
cmpl 0x1b8(%rsp), %eax
jae 0x8e32e
movq 0x168(%rsp), %rax
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
movq $0x0, 0x10(%rcx,%rdx)
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x17c(%rsp), %ecx
shlq $0x7, %rcx
movq $0x0, 0x18(%rax,%rcx)
movl 0x1b4(%rsp), %eax
movq %rax, 0x60(%rsp)
imulq $0x68, %rax, %rdi
addq $0x8, %rdi
callq 0x8030
movq %rax, 0x68(%rsp)
jmp 0x8ddbc
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x58(%rsp)
cmpq $0x0, %rax
je 0x8de1d
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
imulq $0x68, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x90fd0
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
addq $0x68, %rax
cmpq %rcx, %rax
movq %rax, 0x50(%rsp)
jne 0x8ddf6
movq 0x168(%rsp), %rax
movq 0x58(%rsp), %rdx
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %esi
movq (%rcx,%rsi,8), %rcx
movl 0x17c(%rsp), %esi
shlq $0x7, %rsi
addq %rsi, %rcx
movq %rdx, 0x8(%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movl $0x0, (%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movb $0x0, 0x20(%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movl $0x0, 0x78(%rcx)
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x17c(%rsp), %ecx
shlq $0x7, %rcx
addq %rcx, %rax
movl $0x0, 0x7c(%rax)
movl $0x0, 0x178(%rsp)
movl 0x178(%rsp), %eax
cmpl 0x1b4(%rsp), %eax
jae 0x8e316
movq 0x168(%rsp), %rax
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movq $0x0, (%rcx)
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x17c(%rsp), %ecx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl 0x178(%rsp), %eax
imulq $0x68, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
callq 0x5d190
movq 0x168(%rsp), %rax
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movq $0x0, 0x20(%rcx)
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x17c(%rsp), %ecx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl 0x178(%rsp), %eax
imulq $0x68, %rax, %rax
addq %rax, %rdi
addq $0x28, %rdi
callq 0x5d190
movq 0x168(%rsp), %rax
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movb $0x1, 0x48(%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movb $0x0, 0x49(%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movq $-0x1, 0x60(%rcx)
movq 0x90(%rax), %rcx
movl 0x180(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x17c(%rsp), %edx
shlq $0x7, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl 0x178(%rsp), %edx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movq $-0x1, 0x50(%rcx)
movq 0x90(%rax), %rax
movl 0x180(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x17c(%rsp), %ecx
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl 0x178(%rsp), %ecx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq $-0x1, 0x58(%rax)
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x8def1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x8848
jmp 0x8e36a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x8e35d
movq 0x150(%rsp), %rcx
movq %rax, %rsi
movq 0x138(%rsp), %rax
movq %rsi, 0x188(%rsp)
movl %edx, 0x184(%rsp)
cmpq %rax, %rcx
movq %rax, 0x38(%rsp)
je 0x8e1ce
movq 0x38(%rsp), %rdi
addq $-0x108, %rdi           # imm = 0xFEF8
movq %rdi, 0x30(%rsp)
callq 0x90f30
movq 0x150(%rsp), %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x38(%rsp)
jne 0x8e1a1
movq 0x160(%rsp), %rdi
callq 0x8570
jmp 0x8e35d
movq 0x120(%rsp), %rcx
movq %rax, %rsi
movq 0x108(%rsp), %rax
movq %rsi, 0x188(%rsp)
movl %edx, 0x184(%rsp)
cmpq %rax, %rcx
movq %rax, 0x28(%rsp)
je 0x8e239
movq 0x28(%rsp), %rdi
addq $-0x108, %rdi           # imm = 0xFEF8
movq %rdi, 0x20(%rsp)
callq 0x90f30
movq 0x120(%rsp), %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x28(%rsp)
jne 0x8e20c
movq 0x130(%rsp), %rdi
callq 0x8570
jmp 0x8e35d
movq 0xf0(%rsp), %rcx
movq %rax, %rsi
movq 0xd8(%rsp), %rax
movq %rsi, 0x188(%rsp)
movl %edx, 0x184(%rsp)
cmpq %rax, %rcx
movq %rax, 0x18(%rsp)
je 0x8e2a4
movq 0x18(%rsp), %rdi
addq $-0x108, %rdi           # imm = 0xFEF8
movq %rdi, 0x10(%rsp)
callq 0x90f30
movq 0xf0(%rsp), %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x18(%rsp)
jne 0x8e277
movq 0x100(%rsp), %rdi
callq 0x8570
jmp 0x8e35d
movq 0x88(%rsp), %rcx
movq %rax, %rsi
movq 0x70(%rsp), %rax
movq %rsi, 0x188(%rsp)
movl %edx, 0x184(%rsp)
cmpq %rax, %rcx
movq %rax, 0x8(%rsp)
je 0x8e307
movq 0x8(%rsp), %rdi
addq $-0x80, %rdi
movq %rdi, (%rsp)
callq 0x90fb0
movq 0x88(%rsp), %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x8(%rsp)
jne 0x8e2df
movq 0x98(%rsp), %rdi
callq 0x8570
jmp 0x8e35d
jmp 0x8e318
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x8dd34
jmp 0x8e330
movl 0x180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x180(%rsp)
jmp 0x8dc4a
movq 0x168(%rsp), %rax
movq %rax, 0x4c3e3(%rip)     # 0xda738
addq $0x1d8, %rsp            # imm = 0x1D8
retq
movq 0x168(%rsp), %rdi
callq 0x91000
movq 0x188(%rsp), %rdi
callq 0x8770
nopw (%rax,%rax)