1/*
2 * Copyright 2006-2007 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23/**
24
25Module Name:
26
27    CD_Operations.c
28
29Abstract:
30
31		Functions Implementing Command Operations and other common functions
32
33Revision History:
34
35	NEG:27.09.2002	Initiated.
36--*/
37#define __SW_4
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#include <X11/Xos.h>
44#include "xorg-server.h"
45#include "compiler.h"
46
47#include "Decoder.h"
48
49VOID PutDataRegister(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
50VOID PutDataPS(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
51VOID PutDataWS(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
52VOID PutDataFB(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
53VOID PutDataPLL(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
54VOID PutDataMC(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
55
56UINT32 GetParametersDirect32(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
57UINT32 GetParametersDirect16(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
58UINT32 GetParametersDirect8(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
59
60UINT32 GetParametersRegister(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
61UINT32 GetParametersPS(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
62UINT32 GetParametersWS(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
63UINT32 GetParametersFB(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
64UINT32 GetParametersPLL(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
65UINT32 GetParametersMC(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
66
67VOID SkipParameters16(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
68VOID SkipParameters8(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
69
70UINT32 GetParametersIndirect(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
71UINT32 GetParametersDirect(PARSER_TEMP_DATA STACK_BASED *	pParserTempData);
72
73UINT16* GetDataMasterTablePointer(DEVICE_DATA STACK_BASED*  pDeviceData);
74UINT8 GetTrueIndexInMasterTable(PARSER_TEMP_DATA STACK_BASED * pParserTempData, UINT8 IndexInMasterTable);
75
76
77WRITE_IO_FUNCTION WritePCIFunctions[8] =   {
78    WritePCIReg32,
79    WritePCIReg16, WritePCIReg16, WritePCIReg16,
80    WritePCIReg8,WritePCIReg8,WritePCIReg8,WritePCIReg8
81};
82WRITE_IO_FUNCTION WriteIOFunctions[8] =    {
83    WriteSysIOReg32,
84    WriteSysIOReg16,WriteSysIOReg16,WriteSysIOReg16,
85    WriteSysIOReg8,WriteSysIOReg8,WriteSysIOReg8,WriteSysIOReg8
86};
87READ_IO_FUNCTION ReadPCIFunctions[8] =      {
88    (READ_IO_FUNCTION)ReadPCIReg32,
89    (READ_IO_FUNCTION)ReadPCIReg16,
90    (READ_IO_FUNCTION)ReadPCIReg16,
91    (READ_IO_FUNCTION)ReadPCIReg16,
92    (READ_IO_FUNCTION)ReadPCIReg8,
93    (READ_IO_FUNCTION)ReadPCIReg8,
94    (READ_IO_FUNCTION)ReadPCIReg8,
95    (READ_IO_FUNCTION)ReadPCIReg8
96};
97READ_IO_FUNCTION ReadIOFunctions[8] =       {
98    (READ_IO_FUNCTION)ReadSysIOReg32,
99    (READ_IO_FUNCTION)ReadSysIOReg16,
100    (READ_IO_FUNCTION)ReadSysIOReg16,
101    (READ_IO_FUNCTION)ReadSysIOReg16,
102    (READ_IO_FUNCTION)ReadSysIOReg8,
103    (READ_IO_FUNCTION)ReadSysIOReg8,
104    (READ_IO_FUNCTION)ReadSysIOReg8,
105    (READ_IO_FUNCTION)ReadSysIOReg8
106};
107READ_IO_FUNCTION GetParametersDirectArray[8]={
108    GetParametersDirect32,
109    GetParametersDirect16,GetParametersDirect16,GetParametersDirect16,
110    GetParametersDirect8,GetParametersDirect8,GetParametersDirect8,
111    GetParametersDirect8
112};
113
114COMMANDS_DECODER PutDataFunctions[6]   =     {
115    PutDataRegister,
116    PutDataPS,
117    PutDataWS,
118    PutDataFB,
119    PutDataPLL,
120    PutDataMC
121};
122CD_GET_PARAMETERS GetDestination[6]   =     {
123    GetParametersRegister,
124    GetParametersPS,
125    GetParametersWS,
126    GetParametersFB,
127    GetParametersPLL,
128    GetParametersMC
129};
130
131COMMANDS_DECODER SkipDestination[6]   =     {
132    SkipParameters16,
133    SkipParameters8,
134    SkipParameters8,
135    SkipParameters8,
136    SkipParameters8,
137    SkipParameters8
138};
139
140CD_GET_PARAMETERS GetSource[8]   =          {
141    GetParametersRegister,
142    GetParametersPS,
143    GetParametersWS,
144    GetParametersFB,
145    GetParametersIndirect,
146    GetParametersDirect,
147    GetParametersPLL,
148    GetParametersMC
149};
150
151UINT32 AlignmentMask[8] =                   {0xFFFFFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF,0xFF,0xFF,0xFF};
152UINT8  SourceAlignmentShift[8] =            {0,0,8,16,0,8,16,24};
153UINT8  DestinationAlignmentShift[4] =       {0,8,16,24};
154
155#define INDIRECTIO_ID         1
156#define INDIRECTIO_END_OF_ID  9
157
158VOID IndirectIOCommand(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
159VOID IndirectIOCommand_MOVE(PARSER_TEMP_DATA STACK_BASED * pParserTempData, UINT32 temp);
160VOID IndirectIOCommand_MOVE_INDEX(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
161VOID IndirectIOCommand_MOVE_ATTR(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
162VOID IndirectIOCommand_MOVE_DATA(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
163VOID IndirectIOCommand_SET(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
164VOID IndirectIOCommand_CLEAR(PARSER_TEMP_DATA STACK_BASED * pParserTempData);
165
166
167INDIRECT_IO_PARSER_COMMANDS  IndirectIOParserCommands[10]={
168    {IndirectIOCommand,1},
169    {IndirectIOCommand,2},
170    {ReadIndReg32,3},
171    {WriteIndReg32,3},
172    {IndirectIOCommand_CLEAR,3},
173    {IndirectIOCommand_SET,3},
174    {IndirectIOCommand_MOVE_INDEX,4},
175    {IndirectIOCommand_MOVE_ATTR,4},
176    {IndirectIOCommand_MOVE_DATA,4},
177    {IndirectIOCommand,3}
178};
179
180
181VOID IndirectIOCommand(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
182{
183}
184
185
186VOID IndirectIOCommand_MOVE_INDEX(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
187{
188    pParserTempData->IndirectData &= ~((0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1])) << pParserTempData->IndirectIOTablePointer[3]);
189    pParserTempData->IndirectData |=(((pParserTempData->Index >> pParserTempData->IndirectIOTablePointer[2]) &
190				      (0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1]))) << pParserTempData->IndirectIOTablePointer[3]);
191}
192
193VOID IndirectIOCommand_MOVE_ATTR(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
194{
195    pParserTempData->IndirectData &= ~((0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1])) << pParserTempData->IndirectIOTablePointer[3]);
196    pParserTempData->IndirectData |=(((pParserTempData->AttributesData >> pParserTempData->IndirectIOTablePointer[2])
197				      & (0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1]))) << pParserTempData->IndirectIOTablePointer[3]);
198}
199
200VOID IndirectIOCommand_MOVE_DATA(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
201{
202    pParserTempData->IndirectData &= ~((0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1])) << pParserTempData->IndirectIOTablePointer[3]);
203    pParserTempData->IndirectData |=(((pParserTempData->DestData32 >> pParserTempData->IndirectIOTablePointer[2])
204				      & (0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1]))) << pParserTempData->IndirectIOTablePointer[3]);
205}
206
207
208VOID IndirectIOCommand_SET(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
209{
210    pParserTempData->IndirectData |= ((0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1])) << pParserTempData->IndirectIOTablePointer[2]);
211}
212
213VOID IndirectIOCommand_CLEAR(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
214{
215    pParserTempData->IndirectData &= ~((0xFFFFFFFF >> (32-pParserTempData->IndirectIOTablePointer[1])) << pParserTempData->IndirectIOTablePointer[2]);
216}
217
218/* from xorg-server 1.18 compiler.h */
219struct local__una_u32 { uint32_t x __attribute__((packed)); };
220
221/* Avoid conflicts with older versions of compiler.h */
222#define ldw_u xldw_u
223#define ldl_u xldl_u
224#define stl_u xstl_u
225
226static __inline__ uint16_t ldw_u(uint16_t *p)
227{
228	uint16_t ret;
229	memmove(&ret, p, sizeof(*p));
230	return ret;
231}
232
233static __inline__ uint32_t ldl_u(uint32_t *p)
234{
235	uint32_t ret;
236	memmove(&ret, p, sizeof(*p));
237	return ret;
238}
239
240static __inline__ void stl_u(uint32_t val, uint32_t *p)
241{
242	struct local__una_u32 *ptr = (struct local__una_u32 *) p;
243	ptr->x = val;
244}
245
246UINT32 IndirectInputOutput(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
247{
248    // if ((pParserTempData->IndirectData & 0x7f)==INDIRECT_IO_MM) pParserTempData->IndirectData|=pParserTempData->CurrentPortID;
249//  pParserTempData->IndirectIOTablePointer=pParserTempData->IndirectIOTable;
250    while (*pParserTempData->IndirectIOTablePointer)
251    {
252	if ((pParserTempData->IndirectIOTablePointer[0] == INDIRECTIO_ID) &&
253            (pParserTempData->IndirectIOTablePointer[1] == pParserTempData->IndirectData))
254	{
255	    pParserTempData->IndirectIOTablePointer+=IndirectIOParserCommands[*pParserTempData->IndirectIOTablePointer].csize;
256	    while (*pParserTempData->IndirectIOTablePointer != INDIRECTIO_END_OF_ID)
257	    {
258		IndirectIOParserCommands[*pParserTempData->IndirectIOTablePointer].func(pParserTempData);
259		pParserTempData->IndirectIOTablePointer+=IndirectIOParserCommands[*pParserTempData->IndirectIOTablePointer].csize;
260	    }
261	    pParserTempData->IndirectIOTablePointer-=UINT16LE_TO_CPU(ldw_u((uint16_t *)(pParserTempData->IndirectIOTablePointer+1)));
262	    pParserTempData->IndirectIOTablePointer++;
263	    return pParserTempData->IndirectData;
264	} else pParserTempData->IndirectIOTablePointer+=IndirectIOParserCommands[*pParserTempData->IndirectIOTablePointer].csize;
265    }
266    return 0;
267}
268
269
270
271VOID PutDataRegister(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
272{
273    pParserTempData->Index=(UINT32)UINT16LE_TO_CPU(pParserTempData->pCmd->Parameters.WordXX.PA_Destination);
274    pParserTempData->Index+=pParserTempData->CurrentRegBlock;
275    switch(pParserTempData->Multipurpose.CurrentPort){
276	case ATI_RegsPort:
277	    if (pParserTempData->CurrentPortID == INDIRECT_IO_MM)
278	    {
279		if (pParserTempData->Index==0) pParserTempData->DestData32 <<= 2;
280		WriteReg32( pParserTempData);
281	    } else
282	    {
283		pParserTempData->IndirectData=pParserTempData->CurrentPortID+INDIRECT_IO_WRITE;
284		IndirectInputOutput(pParserTempData);
285	    }
286	    break;
287	case PCI_Port:
288	    WritePCIFunctions[pParserTempData->pCmd->Header.Attribute.SourceAlignment](pParserTempData);
289	    break;
290	case SystemIO_Port:
291	    WriteIOFunctions[pParserTempData->pCmd->Header.Attribute.SourceAlignment](pParserTempData);
292	    break;
293    }
294}
295
296VOID PutDataPS(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
297{
298    stl_u(CPU_TO_UINT32LE(pParserTempData->DestData32),
299	  pParserTempData->pDeviceData->pParameterSpace+pParserTempData->pCmd->Parameters.ByteXX.PA_Destination);
300}
301
302VOID PutDataWS(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
303{
304    if (pParserTempData->pCmd->Parameters.ByteXX.PA_Destination < WS_QUOTIENT_C)
305      *(pParserTempData->pWorkingTableData->pWorkSpace+pParserTempData->pCmd->Parameters.ByteXX.PA_Destination) = pParserTempData->DestData32;
306    else
307	  switch (pParserTempData->pCmd->Parameters.ByteXX.PA_Destination)
308	  {
309	    case WS_REMINDER_C:
310		pParserTempData->MultiplicationOrDivision.Division.Reminder32=pParserTempData->DestData32;
311		break;
312	    case WS_QUOTIENT_C:
313		pParserTempData->MultiplicationOrDivision.Division.Quotient32=pParserTempData->DestData32;
314		break;
315	    case WS_DATAPTR_C:
316#ifndef		UEFI_BUILD
317		pParserTempData->CurrentDataBlock=(UINT16)pParserTempData->DestData32;
318#else
319		pParserTempData->CurrentDataBlock=(UINTN)pParserTempData->DestData32;
320#endif
321		break;
322	    case WS_SHIFT_C:
323		pParserTempData->Shift2MaskConverter=(UINT8)pParserTempData->DestData32;
324		break;
325	    case WS_FB_WINDOW_C:
326		pParserTempData->CurrentFB_Window=pParserTempData->DestData32;
327		break;
328	    case WS_ATTRIBUTES_C:
329		pParserTempData->AttributesData=(UINT16)pParserTempData->DestData32;
330		break;
331	    case WS_REGPTR_C:
332		pParserTempData->CurrentRegBlock=(UINT16)pParserTempData->DestData32;
333		break;
334	}
335
336}
337
338VOID PutDataFB(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
339{
340    pParserTempData->Index=(UINT32)pParserTempData->pCmd->Parameters.ByteXX.PA_Destination;
341    //Make an Index from address first, then add to the Index
342    pParserTempData->Index+=(pParserTempData->CurrentFB_Window>>2);
343    WriteFrameBuffer32(pParserTempData);
344}
345
346VOID PutDataPLL(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
347{
348    pParserTempData->Index=(UINT32)pParserTempData->pCmd->Parameters.ByteXX.PA_Destination;
349    WritePLL32( pParserTempData );
350}
351
352VOID PutDataMC(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
353{
354    pParserTempData->Index=(UINT32)pParserTempData->pCmd->Parameters.ByteXX.PA_Destination;
355    WriteMC32( pParserTempData );
356}
357
358
359VOID SkipParameters8(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
360{
361    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
362}
363
364VOID SkipParameters16(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
365{
366    pParserTempData->pWorkingTableData->IP+=sizeof(UINT16);
367}
368
369
370UINT32 GetParametersRegister(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
371{
372    pParserTempData->Index=UINT16LE_TO_CPU(ldw_u((uint16_t *)pParserTempData->pWorkingTableData->IP));
373    pParserTempData->pWorkingTableData->IP+=sizeof(UINT16);
374    pParserTempData->Index+=pParserTempData->CurrentRegBlock;
375    switch(pParserTempData->Multipurpose.CurrentPort)
376    {
377	case PCI_Port:
378	    return ReadPCIFunctions[pParserTempData->pCmd->Header.Attribute.SourceAlignment](pParserTempData);
379	case SystemIO_Port:
380	    return ReadIOFunctions[pParserTempData->pCmd->Header.Attribute.SourceAlignment](pParserTempData);
381	case ATI_RegsPort:
382	default:
383	    if (pParserTempData->CurrentPortID == INDIRECT_IO_MM) return ReadReg32( pParserTempData );
384	    else
385	    {
386		pParserTempData->IndirectData=pParserTempData->CurrentPortID+INDIRECT_IO_READ;
387		return IndirectInputOutput(pParserTempData);
388	    }
389    }
390}
391
392UINT32 GetParametersPS(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
393{
394    UINT32 data;
395    pParserTempData->Index=*pParserTempData->pWorkingTableData->IP;
396    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
397    data = UINT32LE_TO_CPU(ldl_u(pParserTempData->pDeviceData->pParameterSpace+pParserTempData->Index));
398    return data;
399}
400
401UINT32 GetParametersWS(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
402{
403    pParserTempData->Index=*pParserTempData->pWorkingTableData->IP;
404    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
405    if (pParserTempData->Index < WS_QUOTIENT_C)
406	return *(pParserTempData->pWorkingTableData->pWorkSpace+pParserTempData->Index);
407    else
408	switch (pParserTempData->Index)
409	{
410	    case WS_REMINDER_C:
411		return pParserTempData->MultiplicationOrDivision.Division.Reminder32;
412	    case WS_QUOTIENT_C:
413		return pParserTempData->MultiplicationOrDivision.Division.Quotient32;
414	    case WS_DATAPTR_C:
415		return (UINT32)pParserTempData->CurrentDataBlock;
416	    case WS_OR_MASK_C:
417		return ((UINT32)1) << pParserTempData->Shift2MaskConverter;
418	    case WS_AND_MASK_C:
419		return ~(((UINT32)1) << pParserTempData->Shift2MaskConverter);
420	    case WS_FB_WINDOW_C:
421		return pParserTempData->CurrentFB_Window;
422	    case WS_ATTRIBUTES_C:
423		return pParserTempData->AttributesData;
424	    case WS_REGPTR_C:
425		return (UINT32)pParserTempData->CurrentRegBlock;
426	}
427    return 0;
428
429}
430
431UINT32 GetParametersFB(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
432{
433    pParserTempData->Index=*pParserTempData->pWorkingTableData->IP;
434    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
435    pParserTempData->Index+=(pParserTempData->CurrentFB_Window>>2);
436    return ReadFrameBuffer32(pParserTempData);
437}
438
439UINT32 GetParametersPLL(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
440{
441    pParserTempData->Index=*pParserTempData->pWorkingTableData->IP;
442    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
443    return ReadPLL32( pParserTempData );
444}
445
446UINT32 GetParametersMC(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
447{
448    pParserTempData->Index=*pParserTempData->pWorkingTableData->IP;
449    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
450    return ReadMC32( pParserTempData );
451}
452
453
454UINT32 GetParametersIndirect(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
455{
456    UINT32 ret;
457
458    pParserTempData->Index=UINT16LE_TO_CPU(ldw_u((uint16_t *)pParserTempData->pWorkingTableData->IP));
459    pParserTempData->pWorkingTableData->IP+=sizeof(UINT16);
460    ret = UINT32LE_TO_CPU(ldl_u((UINT32*)(RELATIVE_TO_BIOS_IMAGE(pParserTempData->Index)+pParserTempData->CurrentDataBlock)));
461    return ret;
462}
463
464UINT32 GetParametersDirect8(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
465{
466    pParserTempData->CD_Mask.SrcAlignment=alignmentByte0;
467    pParserTempData->Index=*(UINT8*)pParserTempData->pWorkingTableData->IP;
468    pParserTempData->pWorkingTableData->IP+=sizeof(UINT8);
469    return pParserTempData->Index;
470}
471
472UINT32 GetParametersDirect16(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
473{
474    pParserTempData->CD_Mask.SrcAlignment=alignmentLowerWord;
475    pParserTempData->Index=UINT16LE_TO_CPU(ldw_u((uint16_t *)pParserTempData->pWorkingTableData->IP));
476    pParserTempData->pWorkingTableData->IP+=sizeof(UINT16);
477    return pParserTempData->Index;
478}
479
480UINT32 GetParametersDirect32(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
481{
482    pParserTempData->CD_Mask.SrcAlignment=alignmentDword;
483    pParserTempData->Index=UINT32LE_TO_CPU(ldl_u((UINT32*)pParserTempData->pWorkingTableData->IP));
484    pParserTempData->pWorkingTableData->IP+=sizeof(UINT32);
485    return pParserTempData->Index;
486}
487
488
489UINT32 GetParametersDirect(PARSER_TEMP_DATA STACK_BASED *	pParserTempData)
490{
491    return GetParametersDirectArray[pParserTempData->pCmd->Header.Attribute.SourceAlignment](pParserTempData);
492}
493
494
495VOID CommonSourceDataTransformation(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
496{
497    pParserTempData->SourceData32 >>= SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
498    pParserTempData->SourceData32 &=  AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
499    pParserTempData->SourceData32 <<= DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment];
500}
501
502VOID CommonOperationDataTransformation(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
503{
504    pParserTempData->SourceData32 >>= SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
505    pParserTempData->SourceData32 &= AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
506    pParserTempData->DestData32   >>= DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment];
507    pParserTempData->DestData32   &= AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
508}
509
510VOID ProcessMove(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
511{
512    if (pParserTempData->CD_Mask.SrcAlignment!=alignmentDword)
513    {
514				pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
515    } else
516    {
517	SkipDestination[pParserTempData->ParametersType.Destination](pParserTempData);
518    }
519    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
520
521    if (pParserTempData->CD_Mask.SrcAlignment!=alignmentDword)
522    {
523	pParserTempData->DestData32 &= ~(AlignmentMask[pParserTempData->CD_Mask.SrcAlignment] << DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment]);
524	CommonSourceDataTransformation(pParserTempData);
525	pParserTempData->DestData32 |= pParserTempData->SourceData32;
526    } else
527    {
528	pParserTempData->DestData32=pParserTempData->SourceData32;
529    }
530    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
531}
532
533VOID ProcessMask(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
534{
535    UINT8 src;
536
537    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
538    src = pParserTempData->CD_Mask.SrcAlignment;
539    pParserTempData->SourceData32=GetParametersDirect(pParserTempData);
540    pParserTempData->Index=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
541    pParserTempData->SourceData32 <<= DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment];
542    pParserTempData->SourceData32 |= ~(AlignmentMask[pParserTempData->CD_Mask.SrcAlignment] << DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment]);
543    pParserTempData->DestData32   &= pParserTempData->SourceData32;
544    pParserTempData->Index        >>= SourceAlignmentShift[src];
545    pParserTempData->Index        &= AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
546    pParserTempData->Index        <<= DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment];
547    pParserTempData->DestData32   |= pParserTempData->Index;
548    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
549}
550
551VOID ProcessAnd(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
552{
553    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
554    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
555    pParserTempData->SourceData32 >>= SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
556    pParserTempData->SourceData32 <<= DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment];
557    pParserTempData->SourceData32 |= ~(AlignmentMask[pParserTempData->CD_Mask.SrcAlignment] << DestinationAlignmentShift[pParserTempData->CD_Mask.DestAlignment]);
558    pParserTempData->DestData32   &= pParserTempData->SourceData32;
559    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
560}
561
562VOID ProcessOr(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
563{
564    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
565    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
566    CommonSourceDataTransformation(pParserTempData);
567    pParserTempData->DestData32 |= pParserTempData->SourceData32;
568    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
569}
570
571VOID ProcessXor(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
572{
573    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
574    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
575    CommonSourceDataTransformation(pParserTempData);
576    pParserTempData->DestData32 ^= pParserTempData->SourceData32;
577    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
578}
579
580VOID ProcessShl(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
581{
582    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
583    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
584    CommonSourceDataTransformation(pParserTempData);
585    pParserTempData->DestData32 <<= pParserTempData->SourceData32;
586    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
587}
588
589VOID ProcessShr(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
590{
591    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
592    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
593    CommonSourceDataTransformation(pParserTempData);
594    pParserTempData->DestData32 >>= pParserTempData->SourceData32;
595    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
596}
597
598
599VOID ProcessADD(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
600{
601    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
602    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
603    CommonSourceDataTransformation(pParserTempData);
604    pParserTempData->DestData32 += pParserTempData->SourceData32;
605    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
606}
607
608VOID ProcessSUB(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
609{
610    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
611    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
612    CommonSourceDataTransformation(pParserTempData);
613    pParserTempData->DestData32 -= pParserTempData->SourceData32;
614    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
615}
616
617VOID ProcessMUL(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
618{
619    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
620    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
621    CommonOperationDataTransformation(pParserTempData);
622    pParserTempData->MultiplicationOrDivision.Multiplication.Low32Bit=pParserTempData->DestData32 * pParserTempData->SourceData32;
623}
624
625VOID ProcessDIV(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
626{
627    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
628    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
629
630    CommonOperationDataTransformation(pParserTempData);
631    pParserTempData->MultiplicationOrDivision.Division.Quotient32=
632	pParserTempData->DestData32 / pParserTempData->SourceData32;
633    pParserTempData->MultiplicationOrDivision.Division.Reminder32=
634	pParserTempData->DestData32 % pParserTempData->SourceData32;
635}
636
637
638VOID ProcessCompare(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
639{
640    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
641    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
642
643    CommonOperationDataTransformation(pParserTempData);
644
645    // Here we just set flags based on evaluation
646    if (pParserTempData->DestData32==pParserTempData->SourceData32)
647	pParserTempData->CompareFlags = Equal;
648    else
649	pParserTempData->CompareFlags =
650	    (UINT8)((pParserTempData->DestData32<pParserTempData->SourceData32) ? Below : Above);
651
652}
653
654VOID ProcessClear(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
655{
656    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
657
658    if (pParserTempData->ParametersType.Destination == 0 &&
659	pParserTempData->Multipurpose.CurrentPort == ATI_RegsPort &&
660	pParserTempData->Index == 0) {
661        pParserTempData->DestData32 = 0;
662    } else
663        pParserTempData->DestData32 &= ~(AlignmentMask[pParserTempData->CD_Mask.SrcAlignment] << SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment]);
664    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
665
666}
667
668VOID ProcessShift(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
669{
670    UINT32 mask = AlignmentMask[pParserTempData->CD_Mask.SrcAlignment] << SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
671    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
672    pParserTempData->SourceData32=GetParametersDirect8(pParserTempData);
673
674    // save original value of the destination
675    pParserTempData->Index = pParserTempData->DestData32 & ~mask;
676    pParserTempData->DestData32 &= mask;
677
678    if (pParserTempData->pCmd->Header.Opcode < SHIFT_RIGHT_REG_OPCODE)
679	pParserTempData->DestData32 <<= pParserTempData->SourceData32; else
680	    pParserTempData->DestData32 >>= pParserTempData->SourceData32;
681
682    // Clear any bits shifted out of masked area...
683    pParserTempData->DestData32 &= mask;
684    // ... and restore the area outside of masked with original values
685    pParserTempData->DestData32 |= pParserTempData->Index;
686
687    // write data back
688    PutDataFunctions[pParserTempData->ParametersType.Destination](pParserTempData);
689}
690
691VOID ProcessTest(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
692{
693    pParserTempData->DestData32=GetDestination[pParserTempData->ParametersType.Destination](pParserTempData);
694    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
695    CommonOperationDataTransformation(pParserTempData);
696    pParserTempData->CompareFlags =
697	(UINT8)((pParserTempData->DestData32 & pParserTempData->SourceData32) ? NotEqual : Equal);
698
699}
700
701VOID ProcessSetFB_Base(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
702{
703    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
704    pParserTempData->SourceData32 >>= SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
705    pParserTempData->SourceData32 &= AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
706    pParserTempData->CurrentFB_Window=pParserTempData->SourceData32;
707}
708
709VOID ProcessSwitch(PARSER_TEMP_DATA STACK_BASED * pParserTempData){
710    pParserTempData->SourceData32=GetSource[pParserTempData->ParametersType.Source](pParserTempData);
711    pParserTempData->SourceData32 >>= SourceAlignmentShift[pParserTempData->CD_Mask.SrcAlignment];
712    pParserTempData->SourceData32 &= AlignmentMask[pParserTempData->CD_Mask.SrcAlignment];
713
714    while ( UINT16LE_TO_CPU(ldw_u((uint16_t *)pParserTempData->pWorkingTableData->IP)) != (((UINT16)NOP_OPCODE << 8)+NOP_OPCODE))
715    {
716	if (*pParserTempData->pWorkingTableData->IP == 'c')
717	{
718	    pParserTempData->pWorkingTableData->IP++;
719	    pParserTempData->DestData32=GetParametersDirect(pParserTempData);
720	    pParserTempData->Index=GetParametersDirect16(pParserTempData);
721	    if (pParserTempData->SourceData32 == pParserTempData->DestData32)
722	    {
723 	        pParserTempData->pWorkingTableData->IP= RELATIVE_TO_TABLE(pParserTempData->Index);
724		return;
725	    }
726	}
727    }
728    pParserTempData->pWorkingTableData->IP+=sizeof(UINT16);
729}
730
731
732VOID	cmdSetDataBlock(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
733{
734    UINT8 value;
735    UINT16* pMasterDataTable;
736    value=((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.ByteXX.PA_Destination;
737    if (value == 0) pParserTempData->CurrentDataBlock=0; else
738    {
739	if (value == DB_CURRENT_COMMAND_TABLE)
740        {
741	    pParserTempData->CurrentDataBlock= (UINT16)(pParserTempData->pWorkingTableData->pTableHead-pParserTempData->pDeviceData->pBIOS_Image);
742        } else
743	{
744	    pMasterDataTable = GetDataMasterTablePointer(pParserTempData->pDeviceData);
745	    pParserTempData->CurrentDataBlock= UINT16LE_TO_CPU((TABLE_UNIT_TYPE)((PTABLE_UNIT_TYPE)pMasterDataTable)[value]);
746	}
747    }
748    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
749}
750
751VOID	cmdSet_ATI_Port(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
752{
753    pParserTempData->Multipurpose.CurrentPort=ATI_RegsPort;
754    pParserTempData->CurrentPortID = (UINT8)UINT16LE_TO_CPU(((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.WordXX.PA_Destination);
755    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
756}
757
758VOID	cmdSet_Reg_Block(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
759{
760    pParserTempData->CurrentRegBlock = UINT16LE_TO_CPU(((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.WordXX.PA_Destination);
761    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
762}
763
764
765//Atavism!!! Review!!!
766VOID	cmdSet_X_Port(PARSER_TEMP_DATA STACK_BASED * pParserTempData){
767    pParserTempData->Multipurpose.CurrentPort=pParserTempData->ParametersType.Destination;
768    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_ONLY);
769
770}
771
772VOID	cmdDelay_Millisec(PARSER_TEMP_DATA STACK_BASED * pParserTempData){
773    pParserTempData->SourceData32 =
774	((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.ByteXX.PA_Destination;
775    DelayMilliseconds(pParserTempData);
776    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
777}
778VOID	cmdDelay_Microsec(PARSER_TEMP_DATA STACK_BASED * pParserTempData){
779    pParserTempData->SourceData32 =
780	((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.ByteXX.PA_Destination;
781    DelayMicroseconds(pParserTempData);
782    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
783}
784
785VOID ProcessPostChar(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
786{
787    pParserTempData->SourceData32 =
788	((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.ByteXX.PA_Destination;
789    PostCharOutput(pParserTempData);
790    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
791}
792
793VOID ProcessDebug(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
794{
795    pParserTempData->SourceData32 =
796	((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.ByteXX.PA_Destination;
797    CallerDebugFunc(pParserTempData);
798    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
799}
800
801
802VOID ProcessDS(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
803{
804    pParserTempData->pWorkingTableData->IP+=UINT16LE_TO_CPU(((COMMAND_TYPE_1*)pParserTempData->pWorkingTableData->IP)->Parameters.WordXX.PA_Destination)+sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
805}
806
807
808VOID	cmdCall_Table(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
809{
810    UINT16*	MasterTableOffset;
811    pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_VALUE_BYTE);
812    MasterTableOffset = GetCommandMasterTablePointer(pParserTempData->pDeviceData);
813    if(((PTABLE_UNIT_TYPE)MasterTableOffset)[((COMMAND_TYPE_OPCODE_VALUE_BYTE*)pParserTempData->pCmd)->Value]!=0 )  // if the offset is not ZERO
814    {
815	ATOM_TABLE_ATTRIBUTE lTableAttr;
816
817	pParserTempData->CommandSpecific.IndexInMasterTable=GetTrueIndexInMasterTable(pParserTempData,((COMMAND_TYPE_OPCODE_VALUE_BYTE*)pParserTempData->pCmd)->Value);
818
819	lTableAttr = GetCommandTableAttribute(pParserTempData->pWorkingTableData->pTableHead);
820	pParserTempData->Multipurpose.PS_SizeInDwordsUsedByCallingTable = (lTableAttr.PS_SizeInBytes >>2);
821	pParserTempData->pDeviceData->pParameterSpace+=
822	    pParserTempData->Multipurpose.PS_SizeInDwordsUsedByCallingTable;
823	pParserTempData->Status=CD_CALL_TABLE;
824	pParserTempData->pCmd=(GENERIC_ATTRIBUTE_COMMAND*)MasterTableOffset;
825    }
826}
827
828
829VOID	cmdNOP_(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
830{
831}
832
833
834static VOID NotImplemented(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
835{
836    pParserTempData->Status = CD_NOT_IMPLEMENTED;
837}
838
839
840VOID ProcessJump(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
841{
842    if ((pParserTempData->ParametersType.Destination == NoCondition) ||
843	(pParserTempData->ParametersType.Destination == pParserTempData->CompareFlags ))
844    {
845
846      pParserTempData->pWorkingTableData->IP= RELATIVE_TO_TABLE(UINT16LE_TO_CPU(((COMMAND_TYPE_OPCODE_OFFSET16*)pParserTempData->pWorkingTableData->IP)->CD_Offset16));
847    } else
848    {
849	pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
850    }
851}
852
853VOID ProcessJumpE(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
854{
855    if ((pParserTempData->CompareFlags == Equal) ||
856	(pParserTempData->CompareFlags == pParserTempData->ParametersType.Destination))
857    {
858
859      pParserTempData->pWorkingTableData->IP= RELATIVE_TO_TABLE(UINT16LE_TO_CPU(((COMMAND_TYPE_OPCODE_OFFSET16*)pParserTempData->pWorkingTableData->IP)->CD_Offset16));
860    } else
861    {
862	pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
863    }
864}
865
866VOID ProcessJumpNE(PARSER_TEMP_DATA STACK_BASED * pParserTempData)
867{
868    if (pParserTempData->CompareFlags != Equal)
869    {
870
871      pParserTempData->pWorkingTableData->IP= RELATIVE_TO_TABLE(UINT16LE_TO_CPU(((COMMAND_TYPE_OPCODE_OFFSET16*)pParserTempData->pWorkingTableData->IP)->CD_Offset16));
872    } else
873    {
874	pParserTempData->pWorkingTableData->IP+=sizeof(COMMAND_TYPE_OPCODE_OFFSET16);
875    }
876}
877
878
879
880COMMANDS_PROPERTIES CallTable[] =
881{
882    { NULL, 0,0},
883    { ProcessMove,      destRegister,     sizeof(COMMAND_HEADER)},
884    { ProcessMove,      destParamSpace,   sizeof(COMMAND_HEADER)},
885    { ProcessMove,      destWorkSpace,    sizeof(COMMAND_HEADER)},
886    { ProcessMove,      destFrameBuffer,  sizeof(COMMAND_HEADER)},
887    { ProcessMove,      destPLL,          sizeof(COMMAND_HEADER)},
888    { ProcessMove,      destMC,           sizeof(COMMAND_HEADER)},
889    { ProcessAnd,       destRegister,     sizeof(COMMAND_HEADER)},
890    { ProcessAnd,       destParamSpace,   sizeof(COMMAND_HEADER)},
891    { ProcessAnd,       destWorkSpace,    sizeof(COMMAND_HEADER)},
892    { ProcessAnd,       destFrameBuffer,  sizeof(COMMAND_HEADER)},
893    { ProcessAnd,       destPLL,          sizeof(COMMAND_HEADER)},
894    { ProcessAnd,       destMC,           sizeof(COMMAND_HEADER)},
895    { ProcessOr,        destRegister,     sizeof(COMMAND_HEADER)},
896    { ProcessOr,        destParamSpace,   sizeof(COMMAND_HEADER)},
897    { ProcessOr,        destWorkSpace,    sizeof(COMMAND_HEADER)},
898    { ProcessOr,        destFrameBuffer,  sizeof(COMMAND_HEADER)},
899    { ProcessOr,        destPLL,          sizeof(COMMAND_HEADER)},
900    { ProcessOr,        destMC,           sizeof(COMMAND_HEADER)},
901    { ProcessShift,     destRegister,     sizeof(COMMAND_HEADER)},
902    { ProcessShift,     destParamSpace,   sizeof(COMMAND_HEADER)},
903    { ProcessShift,     destWorkSpace,    sizeof(COMMAND_HEADER)},
904    { ProcessShift,     destFrameBuffer,  sizeof(COMMAND_HEADER)},
905    { ProcessShift,     destPLL,          sizeof(COMMAND_HEADER)},
906    { ProcessShift,     destMC,           sizeof(COMMAND_HEADER)},
907    { ProcessShift,     destRegister,     sizeof(COMMAND_HEADER)},
908    { ProcessShift,     destParamSpace,   sizeof(COMMAND_HEADER)},
909    { ProcessShift,     destWorkSpace,    sizeof(COMMAND_HEADER)},
910    { ProcessShift,     destFrameBuffer,  sizeof(COMMAND_HEADER)},
911    { ProcessShift,     destPLL,          sizeof(COMMAND_HEADER)},
912    { ProcessShift,     destMC,           sizeof(COMMAND_HEADER)},
913    { ProcessMUL,       destRegister,     sizeof(COMMAND_HEADER)},
914    { ProcessMUL,       destParamSpace,   sizeof(COMMAND_HEADER)},
915    { ProcessMUL,       destWorkSpace,    sizeof(COMMAND_HEADER)},
916    { ProcessMUL,       destFrameBuffer,  sizeof(COMMAND_HEADER)},
917    { ProcessMUL,       destPLL,          sizeof(COMMAND_HEADER)},
918    { ProcessMUL,       destMC,           sizeof(COMMAND_HEADER)},
919    { ProcessDIV,       destRegister,     sizeof(COMMAND_HEADER)},
920    { ProcessDIV,       destParamSpace,   sizeof(COMMAND_HEADER)},
921    { ProcessDIV,       destWorkSpace,    sizeof(COMMAND_HEADER)},
922    { ProcessDIV,       destFrameBuffer,  sizeof(COMMAND_HEADER)},
923    { ProcessDIV,       destPLL,          sizeof(COMMAND_HEADER)},
924    { ProcessDIV,       destMC,           sizeof(COMMAND_HEADER)},
925    { ProcessADD,       destRegister,     sizeof(COMMAND_HEADER)},
926    { ProcessADD,       destParamSpace,   sizeof(COMMAND_HEADER)},
927    { ProcessADD,       destWorkSpace,    sizeof(COMMAND_HEADER)},
928    { ProcessADD,       destFrameBuffer,  sizeof(COMMAND_HEADER)},
929    { ProcessADD,       destPLL,          sizeof(COMMAND_HEADER)},
930    { ProcessADD,       destMC,           sizeof(COMMAND_HEADER)},
931    { ProcessSUB,       destRegister,     sizeof(COMMAND_HEADER)},
932    { ProcessSUB,       destParamSpace,   sizeof(COMMAND_HEADER)},
933    { ProcessSUB,       destWorkSpace,    sizeof(COMMAND_HEADER)},
934    { ProcessSUB,       destFrameBuffer,  sizeof(COMMAND_HEADER)},
935    { ProcessSUB,       destPLL,          sizeof(COMMAND_HEADER)},
936    { ProcessSUB,       destMC,           sizeof(COMMAND_HEADER)},
937    { cmdSet_ATI_Port,  ATI_RegsPort,     0},
938    { cmdSet_X_Port,    PCI_Port,         0},
939    { cmdSet_X_Port,    SystemIO_Port,    0},
940    { cmdSet_Reg_Block,	0,                0},
941    { ProcessSetFB_Base,0,                sizeof(COMMAND_HEADER)},
942    { ProcessCompare,   destRegister,     sizeof(COMMAND_HEADER)},
943    { ProcessCompare,   destParamSpace,   sizeof(COMMAND_HEADER)},
944    { ProcessCompare,   destWorkSpace,    sizeof(COMMAND_HEADER)},
945    { ProcessCompare,   destFrameBuffer,  sizeof(COMMAND_HEADER)},
946    { ProcessCompare,   destPLL,          sizeof(COMMAND_HEADER)},
947    { ProcessCompare,   destMC,           sizeof(COMMAND_HEADER)},
948    { ProcessSwitch,    0,              	sizeof(COMMAND_HEADER)},
949    { ProcessJump,			NoCondition,      0},
950    { ProcessJump,	    Equal,            0},
951    { ProcessJump,      Below,	          0},
952    { ProcessJump,      Above,	          0},
953    { ProcessJumpE,     Below,            0},
954    { ProcessJumpE,     Above,            0},
955    { ProcessJumpNE,		0,                0},
956    { ProcessTest,      destRegister,     sizeof(COMMAND_HEADER)},
957    { ProcessTest,      destParamSpace,   sizeof(COMMAND_HEADER)},
958    { ProcessTest,      destWorkSpace,    sizeof(COMMAND_HEADER)},
959    { ProcessTest,      destFrameBuffer,  sizeof(COMMAND_HEADER)},
960    { ProcessTest,      destPLL,          sizeof(COMMAND_HEADER)},
961    { ProcessTest,      destMC,           sizeof(COMMAND_HEADER)},
962    { cmdDelay_Millisec,0,                0},
963    { cmdDelay_Microsec,0,                0},
964    { cmdCall_Table,		0,                0},
965    /*cmdRepeat*/	    { NotImplemented,   0,                0},
966    { ProcessClear,     destRegister,     sizeof(COMMAND_HEADER)},
967    { ProcessClear,     destParamSpace,   sizeof(COMMAND_HEADER)},
968    { ProcessClear,     destWorkSpace,    sizeof(COMMAND_HEADER)},
969    { ProcessClear,     destFrameBuffer,  sizeof(COMMAND_HEADER)},
970    { ProcessClear,     destPLL,          sizeof(COMMAND_HEADER)},
971    { ProcessClear,     destMC,           sizeof(COMMAND_HEADER)},
972    { cmdNOP_,		      0,                sizeof(COMMAND_TYPE_OPCODE_ONLY)},
973    /*cmdEOT*/        { cmdNOP_,		      0,                sizeof(COMMAND_TYPE_OPCODE_ONLY)},
974    { ProcessMask,      destRegister,     sizeof(COMMAND_HEADER)},
975    { ProcessMask,      destParamSpace,   sizeof(COMMAND_HEADER)},
976    { ProcessMask,      destWorkSpace,    sizeof(COMMAND_HEADER)},
977    { ProcessMask,      destFrameBuffer,  sizeof(COMMAND_HEADER)},
978    { ProcessMask,      destPLL,          sizeof(COMMAND_HEADER)},
979    { ProcessMask,      destMC,           sizeof(COMMAND_HEADER)},
980    /*cmdPost_Card*/	{ ProcessPostChar,  0,                0},
981    /*cmdBeep*/		    { NotImplemented,   0,                0},
982    /*cmdSave_Reg*/	  { NotImplemented,   0,                0},
983    /*cmdRestore_Reg*/{ NotImplemented,   0,                0},
984    { cmdSetDataBlock,  0,                0},
985    { ProcessXor,        destRegister,     sizeof(COMMAND_HEADER)},
986    { ProcessXor,        destParamSpace,   sizeof(COMMAND_HEADER)},
987    { ProcessXor,        destWorkSpace,    sizeof(COMMAND_HEADER)},
988    { ProcessXor,        destFrameBuffer,  sizeof(COMMAND_HEADER)},
989    { ProcessXor,        destPLL,          sizeof(COMMAND_HEADER)},
990    { ProcessXor,        destMC,           sizeof(COMMAND_HEADER)},
991
992    { ProcessShl,        destRegister,     sizeof(COMMAND_HEADER)},
993    { ProcessShl,        destParamSpace,   sizeof(COMMAND_HEADER)},
994    { ProcessShl,        destWorkSpace,    sizeof(COMMAND_HEADER)},
995    { ProcessShl,        destFrameBuffer,  sizeof(COMMAND_HEADER)},
996    { ProcessShl,        destPLL,          sizeof(COMMAND_HEADER)},
997    { ProcessShl,        destMC,           sizeof(COMMAND_HEADER)},
998
999    { ProcessShr,        destRegister,     sizeof(COMMAND_HEADER)},
1000    { ProcessShr,        destParamSpace,   sizeof(COMMAND_HEADER)},
1001    { ProcessShr,        destWorkSpace,    sizeof(COMMAND_HEADER)},
1002    { ProcessShr,        destFrameBuffer,  sizeof(COMMAND_HEADER)},
1003    { ProcessShr,        destPLL,          sizeof(COMMAND_HEADER)},
1004    { ProcessShr,        destMC,           sizeof(COMMAND_HEADER)},
1005    /*cmdDebug*/		{ ProcessDebug,  0,                0},
1006    { ProcessDS,  0,                0},
1007
1008};
1009
1010// EOF
1011