Path: blob/21.2-virgl/src/broadcom/simulator/v3d_simulator_wrapper.cpp
4560 views
/*1* Copyright © 2017 Broadcom2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223/** @file24*25* Wraps bits of the V3D simulator interface in a C interface for the26* v3d_simulator.c code to use.27*/2829#ifdef USE_V3D_SIMULATOR3031#include "v3d_simulator_wrapper.h"3233#define V3D_TECH_VERSION 334#define V3D_REVISION 335#define V3D_SUB_REV 036#define V3D_HIDDEN_REV 037#define V3D_COMPAT_REV 038#include "v3d_hw_auto.h"3940extern "C" {4142struct v3d_hw *v3d_hw_auto_new(void *in_params)43{44return v3d_hw_auto_make_unique().release();45}464748uint32_t v3d_hw_get_mem(const struct v3d_hw *hw, uint32_t *size, void **p)49{50return hw->get_mem(size, p);51}5253bool v3d_hw_alloc_mem(struct v3d_hw *hw, size_t min_size)54{55return hw->alloc_mem(min_size) == V3D_HW_ALLOC_SUCCESS;56}5758uint32_t v3d_hw_read_reg(struct v3d_hw *hw, uint32_t reg)59{60return hw->read_reg(reg);61}6263void v3d_hw_write_reg(struct v3d_hw *hw, uint32_t reg, uint32_t val)64{65hw->write_reg(reg, val);66}6768void v3d_hw_tick(struct v3d_hw *hw)69{70return hw->tick();71}7273int v3d_hw_get_version(struct v3d_hw *hw)74{75const V3D_HUB_IDENT_T *ident = hw->get_hub_ident();7677return ident->tech_version * 10 + ident->revision;78}7980void81v3d_hw_set_isr(struct v3d_hw *hw, void (*isr)(uint32_t status))82{83hw->set_isr(isr);84}8586uint32_t v3d_hw_get_hub_core()87{88return V3D_HW_HUB_CORE;89}9091}92#endif /* USE_V3D_SIMULATOR */939495