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

libcap-integration: Finish liblcd v2 headers for now.

  -- cap.h: delete, revoke; you may wonder: why do we need this
            if we have libcap? Answer: an LCD needs to have a way
            to modify *it's own* cspace, rather than cspaces it
            manages
  -- console.h: lcd_printk and friends, moved into new file with
                few changes
  -- enter_exit.h: lcd_enter, exit, etc., moved into new file with
                   few changes
parent 7dadddf3
......@@ -41,4 +41,14 @@ struct lcd_boot_info {
cptr_t cptrs[LCD_NUM_BOOT_CPTRS];
};
/**
* lcd_get_boot_info -- Return the bootstrap info
*
* When executing inside an LCD, invoke this function, and it will
* return a pointer to the LCD's bootstrap data.
*
* For non-isolated code, this function returns NULL.
*/
struct lcd_boot_info * lcd_get_boot_info(void);
#endif /* LCD_DOMAINS_BOOTINFO_H */
/*
* cap.h
*
* Operations an LCD can invoke on its own cspace.
*
* Why do we have this header if we have libcap? Because an LCD
* cannot do e.g. cap_insert on its own cspace. It does operations
* on its own cspace via hypercalls out into the microkernel. Similar
* for kLCDs. That's what these functions are for.
*
* Copyright: University of Utah
*/
#ifndef LCD_DOMAINS_CAP_H
#define LCD_DOMAINS_CAP_H
#include <libcap.h>
/**
* lcd_cap_delete -- Delete the capability in slot from caller's cspace
* @slot: the cptr to the capability to delete
*
* This may change the state of the caller. (For example, if the caller is
* a regular lcd, and if the capability is to a page, the page will be unmapped
* from the caller's guest physical address space.)
*
* If this is the last capability to the object, object-specific cleanup
* code will run.
*
* If @slot points to an empty slot in the caller's cspace, silently does
* nothing.
*/
void lcd_cap_delete(cptr_t slot);
/**
* lcd_cap_revoke -- Revoke all derived capabilities
* @slot: the cptr to the slot that contains the parent capability
*
* Does not delete the caller's capability, but deletes all derived
* capabilities in other cspaces.
*
* This may change the state of the LCD's whose capabilities are revoked (see
* comment lcd_cap_delete).
*
* Returns non-zero if revocation failed, in whole or in part.
*/
int lcd_cap_revoke(cptr_t slot);
#endif /* LCD_DOMAINS_CAP_H */
/*
* console.h
*
* Primitive printk for LCDs.
*
* Copyright: University of Utah
*/
#ifndef LCD_DOMAINS_CONSOLE_H
#define LCD_DOMAINS_CONSOLE_H
/**
* lcd_printk -- Print a message to the host kernel log
* @fmt: format string
*
* Note that the entire buffer you print is limited to
* LCD_PRINTK_BUFF_SIZE; the rest is truncated.
*
* Most of the standard format escapes are supported, but
* not the more fancy ones.
*/
void lcd_printk(char *fmt, ...);
/**
* Some helpful macros for printing file and line numbers.
*/
#define LIBLCD_ERR(msg...) do { \
lcd_printk("error @ %s:%d: ", __FILE__, __LINE__); \
lcd_printk(msg); \
lcd_printk("end of error"); \
} while (0)
#define LIBLCD_MSG(msg...) do { \
lcd_printk("msg @ %s:%d: ", __FILE__, __LINE__); \
lcd_printk(msg); \
lcd_printk("end of msg"); \
} while (0)
#define LIBLCD_WARN(msg...) do { \
lcd_printk("warn @ %s:%d: ", __FILE__, __LINE__); \
lcd_printk(msg); \
lcd_printk("end of warn"); \
} while (0)
#endif /* LCD_DOMAINS_CONSOLE_H */
/*
* enter_exit.h
*
* These functions should be invoked when an LCD/thread starts
* executing, and before the thread exits (or when the thread
* exits).
*
* Copyright: University of Utah
*/
#ifndef LCD_DOMAINS_ENTER_EXIT_H
#define LCD_DOMAINS_ENTER_EXIT_H
#ifdef LCD_ISOLATE
#define LCD_MAYBE_NORETURN __noreturn
#else
#define LCD_MAYBE_NORETURN
#endif
/**
* lcd_enter -- Initializes runtime environment for an LCD
*
* No matter if you are isolated or non-isolated, this should be called
* before you invoked any other functions in the liblcd interface.
*
* Semantics:
*
* -- Isolated code: this bootstraps the environment inside the container
* -- Non-isolated code: this switches a non-isolated thread into
* "LCD mode": initializes a cspace and other data
* structures for the caller, so that it can
* start creating LCDs, doing ipc, etc.
*/
int lcd_enter(void);
/**
* lcd_exit -- Exit from LCD (mode) with return value
*
* This should be invoked when you are exiting an isolated LCD
* (think: user-level exit call), or when you are a non-isolated
* thread and want to exit out of LCD mode. Tears down all data
* structures associated with LCD.
*
* For isolated code, this function does not return (just like
* regular user-level exit).
*/
void LCD_MAYBE_NORETURN lcd_exit(int retval);
/**
* lcd_abort -- Abruptly exit from LCD
*
* For non-isolated code, this is equivalent to lcd_exit.
*
* For isolated code, this immediately exits out of the LCD without
* trying to tear down its environment.
*/
void LCD_MAYBE_NORETURN lcd_abort(void);
#endif /* LCD_DOMAINS_ENTER_EXIT_H */
......@@ -128,5 +128,6 @@ static inline hpa_t hpa_add(hpa_t hpa, unsigned long off)
#define LCD_DIR(subpath) \
LCD_TEST_MODS_PATH "/" subpath
#define LCD_PRINTK_BUFF_SIZE 512
#endif /* LCD_DOMAINS_TYPES_H */
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