Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5361 serge 1
/*
2
 * Set dependency control HW scoreboard kernel
3
 * Copyright © <2010>, Intel Corporation.
4
 *
5
 * This program is licensed under the terms and conditions of the
6
 * Eclipse Public License (EPL), version 1.0.  The full text of the EPL is at
7
 * http://www.opensource.org/licenses/eclipse-1.0.php.
8
 *
9
 */
10
// Kernel name: SetHWScoreboard.asm
11
//
12
// Set dependency control HW scoreboard kernel
13
//
14
 
15
// ----------------------------------------------------
16
//  Main: SetHWScoreboard
17
// ----------------------------------------------------
18
 
19
.kernel SetHWScoreboard
20
 
21
SETHWSCOREBOARD:
22
 
23
#ifdef _DEBUG
24
// WA for FULSIM so we'll know which kernel is being debugged
25
mov (1) acc0:ud 0xf0aa55a5:ud
26
#endif
27
 
28
#include "header.inc"
29
#include "SetHWScoreboard_header.inc"
30
 
31
//
32
//  Now, begin source code....
33
//
34
 
35
.code
36
 
37
//	Separate the TotalMB so TotalMB will be multiple of 8
38
//	and RemainderMB will hold the TotalMB%8
39
//
40
	and.z.f0.1 (1)	RemainderMB<1>:uw	TotalMB<0;1,0>:uw	0x0007:uw	// number of %8 commands
41
	and.z.f0.0 (1)	TotalMB<1>:uw		TotalMB<0;1,0>:uw	0xfff8:uw	// Number of 8-command blocks
42
 
43
	mov (1)	MB_SHIFT_MASK_W<1>:uw		0x100*16+12:w					// Set up shift values (12, 16)
44
 
45
//	Initialize common DAP read header
46
//
47
	mov (8)	MRF_READ_HEADER_SRC<1>:ud	r0.0<8;8,1>:ud
48
	shl (1) MRF_READ_HEADER_SRC.2<1>:ud	StartingMB<0;1,0>:uw	6:uw	// Byte-aligned offset being read
49
 
50
//	Initialize Inter DAP write header
51
 	mov (8)	MRF_INTER_WRITE_HEADER<1>:ud	r0.0<8;8,1>:ud
52
 
53
	(f0.0) jmpi (1)	SetHWScoreboard_Remainder							// Jump if TotalMB < 8
54
 
55
//------------------------------------------------------------------------
56
//	Command buffer parsing loop
57
//	Each loop will handle 8 commands
58
//------------------------------------------------------------------------
59
//
60
SetHWScoreboard_Loop:
61
//	Load block 0 (Commands 0/1)
62
	mov (8)	MRF_READ_HEADER0.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
63
	send (16)	CMD_BUFFER_W(0)<1>	MRF_READ_HEADER0	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
64
 
65
//	Load block 1  (Commands 2/3)
66
	mov (8)	MRF_READ_HEADER1.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
67
	add	(1)	MRF_READ_HEADER1.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		128:ud		// Point to next 2-command block
68
	send (16)	CMD_BUFFER_W(4)<1>	MRF_READ_HEADER1	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
69
 
70
//	Load block 2  (Commands 4/5)
71
	mov (8)	MRF_READ_HEADER2.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
72
	add	(1)	MRF_READ_HEADER2.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		256:ud		// Point to next 2-command block
73
	send (16)	CMD_BUFFER_W(8)<1>	MRF_READ_HEADER2	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
74
 
75
//	Load block 3  (Commands 6/7)
76
	mov (8)	MRF_READ_HEADER3.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
77
	add	(1)	MRF_READ_HEADER3.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		384:ud		// Point to next 2-command block
78
	send (16)	CMD_BUFFER_W(12)<1>	MRF_READ_HEADER3	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
79
 
80
//	Start parsing commands
81
    $for(0; <16; 2) {
82
	and.nz.f0.1 (8)	NULLREG	CMD_BUFFER_D(%1,4)<0;1,0>	IS_INTRA_MB:ud		// Is it an "Intra" MB?
83
	or (1)	CMD_BUFFER_D(%1,2)<1>	CMD_BUFFER_D(%1,2)<0;1,0>	BIT21:ud	// Set "Use Scoreboard" for every MB
84
	shl	(2)	CMD_BUFFER_W(%1,2)<1>	CMD_BUFFER_W(%1,14)<0;1,0>	MB_SHIFT_MASK_B<2;2,1>:b	// Set HW SB masks
85
	mov (2)	CMD_BUFFER_B(%1,4)<2>	CMD_BUFFER_B(%1,20)<2;2,1>				// Set scoreboard (X,Y) for intra MB
86
	(-f0.1) mov (2)	CMD_BUFFER_W(%1,2)<1>	CMD_BUFFER_B(%1,20)<2;2,1>		// Set scoreboard (X,Y) for inter MB
87
	(f0.1) jmpi (1) Parse_8_Loop_%1
88
 
89
//	Inter Macroblock
90
//	Output MEDIA_OBJECT command in raster scan order
91
	mul (16) acc0<1>:uw	CMD_BUFFER_B(%1,21)<0;1,0>	PicWidthMB<0;1,0>:uw	// MB offset = Y*W
92
	add (16) acc0<1>:uw	acc0<8;8,1>:uw	CMD_BUFFER_B(%1,20)<0;1,0>			// MB offset = Y*W+X
93
 	shl (1)	MRF_INTER_WRITE_HEADER.2<1>:ud	acc0.2<0;1,0>:uw	6:uw		// Byte-aligned MB offset
94
 	mov (16)	MRF_INTER_WRITE_DATA0<1>:ud	CMD_BUFFER_D(%1)<8;8,1>	{Compr}	// Copy entire command to inter buffer
95
	mov	(16)	CMD_BUFFER_D(%1)<1>		0:ud	{Compr}						// Clear original command
96
	send (16)	NULLREGW	MRF_INTER_WRITE_HEADER	null:uw	DAPWRITE	MSG_LEN(2)+OWBWMSGDSC+OWORD_4+BI_CMD_BUFFER
97
 
98
Parse_8_Loop_%1:
99
	}
