📄 mainstone.mac
字号:
;
; Copyright ?2002-2003 Intel Corp.
;
; ***********************************************************************
; Mainstone.mac: Contains Mainstone-specific macros.
; *Note: These macros use PHYSICAL
; addressing. These are *not* intended for use
; by WinCE drivers, but rather for init code and eboot.
; ***********************************************************************
INCLUDE bvd1.inc
INCLUDE bvd1bd.inc
;------------------------------------------------------------------------
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Macro: FlashSetSyncBurstEight()
;
; Description: This macro configures Intel K3 family of FLASH devices
; to operate in synchronous mode, with a burst-of-8.
;
; Assumptions: 2 Flash arranged in parallel (d[31:16] on one chip, d[15:0] on the other).
; This routine should be used after MSCx[2:0]='011' (burst-of-8 FLASH/ROM).
; The $Base parameter should be an uncahced, non-buffered address.
;
; Input Params: $Base : base address of FPGA; can be physical or virtual
; $Value: the 32-bit value to be written to the HEX LEDs
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; UNKNOWNS: Am i dealing with both devices correctly?
;
;
MACRO
FlashSetSyncBurstEight $Base, $w1, $w2
; First, Read Device Identifier to obtain RCR value
; (a 2 cycle operation)
;
ldr $w1, =0x00900090 ; write "Read Identifier" Command to both devices
str $w1, $Base
ldr $w1, =0x00050005
ldr $w1, [$w1] ; now read the RCR: 32-bits: 16 from upper, 16 from lower
; Now, OR in the correct value to configure as sync, B-O-8 (FLASH uses address lines for this procedure, not data)
; (need to shift to adjust for Adx line mapping)
;
orr $w1, $w1, #(0x9802 :LSL: 2) ; this value is prelim- need to understand what bits[9:8] should be!
; Finally, store it back to the RCR.
; This is done by writing 0x60 to the address
; that is created by the destined RCR value created above.
; (a 2 cycle operation)
;
ldr $w2, =0x00600060
str $w2, [$w1] ; change mode
mov $w2, #0x00030003
str $w2, [$w1] ; update the RCR
MEND
;------------------------------------------------------------------------
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Macro: setHexLED()
;
; Description: This macro displays the value in $Value on the hex LED. $Value is treated
; as a 32-bit value.
; Input Params: $Base : base address of FPGA; can be physical or virtual
; $Value: the 32-bit value to be written to the HEX LEDs
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MACRO
setHexLED $Base, $Value
;str $Value, [$Base, #LEDDAT1_OFFSET] ;masked by hzh
MEND
;------------------------------------------------------------------------
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Macro: SetDiscreteLEDS()
;
; Description: This macro will take a 32-bit register's contents ($Value)
; and display on discrete LEDs. Notice, the range: [x00->xFF].
;
; Input Params: $Base : base address of FPGA; can be physical or virtual
; $Value: the 32-bit value to be written to the HEX LEDs
; $w1 : a scratchpad register; will be corrupted
;
; *Note: on = 0, off = 1 at HW.
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MACRO
setDiscreteLEDs $Base, $Value, $w1
; Read current LEDCTRL value
;
ldr $w1, [$Base, #LEDCTL_OFFSET]
; Invert the $Value word since 0=On, 1=OFf
;
mvn $Value, $Value
; Do not contaminate upper, unrelated, 8 bits of LEDCTRL
;
and $w1, $w1, #0xFF00
; Extract lower 8-bits of $Value (ignore upper 24 bits)
;
and $Value, $Value, #0xFF
; Insert new bits into register
;
orr $w1, $w1, $Value
; Write the new settings
;
str $w1, [$Base, #LEDCTL_OFFSET]
MEND
;------------------------------------------------------------------------
; This macro will read dip SW12 and return its value in $retval
;
MACRO
GET_SW12 $retval, $Base
; read S12's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW12_MASK
; get bit into position 0
;
mov $retval, $retval LSR #15
MEND
;------------------------------------------------------------------------
; This macro will read dip SW11 and return its value in $retval
;
MACRO
GET_SW11 $retval, $Base
; read S11's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW11_MASK
; get bit into position 0
;
mov $retval, $retval LSR #14
MEND
;------------------------------------------------------------------------
; This macro will read dip SW10 and return its value in $retval
;
MACRO
GET_SW10 $retval, $Base
; read S10's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW10_MASK
; get bit into position 0
;
mov $retval, $retval LSR #13
MEND
;------------------------------------------------------------------------
; This macro will read dip SW8 and return its value in $retval
;
MACRO
GET_SW8 $retval, $Base
; read S8's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW8_MASK
; get bit into position 0
;
mov $retval, $retval LSR #12
MEND
;------------------------------------------------------------------------
; This macro will read dip SW7 and return its value in $retval
;
MACRO
GET_SW7 $retval, $Base
; read S7's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW7_MASK
; get bit into position 0
;
mov $retval, $retval LSR #11
MEND
;------------------------------------------------------------------------
; This macro will read dip SW6 and return its value in $retval
;
MACRO
GET_SW6 $retval, $Base
; read S6's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW6_MASK
; get bit into position 0
;
mov $retval, $retval LSR #10
MEND
;------------------------------------------------------------------------
; This macro will read dip SW4 and return its value in $retval
;
MACRO
GET_SW4 $retval, $Base
; read S4's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW4_MASK
; get bit into position 0
;
mov $retval, $retval LSR #9
MEND
;------------------------------------------------------------------------
; This macro will read dip SW3 and return its value in $retval
;
MACRO
GET_SW3 $retval, $Base
; read S3's value
;
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
;
and $retval, $retval, #SW3_MASK
; get bit into position 0
;
mov $retval, $retval LSR #8
MEND
;------------------------------------------------------------------------
; This macro will read rotary S5 and return its value in $retval, preserving $Base
;
MACRO
GET_HEXSW5 $retval, $Base
; read S5's value
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
and $retval, $retval, #HEXSW5_MASK
MEND
;------------------------------------------------------------------------
; This macro will read rotary S26 and return its value in $retval
;
MACRO
GET_HEXSW9 $retval, $Base
; read S9's value
ldr $retval, [$Base, #GPSW_OFFSET]
; mask out irrelevant bits
and $retval, $retval, #HEXSW9_MASK
MEND
;------------------------------------------------------------------------
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -