Custom Display Adapter

Discussions related to using the OSE version of VirtualBox.

Custom Display Adapter

Postby SrBIOS » 20. Jan 2022, 21:35


I'm trying to build a custom display adapter, but I am having some trouble. I have taken DevVGA.cpp and stripped it down a bit, just to try to get something working. I may have other problems, but here is where I currently am...

I've set the VM to have no display adapter in VirtualBox Manager (Graphics Controller = None).
I then pass in, via config, these.
00:00:00.946672 Extradata overrides:
00:00:00.946815 VBoxInternal/Devices/bga/0/Config/MonitorCount="1"
00:00:00.946866 VBoxInternal/Devices/bga/0/LUN#0/Driver="MainDisplay"
00:00:00.946933 VBoxInternal/Devices/bga/0/LUN#999/Config/First="0"
00:00:00.946967 VBoxInternal/Devices/bga/0/LUN#999/Config/Last="0"
00:00:00.947017 VBoxInternal/Devices/bga/0/LUN#999/Config/papLeds="45800128"
00:00:00.947067 VBoxInternal/Devices/bga/0/LUN#999/Driver="MainStatus"
00:00:00.947117 VBoxInternal/PDM/Devices/bga/Path="C:\Ben\bin2\DevBGA.dll"

I have no idea if the LUN999 stuff does anything, but I see the base code doing it...
I try to stitch in the MainDisplay

The original vga device, via ConsoleImpl2.cpp, passes in a parameter called Object, which appears to be a pointer, so I don't add that...
00:00:00.959510 [/Devices/vga/0/LUN#0/Config/] (level 5)
00:00:00.959510 Object <integer> = 0x0000000002b43920 (45 365 536)

So, when I run...

I am in vgaAttach, and an excption is thrown in PDMDevHlpDriverAttach.
caller was int rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->IBase, &pThisCC->pDrvBase, "Display Port");

00:00:00.983050 vgaAttach: LUN=0
00:00:00.983054 vgaAttach: PDMDevHlpDriverAttach
00:00:00.983151 !!! rtR3WinUnhandledXcptFilter caught an exception on thread 0000000000004e3c!!!
00:00:00.983156 ExceptionCode=0xc0000005 ExceptionFlags=0x00000000 ExceptionAddress=00007ffc46238961
00:00:00.983161 ExceptionInformation[0]=0000000000000000
00:00:00.983165 ExceptionInformation[1]=0000000000000018

So, I failed to attach the display so badly, the app crashes!

I'm thinking Object, passed by ConsoleImpl2.cpp is probably required, but how do I pass that, as I'm in PDM and config file land?

Any thoughts or suggestions would be greatly appreciated.

Thank you for your time,
Posts: 18
Joined: 30. Aug 2021, 20:06
Primary OS: MS Windows other
VBox Version: OSE other
Guest OSses: DOS / Windows

Re: Custom Display Adapter

Postby klaus » 21. Jan 2022, 00:51

You better forget about this LUN#999 stuff completely, because that can only work when something is properly integrated into the API. Even in this context it's something we want to improve already for a while. The status stuff shouldn't be a mandatory thing.
Oracle Corporation
Posts: 896
Joined: 10. May 2007, 14:57

Re: Custom Display Adapter

Postby SrBIOS » 21. Jan 2022, 21:21

Hello kalus,

Thank you for your reply. I have removed the 999 stuff.

I found what was causing the exception. I zero'd out the wrong line. I as ignoring VGASTATECC. I only meant to drop VGASTATERC.
/* .cbInstanceShared = */ sizeof(VGASTATE),
/* .cbInstanceCC = */ sizeof(VGASTATECC),
/* .cbInstanceRC = */ 0, /*sizeof(VGASTATERC),*/

Now I get different errors.

If I start with
00:00:00.913370 VBoxInternal/Devices/bga/0/Config/MonitorCount="1"
00:00:00.913432 VBoxInternal/Devices/bga/0/LUN#0/Driver="MainDisplay"
00:00:00.913495 VBoxInternal/PDM/Devices/bga/Path="C:\Ben\bin2\DevBGA.dll"

