[freenos] r328 committed - Renamed PCIFile to PCIRegiser.

  • From: codesite-noreply@xxxxxxxxxx
  • To: freenos@xxxxxxxxxxxxx
  • Date: Sun, 30 Aug 2009 19:32:08 +0000

Revision: 328
Author: nieklinnenbank
Date: Sun Aug 30 12:29:22 2009
Log: Renamed PCIFile to PCIRegiser.

http://code.google.com/p/freenos/source/detail?r=328

Added:
 /trunk/srv/pci/PCIRegister.cpp
 /trunk/srv/pci/PCIRegister.h
Deleted:
 /trunk/srv/pci/PCIFile.cpp
 /trunk/srv/pci/PCIFile.h

=======================================
--- /dev/null
+++ /trunk/srv/pci/PCIRegister.cpp      Sun Aug 30 12:29:22 2009
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Niek Linnenbank
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <File.h>
+#include <FileMode.h>
+#include "PCIServer.h"
+#include "PCIRegister.h"
+
+PCIRegister::PCIRegister(u16 bus, u16 slot, u16 func, u16 reg, Size size)
+{
+    this->access = OwnerRW;
+    this->bus    = bus;
+    this->slot   = slot;
+    this->func   = func;
+    this->reg    = reg;
+    this->size   = size;
+}
+
+Error PCIRegister::read(IOBuffer *buffer, Size size, Size offset)
+{
+    char buf[32];
+    ulong value = 0;
+    Size bytes;
+
+    /* Bounds checking. */
+    if (offset >= this->size)
+    {
+       return 0;
+    }
+    else
+    {
+       /* Read out the register. */
+       switch (this->size)
+       {
+           case 1:
+               value = PCI_READ_BYTE(bus, slot, func, reg);
+               break;
+
+           case 2:
+               value = PCI_READ_WORD(bus, slot, func, reg);
+               break;
+
+           default:
+               value = PCI_READ_LONG(bus, slot, func, reg);
+               break;
+       }
+       itoa(buf, 16, value);
+
+       /* How much bytes to copy? */
+       bytes = strlen(buf) + 1;
+
+       if (bytes > size)
+           bytes = size;
+
+        /* Copy the buffers. */
+       return buffer->write(buf + offset, bytes);
+    }
+}
=======================================
--- /dev/null
+++ /trunk/srv/pci/PCIRegister.h        Sun Aug 30 12:29:22 2009
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2009 Niek Linnenbank
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __PCI_PCIREGISTER_H
+#define __PCI_PCIREGISTER_H
+
+#include <Types.h>
+#include <Error.h>
+#include "File.h"
+#include "FileMode.h"
+#include "Directory.h"
+#include "IOBuffer.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+/**
+ * @brief Represent a PCI configuration register as a File.
+ *
+ * This class reads out a register directly from the PCI
+ * configuration space.
+ *
+ * @see PCIServer
+ * @see File
+ */
+class PCIRegister : public File
+{
+    public:
+
+       /**
+        * @brief Constructor function.
+        * @param bus PCI bus number.
+        * @param slot PCI slot on the bus.
+        * @param func PCI device function number.
+        * @param reg PCI configuration register to access.
+        * @param size The size of the register.
+        */
+       PCIRegister(u16 bus, u16 slot, u16 func, u16 reg, Size size);
+
+       /**
+         * @brief Read bytes from the file.
+        *
+         * @param buffer Output buffer.
+         * @param size Number of bytes to read, at maximum.
+         * @param offset Offset inside the file to start reading.
+         * @return Number of bytes read on success, Error on failure.
+        *
+        * @see IOBuffer
+        * @see PCIServer.h
+         */
+        Error read(IOBuffer *buffer, Size size, Size offset);
+
+    private:
+
+       /** @brief PCI bus number. */
+       u16 bus;
+
+       /** @brief PCI slot number. */
+       u16 slot;
+
+       /** @brief PCI device function number. */
+       u16 func;
+
+       /** @brief PCI register for I/O. */
+       u16 reg;
+
+       /** @brief Size of the register in bytes. */
+       Size size;
+};
+
+/**
+ * @}
+ */
+
+#endif /* __PCI_PCIREGISTER_H */
=======================================
--- /trunk/srv/pci/PCIFile.cpp  Tue Aug 18 13:57:09 2009
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2009 Niek Linnenbank
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <File.h>
-#include <FileMode.h>
-#include "PCIServer.h"
-#include "PCIFile.h"
-
-PCIFile::PCIFile(u16 bus, u16 slot, u16 func, u16 reg, Size size)
-{
-    this->access = OwnerRW;
-    this->bus  = bus;
-    this->slot = slot;
-    this->func = func;
-    this->reg  = reg;
-    this->size = size;
-}
-
-Error PCIFile::read(IOBuffer *buffer, Size size, Size offset)
-{
-    char buf[4];
-
-    /* Bounds checking. */
-    if (offset >= this->size)
-    {
-       return 0;
-    }
-    else
-    {
-       /* Read out the register. */
-       switch (this->size)
-       {
-           case 1:
-               buf[0] = PCI_READ_BYTE(bus, slot, func, reg);
-               break;
-
-           case 2:
-               *(u16 *)(&buf) = PCI_READ_WORD(bus, slot, func, reg);
-               break;
-
-           default:
-               *(u32 *)(&buf) = PCI_READ_LONG(bus, slot, func, reg);
-               break;
-       }
-       /* How much bytes to copy? */
-       Size bytes = this->size - offset > size ?
-                                          size : this->size - offset;
-
-        /* Copy the buffers. */
-       return buffer->write(buf + offset, bytes);
-    }
-}
=======================================
--- /trunk/srv/pci/PCIFile.h    Sun Aug 16 14:22:16 2009
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009 Niek Linnenbank
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __PCI_PCI_FILE_H
-#define __PCI_PCI_FILE_H
-
-#include <Types.h>
-#include <Error.h>
-#include "File.h"
-#include "FileMode.h"
-#include "Directory.h"
-#include "IOBuffer.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-
-/**
- * @brief Represent a PCI configuration register as a File.
- *
- * This class reads out a register directly from the PCI
- * configuration space.
- *
- * @see PCIServer
- * @see File
- */
-class PCIFile : public File
-{
-    public:
-
-       /**
-        * @brief Constructor function.
-        * @param bus PCI bus number.
-        * @param slot PCI slot on the bus.
-        * @param func PCI device function number.
-        * @param reg PCI configuration register to access.
-        * @param size The size of the register.
-        */
-       PCIFile(u16 bus, u16 slot, u16 func, u16 reg, Size size);
-
-       /**
-         * @brief Read bytes from the file.
-        *
-         * @param buffer Output buffer.
-         * @param size Number of bytes to read, at maximum.
-         * @param offset Offset inside the file to start reading.
-         * @return Number of bytes read on success, Error on failure.
-        *
-        * @see IOBuffer
-        * @see PCIServer.h
-         */
-        Error read(IOBuffer *buffer, Size size, Size offset);
-
-    private:
-
-       /** @brief PCI bus number. */
-       u16 bus;
-
-       /** @brief PCI slot number. */
-       u16 slot;
-
-       /** @brief PCI device function number. */
-       u16 func;
-
-       /** @brief PCI register for I/O. */
-       u16 reg;
-
-       /** @brief Size of the register in bytes. */
-       Size size;
-};
-
-/**
- * @}
- */
-
-#endif /* __FILESYSTEM_PSEUDO_FILE_H */

Other related posts:

  • » [freenos] r328 committed - Renamed PCIFile to PCIRegiser. - codesite-noreply