Updates to UART test

This commit is contained in:
Peter Weingartner 2022-04-20 21:50:51 -04:00
parent f8d62a2f66
commit 932a2addc2
7 changed files with 6471 additions and 6407 deletions

View file

@ -86,7 +86,11 @@ c_obj := $(subst .c,.o,$(c_src))
.PHONY: all $(cpu) dev fatfs snd cli
ifeq ($(MEMORY),ram)
all: foenixmcp.s68 $(cpu) dev snd cli
else
all: foenixmcp.bin $(cpu) dev snd cli
endif
$(cpu):
$(MAKE) --directory=$@
@ -106,6 +110,9 @@ 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)
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)
$(CC) -S -c -o $@ $< $(CFLAGS) $(DEFINES)

View file

@ -205,37 +205,67 @@ short cli_test_bitmap(short channel, int argc, const char * argv[]) {
return 0;
}
/**
* Test for the serial ports
*
* TEST UART [1 | 2]
*/
short cli_test_uart(short channel, int argc, const char * argv[]) {
char c;
char c, c_out;
short scan_code;
char buffer[80];
short port = 1;
short uart_index = 0;
long uart_address = 0;
uart_init(0);
uart_setbps(0, UART_9600);
uart_setlcr(0, LCR_DATABITS_8 | LCR_STOPBIT_1 | LCR_PARITY_NONE);
sprintf(buffer, "COM1: 9600, no parity, 1 stop bit, 8 data bits\nPress ESC to finish (%d).\n", UART_115200);
sys_chan_write(0, buffer, strlen(buffer));
for (;;) {
c = kbdmo_getc();
if (c != 0) {
if (c == '~') {
return 0;
}
uart_put(0, c);
if (argc > 1) {
// Get the COM port number
port = (short)cli_eval_number(argv[1]);
if (port < 1) port = 1;
if (port > 2) port = 2;
}
if (uart_has_bytes(0)) {
c = uart_get(0);
uart_index = port - 1;
if (uart_index == 0) {
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);
print(channel, buffer);
uart_init(uart_index);
uart_setbps(uart_index, UART_9600);
uart_setlcr(uart_index, LCR_DATABITS_8 | LCR_STOPBIT_1 | LCR_PARITY_NONE);
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(uart_index)) {
c = uart_get(uart_index);
if (c != 0) {
sys_chan_write_b(channel, c);
}
}
}
scan_code = sys_kbd_scancode();
} while (scan_code != 0x01);
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[]) {
volatile int x = 0;
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[]) {
volatile unsigned char * memory = 0x00000000;
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;
char message[80];
unsigned long i;
@ -291,52 +321,47 @@ short cli_mem_test(short channel, int argc, const char * argv[]) {
mem_start = 0x02000000;
mem_end = 0x06000000;
sprintf(message, "\x1B[H\x1B[2JTesting MERA memory...");
sys_chan_write(channel, message, strlen(message));
print(channel, "\x1B[H\x1B[2JTesting MERA memory...");
}
#else
sprintf(message, "MERA memory is not present on this system.\n");
sys_chan_write(channel, message, strlen(message));
print(channel, "MERA memory is not present on this system.\n");
return 0;
#endif
} else {
sys_get_info(&sys_info);
mem_end = sys_info.system_ram_size;
mem_end = sys_mem_get_ramtop();
sprintf(message, "\x1B[H\x1B[2JTesting system memory...");
sys_chan_write(channel, message, strlen(message));
print(channel, "\x1B[H\x1B[2JTesting system memory...");
}
for (i = mem_start; i < mem_end; i++) {
memory[i] = 0x55; /* Every other bit starting with 1 */
if (memory[i] != 0x55) {
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;
}
memory[i] = 0xAA; /* Every other bit starting with 0 */
if (memory[i] != 0xAA) {
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;
}
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);
sys_chan_write(channel, message, strlen(message));
print(channel, message);
return ERR_GENERAL;
}
if ((i % 1024) == 0) {
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");
sys_chan_write(channel, message, strlen(message));
print(channel, "\x1B[H\x1B[2JMemory passed basic tests.\n\n");
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},
{"SID", "SID [EXT|INT]: test the SID sound chips", sid_test},
#endif
{"UART","UART: test the serial port",cli_test_uart},
{"UART","UART [1|2]: test the serial port",cli_test_uart},
{"END", "END", 0}
};

View file

@ -23,7 +23,7 @@ volatile unsigned char * uart_get_base(short uart) {
*/
void uart_setbps(short uart, unsigned short bps_code) {
volatile unsigned char * uart_base = uart_get_base(uart);
unsigned char lcr;
if (uart_base) {
/* Enable divisor latch */
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) {
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) */
if (uart_base[UART_LCR] != lcr_bits) {
DEBUG("LCR mismatched!");
}
//}
}
}
/*
@ -63,7 +63,7 @@ void uart_setlcr(short uart, unsigned char lcr_bits) {
*/
void uart_init(short uart) {
volatile unsigned char * uart_base = uart_get_base(uart);
DEBUG("uart_init");
if (uart_base) {
/* Default to 9600 bps */
uart_setbps(uart, UART_9600);
@ -87,6 +87,7 @@ void uart_init(short uart) {
*/
short uart_has_bytes(short uart) {
volatile unsigned char * uart_base = uart_get_base(uart);
if (uart_base) {
if (uart_base[UART_LSR] & LSR_DATA_AVAIL) {
return 1;
@ -107,6 +108,7 @@ short uart_has_bytes(short uart) {
*/
void uart_put(short uart, unsigned char b) {
volatile unsigned char * uart_base = uart_get_base(uart);
if (uart_base) {
unsigned char status = 0;
@ -131,6 +133,7 @@ void uart_put(short uart, unsigned char b) {
*/
unsigned char uart_get(short uart) {
volatile unsigned char * uart_base = uart_get_base(uart);
if (uart_base) {
unsigned char status = 0;

View file

@ -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);
/**
* 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
*/

12747
src/mapfile

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 0
#define VER_MINOR 52
#define VER_BUILD 3
#define VER_BUILD 10
#endif