diff options
author | Stephan Broyles <sbroyles@us.ibm.com> | 2014-12-02 18:04:41 -0600 |
---|---|---|
committer | Stephan Broyles <sbroyles@us.ibm.com> | 2014-12-03 17:11:47 -0600 |
commit | e32313ef0f20d06431b3f28991dc347d9c85288e (patch) | |
tree | b38dcb99c86b84ec22d173793afc6b96060a7bcf /src/occBootLoader/bootMain.c | |
parent | 295514f9eb137f9d866fe03e7c378ca2cbd67e77 (diff) | |
download | talos-occ-e32313ef0f20d06431b3f28991dc347d9c85288e.tar.gz talos-occ-e32313ef0f20d06431b3f28991dc347d9c85288e.zip |
Bootloader file clean up.
Change-Id: I6037b4350cb2ce5911599c702de24464be9fc5d2
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/14683
Reviewed-by: Stephan Broyles <sbroyles@us.ibm.com>
Tested-by: Stephan Broyles <sbroyles@us.ibm.com>
Diffstat (limited to 'src/occBootLoader/bootMain.c')
-rwxr-xr-x | src/occBootLoader/bootMain.c | 140 |
1 files changed, 58 insertions, 82 deletions
diff --git a/src/occBootLoader/bootMain.c b/src/occBootLoader/bootMain.c index 10df75f..64333c8 100755 --- a/src/occBootLoader/bootMain.c +++ b/src/occBootLoader/bootMain.c @@ -1,25 +1,25 @@ -/****************************************************************************** -// @file bootMain.c -// @brief OCC boot loader main -*/ -/****************************************************************************** - * - * @page ChangeLogs Change Logs - * @section bootMain.c BOOTMAIN.C - * @verbatim - * - * Flag Def/Fea Userid Date Description - * ------- ---------- -------- ---------- ---------------------------------- - * @pb000 pbavari 06/22/2011 Created - * @dw000 dwoodham 12/12/2011 Update call to IMAGE_HEADER macro - * @rc003 rickylie 02/03/2012 Verify & Clean Up OCC Headers & Comments - * @th00c thallet 03/02/2012 VPO Changes to 405 Caching - * @sb000 905048 sbroyles 10/28/2013 Add tags for code cleanup, - * see RTC task 73327. -* @sb001 906184 sbroyles 11/11/2013 Resolve fix tags - * @endverbatim - * - *///*************************************************************************/ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/occBootLoader/bootMain.c $ */ +/* */ +/* OpenPOWER OnChipController Project */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ //************************************************************************* // Includes @@ -36,9 +36,8 @@ extern void __boot_low_level_init; //************************************************************************* // Image header //************************************************************************* -//@dw001c - added arg: idNum = ID_NUM_INVALID -IMAGE_HEADER (G_bootImageHdr,__boot_low_level_init,BOOT_LOADER_ID, - ID_NUM_INVALID); +IMAGE_HEADER(G_bootImageHdr,__boot_low_level_init,BOOT_LOADER_ID, + ID_NUM_INVALID); //************************************************************************* // Macros @@ -61,8 +60,8 @@ IMAGE_HEADER (G_bootImageHdr,__boot_low_level_init,BOOT_LOADER_ID, //************************************************************************* //Forward declaration uint32_t boot_test_sram(); -uint32_t boot_load_image(const imageHdr_t * i_hdrAddr); -uint32_t calChecksum(const uint32_t i_startAddr,const uint32_t i_sz ); +uint32_t boot_load_image(const imageHdr_t *i_hdrAddr); +uint32_t calChecksum(const uint32_t i_startAddr ,const uint32_t i_sz); //************************************************************************* // Functions @@ -73,9 +72,7 @@ uint32_t calChecksum(const uint32_t i_startAddr,const uint32_t i_sz ); // Name: boot_main // // Description: boot main will test SRAM, copy main application image from -// main memory to SRAM, validate checksum and calls ssx_boot. -// -// Flow: 06/22/2011 FN= boot_main +// main memory to SRAM, validate checksum and call ssx_boot. // // End Function Specification void main() @@ -85,30 +82,30 @@ void main() WRITE_TO_SPRG0(BOOT_TEST_SRAM_CHKPOINT); #ifndef VPO - // @th00c - This is ifdef'd out b/c it takes too long to run in VPO + // This is ifdef'd out b/c it takes too long to run in VPO // Test SRAM l_rc = boot_test_sram(); #endif // If failed to test SRAM, write failed return code to SPRG1 and halt - if( 0 != l_rc ) + if(0 != l_rc) { WRITE_TO_SPRG1_AND_HALT(l_rc); } // set imageHdr_t pointer to point to boot image header to get to boot // image size. This way we can get to main application image header. - imageHdr_t *l_hdrPtr = (imageHdr_t*)(G_bootImageHdr.start_addr + - G_bootImageHdr.image_size ); + imageHdr_t *l_hdrPtr = (imageHdr_t *)(G_bootImageHdr.start_addr + + G_bootImageHdr.image_size); // set checkpoint to boot load main application image to SRAM - WRITE_TO_SPRG0(BOOT_LOAD_IMAGE_CHKPOINT ); + WRITE_TO_SPRG0(BOOT_LOAD_IMAGE_CHKPOINT); // Load main application image to SRAM including main application header l_rc = boot_load_image(l_hdrPtr); // If failed to load image, write failed return code to SPRG1 and halt - if( 0 != l_rc ) + if(0 != l_rc) { WRITE_TO_SPRG1_AND_HALT(l_rc); } @@ -121,7 +118,7 @@ void main() l_hdrPtr->image_size); // If checksum does not match, store bad checksum into SPRG1 and halt - if( l_checksum != l_hdrPtr->checksum) + if(l_checksum != l_hdrPtr->checksum) { WRITE_TO_SPRG1_AND_HALT(l_checksum); } @@ -129,29 +126,18 @@ void main() // set checkpoint to get nest frequency WRITE_TO_SPRG0(BOOT_GET_NEST_FREQ_CHKPOINT); - // @sb001 Remove this local. - //uint32_t l_nestFreq = 2400000; - // set checkpoint to call to SSX_BOOT WRITE_TO_SPRG0(BOOT_SSX_BOOT_CALL_CHKPOINT); - // Invalidate Data Cache before calling __ssx_boot() - //dcache_invalidate_all(); // @th00c - // create function pointer pointing to main application header entry point - // address. This is similar to jump/branch to address in assembly - - // @sb001 Don't pass l_nestFreq anymore, ssx boot code isn't reading it. - //void (*execute_ssx_boot)(uint32_t) = (void (*)(uint32_t)) l_hdrPtr->ep_addr; - //(*execute_ssx_boot)(l_nestFreq); - void (*execute_ssx_boot)(void) = (void (*)(void)) l_hdrPtr->ep_addr; + // address. + void (*execute_ssx_boot)(void) = (void (*)(void))l_hdrPtr->ep_addr; (*execute_ssx_boot)(); // set checkpoint to return from ssx_boot. This should never happen so // halt at this point. WRITE_TO_SPRG0(BOOT_SSX_RETURNED_CHKPOINT); WRITE_TO_SPRG1_AND_HALT(l_hdrPtr->ep_addr); - } // Function Specification @@ -162,24 +148,21 @@ void main() // bytes. Skip checksum field in the imageHdr_t while calculating // checksum // -// Flow: None FN= None -// // End Function Specification - -uint32_t calChecksum(const uint32_t i_startAddr,const uint32_t i_sz ) +uint32_t calChecksum(const uint32_t i_startAddr, const uint32_t i_sz) { uint32_t l_checksum = 0; uint32_t l_counter = 0; - uint8_t * l_srcPtr = (uint8_t *) (i_startAddr); + uint8_t *l_srcPtr = (uint8_t *)(i_startAddr); - while (l_counter < i_sz ) + while(l_counter < i_sz) { l_checksum += (*(l_srcPtr + l_counter)); l_counter = l_counter + 1; - if( l_counter == (uint32_t)(offsetof(imageHdr_t,checksum))) + if(l_counter == (uint32_t)(offsetof(imageHdr_t,checksum))) { - l_counter = ((uint32_t)(offsetof(imageHdr_t,checksum)) + - sizeof(G_bootImageHdr.checksum)); + l_counter = ((uint32_t)(offsetof(imageHdr_t,checksum)) + + sizeof(G_bootImageHdr.checksum)); } } @@ -193,12 +176,8 @@ uint32_t calChecksum(const uint32_t i_startAddr,const uint32_t i_sz ) // Description: This function copies main application image from main memory // to SRAM // -// -// Flow: 06/22/2011 FN= boot_load_image -// // End Function Specification - -uint32_t boot_load_image(const imageHdr_t * i_hdrAddr ) +uint32_t boot_load_image(const imageHdr_t *i_hdrAddr) { uint32_t l_rc = 0x0; uint32_t l_mainAppDestRang = (i_hdrAddr->start_addr) + @@ -206,13 +185,13 @@ uint32_t boot_load_image(const imageHdr_t * i_hdrAddr ) // Make sure main application destination rang address falls within SRAM // range. - if( ( l_mainAppDestRang < SRAM_START_ADDRESS) || - (l_mainAppDestRang > SRAM_END_ADDRESS )) + if((l_mainAppDestRang < SRAM_START_ADDRESS) || + (l_mainAppDestRang > SRAM_END_ADDRESS)) { // Return destination rang address if address is out of range and // address is not zero. If address is zero, then return eye-catcher // address. - if( l_mainAppDestRang != 0 ) + if(l_mainAppDestRang != 0) { l_rc = l_mainAppDestRang; } @@ -221,14 +200,14 @@ uint32_t boot_load_image(const imageHdr_t * i_hdrAddr ) l_rc = EYE_CATCHER_ADDRESS; } } - //Make sure main application start address falls within SRAM range - else if ((i_hdrAddr->start_addr < SRAM_START_ADDRESS) || - (i_hdrAddr->start_addr > SRAM_END_ADDRESS)) + // Make sure main application start address falls within SRAM range + else if((i_hdrAddr->start_addr < SRAM_START_ADDRESS) || + (i_hdrAddr->start_addr > SRAM_END_ADDRESS)) { // Return start address if address is out of range and // address is not zero. If address is zero, then return eye-catcher // address. - if( i_hdrAddr->start_addr != 0 ) + if(i_hdrAddr->start_addr != 0) { l_rc = i_hdrAddr->start_addr; } @@ -244,11 +223,11 @@ uint32_t boot_load_image(const imageHdr_t * i_hdrAddr ) // Now copy main application header specified // size of data from main memory to main application header specified // start address. - uint8_t * l_srcPtr = (uint8_t *) (i_hdrAddr); - uint8_t * l_destPtr = (uint8_t *) (i_hdrAddr->start_addr); + uint8_t *l_srcPtr = (uint8_t *)(i_hdrAddr); + uint8_t *l_destPtr = (uint8_t *)(i_hdrAddr->start_addr); uint32_t l_numWords = i_hdrAddr->image_size; - while (l_numWords != 0 ) + while(l_numWords != 0) { *l_destPtr = *l_srcPtr; l_destPtr++; @@ -269,8 +248,6 @@ uint32_t boot_load_image(const imageHdr_t * i_hdrAddr ) // verifying it back through read // // -// Flow: 06/22/2011 FN= boot_test_sram -// // End Function Specification uint32_t boot_test_sram() @@ -278,23 +255,23 @@ uint32_t boot_test_sram() uint32_t l_rc = 0; // Point start to SRAM start address - uint32_t * l_startPtr = (uint32_t *) SRAM_TEST_START_ADDRESS; + uint32_t *l_startPtr = (uint32_t *)SRAM_TEST_START_ADDRESS; // Copy bit pattern from start until SRAM end address - while( (uint32_t)l_startPtr < SRAM_TEST_END_ADDRESS ) + while((uint32_t)l_startPtr < SRAM_TEST_END_ADDRESS) { *l_startPtr = SRAM_TEST_BIT_PATTERN; l_startPtr++; } // Reset start pointer to point to SRAM start Address - l_startPtr = (uint32_t *) SRAM_TEST_START_ADDRESS; + l_startPtr = (uint32_t *)SRAM_TEST_START_ADDRESS; //Read and verify bit pattern that was written. If pattern does not match, // return address that failed to match the pattern. - while( (uint32_t)l_startPtr < SRAM_TEST_END_ADDRESS ) + while((uint32_t)l_startPtr < SRAM_TEST_END_ADDRESS) { - if( (*l_startPtr) != SRAM_TEST_BIT_PATTERN) + if((*l_startPtr) != SRAM_TEST_BIT_PATTERN) { l_rc = (uint32_t)l_startPtr; break; @@ -305,4 +282,3 @@ uint32_t boot_test_sram() return l_rc; } - |