XINU
Data Structures | Macros | Functions | Variables
flash.h File Reference

Go to the source code of this file.

Data Structures

struct  file
 
struct  flash
 
struct  flash_block
 
struct  flash_region
 
struct  trx_header
 

Macros

#define AMD_BLOCKMOD   0x60
 
#define AMD_CLR_SR   0x50
 
#define AMD_ERASE_CYCLE3   0x80
 
#define AMD_ERASE_CYCLE6   0x30
 
#define AMD_GET_16(addr)   *((volatile unsigned int16 *)((unsigned int)(addr)))
 
#define AMD_GET_8(addr)   *((volatile unsigned char *)((unsigned int)(addr)))
 
#define AMD_H_LOCK   0x02
 
#define AMD_LOCK   0x01
 
#define AMD_PROGRAM_CYCLE3   0xA0
 
#define AMD_PUT_16(addr, word)   *((volatile unsigned int16 *)((unsigned int)(addr)))=(word)
 
#define AMD_PUT_8(addr, byte)   *((volatile unsigned char *)((unsigned int)(addr)))=(byte)
 
#define AMD_READ   0xFF
 
#define AMD_REG_CYCLE1   0x555
 
#define AMD_REG_CYCLE2   0x2AA
 
#define AMD_RESET   0xF0
 
#define AMD_S_LOCK   0x01
 
#define AMD_SR_WSMS   0x001
 
#define AMD_UNLOCK_CYCLE1   0xAA
 
#define AMD_UNLOCK_CYCLE2   0x55
 
#define CFE_MAX_BLOCK   0x01FF
 
#define CFE_MIN_BLOCK   0x0000
 
#define CFI_COMMAND_SET   0x13
 
#define CFI_DEV_INTERFACE   0x28
 
#define CFI_DEV_SIZE   0x27
 
#define CFI_DEVICE   0x01
 
#define CFI_GET_8(addr, offset)   *((volatile unsigned char *)((addr)+((offset)<<FLASH_WIDEMODE)))
 
#define CFI_MANUFACTURER   0x00
 
#define CFI_MAX_BUFFER   0x2A
 
#define CFI_PUT_8(addr, offset, cmd)   *((volatile unsigned char *)((addr)+((offset)<<FLASH_WIDEMODE)))=(cmd)
 
#define CFI_QUERY_ADDR   0x55
 
#define CFI_QUERY_EXIT   0xFF
 
#define CFI_QUERY_MODE   0x98
 
#define CFI_QUERY_STRING   0x10
 
#define CFI_REGION_COUNT   0x2C
 
#define CFI_REGION_TAB   0x2D
 
#define CFI_SIGNATURE   0x10
 
#define FLASH_AMD_ECS   0x0004
 
#define FLASH_AMD_SCS   0x0002
 
#define FLASH_BLK_SIZE   512
 
#define FLASH_BLOCK   0x00
 
#define FLASH_BLOCK_CLEAN   1
 
#define FLASH_BLOCK_DIRTY   2
 
#define FLASH_BLOCK_FREE   0
 
#define FLASH_BLOCK_SIZE   0x0000
 
#define FLASH_ERASE_PREP   0x0014
 
#define FLASH_INTEL_ECS   0x0001
 
#define FLASH_INTEL_SCS   0x0003
 
#define FLASH_LOCK   0x0011
 
#define FLASH_LOCKDOWN   0x0013
 
#define FLASH_LOCKED   0x0010
 
#define FLASH_LOGBLOCK   0x01
 
#define FLASH_MODE   0x0001
 
#define FLASH_MTSU_ECS   0x0101
 
#define FLASH_MTSU_SCS   0x0100
 
#define FLASH_N_BLOCKS   0x0001
 
#define FLASH_RESET   0x0015
 
#define FLASH_STATUS   0x0000
 
#define FLASH_SYNC   0x0002
 
#define FLASH_UNLOCK   0x0012
 
#define FLASH_WIDEMODE   1
 
#define INTEL_BLOCKMOD   0x60
 
#define INTEL_CLR_SR   0x50
 
#define INTEL_CONFIRM   0xD0
 
#define INTEL_ERASE   0x20
 
#define INTEL_GET_16(addr)   *((volatile unsigned int16 *)((unsigned int)(addr)))
 
#define INTEL_GET_8(addr)   *((volatile unsigned char *)((unsigned int)(addr)))
 
#define INTEL_H_LOCK   0x02
 
#define INTEL_ID_BLS   0x04
 
#define INTEL_ID_DEV   0x02
 
#define INTEL_ID_MFG   0x00
 
#define INTEL_LOCK   0x01
 
#define INTEL_LOCKDOWN   0x2F
 
#define INTEL_PROGRAM   0x40
 
#define INTEL_PUT_16(addr, word)   *((volatile unsigned int16 *)((unsigned int)(addr)))=(word)
 
#define INTEL_PUT_8(addr, byte)   *((volatile unsigned char *)((unsigned int)(addr)))=(byte)
 
#define INTEL_READ   0xFF
 
#define INTEL_READ_ID   0x90
 
#define INTEL_READ_SR   0x70
 
#define INTEL_RESUME   0xD0
 
#define INTEL_S_LOCK   0x01
 
#define INTEL_SR_BLS   1
 
#define INTEL_SR_ES   5
 
#define INTEL_SR_ESS   6
 
#define INTEL_SR_PS   4
 
#define INTEL_SR_PSS   2
 
#define INTEL_SR_WSMS   7
 
#define INTEL_SUSPEND   0xB0
 
#define INTEL_UNLOCK   0xD0
 
#define KERNEL_MAX_BLOCK   0x03FF
 
#define KERNEL_MIN_BLOCK   0x0200
 
#define MAX_LIVE_BLOCKS   8
 
#define MAX_REGIONS   8
 
#define NVRAM_MAX_BLOCK   0x1FFF
 
#define NVRAM_MIN_BLOCK   0x1FC0
 
#define TRX_MAGIC   0x30524448
 

Functions

devcall flashClose (struct dentry *)
 
devcall flashControl (struct dentry *, uint16, int32, int32)
 
devcall flashInit (struct dentry *)
 
devcall flashOpen (struct dentry *, va_list)
 
devcall flashRead (struct dentry *, byte *, uint32)
 
devcall flashSeek (struct dentry *, uint32)
 
devcall flashWrite (struct dentry *, byte *, uint32)
 
syscall freeFile (struct file *)
 
struct flash_block logicalMap (struct flash *, uint32)
 
devcall logicalRead (struct flash *, byte *, uint32)
 
devcall logicalWrite (struct flash *, byte *, uint32)
 
devcall physicalAMDRead (struct flash *, struct flash_block *)
 
devcall physicalControl (struct flash *, struct flash_block *, byte, uint32)
 
devcall physicalErase (struct flash *, struct flash_block *)
 
devcall physicalIntelControl (struct flash *, struct flash_block *, byte, uint32)
 
devcall physicalIntelErase (struct flash *, struct flash_block *)
 
devcall physicalIntelRead (struct flash *, struct flash_block *)
 
devcall physicalIntelWrite (struct flash *, struct flash_block *)
 
devcall physicalRead (struct flash *, struct flash_block *)
 
devcall physicalWrite (struct flash *, struct flash_block *)
 
syscall printFileStats (struct file *, char *, char *, int, int)
 
bool validateTrx (struct file *)
 

Variables

struct flash_block bad_block
 
struct flash flashtab []
 

Detailed Description

This file provides various definitions and prototypes for the flash driver and all its affiliates

Id
flash.h 2065 2009-09-04 21:44:36Z brylow

Definition in file flash.h.

Macro Definition Documentation

◆ AMD_BLOCKMOD

#define AMD_BLOCKMOD   0x60

prepare block for lock op

Definition at line 183 of file flash.h.

◆ AMD_CLR_SR

#define AMD_CLR_SR   0x50

clear status register

Definition at line 185 of file flash.h.

◆ AMD_ERASE_CYCLE3

#define AMD_ERASE_CYCLE3   0x80

