/*
 * ram.h
 *
 * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _RAM_H_
#define _RAM_H_

#include <common.h>
#include <sdk/list.h>
#include <clock.h>
#include <filesystem.h>

typedef struct
{
    list_entry_t list;
    char *name;
    dword_t attributes;

    union
    {
        struct
        {
            byte_t *contents;
            qword_t size;
        };

        list_entry_t files;
    };
} ramfs_node_t;

typedef struct
{
    file_t header;
    ramfs_node_t *node;
} ramfs_file_t;

typedef struct
{
    file_instance_t header;
    list_entry_t *dir_scan_node;
} ramfs_file_instance_t;

typedef struct
{
    mounted_volume_t header;
    qword_t max_size;
    ramfs_node_t root;
} ramfs_volume_t;

dword_t ramfs_driver_load(void);

#endif
