pistachio: return kip structure from get_kip

to avoid lot of unnecessary casts afterwards

Issue #798
This commit is contained in:
Alexander Boettcher 2013-07-16 14:17:02 +02:00 committed by Christian Helmuth
parent 505f4290ec
commit 5094b79a31
5 changed files with 13 additions and 11 deletions

View File

@ -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()

View File

@ -18,12 +18,12 @@ using namespace Pistachio;
#include <l4/kip.h>
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_KernelInterfacePage_t *>(L4_KernelInterface());
return kip;
}

View File

@ -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++) {

View File

@ -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");

View File

@ -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;