/*1* This program is free software; you can redistribute it and/or modify2* it under the terms of the GNU General Public License as published by3* the Free Software Foundation; either version 2 of the License, or4* (at your option) any later version.5*6* This program is distributed in the hope that it will be useful,7* but WITHOUT ANY WARRANTY; without even the implied warranty of8* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9* GNU General Public License for more details.10*11* You should have received a copy of the GNU General Public License12* along with this program; if not, write to the Free Software13* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA14*15* Copyright (C) IBM Corp. 200616*17* Authors: Hollis Blanchard <[email protected]>18* Jerone Young <[email protected]>19*/2021#ifndef _LINUX_XENCOMM_H_22#define _LINUX_XENCOMM_H_2324#include <xen/interface/xencomm.h>2526#define XENCOMM_MINI_ADDRS 327struct xencomm_mini {28struct xencomm_desc _desc;29uint64_t address[XENCOMM_MINI_ADDRS];30};3132/* To avoid additionnal virt to phys conversion, an opaque structure is33presented. */34struct xencomm_handle;3536extern void xencomm_free(struct xencomm_handle *desc);37extern struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes);38extern struct xencomm_handle *__xencomm_map_no_alloc(void *ptr,39unsigned long bytes, struct xencomm_mini *xc_area);4041#if 042#define XENCOMM_MINI_ALIGNED(xc_desc, n) \43struct xencomm_mini xc_desc ## _base[(n)] \44__attribute__((__aligned__(sizeof(struct xencomm_mini)))); \45struct xencomm_mini *xc_desc = &xc_desc ## _base[0];46#else47/*48* gcc bug workaround:49* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1666050* gcc doesn't handle properly stack variable with51* __attribute__((__align__(sizeof(struct xencomm_mini))))52*/53#define XENCOMM_MINI_ALIGNED(xc_desc, n) \54unsigned char xc_desc ## _base[((n) + 1 ) * \55sizeof(struct xencomm_mini)]; \56struct xencomm_mini *xc_desc = (struct xencomm_mini *) \57((unsigned long)xc_desc ## _base + \58(sizeof(struct xencomm_mini) - \59((unsigned long)xc_desc ## _base) % \60sizeof(struct xencomm_mini)));61#endif62#define xencomm_map_no_alloc(ptr, bytes) \63({ XENCOMM_MINI_ALIGNED(xc_desc, 1); \64__xencomm_map_no_alloc(ptr, bytes, xc_desc); })6566/* provided by architecture code: */67extern unsigned long xencomm_vtop(unsigned long vaddr);6869static inline void *xencomm_pa(void *ptr)70{71return (void *)xencomm_vtop((unsigned long)ptr);72}7374#define xen_guest_handle(hnd) ((hnd).p)7576#endif /* _LINUX_XENCOMM_H_ */777879