Add macros VNET_SETNAME and VNET_SYMPREFIX, and expose to userspace if

_WANT_VNET is defined.  This way we don't need separate definitions in
libkvm.

Reviewed by:	bz
Approved by:	re (vimage blanket)
This commit is contained in:
rwatson 2009-07-20 07:50:50 +00:00
parent 82903c08b7
commit fb3be5ae64
2 changed files with 14 additions and 7 deletions

View File

@ -350,7 +350,7 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
ef->progtab[pb].addr = dpcpu;
#ifdef VIMAGE
} else if (ef->progtab[pb].name != NULL &&
!strcmp(ef->progtab[pb].name, "set_vnet")) {
!strcmp(ef->progtab[pb].name, VNET_SETNAME)) {
void *vnet_data;
vnet_data = vnet_data_alloc(shdr[i].sh_size);
@ -756,7 +756,7 @@ link_elf_load_file(linker_class_t cls, const char *filename,
dpcpu_alloc(shdr[i].sh_size);
#ifdef VIMAGE
else if (ef->progtab[pb].name != NULL &&
!strcmp(ef->progtab[pb].name, "set_vnet"))
!strcmp(ef->progtab[pb].name, VNET_SETNAME))
ef->progtab[pb].addr =
vnet_data_alloc(shdr[i].sh_size);
#endif
@ -789,7 +789,7 @@ link_elf_load_file(linker_class_t cls, const char *filename,
#ifdef VIMAGE
else if (ef->progtab[pb].addr !=
(void *)mapbase &&
!strcmp(ef->progtab[pb].name, "set_vnet"))
!strcmp(ef->progtab[pb].name, VNET_SETNAME))
vnet_data_copy(ef->progtab[pb].addr,
shdr[i].sh_size);
#endif
@ -909,7 +909,7 @@ link_elf_unload_file(linker_file_t file)
dpcpu_free(ef->progtab[i].addr,
ef->progtab[i].size);
#ifdef VIMAGE
else if (!strcmp(ef->progtab[i].name, "set_vnet"))
else if (!strcmp(ef->progtab[i].name, VNET_SETNAME))
vnet_data_free(ef->progtab[i].addr,
ef->progtab[i].size);
#endif

View File

@ -37,19 +37,26 @@
#ifndef _NET_VNET_H_
#define _NET_VNET_H_
#if defined(_KERNEL) || defined(_WANT_VNET)
#define VNET_SETNAME "set_vnet"
#define VNET_SYMPREFIX "vnet_entry_"
#endif
#ifdef _KERNEL
#ifdef VIMAGE
#if defined(__arm__)
__asm__(".section set_vnet, \"aw\", %progbits");
__asm__(".section " VNET_SETNAME ", \"aw\", %progbits");
#else
__asm__(".section set_vnet, \"aw\", @progbits");
__asm__(".section " VNET_SETNAME ", \"aw\", @progbits");
#endif
__asm__(".previous");
#define VNET_NAME(n) vnet_entry_##n
#define VNET_DECLARE(t, n) extern t VNET_NAME(n)
#define VNET_DEFINE(t, n) t VNET_NAME(n) __section("set_vnet") __used
#define VNET_DEFINE(t, n) t VNET_NAME(n) __section(VNET_SETNAME) __used
#define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \
((b) + (uintptr_t)&VNET_NAME(n))