summaryrefslogtreecommitdiffstats
path: root/src/include/kernel
diff options
context:
space:
mode:
authorDoug Gilbert <dgilbert@us.ibm.com>2011-08-22 17:14:23 -0500
committerDouglas R. Gilbert <dgilbert@us.ibm.com>2011-08-25 13:52:09 -0500
commitbf46e7954689c41cccc897b8b00bcc5db5245374 (patch)
treec7807ff84dd5f8519fb0b065e03ba4939255d485 /src/include/kernel
parent968add63523933786a85ab271b277d79dc5851e6 (diff)
downloadtalos-hostboot-bf46e7954689c41cccc897b8b00bcc5db5245374.tar.gz
talos-hostboot-bf46e7954689c41cccc897b8b00bcc5db5245374.zip
map virtual address to physical address in kernel
Change-Id: Id18e604facd517598a18968af3dff927026ad894 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/272 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include/kernel')
-rw-r--r--src/include/kernel/basesegment.H14
-rw-r--r--src/include/kernel/block.H10
-rw-r--r--src/include/kernel/segment.H9
-rw-r--r--src/include/kernel/segmentmgr.H18
-rw-r--r--src/include/kernel/vmmmgr.H10
5 files changed, 60 insertions, 1 deletions
diff --git a/src/include/kernel/basesegment.H b/src/include/kernel/basesegment.H
index c8cc7a137..a661ae5ce 100644
--- a/src/include/kernel/basesegment.H
+++ b/src/include/kernel/basesegment.H
@@ -44,7 +44,7 @@ class BaseSegment : public Segment
* @brief Constructor.
* Initialize attributes and set base addresss of segment to 0 TB.
*/
- BaseSegment() : Segment(0x0), iv_block(NULL) {};
+ BaseSegment() : Segment(0x0), iv_block(NULL), iv_physMemSize(0) {};
/**
* @brief Destructor
* Delete any blocks owned by this segment.
@@ -75,6 +75,14 @@ class BaseSegment : public Segment
static int mmAllocBlock(MessageQueue* i_mq,void* i_va,
uint64_t i_size);
+ /**
+ * @brief Locate the physical address of the given virtual address
+ * @param[in] i_vaddr virtual address
+ * @return the physical address bound to the virtual address, or
+ * -EFAULT if i_vaddr not found. @see errno.h
+ */
+ virtual uint64_t findPhysicalAddress(uint64_t i_vaddr) const;
+
private:
/**
* @brief Internal implementation of init function.
@@ -84,6 +92,9 @@ class BaseSegment : public Segment
/** Block-chain associated with this Segment. */
Block* iv_block;
+ /** Physical memory byte size */
+ uint64_t iv_physMemSize;
+
/**
* @brief Allocates a block of virtual memory of the given size
* @param i_mq[in] - Message queue to be associated with the block
@@ -92,6 +103,7 @@ class BaseSegment : public Segment
* @return int - 0 for successful block allocation, non-zero otherwise
*/
int _mmAllocBlock(MessageQueue* i_mq,void* i_va,uint64_t i_size);
+
};
#endif
diff --git a/src/include/kernel/block.H b/src/include/kernel/block.H
index 50286a3db..3745b065e 100644
--- a/src/include/kernel/block.H
+++ b/src/include/kernel/block.H
@@ -130,6 +130,16 @@ class Block
*/
void addPTE(void* i_vaddr);
+ /**
+ * @brief Locate the physical address of the given virtual address
+ *
+ * @param[in] i_vaddr virtual address
+ *
+ * @return the physical address bound to the virtual address,
+ * -EFAULT if not found @see errno.h
+ */
+ uint64_t findPhysicalAddress(uint64_t i_vaddr) const;
+
friend class Segment;
friend class BaseSegment;
friend class StackSegment;
diff --git a/src/include/kernel/segment.H b/src/include/kernel/segment.H
index a3df88602..05c5c0fdc 100644
--- a/src/include/kernel/segment.H
+++ b/src/include/kernel/segment.H
@@ -27,6 +27,7 @@
#define __KERNEL_SEGMENT_H
#include <kernel/task.H>
+#include <errno.h>
/** @class Segment
* @brief Virtual segment class to handle virtual memory management within
@@ -66,6 +67,14 @@ class Segment
*/
uint64_t getBaseAddress() const { return iv_baseAddress; };
+ /**
+ * @brief Locate the physical address of the given virtual address
+ * @param[in] i_vaddr virtual address
+ * @return the physical address bound to the virtual address,
+ * or -EFAULT if i_vaddr not found. @see errno.h
+ */
+ virtual uint64_t findPhysicalAddress(uint64_t i_vaddr) const { return -EFAULT; };
+
protected:
/** The base address of the segment. */
const uint64_t iv_baseAddress;
diff --git a/src/include/kernel/segmentmgr.H b/src/include/kernel/segmentmgr.H
index cf1a02b1a..0d8caec33 100644
--- a/src/include/kernel/segmentmgr.H
+++ b/src/include/kernel/segmentmgr.H
@@ -28,6 +28,7 @@
#define __KERNEL_SEGMENTMGR_H
#include <kernel/task.H>
+#include <builtins.h>
// Forward declaration.
class Segment;
@@ -99,6 +100,14 @@ class SegmentManager
*/
static void initSLB();
+ /**
+ * @brief Find the phyiscal address bound to the given address
+ * @param[in] i_vaddr The address
+ * @return the physical address or -EFAULT @see errno.h
+ */
+ static uint64_t findPhysicalAddress(uint64_t i_vaddr);
+
+
private:
/** See handlePageFault. */
bool _handlePageFault(task_t* i_task, uint64_t i_addr);
@@ -107,6 +116,15 @@ class SegmentManager
/** See initSLB. */
void _initSLB();
+ /** See findPhysicalAddress */
+ uint64_t _findPhysicalAddress(uint64_t i_vaddr) const;
+
+ ALWAYS_INLINE inline
+ size_t getSegmentIdFromAddress(uint64_t i_addr) const
+ {
+ return i_addr >> 40; // SLBE_s = 40 Should come from page manager?
+ }
+
/** Array of segment objects to associated segment IDs. */
Segment* iv_segments[MAX_SEGMENTS];
};
diff --git a/src/include/kernel/vmmmgr.H b/src/include/kernel/vmmmgr.H
index a32408e24..06533e34e 100644
--- a/src/include/kernel/vmmmgr.H
+++ b/src/include/kernel/vmmmgr.H
@@ -101,6 +101,13 @@ class VmmManager
*/
static int mmAllocBlock(MessageQueue* i_mq,void* i_va,uint64_t i_size);
+ /**
+ * @brief Find the phyiscal address bound to the given address
+ * @param[in] i_vaddr The address
+ * @return the physical address or -EFAULT @see errno.h
+ */
+ static uint64_t findPhysicalAddress(uint64_t i_vaddr);
+
protected:
VmmManager();
@@ -121,6 +128,9 @@ class VmmManager
bool _pteMiss(task_t*, uint64_t);
+ /** See findPhysicalAddress */
+ uint64_t _findPhysicalAddress(uint64_t i_vaddr);
+
public:
friend class Block;
OpenPOWER on IntegriCloud