Merge zed.eecs.umich.edu:/.automount/fox/y/mserrano/m5_dir/m5
[gem5.git] / dev / ns_gige.hh
index cbb7185e7f37f0d08ff368472700621fc1dbdd6e..ac16aa26652f36f0bb80ea7cdb63fd3db98fb9bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 The Regents of The University of Michigan
+ * Copyright (c) 2004-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* @file
+/** @file
  * Device module for modelling the National Semiconductor
  * DP83820 ethernet controller
  */
 #include "mem/bus/bus.hh"
 #include "sim/eventq.hh"
 
+// Hash filtering constants
+const uint16_t FHASH_ADDR  = 0x100;
+const uint16_t FHASH_SIZE  = 0x100;
+
+// EEPROM constants
+const uint8_t  EEPROM_READ = 0x2;
+const uint8_t  EEPROM_SIZE = 64; // Size in words of NSC93C46 EEPROM
+const uint8_t  EEPROM_PMATCH2_ADDR = 0xA; // EEPROM Address of PMATCH word 2
+const uint8_t  EEPROM_PMATCH1_ADDR = 0xB; // EEPROM Address of PMATCH word 1
+const uint8_t  EEPROM_PMATCH0_ADDR = 0xC; // EEPROM Address of PMATCH word 0
+
 /**
  * Ethernet device registers
  */
@@ -69,6 +80,8 @@ struct dp_regs {
     uint32_t    pcr;
     uint32_t    rfcr;
     uint32_t    rfdr;
+    uint32_t    brar;
+    uint32_t    brdr;
     uint32_t    srr;
     uint32_t    mibc;
     uint32_t    vrcr;
@@ -89,6 +102,12 @@ struct dp_rom {
      * the linux driver doesn't use any other ROM
      */
     uint8_t perfectMatch[ETH_ADDR_LEN];
+
+    /**
+     * for hash table memory.
+     * used by the freebsd driver
+     */
+    uint8_t filterHash[FHASH_SIZE];
 };
 
 class NSGigEInt;
@@ -99,7 +118,7 @@ class Bus;
 class PciConfigAll;
 
 /**
- * NS DP82830 Ethernet device model
+ * NS DP83820 Ethernet device model
  */
 class NSGigE : public PciDev
 {
@@ -137,6 +156,15 @@ class NSGigE : public PciDev
         dmaWriteWaiting
     };
 
+    /** EEPROM State Machine States */
+    enum EEPROMState
+    {
+        eepromStart,
+        eepromGetOpcode,
+        eepromGetAddress,
+        eepromRead
+    };
+
   private:
     Addr addr;
     static const Addr size = sizeof(dp_regs);
@@ -176,8 +204,8 @@ class NSGigE : public PciDev
     ns_desc rxDescCache;
 
     /* state machine cycle time */
-    Tick cycleTime;
-    inline Tick cycles(int numCycles) const { return numCycles * cycleTime; }
+    Tick clock;
+    inline Tick cycles(int numCycles) const { return numCycles * clock; }
 
     /* tx State Machine */
     TxState txState;
@@ -211,6 +239,14 @@ class NSGigE : public PciDev
 
     bool extstsEnable;
 
+    /** EEPROM State Machine */
+    EEPROMState eepromState;
+    bool eepromClk;
+    uint8_t eepromBitsToRx;
+    uint8_t eepromOpcode;
+    uint8_t eepromAddress;
+    uint16_t eepromData;
+
   protected:
     Tick dmaReadDelay;
     Tick dmaWriteDelay;
@@ -266,11 +302,15 @@ class NSGigE : public PciDev
     Tick rxKickTick;
     typedef EventWrapper<NSGigE, &NSGigE::rxKick> RxKickEvent;
     friend void RxKickEvent::process();
+    RxKickEvent rxKickEvent;
 
     void txKick();
     Tick txKickTick;
     typedef EventWrapper<NSGigE, &NSGigE::txKick> TxKickEvent;
     friend void TxKickEvent::process();
+    TxKickEvent txKickEvent;
+
+    void eepromKick();
 
     /**
      * Retransmit event
@@ -299,6 +339,7 @@ class NSGigE : public PciDev
     bool acceptUnicast;
     bool acceptPerfect;
     bool acceptArp;
+    bool multicastHashEnable;
 
     PhysicalMemory *physmem;
 
@@ -328,7 +369,7 @@ class NSGigE : public PciDev
         HierParams *hier;
         Bus *header_bus;
         Bus *payload_bus;
-        Tick cycle_time;
+        Tick clock;
         Tick intr_delay;
         Tick tx_delay;
         Tick rx_delay;
@@ -351,8 +392,8 @@ class NSGigE : public PciDev
     ~NSGigE();
     const Params *params() const { return (const Params *)_params; }
 
-    virtual void WriteConfig(int offset, int size, uint32_t data);
-    virtual void ReadConfig(int offset, int size, uint8_t *data);
+    virtual void writeConfig(int offset, int size, const uint8_t *data);
+    virtual void readConfig(int offset, int size, uint8_t *data);
 
     virtual Fault read(MemReqPtr &req, uint8_t *data);
     virtual Fault write(MemReqPtr &req, const uint8_t *data);