// File: /workspace/github_cpp_makefile_star2_O3/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 0x1bf394(%rip), %rax    # 0x23e3c0
cmpq $0x0, (%rax)
je 0x7f033
retq
xorl %eax, %eax
movb %al, 0x2ecde1(%rip)     # 0x36be1c
leaq 0x1bfef8(%rip), %rcx    # 0x23ef3a
movb %al, (%rcx)
leaq 0x199885(%rip), %rax    # 0x2188d0
movq (%rax), %rcx
cmpq $0x1, %rcx
sete %dl
leaq 0x19bf78(%rip), %rax    # 0x21afd4
movl (%rax), %eax
cmpl $0x50, %eax
sete %sil
testb %sil, %dl
jne 0x7f032
cmpq $0x1, %rcx
jne 0x7f082
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x7f082
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jb 0x7f032
leaq 0x1bfeb0(%rip), %rax    # 0x23ef39
cmpb $0x1, (%rax)
jne 0x7f032
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $-0x1, 0x2ecd79(%rip)   # 0x36be1c
leaq 0x1bfeee(%rip), %r12    # 0x23ef98
movq $0x0, (%r12)
movb $0x1, 0x2ecd64(%rip)    # 0x36be1d
xorl %ebx, %ebx
leaq 0x9c6e4(%rip), %r14     # 0x11b7a6
leaq 0x28f217(%rip), %r13    # 0x30e2e0
movl $0x1, %edi
movl %ebx, %esi
movl $0xc, %edx
movq %r14, %rcx
callq 0xe787
callq 0xab54
movl $0xa, %edi
movl $0x1, %esi
callq 0xaeab
movl $0xa, %edi
callq 0xaf80
callq 0x66646
callq 0x61195
callq 0x6649d
xorl %edi, %edi
callq 0x699e2
callq 0x6660c
callq 0x687a7
callq 0x65c0d
movl $0x4, %edi
callq 0x667f2
callq 0x69c96
movl $0x3, %edi
xorl %esi, %esi
callq 0x68981
callq 0x610e4
callq 0x61139
callq 0x6a96b
movl $0x1f4, %edi            # imm = 0x1F4
callq 0xafe8
cmpl $0x0, 0x179f4(%r13)
je 0x7f1da
callq 0x1cdac
movl $0xa, %edi
callq 0xb9ad
testl %eax, %eax
je 0x7f1e4
movl $0xa, %edi
callq 0xb9ad
testl %eax, %eax
je 0x7f1ce
callq 0x584bd
cmpl $0x10, %eax
jne 0x7f1c7
movl $0xa, %edi
callq 0xb9ad
testl %eax, %eax
jne 0x7f1a1
movl $0x64, %edi
callq 0xafe8
movl $0xa, %edi
callq 0xb9ad
testl %eax, %eax
je 0x7f15e
callq 0x584bd
cmpl $0x3, %eax
je 0x7f1da
movl %eax, %r15d
callq 0x1cdac
cmpl $0x10, %r15d
je 0x7f189
callq 0x1cdac
jmp 0x7f171
movl $0x64, %edi
callq 0xafe8
jmp 0x7f15e
movl $0x2, %edi
callq 0x1cce4
incl %ebx
callq 0x1cdac
cmpq $0x0, (%r12)
je 0x7f0c9
movb $0x0, 0x2ecc20(%rip)    # 0x36be1d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq