blkdev.h 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Block device registry: floppy + IDE. Shared by the `storage` and `format`
  2. * commands so they agree on device names and read/write paths. */
  3. #ifndef BLKDEV_H
  4. #define BLKDEV_H
  5. typedef enum { BLK_FLOPPY, BLK_IDE } blk_kind_t;
  6. typedef struct {
  7. const char *name; /* "floppy0","floppy1","ide0".."ide3" */
  8. blk_kind_t kind;
  9. unsigned int bus; /* floppy: drive #; ide: 0=primary,1=secondary */
  10. unsigned int unit; /* ide: 0=master,1=slave */
  11. int present; /* IDE: set by IDENTIFY; floppy: always listed */
  12. unsigned int total_sectors;/* 0 if unknown (floppy) */
  13. char model[41]; /* IDE model string */
  14. } blk_dev_t;
  15. #define BLKDEV_MAX 8
  16. extern blk_dev_t blk_devs[BLKDEV_MAX];
  17. extern unsigned int blk_dev_count;
  18. /* Probe devices and populate the registry. */
  19. void blk_scan(void);
  20. /* Find a device by name (NULL if not found). */
  21. blk_dev_t *blk_find(const char *name);
  22. /* Read/write count sectors at lba. Return 0 on success, -1 on error. */
  23. int blk_read(blk_dev_t *d, unsigned int lba, void *buf, unsigned int count);
  24. int blk_write(blk_dev_t *d, unsigned int lba, const void *buf, unsigned int count);
  25. #endif