ahci: add ahci driver
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
bd02ddc640
commit
105bdb4464
11 changed files with 522 additions and 260 deletions
|
|
@ -2,13 +2,21 @@
|
|||
#ifndef _BLOCK_H_
|
||||
#define _BLOCK_H_
|
||||
|
||||
#include <fs/vfs.h>
|
||||
#include <kernel/device.h>
|
||||
#include <kernel/sg.h>
|
||||
|
||||
#include <fs/vfs.h>
|
||||
|
||||
struct block_device;
|
||||
struct block_ops {
|
||||
ssize_t (*read)(struct block_device *dev, char *buf, size_t offset, size_t n);
|
||||
ssize_t (*write)(struct block_device *dev, char *buf, size_t offset, size_t n);
|
||||
ssize_t (*read)(struct block_device *dev, struct sg_list *sg, size_t offset, size_t n);
|
||||
ssize_t (*write)(struct block_device *dev, struct sg_list *sg, size_t offset, size_t n);
|
||||
};
|
||||
|
||||
struct disk {
|
||||
u8 is_disk;
|
||||
char model[FILE_NAME_MAX_LEN + 1];
|
||||
list_t part_table;
|
||||
};
|
||||
|
||||
struct block_device {
|
||||
|
|
@ -17,14 +25,9 @@ struct block_device {
|
|||
size_t size;
|
||||
size_t block_size;
|
||||
struct block_ops ops;
|
||||
void *priv;
|
||||
size_t lba_start;
|
||||
};
|
||||
|
||||
struct disk {
|
||||
struct block_device *dev;
|
||||
char model[FILE_NAME_MAX_LEN + 1];
|
||||
list_t part_table;
|
||||
void *priv;
|
||||
size_t lba_start;
|
||||
struct disk disk;
|
||||
};
|
||||
|
||||
ssize_t block_read(struct block_device *dev, char *buf, size_t offset, size_t n_blocks);
|
||||
|
|
|
|||
28
include/kernel/sg.h
Normal file
28
include/kernel/sg.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _SG_H_
|
||||
#define _SG_H_
|
||||
|
||||
#include <kernel/types.h>
|
||||
|
||||
struct sg_entry {
|
||||
paddr_t paddr;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
struct sg_list {
|
||||
struct sg_entry *entries;
|
||||
size_t count;
|
||||
size_t max_count;
|
||||
};
|
||||
|
||||
#define SG_STATIC(name, n) \
|
||||
struct sg_entry name##_buf[n]; \
|
||||
struct sg_list name = {.entries = name##_buf, .count = 0, .max_count = (n)}
|
||||
|
||||
#define sg_for_each(entry, sg) for (struct sg_entry *entry = (sg)->entries; entry < (sg)->entries + (sg)->count; entry++)
|
||||
|
||||
void sg_init(struct sg_list *sg, struct sg_entry *buf, size_t n);
|
||||
int sg_append(struct sg_list *sg, paddr_t paddr, size_t len);
|
||||
void sg_reset(struct sg_list *sg);
|
||||
|
||||
#endif /* _SG_H_ */
|
||||
Loading…
Reference in a new issue