]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blobdiff - src/main/iblinit.c
Corrected merge for 6657 ibl
[keystone-rtos/ibl.git] / src / main / iblinit.c
index 5b5642f300df5ee56235c6dc00375d620ed975dc..cfe60fa2d4d423bfea660bc5458253d7b97e1ffc 100644 (file)
@@ -189,7 +189,7 @@ uint16 swap16val (uint16 v)
  */
 void iblSwap (void)
 {
-    int i;
+    int i, j, k;
 
     ibl.iblMagic = swap32val (ibl.iblMagic);
 
@@ -241,7 +241,7 @@ void iblSwap (void)
 
 
     for (i = 0; i < ibl_N_ETH_PORTS; i++)  {
-        ibl.sgmiiConfig[i].configure     = swap32val(ibl.sgmiiConfig[i].configure);
+        ibl.sgmiiConfig[i].configure     = swap16val(ibl.sgmiiConfig[i].configure);
         ibl.sgmiiConfig[i].adviseAbility = swap32val(ibl.sgmiiConfig[i].adviseAbility);
         ibl.sgmiiConfig[i].control       = swap32val(ibl.sgmiiConfig[i].control);
         ibl.sgmiiConfig[i].txConfig      = swap32val(ibl.sgmiiConfig[i].txConfig);
@@ -268,7 +268,7 @@ void iblSwap (void)
     for (i = 0; i < ibl_MAX_EMIF_PMEM; i++)  {
         ibl.emifConfig[i].csSpace    = swap16val(ibl.emifConfig[i].csSpace);
         ibl.emifConfig[i].busWidth   = swap16val(ibl.emifConfig[i].busWidth);
-        ibl.emifConfig[i].waitEnable = swap32val(ibl.emifConfig[i].waitEnable);
+        ibl.emifConfig[i].waitEnable = swap16val(ibl.emifConfig[i].waitEnable);
     }
 
 
@@ -278,9 +278,9 @@ void iblSwap (void)
         ibl.bootModes[i].port     = swap32val(ibl.bootModes[i].port);
 
         if (ibl.bootModes[i].bootMode == ibl_BOOT_MODE_TFTP)  {
-            ibl.bootModes[i].u.ethBoot.doBootp            = swap32val(ibl.bootModes[i].u.ethBoot.doBootp);
-            ibl.bootModes[i].u.ethBoot.useBootpServerIp   = swap32val(ibl.bootModes[i].u.ethBoot.useBootpServerIp);
-            ibl.bootModes[i].u.ethBoot.useBootpFileName   = swap32val(ibl.bootModes[i].u.ethBoot.useBootpFileName);
+            ibl.bootModes[i].u.ethBoot.doBootp            = swap16val(ibl.bootModes[i].u.ethBoot.doBootp);
+            ibl.bootModes[i].u.ethBoot.useBootpServerIp   = swap16val(ibl.bootModes[i].u.ethBoot.useBootpServerIp);
+            ibl.bootModes[i].u.ethBoot.useBootpFileName   = swap16val(ibl.bootModes[i].u.ethBoot.useBootpFileName);
             ibl.bootModes[i].u.ethBoot.bootFormat         = swap32val(ibl.bootModes[i].u.ethBoot.bootFormat);
             ibl.bootModes[i].u.ethBoot.blob.startAddress  = swap32val(ibl.bootModes[i].u.ethBoot.blob.startAddress);
             ibl.bootModes[i].u.ethBoot.blob.sizeBytes     = swap32val(ibl.bootModes[i].u.ethBoot.blob.sizeBytes);
@@ -288,35 +288,59 @@ void iblSwap (void)
 
         }  else if (ibl.bootModes[i].bootMode == ibl_BOOT_MODE_NAND)  {
             ibl.bootModes[i].u.nandBoot.bootFormat             = swap32val(ibl.bootModes[i].u.nandBoot.bootFormat);
-            ibl.bootModes[i].u.nandBoot.bootAddress            = swap32val(ibl.bootModes[i].u.nandBoot.bootAddress);
+            for (j = 0; j < ibl_N_ENDIANS; j++)
+            {
+                for (k = 0; k < ibl_N_IMAGES; k++)
+                {
+                    ibl.bootModes[i].u.nandBoot.bootAddress[j][k] = swap32val(ibl.bootModes[i].u.nandBoot.bootAddress[j][k]);
+                }
+            }
             ibl.bootModes[i].u.nandBoot.interface              = swap32val(ibl.bootModes[i].u.nandBoot.interface);
-            ibl.bootModes[i].u.nandBoot.blob.startAddress      = swap32val(ibl.bootModes[i].u.nandBoot.blob.startAddress);
-            ibl.bootModes[i].u.nandBoot.blob.sizeBytes         = swap32val(ibl.bootModes[i].u.nandBoot.blob.sizeBytes);
-            ibl.bootModes[i].u.nandBoot.blob.branchAddress     = swap32val(ibl.bootModes[i].u.nandBoot.blob.branchAddress);
+            for (j = 0; j < ibl_N_ENDIANS; j++)
+            {
+                for (k = 0; k < ibl_N_IMAGES; k++)
+                {
+                    ibl.bootModes[i].u.nandBoot.blob[j][k].startAddress  = swap32val(ibl.bootModes[i].u.nandBoot.blob[j][k].startAddress);
+                    ibl.bootModes[i].u.nandBoot.blob[j][k].sizeBytes     = swap32val(ibl.bootModes[i].u.nandBoot.blob[j][k].sizeBytes);
+                    ibl.bootModes[i].u.nandBoot.blob[j][k].branchAddress = swap32val(ibl.bootModes[i].u.nandBoot.blob[j][k].branchAddress);
+                }
+            }
             ibl.bootModes[i].u.nandBoot.nandInfo.busWidthBits  = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.busWidthBits);
             ibl.bootModes[i].u.nandBoot.nandInfo.pageSizeBytes = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.pageSizeBytes);
             ibl.bootModes[i].u.nandBoot.nandInfo.pageEccBytes  = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.pageEccBytes);
             ibl.bootModes[i].u.nandBoot.nandInfo.pagesPerBlock = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.pagesPerBlock);
             ibl.bootModes[i].u.nandBoot.nandInfo.totalBlocks   = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.totalBlocks);
             ibl.bootModes[i].u.nandBoot.nandInfo.addressBytes  = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.addressBytes);
