📄 bbu_library.s
字号:
;*********************************************************************************
;
; COPYRIGHT (C) 2006 - 2007 Marvell International Ltd. All Rights Reserved.
;
; The information in this file is furnished for informational use only,
; is subject to change without notice, and should not be construed as
; a commitment by Marvell. Marvell assumes no responsibility or liability
; for any errors or inaccuracies that may appear in this software or any
; documenation that may be provided in association with this software.
;
;*********************************************************************************
;
; bbu_LIBRARY.s
;
; This file contains subroutines common to all BBU programs
;
;
; LIST OF SUBROUTINES IN THIS FILE:
; ---------------------------------
;
; BBU_parse_cmd - Searches for a command in the BBU input buffer (BBU_ibuf)
;
; BBU_U32Div Performs an unsigned 32 bit divide, with remainder
; ***** Used only inside this source file - (to be removed) *****
; ***** Do not use for any new commands! *****
;
; BBU_getnum Will search the BBU input buffer (BBU_ibuf) for a valid hex or
; decimal number.
;
; BBU_ENCODE Converts a 32 bit binary value to an ASCII number
; ***** Used only by the BBU TIME command *****
; ***** DO not use for any new command! *****
;
; BBU_get_hex_nibble - decodes an ASCII nibble into a hex value
;
;
; BBU_mem_size Given a memory starting address and an increment size, the code
; will test for memory at (increment size) increments and return the number of
; valid (increment size) locations found.
;
; BBU_tickWait Delay 1 clock tick (1 tick = 0.271267 uS) * value in r0
;
; BBU_msWait Will delay program execution by the number of milliseconds passed
; to this subroutine in r0.
;
; BBU_GetPhysical Translate the user supplied virtual address into it's physical
; address. (very useful in setting up DMA structures.)
;
; BBU_MFPR_setup Sets up MFPR registers as part of the init process for a device
;
; BBU_BaseBoard_REV - Gets base board revision level
;
; BBU_Tech_Boards - Returns status of known tech boards
;
; BBU_HEX_LEDS - Writes 16 bit data to debug board hex LEDS
;
; BBU_HEX_SWITCH - Read from debug board hex switches
;
; BBU_SLEEP - Performs a lot of the generic work to put the platform into
; various idle/sleep modes. Specific details are handled by
; the calling routine.
;
INCLUDE bbu_Monahans_defs.inc
INCLUDE xlli_PXA3xx_defs.inc
INCLUDE xlli_Platform_defs.inc
INCLUDE bbu_Littleton_defs.inc ; Littleton specific definitions
GLOBAL BBU_parse_cmd ; Parses for BBU command in input buffer
GLOBAL BBU_getnum ; Parses for numeric value in input buffer
GLOBAL BBU_ENCODE ; Convert 32 bit binary to decimal ASCII
GLOBAL BBU_get_hex_nibble ; Convert ASCII byte (0-F) to hex value
GLOBAL BBU_mem_size ; Sizes a memory region
GLOBAL BBU_msWait ; Delay a specified number of milliseconds
GLOBAL BBU_usWait ; Delay a specified number of milliseconds
GLOBAL BBU_tickWait ; Delay specified # of clock ticks (1 tick = 0.271267 uS)
GLOBAL BBU_GetPhysical ; Converts virtual address to physical address
GLOBAL BBU_MFPR_setup ; Used to configure MFPR registers for a device
GLOBAL BBU_MFPR_restore ; Used to restore MFPR register to pre BBU_MFPR_setup values
GLOBAL BBU_BaseBoard_REV ; Returns BaseBoard Revision
GLOBAL BBU_Tech_Boards ; Searches for attached tech boards
GLOBAL BBU_HEX_LEDS ; Write to hex LEDs
GLOBAL BBU_HEX_SWITCH ; Read from hex switches
GLOBAL BBU_SLEEP ; Takes care of a lot of the generic sleep code
GLOBAL BBU_CMD_FILE ; Process a user's command file
GLOBAL BBU_CMD_SW ; Command switch array
GLOBAL BBU_CMD_ARG ; Command argument array
GLOBAL BBU_CMD_ASCII ; Command ASCII array
GLOBAL BBU_CMD_POINT ; BBU command file pointer
EXTERN BBU_ibuf ; Address of BBU input buffer
EXTERN BBU_putchr ; BBU Put Character function
EXTERN BBU_putstr ; BBU Put String function
EXTERN BBU_crlf ; New Line
EXTERN BBU_getI2C ; Read from I2C bus
EXTERN BBU_putI2C ; Write to the I2C bus
EXTERN LCD_TPO_off ; Turns of LCD panel
EXTERN bbu_cmd_status ; BBU command status word
EXTERN xlli_MFPR_offset_table
AREA |text|,CODE,READONLY
;
;*********************************************************************************
;
; *****************
; * *
; * BBU_parse_cmd * Parses BBU input buffer for a valid BBU command
; * * (4th generation BBU command parser - Jul-2007)
; *****************
;
; PARAMETER PASSING:
;
; INPUT - No inputs
;
; OUTPUT - r0 = command number (0 = no command found)
; bit 31 is set if no command was entered on line (only <cr>).
; bit 30 is set if there was a syntax error or number too big in command.
; - r1 = number of arguments entered on the command line.
; - r2 = Value for argument #1
; - r3 = Value for argument #2
;
; Up to eight command switches and/or numeric arguments, one of which may
; be an ASCII string may be included on the command line and are returned
; in the following arrays:
;
; BBU_CMD_SW: 8 bytes with any entered switch values (A-Z)
; BBU_CMD_ARG: 8 32-bit values (first 2 locations = r2 & r3 returned above)
; BBU_CMD_ASCII 32 byte array with an NULL terminated ASCII string
;
; The arrays should be thought of as having the following structure:
;
; Arg # | Switch | Switch value |
; ------+--------+---------------+
; 1 | 1S | 1V | (1S = 0x0 or ASCII value of 1st Switch (A-Z))
; ------+--------+---------------+ (1V = Value associated with 1st argument)
; 2 | 2S | 2V |
; ------+--------+---------------+ Switch setting is 1 byte wide
; 3 | 3S | 3V | Switch value is a 32-bit number
; ------+--------+---------------+ ASCII string (up to 31 bytes + NULL)
; 4 | 4S | 4V |
; ------+--------+---------------+
; 5 | 5S | 5V |
; ------+--------+---------------+
; 6 | 6S | 6V |
; ------+--------+---------------+
; 7 | 7S | 7V |
; ------+--------+---------------+
; 8 | 8S | 8V |
; ------+--------+---------------+
; | NULL TERMINATED ASCII STRING |
; +------------------------------+
;
;
; The arrays are always zeroed out when this routine is called.
; Switches are indicated by a forward slash followed by a single letter.
; for example: "/T"
;
; Arguments are loaded into the array in the order in which they appear on
; the command line. For example, consider the command:
;
; "XYZ 0x1234 /S /K=128 0x7654" (may be entered as "XYZ 0x1234/S/K=128,0x7654")
;
; The array would be returned as:
;
; Arg # | Switch | Switch Value |
; ------+--------+--------------+
; 1 | 0x00 | 0x0000_1234 | 0x1234
; ------+--------+--------------+
; 2 | 0x53 | 0x0000_0000 | /S (0x53 = "S")
; ------+--------+--------------+
; 3 | 0x4B | 0x0000_0080 | /K=128 (0x4B = "K")
; ------+--------+--------------+
; 4 | 0x00 | 0x0000_7654 | 0x7654
; ------+--------+--------------+
; 5 | 0x00 | 0x0000_0000 | In addition to the array values,
; ------+--------+--------------+ r0 through r3 will contain the
; 6 | 0x00 | 0x0000_0000 | following:
; ------+--------+--------------+
; 7 | 0x00 | 0x0000_0000 | r0 = command number for XYZ command
; ------+--------+--------------+ r1 = 4 (the number of arguments returned)
; 8 | 0x00 | 0x0000_0000 | r2 = 0x1234 (value in argument #1)
; ------+--------+--------------+ r3 = 0x0000 (value in argument #2)
;
; Since nearly all commands use less than 3 arguments, the first two arguments
; are also returned in r2 and r3 for quick and easy access. However, if the code
; needs to check for a switch value, it always needs to search the array.
;
; This subroutine parses the input string for syntax errors or numbers being
; too large and reports these errors to the user so individual command code
; no longer needs to do this.
;
; ***** RESERVED SWITCH SETTINGS (A and H) *****
;
; The switch "/H" is reserved to provide additional help on the selected command.
; Example: "POKE /H" would be used to provide additional help on the POKE command.
; However, it's only valid for HELP if it is the FIRST argument in the command.
; Users can use "/H" for whatever they want as long as it's not part of the first
; argument.
;
; The switch "/A" is reserved to allow the user to enter an ASCII string
; on the command line. For example "/A=this is a test" will save the text
; string "THIS IS A TEST<null>" in the BBU_CMD_ASCII array.
;
BBU_parse_cmd FUNCTION
stmfd sp!, {r4-r8, lr} ; Save used registers, & link reg on stack
;
; Wipe all argument arrays clean
;
ldr r6, =BBU_CMD_SW ; Point to switch values (start of arrays)
mov r0, #0 ; Load a work register
mov r1, #20 ; Loop count (20 32-bit words)
19 str r0, [r6], #4 ; Zero out this location
subs r1, r1, #1 ; Decrement loop count
bne %B19 ; Loop until done
;
; Set up
;
mov r4, #0 ; Set command number to <zero> - no command found
mov r1, #0 ; Set argument count to zero
ldr r3, =BBU_COMMANDS ; Get address of BBU command list
ldr r5, =BBU_ibuf ; Get address of BBU's input buffer
;
; Parse input string for match in BBU command list (first byte only)
;
10 ldrb r6, [r5], #1 ; Get byte from input buffer
ldrb r7, [r3], #1 ; Get byte from BBU command list
cmp r7, #0xFF ; Is this the end of the BBU command list?
moveq r4, #0 ; Yes - zero out the command number
beq %F99 ; ... and take exit path
cmp r6, #0 ; Is this the end of the input string?
moveq r4, #0x80000000 ; Yes - indicate <cr> was the only thing entered
beq %F99 ; Yes - take exit path
cmp r6, r7 ; Do the bytes match?
beq %F15 ; Yes - check rest of string for compare
;
; Code continues here if the first byte of the BBU command and the
; input buffer DON'T match. The following code resets the input buffer
; pointer and advances the BBU COMMANDS pointer to the start of the first
; byte of the next BBU command in the list.
;
11 ldr r5, =BBU_ibuf ; Reset address of BBU's input buffer
12 ldrb r6, [r3], #1 ; Get next byte from command list
cmp r6, #0 ; Is the byte a NULL byte?
bne %B12 ; Nope, - keep truckin' until a NULL is found.
13 add r4, r4, #1 ; Increment command number (to the match that just failed)
b %B10 ; r3 points to next command - try matching again
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -