From 48df968b982859e338c2574b949f49c3ce2e049b Mon Sep 17 00:00:00 2001 From: Vincent Barrilliot Date: Sun, 12 Mar 2023 21:16:20 +0100 Subject: [PATCH] Struggle to make things work. They dont. --- src/boot.c | 22 +- src/dev/channel.c | 20 +- src/dev/console.c | 5 + src/dev/rtc.c | 524 +++++++++--------- src/dev/rtc.h | 136 ++--- src/foenixmcp.c | 24 +- src/log.c | 2 +- src/m68040/startup_m68040.s | 16 +- .../m68k-foenix/vlink_ram_a2560x-vincent.cmd | 50 ++ vbcc/targets/m68k-foenix/vlink_ram_a2560x.cmd | 6 +- 10 files changed, 440 insertions(+), 365 deletions(-) create mode 100644 vbcc/targets/m68k-foenix/vlink_ram_a2560x-vincent.cmd diff --git a/src/boot.c b/src/boot.c index e336332..82d1b61 100644 --- a/src/boot.c +++ b/src/boot.c @@ -12,7 +12,7 @@ #include #include #include -#include "features.h" +#include "sys_general.h" #include "boot.h" #include "constants.h" #include "errors.h" @@ -20,7 +20,6 @@ #include "log.h" #include "simpleio.h" #include "syscalls.h" -#include "sys_general.h" #include "vicky_general.h" #include "cli/cli.h" #include "dev/kbd_mo.h" @@ -223,7 +222,8 @@ short boot_screen() { LUT_0[4*i+3] = splashscreen_lut[4*i+3]; } - /* Copy the bitmap to video RAM */ +#if 1 + /* Copy the bitmap to video RAM, it has simple RLE compression */ for (pixels = splashscreen_pix; *pixels != 0;) { unsigned char count = *pixels++; unsigned char pixel = *pixels++; @@ -231,13 +231,23 @@ short boot_screen() { *vram++ = pixel; } } - +#else + #if 0 + // For debug, try something more basic + const line_len = 640; + //memset(vram, 1, 640*480); + for (i=0; i < 640*480; i++) + vram[i] = 3; + for (i = 0; i < 480; i++) + vram[640*i + i] = 2; + #endif +#endif /* Set up the bitmap */ - *BM0_Addy_Pointer_Reg = 0; + *BM0_Addy_Pointer_Reg = 0; /* Start of VRAM */ *BM0_Control_Reg = 1; /* Set a background color for the bitmap mode */ -#if MODEL == MODEL_FOENIX_A2560K || MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X +#if HAS_DUAL_SCREEN *BackGroundControlReg_B = 0x00202020; screen = 0; #else diff --git a/src/dev/channel.c b/src/dev/channel.c index 98acd27..f6aa833 100644 --- a/src/dev/channel.c +++ b/src/dev/channel.c @@ -7,6 +7,9 @@ */ #include "log_level.h" +#ifdef DEFAULT_LOG_LEVEL + //#undef DEFAULT_LOG_LEVEL +#endif #ifndef DEFAULT_LOG_LEVEL #define DEFAULT_LOG_LEVEL LOG_TRACE #endif @@ -54,22 +57,7 @@ short cdev_register(const p_dev_chan device) { dev = device->number; if (dev < CDEV_DEVICES_MAX) { // Copy the device description into the master table - - p_dev_chan cdev = &g_channel_devs[dev]; - cdev->number = device->number; - cdev->name = device->name; - cdev->init = device->init; - cdev->open = device->open; - cdev->close = device->close; - cdev->read = device->read; - cdev->readline = device->readline; - cdev->read_b = device->read_b; - cdev->write = device->write; - cdev->write_b = device->write_b; - cdev->status = device->status; - cdev->seek = device->seek; - cdev->flush = device->flush; - cdev->ioctrl = device->ioctrl; + memcpy(&g_channel_devs[dev], device, sizeof(t_dev_chan)); return E_OK; } else { return DEV_ERR_BADDEV; diff --git a/src/dev/console.c b/src/dev/console.c index 9c728f1..bb3c4a5 100644 --- a/src/dev/console.c +++ b/src/dev/console.c @@ -5,6 +5,11 @@ * */ +#include "log_level.h" +#ifndef LOG_LEVEL + #define LOG_LEVEL LOG_TRACE +#endif + #include #include #include "features.h" diff --git a/src/dev/rtc.c b/src/dev/rtc.c index e85ef16..fac766c 100644 --- a/src/dev/rtc.c +++ b/src/dev/rtc.c @@ -1,262 +1,262 @@ -/* - * Definitions for access the bq4802LY real time clock - */ - -#include "log.h" -#include "interrupt.h" -#include "gabe_reg.h" -#include "rtc.h" -#include "rtc_reg.h" -#include "simpleio.h" -#include "timers.h" - -static long rtc_ticks; - -/* - * Interrupt handler for the real time clock - */ -void rtc_handle_int() { - unsigned char flags; - - /* Periodic interrupt: increment the ticks counter */ - flags = *RTC_FLAGS; - rtc_ticks++; -} - -/* - * Initialize the RTC - */ -void rtc_init() { - unsigned char flags; - unsigned char rates; - unsigned char enables; - - log(LOG_TRACE, "rtc_init"); - - int_disable(INT_RTC); - - /* Make sure the RTC is on */ - *RTC_CTRL = RTC_STOP; - - /* - * For the moment: Every so often, the RTC interrupt gets acknowledged - * without clearing the flags. Until I can sort out why, I will use - * the SOF A interrupt as a surrogate for the RTC jiffie timer - */ - - // /* Set the periodic interrupt to 15 millisecs */ - // *RTC_RATES = RTC_RATE_15ms; - // - // int_register(INT_RTC, rtc_handle_int); - // - // /* Enable the periodic interrupt */ - // flags = *RTC_FLAGS; - // *RTC_ENABLES = RTC_PIE; - // rtc_ticks = 0; - // - // int_enable(INT_RTC); -} - -/* - * Make sure the RTC tick counter is enabled - */ -void rtc_enable_ticks() { - /* Set the periodic interrupt to 15 millisecs */ - *RTC_RATES = RTC_RATE_15ms; - - unsigned char flags = *RTC_FLAGS; - - *RTC_ENABLES = RTC_PIE; - - int_enable(INT_RTC); -} - -/** - * Register a function to be called periodically - * - * @param rate the rate at which the function should be called using the bq4802LY periodic rate values (0 to disable) - * @param handler a pointer to a function from void to void to be called - * @return 0 on success, any other number is an error - */ -short rtc_register_periodic(short rate, FUNC_V_2_V handler) { - if (rate == 0) { - int_disable(INT_RTC); - *RTC_RATES = 0; - *RTC_ENABLES &= ~RTC_PIE; - - } else { - int_register(INT_RTC, handler); - *RTC_RATES = rate; - unsigned char flags = *RTC_FLAGS; - *RTC_ENABLES = RTC_PIE; - int_enable(INT_RTC); - } - return 0; -} - -/* - * Set the time on the RTC - * - * Inputs: - * time = pointer to a t_time record containing the correct time - */ -void rtc_set_time(p_time time) { - unsigned char ctrl; - unsigned char century_bcd, year_bcd, month_bcd, day_bcd; - unsigned char hour_bcd, minute_bcd, second_bcd; - unsigned short century; - unsigned short year; - - century = time->year / 100; - year = time->year - (century * 100); - - /* Compute the BCD values for the time */ - - century_bcd = i_to_bcd(century); - year_bcd = i_to_bcd(year); - month_bcd = i_to_bcd(time->month); - day_bcd = i_to_bcd(time->day); - hour_bcd = i_to_bcd(time->hour); - minute_bcd = i_to_bcd(time->minute); - second_bcd = i_to_bcd(time->second); - - log_num(LOG_INFO, "Century: ", century_bcd); - log_num(LOG_INFO, "Year: ", year_bcd); - log_num(LOG_INFO, "Month: ", month_bcd); - log_num(LOG_INFO, "Day: ", day_bcd); - log_num(LOG_INFO, "Hour: ", hour_bcd); - log_num(LOG_INFO, "Minute: ", minute_bcd); - log_num(LOG_INFO, "Second: ", second_bcd); - - if (!time->is_24hours) { - if (time->is_pm) { - hour_bcd = hour_bcd | 0x80; - } - } - minute_bcd = i_to_bcd(time->minute); - second_bcd = i_to_bcd(time->second); - - /* Temporarily disable updates to the clock */ - ctrl = *RTC_CTRL; - *RTC_CTRL = ctrl | RTC_UTI; - log(LOG_INFO, "RTC Disabled"); - log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); - log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); - log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); - log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); - - /* Set the time in the RTC */ - - *RTC_CENTURY = century_bcd; - *RTC_YEAR = year_bcd; - *RTC_MONTH = month_bcd; - *RTC_DAY = day_bcd; - *RTC_HOUR = hour_bcd; - *RTC_MIN = minute_bcd; - *RTC_SEC = second_bcd; - - /* Verify */ - - century_bcd = *RTC_CENTURY; - year_bcd = *RTC_YEAR; - month_bcd = *RTC_MONTH; - day_bcd = *RTC_DAY; - hour_bcd = *RTC_HOUR; - minute_bcd = *RTC_MIN; - second_bcd = *RTC_SEC; - log_num(LOG_INFO, "REG Century: ", century_bcd); - log_num(LOG_INFO, "REG Year: ", year_bcd); - log_num(LOG_INFO, "REG Month: ", month_bcd); - log_num(LOG_INFO, "REG Day: ", day_bcd); - log_num(LOG_INFO, "REG Hour: ", hour_bcd); - log_num(LOG_INFO, "REG Minute: ", minute_bcd); - log_num(LOG_INFO, "REG Second: ", second_bcd); - - /* Set the 24/12 hour control bit if needed */ - if (time->is_24hours) { - ctrl = ctrl | RTC_2412; - } - - /* Re-enable updates to the clock */ - *RTC_CTRL = (ctrl & 0x7f) | RTC_STOP; - log(LOG_INFO, "RTC Enabled"); - log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); - log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); - log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); - log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); -} - -/* - * Get the time on the RTC - * - * Inputs: - * time = pointer to a t_time record in which to put the current time - */ -void rtc_get_time(p_time time) { - unsigned char ctrl; - unsigned char century_bcd, year_bcd, month_bcd, day_bcd; - unsigned char hour_bcd, minute_bcd, second_bcd; - - /* Temporarily disable updates to the clock */ - ctrl = *RTC_CTRL; - *RTC_CTRL = ctrl | RTC_UTI; - log(LOG_INFO, "RTC Disabled"); - log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); - log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); - log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); - log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); - - if (*RTC_CTRL & RTC_2412) { - time->is_24hours = 1; - } else { - time->is_24hours = 0; - } - - century_bcd = *RTC_CENTURY; - year_bcd = *RTC_YEAR; - month_bcd = *RTC_MONTH; - day_bcd = *RTC_DAY; - hour_bcd = *RTC_HOUR; - minute_bcd = *RTC_MIN; - second_bcd = *RTC_SEC; - - /* Re-enable updates to the clock */ - *RTC_CTRL = ctrl; - log(LOG_INFO, "RTC Enabled"); - log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); - log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); - log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); - log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); - - log_num(LOG_INFO, "Century: ", century_bcd); - log_num(LOG_INFO, "Year: ", year_bcd); - log_num(LOG_INFO, "Month: ", month_bcd); - log_num(LOG_INFO, "Day: ", day_bcd); - log_num(LOG_INFO, "Hour: ", hour_bcd); - log_num(LOG_INFO, "Minute: ", minute_bcd); - log_num(LOG_INFO, "Second: ", second_bcd); - - /* Fill out the time record */ - - time->year = bcd_to_i(century_bcd) * 100 + bcd_to_i(year_bcd); - time->month = bcd_to_i(month_bcd); - time->day = bcd_to_i(day_bcd); - time->hour = bcd_to_i(hour_bcd & 0x7f); - time->is_pm = ((hour_bcd & 0x80) == 0x80) ? 1 : 0; - time->minute = bcd_to_i(minute_bcd); - time->second = bcd_to_i(second_bcd); -} - -/* - * Get the number of jiffies since the system last booted. - * - * NOTE: a jiffie is 1/60 of a second. This timer will not be - * 100% precise, so it should be used for timeout purposes - * where precision is not critical. - * - * Returns: - * the number of jiffies since the last reset - */ -long rtc_get_jiffies() { - return timers_jiffies(); -} +/* + * Definitions for access the bq4802LY real time clock + */ + +#include "log.h" +#include "interrupt.h" +#include "gabe_reg.h" +#include "rtc.h" +#include "rtc_reg.h" +#include "simpleio.h" +#include "timers.h" + +static long rtc_ticks; + +/* + * Interrupt handler for the real time clock + */ +void rtc_handle_int() { + unsigned char flags; + + /* Periodic interrupt: increment the ticks counter */ + flags = *RTC_FLAGS; + rtc_ticks++; +} + +/* + * Initialize the RTC + */ +void rtc_init() { + unsigned char flags; + unsigned char rates; + unsigned char enables; + + log(LOG_TRACE, "rtc_init"); + + int_disable(INT_RTC); + + /* Make sure the RTC is on */ + *RTC_CTRL = (*RTC_CTRL & 0x07) | RTC_STOP; + + /* + * For the moment: Every so often, the RTC interrupt gets acknowledged + * without clearing the flags. Until I can sort out why, I will use + * the SOF A interrupt as a surrogate for the RTC jiffie timer + */ + + // /* Set the periodic interrupt to 15 millisecs */ + // *RTC_RATES = RTC_RATE_15ms; + // + // int_register(INT_RTC, rtc_handle_int); + // + // /* Enable the periodic interrupt */ + // flags = *RTC_FLAGS; + // *RTC_ENABLES = RTC_PIE; + // rtc_ticks = 0; + // + // int_enable(INT_RTC); +} + +/* + * Make sure the RTC tick counter is enabled + */ +void rtc_enable_ticks() { + /* Set the periodic interrupt to 15 millisecs */ + *RTC_RATES = RTC_RATE_15ms; + + unsigned char flags = *RTC_FLAGS; + + *RTC_ENABLES = RTC_PIE; + + int_enable(INT_RTC); +} + +/** + * Register a function to be called periodically + * + * @param rate the rate at which the function should be called using the bq4802LY periodic rate values (0 to disable) + * @param handler a pointer to a function from void to void to be called + * @return 0 on success, any other number is an error + */ +short rtc_register_periodic(short rate, FUNC_V_2_V handler) { + if (rate == 0) { + int_disable(INT_RTC); + *RTC_RATES = 0; + *RTC_ENABLES &= ~RTC_PIE; + + } else { + int_register(INT_RTC, handler); + *RTC_RATES = rate; + unsigned char flags = *RTC_FLAGS; + *RTC_ENABLES = RTC_PIE; + int_enable(INT_RTC); + } + +} + +/* + * Set the time on the RTC + * + * Inputs: + * time = pointer to a t_time record containing the correct time + */ +void rtc_set_time(p_time time) { + unsigned char ctrl; + unsigned char century_bcd, year_bcd, month_bcd, day_bcd; + unsigned char hour_bcd, minute_bcd, second_bcd; + unsigned short century; + unsigned short year; + + century = time->year / 100; + year = time->year - (century * 100); + + /* Compute the BCD values for the time */ + + century_bcd = i_to_bcd(century); + year_bcd = i_to_bcd(year); + month_bcd = i_to_bcd(time->month); + day_bcd = i_to_bcd(time->day); + hour_bcd = i_to_bcd(time->hour); + minute_bcd = i_to_bcd(time->minute); + second_bcd = i_to_bcd(time->second); + + log_num(LOG_INFO, "Century: ", century_bcd); + log_num(LOG_INFO, "Year: ", year_bcd); + log_num(LOG_INFO, "Month: ", month_bcd); + log_num(LOG_INFO, "Day: ", day_bcd); + log_num(LOG_INFO, "Hour: ", hour_bcd); + log_num(LOG_INFO, "Minute: ", minute_bcd); + log_num(LOG_INFO, "Second: ", second_bcd); + + if (!time->is_24hours) { + if (time->is_pm) { + hour_bcd = hour_bcd | 0x80; + } + } + minute_bcd = i_to_bcd(time->minute); + second_bcd = i_to_bcd(time->second); + + /* Temporarily disable updates to the clock */ + ctrl = *RTC_CTRL; + *RTC_CTRL = ctrl | RTC_UTI; + log(LOG_INFO, "RTC Disabled"); + log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); + log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); + log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); + log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); + + /* Set the time in the RTC */ + + *RTC_CENTURY = century_bcd; + *RTC_YEAR = year_bcd; + *RTC_MONTH = month_bcd; + *RTC_DAY = day_bcd; + *RTC_HOUR = hour_bcd; + *RTC_MIN = minute_bcd; + *RTC_SEC = second_bcd; + + /* Verify */ + + century_bcd = *RTC_CENTURY; + year_bcd = *RTC_YEAR; + month_bcd = *RTC_MONTH; + day_bcd = *RTC_DAY; + hour_bcd = *RTC_HOUR; + minute_bcd = *RTC_MIN; + second_bcd = *RTC_SEC; + log_num(LOG_INFO, "REG Century: ", century_bcd); + log_num(LOG_INFO, "REG Year: ", year_bcd); + log_num(LOG_INFO, "REG Month: ", month_bcd); + log_num(LOG_INFO, "REG Day: ", day_bcd); + log_num(LOG_INFO, "REG Hour: ", hour_bcd); + log_num(LOG_INFO, "REG Minute: ", minute_bcd); + log_num(LOG_INFO, "REG Second: ", second_bcd); + + /* Set the 24/12 hour control bit if needed */ + if (time->is_24hours) { + ctrl = ctrl | RTC_2412; + } + + /* Re-enable updates to the clock */ + *RTC_CTRL = (ctrl & 0x07) | RTC_STOP; + log(LOG_INFO, "RTC Enabled"); + log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); + log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); + log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); + log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); +} + +/* + * Get the time on the RTC + * + * Inputs: + * time = pointer to a t_time record in which to put the current time + */ +void rtc_get_time(p_time time) { + unsigned char ctrl; + unsigned char century_bcd, year_bcd, month_bcd, day_bcd; + unsigned char hour_bcd, minute_bcd, second_bcd; + + /* Temporarily disable updates to the clock */ + ctrl = *RTC_CTRL; + *RTC_CTRL = ctrl | RTC_UTI; + log(LOG_INFO, "RTC Disabled"); + log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); + log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); + log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); + log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); + + if (*RTC_CTRL & RTC_2412) { + time->is_24hours = 1; + } else { + time->is_24hours = 0; + } + + century_bcd = *RTC_CENTURY; + year_bcd = *RTC_YEAR; + month_bcd = *RTC_MONTH; + day_bcd = *RTC_DAY; + hour_bcd = *RTC_HOUR; + minute_bcd = *RTC_MIN; + second_bcd = *RTC_SEC; + + /* Re-enable updates to the clock */ + *RTC_CTRL = (ctrl & 0x07) | RTC_STOP; + log(LOG_INFO, "RTC Enabled"); + log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); + log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); + log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); + log_num(LOG_INFO, "RTC Control: ", *RTC_CTRL); + + log_num(LOG_INFO, "Century: ", century_bcd); + log_num(LOG_INFO, "Year: ", year_bcd); + log_num(LOG_INFO, "Month: ", month_bcd); + log_num(LOG_INFO, "Day: ", day_bcd); + log_num(LOG_INFO, "Hour: ", hour_bcd); + log_num(LOG_INFO, "Minute: ", minute_bcd); + log_num(LOG_INFO, "Second: ", second_bcd); + + /* Fill out the time record */ + + time->year = bcd_to_i(century_bcd) * 100 + bcd_to_i(year_bcd); + time->month = bcd_to_i(month_bcd); + time->day = bcd_to_i(day_bcd); + time->hour = bcd_to_i(hour_bcd & 0x7f); + time->is_pm = ((hour_bcd & 0x80) == 0x80) ? 1 : 0; + time->minute = bcd_to_i(minute_bcd); + time->second = bcd_to_i(second_bcd); +} + +/* + * Get the number of jiffies since the system last booted. + * + * NOTE: a jiffie is 1/60 of a second. This timer will not be + * 100% precise, so it should be used for timeout purposes + * where precision is not critical. + * + * Returns: + * the number of jiffies since the last reset + */ +long rtc_get_jiffies() { + return timers_jiffies(); +} diff --git a/src/dev/rtc.h b/src/dev/rtc.h index 6544606..ad4b767 100644 --- a/src/dev/rtc.h +++ b/src/dev/rtc.h @@ -1,68 +1,68 @@ -/* - * Declarations for access the bq4802LY real time clock - */ - -#ifndef __RTC_H -#define __RTC_H - -#include "types.h" - -typedef struct s_time { - short year; - short month; - short day; - short hour; - short minute; - short second; - short is_pm; - short is_24hours; -} t_time, *p_time; - -/* - * Initialize the RTC - */ -extern void rtc_init(); - -/* - * Make sure the RTC tick counter is enabled - */ -extern void rtc_enable_ticks(); - -/* - * Set the time on the RTC - * - * Inputs: - * time = pointer to a t_time record containing the correct time - */ -extern void rtc_set_time(p_time time); - -/* - * Get the time on the RTC - * - * Inputs: - * time = pointer to a t_time record in which to put the current time - */ -extern void rtc_get_time(p_time time); - -/* - * Get the number of jiffies since the system last booted. - * - * NOTE: a jiffie is 1/60 of a second. This timer will not be - * 100% precise, so it should be used for timeout purposes - * where precision is not critical. - * - * Returns: - * the number of jiffies since the last reset - */ -extern long rtc_get_jiffies(); - -/** - * Register a function to be called periodically - * - * @param rate the rate at which the function should be called using the bq4802LY periodic rate values (0 to disable) - * @param handler a pointer to a function from void to void to be called - * @return 0 on success, any other number is an error - */ -extern short rtc_register_periodic(short rate, FUNC_V_2_V handler); - -#endif +/* + * Declarations for access the bq4802LY real time clock + */ + +#ifndef __RTC_H +#define __RTC_H + +#include "types.h" + +typedef struct s_time { + short year; + short month; + short day; + short hour; + short minute; + short second; + short is_pm; + short is_24hours; +} t_time, *p_time; + +/* + * Initialize the RTC + */ +extern void rtc_init(); + +/* + * Make sure the RTC tick counter is enabled + */ +extern void rtc_enable_ticks(); + +/* + * Set the time on the RTC + * + * Inputs: + * time = pointer to a t_time record containing the correct time + */ +extern void rtc_set_time(p_time time); + +/* + * Get the time on the RTC + * + * Inputs: + * time = pointer to a t_time record in which to put the current time + */ +extern void rtc_get_time(p_time time); + +/* + * Get the number of jiffies since the system last booted. + * + * NOTE: a jiffie is 1/60 of a second. This timer will not be + * 100% precise, so it should be used for timeout purposes + * where precision is not critical. + * + * Returns: + * the number of jiffies since the last reset + */ +extern long rtc_get_jiffies(); + +/** + * Register a function to be called periodically + * + * @param rate the rate at which the function should be called using the bq4802LY periodic rate values (0 to disable) + * @param handler a pointer to a function from void to void to be called + * @return 0 on success, any other number is an error + */ +extern short rtc_register_periodic(short rate, FUNC_V_2_V handler); + +#endif diff --git a/src/foenixmcp.c b/src/foenixmcp.c index cc946e9..68742f4 100644 --- a/src/foenixmcp.c +++ b/src/foenixmcp.c @@ -140,11 +140,23 @@ void initialize() { /* Setup logging early */ log_init(); + #if 0 + char msg[] = "This is some text to test that the debug to UART works ok\r\n"; + { + char *c = (char*)msg; + while (*c) { + uart_put(1, *c++); + } + } + + // The text below gets corrupted. VBCC libc's not being properly initialized if we didn't call ___main ? + //DEBUG("This is some text to test that the debug to UART works ok"); + #endif /* Initialize the memory system */ mem_init(0x3d0000); - // /* Hide the mouse */ + /* Hide the mouse */ mouse_set_visible(0); /* Initialize the variable system */ @@ -155,6 +167,7 @@ void initialize() { #if HAS_DUAL_SCREEN txt_a2560k_a_install(); txt_a2560k_b_install(); + log(LOG_INFO, "Initializing screens..."); txt_init_screen(TXT_SCREEN_A2560K_A); txt_init_screen(TXT_SCREEN_A2560K_B); #elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS @@ -230,7 +243,7 @@ void initialize() { INFO("SDC driver installed."); } -#if MODEL == MODEL_FOENIX_A2560K +#if HAS_FLOPPY if (res = fdc_install()) { ERROR1("FAILED: Floppy drive initialization %d", res); } else { @@ -254,13 +267,15 @@ void initialize() { } #endif -#if HAS_SUPERIO +#if HAS_PARALLEL_PORT if (res = lpt_install()) { log_num(LOG_ERROR, "FAILED: LPT installation", res); } else { log(LOG_INFO, "LPT installed."); } +#endif +#if HAS_MIDI_PORTS if (res = midi_install()) { log_num(LOG_ERROR, "FAILED: MIDI installation", res); } else { @@ -292,7 +307,8 @@ void initialize() { int main(int argc, char * argv[]) { short result; short i; -*((volatile uint32_t*const)0xfec80008) = 0xff00ff00L; +//*((volatile uint32_t*const)0xfec80008) = 0xff99ff22L; + initialize(); //*((volatile uint32_t*const)0xfec00000) = 0x16; diff --git a/src/log.c b/src/log.c index 1251d85..8c2548f 100644 --- a/src/log.c +++ b/src/log.c @@ -52,7 +52,7 @@ void log_init(void) { if (log_channel == LOG_CHANNEL_UART0) { uart_init(UART_COM1); do_log = log_to_uart; - log(LOG_INFO,"FOENIX DEBUG OUTPUT------------------------------------------------------------"); + //log(LOG_INFO,"FOENIX DEBUG OUTPUT------------"); } else do_log = log_to_screen; diff --git a/src/m68040/startup_m68040.s b/src/m68040/startup_m68040.s index 2301ef1..4267dc3 100644 --- a/src/m68040/startup_m68040.s +++ b/src/m68040/startup_m68040.s @@ -129,18 +129,24 @@ coldboot: move.w #$2700,SR ; Supervisor mode, Interrupt mode (68040), d moveq #0,d0 ; Disable 040's MMU movec d0,TC - move.l #$ffff8800,$fec80008 + ;move.l #$ffff0000,$fec80008 ; border color for debug lea ___STACK,sp bsr _int_disable_all lea ___BSSSTART,a0 move.l #___BSSSIZE,d0 beq callmain + moveq #0,d1 + ; Be save in case BSS is not long word-aligned +clrloop: move.b d1,(a0)+ + subq.l #1,d0 + bpl.s clrloop -clrloop: move.l #0,(a0)+ - subq.l #4,d0 - bne clrloop - move.l #$ffff0000,$fec80008 +;clrloop: move.l d1,(a0)+ ; faster but requires BSS to be 4bytes aligned +; subq.l #4,d0 +; bpl.s clrloop + + ;move.l #$ffffff00,$fec80008 ; change border color callmain: jsr _main ; call __main to transfer to the C code ; endless loop; can be changed accordingly diff --git a/vbcc/targets/m68k-foenix/vlink_ram_a2560x-vincent.cmd b/vbcc/targets/m68k-foenix/vlink_ram_a2560x-vincent.cmd new file mode 100644 index 0000000..e83e788 --- /dev/null +++ b/vbcc/targets/m68k-foenix/vlink_ram_a2560x-vincent.cmd @@ -0,0 +1,50 @@ +VECTOR_START = 0x00000000; +VECTOR_LEN = 0x1000; +STORE_LEN = 0x00010000; +STACK_LEN = 0x400; +SYSTEM_RAM_TOP = 0x400000; +OS_RAM_AREA = SYSTEM_RAM_TOP - 0x100000; + +MEMORY +{ + vectors : org = VECTOR_START ,len = VECTOR_LEN + system_ram: org = VECTOR_START+VECTOR_LEN ,len = OS_RAM_AREA - VECTOR_LEN + os_area: org = OS_RAM_AREA ,len = SYSTEM_RAM_TOP - OS_RAM_AREA +} + +SECTIONS +{ + vectors : { *(VECTORS) } >vectors + + bss ALIGN(4) (NOLOAD) : { + ___BSSSTART = .; + *(BSS) + + . = ALIGN(4); + RESERVE(STACK_LEN); + ___USER_STACK = .; + + . = ALIGN(4); + RESERVE(STACK_LEN); + ___STACK = .; + ___stack = .; + + . = ALIGN(4); + ___heap = .; + ___heapptr = . + RESERVE(STORE_LEN); + ___heapend = .; + + . = ALIGN(4); + ___memory_start = .; + } >os_area + + data ALIGN(0x04) : { *(DATA) } >os_area + text ALIGN(0x04) : { *(CODE) } >os_area + .dtors ALIGN(0x04) : { *(.dtors) } >os_area + .ctors ALIGN(0x04) : { *(.ctors) } >os_area + + ___BSSSIZE = SIZEOF(bss); + _RAM_TOP = ADDR(bss); + +} diff --git a/vbcc/targets/m68k-foenix/vlink_ram_a2560x.cmd b/vbcc/targets/m68k-foenix/vlink_ram_a2560x.cmd index 4206440..51b7d89 100644 --- a/vbcc/targets/m68k-foenix/vlink_ram_a2560x.cmd +++ b/vbcc/targets/m68k-foenix/vlink_ram_a2560x.cmd @@ -4,7 +4,7 @@ VECTOR_START = 0x00000000; STORE_START = 0x00180000; KERNEL_START = 0x001C0000; -STACK_LEN = 0x400; +STACK_LEN = 0x2000; VECTOR_LEN = 0x400; STORE_LEN = 0x00030000; KERNEL_LEN = 0x00040000; @@ -23,7 +23,7 @@ MEMORY SECTIONS { vectors : { *(VECTORS) } >vectors - bss (NOLOAD) : { *(BSS) } >storeage + bss ALIGN(4) (NOLOAD) : { *(BSS) } >storeage text ALIGN(0x02) : { *(CODE) } >kernel .dtors ALIGN(0x02) : { *(.dtors) } >kernel .ctors ALIGN(0x02) : { *(.ctors) } >kernel @@ -33,7 +33,7 @@ SECTIONS ___heapend = STORE_START + STORE_LEN - STACK_LEN; ___BSSSTART = ADDR(bss); - ___BSSSIZE = SIZEOF(bss); + ___BSSSIZE = (SIZEOF(bss)+3)%4; ___USER_STACK = 0x00010000; ___STACK = STORE_START + STORE_LEN;