L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
__l4_fpage.h
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 * economic rights: Technische Universität Dresden (Germany)
12 *
13 * This file is part of TUD:OS and distributed under the terms of the
14 * GNU General Public License 2.
15 * Please see the COPYING-GPL-2 file for details.
16 *
17 * As a special exception, you may use this file as part of a free software
18 * library without restriction. Specifically, if other files instantiate
19 * templates or use macros or inline functions from this file, or you compile
20 * this file and link it with other files to produce an executable, this
21 * file does not by itself cause the resulting executable to be covered by
22 * the GNU General Public License. This exception does not however
23 * invalidate any other reasons why the executable file might be covered by
24 * the GNU General Public License.
25 */
26#pragma once
27
28#include <l4/sys/compiler.h>
29
80
89
93enum
94{
103
112
113
133
229
240
253
280
281
299
300
304enum
305{
310
314
315
316
332l4_fpage(l4_addr_t address, unsigned int size, unsigned char rights) L4_NOTHROW;
333
347
356
357
369l4_iofpage(unsigned long port, unsigned int size) L4_NOTHROW;
370
371
385l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW;
386
396L4_INLINE int
398
399
435l4_map_control(l4_umword_t spot, unsigned char cache, unsigned grant) L4_NOTHROW;
436
450l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW;
451
460L4_INLINE unsigned
462
471L4_INLINE unsigned
473
484L4_INLINE unsigned
486
497L4_INLINE unsigned long
499
515
531
545L4_INLINE unsigned long
547
558l4_fpage_set_rights(l4_fpage_t src, unsigned char new_rights) L4_NOTHROW;
559
571L4_INLINE int
572l4_fpage_contains(l4_fpage_t fpage, l4_addr_t addr, unsigned size) L4_NOTHROW;
573
590L4_INLINE unsigned char
591l4_fpage_max_order(unsigned char order, l4_addr_t addr,
592 l4_addr_t min_addr, l4_addr_t max_addr,
593 l4_addr_t hotspot L4_DEFAULT_PARAM(0));
594
595/*************************************************************************
596 * Implementations
597 *************************************************************************/
598
599L4_INLINE unsigned
604
605L4_INLINE unsigned
607{
608 return (f.raw & L4_FPAGE_TYPE_MASK) >> L4_FPAGE_TYPE_SHIFT;
609}
610
611L4_INLINE unsigned
613{
614 return (f.raw & L4_FPAGE_SIZE_MASK) >> L4_FPAGE_SIZE_SHIFT;
615}
616
617L4_INLINE unsigned long
619{
620 return (f.raw & L4_FPAGE_ADDR_MASK) >> L4_FPAGE_ADDR_SHIFT;
621}
622
623L4_INLINE unsigned long
625{
626 return (f.raw & L4_FPAGE_ADDR_MASK) >> L4_FPAGE_ADDR_SHIFT;
627}
628
631{
632 return f.raw & L4_FPAGE_ADDR_MASK;
633}
634
637{
638 return f.raw & L4_FPAGE_ADDR_MASK;
639}
640
643__l4_fpage_generic(unsigned long address, unsigned int type,
644 unsigned int size, unsigned char rights) L4_NOTHROW;
645
647__l4_fpage_generic(unsigned long address, unsigned int type,
648 unsigned int size, unsigned char rights) L4_NOTHROW
649{
650 l4_fpage_t t;
652 | ((type << L4_FPAGE_TYPE_SHIFT) & L4_FPAGE_TYPE_MASK)
653 | ((size << L4_FPAGE_SIZE_SHIFT) & L4_FPAGE_SIZE_MASK)
654 | ((address ) & L4_FPAGE_ADDR_MASK);
655 return t;
656}
657
659l4_fpage_set_rights(l4_fpage_t src, unsigned char new_rights) L4_NOTHROW
660{
661 l4_fpage_t f;
662 f.raw = ((L4_FPAGE_TYPE_MASK | L4_FPAGE_SIZE_MASK | L4_FPAGE_ADDR_MASK) & src.raw)
663 | ((new_rights << L4_FPAGE_RIGHTS_SHIFT) & L4_FPAGE_RIGHTS_MASK);
664 return f;
665}
666
668l4_fpage(l4_addr_t address, unsigned int size, unsigned char rights) L4_NOTHROW
669{
670 return __l4_fpage_generic(address, L4_FPAGE_MEMORY, size, rights);
671}
672
674l4_iofpage(unsigned long port, unsigned int size) L4_NOTHROW
675{
676 return __l4_fpage_generic(port << L4_FPAGE_ADDR_SHIFT, L4_FPAGE_IO, size, L4_FPAGE_RW);
677}
678
680l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
681{
682 static_assert((unsigned long)L4_CAP_SHIFT >= L4_FPAGE_ADDR_SHIFT,
683 "Capability index does not fit into fpage.");
684 return __l4_fpage_generic(obj, L4_FPAGE_OBJ, order, rights);
685}
686
689{
690 return __l4_fpage_generic(0, L4_FPAGE_SPECIAL, L4_WHOLE_ADDRESS_SPACE, 0);
691}
692
695{
696 return __l4_fpage_generic(0, L4_FPAGE_SPECIAL, 0, 0);
697}
698
699
700L4_INLINE int
705
707l4_map_control(l4_umword_t snd_base, unsigned char cache, unsigned grant) L4_NOTHROW
708{
709 return (snd_base & L4_FPAGE_CONTROL_MASK)
710 | ((l4_umword_t)cache << 4) | L4_ITEM_MAP | grant;
711}
712
715{
716 return l4_map_control(snd_base, 0, grant);
717}
718
719L4_INLINE int
720l4_fpage_contains(l4_fpage_t fpage, l4_addr_t addr, unsigned log2size) L4_NOTHROW
721{
722 l4_addr_t fa = l4_fpage_memaddr(fpage);
723 return (fa <= addr)
724 && (fa + (1UL << l4_fpage_size(fpage)) >= addr + (1UL << log2size));
725}
726
727L4_INLINE unsigned char
728l4_fpage_max_order(unsigned char order, l4_addr_t addr,
729 l4_addr_t min_addr, l4_addr_t max_addr,
730 l4_addr_t hotspot)
731{
732 while (order < 30 /* limit to 1GB flexpages */)
733 {
734 l4_addr_t mask;
735 l4_addr_t base = l4_trunc_size(addr, order + 1);
736 if (base < min_addr)
737 return order;
738
739 if (base + (1UL << (order + 1)) - 1 > max_addr - 1)
740 return order;
741
742 mask = ~(~0UL << (order + 1));
743 if (hotspot == ~0UL || ((addr ^ hotspot) & mask))
744 break;
745
746 ++order;
747 }
748
749 return order;
750}
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
#define L4_MWORD_BITS
Size of machine words in bits.
Definition l4int.h:33
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:359
@ L4_CAP_SHIFT
Capability index shift.
Definition consts.h:157
unsigned long l4_fpage_page(l4_fpage_t f) L4_NOTHROW
Return the page part from a flex page.
Definition __l4_fpage.h:618
l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flex page.
Definition __l4_fpage.h:680
l4_fpage_t l4_fpage(l4_addr_t address, unsigned int size, unsigned char rights) L4_NOTHROW
Create a memory flex page.
Definition __l4_fpage.h:668
l4_fpage_cacheability_opt_t
Flex-page cacheability option.
Definition __l4_fpage.h:286
l4_fpage_t l4_fpage_all(void) L4_NOTHROW
Get a flex page, describing all address spaces at once.
Definition __l4_fpage.h:688
l4_fpage_t l4_fpage_set_rights(l4_fpage_t src, unsigned char new_rights) L4_NOTHROW
Set new right in a flex page.
Definition __l4_fpage.h:659
L4_fpage_rights
Memory and IO port flex-page rights.
Definition __l4_fpage.h:125
L4_fpage_control
Flex-page map control flags.
Definition __l4_fpage.h:245
unsigned l4_fpage_type(l4_fpage_t f) L4_NOTHROW
Return type from a flex page.
Definition __l4_fpage.h:606
unsigned long l4_fpage_ioport(l4_fpage_t f) L4_NOTHROW
Return the IO port number from the IO flex page.
Definition __l4_fpage.h:624
l4_addr_t l4_fpage_memaddr(l4_fpage_t f) L4_NOTHROW
Return the memory address from the memory flex page.
Definition __l4_fpage.h:630
int l4_fpage_contains(l4_fpage_t fpage, l4_addr_t addr, unsigned size) L4_NOTHROW
Test whether a given range is completely within an fpage.
Definition __l4_fpage.h:720
unsigned l4_fpage_size(l4_fpage_t f) L4_NOTHROW
Return size from a flex page.
Definition __l4_fpage.h:612
unsigned char l4_fpage_max_order(unsigned char order, l4_addr_t addr, l4_addr_t min_addr, l4_addr_t max_addr, l4_addr_t hotspot=0)
Determine maximum flex page size of a region.
Definition __l4_fpage.h:728
unsigned l4_fpage_rights(l4_fpage_t f) L4_NOTHROW
Return rights from a flex page.
Definition __l4_fpage.h:600
int l4_is_fpage_writable(l4_fpage_t fp) L4_NOTHROW
Test if the flex page is writable.
Definition __l4_fpage.h:701
l4_fpage_t l4_iofpage(unsigned long port, unsigned int size) L4_NOTHROW
Create an IO-port flex page.
Definition __l4_fpage.h:674
L4_fpage_type
Flex-page type.
Definition __l4_fpage.h:234
L4_obj_fpage_ctl
Flex-page map control for capabilities (snd_base)
Definition __l4_fpage.h:264
l4_fpage_t l4_fpage_invalid(void) L4_NOTHROW
Get an invalid flex page.
Definition __l4_fpage.h:694
l4_cap_idx_t l4_fpage_obj(l4_fpage_t f) L4_NOTHROW
Return the capability index from the object flex page.
Definition __l4_fpage.h:636
L4_cap_fpage_rights
Cap-flex-page rights.
Definition __l4_fpage.h:152
L4_fpage_consts
L4 flexpage structure.
Definition __l4_fpage.h:58
@ L4_FPAGE_CACHEABLE
Cacheability option to enable caches for the mapping.
Definition __l4_fpage.h:291
@ L4_FPAGE_CACHE_OPT
Enable the cacheability option in a send flex page.
Definition __l4_fpage.h:288
@ L4_FPAGE_UNCACHEABLE
Cacheability option to disable caching for the mapping.
Definition __l4_fpage.h:297
@ L4_FPAGE_BUFFERABLE
Cacheability option to enable buffered writes for the mapping.
Definition __l4_fpage.h:294
@ L4_FPAGE_X
Executable flex page.
Definition __l4_fpage.h:126
@ L4_FPAGE_RWX
Read-write-execute flex page.
Definition __l4_fpage.h:131
@ L4_FPAGE_RX
Read-execute flex page.
Definition __l4_fpage.h:130
@ L4_FPAGE_RO
Read-only flex page
Definition __l4_fpage.h:128
@ L4_FPAGE_RW
Read-write flex page.
Definition __l4_fpage.h:129
@ L4_FPAGE_W
Writable flex page.
Definition __l4_fpage.h:127
@ L4_FPAGE_CONTROL_MASK
Mask for truncating the lower bits of the send base or the index of the control word.
Definition __l4_fpage.h:251
@ L4_FPAGE_CONTROL_OFFSET_SHIFT
Number of bits an index must be shifted or an address must be aligned to in the control word.
Definition __l4_fpage.h:248
@ L4_WHOLE_IOADDRESS_SPACE
Whole I/O address space size.
Definition __l4_fpage.h:309
@ L4_IOPORT_MAX
Maximum I/O port address plus 1.
Definition __l4_fpage.h:312
@ L4_FPAGE_MEMORY
Memory flex page.
Definition __l4_fpage.h:236
@ L4_FPAGE_IO
IO-port flex page.
Definition __l4_fpage.h:237
@ L4_FPAGE_OBJ
Object flex page (capabilities).
Definition __l4_fpage.h:238
@ L4_FPAGE_SPECIAL
Special flex page, either invalid or all spaces.
Definition __l4_fpage.h:235
@ L4_FPAGE_C_NO_REF_CNT
Don't increase the reference counter.
Definition __l4_fpage.h:266
@ L4_FPAGE_C_OBJ_RIGHT1
Object-type specific right.
Definition __l4_fpage.h:268
@ L4_FPAGE_C_IPCGATE_SVR
The receiver may invoke IPC-gate-specific functions on the capability, e.g.
Definition __l4_fpage.h:278
@ L4_FPAGE_C_OBJ_RIGHT2
Object-type specific right.
Definition __l4_fpage.h:269
@ L4_FPAGE_C_OBJ_RIGHT3
Object-type specific right.
Definition __l4_fpage.h:270
@ L4_FPAGE_C_OBJ_RIGHTS
All Object-type specific right bits.
Definition __l4_fpage.h:271
@ L4_FPAGE_C_REF_CNT
Mapping is reference-counted (default).
Definition __l4_fpage.h:265
@ L4_WHOLE_ADDRESS_SPACE
Whole address space size.
Definition __l4_fpage.h:101
@ L4_CAP_FPAGE_RO
Read right for capability flex-pages.
Definition __l4_fpage.h:179
@ L4_CAP_FPAGE_R
Read right for capability flex-pages.
Definition __l4_fpage.h:178
@ L4_CAP_FPAGE_RW
Read and interface specific 'W' right for capability flex-pages.
Definition __l4_fpage.h:195
@ L4_CAP_FPAGE_W
Interface specific 'W' right for capability flex-pages.
Definition __l4_fpage.h:160
@ L4_CAP_FPAGE_RS
Read and interface specific 'S' right for capability flex-pages.
Definition __l4_fpage.h:202
@ L4_CAP_FPAGE_RWSD
Full rights for capability flex-pages.
Definition __l4_fpage.h:215
@ L4_CAP_FPAGE_RSD
Read, 'S', and delete right for capability flex-pages.
Definition __l4_fpage.h:227
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flex-pages.
Definition __l4_fpage.h:209
@ L4_CAP_FPAGE_D
Delete right for capability flex-pages.
Definition __l4_fpage.h:188
@ L4_CAP_FPAGE_S
Interface specific 'S' right for capability flex-pages.
Definition __l4_fpage.h:172
@ L4_CAP_FPAGE_RWD
Read, write, and delete right for capability flex-pages.
Definition __l4_fpage.h:221
@ L4_FPAGE_ADDR_SHIFT
Page address shift.
Definition __l4_fpage.h:62
@ L4_FPAGE_TYPE_SHIFT
Flexpage type shift (memory, IO port, obj...)
Definition __l4_fpage.h:60
@ L4_FPAGE_RIGHTS_MASK
Mask to get the flexpage rights.
Definition __l4_fpage.h:70
@ L4_FPAGE_TYPE_BITS
Flexpage type size (memory, IO port, obj...)
Definition __l4_fpage.h:65
@ L4_FPAGE_RIGHTS_BITS
Access permissions size.
Definition __l4_fpage.h:64
@ L4_FPAGE_RIGHTS_ALL
Specify as flexpage rights during grant.
Definition __l4_fpage.h:78
@ L4_FPAGE_ADDR_BITS
Page address size.
Definition __l4_fpage.h:67
@ L4_FPAGE_SIZE_BITS
Flexpage size size (log2-based)
Definition __l4_fpage.h:66
@ L4_FPAGE_RIGHTS_SHIFT
Access permissions shift.
Definition __l4_fpage.h:59
@ L4_FPAGE_SIZE_SHIFT
Flexpage size shift (log2-based)
Definition __l4_fpage.h:61
l4_addr_t l4_trunc_size(l4_addr_t address, unsigned char bits) L4_NOTHROW
Round an address down to the next lower flex page with size bits.
Definition consts.h:448
l4_umword_t l4_map_control(l4_umword_t spot, unsigned char cache, unsigned grant) L4_NOTHROW
Create the first word for a map item for the memory space.
Definition __l4_fpage.h:707
l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item for the object space.
Definition __l4_fpage.h:714
@ L4_ITEM_MAP
Identify a message item as map item.
Definition consts.h:226
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
Send-flex-page types.
Definition __l4_fpage.h:108
l4_fpage_t fpage
Source flex-page descriptor.
Definition __l4_fpage.h:110
l4_umword_t snd_base
Offset in receive window (send base)
Definition __l4_fpage.h:109
L4 flexpage type.
Definition __l4_fpage.h:85
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:87
l4_umword_t fpage
Raw value.
Definition __l4_fpage.h:86