VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/* $Id: FlashCore.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * A simple Flash device
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/*
13 * Copyright (C) 2018-2022 Oracle Corporation
14 *
15 * This file is part of VirtualBox Open Source Edition (OSE), as
16 * available from http://www.virtualbox.org. This file is free software;
17 * you can redistribute it and/or modify it under the terms of the GNU
18 * General Public License (GPL) as published by the Free Software
19 * Foundation, in version 2 as it comes in the "COPYING" file of the
20 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
21 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
22 */
23
24#ifndef VBOX_INCLUDED_SRC_EFI_FlashCore_h
25#define VBOX_INCLUDED_SRC_EFI_FlashCore_h
26#ifndef RT_WITHOUT_PRAGMA_ONCE
27# pragma once
28#endif
29
30/*********************************************************************************************************************************
31* Header Files *
32*********************************************************************************************************************************/
33#include <VBox/vmm/pdmdev.h>
34#include <VBox/vmm/pdmifs.h>
35#include <VBox/log.h>
36#include <VBox/err.h>
37#include <iprt/assert.h>
38#include <iprt/string.h>
39#include <iprt/file.h>
40
41#include "VBoxDD.h"
42
43RT_C_DECLS_BEGIN
44
45/*********************************************************************************************************************************
46* Defined Constants And Macros *
47*********************************************************************************************************************************/
48/** The current version of the saved state. */
49#define FLASH_SAVED_STATE_VERSION 1
50
51#if 0
52/** Enables the ring-0/raw-mode read cache optimization, giving the size in
53 * uint64_t units. */
54#define FLASH_WITH_RZ_READ_CACHE_SIZE 32
55#endif
56
57
58/*********************************************************************************************************************************
59* Structures and Typedefs *
60*********************************************************************************************************************************/
61/**
62 * The flash device core structure.
63 */
64typedef struct FLASHCORE
65{
66 /** The current command. */
67 uint8_t bCmd;
68 /** The status register. */
69 uint8_t bStatus;
70 /** Current bus cycle. */
71 uint8_t cBusCycle;
72
73 /** @name The following state does not change at runtime
74 * @{ */
75 /** When set, indicates the state was saved. */
76 bool fStateSaved;
77 /** Manufacturer (high byte) and device (low byte) ID. */
78 uint16_t u16FlashId;
79 /** The configured block size of the device. */
80 uint16_t cbBlockSize;
81 /** The actual flash memory data. */
82 R3PTRTYPE(uint8_t *) pbFlash;
83 /** The flash memory region size. */
84 uint32_t cbFlashSize;
85 /** @} */
86
87#ifdef FLASH_WITH_RZ_READ_CACHE_SIZE
88 /** @name Read cache for non-ring-3 code.
89 * @{ */
90 /** The cache offset, UINT32_MAX if invalid. */
91 uint32_t offCache;
92# if ARCH_BITS == 32
93 uint32_t uPadding;
94# endif
95 /** The cache data. */
96 union
97 {
98 uint64_t au64[FLASH_WITH_RZ_READ_CACHE_SIZE];
99 uint8_t ab[FLASH_WITH_RZ_READ_CACHE_SIZE * 8];
100 } CacheData;
101 /** @} */
102#endif
103} FLASHCORE;
104
105/** Pointer to the Flash device state. */
106typedef FLASHCORE *PFLASHCORE;
107
108#ifndef VBOX_DEVICE_STRUCT_TESTCASE
109
110DECLHIDDEN(VBOXSTRICTRC) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb);
111DECLHIDDEN(VBOXSTRICTRC) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb);
112
113# ifdef IN_RING3
114DECLHIDDEN(int) flashR3Init(PFLASHCORE pThis, PPDMDEVINS pDevIns, uint16_t idFlashDev, uint32_t cbFlash, uint16_t cbBlock);
115DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis, PPDMDEVINS pDevIns);
116DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename);
117DECLHIDDEN(int) flashR3LoadFromBuf(PFLASHCORE pThis, void const *pvBuf, size_t cbBuf);
118DECLHIDDEN(int) flashR3LoadFromVfs(PFLASHCORE pThis, PPDMDEVINS pDevIns, PPDMIVFSCONNECTOR pDrvVfs,
119 const char *pszNamespace, const char *pszPath);
120DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename);
121DECLHIDDEN(int) flashR3SaveToBuf(PFLASHCORE pThis, void *pvBuf, size_t cbBuf);
122DECLHIDDEN(int) flashR3SaveToVfs(PFLASHCORE pThis, PPDMDEVINS pDevIns, PPDMIVFSCONNECTOR pDrvVfs,
123 const char *pszNamespace, const char *pszPath);
124DECLHIDDEN(void) flashR3Reset(PFLASHCORE pThis);
125DECLHIDDEN(int) flashR3SaveExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
126DECLHIDDEN(int) flashR3LoadExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
127# endif /* IN_RING3 */
128
129#endif /* VBOX_DEVICE_STRUCT_TESTCASE */
130
131RT_C_DECLS_END
132
133#endif /* !VBOX_INCLUDED_SRC_EFI_FlashCore_h */
134
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette