1 #ifndef _ARC_ 2 #define _ARC_ 3 4 typedef ULONG ARC_STATUS; 5 6 /* Avoid conflicts with errno.h */ 7 #undef E2BIG 8 #undef EACCES 9 #undef EAGAIN 10 #undef EBADF 11 #undef EBUSY 12 #undef EFAULT 13 #undef EINVAL 14 #undef EIO 15 #undef EISDIR 16 #undef EMFILE 17 #undef EMLINK 18 #undef ENAMETOOLONG 19 #undef ENODEV 20 #undef ENOENT 21 #undef ENOEXEC 22 #undef ENOMEM 23 #undef ENOSPC 24 #undef ENOTDIR 25 #undef ENOTTY 26 #undef ENXIO 27 #undef EROFS 28 #undef EMAXIMUM 29 30 typedef enum _ARC_CODES 31 { 32 ESUCCESS, 33 E2BIG, 34 EACCES, 35 EAGAIN, 36 EBADF, 37 EBUSY, 38 EFAULT, 39 EINVAL, 40 EIO, 41 EISDIR, 42 EMFILE, 43 EMLINK, 44 ENAMETOOLONG, 45 ENODEV, 46 ENOENT, 47 ENOEXEC, 48 ENOMEM, 49 ENOSPC, 50 ENOTDIR, 51 ENOTTY, 52 ENXIO, 53 EROFS, 54 EMAXIMUM 55 } ARC_CODES; 56 57 typedef enum _SEEKMODE 58 { 59 SeekAbsolute, 60 SeekRelative, 61 } SEEKMODE; 62 63 typedef enum _OPENMODE 64 { 65 OpenReadOnly, 66 OpenWriteOnly, 67 OpenReadWrite, 68 CreateWriteOnly, 69 CreateReadOnly, 70 SupersedeWriteOnly, 71 SupersedeReadOnly, 72 SupersedeReadWrite, 73 OpenDirectory, 74 CreateDirectory, 75 } OPENMODE; 76 77 typedef enum _IDENTIFIER_FLAG 78 { 79 Failed = 0x01, 80 ReadOnly = 0x02, 81 Removable = 0x04, 82 ConsoleIn = 0x08, 83 ConsoleOut = 0x10, 84 Input = 0x20, 85 Output = 0x40 86 } IDENTIFIER_FLAG; 87 88 typedef enum _CONFIGURATION_CLASS 89 { 90 SystemClass, 91 ProcessorClass, 92 CacheClass, 93 AdapterClass, 94 ControllerClass, 95 PeripheralClass, 96 MemoryClass, 97 MaximumClass 98 } CONFIGURATION_CLASS; 99 100 // CONFIGURATION_TYPE is also defined in ntddk.h 101 #ifndef _ARC_DDK_ 102 typedef enum _CONFIGURATION_TYPE 103 { 104 ArcSystem, 105 CentralProcessor, 106 FloatingPointProcessor, 107 PrimaryIcache, 108 PrimaryDcache, 109 SecondaryIcache, 110 SecondaryDcache, 111 SecondaryCache, 112 EisaAdapter, 113 TcAdapter, 114 ScsiAdapter, 115 DtiAdapter, 116 MultiFunctionAdapter, 117 DiskController, 118 TapeController, 119 CdromController, 120 WormController, 121 SerialController, 122 NetworkController, 123 DisplayController, 124 ParallelController, 125 PointerController, 126 KeyboardController, 127 AudioController, 128 OtherController, 129 DiskPeripheral, 130 FloppyDiskPeripheral, 131 TapePeripheral, 132 ModemPeripheral, 133 MonitorPeripheral, 134 PrinterPeripheral, 135 PointerPeripheral, 136 KeyboardPeripheral, 137 TerminalPeripheral, 138 OtherPeripheral, 139 LinePeripheral, 140 NetworkPeripheral, 141 SystemMemory, 142 DockingInformation, 143 RealModeIrqRoutingTable, 144 RealModePCIEnumeration, 145 MaximumType 146 } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; 147 #endif /* _ARC_DDK_ */ 148 149 typedef struct _CONFIGURATION_COMPONENT 150 { 151 CONFIGURATION_CLASS Class; 152 CONFIGURATION_TYPE Type; 153 IDENTIFIER_FLAG Flags; 154 USHORT Version; 155 USHORT Revision; 156 ULONG Key; 157 ULONG AffinityMask; 158 ULONG ConfigurationDataLength; 159 ULONG IdentifierLength; 160 PCHAR Identifier; 161 } CONFIGURATION_COMPONENT, *PCONFIGURATION_COMPONENT; 162 163 typedef struct _CONFIGURATION_COMPONENT_DATA 164 { 165 struct _CONFIGURATION_COMPONENT_DATA *Parent; 166 struct _CONFIGURATION_COMPONENT_DATA *Child; 167 struct _CONFIGURATION_COMPONENT_DATA *Sibling; 168 CONFIGURATION_COMPONENT ComponentEntry; 169 PVOID ConfigurationData; 170 } CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA; 171 172 typedef enum _TYPE_OF_MEMORY 173 { 174 LoaderExceptionBlock, 175 LoaderSystemBlock, 176 LoaderFree, 177 LoaderBad, 178 LoaderLoadedProgram, 179 LoaderFirmwareTemporary, 180 LoaderFirmwarePermanent, 181 LoaderOsloaderHeap, 182 LoaderOsloaderStack, 183 LoaderSystemCode, 184 LoaderHalCode, 185 LoaderBootDriver, 186 LoaderConsoleInDriver, 187 LoaderConsoleOutDriver, 188 LoaderStartupDpcStack, 189 LoaderStartupKernelStack, 190 LoaderStartupPanicStack, 191 LoaderStartupPcrPage, 192 LoaderStartupPdrPage, 193 LoaderRegistryData, 194 LoaderMemoryData, 195 LoaderNlsData, 196 LoaderSpecialMemory, 197 LoaderBBTMemory, 198 LoaderReserve, 199 LoaderXIPRom, 200 LoaderHALCachedMemory, 201 LoaderLargePageFiller, 202 LoaderErrorLogMemory, 203 LoaderMaximum 204 } TYPE_OF_MEMORY; 205 206 typedef enum _MEMORY_TYPE 207 { 208 MemoryExceptionBlock, 209 MemorySystemBlock, 210 MemoryFree, 211 MemoryBad, 212 MemoryLoadedProgram, 213 MemoryFirmwareTemporary, 214 MemoryFirmwarePermanent, 215 MemoryFreeContiguous, 216 MemorySpecialMemory, 217 MemoryMaximum 218 } MEMORY_TYPE; 219 220 typedef struct _TIMEINFO 221 { 222 USHORT Year; 223 USHORT Month; 224 USHORT Day; 225 USHORT Hour; 226 USHORT Minute; 227 USHORT Second; 228 } TIMEINFO; 229 230 typedef struct _MEMORY_DESCRIPTOR 231 { 232 MEMORY_TYPE MemoryType; 233 PFN_NUMBER BasePage; 234 PFN_NUMBER PageCount; 235 } MEMORY_DESCRIPTOR, *PMEMORY_DESCRIPTOR; 236 237 typedef struct _MEMORY_ALLOCATION_DESCRIPTOR 238 { 239 LIST_ENTRY ListEntry; 240 TYPE_OF_MEMORY MemoryType; 241 PFN_NUMBER BasePage; 242 PFN_NUMBER PageCount; 243 } MEMORY_ALLOCATION_DESCRIPTOR, *PMEMORY_ALLOCATION_DESCRIPTOR; 244 245 typedef struct _BOOT_DRIVER_LIST_ENTRY 246 { 247 LIST_ENTRY Link; 248 UNICODE_STRING FilePath; 249 UNICODE_STRING RegistryPath; 250 struct _LDR_DATA_TABLE_ENTRY *LdrEntry; 251 } BOOT_DRIVER_LIST_ENTRY, *PBOOT_DRIVER_LIST_ENTRY; 252 253 typedef struct _ARC_DISK_SIGNATURE 254 { 255 LIST_ENTRY ListEntry; 256 ULONG Signature; 257 PCHAR ArcName; 258 ULONG CheckSum; 259 BOOLEAN ValidPartitionTable; 260 BOOLEAN xInt13; 261 BOOLEAN IsGpt; 262 BOOLEAN Reserved; 263 CHAR GptSignature[16]; 264 } ARC_DISK_SIGNATURE, *PARC_DISK_SIGNATURE; 265 266 typedef struct _ARC_DISK_INFORMATION 267 { 268 LIST_ENTRY DiskSignatureListHead; 269 } ARC_DISK_INFORMATION, *PARC_DISK_INFORMATION; 270 271 typedef struct _MONITOR_CONFIGURATION_DATA 272 { 273 USHORT Version; 274 USHORT Revision; 275 USHORT HorizontalResolution; 276 USHORT HorizontalDisplayTime; 277 USHORT HorizontalBackPorch; 278 USHORT HorizontalFrontPorch; 279 USHORT HorizontalSync; 280 USHORT VerticalResolution; 281 USHORT VerticalBackPorch; 282 USHORT VerticalFrontPorch; 283 USHORT VerticalSync; 284 USHORT HorizontalScreenSize; 285 USHORT VerticalScreenSize; 286 } MONITOR_CONFIGURATION_DATA, *PMONITOR_CONFIGURATION_DATA; 287 288 typedef struct _FLOPPY_CONFIGURATION_DATA 289 { 290 USHORT Version; 291 USHORT Revision; 292 CHAR Size[8]; 293 ULONG MaxDensity; 294 ULONG MountDensity; 295 } FLOPPY_CONFIGURATION_DATA, *PFLOPPY_CONFIGURATION_DATA; 296 297 // 298 // SMBIOS Table Header (FIXME: maybe move to smbios.h?) 299 // 300 typedef struct _SMBIOS_TABLE_HEADER 301 { 302 CHAR Signature[4]; 303 UCHAR Checksum; 304 UCHAR Length; 305 UCHAR MajorVersion; 306 UCHAR MinorVersion; 307 USHORT MaximumStructureSize; 308 UCHAR EntryPointRevision; 309 UCHAR Reserved[5]; 310 CHAR Signature2[5]; 311 UCHAR IntermediateChecksum; 312 USHORT StructureTableLength; 313 ULONG StructureTableAddress; 314 USHORT NumberStructures; 315 UCHAR Revision; 316 } SMBIOS_TABLE_HEADER, *PSMBIOS_TABLE_HEADER; 317 318 // 319 // NLS Data Block 320 // 321 typedef struct _NLS_DATA_BLOCK 322 { 323 PVOID AnsiCodePageData; 324 PVOID OemCodePageData; 325 PVOID UnicodeCodePageData; 326 } NLS_DATA_BLOCK, *PNLS_DATA_BLOCK; 327 328 // 329 // ACPI Docking State 330 // 331 typedef struct _PROFILE_ACPI_DOCKING_STATE 332 { 333 USHORT DockingState; 334 USHORT SerialLength; 335 WCHAR SerialNumber[1]; 336 } PROFILE_ACPI_DOCKING_STATE, *PPROFILE_ACPI_DOCKING_STATE; 337 338 // 339 // Subsystem Specific Loader Blocks 340 // 341 typedef struct _PROFILE_PARAMETER_BLOCK 342 { 343 USHORT Status; 344 USHORT Reserved; 345 USHORT DockingState; 346 USHORT Capabilities; 347 ULONG DockID; 348 ULONG SerialNumber; 349 } PROFILE_PARAMETER_BLOCK, *PPROFILE_PARAMETER_BLOCK; 350 351 typedef struct _HEADLESS_LOADER_BLOCK 352 { 353 UCHAR UsedBiosSettings; 354 UCHAR DataBits; 355 UCHAR StopBits; 356 UCHAR Parity; 357 ULONG BaudRate; 358 ULONG PortNumber; 359 PUCHAR PortAddress; 360 USHORT PciDeviceId; 361 USHORT PciVendorId; 362 UCHAR PciBusNumber; 363 UCHAR PciSlotNumber; 364 UCHAR PciFunctionNumber; 365 ULONG PciFlags; 366 GUID SystemGUID; 367 UCHAR IsMMIODevice; 368 UCHAR TerminalType; 369 } HEADLESS_LOADER_BLOCK, *PHEADLESS_LOADER_BLOCK; 370 371 typedef struct _NETWORK_LOADER_BLOCK 372 { 373 PCHAR DHCPServerACK; 374 ULONG DHCPServerACKLength; 375 PCHAR BootServerReplyPacket; 376 ULONG BootServerReplyPacketLength; 377 } NETWORK_LOADER_BLOCK, *PNETWORK_LOADER_BLOCK; 378 379 typedef struct _LOADER_PERFORMANCE_DATA 380 { 381 ULONGLONG StartTime; 382 ULONGLONG EndTime; 383 } LOADER_PERFORMANCE_DATA, *PLOADER_PERFORMANCE_DATA; 384 385 // 386 // Extended Loader Parameter Block 387 // 388 // See http://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/loader_parameter_extension.htm 389 // for more details. 390 // 391 typedef struct _LOADER_PARAMETER_EXTENSION 392 { 393 ULONG Size; 394 PROFILE_PARAMETER_BLOCK Profile; 395 ULONG MajorVersion; /* Not anymore present starting NT 6.1 */ 396 ULONG MinorVersion; /* Not anymore present starting NT 6.1 */ 397 PVOID EmInfFileImage; 398 ULONG EmInfFileSize; 399 PVOID TriageDumpBlock; 400 // 401 // NT 5.1 402 // 403 ULONG_PTR LoaderPagesSpanned; /* Not anymore present starting NT 6.2 */ 404 PHEADLESS_LOADER_BLOCK HeadlessLoaderBlock; 405 PSMBIOS_TABLE_HEADER SMBiosEPSHeader; 406 PVOID DrvDBImage; 407 ULONG DrvDBSize; 408 PNETWORK_LOADER_BLOCK NetworkLoaderBlock; 409 // 410 // NT 5.2+ 411 // 412 #ifdef _X86_ 413 PUCHAR HalpIRQLToTPR; 414 PUCHAR HalpVectorToIRQL; 415 #endif 416 LIST_ENTRY FirmwareDescriptorListHead; 417 PVOID AcpiTable; 418 ULONG AcpiTableSize; 419 // 420 // NT 5.2 SP1+ 421 // 422 /** NT-version-dependent flags **/ 423 ULONG BootViaWinload:1; 424 ULONG BootViaEFI:1; 425 ULONG Reserved:30; 426 /********************************/ 427 PLOADER_PERFORMANCE_DATA LoaderPerformanceData; 428 LIST_ENTRY BootApplicationPersistentData; 429 PVOID WmdTestResult; 430 GUID BootIdentifier; 431 // 432 // NT 6 433 // 434 ULONG ResumePages; 435 PVOID DumpHeader; 436 } LOADER_PARAMETER_EXTENSION, *PLOADER_PARAMETER_EXTENSION; 437 438 // 439 // Architecture specific Loader Parameter Blocks 440 // 441 typedef struct _IA64_LOADER_BLOCK 442 { 443 ULONG PlaceHolder; 444 } IA64_LOADER_BLOCK, *PIA64_LOADER_BLOCK; 445 446 typedef struct _ALPHA_LOADER_BLOCK 447 { 448 ULONG PlaceHolder; 449 } ALPHA_LOADER_BLOCK, *PALPHA_LOADER_BLOCK; 450 451 typedef struct _I386_LOADER_BLOCK 452 { 453 PVOID CommonDataArea; 454 ULONG MachineType; 455 ULONG VirtualBias; 456 } I386_LOADER_BLOCK, *PI386_LOADER_BLOCK; 457 458 typedef struct _PPC_LOADER_BLOCK 459 { 460 PVOID BootInfo; 461 ULONG MachineType; 462 } PPC_LOADER_BLOCK, *PPPC_LOADER_BLOCK; 463 464 typedef struct _ARM_LOADER_BLOCK 465 { 466 #ifdef _ARM_ 467 ULONG InterruptStack; 468 ULONG FirstLevelDcacheSize; 469 ULONG FirstLevelDcacheFillSize; 470 ULONG FirstLevelIcacheSize; 471 ULONG FirstLevelIcacheFillSize; 472 ULONG GpBase; 473 ULONG PanicStack; 474 ULONG PcrPage; 475 ULONG PdrPage; 476 ULONG SecondLevelDcacheSize; 477 ULONG SecondLevelDcacheFillSize; 478 ULONG SecondLevelIcacheSize; 479 ULONG SecondLevelIcacheFillSize; 480 ULONG PcrPage2; 481 #else 482 ULONG PlaceHolder; 483 #endif 484 } ARM_LOADER_BLOCK, *PARM_LOADER_BLOCK; 485 486 // 487 // Firmware information block (NT6+) 488 // 489 490 typedef struct _VIRTUAL_EFI_RUNTIME_SERVICES 491 { 492 ULONG_PTR GetTime; 493 ULONG_PTR SetTime; 494 ULONG_PTR GetWakeupTime; 495 ULONG_PTR SetWakeupTime; 496 ULONG_PTR SetVirtualAddressMap; 497 ULONG_PTR ConvertPointer; 498 ULONG_PTR GetVariable; 499 ULONG_PTR GetNextVariableName; 500 ULONG_PTR SetVariable; 501 ULONG_PTR GetNextHighMonotonicCount; 502 ULONG_PTR ResetSystem; 503 ULONG_PTR UpdateCapsule; 504 ULONG_PTR QueryCapsuleCapabilities; 505 ULONG_PTR QueryVariableInfo; 506 } VIRTUAL_EFI_RUNTIME_SERVICES, *PVIRTUAL_EFI_RUNTIME_SERVICES; 507 508 typedef struct _EFI_FIRMWARE_INFORMATION 509 { 510 ULONG FirmwareVersion; 511 PVIRTUAL_EFI_RUNTIME_SERVICES VirtualEfiRuntimeServices; 512 ULONG SetVirtualAddressMapStatus; 513 ULONG MissedMappingsCount; 514 } EFI_FIRMWARE_INFORMATION, *PEFI_FIRMWARE_INFORMATION; 515 516 typedef struct _PCAT_FIRMWARE_INFORMATION 517 { 518 ULONG PlaceHolder; 519 } PCAT_FIRMWARE_INFORMATION, *PPCAT_FIRMWARE_INFORMATION; 520 521 typedef struct _FIRMWARE_INFORMATION_LOADER_BLOCK 522 { 523 ULONG FirmwareTypeEfi:1; 524 ULONG Reserved:31; 525 union 526 { 527 EFI_FIRMWARE_INFORMATION EfiInformation; 528 PCAT_FIRMWARE_INFORMATION PcatInformation; 529 } u; 530 } FIRMWARE_INFORMATION_LOADER_BLOCK, *PFIRMWARE_INFORMATION_LOADER_BLOCK; 531 532 // 533 // Loader Parameter Block 534 // 535 // See http://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/loader_parameter_block.htm 536 // for more details. 537 // 538 typedef struct _LOADER_PARAMETER_BLOCK 539 { 540 LIST_ENTRY LoadOrderListHead; 541 LIST_ENTRY MemoryDescriptorListHead; 542 LIST_ENTRY BootDriverListHead; 543 ULONG_PTR KernelStack; 544 ULONG_PTR Prcb; 545 ULONG_PTR Process; 546 ULONG_PTR Thread; 547 ULONG RegistryLength; 548 PVOID RegistryBase; 549 PCONFIGURATION_COMPONENT_DATA ConfigurationRoot; 550 PSTR ArcBootDeviceName; 551 PSTR ArcHalDeviceName; 552 PSTR NtBootPathName; 553 PSTR NtHalPathName; 554 PSTR LoadOptions; 555 PNLS_DATA_BLOCK NlsData; 556 PARC_DISK_INFORMATION ArcDiskInformation; 557 PVOID OemFontFile; 558 struct _SETUP_LOADER_BLOCK *SetupLdrBlock; 559 PLOADER_PARAMETER_EXTENSION Extension; 560 union 561 { 562 I386_LOADER_BLOCK I386; 563 ALPHA_LOADER_BLOCK Alpha; 564 IA64_LOADER_BLOCK IA64; 565 PPC_LOADER_BLOCK PowerPC; 566 ARM_LOADER_BLOCK Arm; 567 } u; 568 FIRMWARE_INFORMATION_LOADER_BLOCK FirmwareInformation; 569 } LOADER_PARAMETER_BLOCK, *PLOADER_PARAMETER_BLOCK; 570 571 typedef int CONFIGTYPE; 572 typedef struct tagFILEINFORMATION 573 { 574 LARGE_INTEGER StartingAddress; 575 LARGE_INTEGER EndingAddress; 576 LARGE_INTEGER CurrentAddress; 577 CONFIGTYPE Type; 578 ULONG FileNameLength; 579 UCHAR Attributes; 580 CHAR Filename[32]; 581 } FILEINFORMATION; 582 583 typedef 584 ARC_STATUS 585 (*ARC_CLOSE)( 586 ULONG FileId 587 ); 588 589 typedef 590 ARC_STATUS 591 (*ARC_GET_FILE_INFORMATION)( 592 ULONG FileId, 593 FILEINFORMATION* Information 594 ); 595 596 typedef 597 ARC_STATUS 598 (*ARC_OPEN)( 599 CHAR* Path, 600 OPENMODE OpenMode, 601 ULONG* FileId 602 ); 603 604 typedef 605 ARC_STATUS 606 (*ARC_READ)( 607 ULONG FileId, 608 VOID* Buffer, 609 ULONG N, ULONG* Count 610 ); 611 612 typedef 613 ARC_STATUS 614 (*ARC_SEEK)( 615 ULONG FileId, 616 LARGE_INTEGER* Position, 617 SEEKMODE SeekMode 618 ); 619 620 #endif 621