SuperIO Test Tweaks
Changes to UART, MIDI, and FDC code and tests to match a possible fix to the FPGA.
This commit is contained in:
parent
2581b754d6
commit
b53a2d92d4
Binary file not shown.
|
@ -807,26 +807,37 @@ short midi_loop_test(short channel, int argc, const char * argv[]) {
|
|||
unsigned short scancode = 0;
|
||||
unsigned char output;
|
||||
|
||||
midi_init();
|
||||
short result = midi_init();
|
||||
if (result) {
|
||||
sprintf(message, "Unable to initialize MIDI ports: %s\n", err_message(result));
|
||||
print(channel, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(message, "Plug a MIDI loopback cable between MIDI IN and MIDI OUT.\nThen press '1' to start.\n");
|
||||
sys_chan_write(channel, message, strlen(message));
|
||||
|
||||
sprintf(message, "Press ESC to exit test.\n");
|
||||
sys_chan_write(channel, message, strlen(message));
|
||||
print(channel, "Plug a MIDI loopback cable between MIDI IN and MIDI OUT.\nThen press '1' to start.\n");
|
||||
print(channel, "Press ESC to exit test.\n");
|
||||
|
||||
while (sys_kbd_scancode() != 0x02) ;
|
||||
|
||||
output = 1;
|
||||
while (scancode != 0x01) {
|
||||
sprintf(message, "Sending: ");
|
||||
sys_chan_write(channel, message, strlen(message));
|
||||
midi_put(output);
|
||||
print(channel, "Sending: ");
|
||||
result = midi_put(output);
|
||||
if (result) {
|
||||
sprintf(message, "Unable to write a byte to the MIDI ports: %s\n", err_message(result));
|
||||
print(channel, message);
|
||||
return 0;
|
||||
}
|
||||
sprintf(message, "%02X --> ", output);
|
||||
sys_chan_write(channel, message, strlen(message));
|
||||
|
||||
unsigned char input = midi_get_poll();
|
||||
sprintf(message, "%02X\n", input);
|
||||
short input = midi_get_poll();
|
||||
if (input < 0) {
|
||||
sprintf(message, "Unable to read a byte to the MIDI ports: %s\n", err_message(input));
|
||||
print(channel, message);
|
||||
return 0;
|
||||
}
|
||||
sprintf(message, "%02X\n", (unsigned char)input);
|
||||
sys_chan_write(channel, message, strlen(message));
|
||||
|
||||
scancode = sys_kbd_scancode();
|
||||
|
|
|
@ -216,7 +216,7 @@ short cli_test_uart(short channel, int argc, const char * argv[]) {
|
|||
char buffer[80];
|
||||
short port = 1;
|
||||
short uart_index = 0;
|
||||
long uart_address = 0;
|
||||
unsigned long uart_address = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
// Get the COM port number
|
||||
|
@ -226,11 +226,7 @@ short cli_test_uart(short channel, int argc, const char * argv[]) {
|
|||
}
|
||||
|
||||
uart_index = port - 1;
|
||||
if (uart_index == 0) {
|
||||
uart_address = UART1_BASE;
|
||||
} else if (uart_index == 1) {
|
||||
uart_address = UART2_BASE;
|
||||
}
|
||||
uart_address = (unsigned long)uart_get_base(uart_index);
|
||||
|
||||
sprintf(buffer, "Serial port loopback test of COM%d at 0x%08X...\n", port, uart_address);
|
||||
print(channel, buffer);
|
||||
|
@ -431,29 +427,22 @@ short cli_test_fdc(short screen, int argc, const char * argv[]) {
|
|||
return result;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
for (i = 0; i < 512; i++) {
|
||||
buffer[i] = 0xAA;
|
||||
}
|
||||
|
||||
n = bdev_read(BDEV_FDC, 0, buffer, 512);
|
||||
if (n < 0) {
|
||||
dump_buffer(screen, buffer, 512, 1);
|
||||
err_print(screen, "Unable to read MBR", n);
|
||||
bdev_ioctrl(BDEV_FDC, FDC_CTRL_MOTOR_OFF, 0, 0);
|
||||
return n;
|
||||
}
|
||||
|
||||
dump_buffer(screen, buffer, 512, 1);
|
||||
|
||||
print(screen, "\n\n");
|
||||
|
||||
scancode = sys_kbd_scancode();
|
||||
if (scancode == 0x01) {
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 512; i++) {
|
||||
buffer[i] = 0xAA;
|
||||
}
|
||||
|
||||
n = bdev_read(BDEV_FDC, 0, buffer, 512);
|
||||
if (n < 0) {
|
||||
dump_buffer(screen, buffer, 512, 1);
|
||||
err_print(screen, "Unable to read MBR", n);
|
||||
bdev_ioctrl(BDEV_FDC, FDC_CTRL_MOTOR_OFF, 0, 0);
|
||||
return n;
|
||||
}
|
||||
|
||||
dump_buffer(screen, buffer, 512, 1);
|
||||
|
||||
print(screen, "\n\n");
|
||||
|
||||
bdev_ioctrl(BDEV_FDC, FDC_CTRL_MOTOR_OFF, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -204,7 +204,7 @@ void fdc_delay(int jiffies) {
|
|||
* ptr = pointer to the byte position to fill
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, negative number is an error
|
||||
* 0 on success, 1 = the controller has dropped out of execution mode, negative number is an error
|
||||
*/
|
||||
short fdc_in(unsigned char *ptr) {
|
||||
unsigned char msr, data;
|
||||
|
@ -213,6 +213,12 @@ short fdc_in(unsigned char *ptr) {
|
|||
step = 1;
|
||||
for (i = 0; i < fdc_timeout; i += step) {
|
||||
msr = *FDC_MSR & (FDC_MSR_DIO | FDC_MSR_RQM);
|
||||
|
||||
if ((msr & FDC_MSR_NONDMA) == 0) {
|
||||
// The controller has left execution mode... go to get the status bytes
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (msr == (FDC_MSR_DIO | FDC_MSR_RQM)) {
|
||||
data = *FDC_DATA;
|
||||
if (ptr)
|
||||
|
@ -233,6 +239,43 @@ short fdc_in(unsigned char *ptr) {
|
|||
return DEV_TIMEOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a status/response byte from the floppy drive controller FIFO
|
||||
*
|
||||
* Inputs:
|
||||
* ptr = pointer to the byte position to fill
|
||||
*
|
||||
* Returns:
|
||||
* 0 on success, negative number is an error
|
||||
*/
|
||||
short fdc_stat_in(unsigned char *ptr) {
|
||||
unsigned char msr, data;
|
||||
short step, i;
|
||||
|
||||
step = 1;
|
||||
for (i = 0; i < fdc_timeout; i += step) {
|
||||
msr = *FDC_MSR & (FDC_MSR_DIO | FDC_MSR_RQM);
|
||||
|
||||
if (msr == (FDC_MSR_DIO | FDC_MSR_RQM)) {
|
||||
data = *FDC_DATA;
|
||||
if (ptr)
|
||||
*ptr = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msr == FDC_MSR_RQM) {
|
||||
log(LOG_ERROR, "fdc_stat_in: ready for output during input");
|
||||
return ERR_GENERAL;
|
||||
}
|
||||
|
||||
step += step;
|
||||
fdc_delay(step);
|
||||
}
|
||||
|
||||
log(LOG_ERROR, "fdc_stat_in: timeout");
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Put a byte to the floppy drive controller FIFO
|
||||
*
|
||||
|
@ -544,8 +587,6 @@ short fdc_reset() {
|
|||
|
||||
TRACE("fdc_reset");
|
||||
|
||||
log(LOG_ERROR, "FDC_RESET");
|
||||
|
||||
/* Reset the controller */
|
||||
*FDC_DOR = 0;
|
||||
target_time = timers_jiffies() + 2;
|
||||
|
@ -676,7 +717,13 @@ short fdc_command(p_fdc_trans transaction) {
|
|||
log(LOG_ERROR, "fdc_command: timeout getting data");
|
||||
return result;
|
||||
}
|
||||
//sys_chan_write(0, ".", 1);
|
||||
if (result == 0) {
|
||||
sys_chan_write_b(0, '.');
|
||||
} else {
|
||||
// We dropped out of execution mode... go get status bytes
|
||||
log(LOG_ERROR, "Dropped out of execution mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -687,7 +734,7 @@ short fdc_command(p_fdc_trans transaction) {
|
|||
/* Result phase: read the result bytes */
|
||||
|
||||
for (i = 0; i < transaction->result_count; i++) {
|
||||
if ((result = fdc_in(&transaction->results[i])) < 0) {
|
||||
if ((result = fdc_stat_in(&transaction->results[i])) < 0) {
|
||||
log(LOG_ERROR, "fdc_command: timeout getting results");
|
||||
return result;
|
||||
}
|
||||
|
@ -868,6 +915,7 @@ short fdc_read(long lba, unsigned char * buffer, short size) {
|
|||
t_fdc_trans trans;
|
||||
unsigned char head, cylinder, sector;
|
||||
short result, i;
|
||||
char message[80];
|
||||
|
||||
TRACE("fdc_read");
|
||||
|
||||
|
@ -896,14 +944,16 @@ short fdc_read(long lba, unsigned char * buffer, short size) {
|
|||
while (trans.retries > 0) {
|
||||
result = fdc_command(&trans); /* Issue the transaction */
|
||||
if ((result == 0)) { // && ((trans.results[0] & 0xC0) == 0)) {
|
||||
sprintf(message, "fdc_read: success ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
||||
log(LOG_ERROR, message);
|
||||
return size;
|
||||
} else {
|
||||
if (result != 0) {
|
||||
log_num(LOG_ERROR, "fdc_read: retry ", result);
|
||||
sprintf(message, "fdc_read: retry ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
||||
log(LOG_ERROR, message);
|
||||
} else {
|
||||
char buffer[80];
|
||||
sprintf(buffer, "ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
||||
log(LOG_ERROR, buffer);
|
||||
sprintf(message, "ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
||||
log(LOG_ERROR, message);
|
||||
}
|
||||
}
|
||||
fdc_init();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#if MODEL == MODEL_FOENIX_A2560K
|
||||
|
||||
/** Timeout for waiting on the MIDI interface */
|
||||
const long midi_timeout = 10;
|
||||
const long midi_timeout = 60;
|
||||
|
||||
/**
|
||||
* Wait for data to be ready to read...
|
||||
|
@ -40,7 +40,7 @@ short midi_can_read() {
|
|||
short midi_can_write() {
|
||||
long target = timers_jiffies() + midi_timeout;
|
||||
do {
|
||||
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) == 0) {
|
||||
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) != 0) {
|
||||
// The transmit buffer is empty
|
||||
return 1;
|
||||
}
|
||||
|
@ -57,13 +57,9 @@ short midi_can_write() {
|
|||
* @return 0 on success, any other number is an error
|
||||
*/
|
||||
short midi_command(unsigned char cmd) {
|
||||
if (midi_can_write()) {
|
||||
*MIDI_CMD = cmd;
|
||||
return 0;
|
||||
} else {
|
||||
// We got a timeout
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
/* Send the byte */
|
||||
*MIDI_CMD = cmd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,12 +71,10 @@ short midi_init() {
|
|||
unsigned char dummy;
|
||||
short result;
|
||||
|
||||
print(0, "midi_init: ");
|
||||
|
||||
// result = midi_command(0xFF); /* Reset the MIDI port */
|
||||
// if (result != 0) {
|
||||
// return result;
|
||||
// }
|
||||
result = midi_command(0xFF); /* Reset the MIDI port */
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// /* Wait for the ACK */
|
||||
// for (dummy = 0; dummy != 0xFE; ) {
|
||||
|
@ -88,32 +82,24 @@ short midi_init() {
|
|||
// dummy = *MIDI_DATA;
|
||||
// } else {
|
||||
// // There was a timeout
|
||||
// print(0, "X\n");
|
||||
// return DEV_TIMEOUT;
|
||||
// }
|
||||
// }
|
||||
|
||||
print(0, "1");
|
||||
|
||||
result = midi_command(0x3F); /* Switch the MIDI port into UART mode */
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// /* Wait for the ACK */
|
||||
// do {
|
||||
// if (midi_can_read()) {
|
||||
// dummy = *MIDI_DATA;
|
||||
// print_hex_8(0, dummy);
|
||||
// print(0, "\n");
|
||||
// } else {
|
||||
// // There was a timeout
|
||||
// print(0, "X\n");
|
||||
// return DEV_TIMEOUT;
|
||||
// }
|
||||
// } while (dummy != 0xFE);
|
||||
|
||||
print(0, "2\n");
|
||||
/* Wait for the ACK */
|
||||
do {
|
||||
if (midi_can_read()) {
|
||||
dummy = *MIDI_DATA;
|
||||
} else {
|
||||
// There was a timeout
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
} while (dummy != 0xFE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -129,10 +115,10 @@ short midi_put(unsigned char b) {
|
|||
/* Send the byte */
|
||||
*MIDI_DATA = b;
|
||||
return 0;
|
||||
} else {
|
||||
// There was a timeout
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
|
||||
// There was a timeout
|
||||
return DEV_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,9 +126,9 @@ short midi_put(unsigned char b) {
|
|||
*
|
||||
* @return the byte read
|
||||
*/
|
||||
char midi_get_poll() {
|
||||
short midi_get_poll() {
|
||||
if (midi_can_read()) {
|
||||
return *MIDI_DATA;
|
||||
return ((short)*MIDI_DATA & 0x00ff);
|
||||
} else {
|
||||
// There was a timeout
|
||||
return DEV_TIMEOUT;
|
||||
|
|
|
@ -25,6 +25,6 @@ extern short midi_put(unsigned char b);
|
|||
*
|
||||
* @return the byte read (-1 on error)
|
||||
*/
|
||||
extern char midi_get_poll();
|
||||
extern short midi_get_poll();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
#ifndef __UART_H
|
||||
#define __UART_H
|
||||
|
||||
/**
|
||||
* Returns the address of the first register in the given UART
|
||||
*
|
||||
* @param uart the number of the UART 0 = COM1, 1 = COM2
|
||||
*/
|
||||
extern volatile unsigned char * uart_get_base(short uart);
|
||||
|
||||
/*
|
||||
* Set the data transfer speed
|
||||
*
|
||||
|
|
|
@ -202,13 +202,13 @@ void initialize() {
|
|||
log(LOG_INFO, "SDC driver installed.");
|
||||
}
|
||||
|
||||
// #if MODEL == MODEL_FOENIX_A2560K
|
||||
// if (res = fdc_install()) {
|
||||
// log_num(LOG_ERROR, "FAILED: Floppy drive initialization", res);
|
||||
// } else {
|
||||
// log(LOG_INFO, "Floppy drive initialized.");
|
||||
// }
|
||||
// #endif
|
||||
#if MODEL == MODEL_FOENIX_A2560K
|
||||
if (res = fdc_install()) {
|
||||
log_num(LOG_ERROR, "FAILED: Floppy drive initialization", res);
|
||||
} else {
|
||||
log(LOG_INFO, "Floppy drive initialized.");
|
||||
}
|
||||
#endif
|
||||
|
||||
// At this point, we should be able to call into to console to print to the screens
|
||||
|
||||
|
|
17166
src/mapfile
17166
src/mapfile
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,6 @@
|
|||
|
||||
#define VER_MAJOR 0
|
||||
#define VER_MINOR 52
|
||||
#define VER_BUILD 26
|
||||
#define VER_BUILD 30
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue