// File: /workspace/github_cpp_makefile_star2_O2/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 0x1b486f(%rip), %rax    # 0x2283c0
cmpq $0x0, (%rax)
je 0x73b58
retq
xorl %eax, %eax
movb %al, 0x2e22bc(%rip)     # 0x355e1c
leaq 0x1b53d3(%rip), %rcx    # 0x228f3a
movb %al, (%rcx)
leaq 0x18ed60(%rip), %rax    # 0x2028d0
movq (%rax), %rcx
cmpq $0x1, %rcx
sete %dl
leaq 0x191453(%rip), %rax    # 0x204fd4
movl (%rax), %eax
cmpl $0x50, %eax
sete %sil
testb %sil, %dl
jne 0x73b57
cmpq $0x1, %rcx
jne 0x73ba7
addl $-0x33, %eax
cmpl $0x1d, %eax
ja 0x73ba7
movl $0x20004009, %ecx       # imm = 0x20004009
btl %eax, %ecx
jb 0x73b57
leaq 0x1b538b(%rip), %rax    # 0x228f39
cmpb $0x1, (%rax)
jne 0x73b57
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $-0x1, 0x2e2254(%rip)   # 0x355e1c
leaq 0x1b53c9(%rip), %rax    # 0x228f98
andq $0x0, (%rax)
movb $0x1, 0x2e2243(%rip)    # 0x355e1d
xorl %eax, %eax
pushq $0x1
popq %r14
pushq $0xa
popq %r12
pushq $0x64
popq %r15
xorl %r13d, %r13d
testq %rax, %rax
jne 0x73d12
movl %r14d, %edi
movl %r13d, %esi
pushq $0xc
popq %rdx
leaq 0x91c22(%rip), %rcx     # 0x105826
callq 0xe2d2
callq 0xaa05
movl %r12d, %edi
movl %r14d, %esi
callq 0xad58
movl %r12d, %edi
callq 0xae2d
callq 0x5dffd
callq 0x595d4
callq 0x5de9d
xorl %edi, %edi
callq 0x60ca1
callq 0x5dfc5
callq 0x5fc1e
callq 0x5d7c2
pushq $0x4
popq %rdi
callq 0x5e18e
callq 0x60f41
pushq $0x3
popq %rdi
xorl %esi, %esi
callq 0x5fdea
callq 0x59525
callq 0x5957a
callq 0x61a66
movl $0x1f4, %edi            # imm = 0x1F4
callq 0xae83
leaq 0x284663(%rip), %rax    # 0x2f82e0
cmpl $0x0, 0x179f4(%rax)
je 0x73cf3
callq 0x1be68
movl %r12d, %edi
callq 0xb771
testl %eax, %eax
je 0x73cfb
movl %r12d, %edi
callq 0xb771
testl %eax, %eax
je 0x73ce9
callq 0x51891
movl %eax, %ebx
cmpl $0x10, %ebx
jne 0x73ce2
movl %r12d, %edi
callq 0xb771
testl %eax, %eax
jne 0x73cc3
movl %r15d, %edi
callq 0xae83
movl %r12d, %edi
callq 0xb771
testl %eax, %eax
je 0x73c86
callq 0x51891
cmpl $0x3, %eax
je 0x73cf3
movl %eax, %ebx
callq 0x1be68
jmp 0x73caa
callq 0x1be68
jmp 0x73c97
movl %r15d, %edi
callq 0xae83
jmp 0x73c86
pushq $0x2
popq %rdi
callq 0x1bdb5
incl %r13d
callq 0x1be68
leaq 0x1b528e(%rip), %rax    # 0x228f98
movq (%rax), %rax
jmp 0x73beb
movb $0x0, 0x2e2104(%rip)    # 0x355e1d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq