VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/DevEEPROM.h@ 78229

Last change on this file since 78229 was 76767, checked in by vboxsync, 6 years ago

Typo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: DevEEPROM.h 76767 2019-01-11 10:13:14Z vboxsync $ */
2/** @file
3 * DevEEPROM - Microwire-compatible 64x16-bit 93C46 EEPROM Emulation, Header.
4 */
5
6/*
7 * Copyright (C) 2007-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_Network_DevEEPROM_h
19#define VBOX_INCLUDED_SRC_Network_DevEEPROM_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/types.h>
25
26/** The current Saved state version. */
27#define EEPROM93C46_SAVEDSTATE_VERSION 1
28
29/**
30 * 93C46-compatible EEPROM device emulation.
31 *
32 * @remarks This class is intended to be used in device
33 * emulation which imposes some restrictions if the
34 * device supports GC execution. This is why it is a
35 * plain-old-data structure.
36 */
37struct EEPROM93C46
38{
39 /** General definitions */
40 enum {
41 /** Size of EEPROM in words */
42 SIZE = 64,
43 /** Number of bits per word */
44 WORD_SIZE = 16,
45 /** Number of address bits */
46 ADDR_SIZE = 6,
47 /** Number of bits in opcode */
48 OPCODE_SIZE = 2,
49 /** The most significant bit mask in data word */
50 DATA_MSB = 1<<(WORD_SIZE-1),
51 /** Address mask */
52 ADDR_MASK = (1<<ADDR_SIZE)-1,
53 /** The most significant bit mask in op+addr bit sequence */
54 OPADDR_MSB = 1<<(OPCODE_SIZE+ADDR_SIZE-1)
55 };
56
57 enum OP {
58 OP_READ,
59 OP_WRITE,
60 OP_WRITE_ALL,
61 OP_DECODE,
62 OP_32BIT_HACK = 0x7fffffff
63 };
64
65 /**
66 * Names of signal wires
67 */
68 enum Wires {
69 WIRES_SK=0x1, ///< Clock
70 WIRES_CS=0x2, ///< Chip Select
71 WIRES_DI=0x4, ///< Data In
72 WIRES_DO=0x8 ///< Data Out
73 };
74
75
76 /** @todo save and load methods */
77 void save(PSSMHANDLE pSSM);
78 int load(PSSMHANDLE pSSM);
79
80 /** Actual content of EEPROM */
81 uint16_t m_au16Data[SIZE];
82
83 /** current state.
84 *
85 * EEPROM operates as a simple state machine. Events are primarily
86 * triggered at positive edge of clock signal (SK). Refer to the
87 * timing diagrams of 93C46 to get better understanding.
88 */
89 enum State {
90 /** Initial state. Waiting for start condition (CS, SK, DI high). */
91 STANDBY,
92 /** Reading data in, shifting in the bits into 'word'. */
93 READING_DI,
94 /** Writing data out, shifting out the bits from 'word'. */
95 WRITING_DO,
96 /** Waiting for CS=0 to indicate we are busy (DO=0). */
97 WAITING_CS_FALL,
98 /** Waiting for CS=1 to indicate we are ready (DO=1). */
99 WAITING_CS_RISE,
100 /** Make this enum 4-byte */
101 STATE_MAKE_32BIT_HACK = 0x7fffffff
102 } m_eState;
103 /** setting writeEnable to false prevents write and erase operations */
104 bool m_fWriteEnabled;
105 uint8_t Alignment1;
106 /** intermediate storage */
107 uint16_t m_u16Word;
108 /** currently processed bit in 'word' */
109 uint16_t m_u16Mask;
110 /** decoded address */
111 uint16_t m_u16Addr;
112 /** Data Out, Data In, Chip Select, Clock */
113 uint32_t m_u32InternalWires;
114
115 /** Current opcode decoder. When no operation has been decoded yet
116 * it is set to OP_DECODE.
117 */
118 OP m_eOp;
119#if HC_ARCH_BITS == 64
120 uint32_t Alignment2;
121#endif
122
123#ifdef IN_RING3
124 uint32_t read();
125 void write(uint32_t u32Wires);
126 bool readWord(uint32_t u32Addr, uint16_t *pu16Value);
127
128 void init(const uint16_t *pu16Initial = 0);
129
130 // Operation handlers
131 State opDecode();
132 State opRead();
133 State opWrite();
134 State opWriteAll();
135
136 /** Helper method to implement write protection */
137 void storeWord(uint32_t u32Addr, uint16_t u16Value);
138#endif /* IN_RING3 */
139};
140
141#endif /* !VBOX_INCLUDED_SRC_Network_DevEEPROM_h */
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