Guest User

Xikestor SKS8300-8T Reversed code

a guest
Jun 24th, 2025
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 58.06 KB | None | 0 0
  1.  
  2. uint _phy_826xb_serdes_mode_init(int param_1,int param_2)
  3.  
  4. {
  5.   uint uVar1;
  6.   int iVar2;
  7.   undefined4 *puVar3;
  8.   uint local_18 [3];
  9.  
  10.   local_18[0] = 0;
  11.   uVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x105,local_18);
  12.   if (uVar1 == 0) {
  13.     puVar3 = (undefined4 *)(*(int *)(rtl826xb_info + param_1 * 4) + param_2 * 4);
  14.     if ((local_18[0] & 1) == 0) {
  15.       *puVar3 = 0;
  16.     }
  17.     else {
  18.       *puVar3 = 0xffff;
  19.     }
  20.     iVar2 = _phy_826xb_sdsReg_write(param_1,param_2,6,3,0xf,0,0x88c6);
  21.     uVar1 = (uint)(iVar2 != 0);
  22.   }
  23.   return uVar1;
  24. }
  25.  
  26.  
  27. int _phy_826xb_serdes_reg_read
  28.               (undefined4 param_1,undefined4 param_2,uint param_3,uint param_4,undefined4 *param_5)
  29.  
  30. {
  31.   int iVar1;
  32.   int iVar2;
  33.   undefined4 local_20;
  34.   uint local_1c [2];
  35.  
  36.   local_1c[0] = param_3 & 0x3f | (param_4 & 0x1f) << 6 | 0x8000;
  37.   local_20 = 0;
  38.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x143,local_1c[0]);
  39.   iVar2 = 10;
  40.   if (iVar1 == 0) {
  41.     while (iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x143,local_1c), iVar1 == 0)
  42.     {
  43.       if ((local_1c[0] & 0x8000) == 0) {
  44.         iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x142,&local_20);
  45.         if (iVar1 != 0) {
  46.           return iVar1;
  47.         }
  48.         *param_5 = local_20;
  49.         return 0;
  50.       }
  51.       iVar2 = iVar2 + -1;
  52.       osal_time_udelay(10);
  53.       if (iVar2 == 0) {
  54.         return 0xf01f;
  55.       }
  56.     }
  57.   }
  58.   return iVar1;
  59. }
  60.  
  61.  
  62. void _phy_826xb_serdes_reg_write
  63.                (undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
  64.                undefined4 param_5)
  65.  
  66. {
  67.   int iVar1;
  68.  
  69.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x141,param_5);
  70.   if (iVar1 == 0) {
  71.                     /* WARNING: Could not recover jumptable at 0x00b9c708. Too many branches */
  72.                     /* WARNING: Treating indirect jump as call */
  73.     phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x143);
  74.     return;
  75.   }
  76.   return;
  77. }
  78.  
  79. int _phy_826xb_serdes_mode_power_off_set(undefined4 param_1,undefined4 param_2)
  80.  
  81. {
  82.   int iVar1;
  83.  
  84.   iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0xc2,4,0,0x1f);
  85.   if (iVar1 == 0) {
  86.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0xc6,4,0,0x1f);
  87.     if (iVar1 == 0) {
  88.       iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0xc5,4,0,0x1f);
  89.       if (iVar1 == 0) {
  90.         iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0xc4,4,0,0x1f);
  91.         if (iVar1 == 0) {
  92.           iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0xc3,4,0,0x1f);
  93.           if (iVar1 == 0) {
  94.             osal_time_udelay(100000);
  95.           }
  96.         }
  97.       }
  98.     }
  99.   }
  100.   return iVar1;
  101. }
  102.  
  103.  
  104. void _phy_826xb_serdes_mode_usxgmii_set(undefined4 param_1,undefined4 param_2)
  105.  
  106. {
  107.   int iVar1;
  108.   uint local_18 [2];
  109.  
  110.   local_18[0] = 0;
  111.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x105,local_18);
  112.   if (iVar1 == 0) {
  113.     local_18[0] = local_18[0] & 0xfffffffe;
  114.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x105,local_18[0]);
  115.     if (iVar1 == 0) {
  116.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0xc2,local_18);
  117.       if (iVar1 == 0) {
  118.         local_18[0] = local_18[0] & 0xfffffc00 | 0xd;
  119.         iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0xc2,local_18[0]);
  120.         if (iVar1 == 0) {
  121.           iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x3f1,local_18);
  122.           if (iVar1 == 0) {
  123.             local_18[0] = local_18[0] & 0xffff0000 | 0x72;
  124.             iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x3f1,local_18[0]);
  125.             if (iVar1 == 0) {
  126.               iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x2a2,local_18);
  127.               if (iVar1 == 0) {
  128.                 local_18[0] = local_18[0] & 0xffffff7f;
  129.                 phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x2a2,local_18[0]);
  130.               }
  131.             }
  132.           }
  133.         }
  134.       }
  135.     }
  136.   }
  137.   return;
  138. }
  139.  
  140.  
  141. void _phy_826xb_serdes_mode_10gr_set(undefined4 param_1,undefined4 param_2)
  142.  
  143. {
  144.   int iVar1;
  145.   uint local_18 [2];
  146.  
  147.   local_18[0] = 0;
  148.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x105,local_18);
  149.   if (iVar1 == 0) {
  150.     local_18[0] = local_18[0] | 1;
  151.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x105,local_18[0]);
  152.     if (iVar1 == 0) {
  153.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0xc6,local_18);
  154.       if (iVar1 == 0) {
  155.         local_18[0] = local_18[0] & 0xffffffe0 | 0x1a;
  156.         iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0xc6,local_18[0]);
  157.         if (iVar1 == 0) {
  158.           iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0xc2,local_18);
  159.           if (iVar1 == 0) {
  160.             local_18[0] = local_18[0] & 0xfffffc1f;
  161.             iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0xc2,local_18[0]);
  162.             if (iVar1 == 0) {
  163.               iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x2a2,local_18);
  164.               if (iVar1 == 0) {
  165.                 local_18[0] = local_18[0] & 0xffffff7f;
  166.                 phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x2a2,local_18[0]);
  167.               }
  168.             }
  169.           }
  170.         }
  171.       }
  172.     }
  173.   }
  174.   return;
  175. }
  176.  
  177.  
  178. void _phy_826xb_serdes_mode_sgmii_set(undefined4 param_1,undefined4 param_2)
  179.  
  180. {
  181.   int iVar1;
  182.   uint local_18 [2];
  183.  
  184.   local_18[0] = 0;
  185.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x105,local_18);
  186.   if (iVar1 == 0) {
  187.     local_18[0] = local_18[0] | 1;
  188.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x105,local_18[0]);
  189.     if (iVar1 == 0) {
  190.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0xc3,local_18);
  191.       if (iVar1 == 0) {
  192.         local_18[0] = local_18[0] & 0xfffffff0 | 2;
  193.         iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0xc3,local_18[0]);
  194.         if (iVar1 == 0) {
  195.           iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0xc2,local_18);
  196.           if (iVar1 == 0) {
  197.             local_18[0] = local_18[0] & 0xfffffc1f;
  198.             iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0xc2,local_18[0]);
  199.             if (iVar1 == 0) {
  200.               iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x2a2,local_18);
  201.               if (iVar1 == 0) {
  202.                 local_18[0] = local_18[0] & 0xffffff7f;
  203.                 phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x2a2,local_18[0]);
  204.               }
  205.             }
  206.           }
  207.         }
  208.       }
  209.     }
  210.   }
  211.   return;
  212. }
  213.  
  214.  
  215. int _phy_826xb_serdes_mode_set(int param_1,int param_2,uint param_3)
  216.  
  217. {
  218.   int iVar1;
  219.   code *pcVar2;
  220.  
  221.   if (param_3 == 0x1001) {
  222.     iVar1 = _phy_826xb_serdes_mode_10gr_set();
  223.     if (iVar1 != 0) {
  224.       return iVar1;
  225.     }
  226.     pcVar2 = _phy_826xb_serdes_mode_5gx_set;
  227. LAB_00ba4f34:
  228.     iVar1 = (*pcVar2)(param_1,param_2);
  229.     if (iVar1 != 0) {
  230.       return iVar1;
  231.     }
  232.     pcVar2 = _phy_826xb_serdes_mode_2p5gx_set;
  233.   }
  234.   else {
  235.     if (param_3 < 0x1002) {
  236.       if (param_3 == 0) {
  237.         pcVar2 = _phy_826xb_serdes_mode_usxgmii_set;
  238.       }
  239.       else {
  240.         if (param_3 != 0xff) {
  241.           return 0xf001;
  242.         }
  243.         pcVar2 = _phy_826xb_serdes_mode_power_off_set;
  244.       }
  245.       goto LAB_00ba4e6c;
  246.     }
  247.     if ((param_3 == 0x1101) || (param_3 == 0x1102)) {
  248.       iVar1 = _phy_826xb_serdes_mode_10gr_set();
  249.       if (iVar1 != 0) {
  250.         return iVar1;
  251.       }
  252.       pcVar2 = _phy_826xb_serdes_mode_5g_off_set;
  253.       goto LAB_00ba4f34;
  254.     }
  255.     if (param_3 != 0x1002) {
  256.       return 0xf001;
  257.     }
  258.     iVar1 = _phy_826xb_serdes_mode_10gr_set();
  259.     if (iVar1 != 0) {
  260.       return iVar1;
  261.     }
  262.     iVar1 = _phy_826xb_serdes_mode_xfi_5g_adapt_set(param_1,param_2);
  263.     if (iVar1 != 0) {
  264.       return iVar1;
  265.     }
  266.     pcVar2 = _phy_826xb_serdes_mode_xfi_2p5g_adapt_set;
  267.   }
  268.   iVar1 = (*pcVar2)(param_1,param_2);
  269.   if (iVar1 != 0) {
  270.     return iVar1;
  271.   }
  272.   pcVar2 = _phy_826xb_serdes_mode_sgmii_set;
  273. LAB_00ba4e6c:
  274.   iVar1 = (*pcVar2)(param_1,param_2);
  275.   if (iVar1 == 0) {
  276.     *(uint *)(*(int *)(rtl826xb_info + param_1 * 4) + param_2 * 4) = param_3;
  277.     iVar1 = 0;
  278.   }
  279.   return iVar1;
  280. }
  281.  
  282.  
  283. undefined4
  284. hal_miim_mmd_write(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
  285.                   undefined4 param_5)
  286.  
  287. {
  288.   int iVar1;
  289.   undefined4 uVar2;
  290.   code *UNRECOVERED_JUMPTABLE;
  291.  
  292.   rt_log(8,param_2,0,0x10000,"unit=%d, port=%d, mmdAddr=0x%x, mmdReg=0x%x            data=0x%x",
  293.          param_1,param_2,param_3,param_4,param_5);
  294.   iVar1 = hal_ctrlInfo_get(param_1);
  295.   if (iVar1 == 0) {
  296.     uVar2 = 0xffffffff;
  297.   }
  298.   else {
  299.     UNRECOVERED_JUMPTABLE = *(code **)(*(int *)(*(int *)(iVar1 + 4) + 0x18) + 0x28);
  300.     if (UNRECOVERED_JUMPTABLE != (code *)0x0) {
  301.                     /* WARNING: Could not recover jumptable at 0x007065d4. Too many branches */
  302.                     /* WARNING: Treating indirect jump as call */
  303.       uVar2 = (*UNRECOVERED_JUMPTABLE)(param_1,param_2,param_3,param_4);
  304.       return uVar2;
  305.     }
  306.     uVar2 = 0xf00d;
  307.   }
  308.   return uVar2;
  309. }
  310.  
  311.  
  312. void _phy_826xb_serdes_loopback_set(undefined4 param_1,undefined4 param_2,int param_3)
  313.  
  314. {
  315.   int iVar1;
  316.   undefined4 uVar2;
  317.   int local_18 [2];
  318.  
  319.   if (param_3 == 0) {
  320.     uVar2 = 0;
  321. LAB_00bacf44:
  322.     iVar1 = _phy_826xb_sdsReg_write(param_1,param_2,4,0,0xe,0xe,uVar2);
  323.     if (iVar1 != 0) {
  324.       return;
  325.     }
  326.     uVar2 = 0;
  327.   }
  328.   else {
  329.     iVar1 = phy_826xb_macIntfSerdesMode_get(param_1,param_2,local_18);
  330.     if (iVar1 != 0) {
  331.       return;
  332.     }
  333.     if ((local_18[0] != 0x1a) && (local_18[0] != 0x25)) {
  334.       if (local_18[0] == 8) {
  335.         iVar1 = _phy_826xb_sdsReg_write(param_1,param_2,4,0,0xe,0xe,0);
  336.         if (iVar1 != 0) {
  337.           return;
  338.         }
  339.         iVar1 = _phy_826xb_sdsReg_write(param_1,param_2,2,0,0xe,0xe,0);
  340.         if (iVar1 != 0) {
  341.           return;
  342.         }
  343.         uVar2 = 1;
  344.         goto LAB_00bacf94;
  345.       }
  346.       uVar2 = 1;
  347.       goto LAB_00bacf44;
  348.     }
  349.     iVar1 = _phy_826xb_sdsReg_write(param_1,param_2,4,0,0xe,0xe,0);
  350.     if (iVar1 != 0) {
  351.       return;
  352.     }
  353.     uVar2 = 1;
  354.   }
  355.   iVar1 = _phy_826xb_sdsReg_write(param_1,param_2,2,0,0xe,0xe,uVar2);
  356.   if (iVar1 != 0) {
  357.     return;
  358.   }
  359.   uVar2 = 0;
  360. LAB_00bacf94:
  361.   _phy_826xb_sdsReg_write(param_1,param_2,0,0,4,4,uVar2);
  362.   return;
  363. }
  364.  
  365.  
  366. /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
  367.  
  368. undefined4 _dal_phy_macIntfSerdes_reset(int param_1,undefined4 param_2)
  369.  
  370. {
  371.   int iVar1;
  372.   undefined4 uVar2;
  373.   undefined4 uVar3;
  374.   undefined4 uVar4;
  375.  
  376.   if (*(int *)(&DAT_012b2b40 + param_1 * 4) != 1) {
  377.     return 0xf00f;
  378.   }
  379.   iVar1 = osal_sem_mutex_take(*(undefined4 *)(&DAT_012b2b00 + param_1 * 4),0xffffffff);
  380.   if (iVar1 == 0) {
  381.     uVar3 = phy_serdes_rst(param_1,param_2);
  382.     iVar1 = osal_sem_mutex_give(*(undefined4 *)(&DAT_012b2b00 + param_1 * 4));
  383.     if (iVar1 == 0) {
  384.       return uVar3;
  385.     }
  386.     iVar1 = rt_log(2);
  387.     uVar3 = 0xf014;
  388.     if (iVar1 != 0) {
  389.       return 0xf014;
  390.     }
  391.     uVar4 = 0xf014;
  392.     uVar2 = 0x1ca7;
  393.   }
  394.   else {
  395.     iVar1 = rt_log(2);
  396.     uVar3 = 0xf013;
  397.     if (iVar1 != 0) {
  398.       return 0xf013;
  399.     }
  400.     uVar4 = 0xf013;
  401.     uVar2 = 0x1ca3;
  402.   }
  403.   fprintf(_stderr,"*** [RT_ERR] %s:%d: In function \'%s\'\n             Error Code: 0x%X\n\n",
  404.           "dal/dal_phy.c",uVar2,"_dal_phy_macIntfSerdes_reset",uVar4);
  405.   return uVar3;
  406. }
  407.  
  408.  
  409. void _dal_phy_serdesLinkDown_handler(int param_1)
  410.  
  411. {
  412.   undefined1 uVar1;
  413.   int iVar2;
  414.   int *piVar3;
  415.   uint uVar4;
  416.   uint *puVar5;
  417.   uint uVar6;
  418.   int local_28 [3];
  419.  
  420.   piVar3 = (int *)(&DAT_012b26a0 + param_1 * 0x40);
  421.   uVar4 = 0;
  422.   puVar5 = (uint *)(phySerdes_watchdog_cnt + param_1 * 4);
  423.   do {
  424.     if (*(byte *)(*(int *)((&unitMapStruct)[param_1 * 2] + 0x824) + 0x58c) <= uVar4) {
  425.       return;
  426.     }
  427.     iVar2 = *(int *)((&unitMapStruct)[param_1 * 2] + 0x824) + uVar4 * 8;
  428.     uVar6 = *(uint *)(iVar2 + 0x590);
  429.     if (((uVar6 == 0x11) || ((uVar6 & 0xfffffffb) == 9)) || (uVar6 == 0x16)) {
  430.       uVar1 = *(undefined1 *)(iVar2 + 0x595);
  431.       local_28[0] = 0;
  432.       iVar2 = phy_serdes_linkdown_check(param_1,uVar1,local_28);
  433.       if (iVar2 != 0) {
  434.         return;
  435.       }
  436.       if (local_28[0] == 1) {
  437.         iVar2 = *piVar3;
  438.         *piVar3 = iVar2 + 1;
  439.         if (iVar2 + 1 != 5) goto LAB_00b2cc70;
  440.         if (*puVar5 + 1 < 0x40) {
  441.           *puVar5 = *puVar5 + 1;
  442.         }
  443.         else {
  444.           *puVar5 = 0;
  445.         }
  446.         phy_serdes_rst(param_1,uVar1);
  447.       }
  448.       *piVar3 = 0;
  449.     }
  450. LAB_00b2cc70:
  451.     uVar4 = uVar4 + 1;
  452.     piVar3 = piVar3 + 1;
  453.   } while( true );
  454. }
  455.  
  456.  
  457. void dal_longan_construct_serdesRxauiplus_initial(int param_1,uint param_2)
  458.  
  459. {
  460.   int iVar1;
  461.  
  462.   if (param_2 == *(byte *)((&unitMapStruct)[param_1 * 2] + param_2 + 0x154)) {
  463.     hal_sds_field_write(param_1,param_2,0x2d,5,1,1,1);
  464.     iVar1 = param_2 + 1;
  465.     hal_sds_field_write(param_1,iVar1,0x2d,5,1,1,1);
  466.     hal_sds_field_write(param_1,iVar1,0x2d,0x15,2,0,7);
  467.     hal_sds_field_write(param_1,iVar1,0x2d,0x15,6,5,3);
  468.     hal_sds_field_write(param_1,param_2,10,2,0xf,0xf,0);
  469.     hal_sds_field_write(param_1,iVar1,10,2,0xf,0xf,0);
  470.     hal_sds_field_write(param_1,param_2,10,0xd,9,9,1);
  471.     hal_sds_field_write(param_1,param_2,0x2d,0x10,3,3,1);
  472.     hal_sds_field_write(param_1,iVar1,0x2d,0x10,3,3,1);
  473.   }
  474.   return;
  475. }
  476.  
  477.  
  478. /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
  479.  
  480. undefined4 phy_serdes_rst(undefined4 param_1,uint param_2)
  481.  
  482. {
  483.   int iVar1;
  484.   undefined4 uVar2;
  485.   int iVar3;
  486.   code *pcVar4;
  487.  
  488.   rt_log(8,param_2,0,0x10000,"unit=%d, port=%d",param_1,param_2);
  489.   iVar1 = hal_ctrlInfo_get(param_1);
  490.   if (iVar1 == 0) {
  491.     return 0xffffffff;
  492.   }
  493.   if (0x3f < param_2) {
  494.     return 0xf030;
  495.   }
  496.   iVar1 = iVar1 + param_2 * 4;
  497.   iVar3 = *(int *)(iVar1 + 0xc);
  498.   if (iVar3 == 0) {
  499.     return 0xf030;
  500.   }
  501.   if (*(int *)(iVar3 + 0x10) == 0) {
  502.     return 0xf030;
  503.   }
  504.   iVar3 = hal_ctrlInfo_get(param_1);
  505.   if (iVar3 == 0) {
  506.     return 0xffffffff;
  507.   }
  508.   iVar3 = osal_sem_mutex_take(*(undefined4 *)(iVar3 + 0x144),0xffffffff);
  509.   if (iVar3 != 0) {
  510.     iVar1 = rt_log(2);
  511.     if (iVar1 != 0) {
  512.       return 0xffffffff;
  513.     }
  514.     uVar2 = 0x14a3;
  515.     goto LAB_00bf3dfc;
  516.   }
  517.   switch(**(undefined4 **)(*(int *)(iVar1 + 0xc) + 0x10)) {
  518.   case 10:
  519.     pcVar4 = phy_8214fc_serdes_reset;
  520.     break;
  521.   default:
  522.     goto switchD_00bf3d08_caseD_b;
  523.   case 0xc:
  524.     pcVar4 = phy_8218d_macIntfSerdes_reset;
  525.     break;
  526.   case 0x13:
  527.     pcVar4 = phy_8295r_macIntfSerdes_reset;
  528.     break;
  529.   case 0x14:
  530.     pcVar4 = phy_8214qf_macIntfSerdes_reset;
  531.     break;
  532.   case 0x18:
  533.     pcVar4 = phy_8218e_macIntfSerdes_reset;
  534.   }
  535.   (*pcVar4)(param_1,param_2);
  536. switchD_00bf3d08_caseD_b:
  537.   iVar1 = hal_ctrlInfo_get(param_1);
  538.   if (iVar1 == 0) {
  539.     return 0xffffffff;
  540.   }
  541.   iVar1 = osal_sem_mutex_give(*(undefined4 *)(iVar1 + 0x144));
  542.   if (iVar1 == 0) {
  543.     return 0;
  544.   }
  545.   iVar1 = rt_log(2);
  546.   if (iVar1 != 0) {
  547.     return 0xffffffff;
  548.   }
  549.   uVar2 = 0x14cf;
  550. LAB_00bf3dfc:
  551.   fprintf(_stderr,"*** [RT_ERR] %s:%d: In function \'%s\'\n             Error Code: 0x%X\n\n",
  552.           "hal/common/miim.c",uVar2,"phy_serdes_rst",0xffffffff);
  553.   return 0xffffffff;
  554. }
  555.  
  556.  
  557. int _phy_826xb_serdes_mode_update(undefined4 param_1,undefined4 param_2)
  558.  
  559. {
  560.   int iVar1;
  561.   code *pcVar2;
  562.   undefined4 local_20;
  563.   int local_1c;
  564.   uint local_18 [3];
  565.  
  566.   local_18[0] = 0xffff;
  567.   iVar1 = _phy_826xb_serdes_mode_get(param_1,param_2,local_18);
  568.   if (iVar1 != 0) {
  569.     return iVar1;
  570.   }
  571.   if ((local_18[0] & 0x100) == 0) {
  572.     return 0;
  573.   }
  574.   iVar1 = _phy_826xb_realTime_linkStatus_get(param_1,param_2,&local_1c);
  575.   if (iVar1 != 0) {
  576.     return iVar1;
  577.   }
  578.   if (local_1c == 0) {
  579.     return 0;
  580.   }
  581.   iVar1 = phy_common_c45_speedStatusResReg_get(param_1,param_2,&local_20);
  582.   if (iVar1 != 0) {
  583.     return iVar1;
  584.   }
  585.   if (local_18[0] != 0x1101) {
  586.     if (local_18[0] != 0x1102) {
  587.       return 0xf00f;
  588.     }
  589.     switch(local_20) {
  590.     case 1:
  591.     case 2:
  592. switchD_00ba56a0_caseD_1:
  593.       pcVar2 = _phy_826xb_serdes_mode_sgmii_set;
  594.       break;
  595.     default:
  596. LAB_00ba56f8:
  597.       return 0;
  598.     case 5:
  599.     case 9:
  600. switchD_00ba56a0_caseD_5:
  601.       pcVar2 = _phy_826xb_serdes_mode_2p5gx_set;
  602.       break;
  603.     case 6:
  604.     case 10:
  605.       pcVar2 = _phy_826xb_serdes_mode_xfi_5g_cpri_set;
  606.       break;
  607.     case 7:
  608. switchD_00ba56a0_caseD_7:
  609.       pcVar2 = _phy_826xb_serdes_mode_10gr_set;
  610.     }
  611. LAB_00ba56e4:
  612.     iVar1 = (*pcVar2)(param_1,param_2);
  613.     return iVar1;
  614.   }
  615.   switch(local_20) {
  616.   case 1:
  617.   case 2:
  618.     goto switchD_00ba56a0_caseD_1;
  619.   default:
  620.     goto LAB_00ba56f8;
  621.   case 5:
  622.   case 9:
  623.     goto switchD_00ba56a0_caseD_5;
  624.   case 6:
  625.   case 10:
  626.     pcVar2 = _phy_826xb_serdes_mode_5gr_set;
  627.     goto LAB_00ba56e4;
  628.   case 7:
  629.     goto switchD_00ba56a0_caseD_7;
  630.   }
  631. }
  632.  
  633. int _phy_identify_default_c45(undefined4 param_1,undefined4 param_2,uint param_3,uint param_4)
  634.  
  635. {
  636.   int iVar1;
  637.   int iVar2;
  638.   uint local_20;
  639.   undefined4 local_1c;
  640.  
  641.   local_1c = 0;
  642.   local_20 = 0;
  643.   iVar1 = hal_ctrlInfo_get();
  644.   if (iVar1 != 0) {
  645.     iVar2 = *(int *)(*(int *)(iVar1 + 4) + 0x18);
  646.     if (*(int *)(iVar2 + 4) != 0) {
  647.       (**(code **)(iVar2 + 0x24))(param_1,param_2,1,2,&local_1c);
  648.       (**(code **)(*(int *)(*(int *)(iVar1 + 4) + 0x18) + 0x24))(param_1,param_2,1,3,&local_20);
  649.       iVar1 = _phy_rtk_oui_chk(local_1c,local_20);
  650.       if (iVar1 != 0) {
  651.         rt_log(8);
  652.         rt_log(8);
  653.         return iVar1;
  654.       }
  655.       if (((local_20 & 0x3f0) >> 4 == param_3) && (param_4 <= (local_20 & 0xf))) {
  656.         return 0;
  657.       }
  658.       return 0xe000f;
  659.     }
  660.   }
  661.   return -1;
  662. }
  663.  
  664. int _phy_rtk_oui_chk(int param_1,uint param_2)
  665.  
  666. {
  667.   if (param_1 == 0x1c) {
  668.     return -(uint)(param_2 >> 10 != 0x32);
  669.   }
  670.   return -1;
  671. }
  672.  
  673. void phy_common_c45_autoNegoEnable_set(undefined4 param_1,undefined4 param_2,int param_3)
  674.  
  675. {
  676.   int iVar1;
  677.   uint uVar2;
  678.   uint local_18 [2];
  679.  
  680.   local_18[0] = 0;
  681.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,7,0,local_18);
  682.   if (iVar1 == 0) {
  683.     uVar2 = 0;
  684.     if (param_3 == 1) {
  685.       uVar2 = 0x1200;
  686.     }
  687.     local_18[0] = uVar2 | local_18[0] & 0xffffedff;
  688.     phy_common_general_reg_mmd_set(param_1,param_2,7,0,local_18[0]);
  689.   }
  690.   return;
  691. }
  692.  
  693. void phy_common_c45_autoNegoEnable_get(undefined4 param_1,undefined4 param_2,uint *param_3)
  694.  
  695. {
  696.   int iVar1;
  697.   uint local_10 [2];
  698.  
  699.   local_10[0] = 0;
  700.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,7,0,local_10);
  701.   if (iVar1 == 0) {
  702.     *param_3 = local_10[0] >> 0xc & 1;
  703.   }
  704.   return;
  705. }
  706.  
  707. int phy_common_c45_masterSlave_set(undefined4 param_1,undefined4 param_2,int param_3)
  708.  
  709. {
  710.   int iVar1;
  711.   uint uVar2;
  712.   uint local_20 [3];
  713.  
  714.   local_20[0] = 0;
  715.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,7,0x20,local_20);
  716.   if (iVar1 == 0) {
  717.     local_20[0] = local_20[0] & 0xffff3fff;
  718.     if (param_3 == 1) {
  719.       local_20[0] = local_20[0] | 0x8000;
  720.     }
  721.     else if (param_3 != 0) {
  722.       if (param_3 != 2) {
  723.         return 0xf001;
  724.       }
  725.       local_20[0] = local_20[0] | 0xc000;
  726.     }
  727.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,7,0x20,local_20[0]);
  728.     if (((iVar1 == 0) &&
  729.         (iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,7,0,local_20), iVar1 == 0)) &&
  730.        (uVar2 = local_20[0] & 0x1000, local_20[0] = local_20[0] | 0x200, uVar2 != 0)) {
  731.       iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,7,0,local_20[0]);
  732.     }
  733.   }
  734.   return iVar1;
  735. }
  736.  
  737.  
  738. int phy_common_c45_ieeeTestMode_set(undefined4 param_1,undefined4 param_2,int *param_3)
  739.  
  740. {
  741.   int iVar1;
  742.   undefined4 uVar2;
  743.   undefined4 uVar3;
  744.   undefined4 uVar4;
  745.  
  746.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1f,0xa412,0xe00);
  747.   if (iVar1 != 0) {
  748.     return iVar1;
  749.   }
  750.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,1,0x84,0x400);
  751.   if (iVar1 != 0) {
  752.     return iVar1;
  753.   }
  754.   iVar1 = *param_3;
  755.   if (iVar1 == 0x1030) {
  756.     uVar4 = 0x6400;
  757.   }
  758.   else {
  759.     if (iVar1 < 0x1031) {
  760.       if (iVar1 == 3) {
  761.         uVar4 = 0x6e00;
  762.       }
  763.       else if (iVar1 < 4) {
  764.         if (iVar1 == 1) {
  765.           uVar4 = 0x2e00;
  766.         }
  767.         else {
  768.           if (iVar1 < 2) {
  769.             if (iVar1 == 0) {
  770.               return 0;
  771.             }
  772.             return 0xf036;
  773.           }
  774.           uVar4 = 0x4e00;
  775.         }
  776.       }
  777.       else {
  778.         if (iVar1 == 0x1000) {
  779.           return 0;
  780.         }
  781.         if (0x1000 < iVar1) {
  782.           if (iVar1 == 0x1010) {
  783.             uVar4 = 0x2400;
  784.           }
  785.           else {
  786.             uVar4 = 0x4400;
  787.             if (iVar1 != 0x1020) {
  788.               return 0xf036;
  789.             }
  790.           }
  791.           goto LAB_00b36b20;
  792.         }
  793.         uVar4 = 0x8e00;
  794.         if (iVar1 != 4) {
  795.           return 0xf036;
  796.         }
  797.       }
  798.       uVar2 = 0x1f;
  799.       uVar3 = 0xa412;
  800.       goto LAB_00b36b30;
  801.     }
  802.     if (iVar1 == 0x1045) {
  803.       uVar4 = 0x9400;
  804.     }
  805.     else if (iVar1 < 0x1046) {
  806.       if (iVar1 == 0x1042) {
  807.         uVar4 = 0x8800;
  808.       }
  809.       else if (iVar1 == 0x1044) {
  810.         uVar4 = 0x9000;
  811.       }
  812.       else {
  813.         if (iVar1 != 0x1041) {
  814.           return 0xf036;
  815.         }
  816.         uVar4 = 0x8400;
  817.       }
  818.     }
  819.     else if (iVar1 == 0x1050) {
  820.       uVar4 = 0xa400;
  821.     }
  822.     else if (iVar1 < 0x1051) {
  823.       uVar4 = 0x9800;
  824.       if (iVar1 != 0x1046) {
  825.         return 0xf036;
  826.       }
  827.     }
  828.     else if (iVar1 == 0x1060) {
  829.       uVar4 = 0xc400;
  830.     }
  831.     else {
  832.       uVar4 = 0xe400;
  833.       if (iVar1 != 0x1070) {
  834.         return 0xf036;
  835.       }
  836.     }
  837.   }
  838. LAB_00b36b20:
  839.   uVar2 = 1;
  840.   uVar3 = 0x84;
  841. LAB_00b36b30:
  842.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,uVar2,uVar3,uVar4);
  843.   return iVar1;
  844. }
  845.  
  846.  
  847. void phy_common_c45_enable_set(undefined4 param_1,undefined4 param_2,int param_3)
  848.  
  849. {
  850.   int iVar1;
  851.   uint local_18 [2];
  852.  
  853.   local_18[0] = 0;
  854.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,1,0,local_18);
  855.   if (iVar1 == 0) {
  856.     local_18[0] = (uint)(param_3 != 1) << 0xb | local_18[0] & 0xfffff7ff;
  857.     phy_common_general_reg_mmd_set(param_1,param_2,1,0,local_18[0]);
  858.   }
  859.   return;
  860. }
  861.  
  862.  
  863. int phy_common_c45_speed_set(undefined4 param_1,undefined4 param_2,undefined4 param_3)
  864.  
  865. {
  866.   int iVar1;
  867.   uint local_18 [2];
  868.  
  869.   local_18[0] = 0;
  870.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,1,0,local_18);
  871.   if (iVar1 == 0) {
  872.     local_18[0] = local_18[0] & 0xffffdf83;
  873.     switch(param_3) {
  874.     case 0:
  875.       break;
  876.     case 1:
  877.       local_18[0] = local_18[0] | 0x2000;
  878.       break;
  879.     case 2:
  880.       local_18[0] = local_18[0] | 0x40;
  881.       break;
  882.     default:
  883.       return 0xf00d;
  884.     case 5:
  885.       local_18[0] = local_18[0] | 0x2058;
  886.       break;
  887.     case 6:
  888.       local_18[0] = local_18[0] | 0x205c;
  889.       break;
  890.     case 7:
  891.       local_18[0] = local_18[0] | 0x2040;
  892.     }
  893.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,1,0,local_18[0]);
  894.   }
  895.   return iVar1;
  896. }
  897.  
  898.  
  899. int _phy_c45_check(undefined4 param_1,undefined4 param_2)
  900.  
  901. {
  902.   int iVar1;
  903.   int iVar2;
  904.   int local_20 [3];
  905.  
  906.   iVar1 = hal_ctrlInfo_get();
  907.   if (iVar1 != 0) {
  908.     iVar2 = *(int *)(*(int *)(iVar1 + 4) + 0x18);
  909.     if (*(int *)(iVar2 + 4) != 0) {
  910.       iVar2 = (**(code **)(iVar2 + 0x24))(param_1,param_2,1,2,local_20);
  911.       if (iVar2 != 0) {
  912.         return iVar2;
  913.       }
  914.       if (local_20[0] != 0) {
  915.         return 0;
  916.       }
  917.       iVar2 = (**(code **)(*(int *)(*(int *)(iVar1 + 4) + 0x18) + 0x24))
  918.                         (param_1,param_2,3,2,local_20);
  919.       if (iVar2 != 0) {
  920.         return iVar2;
  921.       }
  922.       if (local_20[0] != 0) {
  923.         return 0;
  924.       }
  925.       iVar2 = (**(code **)(*(int *)(*(int *)(iVar1 + 4) + 0x18) + 0x24))
  926.                         (param_1,param_2,7,2,local_20);
  927.       if (iVar2 != 0) {
  928.         return iVar2;
  929.       }
  930.       if (local_20[0] != 0) {
  931.         return 0;
  932.       }
  933.       iVar1 = (**(code **)(*(int *)(*(int *)(iVar1 + 4) + 0x18) + 0x24))
  934.                         (param_1,param_2,0x1e,0x8003,local_20);
  935.       if ((iVar1 == 0) && (local_20[0] == 0x8295)) {
  936.         return 0;
  937.       }
  938.     }
  939.   }
  940.   return -1;
  941. }
  942.  
  943.  
  944. void phy_826xb_linkStatus_get(undefined4 param_1,undefined4 param_2,uint *param_3)
  945.  
  946. {
  947.   int iVar1;
  948.   uint local_10 [2];
  949.  
  950.   local_10[0] = 0;
  951.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,1,1,local_10);
  952.   if (iVar1 == 0) {
  953.     *param_3 = local_10[0] >> 2 & 1;
  954.   }
  955.   return;
  956. }
  957.  
  958. void phy_826xb_macIntfSerdesLinkStatus_get(undefined4 param_1,undefined4 param_2,uint *param_3)
  959.  
  960. {
  961.   int iVar1;
  962.   uint uVar2;
  963.   int local_18;
  964.   uint local_14;
  965.  
  966.   local_14 = 0;
  967.   local_18 = 0;
  968.   iVar1 = phy_826xb_macIntfSerdesMode_get(param_1,param_2,&local_18);
  969.   if (iVar1 == 0) {
  970.     param_3[2] = 1;
  971.     if ((local_18 - 8U < 0x1e) && ((1 << (local_18 - 8U & 0x1f) & 0x20040001U) != 0)) {
  972.       iVar1 = _phy_826xb_serdes_reg_read(param_1,param_2,1,0x1d,&local_14);
  973.       if (iVar1 != 0) {
  974.         return;
  975.       }
  976.       uVar2 = (uint)((local_14 & 0x111) == 0x111);
  977.     }
  978.     else {
  979.       iVar1 = _phy_826xb_serdes_reg_read(param_1,param_2,5,0,&local_14);
  980.       if (iVar1 != 0) {
  981.         return;
  982.       }
  983.       uVar2 = local_14 >> 0xc & 1;
  984.     }
  985.     *param_3 = uVar2;
  986.   }
  987.   return;
  988. }
  989.  
  990.  
  991. void _phy_826xb_macsec_init(undefined4 param_1,undefined4 param_2)
  992.  
  993. {
  994.   int iVar1;
  995.  
  996.   iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2e0,1,0,3);
  997.   if (iVar1 == 0) {
  998.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2d8,0xf,0,0x5212);
  999.     if (iVar1 == 0) {
  1000.       iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2da,0xf,0,0x101);
  1001.       if (iVar1 == 0) {
  1002.         iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2dc,0xf,0,0x101);
  1003.         if (iVar1 == 0) {
  1004.           iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x3c6,7,0,10);
  1005.           if (iVar1 == 0) {
  1006.             iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x37b,7,0,6);
  1007.             if (iVar1 == 0) {
  1008.               iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2f7,0xf,0,0x486c);
  1009.               if (iVar1 == 0) {
  1010.                 iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x3f1,0xf,0,0x72);
  1011.                 if (iVar1 == 0) {
  1012.                   iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x3f0,0xf,0,0xb0b);
  1013.                   if (iVar1 == 0) {
  1014.                     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x3ee,0xf,0xd,2);
  1015.                     if (iVar1 == 0) {
  1016.                     /* WARNING: Could not recover jumptable at 0x00ba3654. Too many branches */
  1017.                     /* WARNING: Treating indirect jump as call */
  1018.                       phy_macsec_init(param_1,param_2);
  1019.                       return;
  1020.                     }
  1021.                   }
  1022.                 }
  1023.               }
  1024.             }
  1025.           }
  1026.         }
  1027.       }
  1028.     }
  1029.   }
  1030.   return;
  1031. }
  1032.  
  1033. void _phy_826xb_phyReg_read(void)
  1034.  
  1035. {
  1036.   int iVar1;
  1037.   byte in_stack_00000017;
  1038.   uint *in_stack_00000018;
  1039.  
  1040.   iVar1 = phy_common_general_reg_mmd_get();
  1041.   if (iVar1 == 0) {
  1042.     *in_stack_00000018 = 0 >> (in_stack_00000017 & 0x1f);
  1043.   }
  1044.   return;
  1045. }
  1046.  
  1047.  
  1048.  
  1049. void _phy_826xb_phyReg_write
  1050.                (undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
  1051.                byte param_5,byte param_6,int param_7)
  1052.  
  1053. {
  1054.   int iVar1;
  1055.   uint uVar2;
  1056.   uint uVar3;
  1057.   uint local_28 [3];
  1058.  
  1059.   uVar2 = (uint)param_6;
  1060.   local_28[0] = 0;
  1061.   if (((param_5 != 0xf) || (uVar2 != 0)) &&
  1062.      (iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,param_3,param_4,local_28), iVar1 != 0))
  1063.   {
  1064.     return;
  1065.   }
  1066.   uVar3 = (1 << (uVar2 & 0x1f)) - 1U ^ 0xffffffffU >> (~(uint)param_5 & 0x1f);
  1067.   phy_common_general_reg_mmd_set
  1068.             (param_1,param_2,param_3,param_4,
  1069.              ~uVar3 & local_28[0] | uVar3 & param_7 << (uVar2 & 0x1f));
  1070.   return;
  1071. }
  1072.  
  1073.  
  1074. void _phy_826xb_reinit(int param_1,uint param_2)
  1075.  
  1076. {
  1077.   int iVar1;
  1078.   undefined1 local_18 [12];
  1079.  
  1080.   local_18[0] = 0;
  1081.   iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x145,1);
  1082.   if (iVar1 == 0) {
  1083.     iVar1 = phy_common_general_reg_mmd_set(param_1,param_2,0x1e,0x145,0);
  1084.     if (iVar1 == 0) {
  1085.       osal_time_mdelay(0x1e);
  1086.       iVar1 = hwp_get_offset_by_baseport_port
  1087.                         (param_1,*(undefined1 *)((&unitMapStruct)[param_1 * 2] + param_2 + 0x6e4),
  1088.                          param_2 & 0xff,local_18);
  1089.       if (iVar1 == 0) {
  1090.         iVar1 = phy_patch(param_1,param_2,local_18[0],0);
  1091.         if (iVar1 == 0) {
  1092.           phy_826xb_init(param_1,param_2);
  1093.         }
  1094.       }
  1095.     }
  1096.   }
  1097.   return;
  1098. }
  1099.  
  1100.  
  1101. void _phy_826xb_sdsReg_write
  1102.                (undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
  1103.                byte param_5,byte param_6,int param_7)
  1104.  
  1105. {
  1106.   int iVar1;
  1107.   uint uVar2;
  1108.   uint uVar3;
  1109.   uint local_28 [3];
  1110.  
  1111.   uVar2 = (uint)param_6;
  1112.   local_28[0] = 0;
  1113.   if (((param_5 != 0xf) || (uVar2 != 0)) &&
  1114.      (iVar1 = _phy_826xb_serdes_reg_read(param_1,param_2,param_3,param_4,local_28), iVar1 != 0)) {
  1115.     return;
  1116.   }
  1117.   uVar3 = (1 << (uVar2 & 0x1f)) - 1U ^ 0xffffffffU >> (~(uint)param_5 & 0x1f);
  1118.   _phy_826xb_serdes_reg_write
  1119.             (param_1,param_2,param_3,param_4,
  1120.              ~uVar3 & local_28[0] | uVar3 & param_7 << (uVar2 & 0x1f));
  1121.   return;
  1122. }
  1123.  
  1124.  
  1125. int _phy_826xb_skew_get(undefined4 param_1,undefined4 param_2,int param_3,uint *param_4)
  1126.  
  1127. {
  1128.   int iVar1;
  1129.   uint uVar2;
  1130.   uint uVar3;
  1131.   undefined4 uVar4;
  1132.   uint uVar5;
  1133.   uint local_20;
  1134.   int local_1c [2];
  1135.  
  1136.   local_20 = 0;
  1137.   iVar1 = phy_common_c45_speedStatusResReg_get(param_1,param_2,local_1c);
  1138.   if (iVar1 != 0) {
  1139.     return iVar1;
  1140.   }
  1141.   if (param_3 == 0x46) {
  1142.     if (local_1c[0] == 2) {
  1143.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1f,0xa726,&local_20);
  1144.       if (iVar1 != 0) {
  1145.         return iVar1;
  1146.       }
  1147.       uVar5 = local_20 & 0xf;
  1148.       uVar2 = (local_20 & 0xf00) >> 8;
  1149.       goto LAB_00ba2cb0;
  1150.     }
  1151.     uVar4 = 0x92;
  1152.   }
  1153.   else {
  1154.     if (param_3 == 0x47) {
  1155.       if (local_1c[0] == 2) {
  1156.         iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1f,0xa726,&local_20);
  1157.         if (iVar1 != 0) {
  1158.           return iVar1;
  1159.         }
  1160.         uVar5 = local_20 & 0xf;
  1161.         uVar2 = (local_20 & 0xf000) >> 0xc;
  1162.         goto LAB_00ba2cb0;
  1163.       }
  1164.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,1,0x92,&local_20);
  1165.       if (iVar1 != 0) {
  1166.         return iVar1;
  1167.       }
  1168.       local_20 = local_20 & 0x7f;
  1169.       goto LAB_00ba2cec;
  1170.     }
  1171.     if (param_3 != 0x45) {
  1172.       return 0xf001;
  1173.     }
  1174.     if (local_1c[0] == 2) {
  1175.       iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1f,0xa726);
  1176.       if (iVar1 != 0) {
  1177.         return iVar1;
  1178.       }
  1179.       uVar5 = local_20 & 0xf;
  1180.       uVar2 = (local_20 & 0xf0) >> 4;
  1181. LAB_00ba2cb0:
  1182.       uVar3 = uVar5 - uVar2;
  1183.       if (uVar5 < uVar2) {
  1184.         uVar3 = uVar2 - uVar5;
  1185.       }
  1186.       *param_4 = uVar3;
  1187.       return 0;
  1188.     }
  1189.     uVar4 = 0x91;
  1190.   }
  1191.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,1,uVar4,&local_20);
  1192.   if (iVar1 != 0) {
  1193.     return iVar1;
  1194.   }
  1195.   local_20 = (local_20 & 0x7f00) >> 8;
  1196. LAB_00ba2cec:
  1197.   *param_4 = local_20;
  1198.   return 0;
  1199. }
  1200.  
  1201.  
  1202. void _phy_rtl826xb_patch_sds_get
  1203.                (undefined4 param_1,undefined4 param_2,int param_3,int param_4,undefined4 *param_5)
  1204.  
  1205. {
  1206.   int iVar1;
  1207.   undefined4 local_18 [2];
  1208.  
  1209.   local_18[0] = 0;
  1210.   iVar1 = _phy_rtl826xb_patch_top_set(param_1,param_2,0x28,0x13,param_3 + 0x8000 + param_4 * 0x40);
  1211.   if (iVar1 == 0) {
  1212.     iVar1 = _phy_rtl826xb_patch_top_get(param_1,param_2,0x28,0x12,local_18);
  1213.     if (iVar1 == 0) {
  1214.       *param_5 = local_18[0];
  1215.       _phy_rtl826xb_patch_wait(param_1,param_2,0x1e,0x143,0,0x8000,0);
  1216.     }
  1217.   }
  1218.   return;
  1219. }
  1220.  
  1221.  
  1222. void _phy_rtl826xb_patch_sds_set
  1223.                (undefined4 param_1,undefined4 param_2,int param_3,int param_4,undefined4 param_5,
  1224.                undefined1 param_6)
  1225.  
  1226. {
  1227.   int iVar1;
  1228.  
  1229.   iVar1 = _phy_rtl826xb_patch_top_set(param_1,param_2,0x28,0x11,param_5);
  1230.   if (iVar1 == 0) {
  1231.     iVar1 = _phy_rtl826xb_patch_top_set(param_1,param_2,0x28,0x13,param_3 + 0x8800 + param_4 * 0x40)
  1232.     ;
  1233.     if (iVar1 == 0) {
  1234.       _phy_rtl826xb_patch_wait(param_1,param_2,0x1e,0x143,0,0x8000,param_6);
  1235.     }
  1236.   }
  1237.   return;
  1238. }
  1239.  
  1240.  
  1241. void _phy_rtl826xb_patch_top_set(undefined4 param_1,undefined4 param_2,int param_3,int param_4)
  1242.  
  1243. {
  1244.   phy_common_general_reg_mmd_set(param_1,param_2,0x1e,param_4 + -0x10 + param_3 * 8);
  1245.   return;
  1246. }
  1247.  
  1248.  
  1249. void _phy_rtl826xb_patch_top_get
  1250.                (undefined4 param_1,undefined4 param_2,int param_3,int param_4,undefined4 *param_5)
  1251.  
  1252. {
  1253.   int iVar1;
  1254.   undefined4 local_10 [3];
  1255.  
  1256.   local_10[0] = 0;
  1257.   iVar1 = phy_common_general_reg_mmd_get
  1258.                     (param_1,param_2,0x1e,param_4 + -0x10 + param_3 * 8,local_10);
  1259.   if (iVar1 == 0) {
  1260.     *param_5 = local_10[0];
  1261.   }
  1262.   return;
  1263. }
  1264.  
  1265.  
  1266. int phy_826xb_autoNegoAbility_set(undefined4 param_1,uint param_2,uint *param_3)
  1267.  
  1268. {
  1269.   int iVar1;
  1270.   int iVar2;
  1271.   uint uVar3;
  1272.   uint local_20 [3];
  1273.  
  1274.   local_20[0] = 0;
  1275.   iVar1 = _phy_826xb_chip_type_get(param_1,param_2 & 0xff);
  1276.   uVar3 = *param_3;
  1277.   iVar2 = 0xf001;
  1278.   if ((((uVar3 & 0xc0000000) == 0) && (((uVar3 & 0x200000) == 0 || (iVar1 == 0x10)))) &&
  1279.      (((uVar3 & 0x400000) == 0 || (iVar2 = 0xf001, iVar1 != 4)))) {
  1280.     iVar2 = phy_common_general_reg_mmd_get(param_1,param_2,7,0x10,local_20);
  1281.     if (iVar2 == 0) {
  1282.       uVar3 = *param_3;
  1283.       local_20[0] = uVar3 >> 0x16 & 0x80 | local_20[0] & 0xfffff21f | uVar3 >> 0x14 & 0x100 |
  1284.                     uVar3 >> 10 & 0x400 | uVar3 >> 8 & 0x800;
  1285.       iVar2 = phy_common_general_reg_mmd_set(param_1,param_2,7,0x10,local_20[0]);
  1286.       if (iVar2 == 0) {
  1287.         iVar2 = phy_common_general_reg_mmd_get(param_1,param_2,7,0x20,local_20);
  1288.         if (iVar2 == 0) {
  1289.           uVar3 = *param_3;
  1290.           local_20[0] = uVar3 >> 0x10 & 0x80 | local_20[0] & 0xffffee7f | uVar3 >> 0xe & 0x100 |
  1291.                         uVar3 >> 9 & 0x1000;
  1292.           iVar2 = phy_common_general_reg_mmd_set(param_1,param_2,7,0x20,local_20[0]);
  1293.           if (iVar2 == 0) {
  1294.             iVar2 = phy_common_general_reg_mmd_get(param_1,param_2,0x1f,0xa412,local_20);
  1295.             if (iVar2 == 0) {
  1296.               local_20[0] = *param_3 >> 0x13 & 0x100 | local_20[0] & 0xfffffcff |
  1297.                             *param_3 >> 0x11 & 0x200;
  1298.               iVar2 = phy_common_general_reg_mmd_set(param_1,param_2,0x1f,0xa412,local_20[0]);
  1299.               if (iVar2 == 0) {
  1300.                 iVar2 = _phy_826xb_an_restart(param_1,param_2);
  1301.               }
  1302.             }
  1303.           }
  1304.         }
  1305.       }
  1306.     }
  1307.   }
  1308.   return iVar2;
  1309. }
  1310.  
  1311.  
  1312. undefined4 phy_826xb_autoNegoAbilityLocal_get(undefined4 param_1,undefined1 param_2,ushort *param_3)
  1313.  
  1314. {
  1315.   int iVar1;
  1316.   ushort uVar2;
  1317.  
  1318.   iVar1 = _phy_826xb_chip_type_get(param_1,param_2);
  1319.   *(undefined1 *)param_3 = 0;
  1320.   *(undefined1 *)((int)param_3 + 1) = 0;
  1321.   uVar2 = *param_3;
  1322.   *param_3 = uVar2 | 0x3418;
  1323.   *(undefined1 *)(param_3 + 1) = 0;
  1324.   *(undefined1 *)((int)param_3 + 3) = 0;
  1325.   if (iVar1 == 4) {
  1326.     *param_3 = uVar2 | 0x3498;
  1327.   }
  1328.   else {
  1329.     if (iVar1 == 8) {
  1330.       uVar2 = uVar2 | 0x34d8;
  1331.     }
  1332.     else {
  1333.       uVar2 = uVar2 | 0x34f8;
  1334.     }
  1335.     *param_3 = uVar2;
  1336.   }
  1337.   return 0;
  1338. }
  1339.  
  1340.  
  1341. void phy_826xb_autoNegoAbilityPeer_get(undefined4 param_1,undefined4 param_2,ushort *param_3)
  1342.  
  1343. {
  1344.   int iVar1;
  1345.   uint local_18 [2];
  1346.  
  1347.   local_18[0] = 0;
  1348.   phy_common_c45_copperPeerAutoNegoAbility_get();
  1349.   iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1f,0xa414,local_18);
  1350.   if (iVar1 == 0) {
  1351.     *param_3 = *param_3 & 0xf3ff | (ushort)(local_18[0] >> 1) & 0x400 |
  1352.                (ushort)((local_18[0] & 0x400) << 1);
  1353.   }
  1354.   return;
  1355. }
  1356.  
  1357.  
  1358. /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
  1359.  
  1360. int phy_826xb_init(int param_1,undefined4 param_2)
  1361.  
  1362. {
  1363.   void *__s;
  1364.   int iVar1;
  1365.  
  1366.   if (*(int *)(rtl826xb_info + param_1 * 4) == 0) {
  1367.     __s = osal_alloc(0x200);
  1368.     *(void **)(rtl826xb_info + param_1 * 4) = __s;
  1369.     if (__s == (void *)0x0) {
  1370.       iVar1 = rt_log(2);
  1371.       if (iVar1 != 0) {
  1372.         return 0xf032;
  1373.       }
  1374.       fprintf(_stderr,"*** [RT_ERR] %s:%d: In function \'%s\'\n             Error Code: 0x%X\n\n",
  1375.               "hal/phy/phy_rtl826xb.c",0x750,"phy_826xb_init",0xf032,param_2);
  1376.       return 0xf032;
  1377.     }
  1378.     memset(__s,0,0x200);
  1379.   }
  1380.   iVar1 = _phy_826xb_serdes_mode_init(param_1,param_2);
  1381.   if ((((iVar1 == 0) && (iVar1 = _phy_826xb_interrupt_init(param_1,param_2), iVar1 == 0)) &&
  1382.       (iVar1 = _phy_826xb_dbgCount_init(param_1,param_2), iVar1 == 0)) &&
  1383.      (iVar1 = _phy_826xb_synce_init(param_1,param_2), iVar1 == 0)) {
  1384.                     /* WARNING: Could not recover jumptable at 0x00bafdb0. Too many branches */
  1385.                     /* WARNING: Treating indirect jump as call */
  1386.     iVar1 = _phy_826xb_macsec_init(param_1,param_2);
  1387.     return iVar1;
  1388.   }
  1389.   return iVar1;
  1390. }
  1391.  
  1392.  
  1393. int phy_826xb_macsec_reg_get
  1394.               (undefined4 param_1,undefined4 param_2,int param_3,undefined4 param_4,int *param_5)
  1395.  
  1396. {
  1397.   int iVar1;
  1398.   undefined4 uVar2;
  1399.   int local_18;
  1400.   int local_14;
  1401.  
  1402.   local_14 = 0;
  1403.   local_18 = 0;
  1404.   if (param_3 == 0) {
  1405.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2fb,0xf,0,param_4);
  1406.     if (iVar1 != 0) {
  1407.       return iVar1;
  1408.     }
  1409.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2fc,0xf,0,0x10);
  1410.     if (iVar1 != 0) {
  1411.       return iVar1;
  1412.     }
  1413.     iVar1 = _phy_826xb_phyReg_read(param_1,param_2,0x1e,0x2f8,0xf,0,&local_14);
  1414.     if (iVar1 != 0) {
  1415.       return iVar1;
  1416.     }
  1417.     uVar2 = 0x2f9;
  1418.   }
  1419.   else {
  1420.     if (param_3 != 1) {
  1421.       return 0xf001;
  1422.     }
  1423.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x300,0xf,0,param_4);
  1424.     if (iVar1 != 0) {
  1425.       return iVar1;
  1426.     }
  1427.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x301,0xf,0,0x10);
  1428.     if (iVar1 != 0) {
  1429.       return iVar1;
  1430.     }
  1431.     iVar1 = _phy_826xb_phyReg_read(param_1,param_2,0x1e,0x2fd,0xf,0,&local_14);
  1432.     if (iVar1 != 0) {
  1433.       return iVar1;
  1434.     }
  1435.     uVar2 = 0x2fe;
  1436.   }
  1437.   iVar1 = _phy_826xb_phyReg_read(param_1,param_2,0x1e,uVar2,0xf,0,&local_18);
  1438.   if (iVar1 == 0) {
  1439.     *param_5 = local_14 * 0x10000 + local_18;
  1440.     iVar1 = 0;
  1441.   }
  1442.   return iVar1;
  1443. }
  1444.  
  1445.  
  1446. int phy_826xb_macsec_reg_set
  1447.               (undefined4 param_1,undefined4 param_2,int param_3,undefined4 param_4,uint param_5)
  1448.  
  1449. {
  1450.   int iVar1;
  1451.   undefined4 uVar2;
  1452.  
  1453.   if (param_3 == 0) {
  1454.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2f8,0xf,0,param_5 >> 0x10);
  1455.     if (iVar1 != 0) {
  1456.       return iVar1;
  1457.     }
  1458.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2f9,0xf,0,param_5 & 0xffff);
  1459.     if (iVar1 != 0) {
  1460.       return iVar1;
  1461.     }
  1462.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2fb,0xf,0,param_4);
  1463.     if (iVar1 != 0) {
  1464.       return iVar1;
  1465.     }
  1466.     uVar2 = 0x2fc;
  1467.   }
  1468.   else {
  1469.     if (param_3 != 1) {
  1470.       return 0xf001;
  1471.     }
  1472.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2fd,0xf,0,param_5 >> 0x10);
  1473.     if (iVar1 != 0) {
  1474.       return iVar1;
  1475.     }
  1476.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x2fe,0xf,0,param_5 & 0xffff);
  1477.     if (iVar1 != 0) {
  1478.       return iVar1;
  1479.     }
  1480.     iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,0x300,0xf,0,param_4);
  1481.     if (iVar1 != 0) {
  1482.       return iVar1;
  1483.     }
  1484.     uVar2 = 0x301;
  1485.   }
  1486.   iVar1 = _phy_826xb_phyReg_write(param_1,param_2,0x1e,uVar2,0xf,0,1);
  1487.   return iVar1;
  1488. }
  1489.  
  1490.  
  1491. void phy_826xb_sdsEyeParam_get
  1492.                (undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 *param_4)
  1493.  
  1494. {
  1495.   int iVar1;
  1496.   uint local_10 [2];
  1497.  
  1498.   local_10[0] = 0;
  1499.   iVar1 = _phy_826xb_preemphasis_get(param_1,param_2,local_10);
  1500.   if (iVar1 == 0) {
  1501.     *param_4 = 0;
  1502.     param_4[3] = local_10[0] >> 0x1a;
  1503.     param_4[6] = local_10[0] >> 0x13 & 1;
  1504.     param_4[2] = local_10[0] >> 10 & 0x3f;
  1505.     param_4[8] = local_10[0] >> 9 & 1;
  1506.     param_4[1] = local_10[0] >> 3 & 0x3f;
  1507.     param_4[5] = local_10[0] >> 2 & 1;
  1508.   }
  1509.   return;
  1510. }
  1511.  
  1512.  
  1513. void phy_826xb_sdsEyeParam_set(int param_1,int param_2,undefined4 param_3,int param_4)
  1514.  
  1515. {
  1516.   uint uVar1;
  1517.   char cVar2;
  1518.   int iVar3;
  1519.   int iVar4;
  1520.   uint uVar5;
  1521.   uint uVar6;
  1522.   uint uVar7;
  1523.   uint uVar8;
  1524.   uint uStack_20;
  1525.   uint auStack_1c [2];
  1526.  
  1527.   uVar1 = *(uint *)(param_4 + 0x18);
  1528.   iVar4 = *(int *)(param_4 + 0xc);
  1529.   uVar5 = *(uint *)(param_4 + 8);
  1530.   uVar6 = *(uint *)(param_4 + 0x20);
  1531.   uVar7 = *(uint *)(param_4 + 4);
  1532.   uVar8 = *(uint *)(param_4 + 0x14);
  1533.   iVar3 = *(int *)(*(int *)(rtl826xb_info + param_1 * 4) + (param_2 + 0x40) * 4);
  1534.   auStack_1c[0] = 0;
  1535.   uStack_20 = 0;
  1536.   cVar2 = '.';
  1537.   if (iVar3 - 8U < 0x1f) {
  1538.     cVar2 = "$.................(..........,4"[iVar3 + 0x18];
  1539.   }
  1540.   iVar3 = _phy_826xb_serdes_reg_read(param_1,param_2,cVar2,7,&uStack_20);
  1541.   if ((iVar3 == 0) &&
  1542.      (iVar3 = _phy_826xb_serdes_reg_read(param_1,param_2,cVar2,6,auStack_1c), iVar3 == 0)) {
  1543.     auStack_1c[0] = ((uVar1 & 1) << 0x13 | iVar4 << 0x1a) >> 0x10 | auStack_1c[0] & 3;
  1544.     uStack_20 = (uVar5 & 0x3f) << 10 | (uVar6 & 1) << 9 | (uVar7 & 0x3f) << 3 | (uVar8 & 1) << 2 |
  1545.                 uStack_20 & 3;
  1546.     iVar3 = _phy_826xb_serdes_reg_write(param_1,param_2,cVar2,7,uStack_20);
  1547.     if (iVar3 == 0) {
  1548.       _phy_826xb_serdes_reg_write(param_1,param_2,cVar2,6,auStack_1c[0]);
  1549.     }
  1550.   }
  1551.   return;
  1552. }
  1553.  
  1554.  
  1555. int phy_826xb_speed_set(undefined4 param_1,undefined4 param_2,int param_3)
  1556.  
  1557. {
  1558.   int iVar1;
  1559.   int local_18 [2];
  1560.  
  1561.   local_18[0] = 0;
  1562.   iVar1 = 0xf011;
  1563.   if ((((param_3 == 1) && (iVar1 = phy_826xb_ctrl_get(param_1,param_2,0x19,local_18), iVar1 == 0))
  1564.       && (iVar1 = phy_common_c45_speed_set(param_1,param_2,1), iVar1 == 0)) &&
  1565.      (_phy_826xb_an_restart(param_1,param_2), local_18[0] != 0)) {
  1566.     iVar1 = phy_826xb_ctrl_set(param_1,param_2,0x19);
  1567.   }
  1568.   return iVar1;
  1569. }
  1570.  
  1571.  
  1572. void phy_826XBdrv_mapperInit(undefined4 *param_1)
  1573.  
  1574. {
  1575.   *param_1 = 0x1a;
  1576.   param_1[1] = phy_rtl826xb_patch_db_init;
  1577.   param_1[2] = phy_826xb_init;
  1578.   param_1[0x7c] = phy_common_c45_reset_set;
  1579.   param_1[5] = phy_826xb_media_get;
  1580.   param_1[3] = phy_826xb_ctrl_get;
  1581.   param_1[4] = phy_826xb_ctrl_set;
  1582.   param_1[0x7d] = phy_826xb_linkStatus_get;
  1583.   param_1[0x10] = phy_common_c45_enable_get;
  1584.   param_1[0x11] = phy_common_c45_enable_set;
  1585.   param_1[7] = phy_common_c45_autoNegoEnable_get;
  1586.   param_1[8] = phy_826xb_autoNegoEnable_set;
  1587.   param_1[9] = phy_826xb_autoNegoAbilityLocal_get;
  1588.   param_1[10] = phy_826xb_autoNegoAbility_get;
  1589.   param_1[0xb] = phy_826xb_autoNegoAbility_set;
  1590.   param_1[0x7e] = phy_826xb_autoNegoAbilityPeer_get;
  1591.   param_1[0xe] = phy_common_c45_speed_get;
  1592.   param_1[0xf] = phy_826xb_speed_set;
  1593.   param_1[0x95] = phy_common_c45_speedStatusResReg_get;
  1594.   param_1[0x99] = phy_common_c45_speedDuplexStatusResReg_get;
  1595.   param_1[0xc] = phy_826xb_duplex_get;
  1596.   param_1[0xd] = phy_826xb_duplex_set;
  1597.   param_1[0x60] = phy_common_c45_masterSlave_get;
  1598.   param_1[0x61] = phy_common_c45_masterSlave_set;
  1599.   param_1[0x1a] = phy_common_c45_crossOverStatus_get;
  1600.   param_1[0x18] = phy_826xb_crossOverMode_get;
  1601.   param_1[0x19] = phy_826xb_crossOverMode_set;
  1602.   param_1[0x7f] = phy_826xb_macIntfSerdesMode_get;
  1603.   param_1[0x83] = phy_826xb_macIntfSerdesLinkStatus_get;
  1604.   param_1[0x6f] = phy_common_c45_ieeeTestMode_set;
  1605.   param_1[0x12] = phy_826xb_rtctResult_get;
  1606.   param_1[0x13] = phy_826xb_rtct_start;
  1607.   param_1[0x8d] = phy_826xb_intrStatus_get;
  1608.   param_1[0x8b] = phy_826xb_intrEnable_get;
  1609.   param_1[0x8c] = phy_826xb_intrEnable_set;
  1610.   param_1[0x8e] = phy_826xb_intrMask_get;
  1611.   param_1[0x8f] = phy_826xb_intrMask_set;
  1612.   param_1[0x5a] = phy_common_reg_mmd_get;
  1613.   param_1[0x5b] = phy_common_reg_mmd_set;
  1614.   param_1[0x90] = phy_826xb_sdsTestMode_set;
  1615.   param_1[0x91] = phy_826xb_sdsTestModeCnt_get;
  1616.   param_1[0x98] = phy_826xb_dbgCounter_get;
  1617.   param_1[0x14] = phy_826xb_greenEnable_get;
  1618.   param_1[0x15] = phy_826xb_greenEnable_set;
  1619.   param_1[0x27] = phy_826xb_downSpeedEnable_get;
  1620.   param_1[0x28] = phy_826xb_downSpeedEnable_set;
  1621.   param_1[0x29] = phy_826xb_downSpeedStatus_get;
  1622.   param_1[0x16] = phy_826xb_eeeEnable_get;
  1623.   param_1[0x17] = phy_826xb_eeeEnable_set;
  1624.   param_1[0x23] = phy_826xb_eeepEnable_get;
  1625.   param_1[0x24] = phy_826xb_eeepEnable_set;
  1626.   param_1[0x1d] = phy_826xb_linkDownPowerSavingEnable_get;
  1627.   param_1[0x1e] = phy_826xb_linkDownPowerSavingEnable_set;
  1628.   param_1[0x62] = phy_common_c45_loopback_get;
  1629.   param_1[99] = phy_common_c45_loopback_set;
  1630.   param_1[0x84] = phy_826xb_sdsEyeParam_get;
  1631.   param_1[0x85] = phy_826xb_sdsEyeParam_set;
  1632.   param_1[0x88] = phy_826xb_mdiLoopbackEnable_get;
  1633.   param_1[0x89] = phy_826xb_mdiLoopbackEnable_set;
  1634.   param_1[0x72] = phy_826xb_eyeMonitor_start;
  1635.   param_1[0x73] = phy_826xb_eyeMonitorInfo_get;
  1636.   param_1[0x31] = phy_826xb_ptp_portRefTime_get;
  1637.   param_1[0x32] = phy_826xb_ptp_portRefTime_set;
  1638.   param_1[0x33] = phy_826xb_ptp_portRefTimeAdjust_set;
  1639.   param_1[0x46] = phy_826xb_ptp_portRefTimeFreq_get;
  1640.   param_1[0x47] = phy_826xb_ptp_portRefTimeFreq_set;
  1641.   param_1[0x38] = phy_826xb_ptp_portPtpEnable_get;
  1642.   param_1[0x39] = phy_826xb_ptp_portPtpEnable_set;
  1643.   param_1[0x48] = phy_826xb_ptp_portPtpTxInterruptStatus_get;
  1644.   param_1[0x3b] = phy_826xb_ptp_portPtpInterruptEnable_get;
  1645.   param_1[0x3c] = phy_826xb_ptp_portPtpInterruptEnable_set;
  1646.   param_1[0x3d] = phy_826xb_ptp_portPtpVlanTpid_get;
  1647.   param_1[0x3e] = phy_826xb_ptp_portPtpVlanTpid_set;
  1648.   param_1[0x43] = phy_826xb_ptp_portPtpOper_get;
  1649.   param_1[0x44] = phy_826xb_ptp_portPtpOper_set;
  1650.   param_1[0x45] = phy_826xb_ptp_portPtpLatchTime_get;
  1651.   param_1[0x49] = phy_826xb_ptp_ptpTxTimestampFifo_get;
  1652.   param_1[0x4a] = phy_826xb_ptp_ptp1PPSOutput_get;
  1653.   param_1[0x4b] = phy_826xb_ptp_ptp1PPSOutput_set;
  1654.   param_1[0x4c] = phy_826xb_ptp_ptpClockOutput_get;
  1655.   param_1[0x4d] = phy_826xb_ptp_ptpClockOutput_set;
  1656.   param_1[0x4e] = phy_826xb_ptp_portPtpOutputSigSel_get;
  1657.   param_1[0x4f] = phy_826xb_ptp_portPtpOutputSigSel_set;
  1658.   param_1[0x52] = phy_826xb_ptp_portPtpLinkDelay_get;
  1659.   param_1[0x53] = phy_826xb_ptp_portPtpLinkDelay_set;
  1660.   param_1[0x55] = phy_826xb_ptp_fullSec_get;
  1661.   param_1[0x9a] = phy_826xb_macsec_reg_get;
  1662.   param_1[0x9b] = phy_826xb_macsec_reg_set;
  1663.   param_1[0x9c] = phy_macsec_port_cfg_set;
  1664.   param_1[0x9d] = phy_macsec_port_cfg_get;
  1665.   param_1[0x9e] = phy_macsec_sc_create;
  1666.   param_1[0x9f] = phy_macsec_sc_get;
  1667.   param_1[0xa0] = phy_macsec_sc_del;
  1668.   param_1[0xa1] = phy_macsec_sc_status_get;
  1669.   param_1[0xa2] = phy_macsec_sa_create;
  1670.   param_1[0xa3] = phy_macsec_sa_get;
  1671.   param_1[0xa4] = phy_macsec_sa_del;
  1672.   param_1[0xa5] = phy_macsec_sa_activate;
  1673.   param_1[0xa6] = phy_macsec_rxsa_disable;
  1674.   param_1[0xa7] = phy_macsec_txsa_disable;
  1675.   param_1[0xa8] = phy_macsec_stat_clear;
  1676.   param_1[0xa9] = phy_macsec_stat_port_get;
  1677.   param_1[0xaa] = phy_macsec_stat_txsa_get;
  1678.   param_1[0xab] = phy_macsec_stat_rxsa_get;
  1679.   param_1[0xac] = phy_macsec_intr_status_get;
  1680.   return;
  1681. }
  1682.  
  1683.  
  1684. int phy_826xb_speed_set(undefined4 param_1,undefined4 param_2,int param_3)
  1685.  
  1686. {
  1687.   int iVar1;
  1688.   int local_18 [2];
  1689.  
  1690.   local_18[0] = 0;
  1691.   iVar1 = 0xf011;
  1692.   if ((((param_3 == 1) && (iVar1 = phy_826xb_ctrl_get(param_1,param_2,0x19,local_18), iVar1 == 0))
  1693.       && (iVar1 = phy_common_c45_speed_set(param_1,param_2,1), iVar1 == 0)) &&
  1694.      (_phy_826xb_an_restart(param_1,param_2), local_18[0] != 0)) {
  1695.     iVar1 = phy_826xb_ctrl_set(param_1,param_2,0x19);
  1696.   }
  1697.   return iVar1;
  1698. }
  1699.  
  1700.  
  1701. int phy_rtl826xb_patch_db_init(undefined4 param_1,undefined4 param_2,undefined4 *param_3)
  1702.  
  1703. {
  1704.   undefined4 *__s;
  1705.   int iVar1;
  1706.   uint local_30 [2];
  1707.  
  1708.   local_30[0] = 0;
  1709.   __s = (undefined4 *)osal_alloc(0x428);
  1710.   iVar1 = 0xf032;
  1711.   if (__s != (undefined4 *)0x0) {
  1712.     memset(__s,0,0x428);
  1713.     *__s = phy_rtl826xb_patch_op;
  1714.     __s[1] = phy_rtl826xb_patch_flow;
  1715.     iVar1 = phy_common_general_reg_mmd_get(param_1,param_2,0x1e,0x104,local_30);
  1716.     if (iVar1 == 0) {
  1717.       if (((local_30[0] & 0xffc0) == 0x1140) || ((local_30[0] & 0xf) != 0)) {
  1718.         *(undefined1 *)(__s + 0xe) = 5;
  1719.         __s[0x10] = 0x1f68;
  1720.         __s[0x12] = rtl8261n_c_uc_conf;
  1721.         *(undefined1 *)(__s + 0x14) = 0xc;
  1722.         __s[0x16] = 0xb90;
  1723.         *(undefined1 *)(__s + 0x1a) = 0x10;
  1724.         *(undefined1 *)(__s + 0x1b) = 0x10;
  1725.         *(undefined1 *)(__s + 0x1d) = 9;
  1726.         __s[0xf] = rtl8261n_c_uc2_conf;
  1727.         __s[0x1e] = rtl8261n_c_algxg_conf;
  1728.         __s[0x1f] = 0xe60;
  1729.         *(undefined1 *)(__s + 0x20) = 10;
  1730.         __s[0x21] = rtl8261n_c_alg_giga_conf;
  1731.         *(undefined1 *)(__s + 0x11) = 4;
  1732.         __s[0x22] = 100;
  1733.         __s[0x13] = 200;
  1734.         *(undefined1 *)(__s + 0x23) = 0xb;
  1735.         __s[0x15] = rtl8261n_c_dataram_conf;
  1736.         __s[0x24] = rtl8261n_c_normal_conf;
  1737.         *(undefined1 *)(__s + 2) = 0xe;
  1738.         *(undefined1 *)(__s + 3) = 0xe;
  1739.         __s[7] = 0x640;
  1740.         __s[10] = 0x5a0;
  1741.         __s[0xd] = 0x4498;
  1742.         *(undefined1 *)(__s + 0x17) = 0xf;
  1743.         *(undefined1 *)(__s + 0x18) = 0xf;
  1744.         __s[0x25] = 0x71c;
  1745.         *(undefined1 *)(__s + 5) = 6;
  1746.         __s[6] = rtl8261n_c_nctl0_conf;
  1747.         *(undefined1 *)(__s + 8) = 7;
  1748.         __s[9] = rtl8261n_c_nctl1_conf;
  1749.         *(undefined1 *)(__s + 0xb) = 8;
  1750.         __s[0xc] = rtl8261n_c_nctl2_conf;
  1751.         *(undefined1 *)(__s + 0x26) = 1;
  1752.         *(undefined1 *)(__s + 0x32) = 0x11;
  1753.         *(undefined1 *)(__s + 0x33) = 0x11;
  1754.         __s[0x97] = 0x640;
  1755.         __s[0x2e] = 0x26c;
  1756.         *(undefined1 *)(__s + 0x35) = 0x18;
  1757.         *(undefined1 *)(__s + 0x36) = 0x18;
  1758.         __s[0x91] = 0x26c;
  1759.         *(undefined1 *)(__s + 0x98) = 0x13;
  1760.         *(undefined1 *)(__s + 0x99) = 0x13;
  1761.         __s[0x27] = rtl8261n_c_top_conf;
  1762.         __s[0x28] = 0x154;
  1763.         *(undefined1 *)(__s + 0x29) = 2;
  1764.         __s[0x2a] = rtl8261n_c_sds_conf;
  1765.         __s[0x2b] = 0x80c;
  1766.         *(undefined1 *)(__s + 0x2c) = 3;
  1767.         __s[0x2d] = rtl8261n_c_afe_conf;
  1768.         *(undefined1 *)(__s + 0x2f) = 0xd;
  1769.         __s[0x30] = rtl8261n_c_rtct_conf;
  1770.         __s[0x31] = 0xdc0;
  1771.         *(undefined1 *)(__s + 0x86) = 0x1b;
  1772.         *(undefined1 *)(__s + 0x87) = 0x1b;
  1773.         *(undefined1 *)(__s + 0x89) = 1;
  1774.         __s[0x8a] = rtl8261n_c_top_conf;
  1775.         __s[0x8b] = 0x154;
  1776.         *(undefined1 *)(__s + 0x8c) = 2;
  1777.         __s[0x8d] = rtl8261n_c_sds_conf;
  1778.         __s[0x8e] = 0x80c;
  1779.         *(undefined1 *)(__s + 0x8f) = 3;
  1780.         __s[0x90] = rtl8261n_c_afe_conf;
  1781.         *(undefined1 *)(__s + 0x92) = 0x12;
  1782.         *(undefined1 *)(__s + 0x93) = 0x12;
  1783.         *(undefined1 *)(__s + 0x95) = 6;
  1784.         __s[0x96] = rtl8261n_c_nctl0_conf;
  1785.         *(undefined1 *)(__s + 0x9b) = 0x14;
  1786.         __s[0xa9] = 0x4498;
  1787.         *(undefined1 *)(__s + 0xaa) = 0x17;
  1788.         *(undefined1 *)(__s + 0xab) = 0x17;
  1789.         *(undefined1 *)(__s + 0xad) = 4;
  1790.         *(undefined1 *)(__s + 0xb9) = 0xf;
  1791.         __s[0xae] = rtl8261n_c_uc_conf;
  1792.         __s[0xaf] = 200;
  1793.         *(undefined1 *)(__s + 0xb0) = 5;
  1794.         *(undefined1 *)(__s + 0xba) = 0xf;
  1795.         __s[0xb1] = rtl8261n_c_uc2_conf;
  1796.         __s[0xb2] = 0x1f68;
  1797.         *(undefined1 *)(__s + 0xb3) = 0xe;
  1798.         *(undefined1 *)(__s + 0xb4) = 0xe;
  1799.         *(undefined1 *)(__s + 0xb6) = 0xc;
  1800.         __s[0xbd] = rtl8261n_c_algxg_conf;
  1801.         __s[0xb7] = rtl8261n_c_dataram_conf;
  1802.         __s[0xb8] = 0xb90;
  1803.         __s[0xa0] = 0x5a0;
  1804.         *(undefined1 *)(__s + 0xbc) = 9;
  1805.         __s[0xbe] = 0xe60;
  1806.         __s[0xc0] = rtl8261n_c_alg_giga_conf;
  1807.         *(undefined1 *)(__s + 0xa1) = 0x15;
  1808.         *(undefined1 *)(__s + 0xa2) = 0x15;
  1809.         *(undefined1 *)(__s + 0xbf) = 10;
  1810.         __s[0xc1] = 100;
  1811.         *(undefined1 *)(__s + 0x9c) = 0x14;
  1812.         *(undefined1 *)(__s + 0x9e) = 7;
  1813.         __s[0x9f] = rtl8261n_c_nctl1_conf;
  1814.         *(undefined1 *)(__s + 0xa4) = 0x16;
  1815.         *(undefined1 *)(__s + 0xa5) = 0x16;
  1816.         *(undefined1 *)(__s + 0xa7) = 8;
  1817.         __s[0xa8] = rtl8261n_c_nctl2_conf;
  1818.         *(undefined1 *)(__s + 0xc2) = 0xb;
  1819.         __s[0xc3] = rtl8261n_c_normal_conf;
  1820.         __s[0xc4] = 0x71c;
  1821.         *(undefined1 *)(__s + 0xc5) = 0xd;
  1822.         __s[0xc6] = rtl8261n_c_rtct_conf;
  1823.         __s[199] = 0xdc0;
  1824.       }
  1825.       else {
  1826.         *(undefined1 *)(__s + 0xe) = 5;
  1827.         *(undefined1 *)(__s + 0x14) = 0xc;
  1828.         __s[0x16] = 0x8c0;
  1829.         *(undefined1 *)(__s + 0x1a) = 0x10;
  1830.         *(undefined1 *)(__s + 0x1b) = 0x10;
  1831.         *(undefined1 *)(__s + 0x1d) = 9;
  1832.         __s[0x1e] = rtl8264b_algxg_conf;
  1833.         __s[0x1f] = 0x5f0;
  1834.         *(undefined1 *)(__s + 0x20) = 10;
  1835.         __s[0x21] = rtl8264b_alg_giga_conf;
  1836.         __s[0x22] = 0x514;
  1837.         __s[0x10] = 0x1a90;
  1838.         *(undefined1 *)(__s + 0x23) = 0xb;
  1839.         __s[0xf] = rtl8264b_uc2_conf;
  1840.         __s[0x15] = rtl8264b_dataram_conf;
  1841.         __s[0x24] = rtl8264b_normal_conf;
  1842.         *(undefined1 *)(__s + 2) = 0x1a;
  1843.         *(undefined1 *)(__s + 3) = 0x1a;
  1844.         __s[0x13] = 0x1428;
  1845.         *(undefined1 *)(__s + 0x17) = 0xf;
  1846.         *(undefined1 *)(__s + 0x18) = 0xf;
  1847.         __s[0x25] = 0x71c;
  1848.         *(undefined1 *)(__s + 5) = 6;
  1849.         __s[6] = rtl8264b_nctl0_conf;
  1850.         __s[7] = 0xd20;
  1851.         *(undefined1 *)(__s + 8) = 7;
  1852.         __s[9] = rtl8264b_nctl1_conf;
  1853.         __s[10] = 0;
  1854.         *(undefined1 *)(__s + 0xb) = 8;
  1855.         __s[0xc] = rtl8264b_nctl2_conf;
  1856.         __s[0xd] = 0x5118;
  1857.         *(undefined1 *)(__s + 0x11) = 4;
  1858.         __s[0x12] = rtl8264b_uc_conf;
  1859.         *(undefined1 *)(__s + 0x26) = 1;
  1860.         *(undefined1 *)(__s + 0x32) = 0x11;
  1861.         *(undefined1 *)(__s + 0x33) = 0x11;
  1862.         __s[0x28] = 0x154;
  1863.         __s[0x2e] = 0x154;
  1864.         *(undefined1 *)(__s + 0x35) = 0x19;
  1865.         *(undefined1 *)(__s + 0x36) = 0x19;
  1866.         __s[0x8b] = 0x154;
  1867.         __s[0x91] = 0x154;
  1868.         *(undefined1 *)(__s + 0x38) = 0x18;
  1869.         *(undefined1 *)(__s + 0x39) = 0x18;
  1870.         *(undefined1 *)(__s + 0x92) = 0x12;
  1871.         *(undefined1 *)(__s + 0x93) = 0x12;
  1872.         __s[0x27] = rtl8264b_top_conf;
  1873.         *(undefined1 *)(__s + 0x29) = 2;
  1874.         __s[0x2a] = rtl8264b_sds_conf;
  1875.         __s[0x2b] = 0x80c;
  1876.         *(undefined1 *)(__s + 0x2c) = 3;
  1877.         __s[0x2d] = rtl8264b_afe_conf;
  1878.         *(undefined1 *)(__s + 0x2f) = 0xd;
  1879.         __s[0x30] = rtl8264b_nctl1_conf;
  1880.         __s[0x31] = 0;
  1881.         *(undefined1 *)(__s + 0x86) = 0x1b;
  1882.         *(undefined1 *)(__s + 0x87) = 0x1b;
  1883.         *(undefined1 *)(__s + 0x89) = 1;
  1884.         __s[0x8a] = rtl8264b_top_conf;
  1885.         *(undefined1 *)(__s + 0x8c) = 2;
  1886.         __s[0x8d] = rtl8264b_sds_conf;
  1887.         __s[0x8e] = 0x80c;
  1888.         *(undefined1 *)(__s + 0x8f) = 3;
  1889.         __s[0x90] = rtl8264b_afe_conf;
  1890.         *(undefined1 *)(__s + 0x95) = 6;
  1891.         __s[0x96] = rtl8264b_nctl0_conf;
  1892.         __s[0x97] = 0xd20;
  1893.         *(undefined1 *)(__s + 0x98) = 0x13;
  1894.         *(undefined1 *)(__s + 0x99) = 0x13;
  1895.         *(undefined1 *)(__s + 0x9b) = 0x14;
  1896.         *(undefined1 *)(__s + 0x9c) = 0x14;
  1897.         *(undefined1 *)(__s + 0xa1) = 0x15;
  1898.         *(undefined1 *)(__s + 0xa2) = 0x15;
  1899.         *(undefined1 *)(__s + 0xa4) = 0x16;
  1900.         *(undefined1 *)(__s + 0xa5) = 0x16;
  1901.         *(undefined1 *)(__s + 0xaa) = 0x17;
  1902.         *(undefined1 *)(__s + 0xab) = 0x17;
  1903.         __s[0xaf] = 0x1428;
  1904.         *(undefined1 *)(__s + 0xb0) = 5;
  1905.         __s[0xb1] = rtl8264b_uc2_conf;
  1906.         __s[0xb2] = 0x1a90;
  1907.         *(undefined1 *)(__s + 0xb3) = 0x1a;
  1908.         *(undefined1 *)(__s + 0xb4) = 0x1a;
  1909.         *(undefined1 *)(__s + 0xb9) = 0xf;
  1910.         *(undefined1 *)(__s + 0xba) = 0xf;
  1911.         *(undefined1 *)(__s + 0xb6) = 0xc;
  1912.         __s[0xb8] = 0x8c0;
  1913.         *(undefined1 *)(__s + 0xbc) = 9;
  1914.         __s[0xb7] = rtl8264b_dataram_conf;
  1915.         *(undefined1 *)(__s + 0xbf) = 10;
  1916.         __s[0xbd] = rtl8264b_algxg_conf;
  1917.         __s[0xbe] = 0x5f0;
  1918.         __s[0xc0] = rtl8264b_alg_giga_conf;
  1919.         *(undefined1 *)(__s + 0x9e) = 7;
  1920.         __s[0x9f] = rtl8264b_nctl1_conf;
  1921.         __s[0xa0] = 0;
  1922.         *(undefined1 *)(__s + 0xa7) = 8;
  1923.         __s[0xa8] = rtl8264b_nctl2_conf;
  1924.         __s[0xa9] = 0x5118;
  1925.         *(undefined1 *)(__s + 0xad) = 4;
  1926.         __s[0xae] = rtl8264b_uc_conf;
  1927.         __s[0xc1] = 0x514;
  1928.         *(undefined1 *)(__s + 0xc2) = 0xb;
  1929.         __s[0xc3] = rtl8264b_normal_conf;
  1930.         __s[0xc4] = 0x71c;
  1931.         *(undefined1 *)(__s + 0xc5) = 0xd;
  1932.         __s[0xc6] = rtl8264b_nctl1_conf;
  1933.         __s[199] = 0;
  1934.       }
  1935.       *(undefined1 *)(__s + 200) = 0x1c;
  1936.       *(undefined1 *)(__s + 0xc9) = 0x1c;
  1937.       iVar1 = 0;
  1938.       *param_3 = __s;
  1939.     }
  1940.   }
  1941.   return iVar1;
  1942. }
  1943.  
  1944.  
  1945. void rtl826XB_config(int param_1,int param_2,undefined1 param_3)
  1946.  
  1947. {
  1948.   int iVar1;
  1949.   uint uVar2;
  1950.   uint uVar3;
  1951.   uint uVar4;
  1952.   uint uVar5;
  1953.   byte local_28 [8];
  1954.  
  1955.   local_28[0] = 0;
  1956.   uVar5 = 4;
  1957.   if ((param_1 - 0x23U < 6) && ((1 << (param_1 - 0x23U & 0x1f) & 0x27U) != 0)) {
  1958.     uVar5 = 1;
  1959.   }
  1960.   uVar4 = 0;
  1961.   do {
  1962.     iVar1 = hwp_get_port_by_baseport_offset(param_2,param_3,uVar4,local_28);
  1963.     if (iVar1 != 0) {
  1964.       rt_log(1);
  1965.       return;
  1966.     }
  1967.     uVar2 = (uint)local_28[0];
  1968.     uVar3 = *(uint *)(*(int *)((&unitMapStruct)[param_2 * 2] + (uVar2 + 4) * 4 + 4) + 0xc);
  1969.     if ((uVar3 & 0x80) != 0) {
  1970.       iVar1 = phy_826xb_ctrl_set(param_2,uVar2,0x1d,uVar3 >> 7 & 1);
  1971.       if (iVar1 != 0) {
  1972.         rt_log(1);
  1973.       }
  1974.       uVar2 = (uint)local_28[0];
  1975.     }
  1976.     if ((*(char *)(*(int *)((&unitMapStruct)[param_2 * 2] + (uVar2 + 4) * 4 + 4) + 0x10) != '\0') &&
  1977.        (iVar1 = phy_826xb_ctrl_set(param_2,uVar2,0x1c), iVar1 != 0)) {
  1978.       rt_log(1);
  1979.     }
  1980.     uVar4 = uVar4 + 1;
  1981.   } while (uVar4 < uVar5);
  1982.   return;
  1983. }
  1984.  
  1985.  
  1986. void rtl826XB_config(int param_1,int param_2,undefined1 param_3)
  1987.  
  1988. {
  1989.   int iVar1;
  1990.   uint uVar2;
  1991.   uint uVar3;
  1992.   uint uVar4;
  1993.   uint uVar5;
  1994.   byte local_28 [8];
  1995.  
  1996.   local_28[0] = 0;
  1997.   uVar5 = 4;
  1998.   if ((param_1 - 0x23U < 6) && ((1 << (param_1 - 0x23U & 0x1f) & 0x27U) != 0)) {
  1999.     uVar5 = 1;
  2000.   }
  2001.   uVar4 = 0;
  2002.   do {
  2003.     iVar1 = hwp_get_port_by_baseport_offset(param_2,param_3,uVar4,local_28);
  2004.     if (iVar1 != 0) {
  2005.       rt_log(1);
  2006.       return;
  2007.     }
  2008.     uVar2 = (uint)local_28[0];
  2009.     uVar3 = *(uint *)(*(int *)((&unitMapStruct)[param_2 * 2] + (uVar2 + 4) * 4 + 4) + 0xc);
  2010.     if ((uVar3 & 0x80) != 0) {
  2011.       iVar1 = phy_826xb_ctrl_set(param_2,uVar2,0x1d,uVar3 >> 7 & 1);
  2012.       if (iVar1 != 0) {
  2013.         rt_log(1);
  2014.       }
  2015.       uVar2 = (uint)local_28[0];
  2016.     }
  2017.     if ((*(char *)(*(int *)((&unitMapStruct)[param_2 * 2] + (uVar2 + 4) * 4 + 4) + 0x10) != '\0') &&
  2018.        (iVar1 = phy_826xb_ctrl_set(param_2,uVar2,0x1c), iVar1 != 0)) {
  2019.       rt_log(1);
  2020.     }
  2021.     uVar4 = uVar4 + 1;
  2022.   } while (uVar4 < uVar5);
  2023.   return;
  2024. }
Advertisement
Add Comment
Please, Sign In to add comment