1 |
2 |
drasko |
/*
|
2 |
|
|
* Userspace thread control block
|
3 |
|
|
*
|
4 |
|
|
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
5 |
|
|
*/
|
6 |
|
|
#ifndef __GLUE_ARM_MESSAGE_H__
|
7 |
|
|
#define __GLUE_ARM_MESSAGE_H__
|
8 |
|
|
|
9 |
|
|
/*
|
10 |
|
|
* Here's a summary of how ARM registers are used during IPC:
|
11 |
|
|
*
|
12 |
|
|
* System registers:
|
13 |
|
|
* r0 - r2: Passed as arguments to ipc() call. They are the registers
|
14 |
|
|
* the microkernel will read and they have system-wide meaning.
|
15 |
|
|
*
|
16 |
|
|
* Primary message registers:
|
17 |
|
|
* r3 - r8: These 6 registers are the primary message registers MR0-MR6.
|
18 |
|
|
* Their format is application-specific, i.e. the microkernel imposes no
|
19 |
|
|
* format restrictions on them.
|
20 |
|
|
*
|
21 |
|
|
* TODO: The only exception is that, for ANYTHREAD receivers the predefined
|
22 |
|
|
* MR_SENDER is touched by the kernel to indicate the sender. This register
|
23 |
|
|
* is among the primary MRs and it may be better fit to put it into one of
|
24 |
|
|
* the system registers.
|
25 |
|
|
*
|
26 |
|
|
* l4lib registers: (MR_TAG, MR_SENDER, MR_RETURN)
|
27 |
|
|
* Some of the primary message registers are used by the l4lib convenience
|
28 |
|
|
* library for operations necessary on most or all common ipcs. For example
|
29 |
|
|
* every ipc has a tag that specifies the ipc reason. Also send/receive
|
30 |
|
|
* operations require a return value. Threads that are open to receive from
|
31 |
|
|
* all threads require the sender id. These values are passed in predefined
|
32 |
|
|
* primary message registers, but the microkernel has no knowledge about them.
|
33 |
|
|
*
|
34 |
|
|
* System call registers: L4SYS_ARG0 to ARG4.(See syslib.h for definitions)
|
35 |
|
|
* Finally the rest of the primary message registers are available for
|
36 |
|
|
* implementing system call arguments. For example the POSIX services use
|
37 |
|
|
* these arguments to pass posix system call information.
|
38 |
|
|
*
|
39 |
|
|
* Secondary Message Registers:
|
40 |
|
|
* These are non-real registers and are present in the UTCB memory region.
|
41 |
|
|
* Both real and non-real message registers have a location in the UTCB, but
|
42 |
|
|
* non-real ones are copied only if the FULL IPC flag is set.
|
43 |
|
|
*
|
44 |
|
|
* The big picture:
|
45 |
|
|
*
|
46 |
|
|
* r0 System register
|
47 |
|
|
* r1 System register
|
48 |
|
|
* r2 System register
|
49 |
|
|
* r3 Primary MR0 MR_RETURN, MR_TAG Present in UTCB, Short IPC
|
50 |
|
|
* r4 Primary MR1 MR_SENDER Present in UTCB, Short IPC
|
51 |
|
|
* r5 Primary MR2 L4SYS_ARG0 Present in UTCB, Short IPC
|
52 |
|
|
* r6 Primary MR3 L4SYS_ARG1 Present in UTCB, Short IPC
|
53 |
|
|
* r7 Primary MR4 L4SYS_ARG2 Present in UTCB, Short IPC
|
54 |
|
|
* r8 Primary MR5 L4SYS_ARG3 Present in UTCB, Short IPC
|
55 |
|
|
* x Secondary MR6 Present in UTCB, Full IPC only
|
56 |
|
|
* x Secondary MR64 Present in UTCB, Full IPC only
|
57 |
|
|
*
|
58 |
|
|
* Complicated for you? Suggest a simpler design and it shall be implemented!
|
59 |
|
|
*/
|
60 |
|
|
|
61 |
|
|
#define MR_REST ((UTCB_SIZE >> 2) - MR_TOTAL - 4) /* -4 is for fields on utcb */
|
62 |
|
|
#define MR_TOTAL 6
|
63 |
|
|
#define MR_TAG 0 /* Contains the purpose of message */
|
64 |
|
|
#define MR_SENDER 1 /* For anythread receivers to discover sender */
|
65 |
|
|
#define MR_RETURN 0 /* Contains the posix return value. */
|
66 |
|
|
|
67 |
|
|
/* These define the mr start - end range that isn't used by userspace syslib */
|
68 |
|
|
#define MR_UNUSED_START 2 /* The first mr that's not used by syslib.h */
|
69 |
|
|
#define MR_UNUSED_TOTAL (MR_TOTAL - MR_UNUSED_START)
|
70 |
|
|
#define MR_USABLE_TOTAL MR_UNUSED_TOTAL
|
71 |
|
|
|
72 |
|
|
/* These are defined so that we don't hard-code register names */
|
73 |
|
|
#define MR0_REGISTER r3
|
74 |
|
|
#define MR_RETURN_REGISTER r3
|
75 |
|
|
|
76 |
|
|
#define TASK_NOTIFY_SLOTS 8
|
77 |
|
|
#define TASK_NOTIFY_MAXVALUE 255
|
78 |
|
|
|
79 |
|
|
/* Primaries aren't used for memcopy. Those ops use this as a parameter */
|
80 |
|
|
#define L4_UTCB_FULL_BUFFER_SIZE (MR_REST * sizeof(int))
|
81 |
|
|
|
82 |
|
|
#include INC_GLUE(memlayout.h)
|
83 |
|
|
|
84 |
|
|
#if !defined (__ASSEMBLY__)
|
85 |
|
|
struct utcb {
|
86 |
|
|
u32 mr[MR_TOTAL]; /* MRs that are mapped to real registers */
|
87 |
|
|
u32 saved_tag; /* Saved tag field for stacked ipcs */
|
88 |
|
|
u32 saved_sender; /* Saved sender field for stacked ipcs */
|
89 |
|
|
u8 notify[TASK_NOTIFY_SLOTS]; /* Irq notification slots */
|
90 |
|
|
u32 mr_rest[MR_REST]; /* Complete the utcb for up to 64 words */
|
91 |
|
|
};
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
#endif /* __GLUE_ARM_MESSAGE_H__ */
|