// File: /workspace/github_cpp_makefile_star2_O3/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 0x8b66
movl $0x2f, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8bc8
movb $0x55, %al
outb %al, $0x2e
movb $0x20, %al
outb %al, $0x2e
inb $0x2f, %al
cmpl $0x0, 0x79e8(%rip)      # 0x10350
je 0x8a22
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testq %rax, %rax
je 0x899d
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movq 0x7620(%rip), %rdi      # 0xffb0
movq %r14, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x89bb
movq 0x760c(%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 0x75ee(%rip), %r14      # 0xffb0
leaq 0x3178(%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 0x2cf6(%rip), %rsi      # 0xb70b
movl $0x1, %edx
movq %rax, %rdi
callq 0x4310
movb $0x26, %al
outb %al, $0x2e
inb $0x2f, %al
cmpb $0x4e, %al
jne 0x8a88
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, 0x78f7(%rip)      # 0x10350
je 0x8aca
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testq %rax, %rax
je 0x8a94
movq %rax, %r14
movq %rax, %rdi
callq 0x4130
movq 0x7535(%rip), %rdi      # 0xffb0
movq %r14, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x8ab2
movl $0x2e, %ebp
movl $0x2f, %ecx
jmp 0x8b10
movq 0x7515(%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 0x74f7(%rip), %rdi      # 0xffb0
leaq 0x308d(%rip), %rsi      # 0xbb4d
movl $0xd, %edx
callq 0x4310
movl $0x4e, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8c2a
movl $0x4f, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0x44b0
testl %eax, %eax
jne 0x8c89
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 0x2f9f(%rip), %rsi      # 0xbb22
leaq 0x2f9e(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e90
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be6
xorl %ebp, %ebp
leaq 0x6bcc(%rip), %rsi      # 0xf780
movq 0x73e5(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8ce6
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2f3d(%rip), %rsi      # 0xbb22
leaq 0x2f3c(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e90
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be6
xorl %ebp, %ebp
leaq 0x6b6a(%rip), %rsi      # 0xf780
movq 0x7383(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8ce6
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2edb(%rip), %rsi      # 0xbb22
leaq 0x2eda(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e90
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be6
xorl %ebp, %ebp
leaq 0x6b08(%rip), %rsi      # 0xf780
movq 0x7321(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8ce6
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2e7c(%rip), %rsi      # 0xbb22
leaq 0x2e7b(%rip), %rdx      # 0xbb28
leaq 0x8(%rsp), %rdi
callq 0x5e90
callq 0x4030
movl (%rax), %edx
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be6
xorl %ebp, %ebp
leaq 0x6aa9(%rip), %rsi      # 0xf780
movq 0x72c2(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
jmp 0x8cf2
jmp 0x8d13
jmp 0x8cf2
jmp 0x8d13
jmp 0x8cf2
jmp 0x8d13
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x8d0c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42c0
testb %bpl, %bpl
jne 0x8d16
jmp 0x8d1e
movq %rax, %r14
movq %rbx, %rdi
callq 0x41e0
movq %r14, %rdi
callq 0x4550