DevEEPROM.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * DevEEPROM - Microware-compatible 64x16-bit 93C46 EEPROM Emulation.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2007 Oracle Corporation
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * available from http://www.virtualbox.org. This file is free software;
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * General Public License (GPL) as published by the Free Software
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync#define LOG_GROUP LOG_GROUP_DEV_E1000 /// @todo Add a EEPROM logging group.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Initialize EEPROM device.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @param pu16Initial Initial EEPROM content (optional). The size of initial
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * content must be sizeof(uint16_t)*EEPROM93C46::SIZE
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync memcpy(this->m_au16Data, pu16Initial, sizeof(this->m_au16Data));
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync memset(this->m_au16Data, 0, sizeof(this->m_au16Data));
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Writes one word to specified location if write is enabled.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @param u32Addr Address to write at
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @param u16Value Value to store
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsyncvoid EEPROM93C46::storeWord(uint32_t u32Addr, uint16_t u16Value)
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync E1kLog(("EEPROM: Stored word %04x at %08x\n", u16Value, u32Addr));
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync * Reads one word at specified location.
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync * @returns True if read was successful.
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync * @param u32Addr Address to read from
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync * @param pu16Value Placeholder to store the value
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsyncbool EEPROM93C46::readWord(uint32_t u32Addr, uint16_t *pu16Value)
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync return true;
f0679a3d26514d6f85279a4018282ead9ff0f067vboxsync return false;
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Fetch next word pointer by m_u16Addr.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * m_u16Addr is advanced and mask is reset to support sequential reads.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @returns New state
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync E1kLog(("EEPROM: Reading word %04x at %08x\n", m_u16Word, m_u16Addr-1));
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Write the value of m_u16Word to the location specified by m_u16Addr.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @returns New state
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @remarks Need to wait for CS lower/raise to show busy/ready indication.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Overwrite the entire contents of EEPROM with the value of m_u16Word.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @returns New state
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @remarks Need to wait for CS lower/raise to show busy/ready indication.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync for (int i = 0; i < SIZE; i++)
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Decode opcode and address from 'opAddr' member.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Decodes operation and executes it immediately if possible; otherwise, stores
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * the decoded operation and address.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @returns New state
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync case 0: /* ERASE/WRITE DISABLE */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync /* Re-use opWriteAll */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Set bits in EEPROM 4-wire interface.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @param u32Wires Values of DI, CS, SK.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @remarks The value of DO bit in 'u32Wires' is ignored.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync if (!(m_u32InternalWires & WIRES_SK) && (u32Wires & WIRES_SK)) {
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync /* Positive edge of clock */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync else return;
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync /* Next bit */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync switch (this->m_eOp)
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync m_u32InternalWires &= ~WIRES_DO; /* Clear ready/busy status from DO. */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync /* Fall through! */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync m_u32InternalWires |= u32Wires & ~WIRES_DO; /* Do not overwrite DO */
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Read bits in EEPROM 4-wire interface.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @returns Current values of DO, DI, CS, SK.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * @remarks Only DO is controlled by EEPROM, other bits are returned as they
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * were written by 'write'.
da7f6376d98136ac8a76f7110a452c6e56508c49vboxsync SSMR3PutMem( pSSM, m_au16Data, sizeof(m_au16Data));
e178e7e90c2d2d42c37cd65eec49f37292d2f0bbvboxsync return SSMR3GetMem( pSSM, m_au16Data, sizeof(m_au16Data));