// ------------------------------------------------------------------ // Fake readPNOR - image is in memory // ------------------------------------------------------------------ errlHndl_t readPNOR ( uint64_t i_byteAddr, size_t i_numBytes, void * o_data, TARGETING::Target * i_target, pnorInformation & i_pnorInfo, uint64_t &io_cachedAddr, mutex_t * i_mutex ) { errlHndl_t err = NULL; int64_t vpdLocation = 0; uint64_t addr = 0x0; const char * readAddr = NULL; TRACSSCOMP( g_trac_vpd, ENTER_MRK"RT fake readPNOR()" ); do { // fake getPnorAddr gets memory address of VPD err = getPnorAddr(i_pnorInfo, io_cachedAddr, i_mutex ); if(err) { break; } addr = io_cachedAddr; err = getVpdLocation( vpdLocation, i_target); if(err) { break; } // Add Offset for target vpd location addr += (vpdLocation * i_pnorInfo.segmentSize); // Add keyword offset addr += i_byteAddr; TRACUCOMP( g_trac_vpd, INFO_MRK"Address to read: 0x%08x", addr ); readAddr = reinterpret_cast<const char *>( addr ); memcpy( o_data, readAddr, i_numBytes ); } while(0); TRACSSCOMP( g_trac_vpd, EXIT_MRK"RT fake readPNOR()" ); return err; }
// ------------------------------------------------------------------ // writePNOR // ------------------------------------------------------------------ errlHndl_t writePNOR ( uint64_t i_byteAddr, size_t i_numBytes, void * i_data, TARGETING::Target * i_target, pnorInformation & i_pnorInfo, uint64_t &io_cachedAddr, mutex_t * i_mutex ) { errlHndl_t err = NULL; int64_t vpdLocation = 0; uint64_t addr = 0x0; const char * writeAddr = NULL; TRACSSCOMP( g_trac_vpd, ENTER_MRK"writePNOR()" ); do { // Check if we have the PNOR addr cached. if( 0x0 == io_cachedAddr ) { err = getPnorAddr( i_pnorInfo, io_cachedAddr, i_mutex ); if( err ) { break; } } addr = io_cachedAddr; // Find vpd location of the target err = getVpdLocation( vpdLocation, i_target ); if( err ) { break; } // Offset cached address by vpd location multiplier addr += (vpdLocation * i_pnorInfo.segmentSize); // Now offset into that chunk of data by i_byteAddr addr += i_byteAddr; //TODO: Validate write is within bounds of appropriate PNOR // partition/section. RTC: 51807 TRACUCOMP( g_trac_vpd, INFO_MRK"Address to write: 0x%08x", addr ); // Write the data writeAddr = reinterpret_cast<const char*>( addr ); memcpy( (void*)(writeAddr), i_data, i_numBytes ); // @todo RTC:117042 - enable flush once PNOR writes supported // Flush the page to make sure it gets to the PNOR #if 0 int rc = mm_remove_pages( FLUSH, (void*)addr, i_numBytes ); if( rc ) { TRACFCOMP(g_trac_vpd,ERR_MRK"writePNOR() Error from mm_remove_pages, rc=%d",rc); /*@ * @errortype * @moduleid VPD_WRITE_PNOR * @reasoncode VPD_REMOVE_PAGES_FAIL * @userdata1 Requested Address * @userdata2 rc from mm_remove_pages * @devdesc writePNOR mm_remove_pages FLUSH failed */ err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, VPD_WRITE_PNOR, VPD_REMOVE_PAGES_FAIL, addr, TO_UINT64(rc), true /*Add HB Software Callout*/ ); } #endif } while( 0 ); TRACSSCOMP( g_trac_vpd, EXIT_MRK"writePNOR()" ); return err; }
// ------------------------------------------------------------------ // readPNOR // ------------------------------------------------------------------ errlHndl_t readPNOR ( uint64_t i_byteAddr, size_t i_numBytes, void * o_data, TARGETING::Target * i_target, pnorInformation & i_pnorInfo, uint64_t &io_cachedAddr, mutex_t * i_mutex ) { errlHndl_t err = NULL; int64_t vpdLocation = 0; uint64_t addr = 0x0; const char * readAddr = NULL; TRACSSCOMP( g_trac_vpd, ENTER_MRK"readPNOR()" ); do { // Check if we have the PNOR addr cached. if( 0x0 == io_cachedAddr ) { err = getPnorAddr( i_pnorInfo, io_cachedAddr, i_mutex ); if( err ) { break; } } addr = io_cachedAddr; // Find vpd location of the target err = getVpdLocation( vpdLocation, i_target ); if( err ) { break; } // Offset cached address by vpd location multiplier addr += (vpdLocation * i_pnorInfo.segmentSize); // Now offset into that chunk of data by i_byteAddr addr += i_byteAddr; TRACUCOMP( g_trac_vpd, INFO_MRK"Address to read: 0x%08x", addr ); //TODO: Validate write is within bounds of appropriate PNOR // partition/section. RTC: 51807 // Pull the data readAddr = reinterpret_cast<const char*>( addr ); memcpy( o_data, readAddr, i_numBytes ); } while( 0 ); TRACSSCOMP( g_trac_vpd, EXIT_MRK"readPNOR()" ); return err; }