I/O changes and SkipFuncEvents to increase FreeBSD compatibility.
authorBenjamin Nash <benash@umich.edu>
Fri, 17 Jun 2005 22:08:05 +0000 (18:08 -0400)
committerBenjamin Nash <benash@umich.edu>
Fri, 17 Jun 2005 22:08:05 +0000 (18:08 -0400)
SConscript:
    Added kern/freebsd/freebsd_events.cc.
arch/alpha/isa_traits.hh:
    Added Argument to support replacement of calibrate_clocks function in FreeBSD.
dev/ns_gige.hh:
    Fixed NIC model number typo.
dev/tsunami_io.cc:
    Added support for RTC writes and PIC 2 mask reads.  Made RTC static member.
dev/tsunami_io.hh:
    Made RTC static member.
kern/freebsd/freebsd_system.cc:
    Added events to skip functions in FreeBSD.
kern/freebsd/freebsd_system.hh:
    Added events to skip certain functions.

--HG--
extra : convert_revision : 8aaca51d3f9b1bb601722a5bae240aae77b445db

SConscript
arch/alpha/isa_traits.hh
dev/ns_gige.hh
dev/tsunami_io.cc
dev/tsunami_io.hh
kern/freebsd/freebsd_system.cc
kern/freebsd/freebsd_system.hh

index 5d4fc42e183df5b9b0d8a68bc026d69fbed056c7..508b7637596251d0a2a967dfaffe15b414ab4ee8 100644 (file)
@@ -279,6 +279,7 @@ full_system_sources = Split('''
        kern/kernel_stats.cc
        kern/system_events.cc
        kern/freebsd/freebsd_system.cc
+        kern/freebsd/freebsd_events.cc
        kern/linux/linux_events.cc
        kern/linux/linux_syscalls.cc
        kern/linux/linux_system.cc
index 9c7709a6042a1f87f85e406d781a65923f0bbd82..6c0c09b7a432067a8fc8d7f5bae561a24eabf0df 100644 (file)
@@ -287,6 +287,7 @@ const int ReturnAddressReg = TheISA::ReturnAddressReg;
 const int ReturnValueReg = TheISA::ReturnValueReg;
 const int ArgumentReg0 = TheISA::ArgumentReg0;
 const int ArgumentReg1 = TheISA::ArgumentReg1;
+const int ArgumentReg2 = TheISA::ArgumentReg2;
 const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
 const int MaxAddr = (Addr)-1;
 
index f39731493548468563314c31f20eec3158d46a84..9007ea6cf5298b980fa52a8c5d09167c9c726bed 100644 (file)
@@ -99,7 +99,7 @@ class Bus;
 class PciConfigAll;
 
 /**
- * NS DP82830 Ethernet device model
+ * NS DP83820 Ethernet device model
  */
 class NSGigE : public PciDev
 {
index 5d5eba68e0c32ea08ca1e40ee85fc9c41cce55e4..7db55b32147f711add7b654399ee8d67f5092c86 100644 (file)
@@ -52,6 +52,8 @@ using namespace std;
 
 #define UNIX_YEAR_OFFSET 52
 
+struct tm TsunamiIO::tm = { 0 };
+
 // Timer Event for Periodic interrupt of RTC
 TsunamiIO::RTCEvent::RTCEvent(Tsunami* t, Tick i)
     : Event(&mainEventQueue), tsunami(t), interval(i)
@@ -67,6 +69,9 @@ TsunamiIO::RTCEvent::process()
     schedule(curTick + interval);
     //Actually interrupt the processor here
     tsunami->cchip->postRTC();
+
+    // For FreeBSD
+    tm.tm_sec++;
 }
 
 const char *
@@ -217,6 +222,9 @@ TsunamiIO::read(MemReqPtr &req, uint8_t *data)
           case TSDEV_PIC1_MASK:
             *(uint8_t*)data = ~mask1;
             return No_Fault;
+          case TSDEV_PIC2_MASK:
+            *(uint8_t*)data = ~mask2;
+            return No_Fault;
           case TSDEV_PIC1_ISR:
               // !!! If this is modified 64bit case needs to be too
               // Pal code has to do a 64 bit physical read because there is
@@ -261,6 +269,7 @@ TsunamiIO::read(MemReqPtr &req, uint8_t *data)
                 return No_Fault;
               case RTC_DOM:
                 *(uint8_t *)data = tm.tm_mday;
+                return No_Fault;
               case RTC_MON:
                 *(uint8_t *)data = tm.tm_mon + 1;
                 return No_Fault;
@@ -411,7 +420,38 @@ TsunamiIO::write(MemReqPtr &req, const uint8_t *data)
           case TSDEV_KBD:
             return No_Fault;
           case TSDEV_RTC_DATA:
-            panic("RTC Write not implmented (rtc.o won't work)\n");
+            switch(RTCAddress) {
+              case RTC_CNTRL_REGA:
+                return No_Fault;
+              case RTC_CNTRL_REGB:
+                return No_Fault;
+              case RTC_CNTRL_REGC:
+                return No_Fault;
+              case RTC_CNTRL_REGD:
+                return No_Fault;
+              case RTC_SEC:
+                tm.tm_sec = *(uint8_t *)data;
+                return No_Fault;
+              case RTC_MIN:
+                tm.tm_min = *(uint8_t *)data;
+                return No_Fault;
+              case RTC_HR:
+                tm.tm_hour = *(uint8_t *)data;
+                return No_Fault;
+              case RTC_DOW:
+                tm.tm_wday = *(uint8_t *)data;
+                return No_Fault;
+              case RTC_DOM:
+                tm.tm_mday = *(uint8_t *)data;
+                return No_Fault;
+              case RTC_MON:
+                 tm.tm_mon = *(uint8_t *)data - 1;
+                return No_Fault;
+              case RTC_YEAR:
+                tm.tm_year = *(uint8_t *)data + UNIX_YEAR_OFFSET;
+                return No_Fault;
+            //panic("RTC Write not implmented (rtc.o won't work)\n");
+            }
           default:
             panic("I/O Write - va%#x size %d\n", req->vaddr, req->size);
         }
index d5d106db3b9c37802ab4d48347b67135c44ce292..86c739285d7f4267f95ecc5b41b82f31d2384e75 100644 (file)
@@ -51,7 +51,7 @@ class TsunamiIO : public PioDevice
     /** The size of mappad from the above address */
     static const Addr size = 0xff;
 
-    struct tm tm;
+    static struct tm tm;
 
     /**
      * In Tsunami RTC only has two i/o ports one for data and one for
index a22fda9dcaa80659681d958b1dba5ddd926eebfa..08d1af824d614f212689257f3116bcbfb8606371 100644 (file)
@@ -29,7 +29,7 @@
 /**
  * @file
  * Modifications for the FreeBSD kernel.  Based off of kern/linux/linux_system.cc.
- * Currently only used to skip DELAY function. -Ben
+ * Currently only used to skip DELAY function.
  *
  */
 
@@ -64,11 +64,60 @@ FreebsdSystem::FreebsdSystem(Params *p)
     skipDelayEvent = new SkipFuncEvent(&pcEventQueue, "DELAY");
     if (kernelSymtab->findAddress("DELAY", addr))
         skipDelayEvent->schedule(addr+sizeof(MachInst));
+
+    skipOROMEvent = new SkipFuncEvent(&pcEventQueue, "orm_identify");
+    if (kernelSymtab->findAddress("orm_identify", addr))
+        skipOROMEvent->schedule(addr+sizeof(MachInst));
+
+    skipAicEvent = new SkipFuncEvent(&pcEventQueue, "ahc_isa_identify");
+    if (kernelSymtab->findAddress("ahc_isa_identify", addr))
+        skipAicEvent->schedule(addr+sizeof(MachInst));
+
+    skipPNPEvent = new SkipFuncEvent(&pcEventQueue, "pnp_identify");
+    if (kernelSymtab->findAddress("pnp_identify", addr))
+        skipPNPEvent->schedule(addr+sizeof(MachInst));
+
+    skipATAEvent = new SkipFuncEvent(&pcEventQueue, "ata_attach");
+    if (kernelSymtab->findAddress("ata_attach", addr))
+        skipATAEvent->schedule(addr+sizeof(MachInst));
+
+    skipCalibrateClocks = new FreebsdSkipCalibrateClocksEvent(&pcEventQueue, "calibrate_clocks");
+    if (kernelSymtab->findAddress("calibrate_clocks", addr))
+        skipCalibrateClocks->schedule(addr + sizeof(MachInst) * 2);
+
 }
 
+
 FreebsdSystem::~FreebsdSystem()
 {
     delete skipDelayEvent;
+    delete skipOROMEvent;
+    delete skipAicEvent;
+    delete skipATAEvent;
+    delete skipPNPEvent;
+    delete skipCalibrateClocks;
+}
+
+
+void
+FreebsdSystem::doCalibrateClocks(ExecContext *xc)
+{
+    Addr ppc_vaddr = 0;
+    Addr timer_vaddr = 0;
+    Addr ppc_paddr = 0;
+    Addr timer_paddr = 0;
+
+    ppc_vaddr = (Addr)xc->regs.intRegFile[ArgumentReg1];
+    timer_vaddr = (Addr)xc->regs.intRegFile[ArgumentReg2];
+
+    ppc_paddr = vtophys(physmem, ppc_vaddr);
+    timer_paddr = vtophys(physmem, timer_vaddr);
+
+    uint8_t *ppc = physmem->dma_addr(ppc_paddr, sizeof(uint32_t));
+    uint8_t *timer = physmem->dma_addr(timer_paddr, sizeof(uint32_t));
+
+    *(uint32_t *)ppc = 2000000000;
+    *(uint32_t *)timer = 1193180;
 }
 
 
index 8caa81cbc5cc3b39e2c059f2bed6894ab67743ca..3e9867733437efe6d3d2d62d06806257d2748175 100644 (file)
 #include "sim/host.hh"
 #include "sim/system.hh"
 #include "targetarch/isa_traits.hh"
+#include "kern/freebsd/freebsd_events.hh"
 
 
 /**
- * This class skips a lengthy function in the FreeBSD kernel.
+ * This class skips lengthy functions in the FreeBSD kernel.
  */
 class FreebsdSystem : public System
 {
@@ -44,10 +45,21 @@ class FreebsdSystem : public System
     /** PC based event to skip the DELAY call */
     SkipFuncEvent *skipDelayEvent;
 
+    SkipFuncEvent *skipOROMEvent;
+
+    SkipFuncEvent *skipAicEvent;
+
+    SkipFuncEvent *skipPNPEvent;
+
+    SkipFuncEvent *skipATAEvent;
+
+    FreebsdSkipCalibrateClocksEvent *skipCalibrateClocks;
+
   public:
     FreebsdSystem(Params *p);
     ~FreebsdSystem();
+    void doCalibrateClocks(ExecContext *xc);
 
 };
 
-#endif // __KERN_LINUX_LINUX_SYSTEM_HH__
+#endif // __KERN_FREEBSD_FREEBSD_SYSTEM_HH__