9.9 Clearing Uninitialized Data (BSS) Section

Prior to loading a segment into memory, the application must invalidate the corresponding cache lines. The makerom() makes appropriate symbols available to the application that can be used to construct the arguments to the osInvalDCache() routines. Then the actual DMA from ROM to DRAM may be performed, as well as the clearing of the uninitialized data (BSS) section of the segment. It is important that the clearing be performed before the BSS section can be used. Again, makerom() generated symbols may be used for the bzero() call. Following is some sample code that illustrates the process:

extern    char    _newSegmentRomStart[],_newSegmentRomEnd[];
extern    char    _newSegmentStart[];
extern    char    _newSegmentDataStart[],_newSegmentDataEnd[];
extern    char    _newSegmentBssStart[],_newSegmentBssEnd[];

osInvalDCache(_newSegmentDataStart,
    _newSegmentDataEnd-_plainSegmentDataStart);
osPiStartDma(&dmaIOMessageBuf,OS_MESG_PRI_NORMAL,OS_READ,
    (u32)_newSegmentRomStart,_newSegmentStart,
    (u32)_newSegmentRomEnd - (u32)_newSegmentRomStart,
        &dmaMessageQ);

bzero(_newSegmentBssStart,
    _newSegmentBssEnd-_newSegmentBssStart);

(void)osRecvMesg(&dmaMessageQ,NULL,OS_MESG_BLOCK);

UP