L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
factory.h
Go to the documentation of this file.
1
6/*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>,
9 * Björn Döbel <doebel@os.inf.tu-dresden.de>,
10 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>,
11 * Henning Schild <hschild@os.inf.tu-dresden.de>
12 * economic rights: Technische Universität Dresden (Germany)
13 *
14 * License: see LICENSE.spdx (in this directory or the directories above)
15 */
16#pragma once
17
18#include <l4/sys/compiler.h>
19#include <l4/sys/types.h>
20#include <l4/sys/utcb.h>
21
50
56
88 l4_fpage_t *utcb_area) L4_NOTHROW;
89
95l4_factory_create_task_u(l4_cap_idx_t factory, l4_cap_idx_t target_cap,
96 l4_fpage_t *utcb_area, l4_utcb_t *utcb) L4_NOTHROW;
97
118 l4_cap_idx_t target_cap) L4_NOTHROW;
119
125l4_factory_create_thread_u(l4_cap_idx_t factory,
126 l4_cap_idx_t target_cap, l4_utcb_t *utcb) L4_NOTHROW;
127
155 unsigned long limit) L4_NOTHROW;
156
162l4_factory_create_factory_u(l4_cap_idx_t factory, l4_cap_idx_t target_cap,
163 unsigned long limit, l4_utcb_t *utcb) L4_NOTHROW;
164
196 l4_cap_idx_t target_cap,
197 l4_cap_idx_t snd_dst_cap, l4_umword_t label) L4_NOTHROW;
198
204l4_factory_create_gate_u(l4_cap_idx_t factory,
205 l4_cap_idx_t target_cap,
206 l4_cap_idx_t snd_dst_cap, l4_umword_t label,
207 l4_utcb_t *utcb) L4_NOTHROW;
208
227 l4_cap_idx_t target_cap) L4_NOTHROW;
228
234l4_factory_create_irq_u(l4_cap_idx_t factory,
235 l4_cap_idx_t target_cap, l4_utcb_t *utcb) L4_NOTHROW;
236
257 l4_cap_idx_t target_cap) L4_NOTHROW;
258
280 l4_cap_idx_t target_cap) L4_NOTHROW;
281
311 l4_cap_idx_t target_cap,
312 unsigned policy) L4_NOTHROW;
313
342 l4_addr_t ku_status, l4_cap_idx_t task_cap) L4_NOTHROW;
343
349l4_factory_create_vm_u(l4_cap_idx_t factory,
350 l4_cap_idx_t target_cap, l4_utcb_t *utcb) L4_NOTHROW;
351
357l4_factory_create_vcpu_context_u(l4_cap_idx_t factory,
358 l4_cap_idx_t target_cap,
359 l4_utcb_t *utcb) L4_NOTHROW;
360
366l4_factory_create_thread_group_u(l4_cap_idx_t factory,
367 l4_cap_idx_t target_cap,
368 unsigned policy,
370
376l4_factory_create_pi_mutex_u(l4_cap_idx_t factory, l4_cap_idx_t target_cap,
377 l4_addr_t ku_status, l4_cap_idx_t task_cap,
379
385l4_factory_create_start_u(long obj, l4_cap_idx_t target,
386 l4_utcb_t *utcb) L4_NOTHROW;
387
392L4_INLINE int
393l4_factory_create_add_fpage_u(l4_fpage_t d, l4_msgtag_t *tag,
394 l4_utcb_t *utcb) L4_NOTHROW;
395
400L4_INLINE int
401l4_factory_create_add_int_u(l4_mword_t d, l4_msgtag_t *tag,
402 l4_utcb_t *utcb) L4_NOTHROW;
403
408L4_INLINE int
409l4_factory_create_add_uint_u(l4_umword_t d, l4_msgtag_t *tag,
410 l4_utcb_t *utcb) L4_NOTHROW;
411
416L4_INLINE int
417l4_factory_create_add_str_u(char const *s, l4_msgtag_t *tag,
418 l4_utcb_t *utcb) L4_NOTHROW;
419
424L4_INLINE int
425l4_factory_create_add_lstr_u(char const *s, unsigned len, l4_msgtag_t *tag,
426 l4_utcb_t *utcb) L4_NOTHROW;
427
432L4_INLINE int
433l4_factory_create_add_nil_u(l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW;
434
440l4_factory_create_commit_u(l4_cap_idx_t factory, l4_msgtag_t tag,
441 l4_utcb_t *utcb) L4_NOTHROW;
442
448l4_factory_create_u(l4_cap_idx_t factory, long obj, l4_cap_idx_t target,
449 l4_utcb_t *utcb) L4_NOTHROW;
450
451
470l4_factory_create(l4_cap_idx_t factory, long obj,
471 l4_cap_idx_t target) L4_NOTHROW;
472
473/* IMPLEMENTATION -----------------------------------------------------------*/
474
475#include <l4/sys/ipc.h>
476
478l4_factory_create_task_u(l4_cap_idx_t factory,
479 l4_cap_idx_t target_cap, l4_fpage_t *utcb_area,
481{
482 l4_msgtag_t t;
483 t = l4_factory_create_start_u(L4_PROTO_TASK, target_cap, u);
484 l4_factory_create_add_fpage_u(*utcb_area, &t, u);
485 t = l4_factory_create_commit_u(factory, t, u);
486 if (!l4_msgtag_has_error(t))
487 {
488 l4_msg_regs_t *v = l4_utcb_mr_u(u);
489 utcb_area->raw = v->mr[0];
490 }
491 return t;
492}
493
495l4_factory_create_thread_u(l4_cap_idx_t factory,
496 l4_cap_idx_t target_cap, l4_utcb_t *u) L4_NOTHROW
497{
498 return l4_factory_create_u(factory, L4_PROTO_THREAD, target_cap, u);
499}
500
502l4_factory_create_factory_u(l4_cap_idx_t factory,
503 l4_cap_idx_t target_cap, unsigned long limit,
505{
506 l4_msgtag_t t;
507 t = l4_factory_create_start_u(L4_PROTO_FACTORY, target_cap, u);
508 l4_factory_create_add_uint_u(limit, &t, u);
509 return l4_factory_create_commit_u(factory, t, u);
510}
511
513l4_factory_create_gate_u(l4_cap_idx_t factory,
514 l4_cap_idx_t target_cap,
515 l4_cap_idx_t snd_dst_cap, l4_umword_t label,
517{
518 l4_msgtag_t t;
519 l4_msg_regs_t *v;
520 int items = 0;
521 t = l4_factory_create_start_u(0, target_cap, u);
522 l4_factory_create_add_uint_u(label, &t, u);
523 v = l4_utcb_mr_u(u);
524 if (!(snd_dst_cap & L4_INVALID_CAP_BIT))
525 {
526 items = 1;
527 v->mr[3] = l4_map_obj_control(0,0);
528 v->mr[4] = l4_obj_fpage(snd_dst_cap, 0, L4_CAP_FPAGE_RWS).raw;
529 }
531 return l4_factory_create_commit_u(factory, t, u);
532}
533
535l4_factory_create_irq_u(l4_cap_idx_t factory,
536 l4_cap_idx_t target_cap, l4_utcb_t *u) L4_NOTHROW
537{
538 return l4_factory_create_u(factory, L4_PROTO_IRQ_SENDER, target_cap, u);
539}
540
542l4_factory_create_vm_u(l4_cap_idx_t factory,
543 l4_cap_idx_t target_cap,
545{
546 return l4_factory_create_u(factory, L4_PROTO_VM, target_cap, u);
547}
548
550l4_factory_create_vcpu_context_u(l4_cap_idx_t factory,
551 l4_cap_idx_t target_cap,
553{
554 return l4_factory_create_u(factory, L4_PROTO_VCPU_CONTEXT, target_cap, u);
555}
556
558l4_factory_create_thread_group_u(l4_cap_idx_t factory,
559 l4_cap_idx_t target_cap,
560 unsigned policy,
562{
563 l4_msgtag_t t = l4_factory_create_start_u(L4_PROTO_THREAD_GROUP, target_cap, u);
564 l4_factory_create_add_uint_u(policy, &t, u);
565 return l4_factory_create_commit_u(factory, t, u);
566}
567
569l4_factory_create_pi_mutex_u(l4_cap_idx_t factory, l4_cap_idx_t target_cap,
570 l4_addr_t ku_status, l4_cap_idx_t task_cap,
572{
573 l4_msgtag_t t;
574 l4_msg_regs_t *v;
575 t = l4_factory_create_start_u(L4_PROTO_PI_MUTEX, target_cap, u);
576 l4_factory_create_add_uint_u(ku_status, &t, u);
577 v = l4_utcb_mr_u(u);
579 v->mr[l4_msgtag_words(t) + 1] = l4_obj_fpage(task_cap, 0, L4_CAP_FPAGE_RS).raw;
581 return l4_factory_create_commit_u(factory, t, u);
582}
583
586 l4_cap_idx_t target_cap, l4_fpage_t *utcb_area) L4_NOTHROW
587{
588 return l4_factory_create_task_u(factory, target_cap, utcb_area, l4_utcb());
589}
590
593 l4_cap_idx_t target_cap) L4_NOTHROW
594{
595 return l4_factory_create_thread_u(factory, target_cap, l4_utcb());
596}
597
600 l4_cap_idx_t target_cap, unsigned long limit) L4_NOTHROW
601
602{
603 return l4_factory_create_factory_u(factory, target_cap, limit, l4_utcb());
604}
605
608 l4_cap_idx_t target_cap,
609 l4_cap_idx_t snd_dst_cap, l4_umword_t label) L4_NOTHROW
610{
611 return l4_factory_create_gate_u(factory, target_cap, snd_dst_cap, label, l4_utcb());
612}
613
616 l4_cap_idx_t target_cap) L4_NOTHROW
617{
618 return l4_factory_create_irq_u(factory, target_cap, l4_utcb());
619}
620
623 l4_cap_idx_t target_cap) L4_NOTHROW
624{
625 return l4_factory_create_vm_u(factory, target_cap, l4_utcb());
626}
627
630 l4_cap_idx_t target_cap) L4_NOTHROW
631{
632 return l4_factory_create_vcpu_context_u(factory, target_cap, l4_utcb());
633}
634
637 l4_cap_idx_t target_cap,
638 unsigned policy) L4_NOTHROW
639{
640 return l4_factory_create_thread_group_u(factory, target_cap, policy, l4_utcb());
641}
642
645 l4_addr_t ku_status,
646 l4_cap_idx_t task_cap) L4_NOTHROW
647{
648 return l4_factory_create_pi_mutex_u(factory, target_cap, ku_status, task_cap,
649 l4_utcb());
650}
651
653l4_factory_create_start_u(long obj, l4_cap_idx_t target_cap,
655{
656 l4_msg_regs_t *v = l4_utcb_mr_u(u);
657 l4_buf_regs_t *b = l4_utcb_br_u(u);
658 v->mr[0] = obj;
659 b->bdr = 0;
660 b->br[0] = target_cap | L4_RCV_ITEM_SINGLE_CAP;
661 return l4_msgtag(L4_PROTO_FACTORY, 1, 0, 0);
662}
663
664L4_INLINE int
665l4_factory_create_add_fpage_u(l4_fpage_t d, l4_msgtag_t *tag,
667{
668 l4_msg_regs_t *v = l4_utcb_mr_u(u);
669 int w = l4_msgtag_words(*tag);
670 if (w + 2 > L4_UTCB_GENERIC_DATA_SIZE)
671 return 0;
672 v->mr[w] = L4_VARG_TYPE_FPAGE | (sizeof(l4_fpage_t) << 16);
673 v->mr[w + 1] = d.raw;
674 w += 2;
675 tag->raw = (tag->raw & ~0x3fUL) | (w & 0x3f);
676 return 1;
677}
678
679L4_INLINE int
680l4_factory_create_add_int_u(l4_mword_t d, l4_msgtag_t *tag,
682{
683 l4_msg_regs_t *v = l4_utcb_mr_u(u);
684 int w = l4_msgtag_words(*tag);
685 if (w + 2 > L4_UTCB_GENERIC_DATA_SIZE)
686 return 0;
687 v->mr[w] = L4_VARG_TYPE_MWORD | (sizeof(l4_mword_t) << 16);
688 v->mr[w + 1] = d;
689 w += 2;
690 tag->raw = (tag->raw & ~0x3fUL) | (w & 0x3f);
691 return 1;
692}
693
694L4_INLINE int
695l4_factory_create_add_uint_u(l4_umword_t d, l4_msgtag_t *tag,
697{
698 l4_msg_regs_t *v = l4_utcb_mr_u(u);
699 int w = l4_msgtag_words(*tag);
700 if (w + 2 > L4_UTCB_GENERIC_DATA_SIZE)
701 return 0;
702 v->mr[w] = L4_VARG_TYPE_UMWORD | (sizeof(l4_umword_t) << 16);
703 v->mr[w + 1] = d;
704 w += 2;
705 tag->raw = (tag->raw & ~0x3fUL) | (w & 0x3f);
706 return 1;
707}
708
709L4_INLINE int
710l4_factory_create_add_str_u(char const *s, l4_msgtag_t *tag,
712{
713 return l4_factory_create_add_lstr_u(s, __builtin_strlen(s) + 1, tag, u);
714}
715
716L4_INLINE int
717l4_factory_create_add_lstr_u(char const *s, unsigned len, l4_msgtag_t *tag,
719{
720
721 l4_msg_regs_t *v = l4_utcb_mr_u(u);
722 unsigned w = l4_msgtag_words(*tag);
723 char *c;
724 unsigned i;
725
726 if (w + 1 + l4_bytes_to_mwords(len) > L4_UTCB_GENERIC_DATA_SIZE)
727 return 0;
728
729 v->mr[w] = L4_VARG_TYPE_STRING | (len << 16);
730 c = (char*)&v->mr[w + 1];
731 for (i = 0; i < len; ++i)
732 *c++ = *s++;
733
734 w = w + 1 + l4_bytes_to_mwords(len);
735
736 tag->raw = (tag->raw & ~0x3fUL) | (w & 0x3f);
737 return 1;
738}
739
740L4_INLINE int
741l4_factory_create_add_nil_u(l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW
742{
743 l4_msg_regs_t *v = l4_utcb_mr_u(utcb);
744 int w = l4_msgtag_words(*tag);
745 v->mr[w] = L4_VARG_TYPE_NIL;
746 ++w;
747 tag->raw = (tag->raw & ~0x3fUL) | (w & 0x3f);
748 return 1;
749}
750
751
753l4_factory_create_commit_u(l4_cap_idx_t factory, l4_msgtag_t tag,
755{
756 return l4_ipc_call(factory, u, tag, L4_IPC_NEVER);
757}
758
760l4_factory_create_u(l4_cap_idx_t factory, long obj, l4_cap_idx_t target,
761 l4_utcb_t *utcb) L4_NOTHROW
762{
763 l4_msgtag_t t = l4_factory_create_start_u(obj, target, utcb);
764 return l4_factory_create_commit_u(factory, t, utcb);
765}
766
767
771{
772 return l4_factory_create_u(factory, obj, target, l4_utcb());
773}
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:372
l4_msgtag_t l4_factory_create_thread_group(l4_cap_idx_t factory, l4_cap_idx_t target_cap, unsigned policy) L4_NOTHROW
Create a new thread group.
Definition factory.h:636
l4_msgtag_t l4_factory_create_thread(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new thread.
Definition factory.h:592
l4_msgtag_t l4_factory_create_irq(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new IRQ sender.
Definition factory.h:615
l4_msgtag_t l4_factory_create_pi_mutex(l4_cap_idx_t factory, l4_cap_idx_t target_cap, l4_addr_t ku_status, l4_cap_idx_t task_cap) L4_NOTHROW
Create a new priority inheritance mutex.
Definition factory.h:644
l4_msgtag_t l4_factory_create_vcpu_context(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new vCPU context.
Definition factory.h:629
l4_msgtag_t l4_factory_create_factory(l4_cap_idx_t factory, l4_cap_idx_t target_cap, unsigned long limit) L4_NOTHROW
Create a new factory.
Definition factory.h:599
l4_msgtag_t l4_factory_create_task(l4_cap_idx_t factory, l4_cap_idx_t target_cap, l4_fpage_t *utcb_area) L4_NOTHROW
Create a new task.
Definition factory.h:585
l4_msgtag_t l4_factory_create(l4_cap_idx_t factory, long obj, l4_cap_idx_t target) L4_NOTHROW
Create a new object.
Definition factory.h:769
l4_msgtag_t l4_factory_create_vm(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new virtual machine.
Definition factory.h:622
l4_msgtag_t l4_factory_create_gate(l4_cap_idx_t factory, l4_cap_idx_t target_cap, l4_cap_idx_t snd_dst_cap, l4_umword_t label) L4_NOTHROW
Create a new IPC gate, optionally bound to a send destination (a thread or thread group).
Definition factory.h:607
L4_CONSTEXPR l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flexpage.
Definition __l4_fpage.h:731
@ L4_CAP_FPAGE_RS
Read and interface specific 'S' right for capability flexpages.
Definition __l4_fpage.h:199
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flexpages.
Definition __l4_fpage.h:206
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition ipc.h:598
unsigned l4_bytes_to_mwords(unsigned size) L4_NOTHROW
Determine how many machine words (l4_umword_t) are required to store a buffer of 'size' bytes.
Definition consts.h:507
L4_CONSTEXPR l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item that is a send item for the object space.
Definition __l4_fpage.h:765
@ L4_RCV_ITEM_SINGLE_CAP
Mark the receive buffer to be a small receive item that describes a buffer for a single object capabi...
Definition consts.h:286
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:476
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:441
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition types.h:463
unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
Get the flags.
Definition types.h:471
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition types.h:453
@ L4_PROTO_FACTORY
Protocol for messages to a factory object.
Definition types.h:73
@ L4_PROTO_IRQ_SENDER
Protocol for IRQ senders (IRQ -> IPC).
Definition types.h:76
@ L4_PROTO_TASK
Protocol for messages to a task object.
Definition types.h:69
@ L4_PROTO_VM
Protocol for messages to a virtual machine object.
Definition types.h:74
@ L4_PROTO_THREAD_GROUP
Protocol for messages to a thread group obj.
Definition types.h:67
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition types.h:70
@ L4_PROTO_PI_MUTEX
Protocol for priority inheritance mutex.
Definition types.h:84
@ L4_PROTO_VCPU_CONTEXT
Protocol for hardware vCPU contexts.
Definition types.h:83
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:369
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:167
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
Common IPC interface.
Common L4 ABI Data Types.
UTCB definitions.
Encapsulation of the buffer-registers block in the UTCB.
Definition utcb.h:148
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:153
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:150
Message tag data structure.
Definition types.h:269
L4 flexpage type.
Definition __l4_fpage.h:76
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:78
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:133
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:134