Browse Source

Update project organization

master
Yann MAGNIN 2 years ago
parent
commit
da5ff236bb
  1. 1
      .gitignore
  2. 5
      README.md
  3. 39
      include/kernel/devices/earlyterm.h
  4. 21
      include/kernel/devices/tty.h
  5. 13
      include/kernel/drivers/screen.h
  6. 4
      include/kernel/loader.h
  7. 14
      include/kernel/util/debug.h
  8. 51
      include/kernel/util/draw.h
  9. 31
      include/kernel/util/string.h
  10. 64
      include/lib/display.h
  11. 20
      include/lib/string.h
  12. 9
      src/kernel/Makefile
  13. 100
      src/kernel/bootstrap/start.c
  14. 15
      src/kernel/devices/earlyterm/clear.c
  15. 25
      src/kernel/devices/earlyterm/init.c
  16. 162
      src/kernel/devices/earlyterm/write.c
  17. 2
      src/kernel/devices/tty/device.c
  18. 51
      src/kernel/devices/tty/ioctl/ioctl.c
  19. 17
      src/kernel/devices/tty/operations/close.c
  20. 73
      src/kernel/devices/tty/operations/open.c
  21. 27
      src/kernel/devices/tty/operations/read.c
  22. 39
      src/kernel/devices/tty/operations/write.c
  23. 21
      src/kernel/drivers/screen/constructor.c
  24. 12
      src/kernel/drivers/screen/getter.c
  25. 7
      src/kernel/drivers/vbr/exception.c
  26. 7
      src/kernel/drivers/vbr/interrupt.c
  27. 7
      src/kernel/drivers/vbr/tlb.c
  28. 2
      src/kernel/fs/gladfs/file/read.c
  29. 2
      src/kernel/fs/gladfs/file/write.c
  30. 6
      src/kernel/fs/gladfs/filesystem/mount.c
  31. 2
      src/kernel/fs/gladfs/inode/get_name.c
  32. 2
      src/kernel/fs/gladfs/superblock/alloc_inode.c
  33. 4
      src/kernel/fs/smemfs/file/read.c
  34. 20
      src/kernel/fs/smemfs/initialize.c
  35. 9
      src/kernel/fs/syscall/open.c
  36. 2
      src/kernel/fs/vfs/dentry/alloc.c
  37. 34
      src/kernel/fs/vfs/dentry/resolve.c
  38. 31
      src/kernel/fs/vfs/file/open.c
  39. 2
      src/kernel/fs/vfs/file/read.c
  40. 2
      src/kernel/fs/vfs/inode/mkdir.c
  41. 3
      src/kernel/fs/vfs/inode/mknod.c
  42. 25
      src/kernel/fs/vfs/superblock/mount.c
  43. 67
      src/kernel/loader/entry.c
  44. 13
      src/kernel/loader/image.c
  45. 10
      src/kernel/memory/pm_free.c
  46. 21
      src/kernel/scheduler/debug.c
  47. 30
      src/kernel/scheduler/process/create.c
  48. 40
      src/kernel/scheduler/start.c
  49. 13
      src/kernel/scheduler/syscall/sys_exit.c
  50. 30
      src/kernel/scheduler/syscall/sys_fexecve.c
  51. 14
      src/kernel/syscall/handler.c
  52. 74
      src/kernel/test.c
  53. 135
      src/kernel/util/debug/printk.c
  54. 140
      src/kernel/util/draw/ascii.c
  55. 26
      src/kernel/util/draw/clear.c
  56. 43
      src/kernel/util/draw/clr_str_area.c
  57. 16
      src/kernel/util/draw/display.c
  58. 20
      src/kernel/util/draw/print.c
  59. 38
      src/kernel/util/draw/scroll.c
  60. 9
      src/kernel/util/string/memcpy.c
  61. 9
      src/kernel/util/string/memset.c
  62. 17
      src/kernel/util/string/strcat.c
  63. 31
      src/kernel/util/string/strchr.c
  64. 22
      src/kernel/util/string/strcmp.c
  65. 27
      src/kernel/util/string/strcpy.c
  66. 23
      src/kernel/util/string/strlen.c
  67. 8
      src/lib/Makefile
  68. 12
      src/lib/display/dascii.S
  69. 99
      src/lib/display/dascii.c
  70. 12
      src/lib/display/dclear.S
  71. 15
      src/lib/display/dclear.c
  72. 12
      src/lib/display/dclr_str_area.S
  73. 19
      src/lib/display/dopen.c
  74. 12
      src/lib/display/dprint.S
  75. 237
      src/lib/display/dprint.c
  76. 12
      src/lib/display/dreverse.S
  77. 27
      src/lib/display/dreverse.c
  78. 12
      src/lib/display/dscroll.S
  79. 28
      src/lib/display/dscroll.c
  80. 59
      src/lib/display/font_default5x3.c
  81. 9
      src/lib/string/strcmp.c
  82. 10
      src/user/shell/Makefile
  83. 8
      src/user/shell/builtin/proc.c
  84. 14
      src/user/shell/main.c
  85. 6
      src/user/shell/util/check_builtin.c
  86. 4
      src/user/test/Makefile

1
.gitignore

@ -58,3 +58,4 @@ build/
.tests
.old
*.g1a
debug_bin

5
README.md

@ -1,6 +1,6 @@
# Vhex Kernel
Vhex is a kernel which provide development and retro ingenierie environment for fx9860g.
Vhex is a kernel which provide retro ingenierie environment for the fx9860g.
The Casio's OS code is not open-source, but we can read the binary for understand his working.
There are in particular the syscalls, OS's functions that can be called as a library by the add-ins, which are a gold mine of clues about the functioning of the material.
@ -9,6 +9,9 @@ There are in particular the syscalls, OS's functions that can be called as a lib
* Loader ELF
* Scheduler (not prehemptive yet)
* Driver (EEPROM (read), screen, keyboard, timers)
* Syscall
* Virtual File System
* File System Ext2 on RAM
## Building

39
include/kernel/devices/earlyterm.h

@ -0,0 +1,39 @@
#ifndef __KERNEL_DEVICES_EARLYTERM_H__
# define __KERNEL_DEVICES_EARLYTERM_H__
#include <stddef.h>
#include <stdint.h>
#include <lib/display.h>
// Wait for debug (dirty)
// TODO: use earlyterm_read() to wait key event ?
#define DBG_WAIT for(int i = 0 ; i < 3000000 ; i++)
// Internal earlyterm device struc
struct earlyterm
{
// Internal object used by the
// drawing lib
display_t display;
// Cursor part, we use only the X
// axis because we scroll the vram when
// the line overflow or new line char
// involved.
struct {
uint8_t x;
uint8_t y;
struct {
uint8_t x;
uint8_t y;
} max;
} cursor;
};
// Primitives
extern int earlyterm_init(void);
extern void earlyterm_clear(void);
extern void earlyterm_write(const char *format, ...);
#endif /*__KERNEL_DEVICES_EARLYTERM_H__*/

21
include/kernel/devices/tty.h

@ -5,19 +5,25 @@
#include <stdint.h>
#include <kernel/drivers/screen.h>
#include <kernel/util/types.h>
#include <kernel/util/draw.h>
#include <lib/display.h>
// Define default buffer size.
// TODO: remove me ?
#define TTY_BUFFER_LINES (DISPLAY_VCHAR_MAX * 3)
#define TTY_BUFFER_COLUMNS (DISPLAY_HCHAR_MAX)
//#define TTY_BUFFER_LINES (DISPLAY_VCHAR_MAX * 3)
//#define TTY_BUFFER_COLUMNS (DISPLAY_HCHAR_MAX)
// Define TTY major
#define TTY_DEV_MAJOR (4)
struct tty_s
{
char buffer[TTY_BUFFER_LINES + 1][TTY_BUFFER_COLUMNS + 1];
// Internal buffers
struct {
char input[256];
char **output;
} buffers;
// Cursor informations
struct {
int16_t x;
int16_t y;
@ -27,10 +33,9 @@ struct tty_s
} max;
} cursor;
/*struct {
ssize_t (*write)(const void *buffer, size_t count);
ssize_t (*read)(void *buffer, size_t count);
} primitives;*/
// Object used by the drawing library.
// It's store video ram and font informations
display_t disp;
};
// internal strct used by the TTY read primitives

13
include/kernel/drivers/screen.h

@ -4,8 +4,15 @@
#include <stddef.h>
#include <stdint.h>
// Define screen informations.
#define DISPLAY_SCREEN_WIDTH (128)
#define DISPLAY_SCREEN_HEIGHT (64)
// Internal enumeration for the
// screen getter
typedef enum {
SCREEN_WIDTH,
SCREEN_HEIGHT
} screen_getter_t;
// Internal hardware abstract
extern size_t screen_get(screen_getter_t getter);
extern void (*screen_update)(void *vram);
#endif /*__KERNEL_DRIVERS_SCREEN_H__*/

4
include/kernel/loader.h

@ -8,8 +8,8 @@
#include <kernel/util/elf.h>
// Function
extern void *loader(const char *path, struct process *process);
extern int loader(struct process *process, const char *path);
extern int loader_get_header(FILE *file, Elf32_Ehdr *header);
extern void *loader_load_image(FILE *file, Elf32_Ehdr *header, struct process *process);
extern int loader_load_image(struct process *process, FILE *file, Elf32_Ehdr *header);
#endif /*__KERNEL_LOADER_H__*/

14
include/kernel/util/debug.h

@ -1,14 +0,0 @@
#ifndef __KERNEL_UTIL_DEBUG_H__
# define __KERNEL_UTIL_DEBUG_H__
#include <stddef.h>
#include <stdint.h>
#include <kernel/util/draw.h>
// Wait debug (dirty)
#define DBG_WAIT for(int i = 0 ; i < 3000000 ; i++)
// Prototype
void printk(int x, int y, char const *str, ...);
#endif /*__KERNEL_UTIL_DEBUG_H__*/

51
include/kernel/util/draw.h

@ -1,51 +0,0 @@
#ifndef __KERNEL_UTIL_DRAW_H__
# define __KERNEL_UTIL_DRAW_H__
#include <stddef.h>
#include <stdint.h>
#include <kernel/drivers/screen.h>
// Define the (hardcoded) font bitmap informations.
#define KERNEL_FONT_BITMAP_WIDTH (127) // Bitmap width
#define KERNEL_FONT_BITMAP_HEIGHT (23) // Bitmap height
#define KERNEL_FONT_BITMAP_CWIDTH (4) // Character width (bitmap)
#define KERNEL_FONT_BITMAP_CHEIGHT (6) // Character height (bitmap)
#define KERNEL_FONT_REAL_WIDTH (3) // Charater width (real)
#define KERNEL_FONT_REAL_HEIGHT (5) // Character height (real)
#define KERNEL_FONT_NB_CHAR_X ((KERNEL_FONT_BITMAP_WIDTH / KERNEL_FONT_BITMAP_CWIDTH) + 1)
#define KERNEL_FONT_NB_CHAR_Y ((KERNEL_FONT_BITMAP_HEIGHT / KERNEL_FONT_BITMAP_CHEIGHT) + 1)
// Define Number of vertical lines
// and horizontal lines.
// TODO: move me to <kernel/drivers/screen.h> ?
#define DISPLAY_VCHAR_MAX (DISPLAY_SCREEN_HEIGHT / (KERNEL_FONT_REAL_HEIGHT + 1))
#define DISPLAY_HCHAR_MAX (DISPLAY_SCREEN_WIDTH / (KERNEL_FONT_REAL_WIDTH + 1))
// Internal struct used to draw
// the ASCII character.
struct font_block_s
{
int16_t height;
int16_t width;
struct {
uint16_t x;
uint16_t y;
} bitmap;
int16_t x;
int16_t y;
};
// Prototype
extern void kvram_clear(void);
extern void kvram_display(void);
extern void kvram_scroll(int lines);
extern void kvram_reverse(int x, int y, int width, int height);
extern void kvram_clr_str_area(int x, int y, int width, int height);
extern void kvram_print(int x, int y, const char *string, size_t len);
extern void kvram_ascii(int x, int y, char const c);
#endif /*__KERNEL_UTIL_DRAW_H__*/

31
include/kernel/util/string.h

@ -1,31 +0,0 @@
#ifndef __KERNEL_UTIL_STRING_H__
# define __KERNEL_UTIL_STRING_H__
#include <stddef.h>
#include <stdint.h>
/* memset() - fill memory with a constant byte. */
extern void *memset(void *s, int c, size_t n);
extern void *memcpy(void *dest, const void *src, size_t n);
/* strcat() - concatenate two string */
extern char *strcat(char *dest, char const *src);
/* strcmp() - compare two strings */
extern int strcmp(const char *s1, const char *s2);
extern int strncmp(const char *s1, const char *s2, size_t n);
/* strcpy(), strncpy() - copy a string. */
extern char *strncpy(char *dest, char const *str, size_t size);
extern char *strcpy(char *dest, char const *src);
/* strlen - calculate the lenght of a string. */
extern size_t strnlen(char const *str, size_t maxlen);
extern size_t strlen(char const *str);
/* strchr - find the first / last occurent of the char c */
extern char *strchr(const char *s1, int c);
extern char *strchrnul(const char *s1, int c);
extern char *strrchr(const char *s1, int c);
#endif /*__KERNEL_UTIL_STRING_H__*/

64
include/lib/display.h

@ -4,13 +4,61 @@
#include <stddef.h>
#include <stdint.h>
// Draw primtives
extern void dclear(void);
extern void dclr_str_area(int x, int y, int with, int height);
extern void dprint(int x, int y, char const *str, ...);
extern void dascii(int x, int y, char const c);
extern void dreverse(int x, int y, int width, int height);
extern void dscroll(int line);
extern void dupdate(void);
// Internal struct used in each draw function
typedef struct display_s
{
uint32_t vram[256];
struct font_s *font;
struct {
size_t width;
size_t height;
} display;
// Internal pre-calculated value
int nb_char_width;
} display_t;
// Internal struct used to define font structure object.
// TODO: move me ?
struct font_s
{
// Bitmap informations
struct {
uint8_t width;
uint8_t height;
uint8_t cwidth;
uint8_t cheight;
uint8_t *raw;
} bitmap;
// Character information
struct {
uint8_t width;
uint8_t height;
} font;
};
// Internal struct used to draw
// the ASCII character.
struct font_block_s
{
int16_t height;
int16_t width;
struct {
uint16_t x;
uint16_t y;
} bitmap;
int16_t x;
int16_t y;
};
// Draw primitives
extern int dopen(display_t *disp, const char *fontname);
extern void dclear(display_t *disp);
extern void dascii(display_t *disp, int row, int colomn, char const c);
extern size_t dprint(display_t *disp, int x, int y, char const *str, ...);
extern void dscroll(display_t *disp, int line);
extern void dreverse(display_t *disp, int x, int y, int width, int height);
extern void dupdate(display_t *disp);
#endif /*__LIB_DISPLAY_H__*/

20
include/lib/string.h

@ -5,21 +5,25 @@
#include <stddef.h>
/* memset() - fill memory with a constant byte. */
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
extern void *memset(void *s, int c, size_t n);
extern void *memcpy(void *dest, const void *src, size_t n);
/* strcat() - concatenate two string */
char *strcat(char *dest, char const *src);
extern char *strcat(char *dest, char const *src);
/* strcmp() - compare two strings */
int strcmp(const char *s1, const char *s2);
extern int strcmp(const char *s1, const char *s2);
extern int strncmp(const char *s1, const char *s2, size_t n);
/* strcpy(), strncpy() - copy a string. */
char *strncpy(char *dest, char const *str, size_t size);
char *strcpy(char *dest, char const *src);
extern char *strncpy(char *dest, char const *str, size_t size);
extern char *strcpy(char *dest, char const *src);
/* strlen - calculate the lenght of a string. */
size_t strnlen(char const *str, size_t maxlen);
size_t strlen(char const *str);
extern size_t strnlen(char const *str, size_t maxlen);
extern size_t strlen(char const *str);
/* strrchr() - find the last occurent of a byte */
extern char *strrchr(const char *s, int c);
#endif /*__STRING_H__*/

9
src/kernel/Makefile

@ -20,6 +20,7 @@ NAME := vhex
EXEC := $(OUTPUT)/$(NAME).g1a
LDFLAG := -T $(NAME).ld
MEMORY_MAP := $(DEBUG)/$(NAME).map
LIBS := -L../lib -lgcc -lstring -ldisplay
ICON := icon.bmp
@ -46,10 +47,10 @@ OBJ := $(patsubst ._%,$(BUILD)/%.o,$(subst /,_,$(basename $(SRC))))
##---
## General rules
##---
all: | $(BUILD) $(DEBUG) $(OUTPUT) $(EXEC)
all: $(OUTPUT) $(EXEC)
$(EXEC): $(OBJ)
$(CC) -Wl,-M $(LDFLAG) $(CFLAGS) -o $(DEBUG)/$(NAME).elf $(OBJ) $(HEADER) -lgcc -L../lib -l_display > $(MEMORY_MAP)
$(EXEC): $(OBJ) | $(DEBUG)
$(CC) -Wl,-M $(LDFLAG) $(CFLAGS) -o $(DEBUG)/$(NAME).elf $(OBJ) $(HEADER) $(LIBS) > $(MEMORY_MAP)
$(OBJCOPY) -R .comment -R .bss -O binary $(DEBUG)/$(NAME).elf $(DEBUG)/$(NAME).bin
$(WRAPPER) $(DEBUG)/$(NAME).bin -o $@ -i $(ICON)
@ -84,7 +85,7 @@ sec:
## Automated rules
##---
define rule-src
$(patsubst ._%,$(BUILD)/%.o,$(subst /,_,$(basename $1))): $1
$(patsubst ._%,$(BUILD)/%.o,$(subst /,_,$(basename $1))): $1 | $(BUILD)
@ printf "compiling $(white)$$<$(nocolor)..."
@ $(CC) $(CFLAGS) -o $$@ -c $$< $(HEADER) -lgcc
@ printf "$(green)[ok]$(nocolor)\n"

100
src/kernel/bootstrap/start.c

@ -1,20 +1,26 @@
#include <stdint.h>
#include <stddef.h>
// Internal helpers
#include <kernel/util/types.h>
#include <kernel/util/atomic.h>
#include <kernel/util/debug.h>
#include <kernel/util/string.h>
#include <kernel/util/casio.h>
// Modules
#include <kernel/context.h>
#include <kernel/process.h>
#include <kernel/syscall.h>
#include <kernel/scheduler.h>
#include <kernel/loader.h>
// Devices
#include <kernel/devices/tty.h>
#include <kernel/devices/earlyterm.h>
// File System
#include <kernel/fs/vfs.h>
#include <kernel/fs/stat.h>
#include <kernel/fs/smemfs.h>
#include <kernel/fs/gladfs.h>
#include <kernel/loader.h>
#include <kernel/devices/tty.h>
// Libs
#include <lib/display.h>
#include <lib/string.h>
// Internal symbols
mpu_t current_mpu = MPU_UNKNOWN;
@ -78,7 +84,7 @@ static void rom_explore(volatile void *rom, int32_t size)
/* section_execute() - Used to execute contructors and destructors */
static void section_execute(void *bsection, void *esection)
{
while ((uint32_t)bsection < (uint32_t)esection)
while ((uintptr_t)bsection < (uintptr_t)esection)
{
((void (*)(void))*((uint32_t*)bsection))();
bsection = (void*)((uint32_t)bsection + 4);
@ -90,9 +96,6 @@ static void section_execute(void *bsection, void *esection)
__attribute__((section(".pretext")))
int start(void)
{
extern uint32_t vram[256];
int error;
//--
// Bootstrap part !
//--
@ -120,6 +123,16 @@ int start(void)
// before switching the VBR.
rom_explore(&brom, (int32_t)&srom);
// Start early terminal device
// This device is used by the kernel to display
// some logs on screen
if (earlyterm_init() != 0)
return (-1);
earlyterm_clear();
earlyterm_write("Kernel initialisation...\n");
// Save Casio's hardware context and set
// Vhex hardware context.
// @note:
@ -130,6 +143,7 @@ int start(void)
// And this is why between each `atomic_start`
// and `atomic_end()` the code *SHOULD* be
// exception safe.
earlyterm_write("Environment switch...\n");
atomic_start();
fx9860_context_save(&casio_context);
vhex_context_set();
@ -140,14 +154,17 @@ int start(void)
//---
// Internal FS init !
earlyterm_write("Initialize File System...\n");
gladfs_initialize();
smemfs_initialize();
// Initilize Virtual File System
earlyterm_write("Init. Virtual File System...\n");
vfs_register_filesystem(&gladfs_filesystem);
vfs_register_filesystem(&smemfs_filesystem);
// Creat initial file tree
earlyterm_write("Create Filesystem Hierarchy...\n");
vfs_mount(NULL, NULL, "gladfs", VFS_MOUNT_ROOT, NULL);
vfs_mkdir("/dev", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
vfs_mkdir("/home", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
@ -156,41 +173,43 @@ int start(void)
vfs_mount(NULL, "/mnt/smemfs", "smemfs", /*MS_RDONLY*/0, NULL);
// Add devices
earlyterm_write("Add devices...\n");
vfs_mknod("/dev/tty", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
dev_make_major(TTY_DEV_MAJOR));
// Test mode !
//extern void kernel_test(void);
//kernel_test();
//---
// Start first process !
//---
// Create first process: Vhex.
struct process *vhex_process = process_create("Vhex");
if (vhex_process == NULL)
//earlyterm_write("Create first process...\n");
//struct process *vhex_process = process_create("Vhex");
/*if (vhex_process == NULL)
{
kvram_clear();
printk(0, 0, "Vhex fatal error !");
printk(0, 1, "First process error !");
printk(0, 2, "Wait manual reset...");
kvram_display();
earlyterm_clear();
earlyterm_write("Vhex fatal error !\n");
earlyterm_write("First process error !\n");
earlyterm_write("Press [MENU] key...\n");
while (1) { __asm__ volatile ("sleep"); }
}
}*/
// Load programe.
//vhex_process->context.spc = (uint32_t)&kernel_test;
vhex_process->context.spc = (uint32_t)loader("/mnt/smemfs/VHEX/shell.elf", vhex_process);
if (vhex_process->context.spc == 0x00000000)
//vhex_process->context.spc = (uint32_t)loader("/mnt/smemfs/VHEX/shell.elf", vhex_process);
//if (vhex_process->context.spc == 0x00000000)
earlyterm_write("Create first process...\n");
struct process *vhex_process = process_create("Vhex");
if (vhex_process == NULL || loader(vhex_process, "/mnt/smemfs/VHEX/shell.elf") != 0)
{
// Display message.
kvram_clear();
printk(0, 0, "Vhex fatal error !");
printk(0, 1, "File \"VHEX/shell.elf\" not found !");
printk(0, 2, "Press [MENU key]...");
kvram_display();
earlyterm_clear();
earlyterm_write("Vhex fatal error !\n");
earlyterm_write("Unable to create the first process !\n");
if (vhex_process->context.spc == 0xffffffff)
earlyterm_write("process_create() error\n");
else
earlyterm_write("File \"VHEX/shell.elf\" not found !");
earlyterm_write("Press [MENU key]...");
// Restore Casio context.
fx9860_context_restore(&casio_context);
@ -200,7 +219,8 @@ int start(void)
// @note: GetKey will call Bdisp_PutDD_VRAM(),
// so save the current internal Video RAM data into
// Casio's VRAM.
memcpy(casio_Bdisp_GetVRAM(), vram, 1024);
extern struct earlyterm earlyterm;
memcpy(casio_Bdisp_GetVRAM(), earlyterm.display.vram, 1024);
// Wait MENU key.
unsigned int key;
@ -210,24 +230,16 @@ int start(void)
}
}
// DEBUG !
kvram_clear();
printk(0, 0, "Initialize scheduler !");
printk(0, 1, "Try to start sceduler...");
kvram_display();
DBG_WAIT;
// Initialize sheduler !!
//---
// Initialize sheduler !!
//---
earlyterm_write("Initialize scheduler...\n");
sched_initialize();
sched_add_task(vhex_process);
sched_start();
// normally the kernel SHOULD / CAN not arrive here.
kvram_clear();
printk(0, 0, "Kernel job fini !");
kvram_display();
while (1)
{
__asm__ volatile ("sleep");
}
earlyterm_write("Kernel job fini !");
while (1) { __asm__ volatile ("sleep"); }
}

15
src/kernel/devices/earlyterm/clear.c

@ -0,0 +1,15 @@
#include <kernel/devices/earlyterm.h>
#include <lib/display.h>
/* earlyterm_clear() - clear internal vram and reset cursor position */
void earlyterm_clear(void)
{
extern struct earlyterm earlyterm;
// Clear video ram
dclear(&earlyterm.display);
// Reset cursor
earlyterm.cursor.x = 0;
earlyterm.cursor.y = 0;
}

25
src/kernel/devices/earlyterm/init.c

@ -0,0 +1,25 @@
#include <kernel/devices/earlyterm.h>
#include <kernel/drivers/screen.h>
// Internal globals
struct earlyterm earlyterm;
// earlyterm_init()
// Initialize internal early terminal symbols
int earlyterm_init(void)
{
// Get internal vram and font
// TODO: return menu
if (dopen(&earlyterm.display, "default") != 0)
return (-1);
// Generate cursor informations
earlyterm.cursor.x = 0;
earlyterm.cursor.max.x = screen_get(SCREEN_WIDTH);
earlyterm.cursor.max.x /= earlyterm.display.font->font.width + 1;
earlyterm.cursor.max.y = screen_get(SCREEN_HEIGHT);
earlyterm.cursor.max.y /= earlyterm.display.font->font.height + 1;
earlyterm.cursor.y = 0;
return (0);
}

162
src/kernel/devices/earlyterm/write.c

@ -0,0 +1,162 @@
#include <kernel/devices/earlyterm.h>
#include <kernel/drivers/screen.h>
#include <kernel/util/atomic.h>
#include <stdarg.h>
/* earlyterm_vertical_update() - Check / update device vertical cursor */
static void earlyterm_vertical_update(struct earlyterm *earlyterm)
{
// Check if we can move the cursor
if (earlyterm->cursor.y + 1 < earlyterm->cursor.max.y) {
earlyterm->cursor.y = earlyterm->cursor.y + 1;
return;
}
// Other wise scroll the vram
dscroll(&earlyterm->display, earlyterm->display.font->font.height + 1);
}
/* earlyterm_horizontal_update() - Check / update earlyterm horizotal cursor */
static int earlyterm_horizontal_update(struct earlyterm *earlyterm)
{
earlyterm->cursor.x = earlyterm->cursor.x + 1;
if (earlyterm->cursor.x >= earlyterm->cursor.max.x)
{
earlyterm_vertical_update(earlyterm);
earlyterm->cursor.x = 0;
return (1);
}
return (0);
}
/* print_base() - display number in base (0~16)*/
static void print_base(struct earlyterm *earlyterm, uint32_t nb,
int base, int digits_min)
{
char hex[] = "0123456789abcdef";
char buffer[16];
int digits;
// Generate string (reverse)
digits = 0;
while (digits < digits_min || nb != 0)
{
buffer[digits++] = hex[nb % base];
nb = nb / base;
}
// Display string.
while (--digits >= 0)
{
dascii(&earlyterm->display, earlyterm->cursor.x,
earlyterm->cursor.y, buffer[digits]);
earlyterm_horizontal_update(earlyterm);
}
}
/* line_discipline() - Check all "special" char */
static int line_discipline(struct earlyterm *earlyterm, char n)
{
// New line
if (n == '\n')
{
earlyterm->cursor.x = 0;
earlyterm_vertical_update(earlyterm);
return (1);
}
return (0);
}
// earlyterm_write() - printf wrapper for early terminal device
// TODO: update me... x_x
void earlyterm_write(const char *format, ...)
{
extern struct earlyterm earlyterm;
int32_t nb;
va_list ap;
int i;
// Atomic start
atomic_start();
// Get starting variable args
va_start(ap, format);
// Walk into string and display character by character
i = -1;
while (format[++i] != '\0')
{
// Check line discipline
if (line_discipline(&earlyterm, format[i]) != 0)
continue;
// String format "simple"
if (format[i] == '%')
{
if (format[i + 1] == 'd' || format[i + 1] == 'x')
{
// Check negative value
// FIXME: negative error (max)
nb = va_arg(ap, int32_t);
if (nb < 0 && format[i + 1] == 'd')
{
nb = 0 - nb;
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, '-');
earlyterm_horizontal_update(&earlyterm);
}
print_base(&earlyterm, nb, (format[i + 1] == 'd') ? 10 : 16, 1);
i = i + 1;
continue;
}
if ((format[i + 1] == '#' && format[i + 2] == 'x') || format[i + 1] == 'p')
{
// add @ if 'p' (pointer)
if (format[i + 1] == 'p')
{
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, '@');
earlyterm_horizontal_update(&earlyterm);
}
// Add "0x"
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, '0');
earlyterm_horizontal_update(&earlyterm);
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, 'x');
earlyterm_horizontal_update(&earlyterm);
// Get value
nb = va_arg(ap, uint32_t);
print_base(&earlyterm, nb, 16, 8);
// Update cursor
i = (format[i + 1] == '#') ? i + 2 : i + 1;
continue;
}
if (format[i + 1] == 's')
{
nb = va_arg(ap, uint32_t) - 1;
while (*(char*)(++nb) != '\0')
{
if (line_discipline(&earlyterm, *(char*)nb) != 0)
continue;
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, *(char*)nb);
earlyterm_horizontal_update(&earlyterm);
}
i = i + 1;
continue;
}
}
// Default, display character
dascii(&earlyterm.display, earlyterm.cursor.x, earlyterm.cursor.y, format[i]);
earlyterm_horizontal_update(&earlyterm);
}
// Display vram
screen_update(earlyterm.display.vram);
// End of variodic args.
va_end(ap);
// Atomic stop
atomic_stop();
}

2
src/kernel/devices/tty/device.c

@ -7,7 +7,7 @@ DEVICE(tty) = {
.file_op = {
.read = (void *)&tty_read,
.write =(void *)&tty_write,
.ioctl = &tty_ioctl
.ioctl = NULL
},
.close = &tty_close
};

51
src/kernel/devices/tty/ioctl/ioctl.c

@ -1,51 +0,0 @@
#include <kernel/devices/tty.h>
#include <kernel/util/atomic.h>
#include <stdarg.h>
void tty_ioctl(void *inode, uint32_t cmd, ...)
{
struct tty_s *tty;
va_list ap;
// Start atomic operation
atomic_start();
tty = inode;
va_start(ap, cmd);
switch (cmd)
{
case TTY_IOCTL_GETDX:
{
int *dx = va_arg(ap, int*);
*dx = tty->cursor.x * (KERNEL_FONT_REAL_WIDTH + 1);
break;
}
case TTY_IOCTL_GETDY:
{
int *dy = va_arg(ap, int*);
int start = tty->cursor.y;
int saved_start;
int line = -1;
while (++line < DISPLAY_VCHAR_MAX - 1)
{
// Update check line.
saved_start = start;
start = (start - 1 < 0) ? tty->cursor.max.y : start - 1;
// Check if the line exist.
if (tty->buffer[start][0] == '\0')
{
start = saved_start;
break;
}
}
*dy = line * (KERNEL_FONT_REAL_HEIGHT + 1);
break;
}
}
va_end(ap);
// Stop atomic operation
atomic_stop();
}

