47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
#ifndef __HD_H
|
|
#define __HD_H
|
|
|
|
#include "hashmap.h"
|
|
|
|
struct partition_table {
|
|
unsigned char boot;
|
|
unsigned char start_head;
|
|
unsigned short partition_start;
|
|
unsigned char type;
|
|
unsigned char end_head;
|
|
unsigned short partition_end;
|
|
unsigned int relative_sector;
|
|
unsigned int total_sectors;
|
|
} __attribute__((packed));
|
|
|
|
struct block_buffer {
|
|
char key[16];
|
|
unsigned long lba;
|
|
unsigned int accessed;
|
|
unsigned char dirty;
|
|
char buffer[512];
|
|
};
|
|
|
|
struct hd_dev {
|
|
int type;
|
|
void *data;
|
|
unsigned char drive;
|
|
unsigned char part;
|
|
unsigned int part_offset;
|
|
unsigned int part_len;
|
|
map_t block_buffers;
|
|
};
|
|
|
|
extern void init_hd();
|
|
extern int init_ahci_hd(struct ahci_device_t *ahci);
|
|
extern int init_ide_hd(struct ide_dev *ide);
|
|
extern void hd_sync(int hd);
|
|
extern void hd_buffer_trim();
|
|
extern char *hd_read_block(int hd, unsigned int blockno, char *dest, unsigned int blocksize);
|
|
extern int hd_read_blocks(int hd, unsigned int blockstart, unsigned int blockcount, char *dest, unsigned int blocksize);
|
|
extern void hd_write_blocks(int hd, unsigned int blockstart, unsigned int blockcount, char *source, unsigned int blocksize);
|
|
extern void hd_write_blocks_sync(int hd, unsigned int blockstart, unsigned int blockcount, char *source, unsigned int blocksize);
|
|
extern void hd_write_block(int hd, unsigned int blockno, char *source, unsigned int blocksize);
|
|
extern void hd_write_block_sync(int hd, unsigned int blockno, char *source, unsigned int blocksize);
|
|
#endif
|