diff options
Diffstat (limited to 'docs/Ramfs-explained.txt')
-rw-r--r-- | docs/Ramfs-explained.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/Ramfs-explained.txt b/docs/Ramfs-explained.txt new file mode 100644 index 0000000..85d5ae5 --- /dev/null +++ b/docs/Ramfs-explained.txt @@ -0,0 +1,26 @@ +#Ramfs + +A simple ram file system has been introduced to avoid having to embed too many files in the kernel in the future. + +The ram filesystem is created on the development machine and then embedded into the kernel. Kernel can then parse the ramfs and access files in it. + +Ramfs contains a mapping from file's name to it's size and contents. Directories, file permissions, etc. as well as writing to filesystem are not supported. + +Currently this is used to access the code of PL0 test program by the kernel, which it then copies to the appropriate memory location. In case more user mode programs are later written, they can all be added to ramfs to enable the kernel to access them easily. + +## Specification +When ramfs is accessed in memory, it MUST be aligned to a multiple of 4. + +The filesystem itself consists of blocks of data, each containing one file. Blocks of data in the ramfs come one after another, with the requirement, that each block starts at a 4-aligned offset/address. If a block doesn't end at a 4-aligned address, there shall be up to 3 null-bytes of padding after it, so that the next block is properly aligned. + +Each block start with a C (null-terminated) string with the name of the file it contains. At the first 4-aligned offset after the string, file size is stored on 4 bytes in little endian. Null-bytes are used for padding between file name and file size if necessary. Immediately after the file size reside file contents, that take exactly the amount of bytes specified in file size. + +As obvious from the specification, files bigger than 4GB are not supported, which is not a problem in the case of this project. + +## Implementations + +Creation of ramfs is done by the makefs program (src/host/makefs.c). The program accepts file names as command line arguments, creates a ramfs containing all those files and writes it to stdout. As makefs is a very simple tool (just as our ramfs is a simple format), it puts files in ramfs under the names it got on the command line. No stripping or normalizing of path is performed. In case of errors (i.e. io errors) makefs prints information to stderr and exits. + +Parsing/reading of ramfs is done by a kernel driver (src/arm/PL1/kernel/ramfs.c). The driver allows for finding a file in ramfs by name. File size and pointers to file name string and file contents are returned through a structure from function find_file. + +As ramfs is embedded in kernel image, it is easily accessible to kernel code. The alignment of ramfs to a multiple of 4 is assured in kernel's linker script (src/arm/PL1/kernel/kernel_stage2.ld). |