-            ibl.bootModes[i].u.nandBoot.nandInfo.lsbFirst      = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.lsbFirst);
+            ibl.bootModes[i].u.nandBoot.nandInfo.lsbFirst      = swap16val(ibl.bootModes[i].u.nandBoot.nandInfo.lsbFirst);
             ibl.bootModes[i].u.nandBoot.nandInfo.blockOffset   = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.blockOffset);
             ibl.bootModes[i].u.nandBoot.nandInfo.pageOffset    = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.pageOffset);
             ibl.bootModes[i].u.nandBoot.nandInfo.columnOffset  = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.columnOffset);
-            ibl.bootModes[i].u.nandBoot.nandInfo.postCommand   = swap32val(ibl.bootModes[i].u.nandBoot.nandInfo.postCommand);
-
+            ibl.bootModes[i].u.nandBoot.nandInfo.postCommand   = swap16val(ibl.bootModes[i].u.nandBoot.nandInfo.postCommand);
         }  else if (ibl.bootModes[i].bootMode == ibl_BOOT_MODE_NOR)  {
             ibl.bootModes[i].u.norBoot.bootFormat         = swap32val(ibl.bootModes[i].u.norBoot.bootFormat);
-            ibl.bootModes[i].u.norBoot.bootAddress        = swap32val(ibl.bootModes[i].u.norBoot.bootAddress);
+            for (j = 0; j < ibl_N_ENDIANS; j++)
+            {
+                for (k = 0; k < ibl_N_IMAGES; k++)
+                {
+                    ibl.bootModes[i].u.norBoot.bootAddress[j][k] = swap32val(ibl.bootModes[i].u.norBoot.bootAddress[j][k]);
+                }
+            }
             ibl.bootModes[i].u.norBoot.interface          = swap32val(ibl.bootModes[i].u.norBoot.interface);
-            ibl.bootModes[i].u.norBoot.blob.startAddress  = swap32val(ibl.bootModes[i].u.norBoot.blob.startAddress);
-            ibl.bootModes[i].u.norBoot.blob.sizeBytes     = swap32val(ibl.bootModes[i].u.norBoot.blob.sizeBytes);
-            ibl.bootModes[i].u.norBoot.blob.branchAddress = swap32val(ibl.bootModes[i].u.norBoot.blob.branchAddress);
+            for (j = 0; j < ibl_N_ENDIANS; j++)
+            {
+                for (k = 0; k < ibl_N_IMAGES; k++)
+                {
+                    ibl.bootModes[i].u.norBoot.blob[j][k].startAddress  = swap32val(ibl.bootModes[i].u.norBoot.blob[j][k].startAddress);
+                    ibl.bootModes[i].u.norBoot.blob[j][k].sizeBytes     = swap32val(ibl.bootModes[i].u.norBoot.blob[j][k].sizeBytes);
+                    ibl.bootModes[i].u.norBoot.blob[j][k].branchAddress = swap32val(ibl.bootModes[i].u.norBoot.blob[j][k].branchAddress);
+                }
+            }
 
         }
 
     }
 
+    ibl.iblEvmType = swap16val (ibl.iblEvmType);
     ibl.chkSum = swap16val (ibl.chkSum);
 }
 
@@ -434,7 +458,10 @@ void main (void)
     iblStatus.iblVersion   = ibl_VERSION;
     iblStatus.activeDevice = ibl_ACTIVE_DEVICE_I2C;
 
-
+#ifdef C665x
+     /*Set GPIO as SPI,UART*/
+    configureGPIO();
+#endif
     /* Determine the boot device to read from */
     bootDevice = deviceReadBootDevice();