write to 0x555

Definition at line 178 of file flash.h.

◆ AMD_ERASE_CYCLE6

#define AMD_ERASE_CYCLE6   0x30

write to erase address

Definition at line 179 of file flash.h.

◆ AMD_GET_16

#define AMD_GET_16 (   addr)    *((volatile unsigned int16 *)((unsigned int)(addr)))

Definition at line 156 of file flash.h.

◆ AMD_GET_8

#define AMD_GET_8 (   addr)    *((volatile unsigned char *)((unsigned int)(addr)))

Definition at line 144 of file flash.h.

◆ AMD_H_LOCK

#define AMD_H_LOCK   0x02

lock-down (hardward lock)

Definition at line 211 of file flash.h.

◆ AMD_LOCK

#define AMD_LOCK   0x01

soft-lock a block

Definition at line 184 of file flash.h.

◆ AMD_PROGRAM_CYCLE3

#define AMD_PROGRAM_CYCLE3   0xA0

write to 0x555

Definition at line 180 of file flash.h.

◆ AMD_PUT_16

#define AMD_PUT_16 (   addr,
  word 
)    *((volatile unsigned int16 *)((unsigned int)(addr)))=(word)

Definition at line 154 of file flash.h.

◆ AMD_PUT_8

#define AMD_PUT_8 (   addr,
  byte 
)    *((volatile unsigned char *)((unsigned int)(addr)))=(byte)

Definition at line 142 of file flash.h.

◆ AMD_READ

#define AMD_READ   0xFF

read command

Definition at line 182 of file flash.h.

◆ AMD_REG_CYCLE1

#define AMD_REG_CYCLE1   0x555

Register for unlock cycle1

Definition at line 188 of file flash.h.

◆ AMD_REG_CYCLE2

#define AMD_REG_CYCLE2   0x2AA

Register for unlock cycle2

Definition at line 189 of file flash.h.

◆ AMD_RESET

#define AMD_RESET   0xF0

write to 0xXXX

Definition at line 181 of file flash.h.

◆ AMD_S_LOCK

#define AMD_S_LOCK   0x01

software lock

Definition at line 210 of file flash.h.

◆ AMD_SR_WSMS

#define AMD_SR_WSMS   0x001

Write State Machine Status

Definition at line 190 of file flash.h.

◆ AMD_UNLOCK_CYCLE1

#define AMD_UNLOCK_CYCLE1   0xAA

write to 0x555

Definition at line 176 of file flash.h.

◆ AMD_UNLOCK_CYCLE2

#define AMD_UNLOCK_CYCLE2   0x55

write to 0x2AA

Definition at line 177 of file flash.h.

◆ CFE_MAX_BLOCK

#define CFE_MAX_BLOCK   0x01FF

Physical addr: 0x03ffff

Definition at line 24 of file flash.h.

◆ CFE_MIN_BLOCK

#define CFE_MIN_BLOCK   0x0000

Physical addr: 0x000000

Definition at line 23 of file flash.h.

◆ CFI_COMMAND_SET

#define CFI_COMMAND_SET   0x13

Definition at line 116 of file flash.h.

◆ CFI_DEV_INTERFACE

#define CFI_DEV_INTERFACE   0x28

Definition at line 118 of file flash.h.

◆ CFI_DEV_SIZE

#define CFI_DEV_SIZE   0x27

Definition at line 117 of file flash.h.

◆ CFI_DEVICE

#define CFI_DEVICE   0x01

Definition at line 113 of file flash.h.

◆ CFI_GET_8

#define CFI_GET_8 (   addr,
  offset 
)    *((volatile unsigned char *)((addr)+((offset)<<FLASH_WIDEMODE)))

Definition at line 104 of file flash.h.

◆ CFI_MANUFACTURER

#define CFI_MANUFACTURER   0x00

Definition at line 112 of file flash.h.

◆ CFI_MAX_BUFFER

#define CFI_MAX_BUFFER   0x2A

Definition at line 119 of file flash.h.

◆ CFI_PUT_8

