diff options
author | Dan Crowell <dcrowell@us.ibm.com> | 2011-09-12 10:22:02 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2011-09-14 13:28:46 -0500 |
commit | dbc9dc228c879efbd86df3d655990c21df8d9a8f (patch) | |
tree | d756babb6c4a876906718a214c969e31c03d1e9a /src | |
parent | b06c8727c809ec10aafe8fad0b929626f9d50987 (diff) | |
download | talos-hostboot-dbc9dc228c879efbd86df3d655990c21df8d9a8f.tar.gz talos-hostboot-dbc9dc228c879efbd86df3d655990c21df8d9a8f.zip |
Centralizing a few of the memory-related constants to avoid some
redundancies and also to have a single place to update the memory
map if needed.
See Task 3507.
Change-Id: I8f2d632983abe6d6798784e975cd93057018594b
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/330
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/kernel/devicesegment.H | 3 | ||||
-rw-r--r-- | src/include/kernel/ptmgr.H | 3 | ||||
-rw-r--r-- | src/include/kernel/segmentmgr.H | 3 | ||||
-rw-r--r-- | src/include/kernel/stacksegment.H | 10 | ||||
-rw-r--r-- | src/include/kernel/vmmmgr.H | 6 | ||||
-rw-r--r-- | src/include/limits.h | 7 | ||||
-rw-r--r-- | src/include/sys/mmio.h | 3 | ||||
-rw-r--r-- | src/include/usr/vmmconst.h | 70 | ||||
-rw-r--r-- | src/kernel/basesegment.C | 5 | ||||
-rw-r--r-- | src/kernel/devicesegment.C | 2 | ||||
-rw-r--r-- | src/kernel/heapmgr.C | 2 | ||||
-rw-r--r-- | src/kernel/segmentmgr.C | 3 | ||||
-rw-r--r-- | src/kernel/stacksegment.C | 11 | ||||
-rw-r--r-- | src/usr/pnor/pnorrp.H | 6 |
14 files changed, 97 insertions, 37 deletions
diff --git a/src/include/kernel/devicesegment.H b/src/include/kernel/devicesegment.H index e3e2d9723..89180b4eb 100644 --- a/src/include/kernel/devicesegment.H +++ b/src/include/kernel/devicesegment.H @@ -25,6 +25,7 @@ #include <kernel/segment.H> #include <sys/mmio.h> +#include <usr/vmmconst.h> /** * @class DeviceSegment @@ -36,7 +37,7 @@ class DeviceSegment : public Segment /** * @brief Constructor (Device segment at 2TB) */ - DeviceSegment() : Segment(0x020000000000ull) {}; + DeviceSegment() : Segment(VMM_VADDR_DEVICE_SEGMENT) {}; /** * @brief Destructor diff --git a/src/include/kernel/ptmgr.H b/src/include/kernel/ptmgr.H index c7505bc1f..8eca3f213 100644 --- a/src/include/kernel/ptmgr.H +++ b/src/include/kernel/ptmgr.H @@ -231,9 +231,6 @@ class PageTableManager PTE_ACCESS_BITS = 0x800000000000007B, /**< pp0 + WIMG + pp1_2 */ PTEG_SIZE_BYTES = (sizeof(PageTableEntry)*8), /**< Size of PTE Group in bytes */ - SLBE_b = 12, /**< Page Size in bits per SLBE */ - SLBE_s = 40, /**< Segment Size in bits per SLBE */ - }; /** diff --git a/src/include/kernel/segmentmgr.H b/src/include/kernel/segmentmgr.H index 563497047..a8f4e002d 100644 --- a/src/include/kernel/segmentmgr.H +++ b/src/include/kernel/segmentmgr.H @@ -30,6 +30,7 @@ #include <kernel/task.H> #include <builtins.h> #include <kernel/ptmgr.H> +#include <usr/vmmconst.h> // Forward declaration. class Segment; @@ -135,7 +136,7 @@ class SegmentManager ALWAYS_INLINE inline size_t getSegmentIdFromAddress(uint64_t i_addr) const { - return i_addr >> 40; // SLBE_s = 40 Should come from page manager? + return i_addr >> SLBE_s; } /** Array of segment objects to associated segment IDs. */ diff --git a/src/include/kernel/stacksegment.H b/src/include/kernel/stacksegment.H index 8b60ec3c7..ec76c194e 100644 --- a/src/include/kernel/stacksegment.H +++ b/src/include/kernel/stacksegment.H @@ -30,6 +30,7 @@ #include <kernel/types.h> #include <kernel/segment.H> #include <util/locked/list.H> +#include <usr/vmmconst.h> // Forward declaration. class Block; @@ -60,18 +61,11 @@ struct StackBlockNode class StackSegment : public Segment { protected: - enum - { - EIGHT_MEGABYTE = 8 * 1024 * 1024ul, - ONE_TERABYTE = 1024 * 1024 * 1024 * 1024ul, - }; - - /** * @brief Constructor. * Initialize attributes and set base addresss of segment to 1 TB. */ - StackSegment() : Segment(ONE_TERABYTE) {}; + StackSegment() : Segment(VMM_VADDR_STACK_SEGMENT) {}; /** * @brief Destructor diff --git a/src/include/kernel/vmmmgr.H b/src/include/kernel/vmmmgr.H index ff8702f53..2d0d0297d 100644 --- a/src/include/kernel/vmmmgr.H +++ b/src/include/kernel/vmmmgr.H @@ -39,11 +39,7 @@ class VmmManager */ enum VMM_CONSTS { - ONE_MEG = 1 * 1024 * 1024, - FOUR_MEG = 4 * ONE_MEG, - EIGHT_MEG = 8 * ONE_MEG, - - FULL_MEM_SIZE = FOUR_MEG, + FULL_MEM_SIZE = 4*MEGABYTE, // put the Page Table at the end of our memory space PTSIZE = (1 << 18), diff --git a/src/include/limits.h b/src/include/limits.h index 6bfbf1751..3a5227d03 100644 --- a/src/include/limits.h +++ b/src/include/limits.h @@ -23,7 +23,12 @@ #ifndef __LIMITS_H #define __LIMITS_H -#define PAGESIZE 4096 +#define KILOBYTE (1024ul) /**< 1 KB */ +#define MEGABYTE (1024 * 1024ul) /**< 1 MB */ +#define GIGABYTE (MEGABYTE * 1024ul) /**< 1 GB */ +#define TERABYTE (GIGABYTE * 1024ul) /**< 1 TB */ + +#define PAGESIZE (4*KILOBYTE) /**< 4 KB */ #define PAGE_SIZE PAGESIZE #endif diff --git a/src/include/sys/mmio.h b/src/include/sys/mmio.h index 148ceda30..59254b976 100644 --- a/src/include/sys/mmio.h +++ b/src/include/sys/mmio.h @@ -25,6 +25,7 @@ #include <stdint.h> #include <sys/sync.h> +#include <limits.h> #ifdef __cplusplus extern "C" @@ -37,7 +38,7 @@ extern "C" */ enum SEG_DATA_SIZES { - THIRTYTWO_GB = 0x800000000, + THIRTYTWO_GB = (32*GIGABYTE), }; /** diff --git a/src/include/usr/vmmconst.h b/src/include/usr/vmmconst.h new file mode 100644 index 000000000..984bef1db --- /dev/null +++ b/src/include/usr/vmmconst.h @@ -0,0 +1,70 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/vmmconst.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 +#ifndef _VMMCONST_H +#define _VMMCONST_H + +/** + * This file contains any hardcoded memory addresses used by the + * Virtual Memory Subsystem + */ + +#include <limits.h> + +/** + * Segments + */ + +/** Stack Segment is at 1 TB */ +#define VMM_VADDR_STACK_SEGMENT (1 * TERABYTE) + +/** Device Segment is at 2 TB */ +#define VMM_VADDR_DEVICE_SEGMENT (2 * TERABYTE) + + +/** + * Resource Providers + */ + +/** Extended Image is at 1GB */ +#define VMM_VADDR_VFS_EXT_MODULE (1 * GIGABYTE) +// Note : vfs.h hardcodes this value due to external compile issues + +/** PNOR Resource Provider is at 2GB */ +#define VMM_VADDR_PNOR_RP (2 * GIGABYTE) + +/** Attribute Resource Provider */ +//TBD + + +/** + * Other Constants + */ + +/** Segment Size in bits per SLBE */ +#define SLBE_s 40 + +/** Page Size in bits per SLBE */ +#define SLBE_b 12 + + +#endif /* _VMMCONST_H */ diff --git a/src/kernel/basesegment.C b/src/kernel/basesegment.C index 2c5b73c19..fc053f856 100644 --- a/src/kernel/basesegment.C +++ b/src/kernel/basesegment.C @@ -31,7 +31,6 @@ #include <kernel/vmmmgr.H> #include <kernel/cpuid.H> -#define SLBE_s 40 BaseSegment::~BaseSegment() { @@ -54,12 +53,12 @@ void BaseSegment::_init() case CORE_POWER7: case CORE_POWER7_PLUS: case CORE_POWER8_VENICE: - iv_physMemSize = VmmManager::EIGHT_MEG; + iv_physMemSize = (8*MEGABYTE); break; case CORE_POWER8_SALERNO: default: - iv_physMemSize = VmmManager::FOUR_MEG; + iv_physMemSize = (4*MEGABYTE); break; } // Base block is L3 cache physical memory size diff --git a/src/kernel/devicesegment.C b/src/kernel/devicesegment.C index f158ab3ec..4af3a75bb 100644 --- a/src/kernel/devicesegment.C +++ b/src/kernel/devicesegment.C @@ -28,8 +28,6 @@ #include <kernel/devicesegment.H> #include <kernel/segmentmgr.H> -#define SLBE_s 40 - #include <kernel/console.H> /** diff --git a/src/kernel/heapmgr.C b/src/kernel/heapmgr.C index 5eddccc3d..7d3757b9f 100644 --- a/src/kernel/heapmgr.C +++ b/src/kernel/heapmgr.C @@ -102,7 +102,7 @@ void HeapManager::newPage() { void* page = PageManager::allocatePage(); chunk_t * c = (chunk_t*)page; - for (int i = 0; i < (PAGESIZE / (1 << (BUCKETS + 3))); i++) + for (uint64_t i = 0; i < (PAGESIZE / (1 << (BUCKETS + 3))); i++) { c->len = BUCKETS-1; push_bucket(c, BUCKETS-1); diff --git a/src/kernel/segmentmgr.C b/src/kernel/segmentmgr.C index c52b4de04..890bd1812 100644 --- a/src/kernel/segmentmgr.C +++ b/src/kernel/segmentmgr.C @@ -121,9 +121,6 @@ uint64_t SegmentManager::_findPhysicalAddress(uint64_t i_vaddr) const void SegmentManager::_updateRefCount( uint64_t i_vaddr, PageTableManager::UsageStats_t i_stats ) { - // This constant should come from page manager. Segment size. - const size_t SLBE_s = 40; - // Get segment ID from effective address. size_t segId = i_vaddr >> SLBE_s; diff --git a/src/kernel/stacksegment.C b/src/kernel/stacksegment.C index 91b16e6a9..592d4dec7 100644 --- a/src/kernel/stacksegment.C +++ b/src/kernel/stacksegment.C @@ -28,6 +28,7 @@ #include <kernel/segmentmgr.H> #include <kernel/block.H> #include <errno.h> +#include <usr/vmmconst.h> void StackSegment::init() { @@ -62,7 +63,7 @@ StackSegment::~StackSegment() bool StackSegment::handlePageFault(task_t* i_task, uint64_t i_addr) { - uint64_t l_addr_8mb = i_addr & ~((EIGHT_MEGABYTE) - 1); + uint64_t l_addr_8mb = i_addr & ~((8*MEGABYTE) - 1); StackBlockNode* l_node = iv_blockList.find(l_addr_8mb); @@ -73,7 +74,7 @@ bool StackSegment::handlePageFault(task_t* i_task, uint64_t i_addr) uint64_t StackSegment::findPhysicalAddress(uint64_t i_vaddr) const { - uint64_t l_addr_8mb = i_vaddr & ~((EIGHT_MEGABYTE) - 1); + uint64_t l_addr_8mb = i_vaddr & ~((8*MEGABYTE) - 1); StackBlockNode* l_node = iv_blockList.find(l_addr_8mb); @@ -91,7 +92,7 @@ void StackSegment::_init() void* StackSegment::_createStack(tid_t i_task) { /* The segment is broken out into 8MB blocks so we need to place the - * stack somewhere within an 8MB range. The constrants are ensuring + * stack somewhere within an 8MB range. The constraints are ensuring * we have adequate protection and that the hashed page table does not * have a large number of collisions. If we were to place all of the * stacks at (8MB - 64k) there would be a large amount of contention on @@ -117,7 +118,7 @@ void* StackSegment::_createStack(tid_t i_task) * space). */ - uint64_t l_addr_8mb = i_task * EIGHT_MEGABYTE + ONE_TERABYTE; + uint64_t l_addr_8mb = i_task * (8*MEGABYTE) + VMM_VADDR_STACK_SEGMENT; // Ensure block doesn't already exist. kassert(NULL == iv_blockList.find(l_addr_8mb)); @@ -149,7 +150,7 @@ void* StackSegment::_createStack(tid_t i_task) void StackSegment::_deleteStack(tid_t i_task) { - uint64_t l_addr_8mb = i_task * EIGHT_MEGABYTE + ONE_TERABYTE; + uint64_t l_addr_8mb = i_task * (8*MEGABYTE) + VMM_VADDR_STACK_SEGMENT; StackBlockNode* l_node = iv_blockList.find(l_addr_8mb); kassert(NULL != l_node); diff --git a/src/usr/pnor/pnorrp.H b/src/usr/pnor/pnorrp.H index b17509ad2..79d2728a2 100644 --- a/src/usr/pnor/pnorrp.H +++ b/src/usr/pnor/pnorrp.H @@ -28,7 +28,7 @@ #include <stdint.h> #include <builtins.h> #include <errl/errlentry.H> -#include <limits.h> +#include <vmmconst.h> #include "pnordd.H" /** @@ -76,11 +76,11 @@ class PnorRP */ enum { - BASE_VADDR = 2*1024*1024*1024ul, /**< 2GB = 0x80000000*/ + BASE_VADDR = VMM_VADDR_PNOR_RP, /**< 2GB = 0x80000000*/ NUM_SIDES = 3, /**< A, B, Sideless */ - SIDE_SIZE = 32*1024*1024ul, /**< Allocate 32 MB (0x2000000) of VA per side */ + SIDE_SIZE = 32*MEGABYTE, /**< Allocate 32 MB (0x2000000) of VA per side */ SIDEA_VADDR = BASE_VADDR, /**< Base address of Side A */ SIDEB_VADDR = SIDEA_VADDR + SIDE_SIZE, /**< Base address of Side B */ |