Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Functions
physical.c File Reference
#include <flash.h>

Functions

devcall physicalRead (struct flash *flash, struct flash_block *block)
 
devcall physicalWrite (struct flash *flash, struct flash_block *block)
 
devcall physicalErase (struct flash *flash, struct flash_block *block)
 
devcall physicalControl (struct flash *flash, struct flash_block *block, uchar func, ulong arg)
 

Detailed Description

A function from this file calls the proper function of the specific command set if it is supported.

Functions in this file communicate directly with the hardware to achieve their goals. This file acts like the BIOS in older computers (by providing calls to to the physical work to the O/S).

Function Documentation

devcall physicalControl ( struct flash *  flash,
struct flash_block *  block,
uchar  func,
ulong  arg 
)
Parameters
*flashflash device to use
*blockblock to perform operations on
funcsee include/flash.h for functions
argargument (if needed)
Returns
status of function
devcall physicalErase ( struct flash *  flash,
struct flash_block *  block 
)

Erase an erase-block from Flash memory. Flash memory can only change a binary 1 to a binary 0, not the other way around. In order to write new data to the device we must tell flash to change all 0s to 1s.

Parameters
*flashflash device to perform operations on
*blockblock to erase
Returns
OK on success, SYSERR on failure
devcall physicalRead ( struct flash *  flash,
struct flash_block *  block 
)

Physically read from the flash device. Passed in block must contain the start_pos for the reading and the size of the block located at start_pos.

Parameters
*flashflash device used for data.
*blockflash_block to store data in.
Returns
number of bytes read on success, SYSERR on failure.
devcall physicalWrite ( struct flash *  flash,
struct flash_block *  block 
)

Physically write to the flash device. This will write a stored block to memory if the state if FLASH_BLOCK_DIRTY (data within the block has changed). If it is not in the FLASH_BLOCK_DIRTY state that means the block is either FREE (nothing is stored) or CLEAN (hasn't changed since it was read).

Parameters
*flashflash device used for data.
*blockflash_block to store data in.
Returns
number of bytes written on success, SYSERR on failure.