#define CFI_PUT_8 (   addr,
  offset,
  cmd 
)    *((volatile unsigned char *)((addr)+((offset)<<FLASH_WIDEMODE)))=(cmd)

Definition at line 102 of file flash.h.

◆ CFI_QUERY_ADDR

#define CFI_QUERY_ADDR   0x55

Definition at line 108 of file flash.h.

◆ CFI_QUERY_EXIT

#define CFI_QUERY_EXIT   0xFF

Definition at line 110 of file flash.h.

◆ CFI_QUERY_MODE

#define CFI_QUERY_MODE   0x98

Definition at line 109 of file flash.h.

◆ CFI_QUERY_STRING

#define CFI_QUERY_STRING   0x10

Definition at line 115 of file flash.h.

◆ CFI_REGION_COUNT

#define CFI_REGION_COUNT   0x2C

Definition at line 120 of file flash.h.

◆ CFI_REGION_TAB

#define CFI_REGION_TAB   0x2D

Definition at line 121 of file flash.h.

◆ CFI_SIGNATURE

#define CFI_SIGNATURE   0x10

Definition at line 114 of file flash.h.

◆ FLASH_AMD_ECS

#define FLASH_AMD_ECS   0x0004

Definition at line 127 of file flash.h.

◆ FLASH_AMD_SCS

#define FLASH_AMD_SCS   0x0002

Definition at line 125 of file flash.h.

◆ FLASH_BLK_SIZE

#define FLASH_BLK_SIZE   512

disk blocks are 512 bytes

Definition at line 16 of file flash.h.

◆ FLASH_BLOCK

#define FLASH_BLOCK   0x00

block is a flash_block struct

Definition at line 214 of file flash.h.

◆ FLASH_BLOCK_CLEAN

#define FLASH_BLOCK_CLEAN   1

block has been read but not writted

Definition at line 19 of file flash.h.

◆ FLASH_BLOCK_DIRTY

#define FLASH_BLOCK_DIRTY   2

block has been changed

Definition at line 20 of file flash.h.

◆ FLASH_BLOCK_FREE

#define FLASH_BLOCK_FREE   0

block can be allocated

Definition at line 18 of file flash.h.

◆ FLASH_BLOCK_SIZE

#define FLASH_BLOCK_SIZE   0x0000

get the size of disk blocks

Definition at line 31 of file flash.h.

◆ FLASH_ERASE_PREP

#define FLASH_ERASE_PREP   0x0014

prepare hardware to be erased

Definition at line 224 of file flash.h.

◆ FLASH_INTEL_ECS

#define FLASH_INTEL_ECS   0x0001

Definition at line 124 of file flash.h.

◆ FLASH_INTEL_SCS

#define FLASH_INTEL_SCS   0x0003

Definition at line 126 of file flash.h.

◆ FLASH_LOCK

#define FLASH_LOCK   0x0011

put a software lock on a block

Definition at line 221 of file flash.h.

◆ FLASH_LOCKDOWN

#define FLASH_LOCKDOWN   0x0013

put hardware lock on a block

Definition at line 223 of file flash.h.

◆ FLASH_LOCKED

#define FLASH_LOCKED   0x0010

return id register (16-bits)

Definition at line 220 of file flash.h.

◆ FLASH_LOGBLOCK

#define FLASH_LOGBLOCK   0x01

block is a logical block number

Definition at line 215 of file flash.h.

◆ FLASH_MODE

#define FLASH_MODE   0x0001

change mode device is in

Definition at line 219 of file flash.h.

◆ FLASH_MTSU_ECS

#define FLASH_MTSU_ECS   0x0101

Definition at line 129 of file flash.h.

◆ FLASH_MTSU_SCS

#define FLASH_MTSU_SCS   0x0100

Definition at line 128 of file flash.h.

◆ FLASH_N_BLOCKS

#define FLASH_N_BLOCKS   0x0001

get number of disk blocks

Definition at line 32 of file flash.h.

◆ FLASH_RESET

#define FLASH_RESET   0x0015

Definition at line 225 of file flash.h.

◆ FLASH_STATUS

#define FLASH_STATUS   0x0000

return status register (8-bits)

Definition at line 218 of file flash.h.

◆ FLASH_SYNC

#define FLASH_SYNC   0x0002

force sync of disk device

Definition at line 33 of file flash.h.

◆ FLASH_UNLOCK

#define FLASH_UNLOCK   0x0012

remove a software lock on a block

Definition at line 222 of file flash.h.

◆ FLASH_WIDEMODE

#define FLASH_WIDEMODE   1

Definition at line 36 of file flash.h.

◆ INTEL_BLOCKMOD

#define INTEL_BLOCKMOD   0x60

prepare block for lock operation

Definition at line 171 of file flash.h.

◆ INTEL_CLR_SR

#define INTEL_CLR_SR   0x50

clear status register

Definition at line 169 of file flash.h.

◆ INTEL_CONFIRM

#define INTEL_CONFIRM   0xD0

confirm erase command

Definition at line 164 of file flash.h.

◆ INTEL_ERASE

#define INTEL_ERASE   0x20

prepare to erase a block

Definition at line 163 of file flash.h.

◆ INTEL_GET_16

#define INTEL_GET_16 (   addr)    *((volatile unsigned int16 *)((unsigned int)(addr)))

Definition at line 150 of file flash.h.

◆ INTEL_GET_8

#define INTEL_GET_8 (   addr)    *((volatile unsigned char *)((unsigned int)(addr)))

Definition at line 138 of file flash.h.

◆ INTEL_H_LOCK

#define INTEL_H_LOCK   0x02

lock-down (hardward lock)

Definition at line 207 of file flash.h.

◆ INTEL_ID_BLS

#define INTEL_ID_BLS   0x04

bit: 0 = soft-lock, 1 = hard-lock

Definition at line 203 of file flash.h.

◆ INTEL_ID_DEV

#define INTEL_ID_DEV   0x02

Device memory-map

Definition at line 202 of file flash.h.

◆ INTEL_ID_MFG

#define INTEL_ID_MFG   0x00

Intel = 0x0089

Definition at line 201 of file flash.h.

◆ INTEL_LOCK

#define INTEL_LOCK   0x01

soft-lock a block

Definition at line 172 of file flash.h.

◆ INTEL_LOCKDOWN

#define INTEL_LOCKDOWN   0x2F

put a hardware lock on a block

Definition at line 173 of file flash.h.

◆ INTEL_PROGRAM

#define INTEL_PROGRAM   0x40

prepare to write to flash

Definition at line 162 of file flash.h.

◆ INTEL_PUT_16

#define INTEL_PUT_16 (   addr,
  word 
)    *((volatile unsigned int16 *)((unsigned int)(addr)))=(word)

Definition at line 148 of file flash.h.

◆ INTEL_PUT_8

#define INTEL_PUT_8 (   addr,
  byte 
)    *((volatile unsigned char *)((unsigned int)(addr)))=(byte)

Definition at line 136 of file flash.h.

◆ INTEL_READ

#define INTEL_READ   0xFF

read array (normal read ops)

Definition at line 161 of file flash.h.

◆ INTEL_READ_ID

#define INTEL_READ_ID   0x90

read identifier

Definition at line 170 of file flash.h.

◆ INTEL_READ_SR

#define INTEL_READ_SR   0x70

read status register

Definition at line 168 of file flash.h.

◆ INTEL_RESUME

#define INTEL_RESUME   0xD0

write/erase resume (post-suspend)

Definition at line 165 of file flash.h.

◆ INTEL_S_LOCK

#define INTEL_S_LOCK   0x01

software lock

Definition at line 206 of file flash.h.

◆ INTEL_SR_BLS

#define INTEL_SR_BLS   1

Block Lock Status

Definition at line 198 of file flash.h.

◆ INTEL_SR_ES

#define INTEL_SR_ES   5

Erase Status

Definition at line 195 of file flash.h.

◆ INTEL_SR_ESS

#define INTEL_SR_ESS   6

Erase-Suspend Status

Definition at line 194 of file flash.h.

◆ INTEL_SR_PS

