// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: wakeup_nortel()
void wakeup_nortel()
{
int row, col;
unsigned c;

   // try to wake up the Nortel NTGS/NTPX/NTBW units

   if(sim_file) return;
   try_nortel = 0;
   saw_nortel = 0;
   if(PALISADE) return;
   if(SV6_FAMILY) return;
   if(nortel != 1) return;  

   try_nortel = 0xFF;
   wakeup_tsip_msg = 0;
   waking = 1;

   col = 0;
   row = 1;
   while(wakeup_tsip_msg == 0) {
      vidstr(row,col, RED, "*");
      refresh_page();
      ++col;

      SetDtrLine(RCVR_PORT, 1);
      if(NO_SCPI_BREAK && (rcvr_type == SCPI_RCVR)) ; 
      else SendBreak(RCVR_PORT);

      request_sig_levels();           // 0x27
      request_rcvr_health();          // 0x26
      request_sat_list();             // 0x24
      request_sat_status(0x00);       // 0x3C
      request_gps_time();             // 0x21
      request_io_options();           // 0x35
//    request_hw_ver();               // 1C 03
//    request_unk_ver();              // 1C 02
      request_version();              // 1F
      request_rcvr_config(4);         // BB 00
      request_filter_config();        // 70
      set_health_config(0x03, 0x00);  // 39 03 00
      request_c2();                   // C2
      request_7A_00();                // 7A 00
      request_datum();                // 8E 15
      Sleep(500);

      if(1 && com[RCVR_PORT].process_com) {
         loopy:
         abort_wakeup();
         if(SERIAL_DATA_AVAILABLE(RCVR_PORT)) {
            while(SERIAL_DATA_AVAILABLE(RCVR_PORT)) {
               c = get_com_char();
               while(c == DLE) {
                  if(SERIAL_DATA_AVAILABLE(RCVR_PORT) == 0) {
                     Sleep(100);
                  }
                  if(SERIAL_DATA_AVAILABLE(RCVR_PORT) == 0) {
                     goto loopy;
                  }
                  c = get_com_char();
                  if(c == ETX) goto etx_seen;
                  abort_wakeup();
               }
               abort_wakeup();
            }
            Sleep(100);
            goto loopy;
         }
         abort_wakeup();
         continue;
      }

      etx_seen:
      get_pending_gps(2);
      abort_wakeup();
   }

   waking = 0;
// set_pps_mode(RATE_1PPS);  // 1pps mode
// request_pps_mode();
}

// Assembly:
leaq 0x1bf1cf(%rip), %rax    # 0x23e3c0
cmpq $0x0, (%rax)
je 0x7f1f8
retq
xorl %eax, %eax
movb %al, 0x2ecc1c(%rip)     # 0x36be1c
leaq 0x1bfd33(%rip), %rcx    # 0x23ef3a
movb %al, (%rcx)
leaq 0x1996c0(%rip), %rax    # 0x2188d0
movq (%rax), %rcx
cmpq $0x1, %rcx
sete %dl
leaq 0x19bdb3(%rip), %rax    # 0x21afd4
movl (%rax), %eax
cmpl $0x50, %eax
sete %sil
testb %sil, %dl
jne 0x7f1f7
cmpq $0x1, %rcx
jne 0x7f247
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x7f247
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jb 0x7f1f7
leaq 0x1bfceb(%rip), %rax    # 0x23ef39
cmpb $0x1, (%rax)
jne 0x7f1f7
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $-0x1, 0x2ecbb4(%rip)   # 0x36be1c
leaq 0x1bfd29(%rip), %r12    # 0x23ef98
movq $0x0, (%r12)
movb $0x1, 0x2ecb9f(%rip)    # 0x36be1d
xorl %ebx, %ebx
leaq 0x9c48b(%rip), %r14     # 0x11b712
leaq 0x28f052(%rip), %r13    # 0x30e2e0
movl $0x1, %edi
movl %ebx, %esi
movl $0xc, %edx
movq %r14, %rcx
callq 0xe7d0
callq 0xab5f
movl $0xa, %edi
movl $0x1, %esi
callq 0xaeba
movl $0xa, %edi
callq 0xaf8f
callq 0x66423
callq 0x611e9
callq 0x6627a
xorl %edi, %edi
callq 0x69815
callq 0x663e9
callq 0x6851a
callq 0x659e2
movl $0x4, %edi
callq 0x66617
callq 0x69afd
movl $0x3, %edi
xorl %esi, %esi
callq 0x6873c
callq 0x610ef
callq 0x61144
callq 0x6a80b
movl $0x1f4, %edi            # imm = 0x1F4
callq 0xaff7
cmpl $0x0, 0x179f4(%r13)
je 0x7f39f
callq 0x1cd6d
movl $0xa, %edi
callq 0xb9c3
testl %eax, %eax
je 0x7f3a9
movl $0xa, %edi
callq 0xb9c3
testl %eax, %eax
je 0x7f393
callq 0x584d5
cmpl $0x10, %eax
jne 0x7f38c
movl $0xa, %edi
callq 0xb9c3
testl %eax, %eax
jne 0x7f366
movl $0x64, %edi
callq 0xaff7
movl $0xa, %edi
callq 0xb9c3
testl %eax, %eax
je 0x7f323
callq 0x584d5
cmpl $0x3, %eax
je 0x7f39f
movl %eax, %r15d
callq 0x1cd6d
cmpl $0x10, %r15d
je 0x7f34e
callq 0x1cd6d
jmp 0x7f336
movl $0x64, %edi
callq 0xaff7
jmp 0x7f323
movl $0x2, %edi
callq 0x1cca5
incl %ebx
callq 0x1cd6d
cmpq $0x0, (%r12)
je 0x7f28e
movb $0x0, 0x2eca5b(%rip)    # 0x36be1d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq