Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8972
  • 博文数量: 9
  • 博客积分: 320
  • 博客等级: 一等列兵
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-15 16:59
文章分类

全部博文(9)

文章存档

2011年(1)

2009年(1)

2008年(7)

我的朋友
最近访客

分类: LINUX

2008-09-23 21:22:38





@in autoconf.h:#undef CONFIG_DEBUG_LL
ok_nand_read:
#ifdef CONFIG_DEBUG_LL
    ldr    r0, STR_OK
    ldr    r1, SerBase
    bl    PrintWord
#endif
    
    @ verify:检查BOOT SRAM中的数据和copy到RAM中的数据是否相同
    mov    r0, #0
    ldr    r1, =0x33f00000
    mov    r2, #0x400    @ 4 bytes * 1024 = 4K-bytes
go_next:
    ldr    r3, [r0], #4
    ldr    r4, [r1], #4
    teq    r3, r4
    bne    notmatch
    subs    r2, r2, #4
    beq    done_nand_read    
    bne    go_next

@in autoconf.h:#undef CONFIG_DEBUG_LL
notmatch:
#ifdef CONFIG_DEBUG_LL
    sub    r0, r0, #4
    ldr    r1, SerBase
    bl    PrintHexWord
    ldr    r0, STR_FAIL
    ldr    r1, SerBase
    bl    PrintWord
#endif
@不匹配则进入死循环
1:    b    1b
done_nand_read:

@in autoconf.h:#undef CONFIG_DEBUG_LL
#ifdef CONFIG_DEBUG_LL
    ldr    r0, STR_OK
    ldr    r1, SerBase
    bl    PrintWord
#endif
    @return
    mov    pc, r10

@ clear memory
@ r0: start address
@ r1: length
mem_clear:
    mov    r2, #0
    mov    r3, r2
    mov    r4, r2
    mov    r5, r2
    mov    r6, r2
    mov    r7, r2
    mov    r8, r2
    mov    r9, r2

clear_loop:
    stmia     {r2-r9}
    subs    r1, r1, #(8 * 4)
    bne    clear_loop

    mov    pc, lr

#endif @ CONFIG_S3C2410_NAND_BOOT


#ifdef CONFIG_BOOTUP_MEMTEST
@
@ Simple memory test function
@
memtest:
    mov    r10, lr

#ifdef CONFIG_DEBUG_LL
    mov    r0, #'M'
    ldr    r1, SerBase
    bl    PrintChar
    mov    r0, #'T'
    ldr    r1, SerBase
    bl    PrintChar
    mov    r0, #'S'
    ldr    r1, SerBase
    bl    PrintChar
    mov    r0, #'T'
    ldr    r1, SerBase
    bl    PrintChar
    mov    r0, #' '
    ldr    r1, SerBase
    bl    PrintChar
#endif
        
        /* check the first 1MB in increments of 4k , 256 loops*/
        mov r7, #0x1000
        mov r6, r7, lsl #8 /* 4k << 2^8 = 1MB */
        mov r5, #DRAM_BASE

mem_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


    @ 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 {r2-r9}
        subs r0, r0, #(8 * 4)
        bne clear_loop_memtest

#ifdef CONFIG_DEBUG_LL
    ldr    r0, STR_OK
    ldr    r1, SerBase
    bl    PrintWord
#endif

    mov    pc, r10        @ return

badram:
#ifdef CONFIG_DEBUG_LL
    ldr    r0, STR_FAIL
    ldr    r1, SerBase
    bl    PrintWord
#endif
1:    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)
        ldmia r0, {r1, r2} @ store current value in r1 and r2
        mov r3, #0x55 @ write 0x55 to first word
        mov r4, #0xaa @ 0xaa to second
        stmia r0, {r3, r4}
        ldmia r0, {r3, r4} @ read it back
        teq r3, #0x55 @ do the values match
        teqeq r4, #0xaa
        bne bad @ oops, no
        mov r3, #0xaa @ write 0xaa to first word
        mov r4, #0x55 @ 0x55 to second
        stmia r0, {r3, r4}
        ldmia r0, {r3, r4} @ read it back
        teq r3, #0xaa @ do the values match
        teqeq r4, #0x55
bad: stmia r0, {r1, r2} @ in any case, restore old data
        moveq r0, #0 @ ok - all values matched
        movne r0, #1 @ no ram at this location
        mov pc, lr

#endif @ CONFIG_BOOTUP_MEMTEST



@ Initialize UART
@ SerBase = used for debug UART Ctrl Addr
@ r0 = number of UART port

InitUART:
    ldr    r1, SerBase
    mov    r2, #0x0
    str    r2, [r1, #oUFCON]
    str    r2, [r1, #oUMCON]
    mov    r2, #0x3
    @8-bit data,1-bit stop,no parity
    str    r2, [r1, #oULCON]
    ldr    r2, =0x245
    str    r2, [r1, #oUCON]
    @ UART_BAUD_RATE defined in include/platform/smdk2410.h
    @PCLK = 50MHz
#define UART_BRD ((50000000 / (UART_BAUD_RATE * 16)) - 1)
    mov    r2, #UART_BRD
    str    r2, [r1, #oUBRDIV]
    @delay
    mov    r3, #100
    mov    r2, #0x0
1:    sub    r3, r3, #0x1
    tst    r2, r3
    bne    1b

#if 0
    mov    r2, #'U'
    str    r2, [r1, #oUTXHL]

1:    ldr    r3, [r1, #oUTRSTAT]
    and    r3, r3, #UTRSTAT_TX_EMPTY
    tst    r3, #UTRSTAT_TX_EMPTY
    bne    1b    

    mov    r2, #'0'
    str    r2, [r1, #oUTXHL]

1:    ldr    r3, [r1, #oUTRSTAT]
    and    r3, r3, #UTRSTAT_TX_EMPTY
    tst    r3, #UTRSTAT_TX_EMPTY
    bne    1b    

阅读(290) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~