00:00:00.948739 vgaAttach: LUN=0
00:00:00.948743 vgaAttach: PDMDevHlpDriverAttach
00:00:00.948784 vgaAttach: PDMDevHlpDriverAttach: rc=-2802
00:00:00.948791 AssertLogRel V:\VirtualBox-6.1.30\src\VBox\Devices\Ben\DevBGA.cpp(4891) int __cdecl vgaAttach(struct PDMDEVINSR3 *,unsigned int,unsigned int): <NULL>
00:00:00.948796 Failed to attach LUN #0! rc=VERR_PDM_MISSING_INTERFACE_ABOVE
00:00:00.948828 PDM: Failed to construct 'bga'/0! VERR_PDM_MISSING_INTERFACE_ABOVE (-2802) - The above driver doesn't export a interface required by a driver being attached to it. Typical misconfiguration problem.
00:00:00.948840 VMSetError: V:\VirtualBox-6.1.30\src\VBox\VMM\VMMR3\PDMDevice.cpp(474) int __cdecl pdmR3DevInit(struct VM *); rc=VERR_PDM_MISSING_INTERFACE_ABOVE
00:00:00.948842 VMSetError: Failed to construct device 'bga' instance #0
00:00:00.953885 ERROR [COM]: aRC=E_FAIL (0x80004005) aIID={872da645-4a9b-1727-bee2-5585105b9eed} aComponent={ConsoleWrap} aText={Failed to construct device 'bga' instance #0 (VERR_PDM_MISSING_INTERFACE_ABOVE)}, preserve=false aResultDetail=-2802
00:00:00.954136 Console: Machine state changed to 'PoweredOff'
00:00:00.956968 Power up failed (vrc=VERR_PDM_MISSING_INTERFACE_ABOVE, rc=E_FAIL (0X80004005))
00:00:01.458548 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600
00:00:01.458637 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={4680b2de-8690-11e9-b83d-5719e53cf1de} aComponent={DisplayWrap} aText={The console is not powered up (Display::setVideoModeHint)}, preserve=false aResultDetail=0
00:00:01.459309 GUI: Aborting startup due to power up progress issue detected...

After adding lots of LogRel lines, I find that I fail in
Code: Select all   Expand viewCollapse view
    if (!pThis->pVBVACallbacks)
        LogRel(("AssertMsgFailed C\n"));
        AssertMsgFailed(("Configuration error: No VBVA callback interface above!\n"));

I built my driver without VBOX_WITH_VIDEOHWACCEL, but it looks like I need it. That AssertMsgFailed never prints that message. I found it via my LogRel line.

I'm still not sure how to handle this part, when I get there.. It doesn't look like I can dynamically add config lines, as there is no helper for that.
Code: Select all   Expand viewCollapse view
     * Get the Display object pointer and update the mpDrv member.
   LogRel(("Get the Display object pointer and update the mpDrv member.\n"));
    void *pv;
    int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
    if (RT_FAILURE(rc))
      LogRel(("AssertMsgFailed D\n"));
        AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
        return rc;
    Display *pDisplay = (Display *)pv;      /** @todo Check this cast! */
    pThis->pDisplay = pDisplay;
    pThis->pDisplay->mpDrv = pThis;

Is it not possible to bolt on another display adapter, unless it gets compiled into the VirtualBox framework, such that it gets instantiated via ConsoleImpl2.cpp ?

Thank you very much for your time,
Posts: 18
Joined: 30. Aug 2021, 20:06
Primary OS: MS Windows other
VBox Version: OSE other
Guest OSses: DOS / Windows

Re: Custom Display Adapter

Postby klaus » 21. Jan 2022, 22:25

You're actually right - the integration of the VGA stuff has quite some dependencies into the API, and that means it won't be possible to just provide a different VGA implementation through CFGM tweaks alone this at the moment (we have plans to eradicate that annoying pointer passing and replace it with a way to query the needed objects through the code, that should improve this greatly). It wasn't high on our priority list because every reasonably usable device emulation we have will be integrated fully into the API.
Oracle Corporation
Posts: 896
Joined: 10. May 2007, 14:57

Return to VirtualBox OSE

Who is online

Users browsing this forum: No registered users and 3 guests