From 6a0cf5f86ec1efd9ea05e6449f7ec0f97d28c594 Mon Sep 17 00:00:00 2001 From: Liu Aleaxander Date: Tue, 16 Jun 2009 07:42:07 +0800 Subject: [PATCH] core: new diskio library Beginnings of a diskio library capable of reading and writing, and with proper handling of bounce buffers and segment boundaries. Signed-off-by: H. Peter Anvin --- core/fs.c | 3 --- core/include/disk.h | 6 ++++-- core/include/fs.h | 13 +++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/fs.c b/core/fs.c index 617e3e5..d2a82c3 100644 --- a/core/fs.c +++ b/core/fs.c @@ -126,9 +126,6 @@ void device_init(struct device *dev, uint8_t device_num, sector_t offset) dev->cache_size = sizeof core_cache_buf; } else dev->cache_data = NULL; - - /* I just considered the floppy and disk now */ - dev->read_sectors = read_sectors; } diff --git a/core/include/disk.h b/core/include/disk.h index 44a425f..1eb9f03 100644 --- a/core/include/disk.h +++ b/core/include/disk.h @@ -1,11 +1,13 @@ #ifndef DISK_H #define DISK_H +#include + #define SECTOR_SHIFT 9 #define SECTOR_SIZE (1 << SECTOR_SHIFT) -typedef unsigned int sector_t; -typedef unsigned int block_t; +typedef uint64_t sector_t; +typedef uint32_t block_t; extern void read_sectors(char *, sector_t, int); extern void getoneblk(char *, block_t, int); diff --git a/core/include/fs.h b/core/include/fs.h index 0cb1bfc..0c837bd 100644 --- a/core/include/fs.h +++ b/core/include/fs.h @@ -1,6 +1,8 @@ #ifndef FS_H #define FS_H +#include +#include #include #include "core.h" #include "disk.h" @@ -15,7 +17,7 @@ struct fs_info { struct device *fs_dev; }; -struct file{ +struct file { void* open_file; /* points to the fs-specific open_file_t */ struct fs_info *fs; uint32_t file_len; @@ -58,11 +60,16 @@ struct device { /* the sector size, 512B for disk and floppy, 2048B for CD */ uint16_t sector_size; + uint8_t sector_shift; + + /* CHS geometry */ + uint8_t h, s; + uint8_t pad1; /* the start address of this partition(in sectors) */ sector_t part_start; - void (*read_sectors)(char *, sector_t, int ); + int (*rdwr_sectors)(struct device *, void *, sector_t, size_t, bool); /* * I think we still need the cache_data filed here, 'cause hpa said @@ -76,6 +83,4 @@ struct device { uint32_t cache_size; }; - - #endif /* FS_H */ -- 2.7.4