Replace bios with bootloader, don't use bootsector
Instead of using the bootsector to load a bootloader, just put the bootloader in the ROM and call it a day. It looks for a file on the SD card in the root directory named `kernel.bin` and loads it into memory. This is not a perfect solution, as the kernel will grow larger and the kernel load address will have to change. At this point I could add back the bootloader, but that is for later. Also the bootloader is just a copy of the kernel, so that can be trimmed down a lot.
This commit is contained in:
89
sw/bootloader/tests/test_main.c
Normal file
89
sw/bootloader/tests/test_main.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "devices/board_io.h"
|
||||
#include "devices/uart.h"
|
||||
#include "devices/interrupt.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
int i;
|
||||
|
||||
printf("\nStarting tests...\n\n");
|
||||
|
||||
printf("Testing hex_set_8...\n");
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (hex_set_8(i+1, i)) {
|
||||
printf("Failed to write to idx %d!\n", i);
|
||||
retval++;
|
||||
}
|
||||
if (*(uint8_t*)0x7ff0+i != i+1) {
|
||||
printf("Incorrect value at idx %d!\n", i);
|
||||
retval++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hex_set_8(0xab, 3)) {
|
||||
printf("Writing to idx 3 should fail!\n");
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
printf("Testing hex_set_16...\n");
|
||||
if (hex_set_16(0xabcd)){
|
||||
printf("Failed to write!\n");
|
||||
}
|
||||
if (*(uint16_t*)0x7ff0 != 0xabcd) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
printf("Testing hex_set_24...\n");
|
||||
if (hex_set_24(0xabcdef)){
|
||||
printf("Failed to write!\n");
|
||||
}
|
||||
if (*(uint16_t*)0x7ff0 != 0xcdef && *(uint8_t*)0x7ff2 != 0xab) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
printf("Testing hex_enable...\n");
|
||||
hex_enable(0xa5);
|
||||
if (*(uint8_t*)0x7ff3 != 0xa5) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
printf("Testing uart_txb_block...\n");
|
||||
*(uint8_t*)0x7ff5 = 0;
|
||||
uart_txb_block(0xa5);
|
||||
if (*(uint8_t*)0x7ff4 != 0xa5) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
printf("Testing uart_status...\n");
|
||||
*(uint8_t*)0x7ff5 = 0xa5;
|
||||
if (uart_status() != 0xa5) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
|
||||
printf("Testing irq_get_status...\n");
|
||||
*(uint8_t*)0x7fff = 0xa5;
|
||||
if (irq_get_status() != 0xa5) {
|
||||
printf("Incorrect value!\n", i);
|
||||
retval++;
|
||||
}
|
||||
printf("Done!\n\n");
|
||||
|
||||
|
||||
return retval != 0;
|
||||
}
|
||||
Reference in New Issue
Block a user