Boot DIP Switches

Fixed GABE register definitions. Rearranged sys_info routine. Boot code now recognizes DIP switch settings for boot source.
This commit is contained in:
Peter Weingartner 2022-03-31 15:09:30 -04:00
parent 1ac6e233b3
commit 94097ace40
11 changed files with 14158 additions and 14156 deletions

View file

@ -342,6 +342,7 @@ short boot_screen() {
* @param device the number of the block device to use for booting (-1 to go straight to CLI) * @param device the number of the block device to use for booting (-1 to go straight to CLI)
*/ */
void boot_from_bdev(short device) { void boot_from_bdev(short device) {
char initial_path[10];
unsigned short boot_dip = 0; // The setting on the user and boot mode DIP switches unsigned short boot_dip = 0; // The setting on the user and boot mode DIP switches
short bootable = 0; // Is the boot sector of the selected device bootable? short bootable = 0; // Is the boot sector of the selected device bootable?
@ -355,23 +356,27 @@ void boot_from_bdev(short device) {
// Boot from IDE // Boot from IDE
device = BDEV_HDC; device = BDEV_HDC;
log(LOG_INFO, "Boot DIP set for IDE"); log(LOG_INFO, "Boot DIP set for IDE");
strcpy(initial_path, "/hd");
break; break;
case 0x0001: case 0x0001:
// Boot from SDC // Boot from SDC
device = BDEV_SDC; device = BDEV_SDC;
log(LOG_INFO, "Boot DIP set for SDC"); log(LOG_INFO, "Boot DIP set for SDC");
strcpy(initial_path, "/sd");
break; break;
case 0x0002: case 0x0002:
// Boot from Floppy // Boot from Floppy
device = BDEV_FDC; device = BDEV_FDC;
log(LOG_INFO, "Boot DIP set for FDC"); log(LOG_INFO, "Boot DIP set for FDC");
strcpy(initial_path, "/fd");
break; break;
default: default:
// Boot straight to REPL // Boot straight to REPL
log(LOG_INFO, "Boot DIP set for REPL"); log(LOG_INFO, "Boot DIP set for REPL");
strcpy(initial_path, "/sd");
device = -1; device = -1;
break; break;
} }
@ -407,18 +412,21 @@ void boot_from_bdev(short device) {
// Execute startup file on boot device (if present) // Execute startup file on boot device (if present)
switch (device) { switch (device) {
case BDEV_SDC: case BDEV_SDC:
strcpy(initial_path, "/sd");
if (cli_exec_batch(cli_screen, MCP_INIT_SDC) != 0) { if (cli_exec_batch(cli_screen, MCP_INIT_SDC) != 0) {
cli_exec_batch(cli_screen, MCP_INIT_HDC); cli_exec_batch(cli_screen, MCP_INIT_HDC);
} }
break; break;
case BDEV_FDC: case BDEV_FDC:
strcpy(initial_path, "/fd");
if (cli_exec_batch(cli_screen, MCP_INIT_FDC) != 0) { if (cli_exec_batch(cli_screen, MCP_INIT_FDC) != 0) {
cli_exec_batch(cli_screen, MCP_INIT_HDC); cli_exec_batch(cli_screen, MCP_INIT_HDC);
} }
break; break;
case BDEV_HDC: case BDEV_HDC:
strcpy(initial_path, "/hd");
cli_exec_batch(cli_screen, MCP_INIT_HDC); cli_exec_batch(cli_screen, MCP_INIT_HDC);
break; break;
@ -434,7 +442,7 @@ void boot_from_bdev(short device) {
} else { } else {
// No over-ride provided... boot the default // No over-ride provided... boot the default
cli_repl(cli_screen); cli_repl(cli_screen, initial_path);
} }
} }
} }

View file

