diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2011-07-22 09:38:14 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2011-08-08 14:21:57 -0500 |
commit | 6a8d93daac2c006c06aa1d0d9e963e651b9c64b2 (patch) | |
tree | fb7eeb89d0b7b80e64334896973649aab90a2d83 /src/include | |
parent | 0709fbac11be8a30710a34dad5af5f37449d7255 (diff) | |
download | talos-hostboot-6a8d93daac2c006c06aa1d0d9e963e651b9c64b2.tar.gz talos-hostboot-6a8d93daac2c006c06aa1d0d9e963e651b9c64b2.zip |
Device segment MMIO map & unmap system calls
Change-Id: I233c2677909c0c16536133c189ebbd21e4415e22
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/208
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/kernel/devicesegment.H | 100 | ||||
-rw-r--r-- | src/include/kernel/segmentmgr.H | 14 | ||||
-rw-r--r-- | src/include/kernel/syscalls.H | 10 | ||||
-rw-r--r-- | src/include/kernel/vmmmgr.H | 18 | ||||
-rw-r--r-- | src/include/sys/mmio.h | 44 |
5 files changed, 149 insertions, 37 deletions
diff --git a/src/include/kernel/devicesegment.H b/src/include/kernel/devicesegment.H index 5fc63819b..fab284165 100644 --- a/src/include/kernel/devicesegment.H +++ b/src/include/kernel/devicesegment.H @@ -2,32 +2,114 @@ #define __KERNEL_DEVICESEGMENT_H #include <kernel/segment.H> +#include <sys/mmio.h> +/** + * @class DeviceSegment + * @brief Manages the device virtual memory segment + */ class DeviceSegment : public Segment { public: - DeviceSegment() : Segment(0x020000000000ull) - { - for (int i = 0; i < MMIO_MAP_DEVICES; i++) - iv_mmioMap[i] = 0; - }; + /** + * @brief Constructor (Device segment at 2TB) + */ + DeviceSegment() : Segment(0x020000000000ull) {}; + + /** + * @brief Destructor + */ ~DeviceSegment() {}; + /** + * @brief Add the device segment + */ static void init(); + /** + * @brief Handle a page fault for a device address access + * @param i_task[in] - Task pointer to the task requiring the page + * @param i_addr[in] - 64-bit address needed to be paged + * @return bool - true: Page added to page table + * false: Not a valid address to be paged + */ bool handlePageFault(task_t* i_task, uint64_t i_addr); - static void* mmioMap(void* ra, size_t pages); // to be deprecated. - static int mmioUnmap(void* ea, size_t pages); // to be deprecated. + /** + * @brief DEPRECATED + */ + static void* mmioMap(void* ra, size_t pages); + + /** + * @brief DEPRECATED + */ + static int mmioUnmap(void* ea, size_t pages); + + /** + * @brief Map a device into the device segment(2TB) + * @param ra[in] - Void pointer to real address to be mapped in + * @param i_devDataSize[in] - Size of device segment block + * @return void* - Pointer to beginning virtual address, NULL otherwise + */ + static void* devMap(void* ra, SEG_DATA_SIZES i_devDataSize); + + /** + * @brief Unmap a device from the device segment(2TB) + * @param ea[in] - Void pointer to effective address + * @return int - 0 for successful unmap, non-zero otherwise + */ + static int devUnmap(void* ea); private: - enum { MMIO_MAP_DEVICES = 32 }; - uint64_t iv_mmioMap[MMIO_MAP_DEVICES]; + /** + * Attributes to represent a mapped device within a segment block + */ + struct devSegData + { + uint64_t addr; /* Real address assigned to device */ + SEG_DATA_SIZES size; /* A particular device's segment block size */ + devSegData(): addr(0),size(THIRTYTWO_GB){}; + }; + + /** + * Number of devices that can be mapped with a given segment block size + */ + enum + { + MMIO_MAP_DEVICES = 32 + }; //TODO - Only necessary if a device uses a SCOM region other than 32GB + devSegData iv_mmioMap[MMIO_MAP_DEVICES]; + + /** + * @brief Add the device segment + */ void _init(); + /** + * @brief DEPRECATED + */ void* _mmioMap(void* ra, size_t pages); + + /** + * @brief DEPRECATED + */ int _mmioUnmap(void* ea, size_t pages); + + /** + * @brief Map a device into the device segment(2TB) + * @param ra[in] - Void pointer to real address to be mapped in + * @param i_devDataSize[in] - Size of device segment block + * @return void* - Pointer to beginning virtual address, NULL otherwise + */ + void* _devMap(void* ra, SEG_DATA_SIZES i_devDataSize); + + /** + * @brief Unmap a device from the device segment(2TB) + * @param ea[in] - Void pointer to effective address + * @return int - 0 for successful unmap, non-zero otherwise + */ + int _devUnmap(void* ea); }; #endif diff --git a/src/include/kernel/segmentmgr.H b/src/include/kernel/segmentmgr.H index 7048fa365..a2f36be20 100644 --- a/src/include/kernel/segmentmgr.H +++ b/src/include/kernel/segmentmgr.H @@ -22,11 +22,11 @@ class SegmentManager /** Segment Identifiers */ enum SegmentIds { - /** Base Segment (0-1TB). */ + /** Base Segment (0-1TB). */ BASE_SEGMENT_ID = 0, - /** Task Stack Segment (1-2TB). */ + /** Task Stack Segment (1-2TB). */ STACK_SEGMENT_ID = 1, - /** MMIO Space Segment (2-3TB). */ + /** MMIO Space Segment (2-3TB). */ MMIO_SEGMENT_ID = 2, MAX_SEGMENTS = 4 @@ -78,14 +78,14 @@ class SegmentManager static void initSLB(); private: - /** See handlePageFault. */ + /** See handlePageFault. */ bool _handlePageFault(task_t* i_task, uint64_t i_addr); - /** See addSegment. */ + /** See addSegment. */ void _addSegment(Segment* i_segment, size_t i_segId); - /** See initSLB. */ + /** See initSLB. */ void _initSLB(); - /** Array of segment objects to associated segment IDs. */ + /** Array of segment objects to associated segment IDs. */ Segment* iv_segments[MAX_SEGMENTS]; }; diff --git a/src/include/kernel/syscalls.H b/src/include/kernel/syscalls.H index 5b5e31fc3..a76bb82a9 100644 --- a/src/include/kernel/syscalls.H +++ b/src/include/kernel/syscalls.H @@ -46,18 +46,22 @@ namespace Systemcalls MMIO_MAP, /** mmio_unmap() */ MMIO_UNMAP, + /** dev_map() */ + DEV_MAP, + /** dev_unmap() */ + DEV_UNMAP, /** nanosleep() */ TIME_NANOSLEEP, /** futex_wait() */ - FUTEX_WAIT, + FUTEX_WAIT, /** futex_wake() */ - FUTEX_WAKE, + FUTEX_WAKE, /** shutdown() */ - MISC_SHUTDOWN, + MISC_SHUTDOWN, /** cpu_core_type() */ MISC_CPUCORETYPE, diff --git a/src/include/kernel/vmmmgr.H b/src/include/kernel/vmmmgr.H index f57f01677..fe1c2cc73 100644 --- a/src/include/kernel/vmmmgr.H +++ b/src/include/kernel/vmmmgr.H @@ -2,12 +2,16 @@ #define __KERNEL_VMMMGR_H #include <limits.h> +#include <sys/mmio.h> #include <kernel/types.h> #include <kernel/spinlock.H> class VmmManager { public: + /** + * Constants used throughout the virtual memory management classes + */ enum VMM_CONSTS { ONE_MEG = 1 * 1024 * 1024, @@ -49,6 +53,20 @@ class VmmManager static void* mmioMap(void*, size_t); static int mmioUnmap(void*, size_t); + /** + * @brief Map a device into the device segment(2TB) + * @param ra[in] - Void pointer to real address to be mapped in + * @param i_devDataSize[in] - Size of device segment block + * @return void* - Pointer to beginning virtual address, NULL otherwise + */ + static void* devMap(void* ra, SEG_DATA_SIZES i_devDataSize); + + /** + * @brief Unmap a device from the device segment(2TB) + * @param ea[in] - Void pointer to effective address + * @return int - 0 for successful unmap, non-zero otherwise + */ + static int devUnmap(void* ea); protected: VmmManager(); diff --git a/src/include/sys/mmio.h b/src/include/sys/mmio.h index 35392f22e..37c0a029d 100644 --- a/src/include/sys/mmio.h +++ b/src/include/sys/mmio.h @@ -9,29 +9,37 @@ extern "C" { #endif -/** @fn mmio_map() - * @brief Map a region into virtual address space. - * - * @param[in] ra - address of page - * @param[in] pages - count of pages to map - * - * @returns The virtual address where mapped. +/** + * Sizes used to determine segment block size during map/unmap functions + * within the kernel or user space */ -void* mmio_map(void* ra, size_t pages); - +enum SEG_DATA_SIZES +{ + THIRTYTWO_GB = 0x800000000, +}; -/** @fn mmio_unmap() - * @brief Unmap a region previously mapped into virtual address space. - * - * Appears not to be implemented. See _mmioUnmap in src/kernel/vmmmgr.C - * - * @param[in] ea - virtual address as returned from mmio_map() - * @param[in] pages - count of pages to unmap - * - * @returns -1 from _mmioUnmap in src/kernel/vmmmgr.C +/** + * @brief DEPRECATED + */ +void* mmio_map(void* ra, size_t pages); +/** + * @brief DEPRECATED */ int mmio_unmap(void* ea, size_t pages); +/** + * @brief System call to map a device into the device segment(2TB) + * @param ra[in] - Void pointer to real address to be mapped in + * @param i_devDataSize[in] - Size of device segment block + * @return void* - Pointer to beginning virtual address, NULL otherwise + */ +void* mmio_dev_map(void *ra, SEG_DATA_SIZES i_devDataSize); +/** + * @brief System call to unmap a device from the device segment(2TB) + * @param ea[in] - Void pointer to effective address + * @return int - 0 for successful unmap, non-zero otherwise + */ +int mmio_dev_unmap(void *ea); /** @fn mmio_hmer_read() * @brief Reads and returns protected HMER register. |