diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h index 97985a0..04bc044 100644 --- a/include/l4/generic/tcb.h +++ b/include/l4/generic/tcb.h @@ -148,12 +148,12 @@ static inline unsigned int tcb_get_ipc_flags(struct ktcb *task) static inline void tcb_set_ipc_type(struct ktcb *task, unsigned int type) { - task->ipc_flags = type & L4_IPC_FLAGS_TYPE_MASK; + task->ipc_flags = type & IPC_FLAGS_TYPE_MASK; } static inline unsigned int tcb_get_ipc_type(struct ktcb *task) { - return task->ipc_flags & L4_IPC_FLAGS_TYPE_MASK; + return task->ipc_flags & IPC_FLAGS_TYPE_MASK; } #define THREAD_IDS_MAX 1024 diff --git a/include/l4/glue/arm/message.h b/include/l4/glue/arm/message.h index cd86e7e..e49238e 100644 --- a/include/l4/glue/arm/message.h +++ b/include/l4/glue/arm/message.h @@ -89,10 +89,20 @@ #if defined (__KERNEL__) /* Kernel-only flags */ -#define L4_IPC_FLAGS_ERROR_MASK 0xF0000000 -#define L4_IPC_FLAGS_ERROR_SHIFT 28 -#define L4_IPC_EFAULT (1 << 28) -#define L4_IPC_ENOIPC (1 << 29) +#define IPC_FLAGS_SHORT L4_IPC_FLAGS_SHORT +#define IPC_FLAGS_FULL L4_IPC_FLAGS_FULL +#define IPC_FLAGS_EXTENDED L4_IPC_FLAGS_EXTENDED +#define IPC_FLAGS_MSG_INDEX_MASK L4_IPC_FLAGS_MSG_INDEX_MASK +#define IPC_FLAGS_TYPE_MASK L4_IPC_FLAGS_TYPE_MASK +#define IPC_FLAGS_SIZE_MASK L4_IPC_FLAGS_SIZE_MASK +#define IPC_FLAGS_SIZE_SHIFT L4_IPC_FLAGS_SIZE_SHIFT +#define IPC_FLAGS_MSG_INDEX_SHIFT L4_IPC_FLAGS_MSG_INDEX_SHIFT +#define IPC_FLAGS_ERROR_MASK 0xF0000000 +#define IPC_FLAGS_ERROR_SHIFT 28 +#define IPC_EFAULT (1 << 28) +#define IPC_ENOIPC (1 << 29) + +#define IPC_EXTENDED_MAX_SIZE (SZ_1K*2) struct utcb { u32 mr[MR_TOTAL]; /* MRs that are mapped to real registers */ diff --git a/src/api/ipc.c b/src/api/ipc.c index 44e0def..d2f999a 100644 --- a/src/api/ipc.c +++ b/src/api/ipc.c @@ -66,14 +66,14 @@ int ipc_full_copy(struct ktcb *to, struct ktcb *from) static inline int extended_ipc_msg_index(unsigned int flags) { - return (flags & L4_IPC_FLAGS_MSG_INDEX_MASK) - >> L4_IPC_FLAGS_MSG_INDEX_SHIFT; + return (flags & IPC_FLAGS_MSG_INDEX_MASK) + >> IPC_FLAGS_MSG_INDEX_SHIFT; } static inline int extended_ipc_msg_size(unsigned int flags) { - return (flags & L4_IPC_FLAGS_SIZE_MASK) - >> L4_IPC_FLAGS_SIZE_SHIFT; + return (flags & IPC_FLAGS_SIZE_MASK) + >> IPC_FLAGS_SIZE_SHIFT; } /* @@ -125,28 +125,28 @@ int ipc_msg_copy(struct ktcb *to, struct ktcb *from) */ switch(recv_ipc_type) { - case L4_IPC_FLAGS_SHORT: - if (send_ipc_type == L4_IPC_FLAGS_SHORT) + case IPC_FLAGS_SHORT: + if (send_ipc_type == IPC_FLAGS_SHORT) ret = ipc_short_copy(to, from); - if (send_ipc_type == L4_IPC_FLAGS_FULL) + if (send_ipc_type == IPC_FLAGS_FULL) ret = ipc_full_copy(to, from); - if (send_ipc_type == L4_IPC_FLAGS_EXTENDED) + if (send_ipc_type == IPC_FLAGS_EXTENDED) ret = -ENOIPC; break; - case L4_IPC_FLAGS_FULL: - if (send_ipc_type == L4_IPC_FLAGS_SHORT) + case IPC_FLAGS_FULL: + if (send_ipc_type == IPC_FLAGS_SHORT) ret = ipc_full_copy(to, from); - if (send_ipc_type == L4_IPC_FLAGS_FULL) + if (send_ipc_type == IPC_FLAGS_FULL) ret = ipc_full_copy(to, from); - if (send_ipc_type == L4_IPC_FLAGS_EXTENDED) + if (send_ipc_type == IPC_FLAGS_EXTENDED) ret = -ENOIPC; break; - case L4_IPC_FLAGS_EXTENDED: - if (send_ipc_type == L4_IPC_FLAGS_EXTENDED) + case IPC_FLAGS_EXTENDED: + if (send_ipc_type == IPC_FLAGS_EXTENDED) ret = ipc_extended_copy(to, from); - if (send_ipc_type == L4_IPC_FLAGS_SHORT) + if (send_ipc_type == IPC_FLAGS_SHORT) ret = -ENOIPC; - if (send_ipc_type == L4_IPC_FLAGS_FULL) + if (send_ipc_type == IPC_FLAGS_FULL) ret = -ENOIPC; break; } @@ -180,9 +180,9 @@ void ipc_signal_error(struct ktcb *sleeper, int retval) * Set ipc error flag for sleeper. */ if (retval == -EFAULT) - sleeper->ipc_flags |= L4_IPC_EFAULT; + sleeper->ipc_flags |= IPC_EFAULT; if (retval == -ENOIPC) - sleeper->ipc_flags |= L4_IPC_ENOIPC; + sleeper->ipc_flags |= IPC_ENOIPC; } /* @@ -199,14 +199,14 @@ int ipc_handle_errors(void) } /* Did ipc fail with a fault error? */ - if (current->ipc_flags & L4_IPC_EFAULT) { - current->ipc_flags &= ~L4_IPC_EFAULT; + if (current->ipc_flags & IPC_EFAULT) { + current->ipc_flags &= ~IPC_EFAULT; return -EFAULT; } /* Did ipc fail with a general ipc error? */ - if (current->ipc_flags & L4_IPC_ENOIPC) { - current->ipc_flags &= ~L4_IPC_ENOIPC; + if (current->ipc_flags & IPC_ENOIPC) { + current->ipc_flags &= ~IPC_ENOIPC; return -ENOIPC; } @@ -413,7 +413,7 @@ int ipc_recv_extended(l4id_t sendertid, unsigned int flags) size = extended_ipc_msg_size(flags); /* Check size is good */ - if (size > L4_IPC_EXTENDED_MAX_SIZE) + if (size > IPC_EXTENDED_MAX_SIZE) return -EINVAL; /* Set extended ipc copy size */ @@ -473,7 +473,7 @@ int ipc_send_extended(l4id_t recv_tid, unsigned int flags) size = extended_ipc_msg_size(flags); /* Check size is good */ - if (size > L4_IPC_EXTENDED_MAX_SIZE) + if (size > IPC_EXTENDED_MAX_SIZE) return -EINVAL; /* Set extended ipc copy size */ @@ -508,19 +508,19 @@ static inline int __sys_ipc(l4id_t to, l4id_t from, switch (ipc_type) { case IPC_SEND: - if (flags & L4_IPC_FLAGS_EXTENDED) + if (flags & IPC_FLAGS_EXTENDED) ret = ipc_send_extended(to, flags); else ret = ipc_send(to, flags); break; case IPC_RECV: - if (flags & L4_IPC_FLAGS_EXTENDED) + if (flags & IPC_FLAGS_EXTENDED) ret = ipc_recv_extended(from, flags); else ret = ipc_recv(from, flags); break; case IPC_SENDRECV: - if (flags & L4_IPC_FLAGS_EXTENDED) + if (flags & IPC_FLAGS_EXTENDED) ret = ipc_sendrecv_extended(to, from, flags); else ret = ipc_sendrecv(to, from, flags); diff --git a/src/arch/arm/exception.c b/src/arch/arm/exception.c index 8d50fe6..3cb5041 100644 --- a/src/arch/arm/exception.c +++ b/src/arch/arm/exception.c @@ -60,7 +60,7 @@ void fault_ipc_to_pager(u32 faulty_pc, u32 fsr, u32 far) /* Save current ipc flags and set current flags to short ipc */ saved_flags = tcb_get_ipc_flags(current); - tcb_set_ipc_flags(current, L4_IPC_FLAGS_SHORT); + tcb_set_ipc_flags(current, IPC_FLAGS_SHORT); /* Send ipc to the task's pager */ ipc_sendrecv(current->pagerid, current->pagerid, 0);