17
src/kernel/devices/tty/operations/close.c

@ -1,7 +1,22 @@
#include <kernel/devices/tty.h>
#include <kernel/memory.h>
int tty_close(void *inode)
{
// Do nothing for now.
struct tty_s *tty;
int line;
// Get tty object
tty = inode;
// Free'd all allocated memory for the
// output buffer
line = tty->cursor.max.y;
while (line >= 0)
pm_free(tty->buffers.output[line]);
pm_free(tty->buffers.output);
// Free'd tty object
pm_free(tty);
return (0);
}

73
src/kernel/devices/tty/operations/open.c

@ -1,29 +1,64 @@
#include <kernel/devices/tty.h>
#include <kernel/util/string.h>
#include <kernel/devices/earlyterm.h>
#include <kernel/drivers/screen.h>
#include <kernel/memory.h>
#include <lib/display.h>
#include <lib/string.h>
// Internal TTY object.
static struct tty_s tty;
//TODO: MULTIPLE OPEN !!!!
//TODO: SHARED TTY DEVICE !!!!
void *tty_open(dev_t major, dev_t minor)
{
int lines;
struct tty_s *tty;
int line;
// TODO: handle major / minor ?
// TODO: handle major / minor !!
(void)major;
(void)minor;
// Try to allocate tty object
tty = (struct tty_s*)pm_alloc(sizeof(struct tty_s));
if (tty == NULL)
return (NULL);
// Get the font used by the tty.
if (dopen(&tty->disp, "default") != 0)
{
pm_free(tty);
return (NULL);
}
// Generate formated output buffer indicator
tty->cursor.max.x = screen_get(SCREEN_WIDTH) / (tty->disp.font->font.width + 1);
tty->cursor.max.y = screen_get(SCREEN_HEIGHT) / (tty->disp.font->font.height + 1);
tty->cursor.max.y = tty->cursor.max.y * 4;
// Try to alloc new tty output buffer
tty->buffers.output = (char **)pm_alloc(sizeof(char *) * tty->cursor.max.y);
if (tty->buffers.output == NULL)
{
pm_free(tty);
return (NULL);
}
// Initialize TTY cursor.
tty.cursor.x = 0;
tty.cursor.y = 0;
tty.cursor.max.x = TTY_BUFFER_COLUMNS;
tty.cursor.max.y = TTY_BUFFER_LINES;
// Try to alloc each line of the output buffer
line = tty->cursor.max.y;
while (--line >= 0)
{
// Try to alloc the line
tty->buffers.output[line] = (char*)pm_alloc(tty->cursor.max.x);
if (tty->buffers.output[line] != NULL) {
memset(tty->buffers.output[line], '\0', tty->cursor.max.x);
continue;
}
// Release all allocated space and return NULL
while (++line < tty->cursor.max.y)
pm_free(tty->buffers.output[line]);
pm_free(tty->buffers.output);
pm_free(tty);
return (NULL);
}
// Initialize TTY buffer.
// TODO: user can set dynamicaly the TTY buffer size ?
lines = TTY_BUFFER_LINES;
while (--lines >= 0)
memset(tty.buffer[lines], '\0', TTY_BUFFER_COLUMNS);
return (&tty);
// Initialize default TTY cursor position.
tty->cursor.x = 0;
tty->cursor.y = 0;
return (tty);
}

27
src/kernel/devices/tty/operations/read.c

