Embedded Xinu Operating System
An ongoing research project and educational operating system.
|
#include <flash.h>
#include <string.h>
#include <memory.h>
Functions | |
devcall | logicalRead (struct flash *flash, uchar *buffer, ulong block) |
devcall | logicalWrite (struct flash *flash, uchar *buffer, ulong block) |
struct flash_block | logicalMap (struct flash *flash, ulong block) |
This provides a more proper interface between driver calls and the physical layer of flash. It is possible to split the entire flash device into logical blocks of n bytes and this file provides the mappings from physical address to logical block.
struct flash_block logicalMap | ( | struct flash * | flash, |
ulong | block | ||
) |
Given a flash structure and a logical block, this method will discover the physical erase-block (and region) of that block. Once the physical mapping is found it will return an incomplete flash_block structure with the region and erase-block filled in.
*flash | flash device to discover on. |
block | logical block to find. |
devcall logicalRead | ( | struct flash * | flash, |
uchar * | buffer, | ||
ulong | block | ||
) |
With a logical block address, read in the contents of the block into the buffer. This will check if the erase-block is already in memory and if so simply read from the cached copy, if it is not read it into memory and read the specified block. If there is no more room in memory to store an erase-block it will automatically write to the oldest erase-block to flash and read in the requested block.
*flash | flash device to read on. |
*buffer | buffer to read into. |
block | block to read on device. |
devcall logicalWrite | ( | struct flash * | flash, |
uchar * | buffer, | ||
ulong | block | ||
) |
Translate a logical block number to a physical portion of flash and write the data. This function will check if the erase-block is in memory and store changes to the memory location to prevent too many writes to flash. If no more room is available it will evict the oldest erase-block and write it to flash.
*flash | flash device to write to |
*buffer | buffer holding new data |
block | block to write to device |