⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system-macros.h.s

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 S
📖 第 1 页 / 共 5 页
字号:
; Function:	Unified ID Cache Flush utility. 
;
; Internally:	$register is passed to this macro but not actually used. r0 is used
;		internally and restored afterwards.
;
; Superseded:	see INVALIDATE_CACHE_ALL.
;

		MACRO
$label		FLUSH_CACHE $register
		LOCAL
		[	HAS_CACHES
$label		B	jump$l
store$l		%	4
jump$l		STR	$register,store$l
		MOV	$register,#0

		[	TARGET="ARM940T"
		MCR	p15,0,$register,c7,c5,0		; flush ICache
		MCR	p15,0,$register,c7,c6,0		; flush DCache
		|
		MCR	p15,0,$register,c7,c7,0		; ok on Arch 3 & Arch 4 and harvard architectures too
		]
		LDR	$register,store$l
		|
		!	0, "Inappropriate use of FLUSH_CACHE"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_CACHE_ALL $reg
;
; Function:	Invalidates entire ICache and DCache.
;
; Internally:	All registers preserved, except for $reg if specified.
;

		MACRO
$label		INVALIDATE_CACHE_ALL $reg
$label		LOCAL
		[	HAS_CACHES
		[ "$reg" /= ""
		MOV	$reg, #0			; SBZ
		MCR	p15, 0, $reg, c7, c7, 0		; C7C7 = inval I&DCache, 0 = all
		|
		PRESERVE 0, 0
		MOV	r0, #0				; SBZ
		MCR	p15, 0, r0, c7, c7, 0		; C7C7 = inval I&DCache, 0 = all
		RESTORE 0, 0
		]
		|
		!	0, "Inappropriate use of INVALIDATE_CACHE_ALL"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
; Macro:	[label] FLUSH_ICACHE
;
; Function:	Instruction Cache Flush utility.
;
; Internally:	r0 is used internally and restored afterwards.
;
; Superseded:	see INVALIDATE_ICACHE_ALL.
;

		MACRO
$label		FLUSH_ICACHE
$label
		[	HAS_CACHES
		[	HARVARD
		LOCAL
		B	jump$l
store$l		%	4				; temporary storage for R0
jump$l		STR	r0, store$l			; save r0
		MOV	r0,#0
		MCR	p15, 0, r0, c7, c5, 0		; access CP15
		LDR	r0, store$l			; restore r0
		LOCAL_END
		]
		|
		!	0, "FLUSH_ICACHE called for TARGET with NO Icache"
		]
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_ICACHE_ALL $reg
;
; Function:	Invalidates entire ICache.
;
; Internally:	All registers preserved, except for $reg if specified.
;

		MACRO
$label		INVALIDATE_ICACHE_ALL $reg
$label		LOCAL

		[	HAS_CACHES
		[ "$reg" /= ""
		MOV	$reg, #0			; SBZ
		MCR	p15, 0, $reg, c7, c5, 0		; C7C5 = inval ICache, 0 = all
		|
		PRESERVE 0, 0
		MOV	r0, #0				; SBZ
		MCR	p15, 0, r0, c7, c5, 0		; C7C5 = inval ICache, 0 = all
		RESTORE 0, 0
		]
		|
		!	0, "Inappropriate use of INVALIDATE_ICACHE_ALL"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
; Macro:	[label] FLUSH_DCACHE
;
; Function:	Data Cache Flush utility.
;
; Internally:	r0 is used internally and restored afterwards.
;
; Superseded:	see INVALIDATE_DCACHE_ALL
;

		MACRO
$label		FLUSH_DCACHE
$label		LOCAL

		[	HAS_CACHES
		B	jump$l
store$l		%	4				; temporary storage for R0
jump$l		STR	r0, store$l			; save r0
		MOV	r0,#0
		MCR	p15, 0, r0, c7, c6, 0		; access CP15
		LDR	r0, store$l			; restore r0
		|
		!	0, "Inappropriate use of FLUSH_DCACHE"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_DCACHE_ALL $reg
;
; Function:	Invalidates entire DCache.
;
; Internally:	All registers preserved, except for $reg if specified.
;

		MACRO
$label		INVALIDATE_DCACHE_ALL $reg
$label		LOCAL

		[	HAS_CACHES		
		[ "$reg" /= ""
		MOV	$reg, #0			; SBZ
		MCR	p15, 0, $reg, c7, c6, 0		; C7C6 = inval DCache, 0 = all
		|
		PRESERVE 0, 0
		MOV	r0, #0				; SBZ
		MCR	p15, 0, r0, c7, c6, 0		; C7C6 = inval DCache, 0 = all
		RESTORE 0, 0
		]
		|
		!	0, "Inappropriate use of INVALIDATE_DCACHE_ALL"
		]		
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
; Macro:	[label] FLUSH_CACHE_ENTRY $register
;
; Function:	ID Unified Cache Single Entry Flush utility.
;		$register - must contain the entry address in the format
;		(31-26) - index, (25-8) - SBZ, (7-4) - segment, (3-0) SBZ
;
; Internally:	For HARVARD devices this macro will flush corresponding entries
;		in both the I and the D cache (unlikely to be useful!).
;

		MACRO
		FLUSH_CACHE_ENTRY $register
		[	HAS_CACHES
		[	HARVARD
		MCR	p15, 0, $register, c7, c6, 1	; Flush DCache Entry
		MCR	p15, 0, $register, c7, c5, 1	; Flush ICache Entry
		|
		MCR	p15, 0, $register, c7, c7, 1
		]
		|
		!	0, "Inappropriate use of FLUSH_CACHE_ENTRY"
		]
		MEND

;------------------------------------------------------------------------------
; Macro:	[label] FLUSH_ICACHE_ENTRY $seg, $line
;
; Function:	Data Cache Single Entry Flush utility. 
;		$seg -    register containing Cache Segment
;		$line -   register containing Cache Line
;
; Internally:	r0 is used internally and restored afterwards.
;
; Superseded:	see INVALIDATE_ICACHE_INDEX.
;

		MACRO
$label		FLUSH_ICACHE_ENTRY $seg, $line
$label		LOCAL
		[	HAS_CACHES
		B	jump$l
store$l		%	8				; temporary storage for R0
jump$l		STR	r0, store$l			; save r0
		STR	r1, store$l+4			; save r1
		
		[	"$seg" ="R0" :LOR: "$seg" ="r0" 
		!	1,"\nSegment number cannot be specified in R0 for FLUSH_ICACHE_ENTRY "
		]

		MOV	r0, $line, LSL #26
		ORR	r0, r0, $seg, LSL #4
		MCR	p15, 0, r0, c7, c5, 1
		
		LDR	r0, store$l			; restore r0
		LDR	r1, store$l+4			; restore r1
		|
		!	0, "Inappropriate use of FLUSH_ICACHE_ENTRY"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_ICACHE_INDEX $seg, $line
;
; Function:	Invalidates ICache line specified by line R$line and
;		segment R$seg.  R$seg may not be R0.
;
; Internally:	All registers preserved.
;

		MACRO
$label		INVALIDATE_ICACHE_INDEX $seg, $line
$label		LOCAL

		[	HAS_CACHES
		PRESERVE 0, 0
		
		[	"$seg" = "R0" :LOR: "$seg" = "r0" 
		!	1, "\nSegment number cannot be specified in R0 for INVALIDATE_ICACHE_INDEX!"
		]

		[	SEGMENT_ASSOCIATIVE
		MOV	r0, $line, LSL #CACHE_NUM_COLUMN_BITS	; Index in bn upwards
		ORR	r0, r0, $seg, LSL #30		; segment in b30-b31
		|
		MOV	r0, $line, LSL #26		; Index in b26-b31
		ORR	r0, r0, $seg, LSL #CACHE_NUM_COLUMN_BITS ; Segment in bn upwards
		]
		MCR	p15, 0, r0, c7, c5, INV_IND_OP2	; C7C5 = inval ICache, OP2 = using index
		RESTORE 0, 0
		|
		!	0, "Inappropriate use of INVALIDATE_ICACHE_INDEX"
		]

		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_ICACHE_VA $va
;
; Function:	Invalidates ICache line specified by VA R$va.
;
; Internally:	All registers preserved.
;

		MACRO
$label		INVALIDATE_ICACHE_VA $va
$label		LOCAL
		[	HAS_CACHES
		PRESERVE 0, 0
		
		MOV	r0, $va, LSR #CACHE_NUM_COLUMN_BITS ; LSB SBZ
		MOV	r0, r0, LSL #CACHE_NUM_COLUMN_BITS
		MCR	p15, 0, r0, c7, c5, INV_VA_OP2	; C7C5 = inval ICache, OP2 = using VA
		
		RESTORE 0, 0
		|
		!	0, "Inappropriate use of INVALIDATE_ICACHE_VA"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
; Macro:	[label] FLUSH_DCACHE_ENTRY $seg, $line
;
; Function:	Data Cache Single Entry Flush utility. 
;		$seg -    register containing Cache Segment
;		$line -   register containing Cache Line
;
; Internally:	r0 is used internally and restored afterwards.
;
; Superseded:	see INVALIDATE_DCACHE_INDEX.
;

		MACRO
$label		FLUSH_DCACHE_ENTRY $seg, $line
$label		LOCAL
		[	HAS_CACHES
		B	jump$l
store$l		%	8				; temporary storage for R0
jump$l		STR	r0, store$l			; save r0
		STR	r1, store$l+4			; save r1
		
		[ "$seg" ="R0" :LOR: $seg  = "r0" 
		! 1,"\nSegment number cannot be specified in R0 for FLUSH_DCACHE_ENTRY "
		]

		MOV	r0, $line, LSL #26
		ORR	r0, r0, $seg, LSL #4
		MCR	p15, 0, r0, c7, c6, 1
		
		LDR	r0, store$l			; restore r0
		LDR	r1, store$l+4			; restore r1
		|
		!	0, "Inappropriate use of FLUSH_DCACHE_ENTRY"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_DCACHE_INDEX $seg, $line
;
; Function:	Invalidates DCache line specified by line R$line and
;		segment R$seg.  R$seg may not be R0.
;
; Internally:	All registers preserved.
;

		MACRO
$label		INVALIDATE_DCACHE_INDEX $seg, $line
$label		LOCAL
		[	HAS_CACHES
		PRESERVE 0, 0
		
		[	"$seg" ="R0" :LOR: "$seg" ="r0" 
		!	1, "\nSegment number cannot be specified in R0 for INVALIDATE_DCACHE_INDEX!"
		MEXIT
		]

		[	SEGMENT_ASSOCIATIVE
		MOV	r0, $line, LSL #CACHE_NUM_COLUMN_BITS	; Index in bn upwards
		ORR	r0, r0, $seg, LSL #30		; segment in b30-b31
		|
		MOV	r0, $line, LSL #26		; Index in b26-b31
		ORR	r0, r0, $seg, LSL #CACHE_NUM_COLUMN_BITS ; Segment in bn upwards
		]
		MCR	p15, 0, r0, c7, c6, INV_IND_OP2	; C7C6 = inval DCache, OP2 = using index
		
		RESTORE 0, 0
		|
		!	0, "Inappropriate use of INVALIDATE_DCACHE_INDEX"
		]
		LOCAL_END
		MEND

;------------------------------------------------------------------------------
;
; Macro:	$label INVALIDATE_DCACHE_VA $va
;
; Function:	Invalidates DCache line specified by VA R$va.
;
; Internally:	All registers preserved.
;

		MACRO
$label		INVALIDATE_DCACHE_VA $va
$label		LOCAL
		[	HAS_CACHES
		PRESERVE 0, 0
		
		MOV	r0, $va, LSR #CACHE_NUM_COLUMN_BITS ; LSB SBZ
		MOV	r0, r0, LSL #CACHE_NUM_COLUMN_BITS
		MCR	p15, 0, r0, c7, c6, INV_VA_OP2	; C7C6 = inval DCache, OP2 = using VA
		
		RESTORE 0, 0
		|
		!	0, "Inappropriate use of INVALIDATE_DCACHE_VA"
		]
		LOCAL_END
		MEND

;-------------------------------------------------------------------------------
; Macro:        <label> INVALIDATE_DCACHE_MVA <$reg>
;
; Function:     Macro to Invalidate the DCache for the specified
;               Virtual Address.
;
; Operation:    This macro first checks the type of the Cache in the
;               System by reading the CP15 Register 0. If it is Unified,
;               Invalidate the Unified Cache. If it is Separate Cache,
;               Invalidate the DCache. In both cases, it is done for the
;               specified Virtual Address.
;
; Assumptions:
;
; Registers Used:
;               R0 - Used at various stages to hold temporary values
;               R1 - Used at various stages to hold temporary values
;
;-------------------------------------------------------------------------------
                MACRO
                INVALIDATE_DCACHE_MVA $reg

                LOCAL
		PRESERVE 0, 1

                MRC     p15,0,R0,c0,c0,1                ; Read Cache Type Reg
                LDR     R1, =0xFFF
                AND     R1, R0, R1

                AND     R1, R0, #0x01000000             ; Get the S bit
                MOV     R1, R1, LSR #24

                TEQ     R1, #1
                BEQ     Sep_Cache$l

                MCR     p15,0,$reg,c7,c7,1              ; Unified Cache
                B       end$l

Sep_Cache$l     MCR     p15,0,$reg,c7,c6,1
end$l
		RESTORE 0, 1
                LOCAL_END
                MEND

;-------------------------------------------------------------------------------
; Macro:        <label> INVALIDATE_ICACHE_MVA <$reg>
;
; Function:     Macro to Invalidate the ICache for the specified
;               Virtual Address.
;
; Operation:    This macro first checks the type of the Cache in the
;               System by reading the CP15 Register 0. If it is Unified,
;               Invalidate the Unified Cache. If it is Separate Cache,
;               Invalidate the ICache. In both cases, it is done for the
;               specified Virtual Address.
;
; Assumptions:
;
; Registers Used:
;               R0 - Used at various stages to hold temporary values
;               R1 - Used at various stages to hold temporary values
;
;-------------------------------------------------------------------------------
                MACRO
                INVALIDATE_ICACHE_MVA $reg

                LOCAL

		PRESERVE 0, 1

                MRC     p15,0,R0,c0,c0,1                ; Read Cache Type Reg
                LDR     R1, =0xFFF
                AND     R1, R0, R1

                AND     R1, R0, #0x01000000             ; Get the S bit
                MOV     R1, R1, LSR #24

                TEQ     R1, #1
                BEQ     Sep_Cache$l

                MCR     p15,0,$reg,c7,c7,1              ; Unified Cache
                B       end$l

Sep_Cache$l     MCR     p15,0,$reg,c7,c5,1
end$l
		RESTORE 0, 1
                LOCAL_END
                MEND

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -