From 5094b79a31dab58790f0a2f257dccdd556b9f501 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 16 Jul 2013 14:17:02 +0200 Subject: [PATCH] pistachio: return kip structure from get_kip to avoid lot of unnecessary casts afterwards Issue #798 --- base-pistachio/include/pistachio/kip.h | 6 +++--- base-pistachio/src/base/kip/kip.cc | 6 +++--- base-pistachio/src/core/io_mem_session_support.cc | 2 +- base-pistachio/src/core/platform.cc | 6 ++++-- base-pistachio/src/core/platform_pd.cc | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/base-pistachio/include/pistachio/kip.h b/base-pistachio/include/pistachio/kip.h index 7837b0008..c0518e652 100644 --- a/base-pistachio/include/pistachio/kip.h +++ b/base-pistachio/include/pistachio/kip.h @@ -21,7 +21,7 @@ namespace Pistachio { /** * Return a pointer to the kernel info page */ - void *get_kip(); + L4_KernelInterfacePage_t *get_kip(); unsigned int get_page_size_log2(); @@ -35,12 +35,12 @@ namespace Pistachio { inline L4_ThreadId_t get_sigma0() { /* from l4/sigma0.h */ - return L4_GlobalId (((L4_KernelInterfacePage_t *)get_kip())->ThreadInfo.X.UserBase, 1); + return L4_GlobalId (get_kip()->ThreadInfo.X.UserBase, 1); } inline unsigned int get_user_base() { - return ((L4_KernelInterfacePage_t *)get_kip())->ThreadInfo.X.UserBase; + return get_kip()->ThreadInfo.X.UserBase; } inline unsigned int get_threadno_bits() diff --git a/base-pistachio/src/base/kip/kip.cc b/base-pistachio/src/base/kip/kip.cc index ca565c022..04c4db794 100644 --- a/base-pistachio/src/base/kip/kip.cc +++ b/base-pistachio/src/base/kip/kip.cc @@ -18,12 +18,12 @@ using namespace Pistachio; #include -void *Pistachio::get_kip() +L4_KernelInterfacePage_t *Pistachio::get_kip() { - static void *kip = 0; + static L4_KernelInterfacePage_t *kip = 0; if (kip == 0) - kip = L4_KernelInterface(); + kip = reinterpret_cast(L4_KernelInterface()); return kip; } diff --git a/base-pistachio/src/core/io_mem_session_support.cc b/base-pistachio/src/core/io_mem_session_support.cc index e49a872f2..3e3fa857c 100644 --- a/base-pistachio/src/core/io_mem_session_support.cc +++ b/base-pistachio/src/core/io_mem_session_support.cc @@ -37,7 +37,7 @@ static const bool verbose = false; bool is_conventional_memory(addr_t base) { using namespace Pistachio; - void *kip = get_kip(); + L4_KernelInterfacePage_t *kip = get_kip(); /* I miss useful programming languages... */ for (L4_Word_t i = 0; i < L4_NumMemoryDescriptors(kip); i++) { diff --git a/base-pistachio/src/core/platform.cc b/base-pistachio/src/core/platform.cc index 96a05a76f..d98015d13 100644 --- a/base-pistachio/src/core/platform.cc +++ b/base-pistachio/src/core/platform.cc @@ -356,6 +356,8 @@ bool sigma0_req_region(addr_t *addr, unsigned log2size) void Platform::_setup_mem_alloc() { + Pistachio::L4_KernelInterfacePage_t *kip = Pistachio::get_kip(); + /* * Completely map program image by touching all pages read-only to * prevent sigma0 from handing out those page as anonymous memory. @@ -365,7 +367,7 @@ void Platform::_setup_mem_alloc() end = (const char *)&_prog_img_end; for ( ; beg < end; beg += get_page_size()) (void)(*beg); - Pistachio::L4_Word_t page_size_mask = Pistachio::L4_PageSizeMask(Pistachio::get_kip()); + Pistachio::L4_Word_t page_size_mask = Pistachio::L4_PageSizeMask(kip); unsigned int size_log2; /* @@ -449,7 +451,7 @@ void Platform::_setup_basics() L4_Sigma0_GetPage(get_sigma0(), L4_Fpage(beg, get_page_size())); /* store mapping base from received mapping */ - L4_KernelInterfacePage_t *kip = (L4_KernelInterfacePage_t *)get_kip(); + L4_KernelInterfacePage_t *kip = get_kip(); if (kip->magic != L4_MAGIC) panic("we got something but not the KIP"); diff --git a/base-pistachio/src/core/platform_pd.cc b/base-pistachio/src/core/platform_pd.cc index 4f65b0ca6..3b22ab8d3 100644 --- a/base-pistachio/src/core/platform_pd.cc +++ b/base-pistachio/src/core/platform_pd.cc @@ -233,10 +233,10 @@ void Platform_pd::touch_utcb_space() { L4_Word_t utcb_ptr; - void *kip = get_kip(); + L4_KernelInterfacePage_t *kip = get_kip(); L4_ThreadId_t mylocalid = L4_MyLocalId(); utcb_ptr = *(L4_Word_t *) &mylocalid; - utcb_ptr &= ~(L4_UtcbAreaSize (get_kip()) - 1); + utcb_ptr &= ~(L4_UtcbAreaSize (kip) - 1); /* store a pointer to core's utcb area */ _core_utcb_ptr = utcb_ptr;