《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3 KiB

12 years ago
  1. #ifndef __KERN_FS_SFS_BITMAP_H__
  2. #define __KERN_FS_SFS_BITMAP_H__
  3. #include <defs.h>
  4. /*
  5. * Fixed-size array of bits. (Intended for storage management.)
  6. *
  7. * Functions:
  8. * bitmap_create - allocate a new bitmap object.
  9. * Returns NULL on error.
  10. * bitmap_getdata - return pointer to raw bit data (for I/O).
  11. * bitmap_alloc - locate a cleared bit, set it, and return its index.
  12. * bitmap_mark - set a clear bit by its index.
  13. * bitmap_unmark - clear a set bit by its index.
  14. * bitmap_isset - return whether a particular bit is set or not.
  15. * bitmap_destroy - destroy bitmap.
  16. */
  17. struct bitmap;
  18. struct bitmap *bitmap_create(uint32_t nbits); // allocate a new bitmap object.
  19. int bitmap_alloc(struct bitmap *bitmap, uint32_t *index_store); // locate a cleared bit, set it, and return its index.
  20. bool bitmap_test(struct bitmap *bitmap, uint32_t index); // return whether a particular bit is set or not.
  21. void bitmap_free(struct bitmap *bitmap, uint32_t index); // according index, set related bit to 1
  22. void bitmap_destroy(struct bitmap *bitmap); // free memory contains bitmap
  23. void *bitmap_getdata(struct bitmap *bitmap, size_t *len_store); // return pointer to raw bit data (for I/O)
  24. #endif /* !__KERN_FS_SFS_BITMAP_H__ */