Update project organisation (part 2)
This commit is contained in:
parent
4be64372bb
commit
2cd85c8d93
|
@ -13,9 +13,7 @@
|
|||
__attribute__((section(".device"))) \
|
||||
static struct device name##_dev
|
||||
|
||||
// Define dev_t
|
||||
typedef uint16_t dev_t;
|
||||
|
||||
// Struct used to define device
|
||||
struct device
|
||||
{
|
||||
dev_t major;
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/devices/device.h>
|
||||
#include <kernel/drivers/screen.h>
|
||||
#include <kernel/util/types.h>
|
||||
#include <kernel/util/draw.h>
|
||||
|
||||
// Define default buffer size.
|
||||
// TODO: remove me ?
|
||||
|
@ -54,6 +54,9 @@ struct keyboard_obj_s
|
|||
} cursor;
|
||||
} tty;
|
||||
} saved;
|
||||
|
||||
// FIXME Dirty place, remove / move me !
|
||||
struct tty_s *tty;
|
||||
};
|
||||
|
||||
// primitives.
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef __KERNEL_DRIVERS_SCREEN_H__
|
||||
# define __KERNEL_DRIVERS_SCREEN_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Define screen informations.
|
||||
#define DISPLAY_SCREEN_WIDTH (128)
|
||||
#define DISPLAY_SCREEN_HEIGHT (64)
|
||||
|
||||
#endif /*__KERNEL_DRIVERS_SCREEN_H__*/
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/drivers/screen.h>
|
||||
|
||||
// Define font bitmap informations.
|
||||
// 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)
|
||||
|
@ -14,12 +15,9 @@
|
|||
#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 screen informations.
|
||||
#define DISPLAY_SCREEN_WIDTH (128)
|
||||
#define DISPLAY_SCREEN_HEIGHT (64)
|
||||
|
||||
// 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))
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ typedef enum mpu_e
|
|||
} mpu_t;
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
typedef int16_t mode_t;
|
||||
typedef uint16_t dev_t;
|
||||
typedef uint16_t umode_t;
|
||||
|
||||
// Force inline function.
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/util/types.h>
|
||||
|
||||
// Define syscall LIST
|
||||
#include <kernel/unistd_32.h>
|
||||
#include <kernel/util/unistd_32.h>
|
||||
|
||||
|
||||
//TODO: move me
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/string.h>
|
||||
|
||||
// Internal TTY object.
|
||||
|
|
|
@ -23,7 +23,6 @@ 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 tty_s *tty;
|
||||
int first_key;
|
||||
int timer_fd;
|
||||
|
||||
|
@ -32,7 +31,6 @@ ssize_t tty_read(void *inode, void *buffer, size_t count)
|
|||
return (0);
|
||||
|
||||
// get tty device
|
||||
tty = inode;
|
||||
|
||||
// Initialize internal struc.
|
||||
memset(buffer, '\0', count);
|
||||
|
@ -42,14 +40,15 @@ ssize_t tty_read(void *inode, void *buffer, size_t count)
|
|||
keyboard.buffer.clen = 0;
|
||||
keyboard.mode = 0x00;
|
||||
keyboard.cvisible = 0;
|
||||
keyboard.tty = inode;
|
||||
|
||||
// save TTY informations.
|
||||
keyboard.saved.tty.cursor.x = tty->cursor.x;
|
||||
keyboard.saved.tty.cursor.y = tty->cursor.y;
|
||||
keyboard.saved.tty.cursor.x = keyboard.tty->cursor.x;
|
||||
keyboard.saved.tty.cursor.y = keyboard.tty->cursor.y;
|
||||
|
||||
// Initialize timer for cursor.
|
||||
// FIXME: find real ticks value !!
|
||||
timer_fd = timer_install(&cursor_callback, &keyboard, 500 * 500 * 2, 1);
|
||||
timer_fd = timer_install(&cursor_callback, &keyboard, 500 * 500 * 2, TIMER_START);
|
||||
if (timer_fd == -1)
|
||||
return (0);
|
||||
|
||||
|
@ -233,8 +232,8 @@ static void tty_buffer_display(struct keyboard_obj_s *keyboard)
|
|||
size_t size;
|
||||
|
||||
// Restore TTY X/Y axis positions.
|
||||
tty.cursor.x = keyboard->saved.tty.cursor.x;
|
||||
tty.cursor.y = keyboard->saved.tty.cursor.y;
|
||||
keyboard->tty->cursor.x = keyboard->saved.tty.cursor.x;
|
||||
keyboard->tty->cursor.y = keyboard->saved.tty.cursor.y;
|
||||
|
||||
// Workaround for [EXE] key.
|
||||
size =
|
||||
|
@ -325,16 +324,16 @@ static void cursor_callback(struct keyboard_obj_s *keyboard)
|
|||
{
|
||||
// Geneate TTY buffer cursor position.
|
||||
x = keyboard->buffer.cursor + keyboard->saved.tty.cursor.x;
|
||||
y = x / tty.cursor.max.x;
|
||||
x = x - (y * tty.cursor.max.x);
|
||||
y = x / keyboard->tty->cursor.max.x;
|
||||
x = x - (y * keyboard->tty->cursor.max.x);
|
||||
y = y + keyboard->saved.tty.cursor.y;
|
||||
|
||||
// Save current cursor position and
|
||||
// resotre saved position.
|
||||
int sttyx = tty.cursor.x;
|
||||
int sttyy = tty.cursor.x;
|
||||
tty.cursor.x = x;
|
||||
tty.cursor.y = y;
|
||||
int sttyx = keyboard->tty->cursor.x;
|
||||
int sttyy = keyboard->tty->cursor.x;
|
||||
keyboard->tty->cursor.x = x;
|
||||
keyboard->tty->cursor.y = y;
|
||||
|
||||
// Get Display X and Y position.
|
||||
tty_ioctl(NULL, TTY_IOCTL_GETDX, &x);
|
||||
|
@ -345,8 +344,8 @@ static void cursor_callback(struct keyboard_obj_s *keyboard)
|
|||
kvram_display();
|
||||
|
||||
// Restore TTY cursor position
|
||||
tty.cursor.x = sttyx;
|
||||
tty.cursor.y = sttyy;
|
||||
keyboard->tty->cursor.x = sttyx;
|
||||
keyboard->tty->cursor.y = sttyy;
|
||||
|
||||
}
|
||||
// Update cursor status.
|
||||
|
|
|
@ -130,6 +130,9 @@ static void tty_display(struct tty_s *tty)
|
|||
}
|
||||
}
|
||||
|
||||
// clear screen
|
||||
kvram_clear();
|
||||
|
||||
// Display "on-screen" string lines.
|
||||
y = -1;
|
||||
while (++y < line)
|
||||
|
@ -158,6 +161,9 @@ ssize_t tty_write(void *inode, const void *buffer, size_t count)
|
|||
{
|
||||
ssize_t written;
|
||||
|
||||
// Start atomic operation.
|
||||
atomic_start();
|
||||
|
||||
// Update internal buffer and display
|
||||
// TTY on the screen.
|
||||
written = tty_buffer_update(inode, buffer, count);
|
||||
|
@ -165,6 +171,9 @@ ssize_t tty_write(void *inode, const void *buffer, size_t count)
|
|||
// TODO: Monotonic display ?
|
||||
tty_display(inode);
|
||||
|
||||
// Stop atomic operation
|
||||
atomic_stop();
|
||||
|
||||
// Return the number of char written into
|
||||
// TTY's internal buffer.
|
||||
return (written);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
|
@ -15,6 +15,9 @@ struct timer_cache_s timercache[TIMER_NUMBER];
|
|||
__attribute__((constructor))
|
||||
void timer_constructor(void)
|
||||
{
|
||||
// Start atomic operations
|
||||
atomic_start();
|
||||
|
||||
// Initialise internal cache
|
||||
for (int i = 0 ; i < TIMER_NUMBER ; i = i + 1)
|
||||
{
|
||||
|
@ -23,9 +26,6 @@ void timer_constructor(void)
|
|||
timercache[i].arg = NULL;
|
||||
}
|
||||
|
||||
// Start atomic operations
|
||||
atomic_start();
|
||||
|
||||
// Configure TMU
|
||||
SH7305_TMU.TSTR.STR0 = 0; // Stop timer 0
|
||||
SH7305_TMU.TSTR.STR1 = 0; // Stop timer 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <kernel/hardware/cpg.h>
|
||||
#include <kernel/hardware/tmu.h>
|
||||
#include <kernel/util/debug.h>
|
||||
#include <kernel/util/timer.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
|
||||
// Internal data used by the scheduler handler
|
||||
uint32_t sched_timer_id = 0;
|
||||
|
|
|
@ -12,7 +12,7 @@ static void sys_test(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
|
|||
DBG_WAIT;
|
||||
}
|
||||
|
||||
static const void *sys_handler[16] = {
|
||||
static const void *sys_handler[9] = {
|
||||
// Kernel Test
|
||||
sys_test, // test
|
||||
|
||||
|
@ -29,19 +29,19 @@ static const void *sys_handler[16] = {
|
|||
sys_lseek, // lseek
|
||||
|
||||
// Display
|
||||
kvram_display, // kvram_display
|
||||
/* kvram_display, // kvram_display
|
||||
kvram_clear, // kvram_clear
|
||||
printk, // printk
|
||||
kvram_ascii, // kvram_ascii
|
||||
kvram_reverse, // kvram_reverse
|
||||
kvram_scroll, // kvram_scroll
|
||||
kvram_clr_str_area // kvram_clr_str_area
|
||||
kvram_clr_str_area // kvram_clr_str_area*/
|
||||
};
|
||||
|
||||
void *sys_get_handler(int sysno)
|
||||
{
|
||||
// Check sysno validity
|
||||
if (sysno < 0 || sysno >= 16)
|
||||
if (sysno < 0 || sysno >= 9)
|
||||
return (NULL);
|
||||
|
||||
// DEBUG
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
// Font bitmap.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
// Internal Video RAM
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#include <kernel/util/draw.h>
|
||||
|
||||
void kvram_print(int x, int y, char const *string, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
// Generate pixel positions
|
||||
x = x * (KERNEL_FONT_REAL_WIDTH + 1);
|
||||
y = y * (KERNEL_FONT_REAL_HEIGHT + 1);
|
||||
|
||||
i = -1;
|
||||
while (++i < len)
|
||||
{
|
||||
// display ASCII char
|
||||
kvram_ascii(x, y, string[i]);
|
||||
|
||||
// Update X position.
|
||||
x = x + KERNEL_FONT_REAL_WIDTH + 1;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#include <kernel/util/draw.h>
|
||||
#include <kernel/devices/display.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
||||
/* kvram_reverse() - Reverse Video RAM area */
|
||||
|
|
|
@ -11,3 +11,12 @@ int strcmp(const char *s1, const char *s2)
|
|||
}
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (s1 == NULL || s2 == NULL || n == 0)
|
||||
return (0);
|
||||
size_t i = -1;
|
||||
while (++i < n - 1 && s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i]);
|
||||
return (s1[i] - s2[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue