remove some getPtr() calls by changing having function return values
authorAli Saidi <saidi@eecs.umich.edu>
Mon, 29 May 2006 02:21:57 +0000 (22:21 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Mon, 29 May 2006 02:21:57 +0000 (22:21 -0400)
instead of taking a pointer

--HG--
extra : convert_revision : fd9092eaa726e91b501334d35d28dda28aaa01bd

src/dev/simconsole.cc
src/dev/simconsole.hh
src/dev/tsunami_io.cc
src/dev/tsunami_io.hh
src/dev/uart8250.cc

index c3e4f554ac6f4978a30a6443a7363d437576f820..e33fa18b55aaff090109c0c81dae469ed7d65739 100644 (file)
@@ -202,32 +202,31 @@ SimConsole::write(const uint8_t *buf, size_t len)
 #define RECEIVE_NONE (ULL(2) << 62)
 #define RECEIVE_ERROR (ULL(3) << 62)
 
-bool
-SimConsole::in(uint8_t &c)
+uint8_t
+SimConsole::in()
 {
-    bool empty, ret;
+    bool empty;
+    uint8_t c;
 
     empty = rxbuf.empty();
-    ret = !empty;
-    if (!empty) {
-        rxbuf.read((char *)&c, 1);
-        empty = rxbuf.empty();
-    }
+    assert(!empty);
+    rxbuf.read((char *)&c, 1);
+    empty = rxbuf.empty();
 
-    DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d, return: %d\n",
-            isprint(c) ? c : ' ', c, !empty, ret);
 
-    return ret;
+    DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d\n",
+            isprint(c) ? c : ' ', c, !empty);
+
+    return c;
 }
 
 uint64_t
 SimConsole::console_in()
 {
-    uint8_t c;
     uint64_t value;
 
-    if (in(c)) {
-        value = RECEIVE_SUCCESS | c;
+    if (dataAvailable()) {
+        value = RECEIVE_SUCCESS | in();
         if (!rxbuf.empty())
             value  |= MORE_PENDING;
     } else {
index cf0641f9e057d130226b2f5b17b40c857abe10bf..64d1f67170fceefc210a99267b01bf7128acf8cf 100644 (file)
@@ -102,7 +102,7 @@ class SimConsole : public SimObject
     // OS interface
 
     // Get a character from the console.
-    bool in(uint8_t &value);
+    uint8_t  in();
 
     // get a character from the console in the console specific format
     // corresponds to GETC:
index 7c649a84a07ee6d879024db8fba50b1473ab393c..729a61cf7d612fa83fa190257fa29cade12e5211 100644 (file)
@@ -118,25 +118,27 @@ TsunamiIO::RTC::writeData(const uint8_t data)
     }
 }
 
-void
-TsunamiIO::RTC::readData(uint8_t *data)
+uint8_t
+TsunamiIO::RTC::readData()
 {
     if (addr < RTC_STAT_REGA)
-        *data = clock_data[addr];
+        return clock_data[addr];
     else {
         switch (addr) {
           case RTC_STAT_REGA:
             // toggle UIP bit for linux
             stat_regA ^= RTCA_UIP;
-            *data = stat_regA;
+            return stat_regA;
             break;
           case RTC_STAT_REGB:
-            *data = stat_regB;
+            return stat_regB;
             break;
           case RTC_STAT_REGC:
           case RTC_STAT_REGD:
-            *data = 0x00;
+            return 0x00;
             break;
+          default:
+            panic("Shouldn't be here");
         }
     }
 }
@@ -263,31 +265,35 @@ TsunamiIO::PITimer::Counter::latchCount()
     }
 }
 
-void
-TsunamiIO::PITimer::Counter::read(uint8_t *data)
+uint8_t
+TsunamiIO::PITimer::Counter::read()
 {
     if (latch_on) {
         switch (read_byte) {
           case LSB:
             read_byte = MSB;
-            *data = (uint8_t)latched_count;
+            return (uint8_t)latched_count;
             break;
           case MSB:
             read_byte = LSB;
             latch_on = false;
-            *data = latched_count >> 8;
+            return latched_count >> 8;
             break;
+          default:
+            panic("Shouldn't be here");
         }
     } else {
         switch (read_byte) {
           case LSB:
             read_byte = MSB;
-            *data = (uint8_t)count;
+            return (uint8_t)count;
             break;
           case MSB:
             read_byte = LSB;
-            *data = count >> 8;
+            return count >> 8;
             break;
+          default:
+            panic("Shouldn't be here");
         }
     }
 }
@@ -469,16 +475,16 @@ TsunamiIO::read(Packet *pkt)
               pkt->set(0x00);
               break;
           case TSDEV_TMR0_DATA:
-            pitimer.counter0.read(pkt->getPtr<uint8_t>());
+            pkt->set(pitimer.counter0.read());
             break;
           case TSDEV_TMR1_DATA:
-            pitimer.counter1.read(pkt->getPtr<uint8_t>());
+            pkt->set(pitimer.counter1.read());
             break;
           case TSDEV_TMR2_DATA:
-            pitimer.counter2.read(pkt->getPtr<uint8_t>());
+            pkt->set(pitimer.counter2.read());
             break;
           case TSDEV_RTC_DATA:
-            rtc.readData(pkt->getPtr<uint8_t>());
+            pkt->set(rtc.readData());
             break;
           case TSDEV_CTRL_PORTB:
             if (pitimer.counter2.outputHigh())
index 4e4fb2036ec43c5912ab7c2e3576703c87c1e1a4..71ca0d98f48c2453a93e1de8d1febf9c0257e878 100644 (file)
@@ -118,7 +118,7 @@ class TsunamiIO : public BasicPioDevice
         void writeData(const uint8_t data);
 
         /** RTC read data */
-        void readData(uint8_t *data);
+        uint8_t readData();
 
         /**
           * Serialize this object to the given output stream.
@@ -207,7 +207,7 @@ class TsunamiIO : public BasicPioDevice
             void setBCD(int bcd_val);
 
             /** Read a count byte */
-            void read(uint8_t *data);
+            uint8_t read();
 
             /** Write a count byte */
             void write(const uint8_t data);
index 8e6843841f14d340d68c0cb68e9a9ff104809875..8a5a1f1cd872e922036f227df380249070bfc35f 100644 (file)
@@ -124,7 +124,7 @@ Uart8250::read(Packet *pkt)
         case 0x0:
             if (!(LCR & 0x80)) { // read byte
                 if (cons->dataAvailable())
-                    cons->in(*pkt->getPtr<uint8_t>());
+                    pkt->set(cons->in());
                 else {
                     pkt->set((uint8_t)0);
                     // A limited amount of these are ok.