Fork me on GitHub

root/include/fiwix/buffer.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/buffer.h
   3  *
   4  * Copyright 2018-2021, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_BUFFER_H
   9 #define _FIWIX_BUFFER_H
  10 
  11 #include <fiwix/types.h>
  12 #include <fiwix/fs.h>
  13 
  14 /* buffer flags */
  15 #define BUFFER_VALID    0x0001
  16 #define BUFFER_LOCKED   0x0002
  17 #define BUFFER_DIRTY    0x0004
  18 
  19 struct buffer {
  20         __dev_t dev;                    /* device number */
  21         __blk_t block;                  /* block number */
  22         int size;                       /* block size (in bytes) */
  23         int flags;
  24         char *data;                     /* block contents */
  25         struct buffer *prev_hash;
  26         struct buffer *next_hash;
  27         struct buffer *prev_free;
  28         struct buffer *next_free;
  29         struct buffer *prev_dirty;
  30         struct buffer *next_dirty;
  31 };
  32 extern struct buffer *buffer_table;
  33 extern struct buffer **buffer_hash_table;
  34 
  35 /* values to be determined during system startup */
  36 extern unsigned int buffer_table_size;          /* size in bytes */
  37 extern unsigned int buffer_hash_table_size;     /* size in bytes */
  38 
  39 struct buffer * bread(__dev_t, __blk_t, int);
  40 void bwrite(struct buffer *);
  41 void brelse(struct buffer *);
  42 void sync_buffers(__dev_t);
  43 void invalidate_buffers(__dev_t);
  44 int reclaim_buffers(void);
  45 void buffer_init(void);
  46 
  47 #endif /* _FIWIX_BUFFER_H */

/* [previous][next][first][last][top][bottom][index][help] */