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 25 Module Name: 26 27 CD_Struct.h 28 29 Abstract: 30 31 Defines Script Language commands 32 33 Revision History: 34 35 NEG:26.08.2002 Initiated. 36 --*/ 37 38 #ifndef _CD_STRUCTS_H_ 39 #define _CD_STRUCTS_H_ 40 41 #include "CD_binding.h" 42 43 /* Endaianness should be specified before inclusion, 44 * default to little endian 45 */ 46 #ifndef ATOM_BIG_ENDIAN 47 #error Endian not specified 48 #endif 49 50 #ifdef UEFI_BUILD 51 typedef UINT16** PTABLE_UNIT_TYPE; 52 typedef UINTN TABLE_UNIT_TYPE; 53 #else 54 typedef UINT16* PTABLE_UNIT_TYPE; 55 typedef UINT16 TABLE_UNIT_TYPE; 56 #endif 57 58 #include <regsdef.h> //This important file is dynamically generated based on the ASIC!!!! 59 60 #define PARSER_MAJOR_REVISION 5 61 #define PARSER_MINOR_REVISION 0 62 63 //#include "atombios.h" 64 #if (PARSER_TYPE==DRIVER_TYPE_PARSER) 65 #ifdef FGL_LINUX 66 #pragma pack(push,1) 67 #else 68 #pragma pack(push) 69 #pragma pack(1) 70 #endif 71 #endif 72 73 #include "CD_Common_Types.h" 74 #include "CD_Opcodes.h" 75 typedef UINT16 WORK_SPACE_SIZE; 76 typedef enum _CD_STATUS{ 77 CD_SUCCESS, 78 CD_CALL_TABLE, 79 CD_COMPLETED=0x10, 80 CD_GENERAL_ERROR=0x80, 81 CD_INVALID_OPCODE, 82 CD_NOT_IMPLEMENTED, 83 CD_EXEC_TABLE_NOT_FOUND, 84 CD_EXEC_PARAMETER_ERROR, 85 CD_EXEC_PARSER_ERROR, 86 CD_INVALID_DESTINATION_TYPE, 87 CD_UNEXPECTED_BEHAVIOR, 88 CD_INVALID_SWITCH_OPERAND_SIZE 89 }CD_STATUS; 90 91 #define PARSER_STRINGS 0 92 #define PARSER_DEC 1 93 #define PARSER_HEX 2 94 95 #define DB_CURRENT_COMMAND_TABLE 0xFF 96 97 #define TABLE_FORMAT_BIOS 0 98 #define TABLE_FORMAT_EASF 1 99 100 #define EASF_TABLE_INDEX_MASK 0xfc 101 #define EASF_TABLE_ATTR_MASK 0x03 102 103 #define CD_ERROR(a) (((INTN) (a)) > CD_COMPLETED) 104 #define CD_ERROR_OR_COMPLETED(a) (((INTN) (a)) > CD_SUCCESS) 105 106 107 #if (BIOS_PARSER==1) 108 #ifdef _H2INC 109 #define STACK_BASED 110 #else 111 extern __segment farstack; 112 #define STACK_BASED __based(farstack) 113 #endif 114 #else 115 #define STACK_BASED 116 #endif 117 118 typedef enum _COMPARE_FLAGS{ 119 Below, 120 Equal, 121 Above, 122 NotEqual, 123 Overflow, 124 NoCondition 125 }COMPARE_FLAGS; 126 127 typedef UINT16 IO_BASE_ADDR; 128 129 typedef struct _BUS_DEV_FUNC_PCI_ADDR{ 130 UINT8 Register; 131 UINT8 Function; 132 UINT8 Device; 133 UINT8 Bus; 134 } BUS_DEV_FUNC_PCI_ADDR; 135 136 typedef struct _BUS_DEV_FUNC{ 137 UINT8 Function : 3; 138 UINT8 Device : 5; 139 UINT8 Bus; 140 } BUS_DEV_FUNC; 141 142 #ifndef UEFI_BUILD 143 typedef struct _PCI_CONFIG_ACCESS_CF8{ 144 UINT32 Reg : 8; 145 UINT32 Func : 3; 146 UINT32 Dev : 5; 147 UINT32 Bus : 8; 148 UINT32 Reserved: 7; 149 UINT32 Enable : 1; 150 } PCI_CONFIG_ACCESS_CF8; 151 #endif 152 153 typedef enum _MEM_RESOURCE { 154 Stack_Resource, 155 FrameBuffer_Resource, 156 BIOS_Image_Resource 157 }MEM_RESOURCE; 158 159 typedef enum _PORTS{ 160 ATI_RegsPort, 161 PCI_Port, 162 SystemIO_Port 163 }PORTS; 164 165 typedef enum _OPERAND_TYPE { 166 typeRegister, 167 typeParamSpace, 168 typeWorkSpace, 169 typeFrameBuffer, 170 typeIndirect, 171 typeDirect, 172 typePLL, 173 typeMC 174 }OPERAND_TYPE; 175 176 typedef enum _DESTINATION_OPERAND_TYPE { 177 destRegister, 178 destParamSpace, 179 destWorkSpace, 180 destFrameBuffer, 181 destPLL, 182 destMC 183 }DESTINATION_OPERAND_TYPE; 184 185 typedef enum _SOURCE_OPERAND_TYPE { 186 sourceRegister, 187 sourceParamSpace, 188 sourceWorkSpace, 189 sourceFrameBuffer, 190 sourceIndirect, 191 sourceDirect, 192 sourcePLL, 193 sourceMC 194 }SOURCE_OPERAND_TYPE; 195 196 typedef enum _ALIGNMENT_TYPE { 197 alignmentDword, 198 alignmentLowerWord, 199 alignmentMiddleWord, 200 alignmentUpperWord, 201 alignmentByte0, 202 alignmentByte1, 203 alignmentByte2, 204 alignmentByte3 205 }ALIGNMENT_TYPE; 206 207 208 #define INDIRECT_IO_READ 0 209 #define INDIRECT_IO_WRITE 0x80 210 #define INDIRECT_IO_MM 0 211 #define INDIRECT_IO_PLL 1 212 #define INDIRECT_IO_MC 2 213 214 typedef struct _PARAMETERS_TYPE{ 215 UINT8 Destination; 216 UINT8 Source; 217 }PARAMETERS_TYPE; 218 /* The following structures don't used to allocate any type of objects(variables). 219 they are serve the only purpose: Get proper access to data(commands), found in the tables*/ 220 typedef struct _PA_BYTE_BYTE{ 221 UINT8 PA_Destination; 222 UINT8 PA_Source; 223 UINT8 PA_Padding[8]; 224 }PA_BYTE_BYTE; 225 typedef struct _PA_BYTE_WORD{ 226 UINT8 PA_Destination; 227 UINT16 PA_Source; 228 UINT8 PA_Padding[7]; 229 }PA_BYTE_WORD; 230 typedef struct _PA_BYTE_DWORD{ 231 UINT8 PA_Destination; 232 UINT32 PA_Source; 233 UINT8 PA_Padding[5]; 234 }PA_BYTE_DWORD; 235 typedef struct _PA_WORD_BYTE{ 236 UINT16 PA_Destination; 237 UINT8 PA_Source; 238 UINT8 PA_Padding[7]; 239 }PA_WORD_BYTE; 240 typedef struct _PA_WORD_WORD{ 241 UINT16 PA_Destination; 242 UINT16 PA_Source; 243 UINT8 PA_Padding[6]; 244 }PA_WORD_WORD; 245 typedef struct _PA_WORD_DWORD{ 246 UINT16 PA_Destination; 247 UINT32 PA_Source; 248 UINT8 PA_Padding[4]; 249 }PA_WORD_DWORD; 250 typedef struct _PA_WORD_XX{ 251 UINT16 PA_Destination; 252 UINT8 PA_Padding[8]; 253 }PA_WORD_XX; 254 typedef struct _PA_BYTE_XX{ 255 UINT8 PA_Destination; 256 UINT8 PA_Padding[9]; 257 }PA_BYTE_XX; 258 /*The following 6 definitions used for Mask operation*/ 259 typedef struct _PA_BYTE_BYTE_BYTE{ 260 UINT8 PA_Destination; 261 UINT8 PA_AndMaskByte; 262 UINT8 PA_OrMaskByte; 263 UINT8 PA_Padding[7]; 264 }PA_BYTE_BYTE_BYTE; 265 typedef struct _PA_BYTE_WORD_WORD{ 266 UINT8 PA_Destination; 267 UINT16 PA_AndMaskWord; 268 UINT16 PA_OrMaskWord; 269 UINT8 PA_Padding[5]; 270 }PA_BYTE_WORD_WORD; 271 typedef struct _PA_BYTE_DWORD_DWORD{ 272 UINT8 PA_Destination; 273 UINT32 PA_AndMaskDword; 274 UINT32 PA_OrMaskDword; 275 UINT8 PA_Padding; 276 }PA_BYTE_DWORD_DWORD; 277 typedef struct _PA_WORD_BYTE_BYTE{ 278 UINT16 PA_Destination; 279 UINT8 PA_AndMaskByte; 280 UINT8 PA_OrMaskByte; 281 UINT8 PA_Padding[6]; 282 }PA_WORD_BYTE_BYTE; 283 typedef struct _PA_WORD_WORD_WORD{ 284 UINT16 PA_Destination; 285 UINT16 PA_AndMaskWord; 286 UINT16 PA_OrMaskWord; 287 UINT8 PA_Padding[4]; 288 }PA_WORD_WORD_WORD; 289 typedef struct _PA_WORD_DWORD_DWORD{ 290 UINT16 PA_Destination; 291 UINT32 PA_AndMaskDword; 292 UINT32 PA_OrMaskDword; 293 }PA_WORD_DWORD_DWORD; 294 295 296 typedef union _PARAMETER_ACCESS { 297 PA_BYTE_XX ByteXX; 298 PA_BYTE_BYTE ByteByte; 299 PA_BYTE_WORD ByteWord; 300 PA_BYTE_DWORD ByteDword; 301 PA_WORD_BYTE WordByte; 302 PA_WORD_WORD WordWord; 303 PA_WORD_DWORD WordDword; 304 PA_WORD_XX WordXX; 305 /*The following 6 definitions used for Mask operation*/ 306 PA_BYTE_BYTE_BYTE ByteByteAndByteOr; 307 PA_BYTE_WORD_WORD ByteWordAndWordOr; 308 PA_BYTE_DWORD_DWORD ByteDwordAndDwordOr; 309 PA_WORD_BYTE_BYTE WordByteAndByteOr; 310 PA_WORD_WORD_WORD WordWordAndWordOr; 311 PA_WORD_DWORD_DWORD WordDwordAndDwordOr; 312 }PARAMETER_ACCESS; 313 314 typedef struct _COMMAND_ATTRIBUTE { 315 #if ATOM_BIG_ENDIAN 316 UINT8 DestinationAlignment:2; 317 UINT8 SourceAlignment:3; 318 UINT8 Source:3; 319 #else 320 UINT8 Source:3; 321 UINT8 SourceAlignment:3; 322 UINT8 DestinationAlignment:2; 323 #endif 324 }COMMAND_ATTRIBUTE; 325 326 typedef struct _SOURCE_DESTINATION_ALIGNMENT{ 327 UINT8 DestAlignment; 328 UINT8 SrcAlignment; 329 }SOURCE_DESTINATION_ALIGNMENT; 330 typedef struct _MULTIPLICATION_RESULT{ 331 UINT32 Low32Bit; 332 UINT32 High32Bit; 333 }MULTIPLICATION_RESULT; 334 typedef struct _DIVISION_RESULT{ 335 UINT32 Quotient32; 336 UINT32 Reminder32; 337 }DIVISION_RESULT; 338 typedef union _DIVISION_MULTIPLICATION_RESULT{ 339 MULTIPLICATION_RESULT Multiplication; 340 DIVISION_RESULT Division; 341 }DIVISION_MULTIPLICATION_RESULT; 342 typedef struct _COMMAND_HEADER { 343 UINT8 Opcode; 344 COMMAND_ATTRIBUTE Attribute; 345 }COMMAND_HEADER; 346 347 typedef struct _GENERIC_ATTRIBUTE_COMMAND{ 348 COMMAND_HEADER Header; 349 PARAMETER_ACCESS Parameters; 350 } GENERIC_ATTRIBUTE_COMMAND; 351 352 typedef struct _COMMAND_TYPE_1{ 353 UINT8 Opcode; 354 PARAMETER_ACCESS Parameters; 355 } COMMAND_TYPE_1; 356 357 typedef struct _COMMAND_TYPE_OPCODE_OFFSET16{ 358 UINT8 Opcode; 359 UINT16 CD_Offset16; 360 } COMMAND_TYPE_OPCODE_OFFSET16; 361 362 typedef struct _COMMAND_TYPE_OPCODE_OFFSET32{ 363 UINT8 Opcode; 364 UINT32 CD_Offset32; 365 } COMMAND_TYPE_OPCODE_OFFSET32; 366 367 typedef struct _COMMAND_TYPE_OPCODE_VALUE_BYTE{ 368 UINT8 Opcode; 369 UINT8 Value; 370 } COMMAND_TYPE_OPCODE_VALUE_BYTE; 371 372 typedef union _COMMAND_SPECIFIC_UNION{ 373 UINT8 ContinueSwitch; 374 UINT8 ControlOperandSourcePosition; 375 UINT8 IndexInMasterTable; 376 } COMMAND_SPECIFIC_UNION; 377 378 379 typedef struct _CD_GENERIC_BYTE{ 380 #if ATOM_BIG_ENDIAN 381 UINT16 PS_SizeInDwordsUsedByCallingTable:5; 382 UINT16 CurrentPort:2; 383 UINT16 CommandAccessType:3; 384 UINT16 CurrentParameterSize:3; 385 UINT16 CommandType:3; 386 #else 387 UINT16 CommandType:3; 388 UINT16 CurrentParameterSize:3; 389 UINT16 CommandAccessType:3; 390 UINT16 CurrentPort:2; 391 UINT16 PS_SizeInDwordsUsedByCallingTable:5; 392 #endif 393 }CD_GENERIC_BYTE; 394 395 typedef UINT8 COMMAND_TYPE_OPCODE_ONLY; 396 397 typedef UINT8 COMMAND_HEADER_POINTER; 398 399 400 #if (PARSER_TYPE==BIOS_TYPE_PARSER) 401 402 typedef struct _DEVICE_DATA { 403 UINT32 STACK_BASED *pParameterSpace; 404 UINT8 *pBIOS_Image; 405 UINT8 format; 406 #if (IO_INTERFACE==PARSER_INTERFACE) 407 IO_BASE_ADDR IOBase; 408 #endif 409 } DEVICE_DATA; 410 411 #else 412 413 typedef struct _DEVICE_DATA { 414 UINT32 *pParameterSpace; 415 VOID *CAIL; 416 UINT8 *pBIOS_Image; 417 UINT32 format; 418 } DEVICE_DATA; 419 420 #endif 421 422 struct _PARSER_TEMP_DATA; 423 typedef UINT32 WORKSPACE_POINTER; 424 425 struct _WORKING_TABLE_DATA{ 426 UINT8 * pTableHead; 427 COMMAND_HEADER_POINTER * IP; // Commands pointer 428 WORKSPACE_POINTER STACK_BASED * pWorkSpace; 429 struct _WORKING_TABLE_DATA STACK_BASED * prevWorkingTableData; 430 }; 431 432 433 434 typedef struct _PARSER_TEMP_DATA{ 435 DEVICE_DATA STACK_BASED *pDeviceData; 436 struct _WORKING_TABLE_DATA STACK_BASED *pWorkingTableData; 437 UINT32 SourceData32; 438 UINT32 DestData32; 439 DIVISION_MULTIPLICATION_RESULT MultiplicationOrDivision; 440 UINT32 Index; 441 UINT32 CurrentFB_Window; 442 UINT32 IndirectData; 443 UINT16 CurrentRegBlock; 444 TABLE_UNIT_TYPE CurrentDataBlock; 445 UINT16 AttributesData; 446 // UINT8 *IndirectIOTable; 447 UINT8 *IndirectIOTablePointer; 448 GENERIC_ATTRIBUTE_COMMAND *pCmd; //CurrentCommand; 449 SOURCE_DESTINATION_ALIGNMENT CD_Mask; 450 PARAMETERS_TYPE ParametersType; 451 CD_GENERIC_BYTE Multipurpose; 452 UINT8 CompareFlags; 453 COMMAND_SPECIFIC_UNION CommandSpecific; 454 CD_STATUS Status; 455 UINT8 Shift2MaskConverter; 456 UINT8 CurrentPortID; 457 } PARSER_TEMP_DATA; 458 459 460 typedef struct _WORKING_TABLE_DATA WORKING_TABLE_DATA; 461 462 463 464 typedef VOID (*COMMANDS_DECODER)(PARSER_TEMP_DATA STACK_BASED * pParserTempData); 465 typedef VOID (*WRITE_IO_FUNCTION)(PARSER_TEMP_DATA STACK_BASED * pParserTempData); 466 typedef UINT32 (*READ_IO_FUNCTION)(PARSER_TEMP_DATA STACK_BASED * pParserTempData); 467 typedef UINT32 (*CD_GET_PARAMETERS)(PARSER_TEMP_DATA STACK_BASED * pParserTempData); 468 469 typedef struct _COMMANDS_PROPERTIES 470 { 471 COMMANDS_DECODER function; 472 UINT8 destination; 473 UINT8 headersize; 474 } COMMANDS_PROPERTIES; 475 476 typedef struct _INDIRECT_IO_PARSER_COMMANDS 477 { 478 COMMANDS_DECODER func; 479 UINT8 csize; 480 } INDIRECT_IO_PARSER_COMMANDS; 481 482 #if (PARSER_TYPE==DRIVER_TYPE_PARSER) 483 #pragma pack(pop) 484 #endif 485 486 #endif 487