diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-03-09 23:58:17 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2016-03-09 23:58:17 -0800 |
commit | b94c7a4b07f96f24ae7411780abf874416549f7b (patch) | |
tree | b94ca015e49392f52e5abf1209ee184fcf874db4 /machine/htif.h | |
parent | f5a96732cb81571a3ba6b081b8556187d564f678 (diff) | |
download | pk-b94c7a4b07f96f24ae7411780abf874416549f7b.zip pk-b94c7a4b07f96f24ae7411780abf874416549f7b.tar.gz pk-b94c7a4b07f96f24ae7411780abf874416549f7b.tar.bz2 |
Refactor pk, bbl, machine into separate libraries
Yuck.
Diffstat (limited to 'machine/htif.h')
-rw-r--r-- | machine/htif.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/machine/htif.h b/machine/htif.h new file mode 100644 index 0000000..e66ad06 --- /dev/null +++ b/machine/htif.h @@ -0,0 +1,18 @@ +#ifndef _RISCV_HTIF_H +#define _RISCV_HTIF_H + +#include <stdint.h> + +#ifdef __riscv64 +# define TOHOST_CMD(dev, cmd, payload) \ + (((uint64_t)(dev) << 56) | ((uint64_t)(cmd) << 48) | (uint64_t)(payload)) +#else +# define TOHOST_CMD(dev, cmd, payload) ({ \ + if ((dev) || (cmd)) __builtin_trap(); \ + (payload); }) +#endif +#define FROMHOST_DEV(fromhost_value) ((uint64_t)(fromhost_value) >> 56) +#define FROMHOST_CMD(fromhost_value) ((uint64_t)(fromhost_value) << 8 >> 56) +#define FROMHOST_DATA(fromhost_value) ((uint64_t)(fromhost_value) << 16 >> 16) + +#endif |