DevEEPROM.cpp revision e178e7e90c2d2d42c37cd65eec49f37292d2f0bb
/* $Id$ */
/** @file
* DevEEPROM - Microware-compatible 64x16-bit 93C46 EEPROM Emulation.
*/
/*
* Copyright (C) 2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "DevEEPROM.h"
/**
* Initialize EEPROM device.
*
* @param pu16Initial Initial EEPROM content (optional). The size of initial
* content must be sizeof(uint16_t)*EEPROM93C46::SIZE
* bytes.
*/
{
if ( pu16Initial ) {
} else {
}
m_fWriteEnabled = false;
m_u32InternalWires = 0;
}
/**
* Writes one word to specified location if write is enabled.
*
* @param u32Addr Address to write at
* @param u16Value Value to store
*/
{
if (m_fWriteEnabled) {
}
}
/**
* Fetch next word pointer by m_u16Addr.
*
* m_u16Addr is advanced and mask is reset to support sequential reads.
*
* @returns New state
*/
{
return WRITING_DO;
}
/**
* Write the value of m_u16Word to the location specified by m_u16Addr.
*
* @returns New state
*
*/
{
return WAITING_CS_FALL;
}
/**
* Overwrite the entire contents of EEPROM with the value of m_u16Word.
*
* @returns New state
*
*/
{
for (int i = 0; i < SIZE; i++)
return WAITING_CS_FALL;
}
/**
* Decode opcode and address from 'opAddr' member.
*
* Decodes operation and executes it immediately if possible; otherwise, stores
* the decoded operation and address.
*
* @returns New state
*/
{
switch (m_u16Word>>6) {
case 3: /* ERASE */
return WAITING_CS_FALL;
case 2: /* READ */
return opRead(); /* Load first word */
case 1: /* WRITE */
m_u16Word = 0;
return READING_DI;
case 0:
switch (m_u16Word>>4) {
m_fWriteEnabled = false;
return STANDBY;
case 1: /* WRITE ALL */
m_u16Word = 0;
return READING_DI;
case 2: /* ERASE ALL */
/* Re-use opWriteAll */
m_u16Word = 0xFFFF;
return opWriteAll();
m_fWriteEnabled = true;
return STANDBY;
}
}
return m_eState;
}
/**
* Set bits in EEPROM 4-wire interface.
*
* @param u32Wires Values of DI, CS, SK.
* @remarks The value of DO bit in 'u32Wires' is ignored.
*/
{
/* Positive edge of clock */
m_u16Word = 0;
}
}
else {
if (m_eState == READING_DI) {
}
}
else if (m_eState == WRITING_DO) {
}
}
else return;
/* Next bit */
m_u16Mask >>= 1;
if (m_u16Mask == 0)
{
switch (this->m_eOp)
{
case OP_READ:
break;
case OP_WRITE:
break;
case OP_WRITE_ALL:
m_eState = opWriteAll();
break;
case OP_DECODE:
break;
default:
;
}
}
}
}
else if (m_eState == WAITING_CS_RISE) {
}
}
else {
switch(m_eState) {
case WAITING_CS_FALL:
break;
case WAITING_CS_RISE:
break;
case READING_DI:
/* Fall through! */
default:
break;
}
}
}
/**
* Read bits in EEPROM 4-wire interface.
*
* @returns Current values of DO, DI, CS, SK.
*
* @remarks Only DO is controlled by EEPROM, other bits are returned as they
* were written by 'write'.
*/
{
return m_u32InternalWires;
}
{
}
{
int rc;
}