100
 
101
	add.z.f0.0 (1)	TotalMB<1>:w	TotalMB<0;1,0>:w	-8:w				// Update remaining number of 8-command blocks
102
 
103
//	Output modified intra commands
104
//	Write block 0
105
	mov (8)	MRF_INTRA_WRITE_HEADER.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
106
    $for(0; <4; 2) {
107
	mov (16)	MRF_CMD_BUF_D(%1)<1>	CMD_BUFFER_D(%1)<8;8,1>	{Compr}
108
	}
109
	send (16)	NULLREGW	MRF_INTRA_WRITE_HEADER	null:uw	DAPWRITE	MSG_LEN(4)+OWBWMSGDSC+OWORD_8+BI_CMD_BUFFER
110
 
111
//	Write block 1
112
	mov (8)	m1.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
113
	add	(1)	m1.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		128:ud		// Point to next 2-command block
114
	mov (16)	m2<1>:ud	CMD_BUFFER_D(4)<8;8,1>	{Compr}
115
	mov (16)	m4<1>:ud	CMD_BUFFER_D(6)<8;8,1>	{Compr}
116
	send (16)	NULLREGW	m1	null:uw	DAPWRITE	MSG_LEN(4)+OWBWMSGDSC+OWORD_8+BI_CMD_BUFFER
117
 
118
//	Write block 2
119
	add	(1)	MRF_INTRA_WRITE_HEADER.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		256:ud		// Point to next 2-command block
120
    $for(0; <4; 2) {
121
	mov (16)	MRF_CMD_BUF_D(%1)<1>	CMD_BUFFER_D(%1+8)<8;8,1>	{Compr}
122
	}
123
	send (16)	NULLREGW	MRF_INTRA_WRITE_HEADER	null:uw	DAPWRITE	MSG_LEN(4)+OWBWMSGDSC+OWORD_8+BI_CMD_BUFFER
124
 
125
//	Write block 3
126
	add	(1)	m1.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		384:ud		// Point to next 2-command block
127
	mov (16)	m2<1>:ud	CMD_BUFFER_D(12)<8;8,1>	{Compr}
128
	mov (16)	m4<1>:ud	CMD_BUFFER_D(14)<8;8,1>	{Compr}
129
	send (16)	NULLREGW	m1	null:uw	DAPWRITE	MSG_LEN(4)+OWBWMSGDSC+OWORD_8+BI_CMD_BUFFER
130
 
131
//	Update message header for next DAP read
132
	add (1) MRF_READ_HEADER_SRC.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud	512:ud	// Point to next block of 8-commands
133
 
134
	cmp.z.f0.1 (1)	NULLREG	RemainderMB<0;1,0>:w	0:uw	// Check if remainder MB = 0
135
	(-f0.0) jmpi (1)	SetHWScoreboard_Loop			// Continue if more command blocks remain
136
 
137
SetHWScoreboard_Remainder:
138
//	f0.1 should have been set to indicate if RemainderMB = 0
139
//
140
	(f0.1) jmpi (1) SetHWScoreboard_Done				// Stop if all commands have been updated
141
 
142
//	Blindly load next 8 commands anyway
143
//
144
//	Load block 0 (Commands 0/1)
145
	mov (8)	MRF_READ_HEADER0.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
146
	send (16)	CMD_BUFFER_W(0)<1>	MRF_READ_HEADER0	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
147
 
148
//	Load block 1  (Commands 2/3)
149
	mov (8)	MRF_READ_HEADER1.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
150
	add	(1)	MRF_READ_HEADER1.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		128:ud		// Point to next 2-command block
151
	send (16)	CMD_BUFFER_W(4)<1>	MRF_READ_HEADER1	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
152
 
153
//	Load block 2  (Commands 4/5)
154
	mov (8)	MRF_READ_HEADER2.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
