📄 sim_mem_test.s
字号:
#include <config.h>#include <linkage.h>#include <machine.h>#include <memory.h> .text@@ Simple memory test function@ENTRY(memtest) mov r10, lr#ifdef CONFIG_DEBUG_LL adr r0, str_mtst bl printascii#endif /* check the first 1MB in increments of 4 bytes */ mov r7, #0x4 mov r5, #DRAM_BASE mov r6, #0x100000mem_test_loop: mov r0, r5 bl testram_nostack teq r0, #1 beq badram add r5, r5, r7 subs r6, r6, r7 bne mem_test_loop#if 0 /* for more faster */ @ the first megabyte is OK. so let us clear it. mov r0, #((1024 * 1024) / (8 * 4)) @ 1MB in steps of 32 bytes mov r1, #DRAM_BASE mov r2, #0 mov r3, #0 mov r4, #0 mov r5, #0 mov r6, #0 mov r7, #0 mov r8, #0 mov r9, #0 clear_loop_memtest: stmia r1!, {r2-r9} subs r0, r0, #(8 * 4) bne clear_loop_memtest#endif#ifdef CONFIG_DEBUG_LL adr r0, str_pass bl printascii#endif mov pc, r10 @ returnbadram: #ifdef CONFIG_DEBUG_LL adr r0, str_fail bl printascii#endif1: b 1b @ loop @ testmem.S: memory tester, test if there is RAM available at given location@@ Copyright (C) 2001 Russell King (rmk@arm.linux.org.uk)@@ This version clobbers registers r1-r4, so be sure to store their contents@ in a safe position. This function is not APCS compliant, so only use it@ from assembly code.@@ r0 = address to test @ returns r0 = 0 - ram present, r0 = 1 - no ram@ clobbers r1 - r4 ENTRY(testram_nostack) ldr r1, pa1 str r1, [r0] ldr r2, [r0] teq r1, r2 bne bad @ oops, no ldr r1, pa2 str r1, [r0] ldr r2, [r0] teq r1, r2bad: moveq r0, #0 @ ok - all values matched movne r0, #1 @ no ram at this location mov pc, lr .ltorg .align 2pa1: .long 0x55aa55aapa2: .long 0xaa55aa55 .align 2str_mtst: .asciz "testing SDRAM... " .align 2str_pass: .asciz "pass\n" .align 2str_fail: .asciz "fail\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -