diff options
Diffstat (limited to '')
-rw-r--r-- | sw/z80/kernel/filesystem.c | 44 | ||||
-rw-r--r-- | sw/z80/kernel/fs.c | 5 | ||||
-rw-r--r-- | sw/z80/kernel/include/filesystem.h | 91 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/dirent.h | 13 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/fs.h | 65 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/mount.h | 15 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/users.h | 6 | ||||
-rw-r--r-- | sw/z80/kernel/include/sio.h | 49 | ||||
-rw-r--r-- | sw/z80/kernel/include/types.h | 6 |
9 files changed, 159 insertions, 135 deletions
diff --git a/sw/z80/kernel/filesystem.c b/sw/z80/kernel/filesystem.c deleted file mode 100644 index 38a5456..0000000 --- a/sw/z80/kernel/filesystem.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "filesystem.h" - -struct filesystem * fs_parse_superblock(struct filesystem *fs) -{ - -} - -/* resolves an arbitrary path */ -uint16_t fs_parse_path(const char *path) -{ - -} - -/* gets inode from inumber */ -inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number) -{ - -} - -inode_t * fs_new_inode(inode_t *inode, const char *name) -{ - -} - -int fs_free_inode(const inode_t *inode) -{ - -} - -void fs_chmod(inode_t *inode, uint8_t mode) -{ - -} - -void fs_chown(inode_t *inode, uint8_t uid) -{ - -} - -int fs_rename(inode_t *inode, const char *name) -{ - -} - diff --git a/sw/z80/kernel/fs.c b/sw/z80/kernel/fs.c new file mode 100644 index 0000000..3ce7f42 --- /dev/null +++ b/sw/z80/kernel/fs.c @@ -0,0 +1,5 @@ +#include "fs.h" +#include "users.h" +#include "mount.h" + +struct fs_mount_point * mount_points[FS_MOUNT_LIMIT]; diff --git a/sw/z80/kernel/include/filesystem.h b/sw/z80/kernel/include/filesystem.h deleted file mode 100644 index 98c1e90..0000000 --- a/sw/z80/kernel/include/filesystem.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __FILESYSTEM_H__ -#define __FILESYSTEM_H__ - -#include "types.h" - -#define FS_OFFSET 0x1000 - -#define FS_BLOCKS_SIZE 512 -#define FS_BLOCKS_N 12 - -#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 -{ - uint magic :5; /* identifier */ - uint serial_port :3; /* serial port id from serial.h */ - uint16_t blk_size; /* default is 512 bytes */ - uint16_t imap_size; /* size of the inode table in blocks */ - uint16_t dmap_size; /* size of the data blocks map in blocks */ -}; - - -struct fs_blk_entry -{ - uint16_t b_number; /* block number */ - uint16_t data_size; /* bytes used */ -}; - -typedef struct fs_inode -{ - - uint16_t i_number; /* identifier */ - - uint i_mode :3; /* inode mode (rwx) */ - uint i_uid :3; /* user (owner) id */ - uint i_type :2; /* inode type */ - - uint8_t i_blocks; /* number of blocks */ - struct fs_blk_entry i_block[FS_BLOCKS_N]; /* direct blocks */ - - uint16_t parent; - -} inode_t; - -/* inode table structures */ -/* i_number is derived from location */ -struct fs_inode_entry -{ - uint8_t str_len; - char name[24]; -}; - -/* filesystem struct for the operating system */ -struct filesystem -{ - size_t size; - size_t fsize; - inode_t *mntpt; -}; - -struct filesystem * fs_parse_superblock(struct filesystem *fs); - -/* resolves an arbitrary path */ -uint16_t fs_parse_path(const char *path); - -/* gets inode from inumber */ -inode_t * fs_get_inode(inode_t *buffer, uint16_t i_number); - -inode_t * fs_new_inode(inode_t *inode, const char *name); - -int fs_free_inode(const inode_t *inode); - -void fs_chmod(inode_t *inode, uint8_t mode); - -void fs_chown(inode_t *inode, uint8_t uid); - -int fs_rename(inode_t *inode, const char *name); - - -#endif // __FILESYSTEM_H__ diff --git a/sw/z80/kernel/include/fs/dirent.h b/sw/z80/kernel/include/fs/dirent.h new file mode 100644 index 0000000..ea5699b --- /dev/null +++ b/sw/z80/kernel/include/fs/dirent.h @@ -0,0 +1,13 @@ +#ifndef DIRENT_H +#define DIRENT_H + +#include "types.h" + +struct dirent +{ + ino_t i_number; // inode referred + uint8_t name_size; // size of the name + char name[]; // name of the referred inode +} + +#endif diff --git a/sw/z80/kernel/include/fs/fs.h b/sw/z80/kernel/include/fs/fs.h new file mode 100644 index 0000000..62bef36 --- /dev/null +++ b/sw/z80/kernel/include/fs/fs.h @@ -0,0 +1,65 @@ +#ifndef INODE_H +#define INODE_H + +#include "types.h" + +#define FS_OFFSET 0x1000 + +#define FS_BLOCKS_SIZE 512 +#define FS_BLOCKS_N 8 +#define FS_BLOCKS_IND 6 + +#define INODE_TYPE_FILE 0x0 +#define INODE_TYPE_DIR 0x1 +#define INODE_TYPE_HLINK 0x2 +#define INODE_TYPE_SLINK 0x3 + +typedef struct time_s +{ + struct + { + uint minutes :6; + uint hour :5; + + } time; + + struct + { + uint day :5; + uint month :4; + uint year :12; + + } date; + +} time_t; + +struct fs_superblock +{ + uint8_t magic; // identifier + + uint16_t blk_size; // size of a single block + uint16_t imap_size; // quantity of inodes + uint16_t dmap_size; // quantity of blocks +} + +struct fs_inode +{ + + /* inode meta data */ + uint mode :3; // chmod + uint uid :3; // chown + uint type :2; // file, dir, hard-link, sym-link + + /* data storage informations */ + uint24_t size; + uint16_t blocks[FS_BLOCKS_N]; + +} + +struct fs_inumber +{ + uint dev : 4; // device id, global in the fs + ino_t rel; // inode id relative to the volume +} + +#endif diff --git a/sw/z80/kernel/include/fs/mount.h b/sw/z80/kernel/include/fs/mount.h new file mode 100644 index 0000000..a0edd5d --- /dev/null +++ b/sw/z80/kernel/include/fs/mount.h @@ -0,0 +1,15 @@ +#ifndef MOUNT_H +#define MOUNT_H + +#include "fs.h" + +#define FS_MOUNT_LIMIT 16 + +struct fs_mount_point +{ + struct fs_inumber inode; // dir mounted + uint serial_port :4; + struct fs_superblock superblock; // block informations +} + +#endif diff --git a/sw/z80/kernel/include/fs/users.h b/sw/z80/kernel/include/fs/users.h new file mode 100644 index 0000000..7e4016b --- /dev/null +++ b/sw/z80/kernel/include/fs/users.h @@ -0,0 +1,6 @@ +#ifndef USERS_H +#define USERS_H + + + +#endif diff --git a/sw/z80/kernel/include/sio.h b/sw/z80/kernel/include/sio.h new file mode 100644 index 0000000..9dc47f6 --- /dev/null +++ b/sw/z80/kernel/include/sio.h @@ -0,0 +1,49 @@ +#ifndef SIO_H +#define SIO_H + +#include "types.h" + +#define SIO_ROM 0x0 + +#define SIO_PORT_1 0x1 +#define SIO_PORT_2 0x2 +#define SIO_PORT_3 0x3 +#define SIO_PORT_4 0x4 +#define SIO_PORT_5 0x5 +#define SIO_PORT_6 0x6 +#define SIO_PORT_7 0x7 + +/* initialize serial interface */ +void sio_init(); + +/* return the device address in the address space */ +void * sio_dev_addr(uint8_t dev); +/* return the driver id to be used on dev */ +uint8_t sio_dev_driver(uint8_t dev); + +/* set current device in use */ +void sio_set_dev(uint8_t dev); +/* get current device in use */ +uint8_t sio_cdev(); + +/* get pointer in given device */ +uint16_t sio_tellg(uint8_t dev); +/* get pointer in current device */ +uint16_t sio_ctellg(); + +/* set pointer in given device */ +int sio_seekg(uint8_t dev, uint16_t value); +/* set pointer in current device */ +int sio_seekg(uint16_t value); + +/* syscall: read one byte from the current device */ +uint8_t sio_recv(); +/* syscall: write one byte into the current device */ +void sio_send(uint8_t value); + +/* read n bytes from the current device */ +char * sio_read(uint8_t *buffer, size_t n); +/* write n bytes into the current device */ +int sio_write(const uint8_t *buffer, size_t n); + +#endif diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h index 7c1424a..b822144 100644 --- a/sw/z80/kernel/include/types.h +++ b/sw/z80/kernel/include/types.h @@ -15,4 +15,10 @@ #define size_t uint16_t #define pid_t uint8_t +#define ino_t uint16_t + +typedef struct { + uint data : 24; +} uint24_t; + #endif |