1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#ifndef __LIBSEL4_SEL4_ARCH_FUNCTIONS_H 14#define __LIBSEL4_SEL4_ARCH_FUNCTIONS_H 15 16#include <sel4/types.h> 17#include <sel4/macros.h> 18 19/* the segment loaded into GS points directly to the IPC buffer */ 20 21#define SEL4_GET_IPCBUF_SCALE(field, i, res) \ 22 do {\ 23 asm volatile ("movl %%fs:%c2(,%1,%c3), %0"\ 24 : [result] "=r" (res) /* outputs */\ 25 : [scale] "r" (i), /* inputs */\ 26 [offset] "i" (SEL4_OFFSETOF(seL4_IPCBuffer, field)),\ 27 [scale_factor] "i" (sizeof(seL4_Word))\ 28 /* no clobber */);\ 29 } while(0) 30 31 32#define SEL4_SET_IPCBUF_SCALE(field, i, val) \ 33 do {\ 34 asm volatile ("movl %0, %%fs:%c2(,%1,%c3)"\ 35 : /* no outputs */\ 36 : [value] "r" (val), /* inputs */\ 37 [scale] "r" (i),\ 38 [offset] "i" (SEL4_OFFSETOF(seL4_IPCBuffer, field)),\ 39 [scale_factor] "i" (sizeof(seL4_Word))\ 40 : "memory"); /* clobber */\ 41 } while(0) 42 43#define SEL4_GET_IPCBUF(field, res) \ 44 do {\ 45 asm volatile ("movl %%fs:%c1, %0"\ 46 : [result] "=r" (res) /* inputs */\ 47 : [offset] "i" (SEL4_OFFSETOF(seL4_IPCBuffer, field)) /* outputs */\ 48 /* no clobber */);\ 49 } while(0) 50 51 52#define SEL4_SET_IPCBUF(field, val) \ 53 do {\ 54 asm volatile ("movl %0, %%fs:%c1"\ 55 : /* no outputs */\ 56 : [value] "r" (val), /* inputs */\ 57 [offset] "i" (SEL4_OFFSETOF(seL4_IPCBuffer, field))\ 58 : "memory"); /* clobber */\ 59 } while(0) 60 61#endif 62