blockcache.h

Go to the documentation of this file.
00001 /* block.h */
00002 
00003 #ifndef __BLOCK_CACHE
00004 #define __BLOCK_CACHE
00005 
00006 #include <routix/device.h>
00007 #include <routix/task.h>
00008 #include <routix/system.h>
00009 #include <sys/list.h>
00010 
00011 // Cache
00012 typedef enum block_state { READ_LOCKED, WRITE_LOCKED, SYNCRONIZING, UNLOCKED, DIRTY } block_state;
00013 
00014 typedef struct block_cache_t {
00015         device_t device;
00016         word sector;
00017         byte *buffer;
00018 
00019         // Estado del bloque
00020         block_state state;
00021         unsigned int lock_count;                                                                                                                
00022 
00023         // Info para el driver
00024         operation_t operation;
00025         int ret;
00026 
00027         LIST_NEW(task_struct_t)         pending_process_list;                   // lista de procesos en espera por este bloque
00028         LIST_DATA(block_cache_t)        free;                                                                                   // puede pertenecer a una lista de bloques libres
00029         LIST_DATA(block_cache_t)        cached;                                                                         // puede pertenecer a una lista contenida en un hash
00030         LIST_DATA(block_cache_t)        driver_request_list;                    // puede pertenecer a una lista de requests a un driver
00031 
00032 } block_cache_t;
00033 
00034 #define BLOCK_CACHE_DEVICE(bf)                  ((bf)->device)
00035 #define BLOCK_CACHE_SECTOR(bf)                  ((bf)->sector)
00036 #define BLOCK_CACHE_BUFFER(bf)                  ((bf)->buffer)
00037 #define BLOCK_CACHE_STATE(bf)                   ((bf)->state)
00038 #define BLOCK_CACHE_LOCKCOUNT(bf)               ((bf)->lock_count)
00039 #define BLOCK_CACHE_OPERATION(bf)               ((bf)->operation)
00040 #define BLOCK_CACHE_RETURN(bf)                  ((bf)->ret)
00041 #define BLOCK_CACHE_PENDING_PROCESS_LIST(bf)            ((bf)->pending_process_list)
00042 
00043 #define DRIVER_REQUEST_DEVICE(bf)               ((bf)->device)
00044 #define DRIVER_REQUEST_SECTOR(bf)               ((bf)->sector)
00045 #define DRIVER_REQUEST_BUFFER(bf)               ((bf)->buffer)
00046 #define DRIVER_REQUEST_STATE(bf)                ((bf)->state)
00047 #define DRIVER_REQUEST_OPERATION(bf)    ((bf)->operation)
00048 #define DRIVER_REQUEST_RETURN(bf)               ((bf)->ret)
00049 
00050 // Definiciones
00051 #define BLOCK_SIZE      512
00052 
00053 
00054 // Funciones
00055 void start_block_cache(int totalmemory);
00056 
00057 block_cache_t *getrequest(device_t device);
00058 inline void sendrequest(block_cache_t *block);
00059 inline void endrequest(block_cache_t *block);
00060 int cache_read(device_t device, word sector, unsigned int start, char *dstbuffer, unsigned int len);
00061 
00062 
00063 #define CACHE_READ(device,sector,buffer)        ( cache_read(device,sector,0,buffer,BLOCK_SIZE) )
00064 
00065 
00066 #endif

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