blob: d363e2b040759a6fbf529c091479ece43583a1f8 [file] [log] [blame]
/*************************************************************************/ /*!
@File
@Title Services firmware load and access routines for Linux
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Device specific functions
@License MIT
The contents of this file are subject to the MIT license as set out below.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /**************************************************************************/
#include <stdio.h>
#include "fuchsia/msd_img_device.h"
extern "C" {
#include "device.h"
#include "rgxfwload.h"
#include "srvkm.h"
}
struct RGXFW
{
std::unique_ptr<magma::PlatformBuffer> buffer;
std::unique_ptr<magma::PlatformBuffer::Mapping> mapping;
size_t size;
};
RGXFW *
RGXLoadFirmware(PVRSRV_DEVICE_NODE *psDeviceNode, const IMG_CHAR *pszBVNCString, const IMG_CHAR *pszBVpNCString)
{
MsdImgDevice *device = MsdImgDevice::cast(psDeviceNode->psDevConfig->pvOSDevice);
magma::PlatformDevice *platform_device = device->platform_device();
auto fw = std::make_unique<RGXFW>();
magma::Status status = platform_device->LoadFirmware(pszBVNCString, &fw->buffer, &fw->size);
if (!status.ok())
return DRETP(nullptr, "Failed to load firmware: %d", status.get());
if (!fw->buffer->MapCpuWithFlags(0, fw->buffer->size(), magma::PlatformBuffer::kMapRead, &fw->mapping))
return DRETP(nullptr, "Failed to map firmware");
return fw.release();
}
void
RGXUnloadFirmware(RGXFW *psRGXFW)
{
delete psRGXFW;
}
size_t
RGXFirmwareSize(RGXFW *psRGXFW)
{
return psRGXFW->size;
}
const void *
RGXFirmwareData(RGXFW *psRGXFW)
{
return psRGXFW->mapping->address();
}
/******************************************************************************
End of file (rgxfwload.c)
******************************************************************************/