From 48c1c4dcc449d05e9950a861e165f456e0d583a1 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 10 Mar 2015 16:12:03 +0100 Subject: Rename & cleanup. --- src/common/include/framebuffer.h | 19 -------- src/common/include/fs.h | 62 -------------------------- src/common/include/mmap.h | 7 --- src/common/include/proc.h | 25 ----------- src/common/include/proto/fb.h | 33 ++++++++++++++ src/common/include/proto/fs.h | 62 ++++++++++++++++++++++++++ src/common/include/proto/mmap.h | 7 +++ src/common/include/proto/proc.h | 25 +++++++++++ src/common/include/proto/syscall.h | 89 ++++++++++++++++++++++++++++++++++++++ src/common/include/proto/token.h | 11 +++++ src/common/include/syscallproto.h | 89 -------------------------------------- src/common/include/token.h | 11 ----- 12 files changed, 227 insertions(+), 213 deletions(-) delete mode 100644 src/common/include/framebuffer.h delete mode 100644 src/common/include/fs.h delete mode 100644 src/common/include/mmap.h delete mode 100644 src/common/include/proc.h create mode 100644 src/common/include/proto/fb.h create mode 100644 src/common/include/proto/fs.h create mode 100644 src/common/include/proto/mmap.h create mode 100644 src/common/include/proto/proc.h create mode 100644 src/common/include/proto/syscall.h create mode 100644 src/common/include/proto/token.h delete mode 100644 src/common/include/syscallproto.h delete mode 100644 src/common/include/token.h (limited to 'src/common') diff --git a/src/common/include/framebuffer.h b/src/common/include/framebuffer.h deleted file mode 100644 index febbfaa..0000000 --- a/src/common/include/framebuffer.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -typedef struct { - uint32_t width, height; - uint32_t pitch; // bytes per line - uint32_t bpp; -} framebuffer_info_t; - -typedef struct { - int mode_number; - framebuffer_info_t geom; -} fbdev_mode_info_t; - -#define IOCTL_FBDEV_GET_MODE_INFO 10 -#define IOCTL_FBDEV_SET_MODE 11 - -#define IOCTL_FB_GET_INFO 12 - -/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/fs.h b/src/common/include/fs.h deleted file mode 100644 index e70ff55..0000000 --- a/src/common/include/fs.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -#include -#include - -typedef int fd_t; - -#define FT_REGULAR 0 // no flags = regular file -#define FT_DIR (0x01) -#define FT_DEV (0x02) -#define FT_BLOCKDEV (0x04) -#define FT_CHARDEV (0x08) -#define FT_CHANNEL (0x10) // dual-pipe -#define FT_FRAMEBUFFER (0x20) - -// FM_* enum describes modes for opening a file as well as authorized operations in stat_t -// (some flags are used only for open() or only in stat_t.access) -#define FM_READ (0x01) -#define FM_WRITE (0x02) -#define FM_READDIR (0x04) -#define FM_MMAP (0x08) -#define FM_CREATE (0x10) -#define FM_TRUNC (0x20) -#define FM_APPEND (0x40) -#define FM_IOCTL (0x100) -#define FM_BLOCKING (0x200) -#define FM_DCREATE (0x1000) // create file in directory -#define FM_DMOVE (0x2000) // move file from directory -#define FM_DDELETE (0x4000) // delete file from directory - -#define FM_ALL_MODES (0xFFFF) - - -typedef struct { - int type; - int access; - size_t size; - // TODO : times & more metadata -} stat_t; - -#define DIR_MAX 128 // maximum length for a filename - -typedef struct { - char name[DIR_MAX]; - stat_t st; -} dirent_t; - - -#define IOCTL_BLOCKDEV_GET_BLOCK_SIZE 40 -#define IOCTL_BLOCKDEV_GET_BLOCK_COUNT 41 - - -#define SEL_READ 0x01 -#define SEL_WRITE 0x02 -#define SEL_ERROR 0x04 - -typedef struct { - fd_t fd; - uint16_t req_flags, got_flags; // rq_flags : what caller is interested in -} sel_fd_t; - -/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/mmap.h b/src/common/include/mmap.h deleted file mode 100644 index 3134403..0000000 --- a/src/common/include/mmap.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#define MM_READ (0x01) -#define MM_WRITE (0x02) -#define MM_EXEC (0x04) - -/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proc.h b/src/common/include/proc.h deleted file mode 100644 index 29b5b91..0000000 --- a/src/common/include/proc.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include -#include - -typedef int pid_t; - -#define PS_LOADING 1 -#define PS_RUNNING 2 -#define PS_FINISHED 3 -#define PS_FAILURE 4 // exception or segfault or stuff -#define PS_KILLED 5 - -#define FAIL_EXCEPTION 1 // unhandled processor exception -#define FAIL_ZEROPTR 2 // segfault at < 4k -#define FAIL_SEGFAULT 3 -#define FAIL_SC_SEGFAULT 4 // failed to validate parameter for system call - -typedef struct { - int pid; - int status; // one of PS_* - int exit_code; // an error code if state == PS_FAILURE -} proc_status_t; - -/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/fb.h b/src/common/include/proto/fb.h new file mode 100644 index 0000000..0519554 --- /dev/null +++ b/src/common/include/proto/fb.h @@ -0,0 +1,33 @@ +#pragma once + +// Framebuffer-related data structures + +#include +#include + +#define FB_MM_RGB16 1 // 2 bytes (16 bits) per pixel, blue 0-4, green 5-9, red 10-14 +#define FB_MM_BGR16 2 // 2 bytes (16 bits) per pixel, red 0-4, green 5-9, blue 10-14 +#define FB_MM_RGB24 3 // 3 bytes (24 bits) per pixel, blue 0-7, green 8-15, red 16-23 +#define FB_MM_BGR24 4 // 3 bytes (24 bits) per pixel, red 0-7, green 8-15, blue 16-23 +#define FB_MM_RGB32 5 // 4 bytes (32 bits) per pixel, blue 0-7, green 8-15, red 16-23 +#define FB_MM_BGR32 6 // 4 bytes (32 bits) per pixel, red 0-7, green 8-15, blue 16-23 +#define FB_MM_GREY8 10 // 1 byte (8 bits) per pixel greyscale + +typedef struct { + uint32_t width, height; + uint32_t pitch; // bytes per line + uint32_t bpp; + uint32_t memory_model; +} framebuffer_info_t; + +typedef struct { + int mode_number; + framebuffer_info_t geom; +} fbdev_mode_info_t; + +#define IOCTL_FBDEV_GET_MODE_INFO 10 +#define IOCTL_FBDEV_SET_MODE 11 + +#define IOCTL_FB_GET_INFO 12 + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/fs.h b/src/common/include/proto/fs.h new file mode 100644 index 0000000..e70ff55 --- /dev/null +++ b/src/common/include/proto/fs.h @@ -0,0 +1,62 @@ +#pragma once + +#include +#include + +typedef int fd_t; + +#define FT_REGULAR 0 // no flags = regular file +#define FT_DIR (0x01) +#define FT_DEV (0x02) +#define FT_BLOCKDEV (0x04) +#define FT_CHARDEV (0x08) +#define FT_CHANNEL (0x10) // dual-pipe +#define FT_FRAMEBUFFER (0x20) + +// FM_* enum describes modes for opening a file as well as authorized operations in stat_t +// (some flags are used only for open() or only in stat_t.access) +#define FM_READ (0x01) +#define FM_WRITE (0x02) +#define FM_READDIR (0x04) +#define FM_MMAP (0x08) +#define FM_CREATE (0x10) +#define FM_TRUNC (0x20) +#define FM_APPEND (0x40) +#define FM_IOCTL (0x100) +#define FM_BLOCKING (0x200) +#define FM_DCREATE (0x1000) // create file in directory +#define FM_DMOVE (0x2000) // move file from directory +#define FM_DDELETE (0x4000) // delete file from directory + +#define FM_ALL_MODES (0xFFFF) + + +typedef struct { + int type; + int access; + size_t size; + // TODO : times & more metadata +} stat_t; + +#define DIR_MAX 128 // maximum length for a filename + +typedef struct { + char name[DIR_MAX]; + stat_t st; +} dirent_t; + + +#define IOCTL_BLOCKDEV_GET_BLOCK_SIZE 40 +#define IOCTL_BLOCKDEV_GET_BLOCK_COUNT 41 + + +#define SEL_READ 0x01 +#define SEL_WRITE 0x02 +#define SEL_ERROR 0x04 + +typedef struct { + fd_t fd; + uint16_t req_flags, got_flags; // rq_flags : what caller is interested in +} sel_fd_t; + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/mmap.h b/src/common/include/proto/mmap.h new file mode 100644 index 0000000..3134403 --- /dev/null +++ b/src/common/include/proto/mmap.h @@ -0,0 +1,7 @@ +#pragma once + +#define MM_READ (0x01) +#define MM_WRITE (0x02) +#define MM_EXEC (0x04) + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/proc.h b/src/common/include/proto/proc.h new file mode 100644 index 0000000..29b5b91 --- /dev/null +++ b/src/common/include/proto/proc.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +typedef int pid_t; + +#define PS_LOADING 1 +#define PS_RUNNING 2 +#define PS_FINISHED 3 +#define PS_FAILURE 4 // exception or segfault or stuff +#define PS_KILLED 5 + +#define FAIL_EXCEPTION 1 // unhandled processor exception +#define FAIL_ZEROPTR 2 // segfault at < 4k +#define FAIL_SEGFAULT 3 +#define FAIL_SC_SEGFAULT 4 // failed to validate parameter for system call + +typedef struct { + int pid; + int status; // one of PS_* + int exit_code; // an error code if state == PS_FAILURE +} proc_status_t; + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/syscall.h b/src/common/include/proto/syscall.h new file mode 100644 index 0000000..a671c65 --- /dev/null +++ b/src/common/include/proto/syscall.h @@ -0,0 +1,89 @@ +#pragma once + +#include +#include + +typedef struct { fd_t a, b; } fd_pair_t; + +#define SC_MAX 128 // maximum number of syscalls + +#define SC_DBG_PRINT 0 // args: msg, msg_strlen +#define SC_EXIT 1 // args: code +#define SC_YIELD 2 // args: () +#define SC_USLEEP 3 // args: usecs +#define SC_NEW_THREAD 4 // args: eip, esp +#define SC_EXIT_THREAD 5 // args: () + +#define SC_MMAP 10 // args: addr, size, mode +#define SC_MMAP_FILE 11 // args: handle, offset, addr, size, mode +#define SC_MCHMAP 12 // args: addr, new_mode +#define SC_MUNMAP 13 // args: addr + +#define SC_CREATE 20 // args: file, file_strlen, type +#define SC_DELETE 21 // args: file, file_strlen +#define SC_MOVE 22 // args: old_file, old_file_strlen, new_file, new_file_strlen +#define SC_STAT 23 // args: file, file_strlen, out stat_t* data + +#define SC_OPEN 30 // args: file, file_strlen, mode +#define SC_CLOSE 31 // args: fd +#define SC_READ 32 // args: fd, offset, size, out char* data +#define SC_WRITE 33 // args: fd, offset, size, data +#define SC_READDIR 34 // args: fd, ent_no, out dirent_t *data +#define SC_STAT_OPEN 35 // args: fd, out stat_t *data -- stat on open file handle +#define SC_IOCTL 36 // args: fd, command, out void* data +#define SC_GET_MODE 37 // args: fd -- get mode for open file handle +#define SC_SELECT 38 // args: sel_fd_t*, count, timeout + +#define SC_MK_CHANNEL 40 // args: blocking?, (int, int)* +#define SC_GEN_TOKEN 41 // args: fd, token_t* +#define SC_USE_TOKEN 42 // args: token_t* + +#define SC_MAKE_FS 50 // args: sc_make_fs_args_t +#define SC_FS_ADD_SRC 51 // args: fs_name, fs_name_strlen, fd, opts, opts_strlen +#define SC_SUBFS 52 // args: sc_subfs_args_t +#define SC_RM_FS 53 // args: fs_name, fs_name_strlen +// TODO : how do we enumerate filesystems ? + +#define SC_NEW_PROC 60 // args: nothing ? +#define SC_BIND_FS 61 // args: pid, new_name, new_name_strlen, fs_name, fs_name_strlen -- bind FS to child process +#define SC_BIND_SUBFS 62 // args: sc_subfs_args_t -- subfs & bind to child process +#define SC_BIND_MAKE_FS 63 // args: sc_make_fs_args_t +#define SC_BIND_FD 64 // args: pid, new_fd, local_fd -- copy a file descriptor to child process +#define SC_PROC_EXEC 65 // args: pid, exec_name, exec_name_strlen -- execute binary in process +#define SC_PROC_STATUS 66 // args: pid, proc_status_t* +#define SC_PROC_KILL 67 // args: pid, proc_status_t* -- inconditionnally kill child process +#define SC_PROC_WAIT 68 // args: pid?, block?, proc_status_t* + +#define INVALID_PID 0 // do a wait with this PID to wayt for any child + +typedef struct { + const char* driver; + size_t driver_strlen; + + const char* fs_name; + size_t fs_name_strlen; + + fd_t source_fd; + + const char* opts; + size_t opts_strlen; + + pid_t bind_to_pid; // zero = bind to current proc +} sc_make_fs_args_t; + +typedef struct { + const char* new_name; + size_t new_name_strlen; + + const char* from_fs; + size_t from_fs_strlen; + + const char* root; + size_t root_strlen; + + int ok_modes; + + pid_t bind_to_pid; // 0 = bind to current proc +} sc_subfs_args_t; + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/proto/token.h b/src/common/include/proto/token.h new file mode 100644 index 0000000..9ec1aff --- /dev/null +++ b/src/common/include/proto/token.h @@ -0,0 +1,11 @@ +#pragma once + +#include +#include + +#define TOKEN_LENGTH 16 +typedef struct { + char bytes[TOKEN_LENGTH]; +} token_t; + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/syscallproto.h b/src/common/include/syscallproto.h deleted file mode 100644 index 9f300d3..0000000 --- a/src/common/include/syscallproto.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include -#include - -typedef struct { fd_t a, b; } fd_pair_t; - -#define SC_MAX 128 // maximum number of syscalls - -#define SC_DBG_PRINT 0 // args: msg, msg_strlen -#define SC_EXIT 1 // args: code -#define SC_YIELD 2 // args: () -#define SC_USLEEP 3 // args: usecs -#define SC_NEW_THREAD 4 // args: eip, esp -#define SC_EXIT_THREAD 5 // args: () - -#define SC_MMAP 10 // args: addr, size, mode -#define SC_MMAP_FILE 11 // args: handle, offset, addr, size, mode -#define SC_MCHMAP 12 // args: addr, new_mode -#define SC_MUNMAP 13 // args: addr - -#define SC_CREATE 20 // args: file, file_strlen, type -#define SC_DELETE 21 // args: file, file_strlen -#define SC_MOVE 22 // args: old_file, old_file_strlen, new_file, new_file_strlen -#define SC_STAT 23 // args: file, file_strlen, out stat_t* data - -#define SC_OPEN 30 // args: file, file_strlen, mode -#define SC_CLOSE 31 // args: fd -#define SC_READ 32 // args: fd, offset, size, out char* data -#define SC_WRITE 33 // args: fd, offset, size, data -#define SC_READDIR 34 // args: fd, ent_no, out dirent_t *data -#define SC_STAT_OPEN 35 // args: fd, out stat_t *data -- stat on open file handle -#define SC_IOCTL 36 // args: fd, command, out void* data -#define SC_GET_MODE 37 // args: fd -- get mode for open file handle -#define SC_SELECT 38 // args: sel_fd_t*, count, timeout - -#define SC_MK_CHANNEL 40 // args: blocking?, (int, int)* -#define SC_GEN_TOKEN 41 // args: fd, token_t* -#define SC_USE_TOKEN 42 // args: token_t* - -#define SC_MAKE_FS 50 // args: sc_make_fs_args_t -#define SC_FS_ADD_SRC 51 // args: fs_name, fs_name_strlen, fd, opts, opts_strlen -#define SC_SUBFS 52 // args: sc_subfs_args_t -#define SC_RM_FS 53 // args: fs_name, fs_name_strlen -// TODO : how do we enumerate filesystems ? - -#define SC_NEW_PROC 60 // args: nothing ? -#define SC_BIND_FS 61 // args: pid, new_name, new_name_strlen, fs_name, fs_name_strlen -- bind FS to child process -#define SC_BIND_SUBFS 62 // args: sc_subfs_args_t -- subfs & bind to child process -#define SC_BIND_MAKE_FS 63 // args: sc_make_fs_args_t -#define SC_BIND_FD 64 // args: pid, new_fd, local_fd -- copy a file descriptor to child process -#define SC_PROC_EXEC 65 // args: pid, exec_name, exec_name_strlen -- execute binary in process -#define SC_PROC_STATUS 66 // args: pid, proc_status_t* -#define SC_PROC_KILL 67 // args: pid, proc_status_t* -- inconditionnally kill child process -#define SC_PROC_WAIT 68 // args: pid?, block?, proc_status_t* - -#define INVALID_PID 0 // do a wait with this PID to wayt for any child - -typedef struct { - const char* driver; - size_t driver_strlen; - - const char* fs_name; - size_t fs_name_strlen; - - fd_t source_fd; - - const char* opts; - size_t opts_strlen; - - pid_t bind_to_pid; // zero = bind to current proc -} sc_make_fs_args_t; - -typedef struct { - const char* new_name; - size_t new_name_strlen; - - const char* from_fs; - size_t from_fs_strlen; - - const char* root; - size_t root_strlen; - - int ok_modes; - - pid_t bind_to_pid; // 0 = bind to current proc -} sc_subfs_args_t; - -/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/common/include/token.h b/src/common/include/token.h deleted file mode 100644 index 9ec1aff..0000000 --- a/src/common/include/token.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include -#include - -#define TOKEN_LENGTH 16 -typedef struct { - char bytes[TOKEN_LENGTH]; -} token_t; - -/* vim: set ts=4 sw=4 tw=0 noet :*/ -- cgit v1.2.3