Fix / update TTY cursor + try to fix loader reloc crash (not work)
This commit is contained in:
parent
97fb770fe1
commit
8cbf3de246
|
@ -10,7 +10,7 @@
|
|||
|
||||
#define PROCESS_NB_OPEN_FILE (4)
|
||||
#define PROCESS_USER_STACK_SIZE (2 * 1024)
|
||||
#define PROCESS_KERNEL_STACK_SIZE (512)
|
||||
#define PROCESS_KERNEL_STACK_SIZE (1024)
|
||||
#define PROCESS_NAME_LENGHT (16)
|
||||
#define PROCESS_MAX (4)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <kernel/devices/tty.h>
|
||||
#include <kernel/devices/earlyterm.h>
|
||||
#include <kernel/drivers/keyboard.h>
|
||||
#include <kernel/drivers/timer.h>
|
||||
#include <kernel/util/atomic.h>
|
||||
|
@ -289,8 +290,7 @@ static int buffer_insert(struct keyboard_obj_s *keyboard, char n)
|
|||
|
||||
static void cursor_callback(struct keyboard_obj_s *keyboard)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
// static int test = 0;
|
||||
|
||||
// Draw cursor if needed
|
||||
if (keyboard->cvisible == 0)
|
||||
|
@ -299,34 +299,46 @@ static void cursor_callback(struct keyboard_obj_s *keyboard)
|
|||
atomic_start();
|
||||
|
||||
// Geneate TTY buffer cursor position.
|
||||
x = keyboard->buffer.cursor + keyboard->saved.tty.cursor.x;
|
||||
y = x / keyboard->tty->cursor.max.x;
|
||||
int x = keyboard->buffer.cursor + keyboard->saved.tty.cursor.x;
|
||||
int 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 = keyboard->tty->cursor.x;
|
||||
int sttyy = keyboard->tty->cursor.y;
|
||||
keyboard->tty->cursor.x = x;
|
||||
keyboard->tty->cursor.y = y;
|
||||
// Check circular limit
|
||||
if (y >= keyboard->tty->cursor.max.y)
|
||||
y = y - keyboard->tty->cursor.max.y;
|
||||
|
||||
// Get window row
|
||||
int line = -1;
|
||||
while (++line < keyboard->tty->winsize.ws_row - 1)
|
||||
{
|
||||
// Update row cursor.
|
||||
if (--y < 0)
|
||||
y = keyboard->tty->cursor.max.y - 1;
|
||||
|
||||
// Check if the line existe.
|
||||
if (keyboard->tty->buffers.output[y][0] == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
//if (line != test) {
|
||||
// earlyterm_write("line = %d - %d\n", line, keyboard->tty->winsize.ws_row);
|
||||
// test = line;
|
||||
// DBG_WAIT;
|
||||
//}
|
||||
|
||||
// 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);
|
||||
|
||||
y = line * (keyboard->tty->disp.font->font.height + 1);
|
||||
|
||||
// Display cursor.
|
||||
/* dreverse(
|
||||
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();
|
||||
|
|
|
@ -104,10 +104,10 @@ static ssize_t tty_buffer_update(struct tty_s *tty, const uint8_t *buffer, size_
|
|||
// TODO: Update me ?
|
||||
static void tty_display(struct tty_s *tty)
|
||||
{
|
||||
int saved_start;
|
||||
int test_row;
|
||||
int line_len;
|
||||
int line;
|
||||
int start;
|
||||
int line;
|
||||
int y;
|
||||
|
||||
// Start atomic operation.
|
||||
|
@ -115,20 +115,18 @@ static void tty_display(struct tty_s *tty)
|
|||
|
||||
// Get the "first" line and number of line.
|
||||
// @note: circular buffer.
|
||||
line = 0;
|
||||
start = tty->cursor.y;
|
||||
line = -1;
|
||||
test_row = tty->cursor.y;
|
||||
while (++line < tty->winsize.ws_row)
|
||||
{
|
||||
// Update check line.
|
||||
saved_start = start;
|
||||
start = (start - 1 < 0) ? tty->cursor.max.y - 1 : start - 1;
|
||||
start = test_row;
|
||||
if (--test_row < 0)
|
||||
test_row = tty->cursor.max.y - 1;
|
||||
|
||||
// Check if the line existe.
|
||||
if (tty->buffers.output[start][0] == '\0')
|
||||
{
|
||||
start = saved_start;
|
||||
if (tty->buffers.output[test_row][0] == '\0')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// clear screen
|
||||
|
@ -136,7 +134,7 @@ static void tty_display(struct tty_s *tty)
|
|||
|
||||
// Display "on-screen" string lines.
|
||||
y = -1;
|
||||
while (++y < line)
|
||||
while (++y <= line)
|
||||
{
|
||||
// Display line
|
||||
line_len = -1;
|
||||
|
@ -144,7 +142,8 @@ static void tty_display(struct tty_s *tty)
|
|||
dascii(&tty->disp, line_len, y, tty->buffers.output[start][line_len]);
|
||||
|
||||
// Update row index
|
||||
start = (start + 1 < tty->cursor.max.y) ? start + 1 : 0;
|
||||
if (++start >= tty->cursor.max.y)
|
||||
start = 0;
|
||||
}
|
||||
|
||||
// Display on screen.
|
||||
|
|
|
@ -10,12 +10,14 @@ static void *casio_smem_get_data_base_address(smemfs_fragdata_t *fragment)
|
|||
extern struct smemfs_superblock_s smemfs_superblock;
|
||||
struct casio_smem_block_s *block;
|
||||
|
||||
// Find the appropriate block
|
||||
block = smemfs_superblock.sector_table;
|
||||
while (block->magic_start == CASIO_SMEM_BLOCK_ENTRY_MAGIC &&
|
||||
block->info.id != fragment->data_block_id)
|
||||
{
|
||||
block = &block[1];
|
||||
}
|
||||
// If the block ID is missing, return error
|
||||
if (block->info.id != fragment->data_block_id)
|
||||
return (NULL);
|
||||
return ((void *)(block->offset + fragment->data_offset));
|
||||
|
@ -48,7 +50,7 @@ ssize_t smemfs_read(void *inode, void *buf, size_t count, off_t pos)
|
|||
|
||||
// Get the current data fragment.
|
||||
current_size = 0;
|
||||
fragment = inode + sizeof(struct casio_smem_header_s);
|
||||
fragment = (void *)&header[1];
|
||||
while (fragment->magic == CASIO_SMEM_FRAGMENT_MAGIC &&
|
||||
fragment->info == CASIO_SMEM_FRAGMENT_INFO_EXIST &&
|
||||
(off_t)(current_size + fragment->data_size + 1) < pos)
|
||||
|
@ -63,6 +65,10 @@ ssize_t smemfs_read(void *inode, void *buf, size_t count, off_t pos)
|
|||
{
|
||||
atomic_stop();
|
||||
earlyterm_write("smemfs: fragment error !\n");
|
||||
earlyterm_write("* current_size = %d\n", current_size);
|
||||
earlyterm_write("* pos = %#x\n", pos);
|
||||
earlyterm_write("* frag magic = 0x%x\n", fragment->magic);
|
||||
earlyterm_write("* frag info = 0x%x\n", fragment->info);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -84,8 +90,7 @@ ssize_t smemfs_read(void *inode, void *buf, size_t count, off_t pos)
|
|||
break;
|
||||
|
||||
// Handle fragment data offset.
|
||||
if (fragment_data_offset != 0)
|
||||
{
|
||||
if (fragment_data_offset != 0) {
|
||||
data_base_addr = data_base_addr + fragment_data_offset;
|
||||
fragment_data_offset = 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <kernel/fs/vfs.h>
|
||||
#include <kernel/devices/earlyterm.h>
|
||||
#include <lib/string.h>
|
||||
|
||||
ssize_t vfs_read(FILE *file, void *buf, size_t count)
|
||||
|
@ -18,7 +19,7 @@ ssize_t vfs_read(FILE *file, void *buf, size_t count)
|
|||
// Read with FS specifique primitive and return the numbe of reading bytes.
|
||||
memset(buf, 0x00, count);
|
||||
ssize_t read = file->file_op->read(((struct dentry*)file->private)->inode, buf, count, file->cursor);
|
||||
if (read != -1)
|
||||
if (read > 0)
|
||||
file->cursor = file->cursor + read;
|
||||
return (read);
|
||||
}
|
||||
|
|
|
@ -9,14 +9,10 @@ static char *get_shstrtab(FILE *file, Elf32_Ehdr *header)
|
|||
char *shstrtab;
|
||||
|
||||
// Get sections string header tables
|
||||
earlyterm_write(
|
||||
"off_t = %#x\noff_t = %#x\n",
|
||||
header->e_shoff + (header->e_shstrndx * sizeof(Elf32_Shdr)),
|
||||
vfs_lseek(file, header->e_shoff + (header->e_shstrndx * sizeof(Elf32_Shdr)), SEEK_SET)
|
||||
);;
|
||||
vfs_lseek(file, header->e_shoff + (header->e_shstrndx * sizeof(Elf32_Shdr)), SEEK_SET);
|
||||
if (vfs_read(file, &shdr, sizeof(Elf32_Shdr)) != sizeof(Elf32_Shdr))
|
||||
{
|
||||
earlyterm_write("relo_sym: section header table error\n");
|
||||
earlyterm_write("relo_sym: shdr size\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -24,7 +20,7 @@ static char *get_shstrtab(FILE *file, Elf32_Ehdr *header)
|
|||
shstrtab = (char*)pm_alloc(shdr.sh_size);
|
||||
if (shstrtab == NULL)
|
||||
{
|
||||
earlyterm_write("relo_sym: mem error (%d)\n", shdr.sh_size);
|
||||
earlyterm_write("relo_sym:mem (%d)\n", shdr.sh_size);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -69,9 +65,6 @@ int loader_reloc_sym(struct process *process, FILE *file, Elf32_Ehdr *header)
|
|||
Elf32_Shdr shdr;
|
||||
char *shstrtab;
|
||||
|
||||
//TODO
|
||||
(void)process;
|
||||
|
||||
// DEBUG
|
||||
earlyterm_write("e_shoff = %d\n", header->e_shoff);
|
||||
earlyterm_write("e_shnum = %d\n", header->e_shnum);
|
||||
|
@ -109,8 +102,8 @@ int loader_reloc_sym(struct process *process, FILE *file, Elf32_Ehdr *header)
|
|||
}
|
||||
pm_free(shstrtab);
|
||||
//earlyterm_write("start = %p\n", process->memory.program.start);
|
||||
DBG_WAIT;
|
||||
DBG_WAIT;
|
||||
//DBG_WAIT;
|
||||
//DBG_WAIT;
|
||||
//DBG_WAIT;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <lib/display.h>
|
||||
/*#include <lib/display.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// Structure used to store
|
||||
|
@ -34,14 +34,14 @@ void (*actions_list[26])(struct dintern_s *intern, char spec) = {
|
|||
};
|
||||
|
||||
|
||||
/* dchar() - display only one char */
|
||||
// dchar() - display only one char //
|
||||
static void dchar(struct dintern_s *intern, char spec)
|
||||
{
|
||||
(void)spec;
|
||||
disp_char(intern, (char)va_arg(intern->ap, int));
|
||||
}
|
||||
|
||||
/* dstr() - display string */
|
||||
// dstr() - display string //
|
||||
static void dstr(struct dintern_s *intern, char spec)
|
||||
{
|
||||
char *str;
|
||||
|
@ -55,7 +55,7 @@ static void dstr(struct dintern_s *intern, char spec)
|
|||
}
|
||||
}
|
||||
|
||||
/* dint() - Display unsigned interger */
|
||||
// dint() - Display unsigned interger //
|
||||
static void duint(struct dintern_s *intern, char spec)
|
||||
{
|
||||
const char hexa[] = "0123456789abcdef";
|
||||
|
@ -81,7 +81,7 @@ static void duint(struct dintern_s *intern, char spec)
|
|||
}
|
||||
}
|
||||
|
||||
/* dptr() - Display pointer address */
|
||||
// dptr() - Display pointer address //
|
||||
static void dptr(struct dintern_s *intern, char spec)
|
||||
{
|
||||
const char hexa[] = "0123456789abcdef";
|
||||
|
@ -111,7 +111,7 @@ static void dptr(struct dintern_s *intern, char spec)
|
|||
}
|
||||
}
|
||||
|
||||
/* dint() - Display signed number (base 10) */
|
||||
// dint() - Display signed number (base 10) //
|
||||
static void dint(struct dintern_s *intern, char spec)
|
||||
{
|
||||
char buffer[32];
|
||||
|
@ -142,7 +142,7 @@ static void dint(struct dintern_s *intern, char spec)
|
|||
}
|
||||
}
|
||||
|
||||
/* line_discipline() - small line discipline */
|
||||
// line_discipline() - small line discipline //
|
||||
static int line_discipline(struct dintern_s *intern, char n)
|
||||
{
|
||||
// New line
|
||||
|
@ -164,7 +164,7 @@ static int line_discipline(struct dintern_s *intern, char n)
|
|||
|
||||
}
|
||||
|
||||
/* disp_char() - display on character and update internal data */
|
||||
// disp_char() - display on character and update internal data //
|
||||
static void disp_char(struct dintern_s *intern, char n)
|
||||
{
|
||||
dascii(intern->disp, intern->x, intern->y, n);
|
||||
|
@ -173,7 +173,7 @@ static void disp_char(struct dintern_s *intern, char n)
|
|||
intern->force = intern->force - 1;
|
||||
}
|
||||
|
||||
/* dprint() - printf wrapper */
|
||||
// dprint() - printf wrapper //
|
||||
size_t dprint(display_t *disp, int x, int y, const char *format, ...)
|
||||
{
|
||||
void (*action)(struct dintern_s *intern, char spec);
|
||||
|
@ -234,4 +234,4 @@ size_t dprint(display_t *disp, int x, int y, const char *format, ...)
|
|||
(*action)(&intern, *format);
|
||||
}
|
||||
return (intern.counter);
|
||||
}
|
||||
}*/
|
||||
|
|
Loading…
Reference in New Issue