1/*
2 * Copyright (c) 2009, 2010, 2014, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef VFS_BLOCKDEVFS_H
11#define VFS_BLOCKDEVFS_H
12
13#ifndef VFS_BLK_DEBUG
14#if defined(VFS_DEBUG) || defined(GLOBAL_DEBUG)
15#define VFS_BLK_DEBUG(x...) printf("vfs_blockdevfs: " x)
16#else
17#define VFS_BLK_DEBUG(x...) ((void)0)
18#endif
19#endif // VFS_DEBUG
20
21struct blockdev_entry {
22    struct blockdev_entry *prev;
23    struct blockdev_entry *next;
24
25    char *path;
26    size_t size;
27    int type;
28    void *backend_handle;
29    bool open;
30};
31
32void blockdev_append_entry(struct blockdev_entry *entry);
33
34enum blockdev_backend_types
35{
36    blockdev_backend_type_ahci,
37    blockdev_backend_type_ata,
38    blockdev_backend_type_megaraid,
39};
40
41
42// AHCI (direct libahci)
43errval_t blockdevfs_ahci_init(void);
44errval_t blockdevfs_ahci_open(void *handle);
45errval_t blockdevfs_ahci_close(void *handle);
46errval_t blockdevfs_ahci_read(void *handle, size_t pos, void *buffer,
47		size_t bytes, size_t *bytes_read);
48errval_t blockdevfs_ahci_write(void *handle, size_t pos, const void *buffer,
49		size_t bytes, size_t *bytes_written);
50errval_t blockdevfs_ahci_flush(void *handle);
51// AHCI (using Flounder-AHCI)
52errval_t blockdevfs_ata_init(void);
53errval_t blockdevfs_ata_open(void *handle);
54errval_t blockdevfs_ata_close(void *handle);
55errval_t blockdevfs_ata_read(void *handle, size_t pos, void *buffer,
56		size_t bytes, size_t *bytes_read);
57errval_t blockdevfs_ata_write(void *handle, size_t pos, const void *buffer,
58		size_t bytes, size_t *bytes_written);
59errval_t blockdevfs_ata_flush(void *handle);
60// MegaRAID
61errval_t blockdevfs_megaraid_init(void);
62errval_t blockdevfs_megaraid_open(void *handle);
63errval_t blockdevfs_megaraid_close(void *handle);
64errval_t blockdevfs_megaraid_read(void *handle, size_t pos, void *buffer,
65		size_t bytes, size_t *bytes_read);
66errval_t blockdevfs_megaraid_write(void *handle, size_t pos, const void *buffer,
67		size_t bytes, size_t *bytes_written);
68errval_t blockdevfs_megaraid_flush(void *handle);
69#endif
70