Commit d125987a authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan
Browse files

libcap-integration: Simplify types.h header.

Removes cptr and capability crap. Boot info and LCD address
spaces will be moved to separate header(s).
parent 09650d18
/*
* types.h
*
* Common types and macros used throughout the interface and microkernel.
*
* Copyright: University of Utah
*/
#ifndef LCD_DOMAINS_TYPES_H
#define LCD_DOMAINS_TYPES_H
/**
* Return value to signal that a host/non-isolated resource (like a page)
* is not part of the capability system (i.e., is not in any thread's
* cspace).
*/
#define LCD_ERR_NOT_VOLUNTEERED (-512)
/*
* Extra reserved cnodes:
*
* cptr = 1 is the LCD's call endpoint
* cptr = 2 points to an endpoint if the lcd did a receive, and the sender did
* a call (so the lcd can do a reply)
*
* So, if lcd A does a call on endpoint #1 and lcd B does a receive on endpoint
* #1, the endpoint at LCD_CPTR_CALL_ENDPOINT in A's cspace will be granted
* to lcd B in B's cspace at cptr LCD_CPTR_REPLY_ENDPOINT. lcd B can do a reply
* (one time and then it's revoked).
*/
#define LCD_CPTR_CALL_ENDPOINT __cptr(1)
#define LCD_CPTR_REPLY_ENDPOINT __cptr(2)
/* ADDRESS SPACE TYPES ---------------------------------------- */
/* XXX: Assumes host and guest run in 64-bit mode */
typedef struct { unsigned long gva; } gva_t;
typedef struct { unsigned long hva; } hva_t;
typedef struct { unsigned long gpa; } gpa_t;
typedef struct { unsigned long hpa; } hpa_t;
static inline gva_t __gva(unsigned long gva)
{
return (gva_t){ gva };
}
static inline unsigned long gva_val(gva_t gva)
{
return gva.gva;
}
static inline unsigned long * gva_ptr(gva_t * gva)
{
return &(gva->gva);
}
static inline gva_t gva_add(gva_t gva, unsigned long off)
{
return __gva(gva_val(gva) + off);
}
static inline hva_t __hva(unsigned long hva)
{
return (hva_t){ hva };
}
static inline unsigned long hva_val(hva_t hva)
{
return hva.hva;
}
static inline unsigned long * hva_ptr(hva_t * hva)
{
return &(hva->hva);
}
static inline hva_t hva_add(hva_t hva, unsigned long off)
{
return __hva(hva_val(hva) + off);
}
static inline gpa_t __gpa(unsigned long gpa)
{
return (gpa_t){ gpa };
}
static inline unsigned long gpa_val(gpa_t gpa)
{
return gpa.gpa;
}
static inline unsigned long * gpa_ptr(gpa_t * gpa)
{
return &(gpa->gpa);
}
static inline gpa_t gpa_add(gpa_t gpa, unsigned long off)
{
return __gpa(gpa_val(gpa) + off);
}
static inline hpa_t __hpa(unsigned long hpa)
{
return (hpa_t){ hpa };
}
static inline unsigned long hpa_val(hpa_t hpa)
{
return hpa.hpa;
}
static inline unsigned long * hpa_ptr(hpa_t * hpa)
{
return &(hpa->hpa);
}
static inline hpa_t hpa_add(hpa_t hpa, unsigned long off)
{
return __hpa(hpa_val(hpa) + off);
}
#endif /* LCD_DOMAINS_TYPES_H */
......@@ -65,6 +65,43 @@ static inline void __lcd_debug(char *file, int lineno, char *fmt, ...)
va_end(args);
}
/* --------------------------------------------------
* INTERNAL ADDRESS CONVERSIONS
* --------------------------------------------------
*
* This used to be in the types.h header, but it only
* makes sense for internal microkernel calculations.
*/
static inline hpa_t pa2hpa(unsigned long pa)
{
return (hpa_t){ pa };
}
static inline hpa_t va2hpa(void *va)
{
return (hpa_t){ __pa(va) };
}
static inline void * hpa2va(hpa_t hpa)
{
return __va(hpa_val(hpa));
}
static inline hva_t hpa2hva(hpa_t hpa)
{
return (hva_t){ (unsigned long)__va(hpa.hpa) };
}
static inline void * hva2va(hva_t hva)
{
return (void *)hva_val(hva);
}
static inline hva_t va2hva(void *va)
{
return __hva((unsigned long)va);
}
static inline hpa_t hva2hpa(hva_t hva)
{
return (hpa_t){ (unsigned long)__pa(hva2va(hva)) };
}
/* --------------------------------------------------
* LCD MICROKERNEL CAPABILITY TYPES
* --------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment