VirtualBox

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

Last change on this file since 15953 was 15953, checked in by vboxsync, 16 years ago

export E1000 to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: DevEEPROM.h 15953 2009-01-14 19:21:31Z vboxsync $ */
2/** @file
3 * DevEEPROM - Microware-compatible 64x16-bit 93C46 EEPROM Emulation, Header.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
8 *
9 * Sun Microsystems, Inc. confidential
10 * All rights reserved
11 */
12
13/* Interface */
14#include <iprt/types.h>
15
16/**
17 * 93C46-compatible EEPROM device emulation.
18 *
19 * @remarks This class is intended to be used in device
20 * emulation which imposes some restrictions if the
21 * device supports GC execution. This is why it is a
22 * plain-old-data structure.
23 */
24struct EEPROM93C46 {
25 /** General definitions */
26 enum {
27 /** Size of EEPROM in words */
28 SIZE = 64,
29 /** Number of bits per word */
30 WORD_SIZE = 16,
31 /** Number of address bits */
32 ADDR_SIZE = 6,
33 /** Number of bits in opcode */
34 OPCODE_SIZE = 2,
35 /** The most significant bit mask in data word */
36 DATA_MSB = 1<<(WORD_SIZE-1),
37 /** Address mask */
38 ADDR_MASK = (1<<ADDR_SIZE)-1,
39 /** The most significant bit mask in op+addr bit sequence */
40 OPADDR_MSB = 1<<(OPCODE_SIZE+ADDR_SIZE-1)
41 };
42
43 enum OP {
44 OP_READ,
45 OP_WRITE,
46 OP_WRITE_ALL,
47 OP_DECODE,
48 OP_32BIT_HACK = 0x7fffffff
49 };
50
51 /**
52 * Names of signal wires
53 */
54 enum Wires {
55 WIRES_SK=0x1, ///< Clock
56 WIRES_CS=0x2, ///< Chip Select
57 WIRES_DI=0x4, ///< Data In
58 WIRES_DO=0x8 ///< Data Out
59 };
60
61
62 /* @todo save and load methods */
63
64 /** Actual content of EEPROM */
65 uint16_t m_au16Data[SIZE];
66
67 /** current state.
68 *
69 * EEPROM operates as a simple state machine. Events are primarily
70 * triggered at positive edge of clock signal (SK). Refer to the
71 * timing diagrams of 93C46 to get better understanding.
72 */
73 enum State {
74 /** Initial state. Waiting for start condition (CS, SK, DI high). */
75 STANDBY,
76 /** Reading data in, shifting in the bits into 'word'. */
77 READING_DI,
78 /** Writing data out, shifting out the bits from 'word'. */
79 WRITING_DO,
80 /** Waiting for CS=0 to indicate we are busy (DO=0). */
81 WAITING_CS_FALL,
82 /** Waiting for CS=1 to indicate we are ready (DO=1). */
83 WAITING_CS_RISE,
84 /** Make this enum 4-byte */
85 STATE_MAKE_32BIT_HACK = 0x7fffffff
86 } m_eState;
87 /** setting writeEnable to false prevents write and erase operations */
88 bool m_fWriteEnabled;
89 uint8_t Alignment1;
90 /** intermediate storage */
91 uint16_t m_u16Word;
92 /** currently processed bit in 'word' */
93 uint16_t m_u16Mask;
94 /** decoded address */
95 uint16_t m_u16Addr;
96 /** Data Out, Data In, Chip Select, Clock */
97 uint32_t m_u32InternalWires;
98
99 /** Current opcode decoder. When no operation has been decoded yet
100 * it is set to OP_DECODE.
101 */
102 OP m_eOp;
103#if HC_ARCH_BITS == 64
104 uint32_t Alignment2;
105#endif
106
107#ifdef IN_RING3
108 uint32_t read();
109 void write(uint32_t u32Wires);
110
111 void init(const uint16_t *pu16Initial = 0);
112
113 // Operation handlers
114 State opDecode();
115 State opRead();
116 State opWrite();
117 State opWriteAll();
118
119 /** Helper method to implement write protection */
120 void storeWord(uint32_t u32Addr, uint16_t u16Value);
121#endif /* IN_RING3 */
122};
Note: See TracBrowser for help on using the repository browser.

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