Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add 16 tests for MMU DTLB - not passing yet

  • Loading branch information...
commit 80185247b9d6cdc39fd6f48a75d3d9a210049ae0 1 parent 7a050bd
@fallen authored
View
10 software/bios/Makefile
@@ -1,10 +1,11 @@
MMDIR=../..
include $(MMDIR)/software/include.mak
-OBJECTS=crt0.o isr.o main.o unlzma.o boot.o boot-helper.o splash.o
+OBJECTS=crt0.o isr.o main.o unlzma.o boot.o boot-helper.o splash.o dtlb_load_test.o
SEGMENTS=-j .text -j .data -j .rodata
LIBS=$(MMDIR)/software/libhpdmc/libhpdmc.a $(MMDIR)/software/libbase/libbase-light.a \
$(MMDIR)/software/libhal/libhal.a $(MMDIR)/software/libnet/libnet.a
+CFLAGS += -g
all: bios.bin bios-rescue.bin
@@ -21,6 +22,13 @@ bios-rescue.elf: linker-rescue.ld $(OBJECTS) $(LIBS)
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) -L$(MMDIR)/software/libhpdmc -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libhal -L$(MMDIR)/software/libnet --start-group -lhpdmc -lbase-light -lhal -lnet --end-group
chmod -x $@
+mmu_test_gen: mmu_test_gen.c
+ gcc $< -o $@
+ chmod +x $@
+
+dtlb_load_test.c: mmu_test_gen
+ ./$< > $@
+
$(MMDIR)/software/libhpdmc/libhpdmc.a:
make -C $(MMDIR)/software/libhpdmc/
View
3  software/bios/isr.c
@@ -30,10 +30,11 @@ void isr()
if(irqs & IRQ_UART)
uart_isr();
-
+/*
if(irqs & IRQ_TMU)
tmu_isr();
if(irqs & IRQ_USB)
usb_isr();
+*/
}
View
10 software/bios/main.c
@@ -449,7 +449,7 @@ static char *get_token(char **str)
static void dtlbtest(void)
{
- volatile unsigned int *addr;
+/* volatile unsigned int *addr;
register unsigned int value = 0x43;
puts("Starting DTLB tests...");
@@ -499,6 +499,10 @@ static void dtlbtest(void)
puts("FAILURE");
printf("value contains %08X\n", value);
+*/
+ //Running more dtlb load tests
+ dtlb_load_test();
+
}
static void do_command(char *c)
@@ -698,8 +702,8 @@ int main(int i, char **c)
putsnonl(banner);
crcbios();
brd_init();
- tmu_init(); /* < for hardware-accelerated scrolling */
- usb_init();
+// tmu_init(); /* < for hardware-accelerated scrolling */
+// usb_init();
ukb_init();
if(rescue)
View
124 software/bios/mmu_test_gen.c
@@ -0,0 +1,124 @@
+/* MMU test generator
+ * Author : Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <stdio.h>
+
+static inline void generate_test(int i, int j) {
+ int k;
+
+ puts("asm volatile(");
+ puts("\t\"xor r11, r11, r11\\n\\t\"");
+ puts("\t\"ori r11, r11, 0x11\\n\\t\"");
+ puts("\t\"wcsr tlbctrl, r11\\n\\t\"");
+ puts("\t\"xor r0, r0, r0\\n\\t\"");
+ puts("\t\"xor r0, r0, r0\\n\\t\"");
+ puts("\t\"xor r0, r0, r0\\n\\t\"");
+ for (k = 0 ; k < 6 ; k++) {
+ if (k == i)
+ printf("\t\"sw (%2+0), %1");
+ else if(k == j)
+ printf("\t\"lw %0, (%2+0)");
+ else
+ printf("\t\"xor r0, r0, r0");
+ if (k != 5)
+ printf("\\n\\t");
+ puts("\"");
+ }
+
+ puts(": \"=r\"(value_verif) : \"r\"(value), \"r\"(addr) :\"r11\"\n);");
+
+}
+
+int main(void) {
+
+ puts("#include <hal/mmu.h>\n");
+ puts("void dtlb_load_test(void) {\n");
+
+ puts(
+ "char a, b, c, d;\n"
+ "// map vaddr 0x4400 1000 to paddr 0x4400 0000\n"
+ "register unsigned int value, addr, value_verif, stack;\n"
+ "int success, failure;\n"
+ "mmu_dtlb_map(0x44001000, 0x44000000);\n" // for the test
+ "mmu_dtlb_map(0x873000, 0x873000);\n"
+ "mmu_dtlb_map(0x872000, 0x872000);\n"
+ "mmu_dtlb_map(0x871000, 0x871000);\n"
+ "mmu_dtlb_map(0x870000, 0x870000);\n"
+ "mmu_dtlb_map(0x86F000, 0x86F000);\n" // for dtlb_load_test and constants
+ "mmu_dtlb_map(0x86E000, 0x86E000);\n" // for constants
+ "mmu_dtlb_map(0x86D000, 0x86D000);\n"
+ "mmu_dtlb_map(0x86C000, 0x86C000);\n"
+ "mmu_dtlb_map(0x86B000, 0x86B000);\n"
+ "mmu_dtlb_map(0x86A000, 0x86A000);\n"
+ "mmu_dtlb_map(0x869000, 0x869000);\n"
+ "mmu_dtlb_map(0x868000, 0x868000);\n"
+ "mmu_dtlb_map(0x867000, 0x867000);\n" // for isr and uart_isr
+ "mmu_dtlb_map(0x866000, 0x866000);\n" // for printf
+ //"mmu_dtlb_map(0x866000, 0x866000);\n" // for the fun
+ "mmu_dtlb_map(0x865000, 0x865000);\n" // for puts
+ "mmu_dtlb_map(0x864000, 0x864000);\n" // for dtlb_load_test
+ "mmu_dtlb_map(0x863000, 0x863000);\n"
+ "mmu_dtlb_map(0x862000, 0x862000);\n"
+ "mmu_dtlb_map(0x861000, 0x861000);\n"
+ "mmu_dtlb_map(0x860000, 0x860000);\n"
+ "mmu_dtlb_map(0xe0000000, 0xe0000000);\n"
+ "asm volatile(\"mv %0, sp\" : \"=r\"(stack) :: );\n"
+ "mmu_dtlb_map(stack, stack);\n"
+ "mmu_dtlb_map(stack+0x1000, stack+0x1000);\n"
+ "mmu_dtlb_map(stack-0x1000, stack-0x1000);\n"
+ "printf(\"stack == 0x%08X\\n\", stack);"
+ "a = 0;\n"
+ "b = 1;\n"
+ "c = 2;\n"
+ "d = 3;\n"
+ "addr = 0x44001000;\n"
+ "success = 0;\n"
+ "failure = 0;"
+ );
+
+ int test_num = 0;
+ int i, j;
+
+ for (i = 0 ; i < 5 ; i++) {
+ for (j = i+1 ; j < 6 ; j++) {
+
+ puts( "value = a << 24;\n"
+ "value |= b << 16;\n"
+ "value |= c << 8;\n"
+ "value |= d;\n"
+ "addr += 4;\n"
+
+ //"enable_dtlb();"
+
+ );
+
+
+ generate_test(i, j);
+
+ puts("disable_dtlb();");
+ printf("printf(\"Test n° %02d : \");\n", test_num);
+ puts( "if (value == value_verif) {\n"
+ "\tputs(\"PASS\");\n"
+ "\tsuccess++;\n"
+ "} else {\n"
+ "\tputs(\"FAIL\");\n"
+ "\tfailure++;\n"
+ "}"
+ );
+
+ puts( "a++;\n"
+ "b++;\n"
+ "c++;\n"
+ "d++;\n\n"
+ );
+ test_num++;
+ }
+ }
+
+ puts("printf(\"TOTAL : %d/%d successes | %d/%d failures\\n\", success, success + failure, failure, success + failure);");
+
+ puts("}");
+
+ return 0;
+}
View
10 software/include/hal/mmu.h
@@ -19,13 +19,17 @@
#define enable_dtlb() do { \
asm volatile ("xor r11, r11, r11\n\t" \
"ori r11, r11, 0x11\n\t" \
- "wcsr tlbctrl, r11":::"r11"); \
+ "wcsr tlbctrl, r11\n\t" \
+ "xor r0, r0, r0":::"r11"); \
} while(0);
#define disable_dtlb() do { \
asm volatile ("xor r11, r11, r11\n\t" \
- "ori r11, r11, 0x9\n\t" \
- "wcsr tlbctrl, r11":::"r11"); \
+ "ori r11, r11, 0x9\n\t" \
+ "wcsr tlbctrl, r11\n\t" \
+ "xor r0, r0, r0\n\t" \
+ "xor r0, r0, r0\n\t" \
+ "xor r0, r0, r0":::"r11"); \
} while(0);
void mmu_dtlb_map(unsigned int vpfn, unsigned int pfn);
View
9 software/libbase/uart.c
@@ -49,6 +49,15 @@ void uart_isr(void)
{
unsigned int stat = CSR_UART_STAT;
+ mmu_dtlb_map(uart_isr, uart_isr);
+ mmu_dtlb_map(rx_buf, rx_buf);
+ mmu_dtlb_map(tx_buf, tx_buf);
+ mmu_dtlb_map(&tx_produce, &tx_produce);
+ mmu_dtlb_map(&tx_consume, &tx_consume);
+ mmu_dtlb_map(&rx_produce, &rx_produce);
+ mmu_dtlb_map(&tx_cts, &tx_cts);
+ mmu_dtlb_map(irq_ack, irq_ack);
+
if(stat & UART_STAT_RX_EVT) {
rx_buf[rx_produce] = CSR_UART_RXTX;
rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
View
4 software/libhal/mmu.c
@@ -18,9 +18,7 @@
/* @vpfn : virtual page frame number
* @pfn : physical page frame number
*/
-inline void mmu_dtlb_map(vpfn, pfn)
-register unsigned int vpfn;
-register unsigned int pfn;
+inline void mmu_dtlb_map(unsigned int vpfn, unsigned int pfn)
{
asm volatile ("ori %0, %0, 1\n\t"
Please sign in to comment.
Something went wrong with that request. Please try again.