summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/kernel/devicesegment.H47
-rw-r--r--src/include/kernel/misc.H63
-rw-r--r--src/include/kernel/pagemgr.H22
-rw-r--r--src/include/kernel/syscalls.H4
-rw-r--r--src/include/sys/mm.h6
-rw-r--r--src/include/usr/vmmconst.h15
6 files changed, 88 insertions, 69 deletions
diff --git a/src/include/kernel/devicesegment.H b/src/include/kernel/devicesegment.H
index c300eedde..2b87c9161 100644
--- a/src/include/kernel/devicesegment.H
+++ b/src/include/kernel/devicesegment.H
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/include/kernel/devicesegment.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/kernel/devicesegment.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2011-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
#ifndef __KERNEL_DEVICESEGMENT_H
#define __KERNEL_DEVICESEGMENT_H
@@ -41,7 +42,7 @@ class DeviceSegment : public Segment
*
* Associates itself with the SegmentManager.
*/
- explicit DeviceSegment(size_t segId) : Segment(segId * TERABYTE)
+ explicit DeviceSegment(size_t segId) : Segment(segId * VMM_SEGMENT_SIZE)
{ init(segId); };
/**
diff --git a/src/include/kernel/misc.H b/src/include/kernel/misc.H
index f04439748..ebec9cc48 100644
--- a/src/include/kernel/misc.H
+++ b/src/include/kernel/misc.H
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/include/kernel/misc.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/kernel/misc.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2011-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
/** @file misc.H
* @brief Misc. Kernel functions and utilities.
*/
@@ -28,6 +29,7 @@
#define __KERNEL_MISC_H
#include <stdint.h>
+#include <usr/vmmconst.h>
namespace KernelMisc
{
@@ -40,5 +42,22 @@ namespace KernelMisc
extern uint64_t g_payload_base;
/** @brief Address from base of payload entry-point. */
extern uint64_t g_payload_entry;
+
+ /** @fn in_kernel_mode
+ * @brief Determine if the code is currently in kernel mode or not.
+ *
+ * @return [true | false]
+ */
+ inline bool in_kernel_mode()
+ {
+ uint64_t stack = 0;
+ asm volatile("mr %0, 1" : "=r"(stack));
+ if((stack >= VMM_VADDR_STACK_SEGMENT) &&
+ (stack < (VMM_VADDR_STACK_SEGMENT + VMM_SEGMENT_SIZE)))
+ {
+ return false;
+ }
+ return true;
+ }
};
#endif
diff --git a/src/include/kernel/pagemgr.H b/src/include/kernel/pagemgr.H
index 6676a469c..93cd82bb5 100644
--- a/src/include/kernel/pagemgr.H
+++ b/src/include/kernel/pagemgr.H
@@ -54,7 +54,7 @@ class PageManagerCore
/**
* Default Constructor
*/
- PageManagerCore()
+ PageManagerCore()
: iv_available(0) {}
/**
@@ -76,7 +76,7 @@ class PageManagerCore
* @return a pointer to the requested allocation | NULL
* if the request could not be satisfied.
*/
- page_t * allocatePage( size_t i_pageCount );
+ page_t * allocatePage( size_t i_pageCount );
/**
* Return page allocations to the page manager
@@ -136,9 +136,10 @@ class PageManager
/**
* Allocate pages
* @param[in] n, Requested allocation in pages
+ * @param[in] userspace - Request to allocate came from userspace
* @return pointer to requested memory
*/
- static void* allocatePage(size_t n = 1);
+ static void* allocatePage(size_t n = 1, bool userspace = false);
/**
* Return pages to the pagemanager
@@ -170,6 +171,9 @@ class PageManager
{
MEMLEN = VmmManager::MBOX_DMA_ADDR,
RESERVED_PAGES = 4,
+
+ LOWMEM_NORM_LIMIT = 16,
+ LOWMEM_CRIT_LIMIT = 5,
};
static size_t cv_coalesce_count; //!< running coalesced counter
@@ -182,15 +186,9 @@ class PageManager
private:
- void* _allocatePage(size_t); //!< see allocatePage()
- void _freePage(void*, size_t); //!< see freePage()
- void _coalesce( void ); //!< see coalesce()
-
- /**
- * Query if in kernel mode
- * @return [true | false]
- */
- bool queryKernelMode() const;
+ void* _allocatePage(size_t,bool); //!< see allocatePage()
+ void _freePage(void*, size_t); //!< see freePage()
+ void _coalesce( void ); //!< see coalesce()
/** see queryAvail() */
ALWAYS_INLINE uint64_t _queryAvail() const
diff --git a/src/include/kernel/syscalls.H b/src/include/kernel/syscalls.H
index 20cfd4e65..a46fde703 100644
--- a/src/include/kernel/syscalls.H
+++ b/src/include/kernel/syscalls.H
@@ -97,8 +97,8 @@ namespace Systemcalls
/** mm_set_permission() */
MM_SET_PERMISSION,
- /** mm_flush_pages() */
- MM_FLUSH_PAGES,
+ /** mm_alloc_pages() */
+ MM_ALLOC_PAGES,
SYSCALL_MAX
};
diff --git a/src/include/sys/mm.h b/src/include/sys/mm.h
index 105b145be..d9b5536a1 100644
--- a/src/include/sys/mm.h
+++ b/src/include/sys/mm.h
@@ -97,12 +97,6 @@ int mm_remove_pages(PAGE_REMOVAL_OPS i_op, void* i_vaddr, uint64_t i_size);
*/
int mm_set_permission(void* va, uint64_t size, uint64_t access_type);
-/** @fn mm_flush_pages()
- * @brief System call to flush pages
- * @param[in] i_sev - [VmmManager::NORMAL | VmmManager::CRITIAL]
- */
-void mm_flush_pages(uint64_t i_sev);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/include/usr/vmmconst.h b/src/include/usr/vmmconst.h
index a43a70a7a..1997b9276 100644
--- a/src/include/usr/vmmconst.h
+++ b/src/include/usr/vmmconst.h
@@ -35,14 +35,21 @@
* Segments
*/
+/** Stacks are all 1TB in size. */
+#define VMM_SEGMENT_SIZE (1 * TERABYTE)
+
+/** Base Segment is at 0 TB */
+#define VMM_VADDR_BASE_SEGMENT (0 * TERABYTE)
+
/** Stack Segment is at 1 TB */
-#define VMM_VADDR_STACK_SEGMENT (1 * TERABYTE)
+#define VMM_VADDR_STACK_SEGMENT (VMM_VADDR_BASE_SEGMENT + VMM_SEGMENT_SIZE)
/** Device Segments are at 2 TB - 10 TB */
-#define VMM_VADDR_DEVICE_SEGMENT_FIRST (2 * TERABYTE)
-#define VMM_VADDR_DEVICE_SEGMENT_LAST (VMM_VADDR_DEVICE_SEGMENT_FIRST + \
- (8 * TERABYTE))
+#define VMM_VADDR_DEVICE_SEGMENT_FIRST \
+ (VMM_VADDR_STACK_SEGMENT + VMM_SEGMENT_SIZE)
+#define VMM_VADDR_DEVICE_SEGMENT_LAST \
+ (VMM_VADDR_DEVICE_SEGMENT_FIRST + (8 * VMM_SEGMENT_SIZE))
/**
* Resource Providers
OpenPOWER on IntegriCloud