Struggle to make things work. They dont.

This commit is contained in:
Vincent Barrilliot 2023-03-12 21:16:20 +01:00
parent 5b65d88d1b
commit 48df968b98
10 changed files with 440 additions and 365 deletions

View file

@ -12,7 +12,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "features.h" #include "sys_general.h"
#include "boot.h" #include "boot.h"
#include "constants.h" #include "constants.h"
#include "errors.h" #include "errors.h"
@ -20,7 +20,6 @@
#include "log.h" #include "log.h"
#include "simpleio.h" #include "simpleio.h"
#include "syscalls.h" #include "syscalls.h"
#include "sys_general.h"
#include "vicky_general.h" #include "vicky_general.h"
#include "cli/cli.h" #include "cli/cli.h"
#include "dev/kbd_mo.h" #include "dev/kbd_mo.h"
@ -223,7 +222,8 @@ short boot_screen() {
LUT_0[4*i+3] = splashscreen_lut[4*i+3]; 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;) { for (pixels = splashscreen_pix; *pixels != 0;) {
unsigned char count = *pixels++; unsigned char count = *pixels++;
unsigned char pixel = *pixels++; unsigned char pixel = *pixels++;
@ -231,13 +231,23 @@ short boot_screen() {
*vram++ = pixel; *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 */ /* Set up the bitmap */
*BM0_Addy_Pointer_Reg = 0; *BM0_Addy_Pointer_Reg = 0; /* Start of VRAM */
*BM0_Control_Reg = 1; *BM0_Control_Reg = 1;
/* Set a background color for the bitmap mode */ /* 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; *BackGroundControlReg_B = 0x00202020;
screen = 0; screen = 0;
#else #else

View file

@ -7,6 +7,9 @@
*/ */
#include "log_level.h" #include "log_level.h"
#ifdef DEFAULT_LOG_LEVEL
//#undef DEFAULT_LOG_LEVEL
#endif
#ifndef DEFAULT_LOG_LEVEL #ifndef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL LOG_TRACE #define DEFAULT_LOG_LEVEL LOG_TRACE
#endif #endif
@ -54,22 +57,7 @@ short cdev_register(const p_dev_chan device) {
dev = device->number; dev = device->number;
if (dev < CDEV_DEVICES_MAX) { if (dev < CDEV_DEVICES_MAX) {
// Copy the device description into the master table // Copy the device description into the master table
memcpy(&g_channel_devs[dev], device, sizeof(t_dev_chan));
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;
return E_OK; return E_OK;
} else { } else {
return DEV_ERR_BADDEV; return DEV_ERR_BADDEV;

View file

@ -5,6 +5,11 @@
* *
*/ */
#include "log_level.h"
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_TRACE
#endif
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include "features.h" #include "features.h"

View file

@ -36,7 +36,7 @@ void rtc_init() {
int_disable(INT_RTC); int_disable(INT_RTC);
/* Make sure the RTC is on */ /* Make sure the RTC is on */
*RTC_CTRL = RTC_STOP; *RTC_CTRL = (*RTC_CTRL & 0x07) | RTC_STOP;
/* /*
* For the moment: Every so often, the RTC interrupt gets acknowledged * For the moment: Every so often, the RTC interrupt gets acknowledged
@ -91,7 +91,7 @@ short rtc_register_periodic(short rate, FUNC_V_2_V handler) {
*RTC_ENABLES = RTC_PIE; *RTC_ENABLES = RTC_PIE;
int_enable(INT_RTC); int_enable(INT_RTC);
} }
return 0;
} }
/* /*
@ -178,7 +178,7 @@ void rtc_set_time(p_time time) {
} }
/* Re-enable updates to the clock */ /* Re-enable updates to the clock */
*RTC_CTRL = (ctrl & 0x7f) | RTC_STOP; *RTC_CTRL = (ctrl & 0x07) | RTC_STOP;
log(LOG_INFO, "RTC Enabled"); log(LOG_INFO, "RTC Enabled");
log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES);
log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES);
@ -221,7 +221,7 @@ void rtc_get_time(p_time time) {
second_bcd = *RTC_SEC; second_bcd = *RTC_SEC;
/* Re-enable updates to the clock */ /* Re-enable updates to the clock */
*RTC_CTRL = ctrl; *RTC_CTRL = (ctrl & 0x07) | RTC_STOP;
log(LOG_INFO, "RTC Enabled"); log(LOG_INFO, "RTC Enabled");
log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES);
log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES);

View file

@ -140,11 +140,23 @@ void initialize() {
/* Setup logging early */ /* Setup logging early */
log_init(); 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 */ /* Initialize the memory system */
mem_init(0x3d0000); mem_init(0x3d0000);
// /* Hide the mouse */ /* Hide the mouse */
mouse_set_visible(0); mouse_set_visible(0);
/* Initialize the variable system */ /* Initialize the variable system */
@ -155,6 +167,7 @@ void initialize() {
#if HAS_DUAL_SCREEN #if HAS_DUAL_SCREEN
txt_a2560k_a_install(); txt_a2560k_a_install();
txt_a2560k_b_install(); txt_a2560k_b_install();
log(LOG_INFO, "Initializing screens...");
txt_init_screen(TXT_SCREEN_A2560K_A); txt_init_screen(TXT_SCREEN_A2560K_A);
txt_init_screen(TXT_SCREEN_A2560K_B); txt_init_screen(TXT_SCREEN_A2560K_B);
#elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS #elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
@ -230,7 +243,7 @@ void initialize() {
INFO("SDC driver installed."); INFO("SDC driver installed.");
} }
#if MODEL == MODEL_FOENIX_A2560K #if HAS_FLOPPY
if (res = fdc_install()) { if (res = fdc_install()) {
ERROR1("FAILED: Floppy drive initialization %d", res); ERROR1("FAILED: Floppy drive initialization %d", res);
} else { } else {
@ -254,13 +267,15 @@ void initialize() {
} }
#endif #endif
#if HAS_SUPERIO #if HAS_PARALLEL_PORT
if (res = lpt_install()) { if (res = lpt_install()) {
log_num(LOG_ERROR, "FAILED: LPT installation", res); log_num(LOG_ERROR, "FAILED: LPT installation", res);
} else { } else {
log(LOG_INFO, "LPT installed."); log(LOG_INFO, "LPT installed.");
} }
#endif
#if HAS_MIDI_PORTS
if (res = midi_install()) { if (res = midi_install()) {
log_num(LOG_ERROR, "FAILED: MIDI installation", res); log_num(LOG_ERROR, "FAILED: MIDI installation", res);
} else { } else {
@ -292,7 +307,8 @@ void initialize() {
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
short result; short result;
short i; short i;
*((volatile uint32_t*const)0xfec80008) = 0xff00ff00L; //*((volatile uint32_t*const)0xfec80008) = 0xff99ff22L;
initialize(); initialize();
//*((volatile uint32_t*const)0xfec00000) = 0x16; //*((volatile uint32_t*const)0xfec00000) = 0x16;

View file

@ -52,7 +52,7 @@ void log_init(void) {
if (log_channel == LOG_CHANNEL_UART0) { if (log_channel == LOG_CHANNEL_UART0) {
uart_init(UART_COM1); uart_init(UART_COM1);
do_log = log_to_uart; do_log = log_to_uart;
log(LOG_INFO,"FOENIX DEBUG OUTPUT------------------------------------------------------------"); //log(LOG_INFO,"FOENIX DEBUG OUTPUT------------");
} }
else else
do_log = log_to_screen; do_log = log_to_screen;

View file

@ -129,18 +129,24 @@ coldboot: move.w #$2700,SR ; Supervisor mode, Interrupt mode (68040), d
moveq #0,d0 ; Disable 040's MMU moveq #0,d0 ; Disable 040's MMU
movec d0,TC movec d0,TC
move.l #$ffff8800,$fec80008 ;move.l #$ffff0000,$fec80008 ; border color for debug
lea ___STACK,sp lea ___STACK,sp
bsr _int_disable_all bsr _int_disable_all
lea ___BSSSTART,a0 lea ___BSSSTART,a0
move.l #___BSSSIZE,d0 move.l #___BSSSIZE,d0
beq callmain 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)+ ;clrloop: move.l d1,(a0)+ ; faster but requires BSS to be 4bytes aligned
subq.l #4,d0 ; subq.l #4,d0
bne clrloop ; bpl.s clrloop
move.l #$ffff0000,$fec80008
;move.l #$ffffff00,$fec80008 ; change border color
callmain: jsr _main ; call __main to transfer to the C code callmain: jsr _main ; call __main to transfer to the C code
; endless loop; can be changed accordingly ; endless loop; can be changed accordingly

View file

@ -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);
}

View file

@ -4,7 +4,7 @@ VECTOR_START = 0x00000000;
STORE_START = 0x00180000; STORE_START = 0x00180000;
KERNEL_START = 0x001C0000; KERNEL_START = 0x001C0000;
STACK_LEN = 0x400; STACK_LEN = 0x2000;
VECTOR_LEN = 0x400; VECTOR_LEN = 0x400;
STORE_LEN = 0x00030000; STORE_LEN = 0x00030000;
KERNEL_LEN = 0x00040000; KERNEL_LEN = 0x00040000;
@ -23,7 +23,7 @@ MEMORY
SECTIONS SECTIONS
{ {
vectors : { *(VECTORS) } >vectors vectors : { *(VECTORS) } >vectors
bss (NOLOAD) : { *(BSS) } >storeage bss ALIGN(4) (NOLOAD) : { *(BSS) } >storeage
text ALIGN(0x02) : { *(CODE) } >kernel text ALIGN(0x02) : { *(CODE) } >kernel
.dtors ALIGN(0x02) : { *(.dtors) } >kernel .dtors ALIGN(0x02) : { *(.dtors) } >kernel
.ctors ALIGN(0x02) : { *(.ctors) } >kernel .ctors ALIGN(0x02) : { *(.ctors) } >kernel
@ -33,7 +33,7 @@ SECTIONS
___heapend = STORE_START + STORE_LEN - STACK_LEN; ___heapend = STORE_START + STORE_LEN - STACK_LEN;
___BSSSTART = ADDR(bss); ___BSSSTART = ADDR(bss);
___BSSSIZE = SIZEOF(bss); ___BSSSIZE = (SIZEOF(bss)+3)%4;
___USER_STACK = 0x00010000; ___USER_STACK = 0x00010000;
___STACK = STORE_START + STORE_LEN; ___STACK = STORE_START + STORE_LEN;