aboutsummaryrefslogtreecommitdiff
path: root/os/filesystem
diff options
context:
space:
mode:
authorJames Barnett <noreply@jamesbarnett.xyz>2019-10-06 18:39:36 +0100
committerJames Barnett <noreply@jamesbarnett.xyz>2019-10-06 18:39:36 +0100
commit29478baf24532391cd94bd08d94cf867dee976e6 (patch)
tree3127ae32572cd262c7283c6223b6e5712a07f91d /os/filesystem
parente77b371fb0fc4e62fa727a340b2e322fa60ebcff (diff)
downloadtinyOS-29478baf24532391cd94bd08d94cf867dee976e6.tar.xz
tinyOS-29478baf24532391cd94bd08d94cf867dee976e6.zip
Start on ram backed filesystemHEADmaster
Diffstat (limited to 'os/filesystem')
-rw-r--r--os/filesystem/ramfs.c27
-rw-r--r--os/filesystem/ramfs.h10
2 files changed, 37 insertions, 0 deletions
diff --git a/os/filesystem/ramfs.c b/os/filesystem/ramfs.c
new file mode 100644
index 0000000..0c0fdff
--- /dev/null
+++ b/os/filesystem/ramfs.c
@@ -0,0 +1,27 @@
+#include "ramfs.h"
+#include "../../kernel/gpu/text_mode/display.h"
+
+#include "../stdlib/sdtlib.h"
+
+#define RAMDISK_SIZE 102400 // 100 blocks
+#define BLOCK_SIZE 1024
+#define MAX_FILES 128 // fixed size until mem management done
+
+unsigned char ramdisk[RAMDISK_SIZE];
+
+File_t files[MAX_FILES];
+int tip_file_idx = -1;
+
+File_t* ramfs_list_files() {
+ return files;
+}
+
+int ramfs_get_tip_file_idx() {
+ return tip_file_idx;
+}
+
+File_t ramfs_create_file(unsigned char *filename) {
+ int i = ++tip_file_idx;
+ strcpy(filename, files[i].name);
+ return files[i];
+}
diff --git a/os/filesystem/ramfs.h b/os/filesystem/ramfs.h
new file mode 100644
index 0000000..c0dd147
--- /dev/null
+++ b/os/filesystem/ramfs.h
@@ -0,0 +1,10 @@
+typedef struct
+{
+ char name[128]; // 128 max filename lentgh
+ int start_addr;
+ int end_addr;
+} File_t;
+
+File_t ramfs_create_file(unsigned char * filename);
+File_t* ramfs_list_files();
+int ramfs_get_tip_file_idx(); \ No newline at end of file