Updates to UART test
This commit is contained in:
parent
f8d62a2f66
commit
932a2addc2
|
@ -86,7 +86,11 @@ c_obj := $(subst .c,.o,$(c_src))
|
||||||
|
|
||||||
.PHONY: all $(cpu) dev fatfs snd cli
|
.PHONY: all $(cpu) dev fatfs snd cli
|
||||||
|
|
||||||
|
ifeq ($(MEMORY),ram)
|
||||||
all: foenixmcp.s68 $(cpu) dev snd cli
|
all: foenixmcp.s68 $(cpu) dev snd cli
|
||||||
|
else
|
||||||
|
all: foenixmcp.bin $(cpu) dev snd cli
|
||||||
|
endif
|
||||||
|
|
||||||
$(cpu):
|
$(cpu):
|
||||||
$(MAKE) --directory=$@
|
$(MAKE) --directory=$@
|
||||||
|
@ -106,6 +110,9 @@ cli:
|
||||||
foenixmcp.s68: $(c_obj) $(cpu) dev fatfs snd cli
|
foenixmcp.s68: $(c_obj) $(cpu) dev fatfs snd cli
|
||||||
$(CC) $(CFLAGS) $(DEFINES) -o foenixmcp.s68 $(c_obj) $(cpu_c_obj) $(dev_c_obj) $(fat_c_obj) $(snd_c_obj) $(cli_c_obj)
|
$(CC) $(CFLAGS) $(DEFINES) -o foenixmcp.s68 $(c_obj) $(cpu_c_obj) $(dev_c_obj) $(fat_c_obj) $(snd_c_obj) $(cli_c_obj)
|
||||||
|
|
||||||
|
foenixmcp.bin: $(c_obj) $(cpu) dev fatfs snd cli
|
||||||
|
$(CC) $(CFLAGS) $(DEFINES) -o foenixmcp.bin $(c_obj) $(cpu_c_obj) $(dev_c_obj) $(fat_c_obj) $(snd_c_obj) $(cli_c_obj)
|
||||||
|
|
||||||
%.o: %.c $(DEPS)
|
%.o: %.c $(DEPS)
|
||||||
$(CC) -S -c -o $@ $< $(CFLAGS) $(DEFINES)
|
$(CC) -S -c -o $@ $< $(CFLAGS) $(DEFINES)
|
||||||
|
|
||||||
|
|
|
@ -205,37 +205,67 @@ short cli_test_bitmap(short channel, int argc, const char * argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for the serial ports
|
||||||
|
*
|
||||||
|
* TEST UART [1 | 2]
|
||||||
|
*/
|
||||||
short cli_test_uart(short channel, int argc, const char * argv[]) {
|
short cli_test_uart(short channel, int argc, const char * argv[]) {
|
||||||
char c;
|
char c, c_out;
|
||||||
|
short scan_code;
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
|
short port = 1;
|
||||||
|
short uart_index = 0;
|
||||||
|
long uart_address = 0;
|
||||||
|
|
||||||
uart_init(0);
|
if (argc > 1) {
|
||||||
uart_setbps(0, UART_9600);
|
// Get the COM port number
|
||||||
uart_setlcr(0, LCR_DATABITS_8 | LCR_STOPBIT_1 | LCR_PARITY_NONE);
|
port = (short)cli_eval_number(argv[1]);
|
||||||
|
if (port < 1) port = 1;
|
||||||
|
if (port > 2) port = 2;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(buffer, "COM1: 9600, no parity, 1 stop bit, 8 data bits\nPress ESC to finish (%d).\n", UART_115200);
|
uart_index = port - 1;
|
||||||
sys_chan_write(0, buffer, strlen(buffer));
|
if (uart_index == 0) {
|
||||||
|
uart_address = UART1_BASE;
|
||||||
|
} else if (uart_index == 1) {
|
||||||
|
uart_address = UART2_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
sprintf(buffer, "Serial port loopback test of COM%d at 0x%08X...\n", port, uart_address);
|
||||||
c = kbdmo_getc();
|
print(channel, buffer);
|
||||||
if (c != 0) {
|
|
||||||
if (c == '~') {
|
uart_init(uart_index);
|
||||||
return 0;
|
uart_setbps(uart_index, UART_9600);
|
||||||
}
|
uart_setlcr(uart_index, LCR_DATABITS_8 | LCR_STOPBIT_1 | LCR_PARITY_NONE);
|
||||||
uart_put(0, c);
|
sprintf(buffer, "COM%d: 9600, no parity, 1 stop bit, 8 data bits\nPress ESC to finish.\n", port);
|
||||||
|
print(channel, buffer);
|
||||||
|
|
||||||
|
c_out = ' ';
|
||||||
|
do {
|
||||||
|
uart_put(0, c_out++);
|
||||||
|
if (c_out > '}') {
|
||||||
|
c_out = ' ';
|
||||||
|
uart_put(uart_index, '\r');
|
||||||
|
uart_put(uart_index, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uart_has_bytes(0)) {
|
if (uart_has_bytes(uart_index)) {
|
||||||
c = uart_get(0);
|
c = uart_get(uart_index);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
sys_chan_write_b(channel, c);
|
sys_chan_write_b(channel, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
scan_code = sys_kbd_scancode();
|
||||||
|
} while (scan_code != 0x01);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do a simple test of a kernel panic using division by zero
|
||||||
|
*/
|
||||||
short cli_test_panic(short channel, int argc, const char * argv[]) {
|
short cli_test_panic(short channel, int argc, const char * argv[]) {
|
||||||
volatile int x = 0;
|
volatile int x = 0;
|
||||||
return argc / x;
|
return argc / x;
|
||||||
|
@ -280,7 +310,7 @@ short cli_test_rtc(short channel, int argc, const char * argv[]) {
|
||||||
short cli_mem_test(short channel, int argc, const char * argv[]) {
|
short cli_mem_test(short channel, int argc, const char * argv[]) {
|
||||||
volatile unsigned char * memory = 0x00000000;
|
volatile unsigned char * memory = 0x00000000;
|
||||||
t_sys_info sys_info;
|
t_sys_info sys_info;
|
||||||
unsigned long mem_start = 0x00050000; /* TODO find out better where the kernel stop */
|
unsigned long mem_start = 0x00010000; /* TODO find out better where the kernel stop */
|
||||||
unsigned long mem_end;
|
unsigned long mem_end;
|
||||||
char message[80];
|
char message[80];
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
@ -291,52 +321,47 @@ short cli_mem_test(short channel, int argc, const char * argv[]) {
|
||||||
mem_start = 0x02000000;
|
mem_start = 0x02000000;
|
||||||
mem_end = 0x06000000;
|
mem_end = 0x06000000;
|
||||||
|
|
||||||
sprintf(message, "\x1B[H\x1B[2JTesting MERA memory...");
|
print(channel, "\x1B[H\x1B[2JTesting MERA memory...");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sprintf(message, "MERA memory is not present on this system.\n");
|
print(channel, "MERA memory is not present on this system.\n");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
sys_get_info(&sys_info);
|
mem_end = sys_mem_get_ramtop();
|
||||||
mem_end = sys_info.system_ram_size;
|
|
||||||
|
|
||||||
sprintf(message, "\x1B[H\x1B[2JTesting system memory...");
|
print(channel, "\x1B[H\x1B[2JTesting system memory...");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = mem_start; i < mem_end; i++) {
|
for (i = mem_start; i < mem_end; i++) {
|
||||||
memory[i] = 0x55; /* Every other bit starting with 1 */
|
memory[i] = 0x55; /* Every other bit starting with 1 */
|
||||||
if (memory[i] != 0x55) {
|
if (memory[i] != 0x55) {
|
||||||
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x55... read %02X at %p\n\n", memory[i], (void*)i);
|
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x55... read %02X at %p\n\n", memory[i], (void*)i);
|
||||||
sys_chan_write(channel, message, strlen(message));
|
print(channel, message);
|
||||||
return ERR_GENERAL;
|
return ERR_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory[i] = 0xAA; /* Every other bit starting with 0 */
|
memory[i] = 0xAA; /* Every other bit starting with 0 */
|
||||||
if (memory[i] != 0xAA) {
|
if (memory[i] != 0xAA) {
|
||||||
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0xAA... read %02X at %p\n\n", memory[i], (void*)i);
|
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0xAA... read %02X at %p\n\n", memory[i], (void*)i);
|
||||||
sys_chan_write(channel, message, strlen(message));
|
print(channel, message);
|
||||||
return ERR_GENERAL;
|
return ERR_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory[i] = 0x00;
|
memory[i] = 0x00;
|
||||||
if (memory[i] != 0x00) {
|
if (memory[i] != 0x00) {
|
||||||
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x00... read %02X at %p\n\nX", memory[i], (void*)i);
|
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x00... read %02X at %p\n\nX", memory[i], (void*)i);
|
||||||
sys_chan_write(channel, message, strlen(message));
|
print(channel, message);
|
||||||
return ERR_GENERAL;
|
return ERR_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i % 1024) == 0) {
|
if ((i % 1024) == 0) {
|
||||||
sprintf(message, "\x1B[H\x1B[0KMemory tested: %p", (void*)i);
|
sprintf(message, "\x1B[H\x1B[0KMemory tested: %p", (void*)i);
|
||||||
sys_chan_write(channel, message, strlen(message));
|
print(channel, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(message, "\x1B[H\x1B[2JMemory passed basic tests.\n\n");
|
print(channel, "\x1B[H\x1B[2JMemory passed basic tests.\n\n");
|
||||||
sys_chan_write(channel, message, strlen(message));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -736,7 +761,7 @@ const t_cli_test_feature cli_test_features[] = {
|
||||||
{"SEEK", "SEEK <track>: move the floppy drive head to a track", cli_test_seek},
|
{"SEEK", "SEEK <track>: move the floppy drive head to a track", cli_test_seek},
|
||||||
{"SID", "SID [EXT|INT]: test the SID sound chips", sid_test},
|
{"SID", "SID [EXT|INT]: test the SID sound chips", sid_test},
|
||||||
#endif
|
#endif
|
||||||
{"UART","UART: test the serial port",cli_test_uart},
|
{"UART","UART [1|2]: test the serial port",cli_test_uart},
|
||||||
{"END", "END", 0}
|
{"END", "END", 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ volatile unsigned char * uart_get_base(short uart) {
|
||||||
*/
|
*/
|
||||||
void uart_setbps(short uart, unsigned short bps_code) {
|
void uart_setbps(short uart, unsigned short bps_code) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
unsigned char lcr;
|
|
||||||
if (uart_base) {
|
if (uart_base) {
|
||||||
/* Enable divisor latch */
|
/* Enable divisor latch */
|
||||||
uart_base[UART_LCR] = uart_base[UART_LCR] | 0x80;
|
uart_base[UART_LCR] = uart_base[UART_LCR] | 0x80;
|
||||||
|
@ -46,13 +46,13 @@ void uart_setbps(short uart, unsigned short bps_code) {
|
||||||
*/
|
*/
|
||||||
void uart_setlcr(short uart, unsigned char lcr_bits) {
|
void uart_setlcr(short uart, unsigned char lcr_bits) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
DEBUG("uart_setlcr");
|
|
||||||
//if (uart_base) {
|
if (uart_base) {
|
||||||
uart_base[UART_LCR] = lcr_bits; /* Set the LCR bits (without the DLL bit) */
|
uart_base[UART_LCR] = lcr_bits; /* Set the LCR bits (without the DLL bit) */
|
||||||
if (uart_base[UART_LCR] != lcr_bits) {
|
if (uart_base[UART_LCR] != lcr_bits) {
|
||||||
DEBUG("LCR mismatched!");
|
DEBUG("LCR mismatched!");
|
||||||
}
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -63,7 +63,7 @@ void uart_setlcr(short uart, unsigned char lcr_bits) {
|
||||||
*/
|
*/
|
||||||
void uart_init(short uart) {
|
void uart_init(short uart) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
DEBUG("uart_init");
|
|
||||||
if (uart_base) {
|
if (uart_base) {
|
||||||
/* Default to 9600 bps */
|
/* Default to 9600 bps */
|
||||||
uart_setbps(uart, UART_9600);
|
uart_setbps(uart, UART_9600);
|
||||||
|
@ -87,6 +87,7 @@ void uart_init(short uart) {
|
||||||
*/
|
*/
|
||||||
short uart_has_bytes(short uart) {
|
short uart_has_bytes(short uart) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
|
|
||||||
if (uart_base) {
|
if (uart_base) {
|
||||||
if (uart_base[UART_LSR] & LSR_DATA_AVAIL) {
|
if (uart_base[UART_LSR] & LSR_DATA_AVAIL) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -107,6 +108,7 @@ short uart_has_bytes(short uart) {
|
||||||
*/
|
*/
|
||||||
void uart_put(short uart, unsigned char b) {
|
void uart_put(short uart, unsigned char b) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
|
|
||||||
if (uart_base) {
|
if (uart_base) {
|
||||||
unsigned char status = 0;
|
unsigned char status = 0;
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ void uart_put(short uart, unsigned char b) {
|
||||||
*/
|
*/
|
||||||
unsigned char uart_get(short uart) {
|
unsigned char uart_get(short uart) {
|
||||||
volatile unsigned char * uart_base = uart_get_base(uart);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
|
|
||||||
if (uart_base) {
|
if (uart_base) {
|
||||||
unsigned char status = 0;
|
unsigned char status = 0;
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -677,6 +677,26 @@ extern short sys_fsys_register_loader(const char * extension, p_file_loader load
|
||||||
*/
|
*/
|
||||||
extern short sys_fsys_stat(const char * path, p_file_info file);
|
extern short sys_fsys_stat(const char * path, p_file_info file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memory
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the top of system RAM... the user program must not use any
|
||||||
|
* system memory from this address and above.
|
||||||
|
*
|
||||||
|
* @return the address of the first byte of reserved system RAM (one above the last byte the user program can use)
|
||||||
|
*/
|
||||||
|
extern unsigned long sys_mem_get_ramtop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reserve a block of memory at the top of system RAM.
|
||||||
|
*
|
||||||
|
* @param bytes the number of bytes to reserve
|
||||||
|
* @return address of the first byte of the reserved block
|
||||||
|
*/
|
||||||
|
extern unsigned long sys_mem_reserve(unsigned long bytes);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Miscellaneous
|
* Miscellaneous
|
||||||
*/
|
*/
|
||||||
|
|
12747
src/mapfile
12747
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 3
|
#define VER_BUILD 10
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue