blockcache.h File Reference

#include <routix/device.h>
#include <routix/task.h>
#include <routix/system.h>
#include <sys/list.h>

Go to the source code of this file.

Classes

Defines

Typedefs

Enumerations

Functions


Define Documentation

#define BLOCK_CACHE_BUFFER bf   )     ((bf)->buffer)
 

Definition at line 36 of file blockcache.h.

Referenced by cache_read().

#define BLOCK_CACHE_DEVICE bf   )     ((bf)->device)
 

Definition at line 34 of file blockcache.h.

Referenced by cache_read(), endrequest(), and sendrequest().

#define BLOCK_CACHE_LOCKCOUNT bf   )     ((bf)->lock_count)
 

Definition at line 38 of file blockcache.h.

Referenced by cache_read(), and show_cached_list().

#define BLOCK_CACHE_OPERATION bf   )     ((bf)->operation)
 

Definition at line 39 of file blockcache.h.

Referenced by cache_read().

#define BLOCK_CACHE_PENDING_PROCESS_LIST bf   )     ((bf)->pending_process_list)
 

Definition at line 41 of file blockcache.h.

Referenced by cache_read(), and endrequest().

#define BLOCK_CACHE_RETURN bf   )     ((bf)->ret)
 

Definition at line 40 of file blockcache.h.

Referenced by cache_read().

#define BLOCK_CACHE_SECTOR bf   )     ((bf)->sector)
 

Definition at line 35 of file blockcache.h.

Referenced by cache_read(), and show_cached_list().

#define BLOCK_CACHE_STATE bf   )     ((bf)->state)
 

Definition at line 37 of file blockcache.h.

Referenced by cache_read(), getfreeblock(), and show_cached_list().

#define BLOCK_SIZE   512
 

Definition at line 51 of file blockcache.h.

Referenced by alloc_block().

#define CACHE_READ device,
sector,
buffer   )     ( cache_read(device,sector,0,buffer,BLOCK_SIZE) )
 

Definition at line 63 of file blockcache.h.

Referenced by fat_12(), fat_file_find(), fat_root_dir(), and levantar_fat().

#define DRIVER_REQUEST_BUFFER bf   )     ((bf)->buffer)
 

Definition at line 45 of file blockcache.h.

Referenced by leer_escribir_new().

#define DRIVER_REQUEST_DEVICE bf   )     ((bf)->device)
 

Definition at line 43 of file blockcache.h.

#define DRIVER_REQUEST_OPERATION bf   )     ((bf)->operation)
 

Definition at line 47 of file blockcache.h.

Referenced by leer_escribir_new().

#define DRIVER_REQUEST_RETURN bf   )     ((bf)->ret)
 

Definition at line 48 of file blockcache.h.

Referenced by error(), and leer_escribir_new().

#define DRIVER_REQUEST_SECTOR bf   )     ((bf)->sector)
 

Definition at line 44 of file blockcache.h.

Referenced by leer_escribir_new().

#define DRIVER_REQUEST_STATE bf   )     ((bf)->state)
 

Definition at line 46 of file blockcache.h.


Typedef Documentation

typedef struct block_cache_t block_cache_t
 

typedef enum block_state block_state
 


Enumeration Type Documentation

enum block_state
 

Enumeration values:
READ_LOCKED 
WRITE_LOCKED 
SYNCRONIZING 
UNLOCKED 
DIRTY 

Definition at line 12 of file blockcache.h.


Function Documentation

int cache_read device_t  device,
word  sector,
unsigned int  start,
char *  dstbuffer,
unsigned int  len
 

Es la encargada de realizar una lectura desde el cache de bloques y en caso de no poseer dicha solicitud genera la petición al dispositivo correspondiente.

Parameters:
device dispositivo sobre el que se desea leer el sector (ver routix/device.h)
sector sector lógico a leer
start offset desde donde se desea leer el sector
bufferdst puntero a donde debe copiarse la información solicitada por el proceso
len largo a leer
Algorithm: function: cache_read(device,sector,start,bufferdst,len) restart: START ATOMIC OPERATION find (dev,sector) in cached_list if found { if ( WRITE_LOCKED or SYNCRONIZING ) { put this process in the list of io pending processes sleep process FINISH ATOMIC OPERATION reschedule goto restart } increment the lock count for this block if ( UNLOCKED ) { mark it READ_LOCKED quit block from free list } } else { get a free block (via getfreeblock) mark it SYNCRONIZING set it device, sector and operation (IOREAD in this case) insert it into cached list insert process into io processes pending list send request to driver sleep process FINISH ATOMIC OPERATION reschedule START ATOMIC OPERATION quit this process from io processes pending list wake up all other process waiting for this block clean io pending list if request has fail { remove from cached list add block to front of free list FINISH ATOMIC OPERATION return ERROR } mark it READ_LOCKED increment the lock count for this block } FINISH ATOMIC OPERATION copy data to buffer START ATOMIC OPERATION decrement lock count if ( lock count is 0 ) { mark block UNLOCKED put block in TAIL of the free list (LRU) wake up all other process waiting for this block (they wait for write on it) clean io pending list } FINISH ATOMIC OPERATION return SUCCESS

Definition at line 287 of file blockcache.c.

Referenced by read(), and sys_read_debug().

void endrequest block_cache_t block  )  [inline]
 

Definition at line 162 of file blockcache.c.

Referenced by error(), and leer_escribir_new().

block_cache_t* getrequest device_t  device  )  [inline]
 

Definition at line 154 of file blockcache.c.

Referenced by floppy_procesar_buffer().

void sendrequest block_cache_t block  )  [inline]
 

es la encargada de insertar la solicitud al driver correspondiente

Parameters:
el bloque solicitado (de tipo block_cache_t)

Definition at line 176 of file blockcache.c.

Referenced by cache_read().

void start_block_cache int  totalmemory  ) 
 

Referenced by kmain().


Generated on Sun May 30 18:38:36 2004 for Routix OS by doxygen 1.3.6