VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FlashCore.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
RevLine 
[72615]1/* $Id: FlashCore.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
[81250]3 * A simple Flash device
[72615]4 *
5 * A simple non-volatile byte-wide (x8) memory device modeled after Intel 28F008
6 * FlashFile. See 28F008SA datasheet, Intel order number 290429-007.
7 *
8 * Implemented as an MMIO device attached directly to the CPU, not behind any
9 * bus. Typically mapped as part of the firmware image.
10 */
11
12/*
[98103]13 * Copyright (C) 2018-2023 Oracle and/or its affiliates.
[72615]14 *
[96407]15 * This file is part of VirtualBox base platform packages, as
16 * available from https://www.virtualbox.org.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation, in version 3 of the
21 * License.
22 *
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, see <https://www.gnu.org/licenses>.
30 *
31 * SPDX-License-Identifier: GPL-3.0-only
[72615]32 */
33
[81250]34#ifndef VBOX_INCLUDED_SRC_EFI_FlashCore_h
35#define VBOX_INCLUDED_SRC_EFI_FlashCore_h
36#ifndef RT_WITHOUT_PRAGMA_ONCE
37# pragma once
38#endif
[72615]39
40/*********************************************************************************************************************************
41* Header Files *
42*********************************************************************************************************************************/
43#include <VBox/vmm/pdmdev.h>
[91329]44#include <VBox/vmm/pdmifs.h>
[72615]45#include <VBox/log.h>
46#include <VBox/err.h>
47#include <iprt/assert.h>
48#include <iprt/string.h>
49#include <iprt/file.h>
50
51#include "VBoxDD.h"
52
[81250]53RT_C_DECLS_BEGIN
[72615]54
55/*********************************************************************************************************************************
56* Defined Constants And Macros *
57*********************************************************************************************************************************/
58/** The current version of the saved state. */
59#define FLASH_SAVED_STATE_VERSION 1
60
[81506]61#if 0
62/** Enables the ring-0/raw-mode read cache optimization, giving the size in
63 * uint64_t units. */
64#define FLASH_WITH_RZ_READ_CACHE_SIZE 32
65#endif
[72615]66
[81506]67
[72615]68/*********************************************************************************************************************************
69* Structures and Typedefs *
70*********************************************************************************************************************************/
71/**
[81250]72 * The flash device core structure.
[72615]73 */
[81250]74typedef struct FLASHCORE
[72615]75{
76 /** The current command. */
[81502]77 uint8_t bCmd;
[72615]78 /** The status register. */
[81502]79 uint8_t bStatus;
[72615]80 /** Current bus cycle. */
[81502]81 uint8_t cBusCycle;
[72615]82
[81502]83 /** @name The following state does not change at runtime
84 * @{ */
85 /** When set, indicates the state was saved. */
86 bool fStateSaved;
[72615]87 /** Manufacturer (high byte) and device (low byte) ID. */
[81502]88 uint16_t u16FlashId;
[72615]89 /** The configured block size of the device. */
[81502]90 uint16_t cbBlockSize;
[81506]91 /** The actual flash memory data. */
92 R3PTRTYPE(uint8_t *) pbFlash;
[72615]93 /** The flash memory region size. */
[81502]94 uint32_t cbFlashSize;
95 /** @} */
[81506]96
97#ifdef FLASH_WITH_RZ_READ_CACHE_SIZE
98 /** @name Read cache for non-ring-3 code.
99 * @{ */
100 /** The cache offset, UINT32_MAX if invalid. */
101 uint32_t offCache;
102# if ARCH_BITS == 32
103 uint32_t uPadding;
104# endif
105 /** The cache data. */
106 union
107 {
108 uint64_t au64[FLASH_WITH_RZ_READ_CACHE_SIZE];
109 uint8_t ab[FLASH_WITH_RZ_READ_CACHE_SIZE * 8];
110 } CacheData;
111 /** @} */
112#endif
[81250]113} FLASHCORE;
[72615]114
115/** Pointer to the Flash device state. */
[81250]116typedef FLASHCORE *PFLASHCORE;
[72615]117
118#ifndef VBOX_DEVICE_STRUCT_TESTCASE
119
[81502]120DECLHIDDEN(VBOXSTRICTRC) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb);
121DECLHIDDEN(VBOXSTRICTRC) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb);
[72615]122
[81250]123# ifdef IN_RING3
124DECLHIDDEN(int) flashR3Init(PFLASHCORE pThis, PPDMDEVINS pDevIns, uint16_t idFlashDev, uint32_t cbFlash, uint16_t cbBlock);
[81502]125DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis, PPDMDEVINS pDevIns);
126DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename);
[81458]127DECLHIDDEN(int) flashR3LoadFromBuf(PFLASHCORE pThis, void const *pvBuf, size_t cbBuf);
[91329]128DECLHIDDEN(int) flashR3LoadFromVfs(PFLASHCORE pThis, PPDMDEVINS pDevIns, PPDMIVFSCONNECTOR pDrvVfs,
129 const char *pszNamespace, const char *pszPath);
[81502]130DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename);
[81250]131DECLHIDDEN(int) flashR3SaveToBuf(PFLASHCORE pThis, void *pvBuf, size_t cbBuf);
[91329]132DECLHIDDEN(int) flashR3SaveToVfs(PFLASHCORE pThis, PPDMDEVINS pDevIns, PPDMIVFSCONNECTOR pDrvVfs,
133 const char *pszNamespace, const char *pszPath);
[81250]134DECLHIDDEN(void) flashR3Reset(PFLASHCORE pThis);
[81502]135DECLHIDDEN(int) flashR3SaveExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
136DECLHIDDEN(int) flashR3LoadExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
[81250]137# endif /* IN_RING3 */
[72615]138
[81250]139#endif /* VBOX_DEVICE_STRUCT_TESTCASE */
[72615]140
[81250]141RT_C_DECLS_END
[72615]142
[81250]143#endif /* !VBOX_INCLUDED_SRC_EFI_FlashCore_h */
[72615]144
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use