diff options
author | Nao Pross <naopross@thearcway.org> | 2017-08-26 14:50:06 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-08-26 14:50:06 +0200 |
commit | 2f3b8ff5cc1948c46859d3ccd73f7e589b6f5d53 (patch) | |
tree | 6888708397c459827bed79d0333f7d5c967c0789 /sw/z80/kernel/include | |
parent | edit documentation abstract (diff) | |
parent | time to inode (diff) | |
download | z80uPC-2f3b8ff5cc1948c46859d3ccd73f7e589b6f5d53.tar.gz z80uPC-2f3b8ff5cc1948c46859d3ccd73f7e589b6f5d53.zip |
merge remote-tracking branch 'origin/atlas' into naopross
Diffstat (limited to '')
-rw-r--r-- | sw/z80/kernel/include/filesystem.h | 77 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/dirent.h | 13 | ||||
-rw-r--r-- | sw/z80/kernel/include/fs/fs.h | 67 | ||||
-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 |
7 files changed, 156 insertions, 77 deletions
diff --git a/sw/z80/kernel/include/filesystem.h b/sw/z80/kernel/include/filesystem.h deleted file mode 100644 index 6505d5e..0000000 --- a/sw/z80/kernel/include/filesystem.h +++ /dev/null @@ -1,77 +0,0 @@ -#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/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..2a0e9d4 --- /dev/null +++ b/sw/z80/kernel/include/fs/fs.h @@ -0,0 +1,67 @@ +#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 + + time_t ctime; // creation time + + /* 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 |