#define INTEL_SR_PS   4

Program Status

Definition at line 196 of file flash.h.

◆ INTEL_SR_PSS

#define INTEL_SR_PSS   2

Program Suspend Status

Definition at line 197 of file flash.h.

◆ INTEL_SR_WSMS

#define INTEL_SR_WSMS   7

Write State Machine Status

Definition at line 193 of file flash.h.

◆ INTEL_SUSPEND

#define INTEL_SUSPEND   0xB0

program/erase suspend

Definition at line 167 of file flash.h.

◆ INTEL_UNLOCK

#define INTEL_UNLOCK   0xD0

soft-unlock a block

Definition at line 166 of file flash.h.

◆ KERNEL_MAX_BLOCK

#define KERNEL_MAX_BLOCK   0x03FF

Physical addr: 0x07ffff

Definition at line 26 of file flash.h.

◆ KERNEL_MIN_BLOCK

#define KERNEL_MIN_BLOCK   0x0200

Physical addr: 0x040000

Definition at line 25 of file flash.h.

◆ MAX_LIVE_BLOCKS

#define MAX_LIVE_BLOCKS   8

number of blocks to keep in memory

Definition at line 15 of file flash.h.

◆ MAX_REGIONS

#define MAX_REGIONS   8

Definition at line 37 of file flash.h.

◆ NVRAM_MAX_BLOCK

#define NVRAM_MAX_BLOCK   0x1FFF

Physical addr: 0x3fffff

Definition at line 28 of file flash.h.

◆ NVRAM_MIN_BLOCK

#define NVRAM_MIN_BLOCK   0x1FC0

Physical addr: 0x3F8000

Definition at line 27 of file flash.h.

◆ TRX_MAGIC

#define TRX_MAGIC   0x30524448

Definition at line 40 of file flash.h.

Function Documentation

◆ flashClose()

devcall flashClose ( struct dentry )

◆ flashControl()

devcall flashControl ( struct dentry ,
uint16  ,
int32  ,
int32   
)

◆ flashInit()

devcall flashInit ( struct dentry )

◆ flashOpen()

devcall flashOpen ( struct dentry ,
va_list   
)

◆ flashRead()

devcall flashRead ( struct dentry ,
byte ,
uint32   
)

◆ flashSeek()

devcall flashSeek ( struct dentry ,
uint32   
)

◆ flashWrite()

devcall flashWrite ( struct dentry ,
byte ,
uint32   
)

◆ freeFile()

syscall freeFile ( struct file )

◆ logicalMap()

struct flash_block logicalMap ( struct flash ,
uint32   
)

◆ logicalRead()

devcall logicalRead ( struct flash ,
byte ,
uint32   
)

◆ logicalWrite()

devcall logicalWrite ( struct flash ,
byte ,
uint32   
)

◆ physicalAMDRead()

devcall physicalAMDRead ( struct flash ,
struct flash_block  
)

◆ physicalControl()

devcall physicalControl ( struct flash ,
struct flash_block ,
byte  ,
uint32   
)

◆ physicalErase()

devcall physicalErase ( struct flash ,
struct flash_block  
)

◆ physicalIntelControl()

devcall physicalIntelControl ( struct flash ,
struct flash_block ,
byte  ,
uint32   
)

◆ physicalIntelErase()

devcall physicalIntelErase ( struct flash ,
struct flash_block  
)

◆ physicalIntelRead()

devcall physicalIntelRead ( struct flash ,
struct flash_block  
)

◆ physicalIntelWrite()

devcall physicalIntelWrite ( struct flash ,
struct flash_block  
)

◆ physicalRead()

devcall physicalRead ( struct flash ,
struct flash_block  
)

◆ physicalWrite()

devcall physicalWrite ( struct flash ,
struct flash_block  
)

◆ printFileStats()

syscall printFileStats ( struct file ,
char *  ,
char *  ,
int  ,
int   
)

◆ validateTrx()

bool validateTrx ( struct file )

Variable Documentation

◆ bad_block

struct flash_block bad_block

◆ flashtab

struct flash flashtab[]