Update kernel/util organisation + add scheduler !!
This commit is contained in:
parent
53a1ebf5a3
commit
6576cf1e5d
|
@ -1,10 +0,0 @@
|
|||
#ifndef __KERNEL_DBR_H__
|
||||
# define __KERNEL_DBR_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern void *dbr_set(void *dbr_new);
|
||||
extern void *dbr_get(void);
|
||||
|
||||
#endif /*__KERNEL_DBR_H__*/
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/font.h>
|
||||
#include <kernel/util/types.h>
|
||||
#include <kernel/util/draw.h>
|
||||
|
||||
// Define screen informations.
|
||||
#define DISPLAY_SCREEN_WIDTH (128)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
#define KEYCODE_GEN(row, column) \
|
||||
(((row & 0x0f) << 4) | ((column & 0x0f) << 0))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/devices/device.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
// Define default buffer size.
|
||||
// TODO: remove me ?
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef __KERNEL_EXTRA_H__
|
||||
# define __KERNEL_EXTRA_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// SH4-instruction
|
||||
extern void icbi(void *area);
|
||||
|
||||
#endif /*__KERNEL_EXTRA_H__*/
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
#include <kernel/fs/filesystem.h>
|
||||
|
||||
#ifndef FILE_OPEN_NUMBER
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
// FS flags
|
||||
#define FS_RDWR (0x01)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
# define GLADFS_INODE_NAME_LENGHT (16)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
#include <kernel/fs/file.h>
|
||||
|
||||
#define CASIO_SMEM_NAME_LENGHT 12
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
#include <kernel/fs/filesystem.h>
|
||||
#include <kernel/fs/file.h>
|
||||
#include <kernel/devices/device.h>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include <kernel/fs/file.h>
|
||||
#include <kernel/process.h>
|
||||
#include <kernel/elf.h>
|
||||
#include <kernel/util/elf.h>
|
||||
|
||||
// Function
|
||||
extern void *loader(const char *path, struct process *process);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <kernel/fs/file.h>
|
||||
#include <kernel/fs/filesystem.h>
|
||||
#include <kernel/context.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
#define PROCESS_NB_OPEN_FILE (4)
|
||||
#define PROCESS_USER_STACK_SIZE (2 * 1024)
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#ifndef __CASIO_H__
|
||||
# define __CASIO_H__
|
||||
#ifndef __SYSCALL_H__
|
||||
# define __SYSCALL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
//---
|
||||
//
|
||||
// Vhex part !!
|
||||
//
|
||||
//---
|
||||
// Process
|
||||
extern pid_t sys_fork(void);
|
||||
extern pid_t sys_getpid(void);
|
||||
extern pid_t sys_getppid(void);
|
||||
|
@ -17,74 +18,11 @@ extern pid_t sys_waitpid(pid_t pid, int *wstatus, int options);
|
|||
extern pid_t sys_fexecve(const char *pathname);
|
||||
extern void sys_exit(int status);
|
||||
|
||||
// File
|
||||
extern int sys_open(const char *pathname, int flags, ...);
|
||||
extern ssize_t sys_write(int fd, const void *buf, size_t count);
|
||||
extern ssize_t sys_read(int fd, void *buf, size_t count);
|
||||
extern off_t sys_lseek(int fd, off_t offset, int whence);
|
||||
extern int sys_close(int fd);
|
||||
|
||||
//---
|
||||
//
|
||||
// CASIO PART !!
|
||||
// TODO: remove me ?
|
||||
//
|
||||
//----
|
||||
|
||||
|
||||
// Internal Casio datat structure
|
||||
struct rect
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
};
|
||||
|
||||
//
|
||||
// Casio prototypes.
|
||||
//
|
||||
/* GetKey() - display Casio's VRAM and wait keyboard input. */
|
||||
void casio_GetKey(unsigned int *key);
|
||||
void casio_GetKeyWait(int *row, int *column, int type_waiting, int timeout, int menu, unsigned int *key);
|
||||
|
||||
/* Bdisp_PutDisp_DD - display Casio's VRAM on screen */
|
||||
void casio_Bdisp_PutDisp_DD(void);
|
||||
|
||||
/* Bdisp_AllClr_VRAM() - clear entirely the Casio's VRAM */
|
||||
void casio_Bdisp_AllClr_VRAM(void);
|
||||
|
||||
/* Bdisp_AreaClr_VRAM() - clear only VRAM area. */
|
||||
void casio_Bdisp_AreaClr_VRAM(const struct rect *buf);
|
||||
|
||||
/* PrintMini() - print string in Casio's VRAM (and display on screen ?) */
|
||||
void casio_Bdisp_PrintMini(size_t x, size_t y, char const *str, int mode);
|
||||
|
||||
/* Bdisp_DrawLine_VRAM() - draw line in Casio's VRAM. */
|
||||
void casio_Bdisp_DrawLine_VRAM(int x1, int y1, int x2, int y2);
|
||||
|
||||
/* RestoreDisp() - restore saved screen. */
|
||||
void casio_RestoreDisp(unsigned char page);
|
||||
|
||||
/* SaveDisp() - save the content of the screen. */
|
||||
void casio_SaveDisp(unsigned char page);
|
||||
|
||||
/* Malloc() - malloc syscall */
|
||||
void *casio_Malloc(size_t size);
|
||||
|
||||
/* Free() - free syscall */
|
||||
void *casio_Free(void *ptr);
|
||||
|
||||
/* GetVRAM - Get the Video RAM used by Casio */
|
||||
void *casio_Bdisp_GetVRAM(void);
|
||||
|
||||
/* Bkey_PutKeyCode - Inject keycode to key buffer */
|
||||
void casio_Bkey_PutKeymatrix(uint16_t *code);
|
||||
|
||||
// Internal casio abstraction.
|
||||
static inline void dclear_area(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
struct rect area = {.left = x1, .top = y1, .right = x2, .bottom = y2};
|
||||
casio_Bdisp_AreaClr_VRAM(&area);
|
||||
}
|
||||
|
||||
#endif /*__CASIO_H__*/
|
||||
#endif /*__SYSCALL_H__*/
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
#ifndef __KERNEL_UTIL_H__
|
||||
# define __KERNEL_UTIL_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// String function
|
||||
extern void *memset(void *s, int c, size_t n);
|
||||
extern void *memcpy(void *dest, const void *src, size_t count);
|
||||
extern char *strncpy(char *dest, char const *str, size_t size);
|
||||
extern size_t strnlen(char const *str, size_t maxlen);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern int strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern char *strrchr(const char *s1, int c);
|
||||
extern size_t strlen(char const *str);
|
||||
|
||||
// Video RAM functions
|
||||
extern void kvram_clear(void);
|
||||
extern void kvram_display(void);
|
||||
extern void kvram_scroll(int lines);
|
||||
extern void kvram_ascii(int x, int y, char const c);
|
||||
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);
|
||||
|
||||
// Kernel printf-wrapper
|
||||
extern void printk(int x, int y, char const *str, ...);
|
||||
|
||||
// Hardware specific function (do not use !)
|
||||
extern void t6k11_lcd_driver(void *vram);
|
||||
extern void t6k11_variant_lcd_driver(uint8_t *vram);
|
||||
|
||||
//---
|
||||
// Timer functions.
|
||||
//---
|
||||
#define TIMER_NUMBER 3
|
||||
#define TIMER_UNUSED 0xff
|
||||
|
||||
struct timer_cache_s
|
||||
{
|
||||
void *callback;
|
||||
volatile void *arg;
|
||||
uint8_t status;
|
||||
};
|
||||
extern int timer_uninstall(int timer_ID);
|
||||
extern int timer_install(void *callback, void *arg, uint32_t ticks, uint8_t mode);
|
||||
extern int timer_start(int timer_ID);
|
||||
|
||||
// Debug wait
|
||||
#define DBG_WAIT for(int i = 0 ; i < 3000000 ; i++)
|
||||
|
||||
#endif /*__KERNEL_UTIL_H__*/
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef __KERNEL_UTIL_CASIO_H__
|
||||
# define __KERNEL_UTIL_CASIO_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Internal Casio datat structure
|
||||
struct rect
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
};
|
||||
|
||||
//
|
||||
// Casio prototypes.
|
||||
//
|
||||
/* GetKey() - display Casio's VRAM and wait keyboard input. */
|
||||
void casio_GetKey(unsigned int *key);
|
||||
void casio_GetKeyWait(int *row, int *column, int type_waiting, int timeout, int menu, unsigned int *key);
|
||||
|
||||
/* Bdisp_PutDisp_DD - display Casio's VRAM on screen */
|
||||
void casio_Bdisp_PutDisp_DD(void);
|
||||
|
||||
/* Bdisp_AllClr_VRAM() - clear entirely the Casio's VRAM */
|
||||
void casio_Bdisp_AllClr_VRAM(void);
|
||||
|
||||
/* Bdisp_AreaClr_VRAM() - clear only VRAM area. */
|
||||
void casio_Bdisp_AreaClr_VRAM(const struct rect *buf);
|
||||
|
||||
/* PrintMini() - print string in Casio's VRAM (and display on screen ?) */
|
||||
void casio_Bdisp_PrintMini(size_t x, size_t y, char const *str, int mode);
|
||||
|
||||
/* Bdisp_DrawLine_VRAM() - draw line in Casio's VRAM. */
|
||||
void casio_Bdisp_DrawLine_VRAM(int x1, int y1, int x2, int y2);
|
||||
|
||||
/* RestoreDisp() - restore saved screen. */
|
||||
void casio_RestoreDisp(unsigned char page);
|
||||
|
||||
/* SaveDisp() - save the content of the screen. */
|
||||
void casio_SaveDisp(unsigned char page);
|
||||
|
||||
/* Malloc() - malloc syscall */
|
||||
void *casio_Malloc(size_t size);
|
||||
|
||||
/* Free() - free syscall */
|
||||
void *casio_Free(void *ptr);
|
||||
|
||||
/* GetVRAM - Get the Video RAM used by Casio */
|
||||
void *casio_Bdisp_GetVRAM(void);
|
||||
|
||||
/* Bkey_PutKeyCode - Inject keycode to key buffer */
|
||||
void casio_Bkey_PutKeymatrix(uint16_t *code);
|
||||
|
||||
// Internal casio abstraction.
|
||||
static inline void dclear_area(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
struct rect area = {.left = x1, .top = y1, .right = x2, .bottom = y2};
|
||||
casio_Bdisp_AreaClr_VRAM(&area);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /*__KERNEL_UTIL_CASIO_H__*/
|
|
@ -0,0 +1,14 @@
|
|||
#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__*/
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __KERNEL_FONT_H__
|
||||
# define __KERNEL_FONT_H__
|
||||
#ifndef __KERNEL_UTIL_DRAW_H__
|
||||
# define __KERNEL_UTIL_DRAW_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -28,7 +28,14 @@ struct font_block_s
|
|||
int16_t y;
|
||||
};
|
||||
|
||||
// Font function.
|
||||
extern void font_draw(int x, int y, char n);
|
||||
|
||||
#endif /*__KERNEL_FONT_H__*/
|
||||
|
||||
// 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_ascii(int x, int y, char const c);
|
||||
|
||||
#endif /*__KERNEL_UTIL_DRAW_H__*/
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef __KERNEL_UTIL_EXTRA_H__
|
||||
# define __KERNEL_UTIL_EXTRA_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// DeBug Register abstract
|
||||
extern void *dbr_set(void *dbr_new);
|
||||
extern void *dbr_get(void);
|
||||
|
||||
// SH4-instruction
|
||||
extern void icbi(void *area);
|
||||
|
||||
// Vector Based Register abstract.
|
||||
extern void *vbr_set(void *vbr_new);
|
||||
extern void *vbr_get(void);
|
||||
|
||||
#endif /*__KERNEL_UTIL_EXTRA_H__*/
|
|
@ -0,0 +1,31 @@
|
|||
#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__*/
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef __KERNEL_UTIL_TIMER_H__
|
||||
# define __KERNEL_UTIL_TIMER_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Define internal timer informations
|
||||
#define TIMER_NUMBER 3
|
||||
#define TIMER_UNUSED 0xff
|
||||
|
||||
// Structure used by the timer abstraction
|
||||
struct timer_cache_s
|
||||
{
|
||||
void *callback;
|
||||
volatile void *arg;
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
// Internal enum used to setup the timer
|
||||
typedef enum {
|
||||
TIMER_START,
|
||||
TIMER_STOP
|
||||
} tmode_t;
|
||||
|
||||
// Prototypes
|
||||
extern int timer_uninstall(int timer_ID);
|
||||
extern int timer_install(void *callback, void *arg, uint32_t ticks, tmode_t mode);
|
||||
extern int timer_start(int timer_ID);
|
||||
extern int timer_stop(int timer_ID);
|
||||
|
||||
#endif /*__KERNEL_UTIL_TIMER_H__*/
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef __KERNEL_VBR_H__
|
||||
# define __KERNEL_VBR_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Vbr helper.
|
||||
extern void *vbr_set(void *vbr_new);
|
||||
extern void *vbr_get(void);
|
||||
|
||||
#endif /*__KERNEL_VBR_H__*/
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
/* check_sh3 - Detecting sh3-based MPU */
|
||||
static mpu_t check_sh3(uint16_t tplcr)
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <kernel/types.h>
|
||||
#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>
|
||||
#include <kernel/context.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/process.h>
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/scheduler.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/util.h>
|
||||
|
||||
//TODO: remove me !
|
||||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/loader.h>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <kernel/hardware/intc.h>
|
||||
#include <kernel/hardware/power.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/vbr.h>
|
||||
#include <kernel/util/extra.h>
|
||||
|
||||
void vhex_context_set(void)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <kernel/hardware/intc.h>
|
||||
#include <kernel/hardware/power.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/vbr.h>
|
||||
#include <kernel/util/extra.h>
|
||||
|
||||
void fx9860_context_restore(fx9860_context_t *context)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <kernel/hardware/power.h>
|
||||
#include <kernel/hardware/intc.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/vbr.h>
|
||||
#include <kernel/util/extra.h>
|
||||
|
||||
void fx9860_context_save(fx9860_context_t *context)
|
||||
{
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#include <kernel/devices/display.h>
|
||||
|
||||
int display_close(void)
|
||||
{
|
||||
// Do nothing for now.
|
||||
return (0);
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void display_ioctl(uint32_t cmd, ...)
|
||||
{
|
||||
extern int dcurx;
|
||||
extern int dcury;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, cmd);
|
||||
switch (cmd)
|
||||
{
|
||||
case DISPLAY_IOCTL_GETX:
|
||||
{
|
||||
int *ret = va_arg(ap, int *);
|
||||
*ret = dcurx;
|
||||
break;
|
||||
}
|
||||
case DISPLAY_IOCTL_GETY:
|
||||
{
|
||||
int *ret = va_arg(ap, int *);
|
||||
*ret = dcury;
|
||||
break;
|
||||
}
|
||||
case DISPLAY_IOCTL_SETX:
|
||||
{
|
||||
dcurx = va_arg(ap, int);
|
||||
break;
|
||||
}
|
||||
case DISPLAY_IOCTL_SETY:
|
||||
{
|
||||
dcury = va_arg(ap, int);
|
||||
break;
|
||||
}
|
||||
case DISPLAY_IOCTL_CLEAR:
|
||||
{
|
||||
kvram_clear();
|
||||
break;
|
||||
}
|
||||
case DISPLAY_IOCTL_DISPLAY:
|
||||
{
|
||||
kvram_display();
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#include <kernel/devices/display.h>
|
||||
#include <kernel/syscall.h>
|
||||
|
||||
// Create VRAM global.
|
||||
uint32_t vram[256];
|
||||
|
||||
int display_open(void)
|
||||
{
|
||||
//TODO: handle gxcg50 !!!
|
||||
return (0);
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
#include <kernel/devices/display.h>
|
||||
#include <kernel/hardware/t6k11.h>
|
||||
#include <kernel/atomic.h>
|
||||
|
||||
// Internal display cursor.
|
||||
int dcurx = 0;
|
||||
int dcury = 0;
|
||||
|
||||
static void display_clear(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 256;
|
||||
while (--i >= 0)
|
||||
vram[i] = 0x00000000;
|
||||
}
|
||||
|
||||
static void display_ascii(int column, int row, char c)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
// Get real X / Y positions.
|
||||
y = row * (KERNEL_FONT_REAL_HEIGHT + 1);
|
||||
x = column * (KERNEL_FONT_REAL_WIDTH + 1);
|
||||
|
||||
// Draw ASCII character.
|
||||
font_draw(x, y, c);
|
||||
}
|
||||
|
||||
ssize_t display_write(const void *buffer, size_t count)
|
||||
{
|
||||
ssize_t i;
|
||||
int x;
|
||||
int y;
|
||||
// Start atomic operation
|
||||
atomic_start();
|
||||
|
||||
// Write ASCII charactere.
|
||||
y = 0;
|
||||
x = 0;
|
||||
i = -1;
|
||||
while (++i < (ssize_t)count)
|
||||
{
|
||||
// Draw ASCII character.
|
||||
display_ascii(x + dcurx, y + dcury, ((uint8_t*)buffer)[i]);
|
||||
|
||||
// Update draw position.
|
||||
x = x + 1;
|
||||
if (x + dcurx >= DISPLAY_SCREEN_WIDTH)
|
||||
{
|
||||
x = 0;
|
||||
y = y + 1;
|
||||
if (y + dcury >= DISPLAY_SCREEN_HEIGHT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Hardware-specifique screen driver.
|
||||
// TODO: Handle OS 3.00 !
|
||||
//t6k11_display(vram);
|
||||
|
||||
// End atomic operation.
|
||||
atomic_stop();
|
||||
|
||||
// Return the number of written char.
|
||||
return (i);
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/devices/keyboard.h>
|
||||
#include <kernel/context.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/string.h>
|
||||
#include <kernel/util/timer.h>
|
||||
#include <kernel/util/casio.h>
|
||||
|
||||
// Intenral functions
|
||||
static void wait_keyboard_event(void);
|
||||
|
@ -117,7 +120,6 @@ static int check_special(struct keyboard_obj_s *keyboard, key_t key)
|
|||
{
|
||||
extern fx9860_context_t casio_context;
|
||||
extern fx9860_context_t vhex_context;
|
||||
unsigned int tmp;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Internal TTY object.
|
||||
extern struct tty_s tty;
|
||||
|
@ -107,7 +108,6 @@ static void tty_display(void)
|
|||
{
|
||||
int saved_start;
|
||||
int line_len;
|
||||
int row_last;
|
||||
int scolumn;
|
||||
int srow;
|
||||
int line;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/devices/keyboard.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Internal TTY object.
|
||||
struct tty_s tty;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#include <kernel/devices/ubc.h>
|
||||
#include <kernel/hardware/power.h>
|
||||
|
||||
int ubc_close(void)
|
||||
{
|
||||
//FIXME: check MPU before call this function !!!
|
||||
//FIXME: Disable all chennel before power OFF ?
|
||||
SH7305_POWER.MSTPCR0.UBC = 1;
|
||||
return (1);
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
#include <kernel/devices/ubc.h>
|
||||
#include <kernel/hardware/ubc.h>
|
||||
#include <kernel/hardware/power.h>
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/extra.h>
|
||||
#include <kernel/dbr.h>
|
||||
|
||||
// Internal data used by UBC device.
|
||||
void *casio_dbr;
|
||||
|
||||
// Internal function.
|
||||
extern void ubc_handler_pre(void);
|
||||
|
||||
int ubc_open(void)
|
||||
{
|
||||
//FIXME: check MPU before call this function !!!
|
||||
// Power ON the User Break Controller.
|
||||
SH7305_POWER.MSTPCR0.UBC = 0;
|
||||
|
||||
// Set Debug Based Register address.
|
||||
casio_dbr = dbr_set(&ubc_handler_pre);
|
||||
|
||||
// Setup Channel 0.
|
||||
SH7305_UBC.CRR0.PCB = 1; // Set PC break adter instruction break.
|
||||
SH7305_UBC.CRR0.BIE = 1; // Request a Break.
|
||||
|
||||
SH7305_UBC.CBR0.MFE = 0; // Enable Match Flag.
|
||||
SH7305_UBC.CBR0.MFI = 0b000000; // Set UBC.CCMFR.MF0 = 1, when break occur.
|
||||
SH7305_UBC.CBR0.AIE = 0; // Disable ASID check.
|
||||
SH7305_UBC.CBR0.SZ = 0b010; // Disable Match condition.
|
||||
SH7305_UBC.CBR0.CD = 0; // Use Operand Bus for Operand Access.
|
||||
SH7305_UBC.CBR0.ID = 0b01; // Selecte instruction Fetch cycle.
|
||||
SH7305_UBC.CBR0.RW = 0b11; // Use Read or Write for match condition.
|
||||
SH7305_UBC.CBR0.CE = 0; // Disable Channel 0.
|
||||
|
||||
// Set up target address.
|
||||
SH7305_UBC.CAR0 = 0x00000000; // Tested programe address !
|
||||
SH7305_UBC.CAMR0 = 0x00000000; // Address Mask.
|
||||
|
||||
// Setup Control register.
|
||||
SH7305_UBC.CBCR.UBDE = 1; // Use DBR instead of VBR.
|
||||
|
||||
|
||||
//@note:
|
||||
// You *SHOULD* use `icbi` SH4 instruction
|
||||
// After channel enable, otherwise the calculator
|
||||
// will freeze.
|
||||
SH7305_UBC.CBR0.CE = 1; // Enable Channel 0 !
|
||||
icbi((void*)0xa0000000);
|
||||
return (0);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Internal helper
|
||||
extern struct gladfs_fragment_data_s **gladfs_file_pos(off_t *offset, struct gladfs_inode_s *inode, off_t pos);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Internal helper
|
||||
extern struct gladfs_fragment_data_s **gladfs_file_pos(off_t *offset, struct gladfs_inode_s *inode, off_t pos);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
/* gladfs_mount() - GladFS mount primitive (sync) */
|
||||
void *gladfs_mount(void)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* gladfs_creat() - Create new "empty" inode (atomically, sync) */
|
||||
void *gladfs_creat(void *parent_inode, const char *file_name, mode_t mode)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
/* gladfs_get_name() - Dump the name of a file (sync) */
|
||||
int gladfs_get_name(void *inode, char *name, size_t count)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* gladfs_mkdir() - Create new folder inode (atomically, sync) */
|
||||
void *gladfs_mkdir(void *parent_inode, const char *file_name, mode_t mode)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* gladfs_alloc_fragdata() - Superblock primitive to alloc "empty" fragment data block (sync) */
|
||||
int gladfs_alloc_fragdata(struct gladfs_fragment_data_s **parent, int nb_block)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* gladfs_destroy_fragdata() - Free'd allocated fragmented data (sync) */
|
||||
/* @note: *WARNING* no verification will be done, so do not use this primitive */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/gladfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* gladfs_destroy_inode() - Free'd allocated inode (sync) */
|
||||
/* @note: *WARNING* no verification will be done, so do not use this primitive */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/fs/file.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* casio_smem_mount() - Mount the file system (sync) */
|
||||
void *smemfs_mount(void)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/fs/filesystem.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
// Kernel FS block
|
||||
struct file_system_type smemfs_filesystem =
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* smemfs_find_first_child() - Find the fist file in the (folder) inode (sync) */
|
||||
void *smemfs_find_first_child(void *inode)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* smemfs_find_next_sibling() - Find the next file from the same parent (sync) */
|
||||
void *smemfs_find_next_sibling(void *inode)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* smemfs_find_parent() - Return the parent inode */
|
||||
void *smemfs_find_parent(void *inode)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* smemfs_get_mode() - Return the permission dans the type of a file (sync) */
|
||||
mode_t smemfs_get_mode(void *inode)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/fs/smemfs.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* smemfs_get_name() - Dump the name of a file (sync) */
|
||||
int smemfs_get_name(void *inode, char *buf, size_t count)
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/process.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
int sys_open(const char *pathname, int flags, ...)
|
||||
{
|
||||
extern struct process *process_current;
|
||||
|
||||
// DEBUG !
|
||||
kvram_clear();
|
||||
/*kvram_clear();
|
||||
printk(0, 0, "Syscall open() !");
|
||||
printk(0, 1, "path: %s", pathname);
|
||||
printk(0, 2, "flags: %#x", flags);
|
||||
kvram_display();
|
||||
DBG_WAIT;
|
||||
DBG_WAIT;*/
|
||||
|
||||
// Get current process
|
||||
if (process_current == NULL)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
/* vfs_dentry_alloc() - Allocate new "empty" dentry */
|
||||
struct dentry *vfs_dentry_alloc(const char *name, mode_t mode)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
|
||||
//
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
|
||||
struct dentry *vfs_dentry_find_next_sibling(struct dentry *dentry)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/process.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
static int get_name(int *name_lenght, const char *path, char *name)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
/* vfs_open() - Open file named pathname */
|
||||
int vfs_open(FILE *file, char const *pathname, int flags)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
ssize_t vfs_read(FILE *file, void *buf, size_t count)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/util.h>
|
||||
|
||||
ssize_t vfs_write(FILE *file, const void *buf, size_t count)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
/* vfs_mkdir() - Attempts to create a directory named pathname */
|
||||
int vfs_mkdir(const char *pathname, mode_t mode)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
/* gevice_get() - Find internal device */
|
||||
struct device *device_get(dev_t major)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/string.h>
|
||||
#include <kernel/fs/stat.h>
|
||||
|
||||
// Internal informations
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/util.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
// Internal symbols
|
||||
static volatile uint8_t *sel = (void *)0xb4000000;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/timer.h>
|
||||
|
||||
void timer_handler(void)
|
||||
{
|
||||
extern struct timer_cache_s timercache[TIMER_NUMBER];
|
||||
static uint32_t counter = 0;
|
||||
//static uint32_t counter = 0;
|
||||
uint32_t intevt;
|
||||
int timer_ID;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <kernel/devices/display.h>
|
||||
#include <kernel/hardware/ubc.h>
|
||||
#include <kernel/syscall.h>
|
||||
#include <kernel/extra.h>
|
||||
#include <kernel/util/extra.h>
|
||||
|
||||
|
||||
// Internal function.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
void exception_handler(void)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ kernel_stack_switch_end:
|
|||
bt trapa_entry ! ...if yes, jump at <trapa_entry>
|
||||
|
||||
! Call high-level abstraction
|
||||
mov.l .exception_handler, r0 ! get high-level aception abstraction
|
||||
mov.l .exception_handler, r0 ! get high-level exception abstraction
|
||||
jsr @r0 ! call abstraction
|
||||
nop ! (db) nop
|
||||
bra exception_handler_exit ! jump at <exception_handler_exit>
|
||||
|
@ -45,7 +45,7 @@ kernel_stack_switch_end:
|
|||
|
||||
trapa_entry:
|
||||
! Check current process
|
||||
tst r2, r2 ! if current process == NULL...
|
||||
tst r8, r8 ! if current process == NULL...
|
||||
bt exception_handler_exit ! ...if yes, jump at <exception_handler_exit>
|
||||
|
||||
! Call syscall pre handler
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
// Handler prototype.
|
||||
extern void keysc_handler(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
__attribute__((section(".vhex.tlb"), interrupt_handler))
|
||||
void tlb_handler(void)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <kernel/loader.h>
|
||||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/fs/file.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/elf.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/elf.h>
|
||||
|
||||
void *loader(const char *path, struct process *process)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include <kernel/loader.h>
|
||||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/elf.h>
|
||||
|
||||
/* loader_get_header() - get ELF header and check validity */
|
||||
int loader_get_header(FILE *file, Elf32_Ehdr *header)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include <kernel/loader.h>
|
||||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/elf.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
/* loader_load_image() - Load the program into Virtual Memory */
|
||||
void *loader_load_image(FILE *file, Elf32_Ehdr *header, struct process *process)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
void pm_free(void *ptr)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/scheduler.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
static struct sched_task *sched_alloc(void)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/context.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
// Test
|
||||
uint32_t counter = 0;
|
||||
|
|
|
@ -66,10 +66,6 @@ get_contexts:
|
|||
mov r15, r8 ! save first context pointer
|
||||
add #-4, r15 ! create second context pointer
|
||||
mov r15, r9 ! save second context pointer
|
||||
add #-4, r15 ! create context pointer
|
||||
mov.l r15, @r8 ! save context pointer
|
||||
add #-4, r15 ! create context pointer
|
||||
mov.l r15, @r9 ! save context pointer
|
||||
|
||||
! call high level abstraction
|
||||
mov r8, r4 ! send current contexts pointer
|
||||
|
@ -81,7 +77,7 @@ get_contexts:
|
|||
! Restore stack and register (epilogue)
|
||||
mov.l @r8, r4 ! save current context
|
||||
mov.l @r9, r5 ! save next context
|
||||
add #16, r15 ! restore stack
|
||||
add #8, r15 ! restore stack
|
||||
lds.l @r15+, pr ! restore pr register
|
||||
mov.l @r15+, r8 ! restore r8 register
|
||||
mov.l @r15+, r9 ! restore r9 register
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <kernel/process.h>
|
||||
#include <kernel/unistd_32.h>
|
||||
#include <kernel/util/unistd_32.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
struct process *process_create(const char *name)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include <kernel/scheduler.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
|
||||
//TODO: assembly !
|
||||
// @note: This part *SHOULD* be exeption safe !
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <kernel/scheduler.h>
|
||||
#include <kernel/hardware/cpg.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/timer.h>
|
||||
|
||||
// Internal data used by the scheduler handler
|
||||
uint32_t sched_timer_id = 0;
|
||||
|
@ -92,7 +93,7 @@ void sched_start(void)
|
|||
// Setup TMU0 (scheduler) interrupt !
|
||||
// @note: I use Po/4 on TMU prescaler
|
||||
// TODO: generate quantum and quantum counter for preemption !
|
||||
uint32_t ticks = (per_freq / 4) / 16;
|
||||
uint32_t ticks = (per_freq / 4) / 32;
|
||||
sched_timer_id = timer_install(NULL, NULL, ticks, 0);
|
||||
sched_timer_address = (uint32_t)&SH7305_TMU.TIMER[sched_timer_id].TCR;
|
||||
sched_timer_intevt = 0x400 + (0x20 * sched_timer_id);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/scheduler.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
void sys_exit(int status)
|
||||
{
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#include <kernel/process.h>
|
||||
#include <kernel/scheduler.h>
|
||||
#include <kernel/loader.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
pid_t sys_fexecve(const char *pathname)
|
||||
{
|
||||
struct process *proc;
|
||||
pid_t child_pid;
|
||||
FILE *bin;
|
||||
int error;
|
||||
|
||||
// Start atomic operation
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <kernel/syscall.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
|
||||
static void sys_test(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ void *sys_get_handler(int sysno)
|
|||
{
|
||||
// Check sysno validity
|
||||
if (sysno < 0 || sysno >= 16)
|
||||
return (0);
|
||||
return (NULL);
|
||||
|
||||
// DEBUG
|
||||
/*kvram_clear();
|
||||
|
|
|
@ -24,6 +24,12 @@ _syscall_pre:
|
|||
bt.s syscall_pre_exit ! ...if yes, jump at <syscall_pre_exit>
|
||||
mov r0, r9 ! save kernel handler into unbankable register
|
||||
|
||||
! We should restore the user stack
|
||||
mov.l .process_current, r10 ! get current_process adress
|
||||
mov.l @r10, r10 ! get current process
|
||||
mov.l r15, @r10 ! save current kernel stack
|
||||
mov.l @(4, r10), r15 ! restore user stack
|
||||
|
||||
! Get and save SR register
|
||||
stc sr, r0 ! get SR register
|
||||
mov r0, r8 ! save SR register
|
||||
|
@ -36,22 +42,17 @@ _syscall_pre:
|
|||
and r1, r0 ! set SR.BL = 0, SR.RB = 0 and SR.IMASK = 0b0000
|
||||
ldc r0, sr ! update SR regsiter
|
||||
|
||||
! We should restore the user stack
|
||||
mov.l .process_current, r10 ! get current_process adress
|
||||
mov.l @r10, r10 ! get current process
|
||||
mov.l r15, @r10 ! save current kernel stack
|
||||
mov.l @(4, r10), r15 ! restore user stack
|
||||
|
||||
! Call kernel abstraction
|
||||
jsr @r9 ! call system handler
|
||||
nop ! (db) nop.
|
||||
|
||||
! Restore SR regsiter
|
||||
ldc r8, sr ! SR.BL = 1, SR.RB = 1 and SR.IMASK = old mask.
|
||||
|
||||
! Switch stack
|
||||
mov.l r15, @(4, r10) ! save user stack
|
||||
mov.l @r10, r15 ! restore kernel stack
|
||||
|
||||
! Restore SR regsiter
|
||||
ldc r8, sr ! SR.BL = 1, SR.RB = 1 and SR.IMASK = old mask.
|
||||
|
||||
syscall_pre_exit:
|
||||
! Restore used regsiter.
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
.global _dtest
|
||||
|
||||
.align 2
|
||||
_dtest:
|
||||
trapa #0
|
||||
rts
|
||||
nop
|
|
@ -1,13 +1,13 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/memory.h>
|
||||
#include <kernel/util.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/draw.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Tree-wrapper
|
||||
static void vfs_test(struct dentry *node, int level)
|
||||
{
|
||||
int curr_line;
|
||||
|
||||
// Check error.
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
@ -29,7 +29,6 @@ void kernel_test(void)
|
|||
{
|
||||
extern struct dentry *vfs_root_node;
|
||||
char path[] = "/../dev/./../dev/////tty";
|
||||
void *test;
|
||||
FILE file;
|
||||
|
||||
// Debug !
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
.extern _atomic_counter
|
||||
|
||||
.align 2
|
||||
/*TODO: Fix reentrace corruption !!!*/
|
||||
/*
|
||||
** @proto: uint32_t atomic_start(void)
|
||||
** @return:
|
||||
|
@ -46,7 +45,6 @@ atomic_start_exit:
|
|||
rts ! exit.
|
||||
nop ! (db) nop.
|
||||
|
||||
/*TODO: Fix reentrace corruption !!!*/
|
||||
/*
|
||||
** @proto: uint32_t atomic_stop(void)
|
||||
** @return:
|
|
@ -1,6 +1,6 @@
|
|||
#include <kernel/font.h>
|
||||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/atomic.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
// Font bitmap.
|
||||
static const uint8_t kernel_font_bitmap[] = {
|
||||
|
@ -37,7 +37,6 @@ static const uint8_t kernel_font_bitmap[] = {
|
|||
0x92, 0xa9, 0x39, 0x93, 0x03, 0x80
|
||||
};
|
||||
|
||||
|
||||
static void font_draw_core(struct font_block_s *fblock)
|
||||
{
|
||||
extern uint32_t vram[256];
|
||||
|
@ -89,7 +88,8 @@ static void font_draw_core(struct font_block_s *fblock)
|
|||
}
|
||||
|
||||
|
||||
void font_draw(int x, int y, char c)
|
||||
/* kvram_ascii() - Draw ASCII character into Video RAM */
|
||||
void kvram_ascii(int x, int y, char const c)
|
||||
{
|
||||
struct font_block_s fblock;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
// Internal Video RAM
|
||||
uint32_t vram[256];
|
||||
|
||||
/* kvram_clear() - Wipe the Video RAM */
|
||||
void kvram_clear(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// The Video RAM is shared between each
|
||||
// process and the kernel, so we should
|
||||
// use atomic operation when we use it.
|
||||
atomic_start();
|
||||
|
||||
// Wipe Video RAM
|
||||
// @note: here, we suppose that the VRAM is
|
||||
// 4-aligned
|
||||
i = 256;
|
||||
while (--i >= 0)
|
||||
vram[i] = 0x00000000;
|
||||
|
||||
// End of atomic operation
|
||||
atomic_stop();
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
//#include <kernel/util/draw.h>
|
||||
//#include <kernel/devices/display.h>
|
||||
//#include <kernel/atomic.h>
|
||||
|
||||
/* kvram_clr_str_area() - Clear area based on kernel font size on Video RAM */
|
||||
//FIXME: secure (DO NOT USE IT !!!!!!)
|
||||
/*void kvram_clr_str_area(int x, int y, int width, int height)
|
||||
{
|
||||
uint32_t vram_offset_y;
|
||||
int cur_x;
|
||||
int cur_y;
|
||||
|
||||
// Initialize part
|
||||
x = x * (KERNEL_FONT_REAL_WIDTH + 1);
|
||||
y = y * (KERNEL_FONT_REAL_HEIGHT + 1);
|
||||
width = width * (KERNEL_FONT_REAL_WIDTH + 1);
|
||||
height = height * (KERNEL_FONT_REAL_HEIGHT + 1);
|
||||
|
||||
// Get VRAM offset
|
||||
vram_offset_y = y << 2;
|
||||
|
||||
// Start atomic operations
|
||||
atomic_start();
|
||||
|
||||
// Clear area, pixel per pixel x____x
|
||||
// TODO: update me !!!!
|
||||
cur_y = -1;
|
||||
while (++cur_y < height)
|
||||
{
|
||||
cur_x = -1;
|
||||
while (++cur_x < width)
|
||||
{
|
||||
vram[((x + cur_x) >> 5) + vram_offset_y] &=
|
||||
~(0x80000000 >> ((x + cur_x) & 31));
|
||||
}
|
||||
|
||||
// update internal counter
|
||||
vram_offset_y = vram_offset_y + 4;
|
||||
}
|
||||
|
||||
// Stop atomic operations
|
||||
atomic_stop();
|
||||
}*/
|
|
@ -0,0 +1,16 @@
|
|||
#include <kernel/util/draw.h>
|
||||
|
||||
/* kvram_display() - Disaplay Video RAM into screen */
|
||||
void kvram_display(void)
|
||||
{
|
||||
extern void t6k11_variant_lcd_driver(void *vram);
|
||||
extern void t6k11_lcd_driver(void *vram);
|
||||
extern uint32_t vram[256];
|
||||
|
||||
//TODO: handle screen hadware !
|
||||
//TODO: load dynamically screen driver during the boot
|
||||
if (*(uint8_t*)0xa0010021 == '3')
|
||||
t6k11_variant_lcd_driver((void*)vram);
|
||||
else
|
||||
t6k11_lcd_driver(vram);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* kvram_reverse() - Reverse Video RAM area */
|
||||
void kvram_reverse(int x, int y, int width, int height)
|
||||
{
|
||||
extern uint32_t vram[256];
|
||||
int vram_offset_y;
|
||||
int j;
|
||||
|
||||
// Check error.
|
||||
if (width < 0 || height < 0)
|
||||
return;
|
||||
|
||||
// Get "real" X position and area width.
|
||||
if (x < 0)
|
||||
{
|
||||
width = width + x;
|
||||
x = 0;
|
||||
} else {
|
||||
if (x + width >= DISPLAY_SCREEN_WIDTH)
|
||||
width = DISPLAY_SCREEN_WIDTH - x;
|
||||
}
|
||||
|
||||
// Get "real" Y position and area height.
|
||||
if (y < 0)
|
||||
{
|
||||
height = height + x;
|
||||
y = 0;
|
||||
} else {
|
||||
if (y + height >= DISPLAY_SCREEN_HEIGHT)
|
||||
height = DISPLAY_SCREEN_HEIGHT - x;
|
||||
}
|
||||
|
||||
// Check potential error.
|
||||
// @note we do not check height because the while()
|
||||
// while do the job for us.
|
||||
if (width < 0)
|
||||
return;
|
||||
|
||||
// Generate VRAM offset for Y axis.
|
||||
// @note:
|
||||
// The screen width size is always 128 and we
|
||||
// use 4-aligned Video RAM so 32 pixels per "slot"
|
||||
// and 128 / 32 = 4.
|
||||
// y * 4 can be optimised by used shift operator,
|
||||
// this is why we use y << 2 because 2^2 = 4.
|
||||
vram_offset_y = (y + height - 1) << 2;
|
||||
|
||||
|
||||
// The Video RAM is sheared between each
|
||||
// process and the kernel, so we should
|
||||
// use atomic operation when we use it.
|
||||
atomic_start();
|
||||
|
||||
// Reverse area
|
||||
while (--height >= 0)
|
||||
{
|
||||
j = width + x;
|
||||
while (--j >= x)
|
||||
{
|
||||
vram[(j >> 5) + vram_offset_y] ^= 0x80000000 >> (j & 31);
|
||||
}
|
||||
vram_offset_y = vram_offset_y - 4;
|
||||
}
|
||||
|
||||
// End of atomic operation
|
||||
atomic_stop();
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* kvram_scroll() - Scroll up the Video RAM */
|
||||
//FIXME: This part is hardware specific (128x64px)!!
|
||||
void kvram_scroll(int lines)
|
||||
{
|
||||
extern uint32_t vram[256];
|
||||
int i;
|
||||
|
||||
// The Video RAM is shared between each
|
||||
// process and the kernel, so we should
|
||||
// use atomic operation when we use it.
|
||||
atomic_start();
|
||||
|
||||
// Scoll n lines
|
||||
i = 0;
|
||||
while ((i >> 2) < 63 - lines)
|
||||
{
|
||||
vram[i + 0] = vram[i + (lines << 2) + 0];
|
||||
vram[i + 1] = vram[i + (lines << 2) + 1];
|
||||
vram[i + 2] = vram[i + (lines << 2) + 2];
|
||||
vram[i + 3] = vram[i + (lines << 2) + 3];
|
||||
i = i + 4;
|
||||
}
|
||||
// Clear last n lines
|
||||
while ((i >> 2) < 64)
|
||||
{
|
||||
vram[i + 0] = 0x00000000;
|
||||
vram[i + 1] = 0x00000000;
|
||||
vram[i + 2] = 0x00000000;
|
||||
vram[i + 3] = 0x00000000;
|
||||
i = i + 4;
|
||||
}
|
||||
|
||||
// End of atomic operation
|
||||
atomic_stop();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue