dde_ipxe: Properly wrap iPXE interfaces to C++
As iPXE header files are not C++ compatible, the implementation missed proper include directives. For example, alloc_memblock() had a wrong signature, which was not detected. Now, C wrapper functions are implemented using a local API to the C++ backend. Related to #593.
This commit is contained in:
parent
d90b0464b8
commit
f9cb8a9ac3
|
@ -27,9 +27,21 @@
|
||||||
#include <ipxe/pci.h>
|
#include <ipxe/pci.h>
|
||||||
#include <ipxe/settings.h>
|
#include <ipxe/settings.h>
|
||||||
#include <ipxe/netdevice.h>
|
#include <ipxe/netdevice.h>
|
||||||
|
#include <ipxe/timer2.h>
|
||||||
|
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************
|
||||||
|
** Wrapper to DDE support in C++ **
|
||||||
|
***********************************/
|
||||||
|
|
||||||
|
#include "dde_support.h"
|
||||||
|
|
||||||
|
void *alloc_memblock(size_t size, size_t align, size_t offset) { return dde_alloc_memblock(size, align, offset); }
|
||||||
|
void free_memblock(void *p, size_t size) { dde_free_memblock(p, size); }
|
||||||
|
void timer2_udelay(unsigned long usecs) { dde_timer2_udelay(usecs); }
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
** Memory pool in DDE kit slabs **
|
** Memory pool in DDE kit slabs **
|
||||||
**********************************/
|
**********************************/
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <dde_kit/pgtab.h>
|
#include <dde_kit/pgtab.h>
|
||||||
|
#include "dde_support.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
@ -56,18 +57,19 @@ void __attribute__((constructor)) init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void *alloc_memblock(size_t size, size_t align)
|
extern "C" void *dde_alloc_memblock(dde_kit_size_t size, dde_kit_size_t align, dde_kit_size_t offset)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
if (allocator()->alloc_aligned(size, &ptr, log2(align)).is_error()) {
|
if (allocator()->alloc_aligned(size, &ptr, log2(align)).is_error()) {
|
||||||
PERR("memory allocation failed in alloc_memblock");
|
PERR("memory allocation failed in alloc_memblock (size=%zd, align=%zx, offset=%zx)",
|
||||||
|
size, align, offset);
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void free_memblock(void *p, size_t size)
|
extern "C" void dde_free_memblock(void *p, dde_kit_size_t size)
|
||||||
{
|
{
|
||||||
allocator()->free(p, size);
|
allocator()->free(p, size);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,7 @@ extern "C" void free_memblock(void *p, size_t size)
|
||||||
** Timer **
|
** Timer **
|
||||||
***********/
|
***********/
|
||||||
|
|
||||||
extern "C" void timer2_udelay(unsigned long usecs)
|
extern "C" void dde_timer2_udelay(unsigned long usecs)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This function is called only once during rdtsc calibration (usecs will be
|
* This function is called only once during rdtsc calibration (usecs will be
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* \brief DDE iPXE wrappers to C++ backend
|
||||||
|
* \author Christian Helmuth
|
||||||
|
* \date 2013-01-07
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2010-2013 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DDE_SUPPORT_H_
|
||||||
|
#define _DDE_SUPPORT_H_
|
||||||
|
|
||||||
|
#include <dde_kit/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
void *dde_alloc_memblock(dde_kit_size_t size, dde_kit_size_t align, dde_kit_size_t offset);
|
||||||
|
void dde_free_memblock(void *p, dde_kit_size_t size);
|
||||||
|
void dde_timer2_udelay(unsigned long usecs);
|
||||||
|
|
||||||
|
#endif /* _DDE_SUPPORT_H_ */
|
Loading…
Reference in New Issue