@ -254,7 +254,7 @@ char * strtok_r(char * source, const char * delimiter, char ** saveptr) {
void cli_rerepl() { void cli_rerepl() {
while (1) { while (1) {
cli_repl(g_current_channel); cli_repl(g_current_channel, 0);
} }
} }
@ -294,13 +294,21 @@ short cli_process_line(short channel, const char * command_line) {
// //
// Enter the CLI's read-eval-print loop // Enter the CLI's read-eval-print loop
// //
short cli_repl(short channel) { short cli_repl(short channel, const char * init_cwd) {
char command_line[MAX_COMMAND_SIZE]; char command_line[MAX_COMMAND_SIZE];
char cwd_buffer[MAX_PATH_LEN]; char cwd_buffer[MAX_PATH_LEN];
g_current_channel = channel; g_current_channel = channel;
if (init_cwd != 0) {
short result = sys_fsys_set_cwd(init_cwd);
if (result) {
char message[80];
sprintf(message, "Unable to set startup directory: %s\n", err_message(result));
print(channel, message);
}
}
while (1) { while (1) {
sys_chan_write(channel, "\n", 1); sys_chan_write(channel, "\n", 1);
if(sys_fsys_get_cwd(cwd_buffer, MAX_PATH_LEN) == 0) { if(sys_fsys_get_cwd(cwd_buffer, MAX_PATH_LEN) == 0) {

View file

@ -31,8 +31,9 @@ extern short cli_init();
* *
* Inputs: * Inputs:
* channel = the console channel to use for I/O * channel = the console channel to use for I/O
* init_cwd = pointer to the path for the initial current working directory
*/ */
extern short cli_repl(short channel); extern short cli_repl(short channel, const char * init_cwd);
/* /*
* Evaluate an argument to a number * Evaluate an argument to a number

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
/**
* @file gabe_a2560k.h
*
* Define miscellaneous GABE registers
*/
#ifndef __GABE_A2560K_H
#define __GABE_A2560K_H
#define GABE_CTRL_REG ((volatile unsigned int *)0xFEC00000)
#define POWER_ON_LED 0x00000001
#define SDCARD_LED 0x00000002
#define BUZZER_CONTROL 0x00000010
#define MANUAL_RESET 0x00008000 // Make sure the word "DEAD" is written in GABE_RESET_ID
#define GABE_LFSR_REG0 ((volatile unsigned int *)0xFEC00004)
#define RGB_LED ((volatile unsigned int *)0xFEC00008) // Writing Only - A2560K Only - 0x__RRGGBB
#define GABE_LFSR_STATDATA ((volatile unsigned int *)0xFEC00008) // Read Only
#define GABE_SUBVER_ID ((volatile unsigned int *)0xFEC0000C) // Subversion[31:16], Machine ID[3:2] - Read Only
#define GABE_CPU_ID_MASK 0x0000FF00
#define GABE_CPU_SPD_MASK 0x000000E0
#define GABE_ID_MASK 0x0000000C
#define GABE_CHIP_SV_MASK 0xFFFF0000
#define GABE_CHIP_VERSION ((volatile unsigned int *)0xFEC00010) // Number[31:16], Version[15:0]
#define GABE_CHIP_V_MASK 0x0000FFFF
#define GABE_CHIP_N_MASK 0xFFFF0000
#define GABE_DIP_REG ((volatile unsigned int *)0xFEC00518)
#define GABE_DIP_BOOT_MASK 0x00000003 /* Mask for the boot mode: */
#define GABE_DIP_USER_MASK 0x00000700 /* Mask for the user switches: */
/*
* 16-bit register controlling the key of the A2560K built-in keyboard
*/
#define GABE_MO_LEDS ((volatile unsigned long *)0xFEC0000C)
#define GABE_MO_LED_0_B 0x00000001 /* LED 0 (Close to DEL key) -- Blue ON */
#define GABE_MO_LED_0_G 0x00000002 /* LED 0 (Close to DEL key) -- Green ON */
#define GABE_MO_LED_0_R 0x00000004 /* LED 0 (Close to DEL key) -- Red ON */
#define GABE_MO_LED_1_B 0x00000008 /* LED 1 (Below #0) -- Blue ON */
#define GABE_MO_LED_1_G 0x00000010 /* LED 1 (Below #0) -- Green ON */
#define GABE_MO_LED_1_R 0x00000020 /* LED 1 (Below #0) -- Red ON */
#define GABE_MO_LED_2_B 0x00000040 /* LED 2 (above arrow) -- Blue ON */
#define GABE_MO_LED_2_G 0x00000080 /* LED 2 (above arrow) -- Green ON */
#define GABE_MO_LED_2_R 0x00000100 /* LED 2 (above arrow) -- Red ON */
#define GABE_MO_LED_3_B 0x00000200 /* LED 2 (caps lock, Rev C) -- Blue ON */
#define GABE_MO_LED_3_G 0x00000400 /* LED 2 (caps lock, Rev C) -- Green ON */
#define GABE_MO_LED_3_R 0x00000800 /* LED 2 (caps lock, Rev C) -- Red ON */
#endif

View file

@ -0,0 +1,48 @@
/**
* @file gabe_a2560u.h
*
* Define miscellaneous GABE registers
*/
#ifndef __GABE_A2560U_H
#define __GABE_A2560U_H
#define GABE_CTRL_REG ((volatile unsigned short *)0x00B00000)
#define POWER_ON_LED 0x0001
#define SDCARD_LED 0x0002
#define BUZZER_CONTROL 0x0010
#define MANUAL_RESET 0x8000 // Make sure the word "DEAD" is written in GABE_RESET_ID
#define GABE_RESET_ID ((volatile unsigned short *)0x00B00002)
#define GABE_LFSR_REG0 ((volatile unsigned short *)0x00B00004)
#define GABE_LFSR_REG1 ((volatile unsigned short *)0x00B00006)
#define RGB_LED_L ((volatile unsigned short *)0x00B00008) // Writing Only - A2560K Only - 0x__RR
#define RGB_LED_H ((volatile unsigned short *)0x00B0000A) // Writing Only - A2560K Only - 0xGGBB
#define GABE_LFSR_DATA ((volatile unsigned short *)0x00B00008) // Read Only
#define GABE_LFSR_STAT ((volatile unsigned short *)0x00B0000A) // Read Only
#define GABE_MACHINE_ID ((volatile unsigned short *)0x00B0000C) // Machine ID - Read Only
#define GABE_MACH_ID_MASK 0x0003 // 1001 = A2560U and U+
#define GABE_MEMORY_BANKS 0x00C0 // 10 = 2 MB, 11 = 4 MB
#define GABE_CPU_SPEED 0x0F00
#define GABE_CPU_ID 0xF000 // 0000 = MC68SEC000 @ 20MHz
#define FPGA_DATE_YEAR ((volatile unsigned short *)0x00B40030) // YYYY
#define FPGA_DATE_MONTHDAY ((volatile unsigned short *)0x00B40032) // MMDD
#define PCB_REV_1 ((volatile unsigned short *)0x00B40034) // Null terminated string describing the PCB
#define PCB_REV_2 ((volatile unsigned short *)0x00B40036)
#define FPGA_SUBVER ((volatile unsigned short *)0x00B40038)
#define FPGA_VER ((volatile unsigned short *)0x00B4003A)
#define FPGA_MODEL_L ((volatile unsigned short *)0x00B4003C)
#define FPGA_MODEL_H ((volatile unsigned short *)0x00B4003E)
#define GABE_CHIP_SUBREV ((volatile unsigned short *)0x00B0000E)
#define GABE_CHIP_VERSION ((volatile unsigned short *)0x00B00010)
#define GABE_CHIP_NUMBER ((volatile unsigned short *)0x00B00012)
#define GABE_DIP_REG ((volatile unsigned short *)0x00B00518)
#define GABE_DIP_BOOT_MASK 0x0003 /* Mask for the boot mode: */
#define GABE_DIP_USER_MASK 0x0300 /* Mask for the user switches: */

View file

@ -1,91 +1,14 @@
/* /**
* @file gabe_reg.h
*
* Define the various GABE control registers * Define the various GABE control registers
*/ */
#ifndef __GABE_REG_H
#define __GABE_REG_H
#include "sys_general.h" #include "sys_general.h"
#define POWER_ON_LED 0x0001
#define SDCARD_LED 0x0002
#define BUZZER_CONTROL 0x0004
#define MANUAL_RESET 0x8000 // Make sure the word "DEAD" is written in GABE_RESET_ID
#if MODEL == MODEL_FOENIX_A2560K #if MODEL == MODEL_FOENIX_A2560K
#define GABE_CTRL_REG ((volatile unsigned short *)0xFEC00000) #include "A2560K/gabe_a2560k.h"
#define GABE_RESET_ID ((volatile unsigned short *)0xFEC00002)
#define GABE_LFSR_REG0 ((volatile unsigned short *)0xFEC00004)
#define GABE_LFSR_REG1 ((volatile unsigned short *)0xFEC00006)
#define RGB_LED ((volatile unsigned int *)0xFEC00008) // Writing Only - A2560K Only - 0x__RRGGBB
#define GABE_LFSR_DATA ((volatile unsigned short *)0xFEC00008) // Read Only
#define GABE_LFSR_STAT ((volatile unsigned short *)0xFEC0000A) // Read Only
#define GABE_MACHINE_ID ((volatile unsigned short *)0xFEC0000C) // Machine ID - Read Only
#define GABE_CHIP_SUBREV ((volatile unsigned short *)0xFEC0000E)
#define GABE_CHIP_VERSION ((volatile unsigned short *)0xFEC00010)
#define GABE_CHIP_NUMBER ((volatile unsigned short *)0xFEC00012)
#define GABE_DIP_REG ((volatile unsigned short *)0xFEC00518)
#define GABE_DIP_BOOT_MASK 0x0003 /* Mask for the boot mode: */
#define GABE_DIP_USER_MASK 0x0700 /* Mask for the user switches: */
/*
* 16-bit register controlling the key of the A2560K built-in keyboard
*/
#define GABE_MO_LEDS ((volatile unsigned long *)0xFEC0000C)
#define GABE_MO_LED_0_B 0x0001 /* LED 0 (Close to DEL key) -- Blue ON */
#define GABE_MO_LED_0_G 0x0002 /* LED 0 (Close to DEL key) -- Green ON */
#define GABE_MO_LED_0_R 0x0004 /* LED 0 (Close to DEL key) -- Red ON */
#define GABE_MO_LED_1_B 0x0008 /* LED 1 (Below #0) -- Blue ON */
#define GABE_MO_LED_1_G 0x0010 /* LED 1 (Below #0) -- Green ON */
#define GABE_MO_LED_1_R 0x0020 /* LED 1 (Below #0) -- Red ON */
#define GABE_MO_LED_2_B 0x0040 /* LED 2 (above arrow) -- Blue ON */
#define GABE_MO_LED_2_G 0x0080 /* LED 2 (above arrow) -- Green ON */
#define GABE_MO_LED_2_R 0x0100 /* LED 2 (above arrow) -- Red ON */
#define GABE_MO_LED_3_B 0x0200 /* LED 2 (caps lock, Rev C) -- Blue ON */
#define GABE_MO_LED_3_G 0x0400 /* LED 2 (caps lock, Rev C) -- Green ON */
#define GABE_MO_LED_3_R 0x0800 /* LED 2 (caps lock, Rev C) -- Red ON */
#elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS #elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
#include "A2560U/gabe_a2560u.h"
#define GABE_CTRL_REG ((volatile unsigned short *)0x00B00000)
#define GABE_RESET_ID ((volatile unsigned short *)0x00B00002)
#define GABE_LFSR_REG0 ((volatile unsigned short *)0x00B00004)
#define GABE_LFSR_REG1 ((volatile unsigned short *)0x00B00006)
#define RGB_LED_L ((volatile unsigned short *)0x00B00008) // Writing Only - A2560K Only - 0x__RR
#define RGB_LED_H ((volatile unsigned short *)0x00B0000A) // Writing Only - A2560K Only - 0xGGBB
#define GABE_LFSR_DATA ((volatile unsigned short *)0x00B00008) // Read Only
#define GABE_LFSR_STAT ((volatile unsigned short *)0x00B0000A) // Read Only
#define GABE_MACHINE_ID ((volatile unsigned short *)0x00B0000C) // Machine ID - Read Only
#define GABE_MACH_ID_MASK 0x0003 // 1001 = A2560U and U+
#define GABE_MEMORY_BANKS 0x00C0 // 10 = 2 MB, 11 = 4 MB
#define GABE_CPU_SPEED 0x0F00
#define GABE_CPU_ID 0xF000 // 0000 = MC68SEC000 @ 20MHz
#define FPGA_DATE_YEAR ((volatile unsigned short *)0x00B40030) // YYYY
#define FPGA_DATE_MONTHDAY ((volatile unsigned short *)0x00B40032) // MMDD
#define PCB_REV_1 ((volatile unsigned short *)0x00B40034) // Null terminated string describing the PCB
#define PCB_REV_2 ((volatile unsigned short *)0x00B40036)
#define FPGA_SUBVER ((volatile unsigned short *)0x00B40038)
#define FPGA_VER ((volatile unsigned short *)0x00B4003A)
#define FPGA_MODEL_L ((volatile unsigned short *)0x00B4003C)
#define FPGA_MODEL_H ((volatile unsigned short *)0x00B4003E)
#define GABE_CHIP_SUBREV ((volatile unsigned short *)0x00B0000E)
#define GABE_CHIP_VERSION ((volatile unsigned short *)0x00B00010)
#define GABE_CHIP_NUMBER ((volatile unsigned short *)0x00B00012)
#define GABE_DIP_REG ((volatile unsigned short *)0x00B00518)
#define GABE_DIP_BOOT_MASK 0x0003 /* Mask for the boot mode: */
#define GABE_DIP_USER_MASK 0x0300 /* Mask for the user switches: */
#endif
#endif #endif

18472
src/mapfile

File diff suppressed because it is too large Load diff

View file

@ -29,11 +29,6 @@ void init_codec() {
*CODEC = 0x1845; // R12 *CODEC = 0x1845; // R12
codec_wait(); codec_wait();
*CODEC = 0x1DFF; // R14 - Max ADC gain left
codec_wait();
*CODEC = 0x1CFF; // R14 - Max ADC gain left
codec_wait();
codec_set_volume(0xff); codec_set_volume(0xff);
} }

View file

@ -8,7 +8,6 @@
* info = pointer to a s_MODEL_info structure to fill out * info = pointer to a s_MODEL_info structure to fill out
*/ */
void sys_get_information(p_sys_info info) { void sys_get_information(p_sys_info info) {
unsigned short machine_id = *GABE_MACHINE_ID;
info->mcp_version = VER_MAJOR; info->mcp_version = VER_MAJOR;
info->mcp_rev = VER_MINOR; info->mcp_rev = VER_MINOR;
@ -24,111 +23,64 @@ void sys_get_information(p_sys_info info) {
info->cpu = CPU_M68040; info->cpu = CPU_M68040;
info->cpu_name = "M68040V"; info->cpu_name = "M68040V";
info->has_floppy = 1; info->has_floppy = 1;
#else info->has_expansion_card = 0;
info->has_hard_drive = 1;
/* Model, CPU, and the presence of the floppy are set at compile time */ info->has_ethernet = 1;
switch (machine_id & 0x000f) { info->screens = 2;
case 0x00:
info->model = MODEL_FOENIX_FMX;
info->model_name = "Foenix FMX";
info->cpu_name = "WDC 65816";
info->has_floppy = 1;
break;
case 0x01:
info->model = MODEL_FOENIX_C256U;
info->model_name = "Foenix C256U";
info->cpu_name = "WDC 65816";
break;
case 0x05:
info->model = MODEL_FOENIX_C256U_PLUS;
info->model_name = "Foenix C256U+";
info->cpu_name = "WDC 65816";
break;
case 0x09:
info->cpu_name = "MC68SEC000";
if ((machine_id & GABE_MEMORY_BANKS) == 0xC0) {
info->system_ram_size = 0x400000;
info->model_name = "Foenix A2560U+";
info->model = MODEL_FOENIX_A2560U;
} else {
info->system_ram_size = 0x200000;
info->model_name = "Foenix A2560U";
info->model = MODEL_FOENIX_A2560U_PLUS;
}
break;
default:
/* Model is unknown */
info->model = 0xffff;
info->model_name = "Unknown";
info->cpu_name = "Unknown";
break;
}
switch ((machine_id & 0xf000) >> 12) {
case 0x00:
info->cpu = CPU_M68000;
info->cpu_name = "MC68SEC000";
break;
default:
/* Unknown CPU */
info->cpu = 0xffff;
info->cpu_name = "Unknown";
break;
}
#endif
#if MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
info->fpga_date = *FPGA_DATE_YEAR << 16 | *FPGA_DATE_MONTHDAY;
info->fpga_model = *FPGA_MODEL_H << 16 | *FPGA_MODEL_L;
info->fpga_version = *FPGA_VER;
info->fpga_subver = *FPGA_SUBVER;
info->pcb_version[0] = (*PCB_REV_1 & 0xFF00) >> 8;
info->pcb_version[1] = *PCB_REV_1 & 0xFF;
info->pcb_version[2] = (*PCB_REV_2 & 0xFF00) >> 8;
info->pcb_version[3] = 0;
#else
info->fpga_date = 0;
info->fpga_model = 0;
info->fpga_version = 0;
info->fpga_subver = 0;
info->pcb_version[0] = '?'; info->pcb_version[0] = '?';
info->pcb_version[1] = '?'; info->pcb_version[1] = '?';
info->pcb_version[2] = '?'; info->pcb_version[2] = '?';
info->pcb_version[3] = 0; info->pcb_version[3] = 0;
// Get the FPGA number and version/sub-version
info->fpga_date = 0;
info->fpga_model = (*GABE_CHIP_VERSION & GABE_CHIP_N_MASK) >> 16;
info->fpga_version = *GABE_CHIP_VERSION & GABE_CHIP_V_MASK;
info->fpga_subver = (*GABE_SUBVER_ID & GABE_CHIP_SV_MASK) >> 16;
#elif MODEL == MODEL_FOENIX_A2560U || MODEL == MODEL_FOENIX_A2560U_PLUS
// All A2560Us made are actually A2560U+s
info->model = MODEL_FOENIX_A2560U_PLUS;
info->model_name = "Foenix A2560U+";
info->cpu = CPU_M68000;
info->cpu_name = "M68000";
info->has_floppy = 0;
info->has_expansion_card = 0;
info->has_hard_drive = 1;
info->has_ethernet = 0;
info->screens = 1;
info->pcb_version[0] = '?';
info->pcb_version[1] = '?';
info->pcb_version[2] = '?';
info->pcb_version[3] = 0;
info->fpga_date = *FPGA_DATE_YEAR << 16 | *FPGA_DATE_MONTHDAY;
info->fpga_model = *FPGA_MODEL_H << 16 | *FPGA_MODEL_L;
info->fpga_version = *FPGA_VER;
info->fpga_subver = *FPGA_SUBVER;
#else
info->model = MODEL_FOENIX_A2560U_PLUS;
info->model_name = "Unknown";
info->cpu = CPU_M68000;
info->cpu_name = "Unknown";
info->has_floppy = 0;
info->has_expansion_card = 0;
info->has_hard_drive = 0;
info->has_ethernet = 0;
info->screens = 1;
info->pcb_version[0] = '?';
info->pcb_version[1] = '?';
info->pcb_version[2] = '?';
info->pcb_version[3] = 0;
info->fpga_date = 0
info->fpga_model = 0;
info->fpga_version = 0;
info->fpga_subver = 0;
#endif #endif
info->vicky_rev = 0x0000; /* TODO: get this from VICKY */
info->has_expansion_card = 0; /* TODO: figure this out by checking with GABE */
info->has_hard_drive = 0; /* TODO: figure this out by checking with GABE */
/* Set the number of screens and the presence of ethernet based on the model and expansion card */
switch (info->model) {
case MODEL_FOENIX_A2560K:
case MODEL_FOENIX_A2560X:
case MODEL_FOENIX_GENX:
/* These systems are built with 2 screens and ethernet */
info->screens = 2;
info->has_ethernet = 1;
break;
default:
/* Otherwise, we need the correct expansion card */
info->screens = 1;
info->has_ethernet = 0;
// if (info->has_expansion_card) {
// /* TODO: detect card and set screen number and/or ethernet accordingly */
// ;
// }
break;
}
} }

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 0 #define VER_MAJOR 0
#define VER_MINOR 4 #define VER_MINOR 4
#define VER_BUILD 5 #define VER_BUILD 6
#endif #endif