]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blobdiff - src/ethboot/ethboot.c
Build: update setupenvLnx.sh to do error checking
[keystone-rtos/ibl.git] / src / ethboot / ethboot.c
index 9df2053136026df919cc3ca8848912024817a985..163a411b1133e81a85d9e0e3a6e49eb0954fff14 100644 (file)
 #include "device.h"
 #include "mdioapi.h"
 #include <string.h>
+#include "net_osal.h"
+#include "cpsw_api.h"
+#include "qm_api.h"
+#include "cpdma_api.h"
 
 /**
  *  @brief Remove the possible re-definition of iblEthBoot. iblcfg.h defines this to be a void
@@ -93,7 +97,7 @@ void ibl_rec_params (void *params)
     UNFORM_IPN(iblStatus.ethParams.ipAddr, netdev->ip_address);
     UNFORM_IPN(iblStatus.ethParams.serverIp, netdev->server_ip);
 
-    memcpy (iblStatus.ethParams.hwAddress, netdev->mac_address, sizeof(iblStatus.ethParams.hwAddress));
+    netMemcpy (iblStatus.ethParams.hwAddress, netdev->mac_address, sizeof(iblStatus.ethParams.hwAddress));
     strncpy (iblStatus.ethParams.fileName, netdev->file_name, sizeof(iblStatus.ethParams.fileName));
 
 }
@@ -110,11 +114,10 @@ void iblEthBoot (Int32 eIdx)
     void    (*exit)();
     uint8   buf[16];
     char    *ext;
-
-
+    unsigned int i,j;
 
     /* Power up the device. No action is taken if the device is already powered up */
-    if (devicePowerPeriph (TARGET_PWR_ETH(ibl.ethConfig[eIdx].port)) < 0)
+    if (devicePowerPeriph (TARGET_PWR_ETH(ibl.bootModes[eIdx].port)) < 0)
         return;
 
     /* Do any mdio configuration */
@@ -122,33 +125,71 @@ void iblEthBoot (Int32 eIdx)
         hwMdio (ibl.mdioConfig.nMdioOps, ibl.mdioConfig.mdio, 
                 ibl.mdioConfig.mdioClkDiv, ibl.mdioConfig.interDelay);
 
+    for (j = 0; j < 0x100; j++)
+       for (i = 0; i < 0x1000000; i++);
 
     /* SGMII configuration. If sgmii is not present this statement is defined
      * to void in target.h */
-    hwSgmiiConfig (ibl.ethConfig[eIdx].port, &ibl.sgmiiConfig[eIdx]);
+    for (n = 0; n < ibl_N_ETH_PORTS; n++)  {
+        if (ibl.sgmiiConfig[n].configure == TRUE)
+            hwSgmiiConfig (n, &ibl.sgmiiConfig[n]);
+    }
+
+
+#ifdef DEVICE_CPSW
+    /* On chip switch configuration */
+    hwCpswConfig (targetGetSwitchCtl(), targetGetSwitchMaxPktSize());
+#endif
+
+
+#ifdef DEVICE_QM
+    /* Queue manager configuration */
+    hwQmSetup ((qmConfig_t *)(targetGetQmConfig()));
+    targetInitQs ();
+#endif
+    
+
+#ifdef DEVICE_CPDMA
+    /* Cpdma configuration. */
+    hwCpdmaRxConfig ((cpdmaRxCfg_t *)targetGetCpdmaRxConfig());
+    hwCpdmaTxConfig ((cpdmaTxCfg_t *)targetGetCpdmaTxConfig());
+#endif
+
+
+#ifdef DEVICE_PA
+    /* Packet accelerator configuration. If PA is not present this statement is defined
+     * to void in target.h */
+    targetPaConfig(ibl.bootModes[eIdx].u.ethBoot.ethInfo.hwAddress);
+#endif
 
 
-    nDevice.port_num = ibl.ethConfig[eIdx].port;
+#ifdef DEVICE_SS
+    /* Streaming switch configuration. If not present this statement is defined to void
+     * in target.h.  If present this is usually defined to a series of register writes */
+    hwConfigStreamingSwitch();
+#endif
+
+    nDevice.port_num = ibl.bootModes[eIdx].port;
 
     /* Simple transation to initialize the driver */
-    memcpy (nDevice.mac_address, ibl.ethConfig[eIdx].ethInfo.hwAddress, sizeof(nDevice.mac_address));
+    netMemcpy (nDevice.mac_address, ibl.bootModes[eIdx].u.ethBoot.ethInfo.hwAddress, sizeof(nDevice.mac_address));
 
-    nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.ipAddr);
-    if (ibl.ethConfig[eIdx].doBootp == TRUE)
+    nl = FORM_IPN(ibl.bootModes[eIdx].u.ethBoot.ethInfo.ipAddr);
+    if (ibl.bootModes[eIdx].u.ethBoot.doBootp == TRUE)
         nDevice.ip_address = 0;
     else
         nDevice.ip_address = htonl(nl);
 
-    nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.netmask);
+    nl = FORM_IPN(ibl.bootModes[eIdx].u.ethBoot.ethInfo.netmask);
     nDevice.net_mask  = htonl(nl);
 
-    nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.serverIp);
+    nl = FORM_IPN(ibl.bootModes[eIdx].u.ethBoot.ethInfo.serverIp);
     nDevice.server_ip           = htonl(nl);
-    nDevice.use_bootp_server_ip = ibl.ethConfig[eIdx].useBootpServerIp;
+    nDevice.use_bootp_server_ip = ibl.bootModes[eIdx].u.ethBoot.useBootpServerIp;
 
     /* Note - the file name structure in nDevice is only 64 bytes, but 128 in ethInfo */
-    memcpy (nDevice.file_name, ibl.ethConfig[eIdx].ethInfo.fileName, sizeof(nDevice.file_name));
-    nDevice.use_bootp_file_name = ibl.ethConfig[eIdx].useBootpFileName;
+    netMemcpy (nDevice.file_name, ibl.bootModes[eIdx].u.ethBoot.ethInfo.fileName, sizeof(nDevice.file_name));
+    nDevice.use_bootp_file_name = ibl.bootModes[eIdx].u.ethBoot.useBootpFileName;
 
 
     nDevice.start    = cpmac_drv_start;
@@ -176,7 +217,7 @@ void iblEthBoot (Int32 eIdx)
         }
     }
 
-    format = ibl.ethConfig[eIdx].bootFormat;
+    format = ibl.bootModes[eIdx].u.ethBoot.bootFormat;
 
     /* If the data format was based on the name extension, determine
      * the boot data format */
@@ -222,7 +263,8 @@ void iblEthBoot (Int32 eIdx)
 
     }
 
-    entry = iblBoot (&net_boot_module, format, &ibl.ethConfig[eIdx].blob);
+
+    entry = iblBoot (&net_boot_module, format, &ibl.bootModes[eIdx].u.ethBoot.blob);
 
 
     /* Before closing the module read any remaining data. In the coff boot mode the boot may
@@ -255,6 +297,24 @@ void iblEthBoot (Int32 eIdx)
     /* Close up the peripheral */
     (*net_boot_module.close)();
 
+
+#ifdef DEVICE_PA
+    hwPaDisable ();
+#endif
+
+#ifdef DEVICE_CPDMA
+    /* Cpdma configuration. */
+    hwCpdmaRxDisable ((cpdmaRxCfg_t *)targetGetCpdmaRxConfig());
+    hwCpdmaTxDisable ((cpdmaTxCfg_t *)targetGetCpdmaTxConfig());
+#endif
+
+#ifdef DEVICE_QM
+    targetFreeQs ();
+    /* Queue manager configuration */
+    hwQmTeardown ();
+#endif
+
+
     if (entry != 0)  {
 
         iblStatus.exitAddress = entry;