// File: /workspace/github_cpp_makefile_star2_O1/merelin[P]mediasmartserverd/src/led_control_sch5127_base.h
// Function: LedControlSCH5127Base::initSch5127_()
bool initSch5127_( ) {
		enum {
			IDX_LDN			= 0x07,	///< Logical Device Number
			IDX_ID			= 0x20,	///< device identification
			IDX_BASE_MSB	= 0x60,	///< base address MSB register
			IDX_BASE_LSB	= 0x61,	///< base address LSB register
			IDX_ENTER		= 0x55,	///< enter configuration mode
			IDX_EXIT		= 0xaa,	///< exit configuration mode
		};
		
		// try LPC SIO @ 0x2e
		unsigned int sio_addr = 0x2e;
		unsigned int sio_data = sio_addr + 1;
		if ( ioperm(sio_addr, 1, 1) ) throw ErrnoException("ioperm");
		if ( ioperm(sio_data, 1, 1) ) throw ErrnoException("ioperm");
		
		// enter configuration mode
		outb( IDX_ENTER, sio_addr );
		
		// retrieve identification
		outb( IDX_ID, sio_addr );
		const unsigned int device_id = inb( sio_data );
		if ( debug ) std::cout << Desc() << ": Device 0x" << std::hex << device_id << std::dec << "\n";
		
		// 
		{
			outb( 0x26, sio_addr );
			const unsigned int in = inb( sio_data );
			if ( 0x4e == in ) {
				outb( IDX_EXIT, sio_addr );
				
				// finished with these ports
				ioperm( sio_addr, 1, 0 );
				ioperm( sio_data, 1, 0 );
				
				// and switch to these if we are told to
				if ( debug ) std::cout << Desc() << ": Using 0x4e\n";
				sio_addr = 0x4e;
				sio_data = sio_addr + 1;
				
				if ( ioperm(sio_addr, 1, 1) ) throw ErrnoException("ioperm");
		        if ( ioperm(sio_data, 1, 1) ) throw ErrnoException("ioperm");
				
				outb( IDX_ENTER, sio_addr );
			}
		}
		
		// select logical device 0x0a (base address?)
		outb( IDX_LDN, sio_addr );
		outb( 0x0a, sio_data );
		
		// get base address of runtime registers
		outb( IDX_BASE_MSB, sio_addr );
		const unsigned int index_msb = inb( sio_data );
		outb( IDX_BASE_LSB, sio_addr );
		const unsigned int index_lsb = inb( sio_data );
		
		io_sch5127_regs_ = index_msb << 8 | index_lsb;
		
		// exit configuration
		outb( IDX_EXIT, sio_addr );
		
		// finished with SuperI/O ports
		ioperm(sio_data, 1, 0);
		ioperm(sio_addr, 1, 0);
		
		return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl $0x2e, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8b90
movl $0x2f, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8bf2
movb $0x55, %al
outb %al, $0x2e
movb $0x20, %al
outb %al, $0x2e
inb $0x2f, %al
cmpl $0x0, 0x79be(%rip)      # 0x10350
je 0x8a4c
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testq %rax, %rax
je 0x89c7
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movq 0x75f6(%rip), %rdi      # 0xffb0
movq %r14, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x89e5
movq 0x75e2(%rip), %rax      # 0xffb0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x4510
movq 0x75c4(%rip), %r14      # 0xffb0
leaq 0x314e(%rip), %rsi      # 0xbb41
movl $0xb, %edx
movq %r14, %rdi
callq 0x4310
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movzbl %bpl, %esi
movq %r14, %rdi
callq 0x41a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x2ccc(%rip), %rsi      # 0xb70b
movl $0x1, %edx
movq %rax, %rdi
callq 0x4310
movb $0x26, %al
outb %al, $0x2e
inb $0x2f, %al
cmpb $0x4e, %al
jne 0x8ab2
movb $-0x56, %al
outb %al, $0x2e
movl $0x2e, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x44b0
movl $0x2f, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x44b0
cmpl $0x0, 0x78cd(%rip)      # 0x10350
je 0x8af4
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testq %rax, %rax
je 0x8abe
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movq 0x750b(%rip), %rdi      # 0xffb0
movq %r14, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x8adc
movl $0x2e, %ebp
movl $0x2f, %ecx
jmp 0x8b3a
movq 0x74eb(%rip), %rax      # 0xffb0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x4510
movq 0x74cd(%rip), %rdi      # 0xffb0
leaq 0x3063(%rip), %rsi      # 0xbb4d
movl $0xd, %edx
callq 0x4310
movl $0x4e, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8c54
movl $0x4f, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8cb3
movb $0x55, %al
outb %al, $0x4e
movl $0x4e, %ebp
movl $0x4f, %ecx
movb $0x7, %al
movl %ebp, %edx
outb %al, %dx
movb $0xa, %al
movl %ecx, %edx
outb %al, %dx
movb $0x60, %al
movl %ebp, %edx
outb %al, %dx
movl %ecx, %edx
inb %dx, %al
movzbl %al, %esi
movb $0x61, %al
movl %ebp, %edx
outb %al, %dx
movl %ecx, %edx
inb %dx, %al
movzbl %al, %eax
shll $0x8, %esi
orl %eax, %esi
movl %esi, 0xc(%rbx)
movb $-0x56, %al
movl %ebp, %edx
outb %al, %dx
movl %ecx, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x44b0
movl %ebp, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x44b0
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2f75(%rip), %rsi      # 0xbb22
leaq 0x2f74(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e88
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be8
xorl %ebp, %ebp
leaq 0x6b12(%rip), %rsi      # 0xf6f0
movq 0x73bb(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8d10
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2f13(%rip), %rsi      # 0xbb22
leaq 0x2f12(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e88
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be8
xorl %ebp, %ebp
leaq 0x6ab0(%rip), %rsi      # 0xf6f0
movq 0x7359(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8d10
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2eb1(%rip), %rsi      # 0xbb22
leaq 0x2eb0(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e88
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be8
xorl %ebp, %ebp
leaq 0x6a4e(%rip), %rsi      # 0xf6f0
movq 0x72f7(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8d10
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2e52(%rip), %rsi      # 0xbb22
leaq 0x2e51(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e88
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be8
xorl %ebp, %ebp
leaq 0x69ef(%rip), %rsi      # 0xf6f0
movq 0x7298(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8d1c
jmp 0x8d38
jmp 0x8d1c
jmp 0x8d38
jmp 0x8d1c
jmp 0x8d38
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x8d3e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42c0
jmp 0x8d3e
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x8d4b
movq %rbx, %rdi
callq 0x41e0
movq %r14, %rdi
callq 0x4550
nop