How to use yaffs_guts
This article mainly explains "how to use yaffs_guts". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use yaffs_guts.
1. Calculate the bitmap of the given Block
Static _ _ inline _ _ U8 * yaffs_BlockBits (yaffs_Device * dev, int blk)
{
Return dev- > chunkBits + (dev- > chunkBitmapStride * (blk-dev- > internalStartBlock))
}
/ / chunkbits and chunkBitmapStride are two very interesting things. They make up the bitmap architecture of the entire nandflash. For a 32-page nandflash, the chunkBitmapStride is 4 and the chunkbits is 8-bit, which is exactly 4-8-32, that is, each bit corresponds to an page in the nandflash. Of course, each block is allocated when the system is mounted and initialized, that is to say, every bit in the first address corresponds to a page of the nandflash. Of course, an address corresponds to eight pages.
The system maintains a bitmap in the device description structure yaffs_Device. Each bit of the bitmap represents the state of a chunk on the Flash. Yaffs_SetChunkBit () takes the corresponding position 1 of the newly assigned chunk in the bitmap, indicating that the block has been used. After updating some statistics, you can return.
two。 Zero the first chunkBitmapStride bytes of the given chunk
Static _ _ inline__ void yaffs_ClearChunkBits (yaffs_Device * dev,int blk)
{
_ _ U8 * blkBits = yaffs_BlockBits (dev,blk)
Memset (blkBits,0,dev- > chunkBitmapStride)
}
At this point, I believe you have a deeper understanding of "how to use yaffs_guts". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!