// File: /workspace/github_c_makefile_star2_O0/j-hoppe[P]tu58fs/main.c
// Function: check_capabilities
static void check_capabilities() {
	int unit;
	image_t *img;
	filesystem_type_t fstype = fsNONE;
	unsigned fssize;

	if (drive_count > 0 && opt_boot_monitor != monitor_none)
		fatal("--boot function incompatible with device emulation!");

	if (drive_count > 0 && strlen(opt_serial_port) == 0) {
		fatal("No serial port specified, drive emulator not started.");
	}

	if (opt_boot_monitor != monitor_none && opt_boot_monitor != monitor_showcode && strlen(opt_serial_port) == 0) {
		fatal("No serial port specified, boot loader transfer not started.");
	}

	if (drive_count > 0 && opt_serial_bitcount != 8)
		fatal("TU58 drive emulation requires 8 bit serial line format!");

	// XXDP: boot device #0 oversized?
	img = tu58image_get(0);
	if (img && img->dec_filesystem == fsXXDP
			&& img->data_size != (unsigned)img->device_info->block_count * img->blocksize)
		warning("XXDP device #0 is oversized, XXDP2.5 can not boot this");

	//	RT-11: only dd0 and dd1:
	for (unit = 2; unit < TU58_DEVICECOUNT; unit++) {
		img = tu58image_get(unit);
		if (img && img->dec_filesystem == fsRT11)
			warning("RT-11 can only access DD0 and DD1:, TU58 unit %d not usable", unit);
	}
	// all devices same filesystem?

	fstype = fsNONE;
	for (unit = 0; unit < TU58_DEVICECOUNT; unit++) {
		img = tu58image_get(unit);
		if (img) {
			if (fstype == fsNONE)
				fstype = img->dec_filesystem;
			else if (fstype != img->dec_filesystem)
				fatal("All devices must have the same filesystem type!");
		}
	}

	// RT-11: all devices same size, when --size

	fssize = 0;
	for (unit = 0; unit < TU58_DEVICECOUNT; unit++) {
		img = tu58image_get(unit);
		if (img && img->dec_filesystem == fsRT11) {
			if (fssize == 0)
				fssize = img->data_size;
			else if (fssize != img->data_size)
				warning("All RT-11 devices must have the same image size!");
		}
	}

	// RT-11: boot device readonly, if patched?
	img = tu58image_get(0);
	if (img && img->dec_filesystem == fsRT11
			&& img->data_size != (unsigned)img->device_info->block_count * img->blocksize
			&& !img->readonly)
		warning("RT-11 device #0 is oversized and on shared dir.\n"
				"RT-11 v5.3 can not reload image after changed, so should be read-only.\n"
				"RT-11 v5.5 seems to be OK.");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x14(%rbp)
cmpl $0x0, 0x1f902(%rip)     # 0x24f68
jle 0x567f
cmpl $0x0, 0x1e719(%rip)     # 0x23d88
je 0x567f
leaq 0x15a3e(%rip), %rdi     # 0x1b0b6
movb $0x0, %al
callq 0xd140
cmpl $0x0, 0x1f8e2(%rip)     # 0x24f68
jle 0x56a8
leaq 0x1e5d1(%rip), %rdi     # 0x23c60
callq 0x3190
cmpq $0x0, %rax
jne 0x56a8
leaq 0x15a49(%rip), %rdi     # 0x1b0ea
movb $0x0, %al
callq 0xd140
cmpl $0x0, 0x1e6d9(%rip)     # 0x23d88
je 0x56da
cmpl $0x1, 0x1e6d0(%rip)     # 0x23d88
je 0x56da
leaq 0x1e59f(%rip), %rdi     # 0x23c60
callq 0x3190
cmpq $0x0, %rax
jne 0x56da
leaq 0x15a4d(%rip), %rdi     # 0x1b120
movb $0x0, %al
callq 0xd140
cmpl $0x0, 0x1f887(%rip)     # 0x24f68
jle 0x56fa
cmpl $0x8, 0x1dc16(%rip)     # 0x23300
je 0x56fa
leaq 0x15a69(%rip), %rdi     # 0x1b15c
movb $0x0, %al
callq 0xd140
xorl %edi, %edi
callq 0x7aa0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x574e
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10c(%rax)
jne 0x574e
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0xe8(%rcx), %rcx
movl 0x18(%rcx), %ecx
movq -0x10(%rbp), %rdx
imull 0xf0(%rdx), %ecx
cmpl %ecx, %eax
je 0x574e
leaq 0x15a4d(%rip), %rdi     # 0x1b194
movb $0x0, %al
callq 0xd050
movl $0x2, -0x4(%rbp)
cmpl $0x8, -0x4(%rbp)
jge 0x5799
movl -0x4(%rbp), %edi
callq 0x7aa0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x578c
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10c(%rax)
jne 0x578c
movl -0x4(%rbp), %esi
leaq 0x15a46(%rip), %rdi     # 0x1b1cb
movb $0x0, %al
callq 0xd050
jmp 0x578e
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x5755
movl $0x0, -0x14(%rbp)
movl $0x0, -0x4(%rbp)
cmpl $0x8, -0x4(%rbp)
jge 0x5803
movl -0x4(%rbp), %edi
callq 0x7aa0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x57f6
cmpl $0x0, -0x14(%rbp)
jne 0x57d5
movq -0x10(%rbp), %rax
movl 0x10c(%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x57f4
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10c(%rcx), %eax
je 0x57f2
leaq 0x15a1c(%rip), %rdi     # 0x1b207
movb $0x0, %al
callq 0xd140
jmp 0x57f4
jmp 0x57f6
jmp 0x57f8
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x57a7
movl $0x0, -0x18(%rbp)
movl $0x0, -0x4(%rbp)
cmpl $0x8, -0x4(%rbp)
jge 0x587a
movl -0x4(%rbp), %edi
callq 0x7aa0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x586d
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10c(%rax)
jne 0x586d
cmpl $0x0, -0x18(%rbp)
jne 0x584c
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movl %eax, -0x18(%rbp)
jmp 0x586b
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x110(%rcx), %eax
je 0x5869
leaq 0x159d5(%rip), %rdi     # 0x1b237
movb $0x0, %al
callq 0xd050
jmp 0x586b
jmp 0x586d
jmp 0x586f
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x5811
xorl %edi, %edi
callq 0x7aa0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x58d8
movq -0x10(%rbp), %rax
cmpl $0x2, 0x10c(%rax)
jne 0x58d8
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0xe8(%rcx), %rcx
movl 0x18(%rcx), %ecx
movq -0x10(%rbp), %rdx
imull 0xf0(%rdx), %ecx
cmpl %ecx, %eax
je 0x58d8
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0x58d8
leaq 0x15997(%rip), %rdi     # 0x1b268
movb $0x0, %al
callq 0xd050
addq $0x20, %rsp
popq %rbp
retq
nop