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 short scancode = 0;
|
||||||
unsigned char output;
|
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");
|
print(channel, "Plug a MIDI loopback cable between MIDI IN and MIDI OUT.\nThen press '1' to start.\n");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
print(channel, "Press ESC to exit test.\n");
|
||||||
|
|
||||||
sprintf(message, "Press ESC to exit test.\n");
|
|
||||||
sys_chan_write(channel, message, strlen(message));
|
|
||||||
|
|
||||||
while (sys_kbd_scancode() != 0x02) ;
|
while (sys_kbd_scancode() != 0x02) ;
|
||||||
|
|
||||||
output = 1;
|
output = 1;
|
||||||
while (scancode != 0x01) {
|
while (scancode != 0x01) {
|
||||||
sprintf(message, "Sending: ");
|
print(channel, "Sending: ");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
result = midi_put(output);
|
||||||
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);
|
sprintf(message, "%02X --> ", output);
|
||||||
sys_chan_write(channel, message, strlen(message));
|
sys_chan_write(channel, message, strlen(message));
|
||||||
|
|
||||||
unsigned char input = midi_get_poll();
|
short input = midi_get_poll();
|
||||||
sprintf(message, "%02X\n", input);
|
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));
|
sys_chan_write(channel, message, strlen(message));
|
||||||
|
|
||||||
scancode = sys_kbd_scancode();
|
scancode = sys_kbd_scancode();
|
||||||
|
|
|
@ -216,7 +216,7 @@ short cli_test_uart(short channel, int argc, const char * argv[]) {
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
short port = 1;
|
short port = 1;
|
||||||
short uart_index = 0;
|
short uart_index = 0;
|
||||||
long uart_address = 0;
|
unsigned long uart_address = 0;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
// Get the COM port number
|
// Get the COM port number
|
||||||
|
@ -226,11 +226,7 @@ short cli_test_uart(short channel, int argc, const char * argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uart_index = port - 1;
|
uart_index = port - 1;
|
||||||
if (uart_index == 0) {
|
uart_address = (unsigned long)uart_get_base(uart_index);
|
||||||
uart_address = UART1_BASE;
|
|
||||||
} else if (uart_index == 1) {
|
|
||||||
uart_address = UART2_BASE;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(buffer, "Serial port loopback test of COM%d at 0x%08X...\n", port, uart_address);
|
sprintf(buffer, "Serial port loopback test of COM%d at 0x%08X...\n", port, uart_address);
|
||||||
print(channel, buffer);
|
print(channel, buffer);
|
||||||
|
@ -431,7 +427,6 @@ short cli_test_fdc(short screen, int argc, const char * argv[]) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
|
||||||
for (i = 0; i < 512; i++) {
|
for (i = 0; i < 512; i++) {
|
||||||
buffer[i] = 0xAA;
|
buffer[i] = 0xAA;
|
||||||
}
|
}
|
||||||
|
@ -448,12 +443,6 @@ short cli_test_fdc(short screen, int argc, const char * argv[]) {
|
||||||
|
|
||||||
print(screen, "\n\n");
|
print(screen, "\n\n");
|
||||||
|
|
||||||
scancode = sys_kbd_scancode();
|
|
||||||
if (scancode == 0x01) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bdev_ioctrl(BDEV_FDC, FDC_CTRL_MOTOR_OFF, 0, 0);
|
bdev_ioctrl(BDEV_FDC, FDC_CTRL_MOTOR_OFF, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -204,7 +204,7 @@ void fdc_delay(int jiffies) {
|
||||||
* ptr = pointer to the byte position to fill
|
* ptr = pointer to the byte position to fill
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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) {
|
short fdc_in(unsigned char *ptr) {
|
||||||
unsigned char msr, data;
|
unsigned char msr, data;
|
||||||
|
@ -213,6 +213,12 @@ short fdc_in(unsigned char *ptr) {
|
||||||
step = 1;
|
step = 1;
|
||||||
for (i = 0; i < fdc_timeout; i += step) {
|
for (i = 0; i < fdc_timeout; i += step) {
|
||||||
msr = *FDC_MSR & (FDC_MSR_DIO | FDC_MSR_RQM);
|
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)) {
|
if (msr == (FDC_MSR_DIO | FDC_MSR_RQM)) {
|
||||||
data = *FDC_DATA;
|
data = *FDC_DATA;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
|
@ -233,6 +239,43 @@ short fdc_in(unsigned char *ptr) {
|
||||||
return DEV_TIMEOUT;
|
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
|
* Put a byte to the floppy drive controller FIFO
|
||||||
*
|
*
|
||||||
|
@ -544,8 +587,6 @@ short fdc_reset() {
|
||||||
|
|
||||||
TRACE("fdc_reset");
|
TRACE("fdc_reset");
|
||||||
|
|
||||||
log(LOG_ERROR, "FDC_RESET");
|
|
||||||
|
|
||||||
/* Reset the controller */
|
/* Reset the controller */
|
||||||
*FDC_DOR = 0;
|
*FDC_DOR = 0;
|
||||||
target_time = timers_jiffies() + 2;
|
target_time = timers_jiffies() + 2;
|
||||||
|
@ -676,7 +717,13 @@ short fdc_command(p_fdc_trans transaction) {
|
||||||
log(LOG_ERROR, "fdc_command: timeout getting data");
|
log(LOG_ERROR, "fdc_command: timeout getting data");
|
||||||
return result;
|
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;
|
break;
|
||||||
|
|
||||||
|
@ -687,7 +734,7 @@ short fdc_command(p_fdc_trans transaction) {
|
||||||
/* Result phase: read the result bytes */
|
/* Result phase: read the result bytes */
|
||||||
|
|
||||||
for (i = 0; i < transaction->result_count; i++) {
|
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");
|
log(LOG_ERROR, "fdc_command: timeout getting results");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -868,6 +915,7 @@ short fdc_read(long lba, unsigned char * buffer, short size) {
|
||||||
t_fdc_trans trans;
|
t_fdc_trans trans;
|
||||||
unsigned char head, cylinder, sector;
|
unsigned char head, cylinder, sector;
|
||||||
short result, i;
|
short result, i;
|
||||||
|
char message[80];
|
||||||
|
|
||||||
TRACE("fdc_read");
|
TRACE("fdc_read");
|
||||||
|
|
||||||
|
@ -896,14 +944,16 @@ short fdc_read(long lba, unsigned char * buffer, short size) {
|
||||||
while (trans.retries > 0) {
|
while (trans.retries > 0) {
|
||||||
result = fdc_command(&trans); /* Issue the transaction */
|
result = fdc_command(&trans); /* Issue the transaction */
|
||||||
if ((result == 0)) { // && ((trans.results[0] & 0xC0) == 0)) {
|
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;
|
return size;
|
||||||
} else {
|
} else {
|
||||||
if (result != 0) {
|
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 {
|
} else {
|
||||||
char buffer[80];
|
sprintf(message, "ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
||||||
sprintf(buffer, "ST0 = %02x ST1 = %02x ST2 = %02x", trans.results[0], trans.results[1], trans.results[2]);
|
log(LOG_ERROR, message);
|
||||||
log(LOG_ERROR, buffer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fdc_init();
|
fdc_init();
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#if MODEL == MODEL_FOENIX_A2560K
|
#if MODEL == MODEL_FOENIX_A2560K
|
||||||
|
|
||||||
/** Timeout for waiting on the MIDI interface */
|
/** 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...
|
* Wait for data to be ready to read...
|
||||||
|
@ -40,7 +40,7 @@ short midi_can_read() {
|
||||||
short midi_can_write() {
|
short midi_can_write() {
|
||||||
long target = timers_jiffies() + midi_timeout;
|
long target = timers_jiffies() + midi_timeout;
|
||||||
do {
|
do {
|
||||||
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) == 0) {
|
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) != 0) {
|
||||||
// The transmit buffer is empty
|
// The transmit buffer is empty
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -57,13 +57,9 @@ short midi_can_write() {
|
||||||
* @return 0 on success, any other number is an error
|
* @return 0 on success, any other number is an error
|
||||||
*/
|
*/
|
||||||
short midi_command(unsigned char cmd) {
|
short midi_command(unsigned char cmd) {
|
||||||
if (midi_can_write()) {
|
/* Send the byte */
|
||||||
*MIDI_CMD = cmd;
|
*MIDI_CMD = cmd;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
// We got a timeout
|
|
||||||
return DEV_TIMEOUT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,12 +71,10 @@ short midi_init() {
|
||||||
unsigned char dummy;
|
unsigned char dummy;
|
||||||
short result;
|
short result;
|
||||||
|
|
||||||
print(0, "midi_init: ");
|
result = midi_command(0xFF); /* Reset the MIDI port */
|
||||||
|
if (result != 0) {
|
||||||
// result = midi_command(0xFF); /* Reset the MIDI port */
|
return result;
|
||||||
// if (result != 0) {
|
}
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /* Wait for the ACK */
|
// /* Wait for the ACK */
|
||||||
// for (dummy = 0; dummy != 0xFE; ) {
|
// for (dummy = 0; dummy != 0xFE; ) {
|
||||||
|
@ -88,32 +82,24 @@ short midi_init() {
|
||||||
// dummy = *MIDI_DATA;
|
// dummy = *MIDI_DATA;
|
||||||
// } else {
|
// } else {
|
||||||
// // There was a timeout
|
// // There was a timeout
|
||||||
// print(0, "X\n");
|
|
||||||
// return DEV_TIMEOUT;
|
// return DEV_TIMEOUT;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
print(0, "1");
|
|
||||||
|
|
||||||
result = midi_command(0x3F); /* Switch the MIDI port into UART mode */
|
result = midi_command(0x3F); /* Switch the MIDI port into UART mode */
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* Wait for the ACK */
|
/* Wait for the ACK */
|
||||||
// do {
|
do {
|
||||||
// if (midi_can_read()) {
|
if (midi_can_read()) {
|
||||||
// dummy = *MIDI_DATA;
|
dummy = *MIDI_DATA;
|
||||||
// print_hex_8(0, dummy);
|
} else {
|
||||||
// print(0, "\n");
|
// There was a timeout
|
||||||
// } else {
|
return DEV_TIMEOUT;
|
||||||
// // There was a timeout
|
}
|
||||||
// print(0, "X\n");
|
} while (dummy != 0xFE);
|
||||||
// return DEV_TIMEOUT;
|
|
||||||
// }
|
|
||||||
// } while (dummy != 0xFE);
|
|
||||||
|
|
||||||
print(0, "2\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -129,20 +115,20 @@ short midi_put(unsigned char b) {
|
||||||
/* Send the byte */
|
/* Send the byte */
|
||||||
*MIDI_DATA = b;
|
*MIDI_DATA = b;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// There was a timeout
|
// There was a timeout
|
||||||
return DEV_TIMEOUT;
|
return DEV_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a byte from the MIDI port
|
* Get a byte from the MIDI port
|
||||||
*
|
*
|
||||||
* @return the byte read
|
* @return the byte read
|
||||||
*/
|
*/
|
||||||
char midi_get_poll() {
|
short midi_get_poll() {
|
||||||
if (midi_can_read()) {
|
if (midi_can_read()) {
|
||||||
return *MIDI_DATA;
|
return ((short)*MIDI_DATA & 0x00ff);
|
||||||
} else {
|
} else {
|
||||||
// There was a timeout
|
// There was a timeout
|
||||||
return DEV_TIMEOUT;
|
return DEV_TIMEOUT;
|
||||||
|
|
|
@ -25,6 +25,6 @@ extern short midi_put(unsigned char b);
|
||||||
*
|
*
|
||||||
* @return the byte read (-1 on error)
|
* @return the byte read (-1 on error)
|
||||||
*/
|
*/
|
||||||
extern char midi_get_poll();
|
extern short midi_get_poll();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,6 +5,13 @@
|
||||||
#ifndef __UART_H
|
#ifndef __UART_H
|
||||||
#define __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
|
* Set the data transfer speed
|
||||||
*
|
*
|
||||||
|
|
|
@ -202,13 +202,13 @@ void initialize() {
|
||||||
log(LOG_INFO, "SDC driver installed.");
|
log(LOG_INFO, "SDC driver installed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// #if MODEL == MODEL_FOENIX_A2560K
|
#if MODEL == MODEL_FOENIX_A2560K
|
||||||
// if (res = fdc_install()) {
|
if (res = fdc_install()) {
|
||||||
// log_num(LOG_ERROR, "FAILED: Floppy drive initialization", res);
|
log_num(LOG_ERROR, "FAILED: Floppy drive initialization", res);
|
||||||
// } else {
|
} else {
|
||||||
// log(LOG_INFO, "Floppy drive initialized.");
|
log(LOG_INFO, "Floppy drive initialized.");
|
||||||
// }
|
}
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
// At this point, we should be able to call into to console to print to the screens
|
// 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_MAJOR 0
|
||||||
#define VER_MINOR 52
|
#define VER_MINOR 52
|
||||||
#define VER_BUILD 26
|
#define VER_BUILD 30
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue