Adapt for A2560U, includes modification of logging so to be able to log to the COM1.

This commit is contained in:
Vincent Barrilliot 2022-06-11 22:20:44 +02:00
parent 9549b9f1b8
commit 462b05d634
9 changed files with 330 additions and 101 deletions

View file

@ -23,6 +23,7 @@
#include "rsrc/font/quadrotextFONT.h"
#if MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
#include "rsrc/bitmaps/splash_a2560u.h"
#include "dev/txt_a2560u.h"
#elif MODEL == MODEL_FOENIX_A2560K
#include "rsrc/bitmaps/splash_a2560k.h"
#endif
@ -183,7 +184,7 @@ void make_key_name(const char * original, char * buffer) {
short boot_screen() {
t_rect region;
short device = BOOT_DEFAULT;
short screen = 0;
short screen;
char buffer[256];
char entry[50];
unsigned long target_jiffies = 0;
@ -255,7 +256,11 @@ short boot_screen() {
make_key_name("SPACE", space);
make_key_name("RETURN", cr_text);
sprintf(buffer, "BOOT: %s=FLOPPY, %s=SD CARD, %s=HARD DRIVE, %s=DEFAULT, %s=SAFE", f1, f2, f3, space, cr_text);
#if MODEL == MODEL_FOENIX_A2560K
sprintf(buffer, "BOOT: %%s=SD CARD, %s=HARD DRIVE, s=FLOPPY, %s=DEFAULT, %s=SAFE", f1, f2, f3, space, cr_text);
#else
sprintf(buffer, "BOOT: %s=SD CARD, %s=HARD DRIVE, %s=DEFAULT, %s=SAFE", f1, f2, space, cr_text);
#endif
txt_set_xy(screen, (80 - strlen(buffer)) / 2, 58);
sys_chan_write(screen, buffer, strlen(buffer));
@ -285,46 +290,59 @@ short boot_screen() {
sprintf(buffer, "Booting from default device...\n");
min_jiffies = sys_time_jiffies();
target_jiffies = min_jiffies + SPLASH_WAIT_SEC * 60;
current_jiffies = sys_time_jiffies();
while (target_jiffies > current_jiffies) {
while (target_jiffies > (current_jiffies = sys_time_jiffies())) {
boot_animate_keyboard(target_jiffies, current_jiffies, min_jiffies);
short scan_code = sys_kbd_scancode();
if (scan_code != 0) {
switch (scan_code) {
case SC_F1:
device = BDEV_FDC;
strcpy(buffer, "Booting from floppy drive.\n");
break;
unsigned short scan_code = sys_kbd_scancode();
if (scan_code == 0)
continue;
case SC_F2:
device = BDEV_SDC;
strcpy(buffer, "Booting from SD card.\n");
break;
switch (scan_code) {
case SC_F1:
device = BDEV_SDC;
strcpy(buffer, "Booting from SD card.\n");
break;
case SC_F3:
device = BDEV_HDC;
strcpy(buffer, "Booting from hard drive.\n");
break;
case SC_F2:
device = BDEV_HDC;
strcpy(buffer, "Booting from hard drive.\n");
break;
case SC_RETURN:
device = BOOT_SAFE;
strcpy(buffer, "Booting directly to the command line.\n");
break;
#if MODEL == MODEL_FOENIX_A2560K
case SC_F3:
device = BDEV_FDC;
strcpy(buffer, "Booting from floppy drive.\n");
break;
#endif
default:
device = BOOT_DEFAULT;
break;
}
break;
case SC_RETURN:
device = BOOT_SAFE;
strcpy(buffer, "Booting directly to the command line.\n");
break;
default:
device = BOOT_DEFAULT;
break;
}
current_jiffies = sys_time_jiffies();
break;
}
/* Initialise all screens */
log_num(LOG_DEBUG,"boot_screen: initialize Screen", screen);
txt_init_screen(screen);
txt_set_resolution(0, 0, 0); // Set the resolution based on the DIP switch
txt_init_screen(screen); /* This is the one used for the boot message */
/* No need to txt_set_resolution(screen, 0, 0) because during screen_init, the defaults are applied */
#if MODEL == MODEL_FOENIX_A2560K
txt_set_resolution(1, 0, 0); // Set the resolution based on the DIP switch
#endif
DEBUG("boot_screen: Screen(s) initialized");
{
t_rect region;
txt_get_region(screen, &region);
}
print(screen, buffer);
#if MODEL == MODEL_FOENIX_A2560K
@ -365,12 +383,14 @@ void boot_from_bdev(short device) {
strcpy(initial_path, "/sd");
break;
#if MODEL == MODEL_FOENIX_A2560K
case 0x0002:
// Boot from Floppy
device = BDEV_FDC;
log(LOG_INFO, "Boot DIP set for FDC");
strcpy(initial_path, "/fd");
break;
#endif
default:
// Boot straight to REPL

View file

@ -55,6 +55,10 @@
#define CLI_KEY_CTX 0x8011 /* A2560K CTX Switch key */
#define CLI_KEY_HELP 0x8012 /* A2560K Menu/Help key */
// DEBUG: if I uncomment this then I get a crash
//#define sys_txt_get_region txt_get_region
//#define sys_txt_set_region txt_set_region
//
// Types
//
@ -211,7 +215,7 @@ void cli_txt_screen_set(short screen) {
* @return the number of the text device to use
*/
short cli_txt_screen_get() {
return sys_chan_device(0);
return sys_chan_device(CDEV_CONSOLE); // FIXME that seems to always return rather than e.g. TXT_SCREEN_A2560U
}
//
@ -327,7 +331,6 @@ short cmd_showint(short channel, int argc, const char * argv[]) {
// parameters = the string of parameters to be passed to the command
//
short cli_exec(short channel, char * command, int argc, const char * argv[]) {
const char * cmd_not_found = "Command not found.\n";
p_cli_command commands = (p_cli_command)g_cli_commands;
log3(LOG_INFO, "cli_exec: '", argv[0], "'");
@ -784,9 +787,14 @@ void cli_draw_window(short channel, const char * status, short is_active) {
short i = 0, j;
short dev = sys_chan_device(channel);
if (dev == ERR_BADCHANNEL) {
log_num(LOG_ERROR, "cli_draw_window on bad channel ", dev);
return;
}
// Save the current region and cursor location
sys_txt_get_xy(dev, &cursor);
DEBUG("Backup current region");
sys_txt_get_region(dev, &old_region);
sys_txt_get_color(dev, &foreground, &background);
@ -795,6 +803,7 @@ void cli_draw_window(short channel, const char * status, short is_active) {
region.origin.y = 0;
region.size.width = 0;
region.size.height = 0;
DEBUG("Get full screen dimensions");
sys_txt_set_region(dev, &region);
sys_txt_get_region(dev, &full_region);
@ -822,12 +831,14 @@ void cli_draw_window(short channel, const char * status, short is_active) {
// Restore the region and cursor location
sys_txt_set_color(dev, foreground, background);
DEBUG("Restore region and cursor location");
sys_txt_set_region(dev, &old_region);
sys_txt_set_xy(dev, cursor.x, cursor.y);
// Set cursor visibility based on if the screen is active
sys_chan_ioctrl(0, 0x06, 0, 0);
sys_chan_ioctrl(1, 0x07, 0, 0);
for (i = 0; i < cli_sys_info.screens; i++) {
sys_chan_ioctrl(i, i == channel ? CON_IOCTRL_CURS_ON : CON_IOCTRL_CURS_OFF, 0, 0);
}
}
/**
@ -837,6 +848,12 @@ void cli_setup_screen(short channel, const char * path, short is_active) {
t_rect full_region, command_region;
char message[80];
{
char buf[60];
sprintf(buf, "cli_setup_screen for channel %d", channel);
DEBUG(buf);
}
short dev = sys_chan_device(channel);
// Get the size of the screen
@ -844,12 +861,20 @@ void cli_setup_screen(short channel, const char * path, short is_active) {
full_region.origin.y = 0;
full_region.size.width = 0;
full_region.size.height = 0;
sys_txt_set_region(dev, &full_region);
sys_txt_get_region(dev, &full_region);
{
char buf[60];
sprintf(buf, "cli_setup_screen: get screen size, dev=%d, region=%p", dev, &full_region);
DEBUG(buf);
}
sys_txt_set_region(dev, &full_region);
DEBUG("1");
sys_txt_get_region(dev, &full_region);
DEBUG("2");
// Clear the screen
print(channel, "\x1b[2J\x1b[H");
DEBUG("3");
// Figure out the size of the command box and its region
command_region.origin.x = 0;
command_region.origin.y = 1;
@ -857,13 +882,13 @@ void cli_setup_screen(short channel, const char * path, short is_active) {
command_region.size.height = full_region.size.height - 1;
// Restrict the region to the command panel
DEBUG("Restrict the region to the command panel");
sys_txt_set_region(dev, &command_region);
// Draw the window
cli_draw_window(channel, path, is_active);
print(channel, "\x1b[2J\x1b[1;2H");
print(channel, "\x1b[2J\x1b[1;2H");
print_banner(channel, cli_sys_info.model);
sprintf(message, "\nFoenix/MCP v%02u.%02u.%04u\n\n", (unsigned int)cli_sys_info.mcp_version, (unsigned int)cli_sys_info.mcp_rev, (unsigned int)cli_sys_info.mcp_build);
@ -898,14 +923,14 @@ short cli_repl(short channel) {
if (sys_fsys_get_cwd(cwd_buffer, MAX_PATH_LEN) == 0) {
// char message[80];
// sprintf(message, "%d", strlen(cwd_buffer));
print(0, "");
print(CDEV_CONSOLE, "");
if (g_channels_swapped) {
// If channel has changed, deactivate old channel
cli_draw_window(1, cwd_buffer, 0);
cli_draw_window(CDEV_EVID, cwd_buffer, 0);
old_channel = g_current_channel;
g_channels_swapped = 0;
}
cli_draw_window(0, cwd_buffer, 1);
cli_draw_window(CDEV_CONSOLE, cwd_buffer, 1);
}
}

View file

@ -15,23 +15,24 @@
extern const unsigned char MSX_CP437_8x8_bin[];
/* Default text color lookup table values (AARRGGBB) */
const unsigned long a2560u_a_lut[VKY3_LUT_SIZE] = {
0xFF000000, // Black (transparent)
0xFF800000, // Mid-Tone Red
0xFF008000, // Mid-Tone Green
0xFF808000, // Mid-Tone Yellow
0xFF000080, // Mid-Tone Blue
0xFFAA5500, // Mid-Tone Orange
0xFF008080, // Mid-Tone Cian
0xFF808080, // 50% Grey
0xFF555555, // Dark Grey
0xFFFF0000, // Bright Red
0xFF55FF55, // Bright Green
0xFFFFFF55, // Bright Yellow
0xFF5555FF, // Bright Blue
0xFFFF7FFF, // Bright Orange
0xFF55FFFF, // Bright Cyan
0xFFFFFFFF // White
/* 0xGGBB, 0xAARR */
const unsigned short a2560u_a_lut[] = {
0x0000, 0xFF00, // Black (transparent)
0x0000, 0xFF80, // Mid-Tone Red
0x8000, 0xFF00, // Mid-Tone Green
0x8000, 0xFF80, // Mid-Tone Yellow
0x0080, 0xFF00, // Mid-Tone Blue
0x5500, 0xFFAA, // Mid-Tone Orange
0x8080, 0xFF00, // Mid-Tone Cian
0x8080, 0xFF80, // 50% Grey
0x5555, 0xFF55, // Dark Grey
0x5555, 0xFFFF, // Bright Red
0xFF55, 0xFF55, // Bright Green
0xFF55, 0xFFFF, // Bright Yellow
0x55FF, 0xFF55, // Bright Blue
0x7FFF, 0xFFFF, // Bright Orange
0xFFFF, 0xFF55, // Bright Cyan
0xFFFF, 0xFFFF // White
};
/*
@ -90,12 +91,19 @@ static void txt_a2560u_set_sizes() {
if ((a2560u_border_width != 0) && (a2560u_border_height != 0)) {
short border_width = (2 * a2560u_border_width) / a2560u_font_size.width;
short border_height = (2 * a2560u_border_height) / a2560u_font_size.height;
a2560u_visible_size.width = a2560u_max_size.width - border_width;
a2560u_visible_size.height = a2560u_max_size.height - border_height;
} else {
a2560u_visible_size.width = a2560u_max_size.width;
a2560u_visible_size.width = a2560u_max_size.width;
a2560u_visible_size.height = a2560u_max_size.height;
}
{
char msg[80];
sprintf(msg,"txt_a2560u_set_sizes max:%d,%d, visible:%d,%d", a2560u_max_size.width, a2560u_max_size.height, a2560u_visible_size.width, a2560u_visible_size.height);
DEBUG(msg);
}
}
}
@ -166,11 +174,18 @@ static short txt_a2560u_set_resolution(short width, short height) {
}
}
{
char msg[80];
sprintf(msg, "Setting resolution %dx%d", width, height);
DEBUG(msg);
}
/* Turn off resolution bits */
/* TODO: there gotta be a better way to do that */
msr_shadow &= ~(VKY3_MCR_RES_MASK);
if ((width == 800) && (height == 600)) {
msr_shadow |= VKY3_MCR_800x600;
a2560u_resolution.width = width;
a2560u_resolution.height = height;
@ -219,18 +234,14 @@ static void txt_a2560u_set_border(short width, short height) {
a2560u_border_width = width;
a2560u_border_height = height;
*BorderControlReg = (height & 0x3f) << 16 | (width & 0x3f) << 8 | VKY3_BRDR_EN;
// Recalculate the size of the screen
txt_a2560u_set_sizes();
} else {
a2560u_border_width = 0;
a2560u_border_height = 0;
*BorderControlReg = 0;
// Recalculate the size of the screen
txt_a2560u_set_sizes();
}
// Recalculate the size of the screen
txt_a2560u_set_sizes();
}
/**
@ -252,7 +263,7 @@ static void txt_a2560u_set_border_color(unsigned char red, unsigned char green,
* @param data pointer to the raw font data to be loaded
*/
static short txt_a2560u_set_font(short width, short height, const unsigned char * data) {
if (((width == 8) && (height == 8)) ) {
if (width == 8 && height == 8) {
int i;
/* The size is valid... set the font */
@ -312,6 +323,12 @@ static short txt_a2560u_get_region(p_rect region) {
region->size.width = a2560u_region.size.width;
region->size.height = a2560u_region.size.height;
{
char msg[80];
sprintf(msg,"txt_a2560u_get_region %p: x:%d, y:%d, w:%d, h:%d", region, region->origin.x, region->origin.y, region->size.width, region->size.height);
DEBUG(msg);
}
return 0;
}
@ -323,21 +340,34 @@ static short txt_a2560u_get_region(p_rect region) {
*
* @return 0 on success, any other number means the region was invalid
*/
static short txt_a2560u_set_region(p_rect region) {
static short txt_a2560u_set_region(const p_rect region) {
char msg[80];
sprintf(msg,"SET REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)",
region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height);
//DEBUG(msg);
if ((region->size.width == 0) || (region->size.height == 0)) {
/* Set the region to the default (full screen) */
a2560u_region.origin.x = 0;
a2560u_region.origin.y = 0;
a2560u_region.size.width = a2560u_visible_size.width;
a2560u_region.size.height = a2560u_visible_size.height;
a2560u_region.size.height = a2560u_visible_size.height;
} else {
a2560u_region.origin.x = region->origin.x;
a2560u_region.origin.y = region->origin.y;
a2560u_region.size.width = region->size.width;
a2560u_region.size.height = region->size.height;
//sprintf(msg,"specific region %d %d %d %d", region->origin.x, region->origin.y, region->size.width, region->size.height);
//DEBUG(msg);
}
{
sprintf(msg,"txt_a2560u_set_region: NEW REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)",
region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height);
//DEBUG(msg);
}
return 0;
}
@ -379,7 +409,7 @@ static void txt_a2560u_scroll(short horizontal, short vertical) {
/*
* Determine limits of rectangles to move and fill and directions of loops
* x0 and y0 are the positions of the first cell to be over-written
* x1 and y1 are the positions of the first cell to be copyed... TEXT[x0,y0] := TEXT[x1,y1]
* x1 and y1 are the positions of the first cell to be copied... TEXT[x0,y0] := TEXT[x1,y1]
* x2 and y2 are the position of the last cell to be over-written
* x3 and y3 are the position of the last cell to be copied... TEXT[x2,y2] := TEXT[x3,y3]
*
@ -418,6 +448,24 @@ static void txt_a2560u_scroll(short horizontal, short vertical) {
dx = -1;
}
{
// char buffer[80];
// sprintf(buffer,"a2560u_region.origin:%d,%d size:%d,%d", a2560u_region.origin.x, a2560u_region.origin.y, a2560u_region.size.width, a2560u_region.size.height);
// DEBUG(buffer);
// sprintf(buffer,"%d %d dx:%d dy:%d", a2560u_region.size.width, a2560u_region.size.height, dx, dy);
// DEBUG(buffer);
// sprintf(buffer,"(%d,%d) (%d,%d) vers (%d,%d) (%d,%d)",
// x1,y1, x3,y3, x0,y0, x2,y2);
// x1 % a2560u_region.size.width,y1 / a2560u_region.size.width,
// x3 % a2560u_region.size.width,y3 / a2560u_region.size.width,
// x0 % a2560u_region.size.width,y0 / a2560u_region.size.width,
// x2 % a2560u_region.size.width,y2 / a2560u_region.size.width);
//DEBUG(buffer);
}
#if 1
/* Copy the rectangle */
for (y = y0; y != y2; y += dy) {
@ -430,7 +478,31 @@ static void txt_a2560u_scroll(short horizontal, short vertical) {
ColorText_A[offset_dst] = ColorText_A[offset_src];
}
}
#else
/* Copy the rectangle */
int ydiff = vertical * a2560u_max_size.width;
for (y = y0; y != y2; y += dy) {
int row_dst = y * a2560u_max_size.width;
int row_src = row_dst + ydiff;
/* FIXME: this will crash on a 68k if the offsets are not even */
unsigned short *src = (unsigned short*)(&ScreenText_A[row_src + x0]);
unsigned short *dst = (unsigned short*)(&ScreenText_A[row_dst + x0 + horizontal]);
unsigned short *csrc = (unsigned short*)(&ColorText_A[row_src + x0]);
unsigned short *cdst = (unsigned short*)(&ColorText_A[row_dst + x0 + horizontal]);
/* FIXME: not sure if horizontal scrolling works ok in both directions. */
int width = x2 - x0;
if (width < 0)
width -= width;
width >>= 1; // We copy shorts so /2
while (width--) {
*dst++ = *src++;
*cdst++ = *csrc++;
}
}
#endif
/* Clear the rectangles */
if (horizontal != 0) {
@ -544,13 +616,15 @@ static void txt_a2560u_init() {
char buffer[255];
t_rect region;
int i;
DEBUG("txt_a2560u_init-------------------");
a2560u_resolution.width = 0;
a2560u_resolution.height = 0;
a2560u_visible_size.width = 0;
a2560u_visible_size.height = 0;
a2560u_font_size.width = 0;
a2560u_font_size.height = 0;
/* Disable the set_sizes call for now */
/* Disable the set_sizes call for now, to avoid computing transcient unnecessary values */
a2560u_enable_set_sizes = 0;
/* Start with nothing on */
@ -569,13 +643,13 @@ static void txt_a2560u_init() {
a2560u_caps.resolutions = a2560u_resolutions;
/* Only 8x8 on the U */
a2560u_caps.font_size_count = sizeof(a2560u_fonts) / sizeof(t_extent);;
a2560u_caps.font_size_count = sizeof(a2560u_fonts) / sizeof(t_extent);
a2560u_caps.font_sizes = a2560u_fonts;
/* Initialze the color lookup tables */
for (i = 0; i < VKY3_LUT_SIZE; i++) {
FG_CLUT_A[i] = a2560u_a_lut[i];
BG_CLUT_A[i] = a2560u_a_lut[i];
/* Initialize the color lookup tables */
for (i = 0; i < sizeof(a2560u_a_lut)/sizeof(unsigned short); i++) {
FG_CLUT_A[i] = a2560u_a_lut[i];
BG_CLUT_A[i] = a2560u_a_lut[i];
}
/* Set the mode to text */

View file

@ -65,6 +65,9 @@ void txt_init() {
* @return 0 on success, any other number is an error
*/
short txt_register(p_txt_device device) {
char buf[80];
sprintf(buf,"txt_register %p", device);
DEBUG(buf);
if (device->number < TXT_CNT_SCREENS) {
int i = device->number;
@ -98,6 +101,7 @@ short txt_register(p_txt_device device) {
}
}
#include <stdio.h>
/**
* Find the device driver for the screen, if installed
*
@ -124,6 +128,7 @@ p_txt_device txt_get_device(short screen) {
* @param screen the number of the text device
*/
void txt_init_screen(short screen) {
TRACE("txt_init_screen");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->init) {
@ -142,6 +147,7 @@ void txt_init_screen(short screen) {
* @return a pointer to the read-only description (0 on error)
*/
const p_txt_capabilities txt_get_capabilities(short screen) {
TRACE("txt_get_capabilities");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->get_capabilities) {
@ -159,6 +165,7 @@ const p_txt_capabilities txt_get_capabilities(short screen) {
* @return 0 on success, any other number means the mode is invalid for the screen
*/
short txt_set_mode(short screen, short mode) {
TRACE("txt_set_mode");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_mode) {
@ -174,6 +181,7 @@ short txt_set_mode(short screen, short mode) {
* @return 0 on success, any other number means the mode is invalid for the screen
*/
short txt_setsizes(short screen) {
TRACE("txt_setsizes");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_sizes) {
@ -194,6 +202,7 @@ short txt_setsizes(short screen) {
* @return 0 on success, any other number means the resolution is unsupported
*/
short txt_set_resolution(short screen, short width, short height) {
TRACE("txt_set_resolution");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_resolution) {
@ -211,6 +220,7 @@ short txt_set_resolution(short screen, short width, short height) {
* @param height the vertical size of one side of the border (0 - 32 pixels)
*/
void txt_set_border(short screen, short width, short height) {
TRACE("txt_set_border");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_border) {
@ -228,6 +238,7 @@ void txt_set_border(short screen, short width, short height) {
* @param blue the blue component of the color (0 - 255)
*/
void txt_set_border_color(short screen, unsigned char red, unsigned char green, unsigned char blue) {
TRACE("txt_set_border_color");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_border_color) {
@ -245,6 +256,7 @@ void txt_set_border_color(short screen, unsigned char red, unsigned char green,
* @param data pointer to the raw font data to be loaded
*/
short txt_set_font(short screen, short width, short height, const unsigned char * data) {
TRACE("txt_set_font");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_font) {
@ -263,6 +275,7 @@ short txt_set_font(short screen, short width, short height, const unsigned char
* @param c the character in the current font to use as a cursor
*/
void txt_set_cursor(short screen, short enable, short rate, char c) {
TRACE("txt_set_cursor");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_cursor) {
@ -278,6 +291,7 @@ void txt_set_cursor(short screen, short enable, short rate, char c) {
* @param enable 0 to hide, any other number to make visible
*/
void txt_set_cursor_visible(short screen, short enable) {
TRACE("txt_set_cursor_visible");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_cursor_visible) {
@ -295,6 +309,9 @@ void txt_set_cursor_visible(short screen, short enable) {
* @return 0 on success, any other number means the region was invalid
*/
short txt_get_region(short screen, p_rect region) {
char buf[80];
sprintf(buf, "txt_get_region screen:%d region:%p", screen, region);
DEBUG(buf);
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->get_region) {
@ -314,6 +331,7 @@ short txt_get_region(short screen, p_rect region) {
* @return 0 on success, any other number means the region was invalid
*/
short txt_set_region(short screen, p_rect region) {
TRACE("txt_set_region");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_region) {
@ -331,6 +349,7 @@ short txt_set_region(short screen, p_rect region) {
* @param background the Text LUT index of the new current background color (0 - 15)
*/
short txt_set_color(short screen, unsigned char foreground, unsigned char background) {
TRACE("txt_set_color");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->set_color) {
@ -349,6 +368,7 @@ short txt_set_color(short screen, unsigned char foreground, unsigned char backgr
* background = pointer to the background color number
*/
void txt_get_color(short screen, unsigned char * foreground, unsigned char * background) {
TRACE("txt_get_color");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->get_color) {
@ -705,6 +725,7 @@ void txt_delete(short screen, short count) {
* @param pixel_size the size of the screen in pixels (may be null)
*/
void txt_get_sizes(short screen, p_extent text_size, p_extent pixel_size) {
TRACE("txt_get_sizes");
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->get_sizes) {

View file

@ -126,8 +126,8 @@ void initialize() {
int i;
short res;
/* Set the logging level */
log_setlevel(LOG_FATAL);
/* Setup logging early */
log_init();
/* Initialize the memory system */
mem_init(0x3d0000);
@ -143,11 +143,13 @@ void initialize() {
#if MODEL == MODEL_FOENIX_A2560K
txt_a2560k_a_install();
txt_a2560k_b_install();
txt_init_screen(1);
txt_init_screen(TXT_SCREEN_A2560K_A);
txt_init_screen(TXT_SCREEN_A2560K_B);
#elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
txt_a2560u_install();
txt_init_screen(TXT_SCREEN_A2560U);
#endif
txt_init_screen(0);
log(LOG_INFO, "Text system initialized");
/* Initialize the indicators */

View file

@ -9,14 +9,51 @@
#include "log.h"
#include "simpleio.h"
#include "syscalls.h"
#include "dev/uart.h"
#include "dev/txt_screen.h"
static short log_channel = 0;
static short log_level = 999;
void log_init() {
log_channel = 0;
log_level = 999;
#if MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
#include "A2560U/gabe_a2560u.h"
#elif MODEL == MODEL_FOENIX_A2560K
#include "A2560K/gabe_a2560k.h"
#endif
/* Channel to which the logging output should go.
* Positive: screen number
* -1: UART.
*/
static short log_channel = LOG_CHANNEL;
static short log_level;
static void (*do_log)(const char* message);
static void log_to_uart(const char* message);
static void log_to_screen(const char* message);
#define UART_COM1 0
/* Can use the buzzer as sound clues */
void buzzer_on(void) {
*(GABE_CTRL_REG) = BUZZER_CONTROL;
}
void buzzer_off(void) {
*(GABE_CTRL_REG) &= ~BUZZER_CONTROL;
}
void log_init(void) {
log_setlevel(DEFAULT_LOG_LEVEL);
if (log_channel == LOG_CHANNEL_UART0) {
uart_init(UART_COM1);
do_log = log_to_uart;
log(LOG_INFO,"FOENIX DEBUG OUTPUT");
}
else
do_log = log_to_screen;
}
unsigned short panic_number; /* The number of the kernel panic */
@ -204,6 +241,20 @@ void log_setlevel(short level) {
log_level = level;
}
static void log_to_uart(const char *message) {
char *c = (char*)message;
while (*c)
uart_put(UART_COM1, *c++);
uart_put(UART_COM1,'\r');
uart_put(UART_COM1,'\n');
}
static void log_to_screen(const char *message) {
txt_print(log_channel, message);
txt_print(log_channel, "\n");
}
/*
* Log a message to the console
*
@ -212,10 +263,10 @@ void log_setlevel(short level) {
* message = the message to log
*/
void log(short level, char * message) {
if (level <= log_level) {
txt_print(log_channel, message);
txt_print(log_channel, "\n");
}
if (level > log_level)
return;
(*do_log)(message);
}
/*
@ -230,7 +281,7 @@ void log2(short level, char * message1, char * message2) {
if (level <= log_level) {
char line[80];
sprintf(line, "%s%s\n", message1, message2);
txt_print(log_channel, line);
log(level, line);
}
}
@ -247,7 +298,7 @@ void log3(short level, const char * message1, const char * message2, const char
if (level <= log_level) {
char line[80];
sprintf(line, "%s%s%s\n", message1, message2, message3);
txt_print(log_channel, line);
log(level, line);
}
}
@ -263,8 +314,8 @@ void log_num(short level, char * message, int n) {
char line[80];
if (level <= log_level) {
sprintf(line, "%s%08X\n", message, n);
print(log_channel, line);
sprintf(line, "%s%08X", message, n);
log(level, line);
}
}
@ -272,7 +323,8 @@ void log_num(short level, char * message, int n) {
* Send a single character to the debugging channel
*/
void log_c(short level, char c) {
if (log_level <= level) {
txt_put(log_channel, c);
}
char line[2];
line[0] = c;
line[1] = '\0';
log(level, line);
}

View file

@ -12,6 +12,21 @@
#define LOG_TRACE 4 /* Log tracing information (like entry into a subroutine) */
#define LOG_VERBOSE 5 /* Log a truly verbose message... the sort you almost never want to bother with */
#define LOG_CHANNEL_UART0 -1
#define LOG_CHANNEL_CHANNEL_A 0
#define LOG_CHANNEL_CHANNEL B 1
/*
* Settings
*/
#ifndef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL LOG_TRACE
#endif
#ifndef LOG_CHANNEL
#define LOG_CHANNEL LOG_CHANNEL_UART0
#endif
/*
* Return human readable message for an error number
*/
@ -35,6 +50,12 @@ extern void err_print(short channel, const char * message, short err_number);
*/
extern void panic(void);
/*
* Setup the logging facility (for debugging)
*/
extern void log_init(void);
/*
* Set the maximum level of verbosity in logging.
* To be printed, a message must have a level lower or equal to this level.

View file

@ -306,11 +306,21 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
return 0;
case KFN_TXT_SET_REGION:
{
char buf[60];
sprintf(buf, "KFN_TXT_SET_REGION: %d %p", (short)param0, (p_rect)param1);
DEBUG(buf);
}
/* Sets the clipping/scrolling region for further text operations */
return txt_set_region((short)param0, (p_rect)param1);
case KFN_TXT_GET_REGION:
/* Gets the current clipping/scrolling region */
{
char buf[60];
sprintf(buf, "KFN_TXT_GET_REGION: %d %p", (short)param0, (p_rect)param1);
DEBUG(buf);
}
return txt_get_region((short)param0, (p_rect)param1);
case KFN_TXT_SET_COLOR:

View file

@ -5,6 +5,7 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include "log.h"
#include "syscalls.h"
#include "simpleio.h"
#include "dev/txt_screen.h"
@ -29,7 +30,10 @@ void print_c(short channel, char c) {
* message = the ASCII-Z string to print
*/
void print(short channel, const char * message) {
sys_chan_write(channel, message, strlen(message));
short ret;
ret = sys_chan_write(channel, message, strlen(message));
if (ret < 0)
log_num(LOG_ERROR, "Error while printing: ", ret);
}
/**