DevEEPROM.cpp revision dbcf44d4b4f08f03eae2903053ed8c5264b0c23f
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * DevEEPROM - Microware-compatible 64x16-bit 93C46 EEPROM Emulation.
aaf6eb788dab09bc8c3c8576c60fabc60037a483vboxsync * Copyright (C) 2007 Sun Microsystems, Inc.
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.
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
dbcf44d4b4f08f03eae2903053ed8c5264b0c23fvboxsync * additional information or have any questions.
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));
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'.