Clearing Uninitialized Data (BSS) Section

Prior to loading a segment into memory, the application must invalidate the corresponding cache lines. The makerom (1P) makes appropriate symbols available to the application that can be used to construct the arguments to the osInvalDCache (3P) 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 (1P) 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);

Copyright © 1999 Nintendo of America Inc. All Rights Reserved Nintendo and N64 are registered trademarks of Nintendo Last Updated January, 1999