summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-08-01 01:32:37 +0200
committerNao Pross <naopross@thearcway.org>2017-08-01 01:32:37 +0200
commitfafba296467b7398a97549a7d1f4dbf1552d6475 (patch)
tree8847debacba5ce7711bb85234d38c8a56d473622 /sw
parentnew structure for process management, structures to discuss (diff)
downloadz80uPC-fafba296467b7398a97549a7d1f4dbf1552d6475.tar.gz
z80uPC-fafba296467b7398a97549a7d1f4dbf1552d6475.zip
filesystem structure intro and docs
- new type pid_t and program management mechanism to make it easier to switch to a multitasking kernel - new memory related functions in memory.h to move, copy and manage pages - fix typos
Diffstat (limited to '')
-rw-r--r--sw/z80/kernel/drivers/pio.c6
-rw-r--r--sw/z80/kernel/filesystem.c1
-rw-r--r--sw/z80/kernel/include/filesystem.h77
-rw-r--r--sw/z80/kernel/include/memory.h2
-rw-r--r--sw/z80/kernel/include/process.h20
-rw-r--r--sw/z80/kernel/include/syscall.h4
-rw-r--r--sw/z80/kernel/include/types.h2
-rw-r--r--sw/z80/kernel/process.c10
-rw-r--r--sw/z80/makefile1
9 files changed, 106 insertions, 17 deletions
diff --git a/sw/z80/kernel/drivers/pio.c b/sw/z80/kernel/drivers/pio.c
index e29383f..289ebe0 100644
--- a/sw/z80/kernel/drivers/pio.c
+++ b/sw/z80/kernel/drivers/pio.c
@@ -13,7 +13,7 @@ void _pio_command(int port, uint8_t cmd)
*(pio_ctrl + port) = cmd;
}
-void pio_set_mode(int port, int mode)
+/* void pio_set_mode(int port, int mode)
{
-
-}
+
+} */
diff --git a/sw/z80/kernel/filesystem.c b/sw/z80/kernel/filesystem.c
new file mode 100644
index 0000000..101af75
--- /dev/null
+++ b/sw/z80/kernel/filesystem.c
@@ -0,0 +1 @@
+#include "filesystem.h" \ No newline at end of file
diff --git a/sw/z80/kernel/include/filesystem.h b/sw/z80/kernel/include/filesystem.h
new file mode 100644
index 0000000..6505d5e
--- /dev/null
+++ b/sw/z80/kernel/include/filesystem.h
@@ -0,0 +1,77 @@
+#ifndef __FILESYSTEM_H__
+#define __FILESYSTEM_H__
+
+#include "types.h"
+
+#define FS_OFFSET 0x1000
+
+#define FS_BLOCK_SIZE 512
+#define FS_BLOCKS_N 12
+/* #define FS_IBLOCKS_N 1 */
+
+#define INODE_TYPE_FILE 0
+#define INODE_TYPE_DIR 1
+#define INODE_TYPE_LINK 2
+
+typedef struct time_s
+{
+ uint16_t time;
+ uint16_t date;
+} time_t;
+
+
+/* on-disk structures */
+struct fs_superblock
+{
+ uint8_t magic;
+ uint16_t blk_size; /* default is 512 bytes */
+ uint16_t imap_size; /* size of the inode bitmap in blocks */
+ uint16_t dmap_size; /* size of the data blocks map in blocks */
+};
+
+
+struct fs_blk
+{
+ uint size;
+};
+
+typedef struct fs_inode
+{
+ uint i_used :1; // inode is free
+ uint i_mode :3; // inode mode (rwx)
+
+ uint8_t i_uid; // user (owner) id
+ uint16_t i_number; // identifier
+
+ uint16_t i_blocks; // number of blocks
+
+ struct fs_blk i_block[FS_BLOCKS_N]; // direct blocks
+/* struct fs_blk i_iblock[FS_IBLOCKS_N]; // indirect blocks */
+
+ inode_t *parent;
+} inode_t;
+
+/* inode table structures */
+struct fs_inode_entry
+{
+ uint16_t i_number;
+ uint8_t str_len;
+ char name[24];
+};
+
+/* filesystem struct for the operating system */
+struct filesystem
+{
+ size_t size;
+ size_t fsize;
+ inode_t *mntpt;
+};
+
+void fs_parse_superblock(struct filesystem *fs);
+
+void fs_write_imap();
+void fs_write_dmap();
+
+/* void fs_ */
+
+#endif // __FILESYSTEM_H__
diff --git a/sw/z80/kernel/include/memory.h b/sw/z80/kernel/include/memory.h
index 5bca5a5..e4352b5 100644
--- a/sw/z80/kernel/include/memory.h
+++ b/sw/z80/kernel/include/memory.h
@@ -34,7 +34,7 @@
struct page
{
uint used :1;
- uint8_t pid; // process owner of the page
+ pid_t pid; // process owner of the page
uint16_t addr; // physical address
};
diff --git a/sw/z80/kernel/include/process.h b/sw/z80/kernel/include/process.h
index ffd39e7..d7aa7fd 100644
--- a/sw/z80/kernel/include/process.h
+++ b/sw/z80/kernel/include/process.h
@@ -2,6 +2,7 @@
#define __PROCESS_H__
#include "types.h"
+#include "memory.h"
/* maximum number of processes (i.e. pages in ram)
* since each program can use only one page in ram
@@ -10,17 +11,17 @@
struct executable
{
- void *text;
- size_t text_size;
- void *bss;
- size_t bss_size;
-}
+ void *text;
+ size_t text_size;
+ void *bss;
+ size_t bss_size;
+};
struct process
{
- uint blocked :1; // process is waiting for hardware or locked
- uint running :1; // pid is used
- uint pages[4]; // pages used by the process
+ uint blocked :1; // process is waiting for hardware or locked
+ uint running :1; // pid is used
+ struct page pages[4]; // pages used by the process
// TODO: implement quick callback?
};
@@ -29,8 +30,9 @@ struct process
* limitation but for our purposes is more than enough
*/
extern struct process proc_table[255];
+extern struct process *current_proc;
-static pid_t newpid(void);
+pid_t newpid(void);
int fork(void);
int exec(char *path, char *args);
diff --git a/sw/z80/kernel/include/syscall.h b/sw/z80/kernel/include/syscall.h
index 9641f25..29941c9 100644
--- a/sw/z80/kernel/include/syscall.h
+++ b/sw/z80/kernel/include/syscall.h
@@ -1,5 +1,5 @@
-#ifndef SYS_CALL
-#define SYS_CALL
+#ifndef __SYS_CALL_H__
+#define __SYS_CALL_H__
/*
* Enable / disable virtual address traslation
diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h
index 44df3eb..7c1424a 100644
--- a/sw/z80/kernel/include/types.h
+++ b/sw/z80/kernel/include/types.h
@@ -1,6 +1,8 @@
#ifndef __TYPES_H__
#define __TYPES_H__
+/* only types from primitive types are defined in this file */
+
#define register_t volatile unsigned char
#define uint unsigned int
diff --git a/sw/z80/kernel/process.c b/sw/z80/kernel/process.c
index f33ead6..49b86b8 100644
--- a/sw/z80/kernel/process.c
+++ b/sw/z80/kernel/process.c
@@ -2,9 +2,15 @@
struct process proc_table[255];
-int fork(void)
+pid_t newpid(void)
{
+ static pid_t last_pid = 0;
+ return ++last_pid;
+}
+int fork(void)
+{
+
}
int exec(char *path, char *args)
@@ -15,4 +21,4 @@ int exec(char *path, char *args)
int spawn(char *path, char *args)
{
-} \ No newline at end of file
+}
diff --git a/sw/z80/makefile b/sw/z80/makefile
index 2eb4713..5047824 100644
--- a/sw/z80/makefile
+++ b/sw/z80/makefile
@@ -23,6 +23,7 @@ CFLAGS := -mz80 \
-DDEBUG
LDFLAGS := -mz80 --no-std-crt0 crt0.rel \
+ --std-c89 -pedantic \
--code-loc 0x0800 --data-loc 0x8000
.PHONY: dirs dis clean