@ -2,11 +2,10 @@
#include <kernel/drivers/keyboard.h>
#include <kernel/drivers/timer.h>
#include <kernel/util/atomic.h>
#include <kernel/util/debug.h>
#include <kernel/util/string.h>
#include <kernel/util/casio.h>
#include <kernel/context.h>
#include <kernel/syscall.h>
#include <lib/string.h>
// Intenral functions
static int check_signal(struct keyboard_obj_s *keyboard, key_t key);
@ -20,8 +19,8 @@ static void cursor_callback(struct keyboard_obj_s *keyboard);
ssize_t tty_read(void *inode, void *buffer, size_t count)
{
extern struct keycache_s *keylist;
struct keycache_s *keynode;
struct keyboard_obj_s keyboard;
struct keycache_s *keynode;
int first_key;
int timer_fd;
@ -29,8 +28,6 @@ ssize_t tty_read(void *inode, void *buffer, size_t count)
if (count < 2)
return (0);
// get tty device
// Initialize internal struc.
memset(buffer, '\0', count);
keyboard.buffer.addr = buffer;
@ -305,6 +302,9 @@ static void cursor_callback(struct keyboard_obj_s *keyboard)
// Draw cursor if needed
if (keyboard->cvisible == 0)
{
// Force atomic operation
atomic_start();
// Geneate TTY buffer cursor position.
x = keyboard->buffer.cursor + keyboard->saved.tty.cursor.x;
y = x / keyboard->tty->cursor.max.x;
@ -318,19 +318,24 @@ static void cursor_callback(struct keyboard_obj_s *keyboard)
keyboard->tty->cursor.x = x;
keyboard->tty->cursor.y = y;
// Get Display X and Y position.
// TODO: remove me / find better way !!
tty_ioctl(keyboard->tty, TTY_IOCTL_GETDX, &x);
tty_ioctl(keyboard->tty, TTY_IOCTL_GETDY, &y);
// Get "real" X and Y position (pixel)
x = x * (keyboard->tty->disp.font->font.width + 1);
y = y * (keyboard->tty->disp.font->font.height + 1);
// Display cursor.
kvram_reverse(x, y, (KERNEL_FONT_REAL_WIDTH + 1), (KERNEL_FONT_REAL_HEIGHT + 1));
kvram_display();
dreverse(
&keyboard->tty->disp, x, y,
(keyboard->tty->disp.font->font.width + 1),
(keyboard->tty->disp.font->font.height + 1)
);
(*screen_update)(keyboard->tty->disp.vram);
// Restore TTY cursor position
keyboard->tty->cursor.x = sttyx;
keyboard->tty->cursor.y = sttyy;
// Stop atomic operations
atomic_stop();
}
// Update cursor status.
keyboard->cvisible = keyboard->cvisible ^ 1;

39
src/kernel/devices/tty/operations/write.c

@ -1,7 +1,7 @@
#include <kernel/devices/tty.h>
#include <kernel/devices/earlyterm.h>
#include <kernel/util/atomic.h>
#include <kernel/util/debug.h>
#include <kernel/util/string.h>
#include <lib/string.h>
/* tty_vertical_update() - Check / update TTY vertical cursor */
static void tty_vertical_update(struct tty_s *tty)
@ -13,7 +13,7 @@ static void tty_vertical_update(struct tty_s *tty)
tty->cursor.y = 0;
// Wipe new line.
memset(tty->buffer[tty->cursor.y], '\0', tty->cursor.max.x);
memset(tty->buffers.output[tty->cursor.y], '\0', tty->cursor.max.x);
}
/* tty_horizontal_update() - Check / update TTY horizotal cursor */
@ -49,7 +49,7 @@ static ssize_t tty_buffer_update(struct tty_s *tty, const uint8_t *buffer, size_
{
if (tty->cursor.x > 0)
tty->cursor.x = tty->cursor.x - 1;
tty->buffer[tty->cursor.y][tty->cursor.x] = '\0';
tty->buffers.output[tty->cursor.y][tty->cursor.x] = '\0';
continue;
}
@ -60,7 +60,7 @@ static ssize_t tty_buffer_update(struct tty_s *tty, const uint8_t *buffer, size_
offset = 5 - (tty->cursor.x - ((tty->cursor.x / 5) * 5));
if (tty->cursor.x + offset < tty->cursor.max.x)
{
memset(&tty->buffer[tty->cursor.y][tty->cursor.x], ' ', offset);
memset(&tty->buffers.output[tty->cursor.y][tty->cursor.x], ' ', offset);
tty->cursor.x = tty->cursor.x + offset;
continue;
}
@ -86,7 +86,7 @@ static ssize_t tty_buffer_update(struct tty_s *tty, const uint8_t *buffer, size_
if (buffer[i] == '\f' || buffer[i] == '\v')
{
tty_vertical_update(tty);
memset(tty->buffer[tty->cursor.y], ' ', tty->cursor.x);
memset(tty->buffers.output[tty->cursor.y], ' ', tty->cursor.x);
continue;
}
@ -94,7 +94,7 @@ static ssize_t tty_buffer_update(struct tty_s *tty, const uint8_t *buffer, size_
if (buffer[i] == '\r') { tty->cursor.x = 0; continue;}
// Update TTY buffer char.
tty->buffer[tty->cursor.y][tty->cursor.x] = buffer[i];
tty->buffers.output[tty->cursor.y][tty->cursor.x] = buffer[i];
tty_horizontal_update(tty);
}
return (i);
@ -117,14 +117,14 @@ static void tty_display(struct tty_s *tty)
// @note: circular buffer.
line = 0;
start = tty->cursor.y;
while (++line < DISPLAY_VCHAR_MAX)
while (++line < tty->cursor.max.y)
{
// Update check line.
saved_start = start;
start = (start - 1 < 0) ? tty->cursor.max.y : start - 1;
start = (start - 1 < 0) ? tty->cursor.max.y - 1 : start - 1;
// Check if the line existe.
if (tty->buffer[start][0] == '\0')
if (tty->buffers.output[start][0] == '\0')
{
start = saved_start;
break;
@ -132,26 +132,23 @@ static void tty_display(struct tty_s *tty)
}
// clear screen
kvram_clear();
dclear(&tty->disp);
// Display "on-screen" string lines.
y = -1;
while (++y < line)
{
// Get / check line lenght.
line_len = strnlen(tty->buffer[start], tty->cursor.max.x);
if (line_len == 0)
continue;
// Display line.
kvram_print(0, y, tty->buffer[start], line_len);
// Display line
line_len = -1;
while (tty->buffers.output[start][++line_len] != '\0')
dascii(&tty->disp, line_len, y, tty->buffers.output[start][line_len]);
// Get "next" line.
start = (start + 1 > tty->cursor.max.y) ? 0 : start + 1;
// Update row index
start = (start + 1 < tty->cursor.max.y) ? start + 1 : 0;
}
// Display on screen.
kvram_display();
(*screen_update)(tty->disp.vram);
// Stop atomic operation
atomic_stop();

21
src/kernel/drivers/screen/constructor.c

@ -0,0 +1,21 @@
#include <kernel/drivers/screen.h>
// Internal drivers
extern void t6k11_variant_lcd_driver(void *vram);
extern void t6k11_lcd_driver(void *vram);
// Primitives
void (*screen_update)(void *vram);
__attribute__((constructor))
static void screen_constructor(void)
{
// Check T6K11 variant which appear during
// the OS >= 03.00.0000
if (*(uint8_t*)0xa0010021 == '3') {
screen_update = (void*)&t6k11_variant_lcd_driver;
return;
}
// Default driver
screen_update = &t6k11_lcd_driver;
}

12
src/kernel/drivers/screen/getter.c

@ -0,0 +1,12 @@
#include <kernel/drivers/screen.h>
/* screen_get() - Internal screen getter */
size_t screen_get(screen_getter_t getter)
{
switch (getter)
{
case SCREEN_WIDTH: return (128);
case SCREEN_HEIGHT: return (64);
}
return (0);
}

7
src/kernel/drivers/vbr/exception.c

@ -1,4 +1,4 @@
#include <kernel/util/debug.h>
#include <kernel/devices/earlyterm.h>
void exception_handler(void)
{
@ -18,8 +18,8 @@ void exception_handler(void)
);
// Write exception informations.
kvram_clear();
printk(0, 0,
earlyterm_clear();
earlyterm_write(
"Ho crap ! Exception !\n"
"tra: %#x\n"
"expevt: %#x\n"
@ -32,6 +32,5 @@ void exception_handler(void)
ssr,
sr
);
kvram_display();
while (1);
}

7
src/kernel/drivers/vbr/interrupt.c

@ -1,4 +1,4 @@
#include <kernel/util/debug.h>
#include <kernel/devices/earlyterm.h>
// Handler prototype.
extern void keysc_handler(void);
@ -24,13 +24,12 @@ void interrupt_handler(void)
}
// Display error.
kvram_clear();
printk(0, 0,
earlyterm_clear();
earlyterm_write(
"Ho crap ! Interrupt error !\n"
"Interrupt ID (%#x)\n"
"Error: handler not foud !\n",
intevt
);
kvram_display();
while (1);
}

7
src/kernel/drivers/vbr/tlb.c

@ -1,4 +1,4 @@
#include <kernel/util/debug.h>
#include <kernel/devices/earlyterm.h>
__attribute__((section(".vhex.tlb"), interrupt_handler))
void tlb_handler(void)
@ -19,8 +19,8 @@ void tlb_handler(void)
);
// Write exception informations.
kvram_clear();
printk(0, 0,
earlyterm_clear();
earlyterm_write(
"Ho crap ! TLB Exception !\n"
"tra: %#x\n"
"expevt: %#x\n"
@ -33,6 +33,5 @@ void tlb_handler(void)
ssr,
sr
);
kvram_display();
while (1);
}

2
src/kernel/fs/gladfs/file/read.c

@ -1,6 +1,6 @@
#include <kernel/fs/gladfs.h>
#include <kernel/util/atomic.h>
#include <kernel/util/string.h>
#include <lib/string.h>
// Internal helper
extern struct gladfs_fragment_data_s **gladfs_file_pos(off_t *offset, struct gladfs_inode_s *inode, off_t pos);

2
src/kernel/fs/gladfs/file/write.c

@ -1,6 +1,6 @@
#include <kernel/fs/gladfs.h>
#include <kernel/util/atomic.h>
#include <kernel/util/string.h>
#include <lib/string.h>
// Internal helper
extern struct gladfs_fragment_data_s **gladfs_file_pos(off_t *offset, struct gladfs_inode_s *inode, off_t pos);

6
src/kernel/fs/gladfs/filesystem/mount.c

@ -1,6 +1,6 @@
#include <kernel/fs/gladfs.h>
#include <kernel/util/atomic.h>
#include <kernel/util/debug.h>
#include <kernel/devices/earlyterm.h>
/* gladfs_mount() - GladFS mount primitive (sync) */
void *gladfs_mount(void)
@ -18,9 +18,7 @@ void *gladfs_mount(void)
gladfs_superblock.root_inode = gladfs_superblock.super_op.alloc_inode("/", GLADFS_INODE_TYPE_ROOT);
if (gladfs_superblock.root_inode == NULL)
{
kvram_clear();
printk(0, 0, "GladFS: ROOT inode alloc error !");
kvram_display();
earlyterm_write("GladFS: ROOT inode alloc error !");
DBG_WAIT;
}
}

2
src/kernel/fs/gladfs/inode/get_name.c

@ -1,6 +1,6 @@
#include <kernel/fs/gladfs.h>
#include <kernel/util/atomic.h>
#include <kernel/util/string.h>
#include <lib/string.h>
/* gladfs_get_name() - Dump the name of a file (sync) */
int gladfs_get_name(void *inode, char *name, size_t count)

2
src/kernel/fs/gladfs/superblock/alloc_inode.c

@ -1,7 +1,7 @@
#include <kernel/fs/gladfs.h>
#include <kernel/memory.h>
#include <kernel/util/atomic.h>
#include <kernel/util/string.h>
#include <lib/string.h>
/* gladfs_alloc_inode() - Superblock primitive to alloc "empty" inode (sync) */
struct gladfs_inode_s *gladfs_alloc_inode(const char *name, mode_t mode)

4
src/kernel/fs/smemfs/file/read.c

@ -1,7 +1,7 @@
#include <kernel/fs/smemfs.h>
#include <kernel/fs/file.h>
#include <kernel/util/atomic.h>
#include <kernel/util/string.h>
#include <lib/string.h>
/* casio_smem_data_base_address() - Generate the fragmented data address (0xa0000000 + offset) */
static void *casio_smem_get_data_base_address(smemfs_fragdata_t *fragment)
@ -17,7 +17,7 @@ static void *casio_smem_get_data_base_address(smemfs_fragdata_t *fragment)
}
if (block->info.id != fragment->data_block_id)
return (NULL);
return ((void *)(block->offset + fragment->data_offset));
return ((void *)(uint32_t)(block->offset + fragment->data_offset));
}
/* casio_smem_read() - Read the file data (based on internal cursor) */

20
src/kernel/fs/smemfs/initialize.c

@ -1,6 +1,6 @@
#include <kernel/fs/smemfs.h>
#include <kernel/fs/filesystem.h>
#include <kernel/util/debug.h>
#include <kernel/devices/earlyterm.h>
// Kernel FS block
struct file_system_type smemfs_filesystem =
@ -47,19 +47,20 @@ void smemfs_initialize(void)
// Get / check Casio SMEM sector table
// @note:
// Casio SMEM sector table start
// always at 0xa0270000.
// always (?) at 0xa0270000 (tested with OS 1.00.0000).
// TODO: return error !!
smemfs_superblock.sector_table = (void *)0xa0270000;
if (smemfs_superblock.sector_table->magic_start != 0x4200)
{
kvram_clear();
printk(0, 0, "SMEMFS: Casio sector table error !");
printk(0, 1, "Wait manual reset...");
kvram_display();
earlyterm_clear();
earlyterm_write("SMEMFS: Casio sector table error !");
earlyterm_write("Wait manual reset...");
while (1){ __asm__ volatile ("sleep"); }
}
// Casio SMEM inode table start always at the end of the sector table.
// Normaly start at 0xa0270320 but not always (?)
// TODO: return error !!
int i = -1;
while (smemfs_superblock.sector_table[++i].magic_start == CASIO_SMEM_BLOCK_ENTRY_MAGIC);
smemfs_superblock.inode_table = (void *)&smemfs_superblock.sector_table[i];
@ -68,10 +69,9 @@ void smemfs_initialize(void)
smemfs_superblock.inode_table->parent.id != 0xffff ||
smemfs_superblock.inode_table->parent.type != 0xffff)
{
kvram_clear();
printk(0, 0, "SMEMFS: Casio inode table error !");
printk(0, 1, "Wait manual reset...");
kvram_display();
earlyterm_clear();
earlyterm_write("SMEMFS: Casio inode table error !");
earlyterm_write("Wait manual reset...");
while (1){ __asm__ volatile ("sleep"); }
}
}

9
src/kernel/fs/syscall/open.c

@ -1,19 +1,10 @@
#include <kernel/fs/vfs.h>
#include <kernel/process.h>
#include <kernel/util/debug.h>
int sys_open(const char *pathname, int flags, ...)
{
extern struct process *process_current;
// DEBUG !
/*kvram_clear();
printk(0, 0, "Syscall open() !");
printk(0, 1, "path: %s", pathname);
printk(0, 2, "flags: %#x", flags);
kvram_display();
DBG_WAIT;*/
// Get current process
if (process_current == NULL)