ReactOS 0.4.16-dev-2232-gc2aaa52
framebuf.c File Reference
#include <arc/arc.h>
#include <ndk/kefuncs.h>
#include <drivers/bootvid/framebuf.h>
#include <ndk/halfuncs.h>
Include dependency graph for framebuf.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DPRINT_TRACE(...)
 

Functions

static BOOLEAN IsNewConfigData (_In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
 
static VOID GetVideoData (_In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *Interrupt, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *ControlPort, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *CursorPort, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *VideoRam, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *DeviceSpecific)
 Given a CM_PARTIAL_RESOURCE_LIST, obtain pointers to resource descriptors for legacy video configuration: interrupt, control and cursor I/O ports, and video RAM memory descriptors. In addition, retrieve any device-specific resource present.
 
static VOID GetMonitorData (_In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *DeviceSpecific)
 Given a CM_PARTIAL_RESOURCE_LIST, obtain a pointer to resource descriptor for monitor configuration data, listed as a device-specific resource.
 
NTSTATUS GetFramebufferVideoData (_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
 
NTSTATUS GetFramebufferMonitorData (_Out_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
 
static INTERFACE_TYPE GetArcComponentInterface (_In_ PCONFIGURATION_COMPONENT Component, _Out_opt_ PULONG BusNumber)
 Retrieve the NT interface type and bus number of a given ARC configuration component, that can be used in a call to HalTranslateBusAddress() or to BootTranslateBusAddress().
 
static NTSTATUS FindBootDisplayFromLoaderARCTree (_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _Out_opt_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _Out_opt_ PINTERFACE_TYPE Interface, _Out_opt_ PULONG BusNumber)
 
NTSTATUS FindBootDisplay (_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _Out_opt_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _Out_opt_ PINTERFACE_TYPE Interface, _Out_opt_ PULONG BusNumber)
 Retrieves configuration data for the boot-time (POST) display controller and monitor peripheral.
 
BOOLEAN NTAPI BootTranslateBusAddress (_In_ INTERFACE_TYPE InterfaceType, _In_ ULONG BusNumber, _In_ PHYSICAL_ADDRESS BusAddress, _Inout_ PULONG AddressSpace, _Out_ PPHYSICAL_ADDRESS TranslatedAddress)
 Wrapper around HalTranslateBusAddress() and HALPRIVATEDISPATCH->HalFindBusAddressTranslation().
 

Macro Definition Documentation

◆ DPRINT_TRACE

#define DPRINT_TRACE (   ...)

Definition at line 15 of file framebuf.c.

Function Documentation

◆ BootTranslateBusAddress()

BOOLEAN NTAPI BootTranslateBusAddress ( _In_ INTERFACE_TYPE  InterfaceType,
_In_ ULONG  BusNumber,
_In_ PHYSICAL_ADDRESS  BusAddress,
_Inout_ PULONG  AddressSpace,
_Out_ PPHYSICAL_ADDRESS  TranslatedAddress 
)

Wrapper around HalTranslateBusAddress() and HALPRIVATEDISPATCH->HalFindBusAddressTranslation().

Note
Context parameter is supplemental from standard HalTranslateBusAddress(). It allows context passing for the underlying HalFindBusAddressTranslation() between different calls of the function.

Definition at line 677 of file framebuf.c.

684{
685 ULONG_PTR Context = 0;
686
687 /* If InterfaceType is negative, don't do any translation */
689 {
690 /* Return the bus address */
692 return TRUE;
693 }
694
695 /* If InterfaceType is valid, attempt to call the original HAL function */
697 {
699 BusNumber,
703 {
704 return TRUE;
705 }
706 DPRINT1("HalTranslateBusAddress(%lu, %lu, 0x%I64X) failed, fall back to finding a bus translation\n",
708 }
709
710 /* Otherwise, in case of failure, or if InterfaceType is greater than
711 * the maximum supported type (meaning we don't know yet the interface
712 * and bus number), we need to find a bus translation. */
713
714 /* Ensure we have a bus translation function then do the call */
716 return FALSE;
720 &Context,
721 TRUE);
722}
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
#define HalFindBusAddressTranslation
Definition: halfuncs.h:44
@ MaximumInterfaceType
Definition: restypes.h:138
@ InterfaceTypeUndefined
Definition: restypes.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2273
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274

Referenced by VidInitialize().

◆ FindBootDisplay()

NTSTATUS FindBootDisplay ( _Out_ PPHYSICAL_ADDRESS  VideoRamAddress,
_Out_ PULONG  VideoRamSize,
_Out_ PCM_FRAMEBUF_DEVICE_DATA  VideoConfigData,
_Out_opt_ PCM_MONITOR_DEVICE_DATA  MonitorConfigData,
_Out_opt_ PINTERFACE_TYPE  Interface,
_Out_opt_ PULONG  BusNumber 
)

Retrieves configuration data for the boot-time (POST) display controller and monitor peripheral.

This data is initialized by the firmware and the NT bootloader, and can be retrieved from the loader block configuration ARC tree.

Note
Data from the loader block is available only for boot drivers and gets freed later on during NT loading.

Definition at line 564 of file framebuf.c.

571{
572 CM_MONITOR_DEVICE_DATA LocalMonitorConfigData = {0};
573 INTERFACE_TYPE LocalInterface;
574 ULONG LocalBusNumber;
576
577 PAGED_CODE();
578
579 /*
580 * Retrieve video and monitor configuration data.
581 * For monitor data, use the local variable since we may need
582 * to do some adjustments in the video data using monitor data,
583 * even if the caller does not require the monitor data itself
584 * to be returned.
585 */
587 VideoRamSize,
588 VideoConfigData,
589 &LocalMonitorConfigData,
590 &LocalInterface,
591 &LocalBusNumber);
592 if (!NT_SUCCESS(Status))
593 {
594 DPRINT1("Boot Display not found\n");
595 return STATUS_DEVICE_DOES_NOT_EXIST; // STATUS_SYSTEM_DEVICE_NOT_FOUND; (Vista+)
596 }
597
598#if DBG
599 DPRINT_TRACE("\n");
600 DbgPrint("Boot Display found on Interface %lu, Bus %lu\n",
601 LocalInterface, LocalBusNumber);
602 DbgPrint(" VideoRamAddress : 0x%I64X\n", VideoRamAddress->QuadPart);
603 DbgPrint(" VideoRamSize : %lu\n", *VideoRamSize);
604 DbgPrint(" Version : %u.%u\n", VideoConfigData->Version, VideoConfigData->Revision);
605 DbgPrint(" VideoClock : %lu\n", VideoConfigData->VideoClock);
606 DbgPrint("Framebuffer format:\n");
607 /* Absolute offset from the start of the video RAM of the framebuffer
608 * to be displayed on the monitor. The framebuffer size is obtained by:
609 * FrameBufferSize = ScreenHeight * PixelsPerScanLine * BytesPerPixel */
610 DbgPrint(" BaseAddress : 0x%I64X\n", VideoRamAddress->QuadPart + VideoConfigData->FrameBufferOffset);
611 // DbgPrint(" BufferSize : %lu\n", framebufInfo.BufferSize);
612 DbgPrint(" ScreenWidth : %lu\n", VideoConfigData->ScreenWidth);
613 DbgPrint(" ScreenHeight : %lu\n", VideoConfigData->ScreenHeight);
614 DbgPrint(" PixelsPerScanLine : %lu\n", VideoConfigData->PixelsPerScanLine);
615 DbgPrint(" BitsPerPixel : %lu\n", VideoConfigData->BitsPerPixel);
616 DbgPrint(" ARGB masks: : %08x/%08x/%08x/%08x\n",
617 VideoConfigData->PixelMasks.ReservedMask,
618 VideoConfigData->PixelMasks.RedMask,
619 VideoConfigData->PixelMasks.GreenMask,
620 VideoConfigData->PixelMasks.BlueMask);
621#endif
622
623 /* If the screen sizes are not already initialized by now, use monitor data */
624 // TODO: Investigate: Do we want to do this here, or in the caller?
625 if ((VideoConfigData->ScreenWidth == 0) || (VideoConfigData->ScreenHeight == 0))
626 {
627 VideoConfigData->ScreenWidth = LocalMonitorConfigData.HorizontalResolution;
628 VideoConfigData->ScreenHeight = LocalMonitorConfigData.VerticalResolution;
629#if DBG
630 DbgPrint("Video screen dimensions not defined; use monitor resolution\n");
631 DbgPrint(" ScreenWidth : %lu\n", VideoConfigData->ScreenWidth);
632 DbgPrint(" ScreenHeight : %lu\n", VideoConfigData->ScreenHeight);
633#endif
634 }
635
636 /* Return any optional data to the caller if required */
637 if (MonitorConfigData)
638 *MonitorConfigData = LocalMonitorConfigData;
639 if (Interface)
640 *Interface = LocalInterface;
641 if (BusNumber)
642 *BusNumber = LocalBusNumber;
643
644 if ((VideoConfigData->ScreenWidth <= 1) || (VideoConfigData->ScreenHeight <= 1))
645 {
646 DPRINT1("Cannot obtain current screen resolution\n");
647 /* Don't fail, but the caller will have to cope with it */
648 }
649
650 return STATUS_SUCCESS;
651}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static NTSTATUS FindBootDisplayFromLoaderARCTree(_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _Out_opt_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _Out_opt_ PINTERFACE_TYPE Interface, _Out_opt_ PULONG BusNumber)
Definition: framebuf.c:454
#define DPRINT_TRACE(...)
Definition: framebuf.c:15
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:522
enum _INTERFACE_TYPE INTERFACE_TYPE
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT HorizontalResolution
Definition: cmtypes.h:458
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by VidInitialize().

◆ FindBootDisplayFromLoaderARCTree()

static NTSTATUS FindBootDisplayFromLoaderARCTree ( _Out_ PPHYSICAL_ADDRESS  VideoRamAddress,
_Out_ PULONG  VideoRamSize,
_Out_ PCM_FRAMEBUF_DEVICE_DATA  VideoConfigData,
_Out_opt_ PCM_MONITOR_DEVICE_DATA  MonitorConfigData,
_Out_opt_ PINTERFACE_TYPE  Interface,
_Out_opt_ PULONG  BusNumber 
)
static

Definition at line 454 of file framebuf.c.

461{
462 PCONFIGURATION_COMPONENT_DATA ConfigurationRoot;
464 // ULONG ComponentKey = 0; // First controller.
466
467 ConfigurationRoot = (KeLoaderBlock ? KeLoaderBlock->ConfigurationRoot : NULL);
468 if (!ConfigurationRoot)
470
471 /* Enumerate and find the boot-time console display controller */
472#if 0
473 Entry = KeFindConfigurationEntry(ConfigurationRoot,
476 &ComponentKey);
477#else
478 while (TRUE)
479 {
480 Entry = KeFindConfigurationNextEntry(ConfigurationRoot,
483 NULL, // &ComponentKey
484 &Entry);
485 if (!Entry)
486 break; /* Not found */
487 if (Entry->ComponentEntry.Flags & (Output | ConsoleOut))
488 break; /* Found it */
489 }
490#endif
491
492 if (!Entry)
494
495 // Entry->ComponentEntry.IdentifierLength;
496 DPRINT_TRACE("Display: '%s'\n", Entry->ComponentEntry.Identifier);
497
498 Status = GetFramebufferVideoData(VideoRamAddress,
499 VideoRamSize,
500 VideoConfigData,
501 Entry->ConfigurationData,
502 Entry->ComponentEntry.ConfigurationDataLength);
503 if (!NT_SUCCESS(Status) ||
504 (VideoRamAddress->QuadPart == 0) || (*VideoRamSize == 0))
505 {
506 /* Fail if no framebuffer was provided */
507 DPRINT1("No framebuffer found!\n");
509 }
510
511 if (Interface)
513 //if (BusNumber)
514 // *BusNumber = -1;
515
516 /* If no monitor data to retrieve, just return success */
517 if (!MonitorConfigData)
518 return STATUS_SUCCESS;
519
520 /* Now find the MonitorPeripheral to obtain more information.
521 * It should be a child of the display controller. */
522 Entry = Entry->Child;
523 /* Ignore if no monitor data is given */
524 if (!Entry)
525 return STATUS_SUCCESS;
526
527 // Entry->ComponentEntry.IdentifierLength;
528 DPRINT_TRACE("Monitor: '%s'\n", Entry->ComponentEntry.Identifier);
529
530 if ((Entry->ComponentEntry.Class != PeripheralClass) ||
531 (Entry->ComponentEntry.Type != MonitorPeripheral) ||
532 !(Entry->ComponentEntry.Flags & (Output | ConsoleOut)))
533 {
534 /* Ignore */
535 return STATUS_SUCCESS;
536 }
537
538 /* Retrieve monitor configuration data. Use the local variable
539 * since we may need to do some adjustments in the video data
540 * using monitor data, even if the caller does not require the
541 * monitor data itself to be returned. */
542 Status = GetFramebufferMonitorData(MonitorConfigData,
543 Entry->ConfigurationData,
544 Entry->ComponentEntry.ConfigurationDataLength);
545 if (!NT_SUCCESS(Status))
546 DPRINT_TRACE("Invalid monitor data, ignoring.\n");
547
548 return STATUS_SUCCESS;
549}
#define NULL
Definition: types.h:112
NTSTATUS GetFramebufferMonitorData(_Out_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
Definition: framebuf.c:291
NTSTATUS GetFramebufferVideoData(_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
Definition: framebuf.c:203
static INTERFACE_TYPE GetArcComponentInterface(_In_ PCONFIGURATION_COMPONENT Component, _Out_opt_ PULONG BusNumber)
Retrieve the NT interface type and bus number of a given ARC configuration component,...
Definition: framebuf.c:345
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:28
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationNextEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL, IN PCONFIGURATION_COMPONENT_DATA *NextLink)
Definition: config.c:42
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationEntry(IN PCONFIGURATION_COMPONENT_DATA Child, IN CONFIGURATION_CLASS Class, IN CONFIGURATION_TYPE Type, IN PULONG ComponentKey OPTIONAL)
Definition: config.c:22
@ ControllerClass
Definition: arc.h:103
@ PeripheralClass
Definition: arc.h:104
@ MonitorPeripheral
Definition: arc.h:142
@ DisplayController
Definition: arc.h:132
@ ConsoleOut
Definition: arc.h:92
@ Output
Definition: arc.h:94
base of all file and directory entries
Definition: entries.h:83
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:840

Referenced by FindBootDisplay().

◆ GetArcComponentInterface()

static INTERFACE_TYPE GetArcComponentInterface ( _In_ PCONFIGURATION_COMPONENT  Component,
_Out_opt_ PULONG  BusNumber 
)
static

Retrieve the NT interface type and bus number of a given ARC configuration component, that can be used in a call to HalTranslateBusAddress() or to BootTranslateBusAddress().

Definition at line 345 of file framebuf.c.

348{
349 static const struct
350 {
353 // USHORT Count;
355 {
356 {"ISA", Isa},
357 {"MCA", MicroChannel},
358 {"PCI", PCIBus},
359 {"VME", VMEBus},
360 {"PCMCIA", PCMCIABus},
361 {"CBUS", CBus},
362 {"MPIPI", MPIBus},
363 {"MPSA", MPSABus},
364 {NULL, Internal}
365 };
366
368
369 /* Retrieve the top-level parent adapter component */
370 PCONFIGURATION_COMPONENT_DATA ComponentData =
372 for (; ComponentData->Parent; ComponentData = ComponentData->Parent)
373 {
374 if (ComponentData->Parent->ComponentEntry.Class == SystemClass)
375 break;
376 }
377 Component = &ComponentData->ComponentEntry;
378
379 /* Check if this is an adapter */
380 if (!ComponentData->Parent ||
381 (ComponentData->Parent->ComponentEntry.Class != SystemClass) ||
382 (Component->Class != AdapterClass))
383 {
384 return Interface; /* It's not, return early */
385 }
386
387 /* Check what kind of adapter it is */
388 switch (Component->Type)
389 {
390 /* EISA */
391 case EisaAdapter:
392 {
393 Interface = Eisa;
394 // Bus = CmpTypeCount[EisaAdapter]++;
395 break;
396 }
397
398 /* Turbo-channel */
399 case TcAdapter:
400 {
402 // Bus = CmpTypeCount[TurboChannel]++;
403 break;
404 }
405
406 /* ISA, PCI, etc buses */
408 {
409 /* Check if we have an identifier */
410 if (Component->Identifier)
411 {
412 /* Loop each multi-function adapter type */
413 ULONG i;
414 for (i = 0; CmpMultifunctionTypes[i].Identifier; i++)
415 {
416 /* Check for a name match */
418 Component->Identifier))
419 {
420 /* Match found */
421 break;
422 }
423 }
424
426 // Bus = CmpMultifunctionTypes[i].Count++;
427 }
428 break;
429 }
430
431 /* SCSI Bus */
432 case ScsiAdapter:
433 {
435 // Bus = CmpTypeCount[ScsiAdapter]++;
436 break;
437 }
438
439 /* Unknown */
440 default:
441 {
443 // Bus = CmpUnknownBusCount++;
444 break;
445 }
446 }
447
448 if (BusNumber)
449 *BusNumber = Component->Key;
450 return Interface;
451}
@ Identifier
Definition: asmpp.cpp:95
@ ScsiAdapter
Definition: arcname.c:40
@ EisaAdapter
Definition: arcname.c:39
#define _stricmp
Definition: cat.c:22
CMP_MF_TYPE CmpMultifunctionTypes[]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ Eisa
Definition: restypes.h:123
@ VMEBus
Definition: restypes.h:127
@ CBus
Definition: restypes.h:130
@ TurboChannel
Definition: restypes.h:125
@ PCIBus
Definition: restypes.h:126
@ MPIBus
Definition: restypes.h:131
@ MPSABus
Definition: restypes.h:132
@ Internal
Definition: restypes.h:121
@ MicroChannel
Definition: restypes.h:124
@ Isa
Definition: restypes.h:122
@ PCMCIABus
Definition: restypes.h:129
@ SystemClass
Definition: arc.h:99
@ AdapterClass
Definition: arc.h:102
@ MultiFunctionAdapter
Definition: arc.h:125
@ TcAdapter
Definition: arc.h:122
PCHAR Identifier
Definition: cm.h:453
USHORT InterfaceType
Definition: cm.h:454
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:287
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition: arc.h:284
const char * PCSTR
Definition: typedefs.h:52
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ ULONG Component
Definition: potypes.h:499

Referenced by FindBootDisplayFromLoaderARCTree().

◆ GetFramebufferMonitorData()

NTSTATUS GetFramebufferMonitorData ( _Out_ PCM_MONITOR_DEVICE_DATA  MonitorConfigData,
_In_ PVOID  ConfigurationData,
_In_ ULONG  ConfigurationDataLength 
)

Definition at line 291 of file framebuf.c.

295{
296 if (!ConfigurationData ||
297 (ConfigurationDataLength < sizeof(CM_PARTIAL_RESOURCE_LIST)))
298 {
299 /* Invalid entry */
301 }
302
303 /* Initialize the monitor parameters, converting
304 * them to the new format if needed */
305 // TODO: Handle legacy MONITOR_CONFIGURATION_DATA
306 if (IsNewConfigData(ConfigurationData, ConfigurationDataLength))
307 {
308 /* New configuration data */
310
311 GetMonitorData((PCM_PARTIAL_RESOURCE_LIST)ConfigurationData,
312 &Descriptor);
313
314 if (Descriptor &&
315 (Descriptor->u.DeviceSpecificData.DataSize >= sizeof(CM_MONITOR_DEVICE_DATA)))
316 {
317 /* NOTE: This descriptor *MUST* be the last one.
318 * The actual device data follows the descriptor. */
320
321 /* Just copy the data */
322 *MonitorConfigData = *MonitorData;
323 }
324 else
325 {
326 /* The configuration data does not contain any monitor information.
327 * We will calculate default values later. */
328 }
329
330 return STATUS_SUCCESS;
331 }
332
333 /* Unknown configuration, invalid entry? */
335}
static BOOLEAN IsNewConfigData(_In_ PVOID ConfigurationData, _In_ ULONG ConfigurationDataLength)
Definition: framebuf.c:19
static VOID GetMonitorData(_In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *DeviceSpecific)
Given a CM_PARTIAL_RESOURCE_LIST, obtain a pointer to resource descriptor for monitor configuration d...
Definition: framebuf.c:175
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:713
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
struct _CM_MONITOR_DEVICE_DATA * PCM_MONITOR_DEVICE_DATA

Referenced by FindBootDisplayFromLoaderARCTree().

◆ GetFramebufferVideoData()

NTSTATUS GetFramebufferVideoData ( _Out_ PPHYSICAL_ADDRESS  VideoRamAddress,
_Out_ PULONG  VideoRamSize,
_Out_ PCM_FRAMEBUF_DEVICE_DATA  VideoConfigData,
_In_ PVOID  ConfigurationData,
_In_ ULONG  ConfigurationDataLength 
)

Definition at line 203 of file framebuf.c.

209{
210 if (!ConfigurationData ||
211 (ConfigurationDataLength < sizeof(CM_PARTIAL_RESOURCE_LIST)))
212 {
213 /* Invalid entry */
215 }
216
217 /* Initialize the display adapter parameters, converting
218 * them to the new format if needed */
219 // TODO: Handle legacy VIDEO_HARDWARE_CONFIGURATION_DATA based data
220 if (IsNewConfigData(ConfigurationData, ConfigurationDataLength))
221 {
222 /* New configuration data */
224
225 DPRINT_TRACE("** FbBVid: New Config data found\n");
226 GetVideoData((PCM_PARTIAL_RESOURCE_LIST)ConfigurationData,
227 NULL, // Interrupt
228 NULL, // ControlPort
229 NULL, // CursorPort
230 &VideoRam,
231 &Descriptor);
232
233 if (VideoRam)
234 {
235 /* Save the video RAM base and size */
236 *VideoRamAddress = VideoRam->u.Memory.Start;
237 *VideoRamSize = VideoRam->u.Memory.Length;
238 DPRINT_TRACE("** FbBVid: Got video RAM address: 0x%I64X - Size: %lu\n",
239 VideoRamAddress->QuadPart, *VideoRamSize);
240 }
241 else
242 {
243 /* No video RAM base: zero it out */
244 DPRINT1("** FbBVid: No video RAM available\n");
245 VideoRamAddress->QuadPart = 0;
246 *VideoRamSize = 0;
247 }
248
249 if (Descriptor &&
250 (Descriptor->u.DeviceSpecificData.DataSize >= sizeof(CM_FRAMEBUF_DEVICE_DATA)))
251 {
252 /* NOTE: This descriptor *MUST* be the last one.
253 * The actual device data follows the descriptor. */
255
256 /* Just copy the data */
257 *VideoConfigData = *VideoData;
258
259 DPRINT_TRACE("** FbBVid: Framebuffer at: 0x%I64X\n",
260 VideoRamAddress->QuadPart + VideoData->FrameBufferOffset);
261 }
262 else
263 {
264 /* The configuration data does not contain any
265 * framebuffer information (format, etc.)
266 * We will calculate default values later. */
267 DPRINT1("** FbBVid: Framebuffer data NOT FOUND\n");
268 }
269
270 return STATUS_SUCCESS;
271 }
272 else
273 {
274 /* Unknown configuration, invalid entry? */
276 }
277
278#if 0
279 /* Fail if no video is available */
280 if ((VideoRamAddress->QuadPart == 0) || (*VideoRamSize == 0))
281 {
282 DPRINT1("No video available!\n");
284 }
285#endif
286
287 return STATUS_SUCCESS;
288}
static VOID GetVideoData(_In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *Interrupt, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *ControlPort, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *CursorPort, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *VideoRam, _Out_opt_ PCM_PARTIAL_RESOURCE_DESCRIPTOR *DeviceSpecific)
Given a CM_PARTIAL_RESOURCE_LIST, obtain pointers to resource descriptors for legacy video configurat...
Definition: framebuf.c:65
struct _CM_FRAMEBUF_DEVICE_DATA * PCM_FRAMEBUF_DEVICE_DATA
ReactOS Framebuffer-specific video device configuration data.
Definition: framebuf.h:35
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432::@437 Memory
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@432 u

Referenced by FindBootDisplayFromLoaderARCTree().

◆ GetMonitorData()

static VOID GetMonitorData ( _In_ PCM_PARTIAL_RESOURCE_LIST  ResourceList,
_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR DeviceSpecific 
)
static

Given a CM_PARTIAL_RESOURCE_LIST, obtain a pointer to resource descriptor for monitor configuration data, listed as a device-specific resource.

Definition at line 175 of file framebuf.c.

178{
180 ULONG i;
181
182 /* Initialize the return values */
183 *DeviceSpecific = NULL;
184
185 /* Find the CmResourceTypeDeviceSpecific CM_MONITOR_DEVICE_DATA */
186 for (i = 0; i < ResourceList->Count; ++i)
187 {
188 Descriptor = &ResourceList->PartialDescriptors[i];
190 {
191 /* NOTE: This descriptor *MUST* be the last one.
192 * The actual device data follows the descriptor. */
193 ASSERT(i == ResourceList->Count - 1);
194
195 if (DeviceSpecific)
196 *DeviceSpecific = Descriptor;
197 break;
198 }
199 }
200}
#define ASSERT(a)
Definition: mode.c:44
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

Referenced by GetFramebufferMonitorData().

◆ GetVideoData()

Given a CM_PARTIAL_RESOURCE_LIST, obtain pointers to resource descriptors for legacy video configuration: interrupt, control and cursor I/O ports, and video RAM memory descriptors. In addition, retrieve any device-specific resource present.

Definition at line 65 of file framebuf.c.

72{
74 ULONG PortCount = 0, IntCount = 0, MemCount = 0;
75 ULONG i;
76
77 /* Initialize the return values */
78 if (Interrupt) *Interrupt = NULL;
79 if (ControlPort) *ControlPort = NULL;
80 if (CursorPort) *CursorPort = NULL;
81 *VideoRam = NULL;
82 if (DeviceSpecific) *DeviceSpecific = NULL;
83
84 DPRINT_TRACE("GetVideoData\n");
85
86 for (i = 0; i < ResourceList->Count; ++i)
87 {
88 Descriptor = &ResourceList->PartialDescriptors[i];
89
90 switch (Descriptor->Type)
91 {
93 {
94 DPRINT_TRACE(" CmResourceTypePort\n");
95 /* We only check for memory I/O ports */
96 // if (!(Descriptor->Flags & CM_RESOURCE_PORT_MEMORY))
98 break;
99
100 /* If more than two memory I/O ports
101 * have been encountered, ignore them */
102 if (PortCount > 2)
103 break;
104 ++PortCount;
105
106 /* First port is Control; second port is Cursor */
107 if (PortCount == 1)
108 {
109 if (ControlPort)
110 *ControlPort = Descriptor;
111 }
112 else // if (PortCount == 2)
113 {
114 if (CursorPort)
115 *CursorPort = Descriptor;
116 }
117 break;
118 }
119
121 {
122 DPRINT_TRACE(" CmResourceTypeInterrupt\n");
123 /* If more than one interrupt resource
124 * has been encountered, ignore them */
125 if (IntCount > 1)
126 break;
127 ++IntCount;
128
129 if (Interrupt)
131 break;
132 }
133
135 {
136 DPRINT_TRACE(" CmResourceTypeMemory\n");
137 /* If more than one memory resource
138 * has been encountered, ignore them */
139 if (MemCount > 1)
140 break;
141 ++MemCount;
142
143 /* Video RAM should be writable (but may or may not be readable) */
146 {
147 break; /* Cannot use this memory */
148 }
149 *VideoRam = Descriptor;
150 break;
151 }
152
154 {
155 DPRINT_TRACE(" CmResourceTypeDeviceSpecific\n");
156 /* NOTE: This descriptor *MUST* be the last one.
157 * The actual device data follows the descriptor. */
158 ASSERT(i == ResourceList->Count - 1);
159 i = ResourceList->Count; // To force-break the for-loop.
160
161 if (DeviceSpecific)
162 *DeviceSpecific = Descriptor;
163 break;
164 }
165 }
166 }
167}
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_MEMORY_READ_ONLY
Definition: cmtypes.h:121
#define CmResourceTypeMemory
Definition: restypes.h:106
#define CmResourceTypePort
Definition: restypes.h:104
#define CmResourceTypeInterrupt
Definition: restypes.h:105
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
#define CM_RESOURCE_MEMORY_WRITEABILITY_MASK
Definition: cmtypes.h:273

Referenced by GetFramebufferVideoData().

◆ IsNewConfigData()

static BOOLEAN IsNewConfigData ( _In_ PVOID  ConfigurationData,
_In_ ULONG  ConfigurationDataLength 
)
static

Definition at line 19 of file framebuf.c.

22{
23 /* Cast to PCM_PARTIAL_RESOURCE_LIST to access
24 * the common Version and Revision fields */
26 (PCM_PARTIAL_RESOURCE_LIST)ConfigurationData;
27
28 if (!ConfigurationData)
29 {
30 DPRINT_TRACE("IsNewConfigData:FALSE - ConfigurationData == NULL\n");
31 return FALSE;
32 }
33
34 if (ConfigurationDataLength < FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors))
35 {
36 DPRINT_TRACE("IsNewConfigData:FALSE - ConfigurationDataLength == %lu\n",
37 ConfigurationDataLength);
38 return FALSE;
39 }
40
41 /* If Version/Revision is strictly lower than 1.2, this cannot be
42 * a new configuration data (even if the length appears to match
43 * a CM_FULL_RESOURCE_DESCRIPTOR with zero or more descriptors) */
44 if ( (ResourceList->Version < 1) ||
45 ((ResourceList->Version == 1) && (ResourceList->Revision <= 1)) )
46 {
47 DPRINT_TRACE("IsNewConfigData:FALSE - Version %lu, Revision %lu\n",
48 ResourceList->Version, ResourceList->Revision);
49 return FALSE;
50 }
51
52 /* This should be a new configuration data */
53 DPRINT_TRACE("IsNewConfigData:TRUE\n");
54 return TRUE;
55}
struct _CM_PARTIAL_RESOURCE_LIST * PCM_PARTIAL_RESOURCE_LIST
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by GetFramebufferMonitorData(), and GetFramebufferVideoData().