AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
ramdisk.c File Reference

The RAM disk: the initial RAM disk the boot loader loaded, as block device 1, 0. More...

#include <core/system.h>
#include <core/panic.h>
#include <core/arch.h>
#include <core/module.h>
#include <core/string.h>
#include <boot/boot.h>
#include <dev/dev.h>
#include <mm/vm.h>

Go to the source code of this file.

Functions

static ssize_t rd_read (struct devid *dd, off_t offset, size_t size, void *buf)
 Reads from the RAM disk: up to size bytes at offset, fewer at its end.
static ssize_t rd_write (struct devid *dd, off_t offset, size_t size, void *buf)
 Writes to the RAM disk: up to size bytes at offset, fewer at its end.
static int rd_probe ()
 Maps the RAM disk the boot loader loaded, and registers it as block device 1.
static size_t rd_getbs (struct devid *dd)
 Returns the RAM disk's block size: 1, it is read byte by byte.

Variables

static void * rd_addr = NULL
size_t rd_size = 0
struct dev rddev

Detailed Description

The RAM disk: the initial RAM disk the boot loader loaded, as block device 1, 0.

The boot loader puts the RAM disk (the first module) in memory; this driver maps it, and reads and writes it with plain copies. The kernel then unpacks the archive it holds as the first root filesystem (see load_ramdisk()). Without a module, the root is on a disk, and there is no RAM disk.

Definition in file ramdisk.c.

Function Documentation

◆ rd_getbs()

size_t rd_getbs ( struct devid * dd)
static

Returns the RAM disk's block size: 1, it is read byte by byte.

Definition at line 88 of file ramdisk.c.

References rd_getbs().

Referenced by rd_getbs().

◆ rd_probe()

int rd_probe ( )
static

Maps the RAM disk the boot loader loaded, and registers it as block device 1.

Without one (the root is on a disk), it does nothing.

Definition at line 65 of file ramdisk.c.

References __kboot, arch_phys_map(), kdev_blkdev_register(), boot::modules, boot::modules_count, module_t::paddr, panic, rd_addr, rd_probe(), rd_size, rddev, and module_t::size.

Referenced by rd_probe().

◆ rd_read()

ssize_t rd_read ( struct devid * dd,
off_t offset,
size_t size,
void * buf )
static

Reads from the RAM disk: up to size bytes at offset, fewer at its end.

Returns how many were read, 0 past the end.

Definition at line 29 of file ramdisk.c.

References memcpy(), MIN, rd_addr, rd_read(), and rd_size.

Referenced by rd_read().

◆ rd_write()

ssize_t rd_write ( struct devid * dd,
off_t offset,
size_t size,
void * buf )
static

Writes to the RAM disk: up to size bytes at offset, fewer at its end.

Returns how many were written, 0 past the end.

Definition at line 47 of file ramdisk.c.

References memcpy(), MIN, rd_addr, rd_size, and rd_write().

Referenced by rd_write().

Variable Documentation

◆ rd_addr

void* rd_addr = NULL
static

Definition at line 22 of file ramdisk.c.

Referenced by rd_probe(), rd_read(), and rd_write().

◆ rd_size

size_t rd_size = 0

Definition at line 25 of file ramdisk.c.

Referenced by load_ramdisk(), rd_probe(), rd_read(), and rd_write().

◆ rddev

struct dev rddev
Initial value:
= {
.name = "ramdisk",
.probe = rd_probe,
.bread = rd_read,
.bwrite = rd_write,
.getbs = rd_getbs,
}
static ssize_t rd_read(struct devid *dd, off_t offset, size_t size, void *buf)
Reads from the RAM disk: up to size bytes at offset, fewer at its end.
Definition ramdisk.c:29
static int rd_probe()
Maps the RAM disk the boot loader loaded, and registers it as block device 1.
Definition ramdisk.c:65
static ssize_t rd_write(struct devid *dd, off_t offset, size_t size, void *buf)
Writes to the RAM disk: up to size bytes at offset, fewer at its end.
Definition ramdisk.c:47
static size_t rd_getbs(struct devid *dd)
Returns the RAM disk's block size: 1, it is read byte by byte.
Definition ramdisk.c:88

Definition at line 93 of file ramdisk.c.

Referenced by rd_probe().