00001 #ifndef DEVICES_BLOCK_H
00002
00003 #define DEVICES_BLOCK_H
00004
00005 #include <stddef.h>
00006 #include <inttypes.h>
00007
00008
00009
00010
00011
00012 #define BLOCK_SECTOR_SIZE 512
00013
00014
00015
00016 typedef uint32_t block_sector_t;
00017
00018
00019
00020 #define PRDSNu PRIu32
00021
00022
00023
00024 struct block;
00025
00026
00027 enum block_type
00028 {
00029
00030 BLOCK_KERNEL,
00031 BLOCK_FILESYS,
00032 BLOCK_SCRATCH,
00033 BLOCK_SWAP,
00034 BLOCK_ROLE_CNT,
00035
00036
00037
00038 BLOCK_RAW = BLOCK_ROLE_CNT,
00039 BLOCK_FOREIGN,
00040 BLOCK_CNT
00041 };
00042
00043 const char *block_type_name (enum block_type);
00044
00045
00046 struct block *block_get_role (enum block_type);
00047 void block_set_role (enum block_type, struct block *);
00048 struct block *block_get_by_name (const char *name);
00049
00050 struct block *block_first (void);
00051 struct block *block_next (struct block *);
00052
00053
00054 block_sector_t block_size (struct block *);
00055 void block_read (struct block *, block_sector_t, void *);
00056 void block_write (struct block *, block_sector_t, const void *);
00057 const char *block_name (struct block *);
00058 enum block_type block_type (struct block *);
00059
00060
00061 void block_print_stats (void);
00062
00063
00064
00065 struct block_operations
00066 {
00067 void (*read) (void *aux, block_sector_t, void *buffer);
00068 void (*write) (void *aux, block_sector_t, const void *buffer);
00069 };
00070
00071 struct block *block_register (const char *name, enum block_type,
00072 const char *extra_info, block_sector_t size,
00073 const struct block_operations *, void *aux);
00074
00075 #endif