155
	add	(1)	MRF_READ_HEADER2.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		256:ud		// Point to next 2-command block
156
	send (16)	CMD_BUFFER_W(8)<1>	MRF_READ_HEADER2	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
157
 
158
//	Load block 3  (Commands 6/7)
159
	mov (8)	MRF_READ_HEADER3.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
160
	add	(1)	MRF_READ_HEADER3.2<1>:ud	MRF_READ_HEADER_SRC.2<0;1,0>:ud		384:ud		// Point to next 2-command block
161
	send (16)	CMD_BUFFER_W(12)<1>	MRF_READ_HEADER3	null:uw	DAPREAD	RESP_LEN(4)+OWBRMSGDSC_SC+OWORD_8+BI_CMD_BUFFER
162
 
163
//	Initialize necessary pointers
164
	mov (1)	a0.1<1>:ud	((CMD_BUFFER_REG_OFF+1)*0x10000+CMD_BUFFER_REG_OFF)*32	// a0.2:w points to command buffer (first half)
165
																			// a0.3:w points to command buffer (second half)
166
//	Initialize Inter DAP write header
167
 	mov (8)	MRF_INTER_WRITE_HEADER<1>:ud	r0.0<8;8,1>:ud
168
 
169
SetHWScoreboard_Remainder_Loop:
170
	and.nz.f0.1 (8)	NULLREG	r[a0.2,4*4]<0;1,0>:ud	IS_INTRA_MB:ud		// Is it an "Intra" MB?
171
	add.z.f0.0 (1)	RemainderMB<1>:w	RemainderMB<0;1,0>:w	-1:w	// Decrement MB #
172
	or (1)	r[a0.2,2*4]<1>:ud	r[a0.2,2*4]<0;1,0>:ud	BIT21:ud		// Set "Use Scoreboard" for every MB
173
	shl	(2)	r[a0.2,2*2]<1>:uw	r[a0.2,14*2]<0;1,0>:uw	MB_SHIFT_MASK_B<2;2,1>:b	// Set HW SB masks
174
	mov (2)	r[a0.2,4*1]<2>:ub	r[a0.2,5*4]<2;2,1>:ub					// Set scoreboard (X,Y) for intra MB
175
 
176
	(-f0.1) mov (2)	r[a0.2,4*1]<1>:uw	r[a0.2,5*4]<2;2,1>:ub			// Set scoreboard (X,Y) for inter MB
177
	(f0.1) jmpi (1)	Output_Remainder_Intra
178
 
179
//	Inter Macroblock
180
//	Output MEDIA_OBJECT command in raster scan order
181
	mul (16) acc0<1>:uw	r[a0.2,21]<0;1,0>:ub	PicWidthMB<0;1,0>:uw	// MB offset = Y*W
182
	add (16) acc0<1>:uw	acc0<8;8,1>:uw	r[a0.2,20]<0;1,0>:ub			// MB offset = Y*W+X
183
 	shl (1)	MRF_INTER_WRITE_HEADER.2<1>:ud	acc0.2<0;1,0>:uw	6:uw	// Byte-aligned MB offset
184
 	mov (16)	MRF_INTER_WRITE_DATA0<1>:ud	r[a0.2]<8;8,1>:ud	{Compr}	// Copy entire command to inter buffer
185
	mov	(16)	r[a0.2]<1>:ud		0:ud	{Compr}						// Clear original command
186
	send (16)	NULLREGW	MRF_INTER_WRITE_HEADER	null:uw	DAPWRITE	MSG_LEN(2)+OWBWMSGDSC+OWORD_4+BI_CMD_BUFFER
187
 
188
Output_Remainder_Intra:
189
//	Intra MB command always output
190
	mov (8)	MRF_INTRA_WRITE_HEADER.0<1>:ud	MRF_READ_HEADER_SRC.0<8;8,1>:ud
191
 	mov (16)	MRF_CMD_BUF_D(0)<1>		r[a0.2]<8;8,1>:ud	{Compr}		// Copy entire command to intra buffer
192
	send (16)	NULLREGW	MRF_INTRA_WRITE_HEADER	null:uw	DAPWRITE	MSG_LEN(2)+OWBWMSGDSC+OWORD_4+BI_CMD_BUFFER
193
 
194
	add	(1)	MRF_READ_HEADER_SRC.2<1>:ud		MRF_READ_HEADER_SRC.2<0;1,0>:ud		64:ud	// Point to next command
195
	add (1)	a0.1<1>:ud	a0.1<0;1,0>:ud	0x00400040:ud					// Update pointers
196
	(-f0.0) jmpi (1)	SetHWScoreboard_Remainder_Loop
197
 
198
// All MBs have been decoded. Terminate the thread now
199
//
200
SetHWScoreboard_Done:
201
    END_THREAD
202
 
203
#if !defined(COMBINED_KERNEL)		// For standalone kernel only
204
.end_code
205
 
206
.end_kernel
207
#endif
208
 
209
// End of SetHWScoreboard