mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 13:26:27 +00:00
Imported Genode release 11.11
This commit is contained in:
parent
6bcc9aef0e
commit
da4e1feaa5
280
LICENSE
Normal file
280
LICENSE
Normal file
@ -0,0 +1,280 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
182
README
182
README
@ -1,4 +1,180 @@
|
||||
Genode OS Framework
|
||||
|
||||
This is just the initial version without any code yet. We're on the
|
||||
way to migrate the current released version into Git.
|
||||
=================================
|
||||
Genode Operating System Framework
|
||||
=================================
|
||||
|
||||
|
||||
This is the source tree of the reference implementation of the Genode OS
|
||||
architecture. For a general overview about the architecture, please refer to
|
||||
the project's official website:
|
||||
|
||||
:Official project website for the Genode OS Framework:
|
||||
|
||||
[http://genode.org/documentation/general-overview]
|
||||
|
||||
The current implementation can be compiled for 8 different kernels: Linux,
|
||||
L4ka::Pistachio, L4/Fiasco, OKL4, NOVA, Fiasco.OC, Codezero, and a custom
|
||||
kernel for the MicroBlaze architecture. Whereas the Linux version serves us as
|
||||
development vehicle and enables us to rapidly develop the generic parts of the
|
||||
system, the actual target platforms of the framework are microkernels. There
|
||||
is no "perfect" microkernel - and neither should there be one. If a microkernel
|
||||
pretended to be fit for all use cases, it wouldn't be "micro". Hence, all
|
||||
microkernels differ in terms of their respective features, complexity, and
|
||||
supported hardware architectures.
|
||||
|
||||
Genode allows the use of each of the kernels listed above with a rich set of
|
||||
device drivers, protocol stacks, libraries, and applications in a uniform way.
|
||||
For developers, the framework provides an easy way to target multiple different
|
||||
kernels instead of tying the development to a particular kernel technology. For
|
||||
kernel developers, Genode contributes advanced workloads, stress-testing their
|
||||
kernel, and enabling a variety of application use cases that would not be
|
||||
possible otherwise. For users and system integrators, it enables the choice of
|
||||
the kernel that fits best with the requirements at hand for the particular
|
||||
usage scenario.
|
||||
|
||||
|
||||
Directory overview
|
||||
##################
|
||||
|
||||
The Genode source tree is composed of the following subdirectories:
|
||||
|
||||
:'doc':
|
||||
|
||||
This directory contains general documentation. Please consider the following
|
||||
document for a quick guide to get started with the framework:
|
||||
|
||||
! doc/getting_started.txt
|
||||
|
||||
If you are curious about the ready-to-use components that come with the
|
||||
framework, please review the components overview:
|
||||
|
||||
! doc/components.txt
|
||||
|
||||
:'base':
|
||||
|
||||
This directory contains the source-code repository of the fundamental
|
||||
frameworks and interfaces of Genode. Furthermore, it contains the generic
|
||||
parts of core.
|
||||
|
||||
:'os':
|
||||
|
||||
This directory contains the non-base OS components such as the init process,
|
||||
device drivers, and basic system services.
|
||||
|
||||
:'demo':
|
||||
|
||||
This directory contains the source-code repository of various services and
|
||||
applications that we use for demonstration purposes. For example, a graphical
|
||||
application launcher called Launchpad and the Scout tutorial browser.
|
||||
|
||||
:'base-<platform>':
|
||||
These directories contain platform-specific source-code repositories
|
||||
complementing the 'base' repository. The following platforms are supported:
|
||||
|
||||
:'linux':
|
||||
Linux kernel (both x86_32 and x86_64)
|
||||
|
||||
:'pistachio':
|
||||
L4ka::Pistachio kernel developed at University of Karlsruhe.
|
||||
See [http://genode.org/community/wiki/GenodeOnL4kaPistachio]
|
||||
|
||||
:'fiasco':
|
||||
L4/Fiasco kernel developed at University of Technology Dresden.
|
||||
See [http://genode.org/community/wiki/GenodeOnL4Fiasco]
|
||||
|
||||
:'foc':
|
||||
Fiasco.OC is a modernized version of the Fiasco microkernel with a
|
||||
completely revised kernel interface fostering capability-based
|
||||
security. It is not compatible with L4/Fiasco.
|
||||
See [http://genode.org/community/wiki/GenodeOnFiascoOC]
|
||||
|
||||
:'okl4':
|
||||
OKL4 kernel (x86_32 and ARM) developed at Open-Kernel-Labs.
|
||||
See [http://genode.org/community/wiki/GenodeOnOKL4]
|
||||
|
||||
:'nova':
|
||||
NOVA hypervisor developed at University of Technology Dresden
|
||||
See [http://genode.org/community/wiki/GenodeOnNOVA]
|
||||
|
||||
:'codezero':
|
||||
Codezero microkernel developed by B-Labs
|
||||
See [http://genode.org/community/wiki/GenodeOnCodezero]
|
||||
|
||||
:'mb':
|
||||
Support for running Genode natively on the MicroBlaze softcore CPU.
|
||||
See [http://genode.org/community/wiki/GenodeOnMicroBlaze]
|
||||
|
||||
:'host':
|
||||
Pseudo platform documenting the interface between the generic and
|
||||
platform-specific parts of the base framework. This is not a functional
|
||||
base platform.
|
||||
|
||||
:'tool':
|
||||
|
||||
Source-code management tools and scripts. Please refer to the README file
|
||||
contained in the directory.
|
||||
|
||||
:'hello_tutorial':
|
||||
|
||||
Tutorial for creating a simple client-server scenario with Genode. This
|
||||
repository includes documentation and the complete source code.
|
||||
|
||||
:'libports':
|
||||
|
||||
This source-code repository contains ports of popular open-source libraries
|
||||
to Genode, most importantly the C library. The repository contains no
|
||||
upstream source code but means to download the code and adapt it to Genode.
|
||||
For instructions about how to use this mechanism, please consult the README
|
||||
file at the top level of the repository.
|
||||
|
||||
:'linux_drivers':
|
||||
|
||||
This source-code repository contains the device driver environment for
|
||||
executing Linux device drivers natively on Genode.
|
||||
|
||||
:'dde_ipxe':
|
||||
|
||||
This source-code repository contains the device driver environment for
|
||||
executing drivers of the iPXE project.
|
||||
|
||||
:'qt4':
|
||||
|
||||
This source-code repository contains the Genode version of Qt4 framework.
|
||||
Please find more information about using Qt4 with Genode in the repository's
|
||||
'README' file.
|
||||
|
||||
:'ports':
|
||||
|
||||
This source-code repository hosts ports of 3rd-party applications to
|
||||
Genode. The repository does not contain upstream source code but provides
|
||||
a mechanism for downloading the official source distributions and adapt
|
||||
them to the Genode environment. The used mechanism is roughly the same
|
||||
as used for the 'libports' repository. Please consult 'libports/README'
|
||||
for further information.
|
||||
|
||||
:'ports-<platform>':
|
||||
|
||||
These platform-specific source-code repositories contain software that
|
||||
capitalizes special features of the respective kernel platform. I.e.,
|
||||
for the OKL4 base platform, a port of OKLinux is provided in 'ports-okl4'.
|
||||
For the Fiasco.OC platform, 'ports-foc' hosts a port of the L4Linux
|
||||
kernel. For further information, please refer to the README file at the
|
||||
top level of the respective repository.
|
||||
|
||||
:'gems':
|
||||
|
||||
This source-code repository contains Genode applications that use
|
||||
both native Genode interfaces as well as features of other high-level
|
||||
repositories, in particular shared libraries provided by 'libports'.
|
||||
|
||||
|
||||
Contact
|
||||
#######
|
||||
|
||||
The best way to get in touch with Genode developers and users is the project's
|
||||
mailing list. Please feel welcome to join in!
|
||||
|
||||
:Genode Mailing Lists:
|
||||
|
||||
[http://genode.org/community/mailing-lists]
|
||||
|
||||
|
44
base-codezero/Makefile
Normal file
44
base-codezero/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#
|
||||
# \brief Download and prepare the Codezero kernel
|
||||
# \author Norman Feske
|
||||
# \date 2011-08-05
|
||||
#
|
||||
|
||||
VERBOSE ?= @
|
||||
ECHO = @echo
|
||||
GIT_URL = git://git.l4dev.org/codezero.git
|
||||
GIT_REV = 6fa4884a5a1cf6207372f69ae01e5faa6d5a39c8
|
||||
CONTRIB_DIR = contrib
|
||||
PATCHES = $(shell find patches -name *.patch)
|
||||
|
||||
#
|
||||
# Print help information by default
|
||||
#
|
||||
help::
|
||||
|
||||
prepare: $(CONTRIB_DIR)
|
||||
|
||||
help::
|
||||
$(ECHO)
|
||||
$(ECHO) "Check out upstream source code of the Codezero kernel"
|
||||
$(ECHO)
|
||||
$(ECHO) "The source code will be located at the '$(CONTRIB_DIR)/' directory."
|
||||
$(ECHO)
|
||||
$(ECHO) "--- available commands ---"
|
||||
$(ECHO) "prepare - checkout upstream source codes"
|
||||
$(ECHO) "clean - remove upstream source codes"
|
||||
$(ECHO)
|
||||
|
||||
$(CONTRIB_DIR)/.git:
|
||||
$(VERBOSE)git clone $(GIT_URL) $(CONTRIB_DIR)
|
||||
|
||||
$(CONTRIB_DIR): $(CONTRIB_DIR)/.git
|
||||
$(VERBOSE)cd $(CONTRIB_DIR); git reset --hard $(GIT_REV)
|
||||
$(ECHO) "applying patches to '$(CONTRIB_DIR)/'"
|
||||
$(VERBOSE)for i in $(PATCHES); do patch -d $@ -p1 < $$i; done
|
||||
|
||||
.PHONY: $(CONTRIB_DIR)
|
||||
|
||||
clean::
|
||||
$(VERBOSE)rm -rf $(CONTRIB_DIR)
|
||||
|
3
base-codezero/README
Normal file
3
base-codezero/README
Normal file
@ -0,0 +1,3 @@
|
||||
This repository contains the port of Genode to the Codezero microkernel
|
||||
For instructions about using Genode with Codezero, please refer to
|
||||
'doc/codezero.txt'.
|
240
base-codezero/config/vpb926.cml
Normal file
240
base-codezero/config/vpb926.cml
Normal file
@ -0,0 +1,240 @@
|
||||
#
|
||||
# Automatically generated, don't edit
|
||||
#
|
||||
# Generated on: furnace
|
||||
# At: Fri, 05 Aug 2011 21:48:00 +0000
|
||||
# Linux version 2.6.32-33-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011
|
||||
|
||||
#
|
||||
# Codezero Microkernel Configurator
|
||||
#
|
||||
|
||||
#
|
||||
# Main architecture
|
||||
#
|
||||
CONFIG_ARCH_ARM=y
|
||||
|
||||
|
||||
#
|
||||
# ARM Architecture Configuration
|
||||
#
|
||||
|
||||
#
|
||||
# ARM Platform Type
|
||||
#
|
||||
CONFIG_PLATFORM_PB926=y
|
||||
CONFIG_PLATFORM_PBA9=n
|
||||
CONFIG_PLATFORM_BEAGLE=n
|
||||
CONFIG_PLATFORM_EB=n
|
||||
|
||||
|
||||
#
|
||||
# ARM Processor Type
|
||||
#
|
||||
CONFIG_CPU_ARM926=y
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Generic Processor Properties
|
||||
#
|
||||
CONFIG_ICACHE_DISABLE=n
|
||||
CONFIG_DCACHE_DISABLE=n
|
||||
|
||||
|
||||
#
|
||||
# Generic Kernel Properties
|
||||
#
|
||||
CONFIG_PREEMPT_DISABLE=n
|
||||
CONFIG_DEBUG_ACCOUNTING=n
|
||||
CONFIG_DEBUG_SPINLOCKS=n
|
||||
CONFIG_SCHED_TICKS=1000
|
||||
|
||||
|
||||
#
|
||||
# Toolchain Prefix
|
||||
#
|
||||
CONFIG_TOOLCHAIN_USERSPACE="arm-none-linux-gnueabi-"
|
||||
CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-"
|
||||
|
||||
|
||||
#
|
||||
# Container Setup
|
||||
#
|
||||
CONFIG_CAPABILITIES=n
|
||||
CONFIG_CONTAINERS=1
|
||||
|
||||
#
|
||||
# Container 0 Parameters
|
||||
#
|
||||
|
||||
#
|
||||
# Container 0 Type
|
||||
#
|
||||
CONFIG_CONT0_TYPE_BAREMETAL=y
|
||||
CONFIG_CONT0_TYPE_POSIX=n
|
||||
CONFIG_CONT0_TYPE_LINUX=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Options
|
||||
#
|
||||
CONFIG_CONT0_OPT_NAME="empty0"
|
||||
|
||||
#
|
||||
# Baremetal Project Type
|
||||
#
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_EMPTY=y
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_HELLO_WORLD=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_THREADS_DEMO=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_TEST_SUITE=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_UART_SERVICE=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_TIMER_SERVICE=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_KMI_SERVICE=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_MUTEX_DEMO=n
|
||||
CONFIG_CONT0_BAREMETAL_PROJ_IPC_DEMO=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Pager Linker Parameters
|
||||
#
|
||||
CONFIG_CONT0_PAGER_LMA=0x40000
|
||||
CONFIG_CONT0_PAGER_VMA=0x100000
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Pager Physical Memory Regions (Capabilities)
|
||||
#
|
||||
CONFIG_CONT0_PAGER_PHYSMEM_REGIONS=1
|
||||
CONFIG_CONT0_PAGER_PHYS0_START=0x40000
|
||||
CONFIG_CONT0_PAGER_PHYS0_END=0x4000000
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Pager Virtual Memory Regions (Capabilities)
|
||||
#
|
||||
CONFIG_CONT0_PAGER_VIRTMEM_REGIONS=1
|
||||
CONFIG_CONT0_PAGER_VIRT0_START=0x0
|
||||
CONFIG_CONT0_PAGER_VIRT0_END=0x50000000
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Pager Capabilities
|
||||
#
|
||||
|
||||
#
|
||||
# Container 0 Thread Pool Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_THREADPOOL_USE=y
|
||||
CONFIG_CONT0_PAGER_CAP_THREADPOOL_SIZE=64
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Space Pool Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_SPACEPOOL_USE=y
|
||||
CONFIG_CONT0_PAGER_CAP_SPACEPOOL_SIZE=64
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Mutex Pool Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_USE=y
|
||||
CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_SIZE=100
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Map Pool Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_MAPPOOL_USE=y
|
||||
CONFIG_CONT0_PAGER_CAP_MAPPOOL_SIZE=800
|
||||
|
||||
|
||||
#
|
||||
# Container 0 IPC Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_IPC_USE=y
|
||||
CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER=y
|
||||
CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
|
||||
CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER=n
|
||||
CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_PAGER=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 IRQ Control Capability
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_IRQCTRL_USE=y
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Custom Capability 0 Parameters
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_CUSTOM0_USE=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Custom Capability 1 Parameters
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_CUSTOM1_USE=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Custom Capability 2 Parameters
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_CUSTOM2_USE=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Custom Capability 3 Parameters
|
||||
#
|
||||
CONFIG_CONT0_PAGER_CAP_CUSTOM3_USE=n
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Global Capabilities
|
||||
#
|
||||
|
||||
#
|
||||
# Container 0 IPC Capability
|
||||
#
|
||||
CONFIG_CONT0_CAP_IPC_USE=y
|
||||
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y
|
||||
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
|
||||
CONFIG_CONT0_CAP_IPC_TARGET_OTHER_CONTAINER=n
|
||||
CONFIG_CONT0_CAP_IPC_TARGET_OTHER_PAGER=n
|
||||
|
||||
|
||||
#
|
||||
# Container 0 Mutex Pool Capability
|
||||
#
|
||||
CONFIG_CONT0_CAP_MUTEXPOOL_USE=y
|
||||
CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Derived symbols
|
||||
#
|
||||
CONFIG_CONT3_START_PC_ADDR=0xd0000000
|
||||
CONFIG_DEBUG_PERFMON_KERNEL=n
|
||||
CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000
|
||||
CONFIG_CONT2_START_PC_ADDR=0xc0000000
|
||||
CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000
|
||||
CONFIG_RAM_BASE_PLAT=0
|
||||
CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000
|
||||
CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000
|
||||
CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000
|
||||
CONFIG_SUBARCH_V5=y
|
||||
CONFIG_SUBARCH_V7=n
|
||||
CONFIG_SUBARCH_V6=n
|
||||
CONFIG_CONT0_PAGER_LOAD_ADDR=0x40000
|
||||
CONFIG_CONT0_PAGER_VIRT_ADDR=0x100000
|
||||
CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000
|
||||
CONFIG_CONT0_START_PC_ADDR=0x100000
|
||||
CONFIG_CONT1_START_PC_ADDR=0xb0000000
|
||||
#
|
||||
# That's all, folks!
|
274
base-codezero/doc/codezero.txt
Normal file
274
base-codezero/doc/codezero.txt
Normal file
@ -0,0 +1,274 @@
|
||||
|
||||
==================================
|
||||
Genode on the Codezero microkernel
|
||||
==================================
|
||||
|
||||
|
||||
Norman Feske
|
||||
|
||||
|
||||
Codezero is a microkernel primarily targeted at ARM-based embedded systems.
|
||||
It is developed by the British company B-Labs.
|
||||
|
||||
:B-Labs website:
|
||||
|
||||
[http://b-labs.co.uk]
|
||||
|
||||
The Codezero kernel was first made publicly available in summer 2009. The
|
||||
latest version, documentation, and community resources are available at the
|
||||
project website:
|
||||
|
||||
:Codezero project website:
|
||||
|
||||
[http://l4dev.org]
|
||||
|
||||
As highlighted by the name of the project website, the design of the kernel is
|
||||
closely related to the family of L4 microkernels. In short, the kernel provides
|
||||
a minimalistic set of functionality for managing address spaces, threads, and
|
||||
communication between threads, but leaves complicated policy and device access
|
||||
to user-level components.
|
||||
|
||||
|
||||
Using Genode with Codezero
|
||||
##########################
|
||||
|
||||
For using Codezero, please ensure to have Git, SCons, and Python installed as
|
||||
these tools are required for downloading and building the kernel. Furthermore,
|
||||
you will need to install the tool chain for ARM. For instructions on how to
|
||||
download and install the tool chain, please refer to:
|
||||
|
||||
:[http://genode.org/download/tool-chain]:
|
||||
Genode tool-chain
|
||||
|
||||
To download the Codezero kernel and integrate it with Genode, issue
|
||||
|
||||
! make prepare
|
||||
|
||||
from the 'base-codezero/' directory. The Codezero kernel is fully supported by
|
||||
Genode's run mechanism. Therefore, you can run Genode scenarios using Qemu
|
||||
directly from the build directory. For a quick test, let's create a build
|
||||
directory for Codezero on the VersatilePB926 platform using Genode's
|
||||
'create_builddir' tool:
|
||||
|
||||
! <genode-dir>/tool/create_builddir codezero_vpb926 BUILD_DIR=<build_dir>
|
||||
|
||||
To execute the graphical Genode demo, change to the new created build directory
|
||||
and issue:
|
||||
|
||||
! make run/demo
|
||||
|
||||
|
||||
Characteristics of the kernel
|
||||
#############################
|
||||
|
||||
To put Codezero in relation to other L4 kernels, here is a quick summary on the
|
||||
most important design aspects as implemented with the version 0.3, and on how
|
||||
our port of Genode relates to them:
|
||||
|
||||
* In the line of the original L4 interface, the kernel uses global name spaces
|
||||
for kernel objects such as threads and address spaces.
|
||||
|
||||
* For the interaction between a user thread and the kernel, the concept of
|
||||
user-level thread-control blocks (UTCB) is used. A UTCB is a small
|
||||
thread-specific region in the thread's virtual address space, which is
|
||||
always mapped. Hence the access to the UTCB can never raise a page fault,
|
||||
which makes it perfect for the kernel to access system-call arguments,
|
||||
in particular IPC payload copied from/to user threads. In contrast to other
|
||||
L4 kernels, the location of UTCBs within the virtual address space is managed
|
||||
by the user land.
|
||||
|
||||
On Genode, core keeps track of the UTCB locations for all user threads.
|
||||
This way, the physical backing store for the UTCB can be properly accounted
|
||||
to the corresponding protection domain.
|
||||
|
||||
* The kernel provides three kinds of synchronous inter-process communication
|
||||
(IPC): Short IPC carries payload in CPU registers only. Full IPC copies
|
||||
message payload via the UTCBs of the communicating parties. Extended IPC
|
||||
transfers a variable-sized message from/to arbitrary locations of the
|
||||
sender/receiver address spaces. During an extended IPC, page fault may
|
||||
occur.
|
||||
|
||||
Genode solely relies on extended IPC, leaving the other IPC mechanisms to
|
||||
future optimizations.
|
||||
|
||||
* The scheduling of threads is based on hard priorities. Threads with the
|
||||
same priority are executed in a round-robin fashion. The kernel supports
|
||||
time-slice-based preemption.
|
||||
|
||||
Genode does not support Codezero priorities yet.
|
||||
|
||||
* The original L4 interface leaves open the question on how to manage
|
||||
and account kernel resources such as the memory used for page tables.
|
||||
Codezero makes the accounting of such resources explicit, enables the
|
||||
user-land to manage them in a responsible way, and prevent kernel-resource
|
||||
denial-of-service problems.
|
||||
|
||||
* In contrast to the original L4.v2 and L4.x0 interfaces, the kernel provides
|
||||
no time source in the form of IPC timeouts to the user land. A time source
|
||||
must be provided by a user-space timer driver. Genode employs such a timer
|
||||
services on all platforms so that it is not effected by this limitation.
|
||||
|
||||
In several ways, Codezero goes beyond the known L4 interfaces. The most
|
||||
noticeable addition is the support for so-called containers. A container is
|
||||
similar to a virtual machine. It is an execution environment that holds a set
|
||||
of physical resources such as RAM and devices. The number of containers and the
|
||||
physical resources assigned to them is static and is to be defined at build
|
||||
time. The code executed inside a container can be roughly classified into two
|
||||
cases. First, there are static programs that require strong isolation from the
|
||||
rest of the system but no classical operating-system infrastructure, for
|
||||
example special-purpose telecommunication stacks or cryptographic functionality
|
||||
of an embedded device. Second, there a kernel-like workload, which use the L4
|
||||
interface to substructure the container into address spaces, for example a
|
||||
paravirtualized Linux kernel that uses Codezero address spaces to protect Linux
|
||||
processes. Genode runs inside a container and facilitates Codezero's L4
|
||||
interface to implement its multi-server architecture.
|
||||
|
||||
|
||||
Behind the scenes
|
||||
#################
|
||||
|
||||
The 'make prepare' mechanism checks out the kernel source code from the
|
||||
upstream Git repository to 'base-codezero/contrib'. When building the kernel
|
||||
from within a Genode build directory via 'make kernel', this directory won't be
|
||||
touched by the Genode build system. Instead, a snapshot of the 'contrib'
|
||||
directory is taken to '<build-dir>/kernel/codezero'. This is the place where
|
||||
the Codezero configuration and build processes are executed. By working with a
|
||||
build-directory-local snapshot, we ensure that the source tree remains
|
||||
untouched at all times. After having taken the snapshot, the Codezero kernel is
|
||||
configured using a configuration template specific for the hardware platform.
|
||||
The configuration comes in the form of a CML file located at
|
||||
'base-codezero/config/'. There is one CML file per supported platform named
|
||||
'<platform>.cml'. The configured Codezero build directory will reside at
|
||||
'<build-dir>/kernel/codezero/build/'. Finally, the Codezero build system is
|
||||
invoked to build the kernel.
|
||||
|
||||
The two stages of building Codezero
|
||||
===================================
|
||||
|
||||
The Codezero build system always performs the compilation of the kernel and the
|
||||
so-called containers as well as the integration of all these components into a
|
||||
final ELF image as one operation. When building just the kernel via 'make
|
||||
kernel', the final image will contain the default container0 that comes with
|
||||
the Codezero distribution. For integrating Genode into the final image, the
|
||||
content of the container0 must be replaced by the Genode binaries followed by
|
||||
another execution of 'kernel/codezero/build.py'. Now, the single-image will be
|
||||
re-created, including the Genode binaries. When using Genode's run mechanism,
|
||||
these steps are automated for you. For reference, please review the Codezero
|
||||
run environment at 'base-codezero/run/env'.
|
||||
|
||||
By first building the kernel with Codezero's default container ('make kernel')
|
||||
and later replacing the container's content with Genode binaries, we
|
||||
optimize the work flow for building Genode components. The kernel is compiled
|
||||
only once, but the (quick) re-linking of the final image is done every time a
|
||||
run script is executed.
|
||||
|
||||
In the run environment, you will see that we forcefully remove a file called
|
||||
'cinfo.c' from the build-directory-local snapshot of the Codezero source tree.
|
||||
This file is generated automatically by the Codezero build system and linked
|
||||
against the kernel. It contains the parameters of the containers executed on
|
||||
the kernel. Because we change the content of container0 each time when
|
||||
executing a run script, those parameter change. So we have to enforce to
|
||||
re-generation of the 'cinfo.c' file.
|
||||
|
||||
How Genode ROM modules are passed into the final image
|
||||
======================================================
|
||||
|
||||
The Codezero build system picks up any ELF files residing the container's
|
||||
directory wheres the file called 'main.elf' is considered to be the roottask
|
||||
(in Codezero speak called pager) of the container. For Genode, 'main.elf'
|
||||
corresponds to the core executable. All other boot modules are merged into an
|
||||
ELF file, which we merely use as a container for these binary data. This ELF
|
||||
file is linked such that it gets loaded directly after the core image (this is
|
||||
how core finds the boot modules). The process of archiving all boot modules
|
||||
into the single ELF file is automated via the 'base-codezero/tool/gen_romfs'
|
||||
tool. In the container's directory, the merged file is called 'modules.elf'.
|
||||
|
||||
Adapting the source code of the kernel
|
||||
======================================
|
||||
|
||||
For debugging and development you might desire to change the kernel code
|
||||
at times. You can safely do so within the 'base-codezero/contrib/' directory.
|
||||
When issuing the next 'make kernel' from the Genode build directory, your
|
||||
changes will be picked up. However, when working with run scripts, the kernel
|
||||
is not revisited each time. The kernel gets built only once if the
|
||||
'<build-dir>/kernel' directory does not exist, yet. If you work on the kernel
|
||||
source tree and wish to conveniently test the kernel with a run script, use
|
||||
|
||||
! make kernel run/<run-script>
|
||||
|
||||
This way, you make sure to rebuild the kernel prior executing the steps
|
||||
described in the run script.
|
||||
|
||||
Tweaking the kernel configuration
|
||||
=================================
|
||||
|
||||
The kernel configuration can be tweaked within '<build-dir>/kernel/codezero'.
|
||||
Just change to this directory and issue './build.py -C'. The next time you
|
||||
build the kernel via 'make kernel' your configuration will be applied.
|
||||
If you want to conserve your custom configuration, just copy the file
|
||||
'<build-dir>/kernel/codezero/build/config.cml'.
|
||||
|
||||
Parameters of 'vpb926.cml' explained
|
||||
====================================
|
||||
|
||||
The default configuration for the VersatilePB926 platform as found at
|
||||
'base-codzero/config/vpb926.cml' is paramaterized as follows:
|
||||
|
||||
:Default pager parameters:
|
||||
! 0x40000 Pager LMA
|
||||
! 0x100000 Pager VMA
|
||||
These values are important because they are currently hard-wired in the
|
||||
linker script used by Genode. If you need to adopt these values, make
|
||||
sure to also update the Genode linker script located at
|
||||
'base-codezero/src/platform/genode.ld'.
|
||||
|
||||
:Physical Memory Regions:
|
||||
! 1 Number of Physical Regions
|
||||
! 0x40000 Physical Region 0 Start Address
|
||||
! 0x4000000 Physical Region 0 End Address
|
||||
We only use 64MB of memory. The physical memory between 0 and 0x40000 is
|
||||
used by the kernel.
|
||||
|
||||
:Virtual Memory Regions:
|
||||
! 1 Number of Virtual Regions
|
||||
! 0x0 Virtual Region 0 Start Address
|
||||
! 0x50000000 Virtual Region 0 End Address
|
||||
It is important to choose the end address such that the virtual memory
|
||||
covers the thread context area. The context area is defined at
|
||||
'base/include/base/thread.h'.
|
||||
|
||||
|
||||
Limitations
|
||||
###########
|
||||
|
||||
At the current stage, the Genode version for Codezero is primarily geared
|
||||
towards the developers of Codezero as a workload to stress their kernel. It
|
||||
still has a number of limitations that would affect the real-world use:
|
||||
|
||||
* Because the only platform supported out of the box by the official Codezero
|
||||
source tree is the ARM-based Versatilebp board, Genode is currently tied to
|
||||
this hardware platform.
|
||||
|
||||
* The current timer driver at 'os/src/drivers/timer/codezero/' is a dummy
|
||||
driver that just yields the CPU time instead of blocking. Is is not
|
||||
suitable as time source.
|
||||
|
||||
* The PL110 framebuffer driver at 'os/src/drivers/framebuffer/pl110/'
|
||||
does only support the LCD display as provided by Qemu but it is not tested on
|
||||
real hardware.
|
||||
|
||||
* Even though Codezero provides priority-based scheduling, Genode does not
|
||||
allow assigning priorities to Codezero processes, yet.
|
||||
|
||||
As always, these limitations will be addressed as needed.
|
||||
|
||||
|
||||
Thanks
|
||||
######
|
||||
|
||||
We want to thank the main developer of Codezero Bahadir Balban for his great
|
||||
responsiveness to our feature requests and questions. Without his help, the
|
||||
porting effort would have taken much more effort. We hope that our framework
|
||||
will be of value to the Codezero community.
|
||||
|
||||
|
1
base-codezero/etc/specs.conf
Normal file
1
base-codezero/etc/specs.conf
Normal file
@ -0,0 +1 @@
|
||||
SPECS = genode
|
33
base-codezero/include/arm/cpu/atomic.h
Normal file
33
base-codezero/include/arm/cpu/atomic.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* \brief Atomic operations for ARM on codezero
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__ARM__CPU__ATOMIC_H_
|
||||
#define _INCLUDE__ARM__CPU__ATOMIC_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Atomic compare and exchange
|
||||
*
|
||||
* This function compares the value at dest with cmp_val.
|
||||
* If both values are equal, dest is set to new_val. If
|
||||
* both values are different, the value at dest remains
|
||||
* unchanged.
|
||||
*
|
||||
* \return 1 if the value was successfully changed to new_val,
|
||||
* 0 if cmp_val and the value at dest differ.
|
||||
*/
|
||||
int cmpxchg(volatile int *dest, int cmp_val, int new_val);
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__ARM__CPU__ATOMIC_H_ */
|
63
base-codezero/include/base/ipc_msgbuf.h
Normal file
63
base-codezero/include/base/ipc_msgbuf.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* \brief IPC message buffer
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
#define _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* IPC message buffer layout
|
||||
*/
|
||||
class Msgbuf_base
|
||||
{
|
||||
protected:
|
||||
|
||||
size_t _size;
|
||||
char _msg_start[]; /* symbol marks start of message */
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* Begin of actual message buffer
|
||||
*/
|
||||
char buf[];
|
||||
|
||||
/**
|
||||
* Return size of message buffer
|
||||
*/
|
||||
inline size_t size() const { return _size; };
|
||||
|
||||
/**
|
||||
* Return address of message buffer
|
||||
*/
|
||||
inline void *addr() { return &_msg_start[0]; };
|
||||
|
||||
} __attribute__((aligned(4)));
|
||||
|
||||
/**
|
||||
* Instance of IPC message buffer with specified buffer size
|
||||
*/
|
||||
template <unsigned BUF_SIZE>
|
||||
class Msgbuf : public Msgbuf_base
|
||||
{
|
||||
public:
|
||||
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
Msgbuf() { _size = BUF_SIZE; }
|
||||
|
||||
} __attribute__((aligned(4)));
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */
|
169
base-codezero/include/base/ipc_pager.h
Normal file
169
base-codezero/include/base/ipc_pager.h
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* \brief Dummy pager support for Genode
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_PAGER_H_
|
||||
#define _INCLUDE__BASE__IPC_PAGER_H_
|
||||
|
||||
#include <base/ipc.h>
|
||||
#include <base/stdint.h>
|
||||
#include <base/native_types.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Mapping
|
||||
{
|
||||
private:
|
||||
|
||||
addr_t _from_phys_addr;
|
||||
addr_t _to_virt_addr;
|
||||
size_t _num_pages;
|
||||
bool _writeable;
|
||||
|
||||
enum { PAGE_SIZE_LOG2 = 12 };
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Mapping(addr_t dst_addr, addr_t src_addr,
|
||||
bool write_combined, unsigned l2size = PAGE_SIZE_LOG2,
|
||||
bool rw = true)
|
||||
:
|
||||
_from_phys_addr(src_addr),
|
||||
_to_virt_addr(dst_addr),
|
||||
_num_pages(1 << (l2size - PAGE_SIZE_LOG2)),
|
||||
_writeable(rw)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Construct invalid mapping
|
||||
*/
|
||||
Mapping() : _num_pages(0) { }
|
||||
|
||||
/**
|
||||
* Prepare map operation
|
||||
*
|
||||
* No preparations are needed on Codezero because all mapping
|
||||
* originate from the physical address space.
|
||||
*/
|
||||
void prepare_map_operation() { }
|
||||
|
||||
addr_t from_phys() const { return _from_phys_addr; }
|
||||
addr_t to_virt() const { return _to_virt_addr; }
|
||||
size_t num_pages() const { return _num_pages; }
|
||||
bool writeable() const { return _writeable; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Special paging server class
|
||||
*/
|
||||
class Ipc_pager : public Native_capability
|
||||
{
|
||||
private:
|
||||
|
||||
Native_thread_id _last; /* faulted thread */
|
||||
addr_t _pf_addr; /* page-fault address */
|
||||
addr_t _pf_ip; /* instruction pointer of faulter */
|
||||
bool _pf_write; /* true on write fault */
|
||||
|
||||
Mapping _reply_mapping;
|
||||
|
||||
// protected:
|
||||
//
|
||||
// /**
|
||||
// * Wait for pagefault
|
||||
// */
|
||||
// void _wait();
|
||||
//
|
||||
// /**
|
||||
// * Send page-fault reply and wait for next page fault
|
||||
// */
|
||||
// void _reply_and_wait();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ipc_pager();
|
||||
|
||||
/**
|
||||
* Wait for a new page fault received as short message IPC
|
||||
*/
|
||||
void wait_for_fault();
|
||||
|
||||
/**
|
||||
* Reply current page-fault and wait for a new one
|
||||
*/
|
||||
void reply_and_wait_for_fault();
|
||||
|
||||
/**
|
||||
* Request instruction pointer of current page fault
|
||||
*/
|
||||
addr_t fault_ip() { return _pf_ip; }
|
||||
|
||||
/**
|
||||
* Request fault address of current page fault
|
||||
*/
|
||||
addr_t fault_addr() { return _pf_addr; }
|
||||
|
||||
/**
|
||||
* Set parameters for next reply
|
||||
*/
|
||||
void set_reply_mapping(Mapping m) { _reply_mapping = m; }
|
||||
|
||||
/**
|
||||
* Set destination for next reply
|
||||
*/
|
||||
void set_reply_dst(Native_capability pager_object) {
|
||||
_last = pager_object.local_name(); }
|
||||
|
||||
/**
|
||||
* Answer call without sending a mapping
|
||||
*
|
||||
* This function is used to acknowledge local calls from one of
|
||||
* core's region-manager sessions.
|
||||
*/
|
||||
void acknowledge_wakeup();
|
||||
|
||||
/**
|
||||
* Return thread ID of last faulter
|
||||
*/
|
||||
Native_thread_id last() const { return _last; }
|
||||
|
||||
/**
|
||||
* Return badge for faulting thread
|
||||
*/
|
||||
unsigned long badge() const { return _last.tid; }
|
||||
|
||||
/**
|
||||
* Return true if page fault was a write fault
|
||||
*/
|
||||
bool is_write_fault() const { return _pf_write; }
|
||||
|
||||
/**
|
||||
* Return true if last fault was an exception
|
||||
*/
|
||||
bool is_exception() const
|
||||
{
|
||||
/*
|
||||
* Reflection of exceptions is not supported on this platform.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */
|
143
base-codezero/include/base/native_types.h
Normal file
143
base-codezero/include/base/native_types.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* \brief Dummy definitions for native types used for compiling unit tests
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
namespace Codezero {
|
||||
|
||||
struct l4_mutex;
|
||||
|
||||
enum { NILTHREAD = -1 };
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
struct Native_thread_id
|
||||
{
|
||||
int tid;
|
||||
|
||||
/**
|
||||
* Pointer to thread's running lock
|
||||
*
|
||||
* Once initialized (see 'lock_helper.h'), it will point to the
|
||||
* '_running_lock' field of the thread's 'Native_thread' structure,
|
||||
* which is part of the thread context. This member variable is
|
||||
* used by the lock implementation only.
|
||||
*/
|
||||
struct Codezero::l4_mutex *running_lock;
|
||||
|
||||
Native_thread_id() { }
|
||||
|
||||
/**
|
||||
* Constructor (used as implicit constructor)
|
||||
*/
|
||||
Native_thread_id(int l4id) : tid(l4id), running_lock(0) { }
|
||||
|
||||
Native_thread_id(int l4id, Codezero::l4_mutex *rl) : tid(l4id), running_lock(rl) { }
|
||||
};
|
||||
|
||||
struct Native_thread
|
||||
{
|
||||
Native_thread_id l4id;
|
||||
|
||||
/**
|
||||
* Only used in core
|
||||
*
|
||||
* For 'Thread' objects created within core, 'pt' points to the
|
||||
* physical thread object, which is going to be destroyed on
|
||||
* destruction of the 'Thread'.
|
||||
*/
|
||||
Platform_thread *pt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Empty UTCB type expected by the thread library
|
||||
*
|
||||
* On this kernel, UTCBs are not placed within the the context area. Each
|
||||
* thread can request its own UTCB pointer using the kernel interface.
|
||||
* However, we use the 'Native_utcb' member of the thread context to
|
||||
* hold thread-specific data, i.e. the running lock used by the lock
|
||||
* implementation.
|
||||
*/
|
||||
struct Native_utcb
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Prevent construction
|
||||
*
|
||||
* A UTCB is never constructed, it is backed by zero-initialized memory.
|
||||
*/
|
||||
Native_utcb();
|
||||
|
||||
/**
|
||||
* Backing store for per-thread running lock
|
||||
*
|
||||
* The size of this member must equal 'sizeof(Codezero::l4_mutex)'.
|
||||
* Unfortunately, we cannot include the Codezero headers here.
|
||||
*/
|
||||
int _running_lock;
|
||||
|
||||
public:
|
||||
|
||||
Codezero::l4_mutex *running_lock() {
|
||||
return (Codezero::l4_mutex *)&_running_lock; }
|
||||
};
|
||||
|
||||
inline bool operator == (Native_thread_id t1, Native_thread_id t2) { return t1.tid == t2.tid; }
|
||||
inline bool operator != (Native_thread_id t1, Native_thread_id t2) { return t1.tid != t2.tid; }
|
||||
|
||||
/*
|
||||
* Because Codezero does not support local names for capabilities, a Genode
|
||||
* capability consists of the global thread ID and a global object ID, not
|
||||
* protected by the kernel when transmitted as IPC payloads.
|
||||
*/
|
||||
class Native_capability
|
||||
{
|
||||
private:
|
||||
|
||||
Native_thread_id _tid; /* global thread ID */
|
||||
int _local_name; /* global unique object ID */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor creates invalid capability
|
||||
*/
|
||||
Native_capability()
|
||||
: _local_name(0) { _tid.tid = Codezero::NILTHREAD; }
|
||||
|
||||
/**
|
||||
* Constructor for hand-crafting capabilities
|
||||
*
|
||||
* This constructor is only used internally be the framework.
|
||||
*/
|
||||
Native_capability(Native_thread_id tid, int local_name)
|
||||
: _tid(tid), _local_name(local_name) { }
|
||||
|
||||
bool valid() const { return _tid.tid != Codezero::NILTHREAD; }
|
||||
|
||||
int local_name() const { return _local_name; }
|
||||
int dst() const { return _tid.tid; }
|
||||
|
||||
Native_thread_id tid() const { return _tid; }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */
|
0
base-codezero/include/codezero/dummies/stdio.h
Normal file
0
base-codezero/include/codezero/dummies/stdio.h
Normal file
0
base-codezero/include/codezero/dummies/string.h
Normal file
0
base-codezero/include/codezero/dummies/string.h
Normal file
76
base-codezero/include/codezero/syscalls.h
Normal file
76
base-codezero/include/codezero/syscalls.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* \brief Aggregate Codezero syscall bindings
|
||||
* \author Norman Feske
|
||||
* \date 2010-02-16
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__CODEZERO__SYSCALLS_H_
|
||||
#define _INCLUDE__CODEZERO__SYSCALLS_H_
|
||||
|
||||
/*
|
||||
* Codezero headers happen to include the compiler's 'stdarg.h'. If this
|
||||
* happened within the 'Codezero' namespace below, we would not be able to
|
||||
* include 'stdarg.h' later on into the root namespace (stdarg's include guards
|
||||
* would prevent this. Therefore, we make sure to include the file into the
|
||||
* root namespace prior processing any Codezero headers.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
namespace Codezero { extern "C" {
|
||||
|
||||
/* make Codezero includes happy */
|
||||
extern char *strncpy(char *dest, const char *src, __SIZE_TYPE__);
|
||||
extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__);
|
||||
|
||||
/*
|
||||
* Work around the problem of C++ keywords being used as
|
||||
* argument names in the Codezero API headers.
|
||||
*/
|
||||
#define new _new_
|
||||
#define virtual _virtual_
|
||||
#define printf(A, ...)
|
||||
|
||||
#include <l4lib/macros.h>
|
||||
#include <l4lib/arch/arm/syscalls.h>
|
||||
#include <l4lib/arch/arm/syslib.h>
|
||||
#include <l4lib/ipcdefs.h>
|
||||
#include <l4lib/init.h>
|
||||
#include <l4lib/mutex.h>
|
||||
#include <l4/api/thread.h>
|
||||
#include <l4/api/irq.h>
|
||||
#include <l4lib/exregs.h>
|
||||
#include <l4/lib/list.h> /* needed for capability.h */
|
||||
#include <l4/generic/capability.h>
|
||||
#include <l4/generic/cap-types.h>
|
||||
#include <l4/arch/arm/exception.h>
|
||||
#include <l4/arch/arm/io.h>
|
||||
|
||||
#undef new
|
||||
#undef virtual
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#undef printf
|
||||
} }
|
||||
|
||||
namespace Codezero {
|
||||
|
||||
/**
|
||||
* Return thread ID of the calling thread
|
||||
*/
|
||||
inline int thread_myself()
|
||||
{
|
||||
struct task_ids ids = { 0, 0, 0 };
|
||||
l4_getid(&ids);
|
||||
return ids.tid;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__CODEZERO__SYSCALLS_H_ */
|
9
base-codezero/lib/mk/arm/startup.mk
Normal file
9
base-codezero/lib/mk/arm/startup.mk
Normal file
@ -0,0 +1,9 @@
|
||||
LIBS = cxx lock l4
|
||||
SRC_S = crt0.s
|
||||
SRC_CC = _main.cc
|
||||
INC_DIR += $(REP_DIR)/src/platform
|
||||
INC_DIR += $(BASE_DIR)/src/platform
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath crt0.s $(BASE_DIR)/src/platform/arm
|
||||
vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc))
|
3
base-codezero/lib/mk/arm_v5/l4.mk
Normal file
3
base-codezero/lib/mk/arm_v5/l4.mk
Normal file
@ -0,0 +1,3 @@
|
||||
LIBS += l4_arm_v5
|
||||
|
||||
include $(REP_DIR)/lib/mk/l4.inc
|
9
base-codezero/lib/mk/arm_v5/l4_arm_v5.mk
Normal file
9
base-codezero/lib/mk/arm_v5/l4_arm_v5.mk
Normal file
@ -0,0 +1,9 @@
|
||||
LIBL4_DIR = $(CODEZERO_DIR)/conts/userlibs/libl4
|
||||
|
||||
INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libc/include
|
||||
|
||||
SRC_C += $(notdir $(wildcard $(LIBL4_DIR)/src/arch/arm/v5/*.c))
|
||||
SRC_S += $(notdir $(wildcard $(LIBL4_DIR)/src/arch/arm/v5/*.S))
|
||||
|
||||
vpath %.c $(LIBL4_DIR)/src/arch/arm/v5
|
||||
vpath %.S $(LIBL4_DIR)/src/arch/arm/v5
|
3
base-codezero/lib/mk/codezero_cml.inc
Normal file
3
base-codezero/lib/mk/codezero_cml.inc
Normal file
@ -0,0 +1,3 @@
|
||||
ifeq ($(filter-out $(SPECS),platform_vpb926),)
|
||||
CODEZERO_CML = $(REP_DIR)/config/vpb926.cml
|
||||
endif
|
13
base-codezero/lib/mk/cxx.mk
Normal file
13
base-codezero/lib/mk/cxx.mk
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Additional symbols we need to keep when using the arm-none-linux-gnueabi
|
||||
# tool chain
|
||||
#
|
||||
KEEP_SYMBOLS += __aeabi_ldivmod __aeabi_uldivmod __dynamic_cast
|
||||
KEEP_SYMBOLS += _ZN10__cxxabiv121__vmi_class_type_infoD0Ev
|
||||
|
||||
#
|
||||
# Override sources of the base repository with our changed version
|
||||
#
|
||||
vpath exception.cc $(REP_DIR)/src/base/cxx
|
||||
|
||||
include $(BASE_DIR)/lib/mk/cxx.mk
|
4
base-codezero/lib/mk/ipc.mk
Normal file
4
base-codezero/lib/mk/ipc.mk
Normal file
@ -0,0 +1,4 @@
|
||||
SRC_CC = ipc.cc pager.cc
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/base/ipc
|
43
base-codezero/lib/mk/l4.inc
Normal file
43
base-codezero/lib/mk/l4.inc
Normal file
@ -0,0 +1,43 @@
|
||||
LIBL4_DIR = $(CODEZERO_DIR)/conts/userlibs/libl4
|
||||
|
||||
SRC_C += init.c irq.c mutex.c
|
||||
SRC_C += arch/arm/exregs.c
|
||||
SRC_S += $(addprefix arch/arm/,syscalls.S new_thread.S)
|
||||
SRC_C += $(addprefix lib/,addr.c bit.c idpool.c)
|
||||
SRC_C += $(addprefix lib/thread/,init.c thread.c)
|
||||
SRC_C += $(addprefix lib/cap/,cap.c read.c)
|
||||
|
||||
INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libc/include
|
||||
INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libmem/include
|
||||
INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libmem
|
||||
|
||||
vpath % $(LIBL4_DIR)/src
|
||||
|
||||
#
|
||||
# The libl4 source files uses macros defined in macros.h but do not
|
||||
# explicitly include the 'macros.h' header file.
|
||||
#
|
||||
CC_OPT += -include $(LIBL4_DIR)/include/l4lib/macros.h
|
||||
|
||||
#
|
||||
# Resolve conflicts with built-in functions
|
||||
#
|
||||
CC_OPT += -fno-builtin-pow
|
||||
|
||||
#
|
||||
# During the compilation of the libl4 file 'thread.c', the 'l4id_t' type
|
||||
# is used without prior inclusion of 'types.h'. Furthermore, 'types.h'
|
||||
# has a wrong include guard, so we take care of this problem using a
|
||||
# wrapper.
|
||||
#
|
||||
CC_OPT_lib_thread_thread += -include fix_include_types.h
|
||||
CC_OPT_arch_arm_exregs += -include fix_include_types.h
|
||||
|
||||
lib/thread/thread.o arch/arm/exregs.o: fix_include_types.h
|
||||
|
||||
fix_include_types.h:
|
||||
@echo "#include <l4lib/arch/arm/types.h>" > $@
|
||||
@echo "#define __L4LIB_ARM_TYPES_H___" >> $@
|
||||
|
||||
CC_OPT += -std=gnu99
|
||||
|
7
base-codezero/lib/mk/lock.mk
Normal file
7
base-codezero/lib/mk/lock.mk
Normal file
@ -0,0 +1,7 @@
|
||||
SRC_CC = lock.cc cmpxchg.cc
|
||||
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
INC_DIR += $(REP_DIR)/src/base/lock
|
||||
|
||||
vpath lock.cc $(BASE_DIR)/src/base/lock
|
||||
vpath cmpxchg.cc $(REP_DIR)/src/base/lock
|
4
base-codezero/lib/mk/pager.mk
Normal file
4
base-codezero/lib/mk/pager.mk
Normal file
@ -0,0 +1,4 @@
|
||||
SRC_CC = pager.cc
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath pager.cc $(REP_DIR)/src/base/pager
|
6
base-codezero/lib/mk/pl011/core_printf.mk
Normal file
6
base-codezero/lib/mk/pl011/core_printf.mk
Normal file
@ -0,0 +1,6 @@
|
||||
SRC_CC = core_printf.cc
|
||||
LIBS = cxx console
|
||||
INC_DIR += $(REP_DIR)/src/base/console/pl011
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath core_printf.cc $(BASE_DIR)/src/base/console
|
33
base-codezero/lib/mk/platform.mk
Normal file
33
base-codezero/lib/mk/platform.mk
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# Create prerequisites for building Genode for Codezero
|
||||
#
|
||||
|
||||
#
|
||||
# Execute the rules in this file only at the second build stage when we know
|
||||
# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'.
|
||||
#
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
include $(REP_DIR)/lib/mk/codezero_cml.inc
|
||||
|
||||
all: $(BUILD_BASE_DIR)/include/l4/config.h
|
||||
|
||||
$(BUILD_BASE_DIR)/include/l4/config.h: $(CODEZERO_CML)
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)$(CODEZERO_DIR)/tools/cml2header.py -i $^ -o $@
|
||||
|
||||
#
|
||||
# Codezero's 'macros.h' includes the file "config.h", expected to be located in
|
||||
# the same directory (using #include "config.h"). However, 'config.h' is
|
||||
# generated into the source tree by the Codezero configuration system. Since we
|
||||
# do not want to pollute the source tree, we create a shadow copy of 'macros.h'
|
||||
# in the same directory as our generated 'config.h'.
|
||||
#
|
||||
all: $(BUILD_BASE_DIR)/include/l4/macros.h
|
||||
|
||||
$(BUILD_BASE_DIR)/include/l4/macros.h: $(CODEZERO_DIR)/include/l4/macros.h
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)ln -s $^ $@
|
||||
|
||||
endif
|
||||
|
5
base-codezero/lib/mk/thread.mk
Normal file
5
base-codezero/lib/mk/thread.mk
Normal file
@ -0,0 +1,5 @@
|
||||
SRC_CC = thread.cc thread_start.cc thread_bootstrap.cc
|
||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath thread_start.cc $(REP_DIR)/src/base/thread
|
||||
vpath %.cc $(BASE_DIR)/src/base/thread
|
56
base-codezero/mk/spec-codezero.mk
Normal file
56
base-codezero/mk/spec-codezero.mk
Normal file
@ -0,0 +1,56 @@
|
||||
#
|
||||
# Specifics for the Codezero kernel API
|
||||
#
|
||||
|
||||
#
|
||||
# Read default and builddir-specific config files
|
||||
#
|
||||
# In these config files, we expect to find the definition of CODEZERO_DIR
|
||||
#
|
||||
-include $(call select_from_repositories,etc/codezero.conf)
|
||||
-include $(BUILD_BASE_DIR)/etc/codezero.conf
|
||||
|
||||
ifeq ($(CODEZERO_DIR),)
|
||||
$(error Could not find the definition of CODEZERO_DIR in etc/codezero.conf)
|
||||
endif
|
||||
|
||||
#
|
||||
# Convert path to absolute directory
|
||||
#
|
||||
absdir = $(shell readlink -f $(1))
|
||||
|
||||
#
|
||||
# Headers generated within the build directory
|
||||
# (see 'lib/mk/platform.mk')
|
||||
#
|
||||
INC_DIR += $(BUILD_BASE_DIR)/include
|
||||
|
||||
#
|
||||
# Codezero headers
|
||||
#
|
||||
CODEZERO_ABS_DIR = $(call absdir,$(CODEZERO_DIR))
|
||||
|
||||
INC_DIR += $(CODEZERO_ABS_DIR)/include
|
||||
INC_DIR += $(CODEZERO_ABS_DIR)/conts/userlibs/libl4/include
|
||||
INC_DIR += $(CODEZERO_ABS_DIR)/conts/userlibs/libdev/uart/include
|
||||
|
||||
#
|
||||
# Codezero-specific startup code
|
||||
#
|
||||
PRG_LIBS += startup
|
||||
|
||||
#
|
||||
# Allow programs to test for the Codezero kernel
|
||||
#
|
||||
# This is needed by the 'pl050/irq_handler.h' to handle the interrupt semantics
|
||||
# of Codezero.
|
||||
#
|
||||
CC_OPT += -D__CODEZERO__
|
||||
|
||||
#
|
||||
# Clean rules for removing the side effects of building the platform
|
||||
#
|
||||
clean_includes:
|
||||
$(VERBOSE)rm -rf $(BUILD_BASE_DIR)/include
|
||||
|
||||
cleanall: clean_includes
|
13
base-codezero/mk/spec-codezero_arm.mk
Normal file
13
base-codezero/mk/spec-codezero_arm.mk
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Specifics for Codezero on ARM
|
||||
#
|
||||
SPECS += codezero
|
||||
|
||||
#
|
||||
# Linker options specific for ARM
|
||||
#
|
||||
LD_TEXT_ADDR ?= 0x02000000
|
||||
|
||||
CC_OPT += -D__ARCH__=arm
|
||||
|
||||
include $(call select_from_repositories,mk/spec-codezero.mk)
|
9
base-codezero/mk/spec-codezero_arm_v5.mk
Normal file
9
base-codezero/mk/spec-codezero_arm_v5.mk
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# Specifics for Codezero on ARMv5
|
||||
#
|
||||
|
||||
SPECS += codezero_arm
|
||||
|
||||
CC_OPT += -D__SUBARCH__=v5
|
||||
|
||||
include $(call select_from_repositories,mk/spec-codezero_arm.mk)
|
6
base-codezero/mk/spec-codezero_platform_vpb926.mk
Normal file
6
base-codezero/mk/spec-codezero_platform_vpb926.mk
Normal file
@ -0,0 +1,6 @@
|
||||
SPECS += codezero_arm_v5 platform_vpb926
|
||||
|
||||
CC_OPT += -D__PLATFORM__=pb926
|
||||
|
||||
include $(call select_from_repositories,mk/spec-codezero_arm_v5.mk)
|
||||
include $(call select_from_repositories,mk/spec-platform_vpb926.mk)
|
67
base-codezero/patches/README
Normal file
67
base-codezero/patches/README
Normal file
@ -0,0 +1,67 @@
|
||||
This directory contains patches of the Codezero kernel that are needed for the
|
||||
integration with Genode. Furthermore, some patches address issues with recent
|
||||
tool chains not yet supported by the official Codezero verison.
|
||||
|
||||
:binutils-2.21.patch:
|
||||
|
||||
The GNU assembler of binutils-2.21 complains with an error that was ignored
|
||||
by previous binutils versions:
|
||||
|
||||
"Error: .size expression for ... does not evaluate to a constant"
|
||||
|
||||
This error seems to occur if the argument of 'BEGIN_PROC' does not match
|
||||
the argument of 'END_PROC'. The patch fixes such inconsistencies in the
|
||||
code.
|
||||
|
||||
:gcc_shared_enabled.patch:
|
||||
|
||||
Codezero expect the tool chain to be used for the kernel to not support
|
||||
shared libraries. This is the case for Codesourcery's arm-non-eabi
|
||||
tool chain. Such tool chains use to incorporate both libgcc and libgcc_eh
|
||||
into the single libgcc.a library. In contrast, for tool chains built with
|
||||
'--enable-shared', libgcc does not contain the functions of libgcc_eh. Hence,
|
||||
one symbol called '__aeabi_unwind_cpp_pr0' referenced by libgcc and normally
|
||||
provided by libgcc_eh remains unresolved. There are two possible solutions
|
||||
for this problem: We could link libgcc_eh to the 'final.elf' image as
|
||||
expected by libgcc. However, this way, we will need to implement the
|
||||
the environment expected by libgcc_eh. For Codezero, this is pointless
|
||||
because no C++ is used. The second option is to provide a dummy symbol
|
||||
for '__aeabi_unwind_cpp_pr0' just to make the linker happy. This patch
|
||||
adds such a dummy symbol to 'loader/main.c'.
|
||||
|
||||
:libc_search_dir.patch:
|
||||
|
||||
The userlibs are build with w/o '-nostdinc'. Consequently, the standard
|
||||
search paths of the tool chain are used. Because the user land is
|
||||
normally build with the Codesourcery tool chain 'arm-none-linux-gnueabi',
|
||||
the complete glibc headers (that come with the tool chain) end up in
|
||||
the default search path. Coincidentally, the userlibs SConstruct file
|
||||
misses to supply the Codezero libc headers, which goes undetected because
|
||||
headers such as 'stdio.h' are silently taken from the tool chain's libc.
|
||||
This patch supplies Codezero's libc include-search path for building
|
||||
the userlibs. This enables the userlibs to be built with tool chains
|
||||
that do not come with a complete libc.
|
||||
|
||||
:scons-2.0.1.patch:
|
||||
|
||||
SCons 2.0.1 complains about the 'build_dir' argument being renamed to
|
||||
'variant_dir'. This patch renames the argument where needed for building
|
||||
the kernel and the default container.
|
||||
|
||||
:set_fixed_pager.patch:
|
||||
|
||||
At some point, Codezero abandoned the facility to define the pager for a
|
||||
given thread via the exregs system call. Instead, the kernel hard-wires the
|
||||
creator of the thread as the thread's pager. This is conflicting with
|
||||
Genode's way of creating and paging threads. On the current version of Genode
|
||||
for Codezero, all threads are paged by one thread (thread 3 happens to be the
|
||||
global pager) within core. As a work-around to Codezero's current limitation,
|
||||
we define thread 3 to be the pager of all threads.
|
||||
|
||||
:gcc_4_6_1_fixes.patch:
|
||||
|
||||
Version 4.6.1 of GCC is more picky about dead code than previous versions and
|
||||
warns about unused variables. Because Codezero is build with the '-Werror'
|
||||
flag, these warnings cause the kernel build to fail. The patch fixes those
|
||||
warnings by removing the variables in question.
|
||||
|
33
base-codezero/patches/binutils-2.21.patch
Normal file
33
base-codezero/patches/binutils-2.21.patch
Normal file
@ -0,0 +1,33 @@
|
||||
diff --git a/src/arch/arm/vectors.S b/src/arch/arm/vectors.S
|
||||
index 0475389..62f3c38 100644
|
||||
--- a/src/arch/arm/vectors.S
|
||||
+++ b/src/arch/arm/vectors.S
|
||||
@@ -503,7 +503,7 @@ BEGIN_PROC(arm_irq_exception_basic)
|
||||
mov lr, pc
|
||||
ldr pc, =do_irq
|
||||
ldmfd sp!, {r0-r3, pc}^
|
||||
-END_PROC(arm_irq_exception)
|
||||
+END_PROC(arm_irq_exception_basic)
|
||||
|
||||
/* Minimal IRQ state saved on irq stack right after irq vector enters: */
|
||||
#define IRQ_R0 0
|
||||
diff --git a/conts/userlibs/libc/src/arch-arm/memcpy.S b/conts/userlibs/libc/src/arch-arm/memcpy.S
|
||||
index 383f5d2..b4df27f 100644
|
||||
--- a/conts/userlibs/libc/src/arch-arm/memcpy.S
|
||||
+++ b/conts/userlibs/libc/src/arch-arm/memcpy.S
|
||||
@@ -57,4 +57,4 @@ BEGIN_PROC(memcpy)
|
||||
bne last
|
||||
1:
|
||||
pop {r0, r4 - r11, pc}
|
||||
-END_PROC(_memcpy)
|
||||
+END_PROC(memcpy)
|
||||
diff --git a/conts/userlibs/libc/src/arch-arm/memset.S b/conts/userlibs/libc/src/arch-arm/memset.S
|
||||
index ce9b06c..3746955 100644
|
||||
--- a/conts/userlibs/libc/src/arch-arm/memset.S
|
||||
+++ b/conts/userlibs/libc/src/arch-arm/memset.S
|
||||
@@ -65,4 +65,4 @@ BEGIN_PROC(memset)
|
||||
bne end
|
||||
|
||||
ldmfd sp!, {r4 - r11, pc}
|
||||
-END_PROC(_memset)
|
||||
+END_PROC(memset)
|
182
base-codezero/patches/gcc_4_6_1_fixes.patch
Normal file
182
base-codezero/patches/gcc_4_6_1_fixes.patch
Normal file
@ -0,0 +1,182 @@
|
||||
diff --git a/src/api/map.c b/src/api/map.c
|
||||
index 1d15086..6139b4c 100644
|
||||
--- a/src/api/map.c
|
||||
+++ b/src/api/map.c
|
||||
@@ -78,6 +78,6 @@ int sys_unmap(unsigned long virtual, unsigned long npages, unsigned int tid)
|
||||
retval = ret;
|
||||
}
|
||||
|
||||
- return ret;
|
||||
+ return retval;
|
||||
}
|
||||
|
||||
diff --git a/src/api/thread.c b/src/api/thread.c
|
||||
index 985c425..579e4fb 100644
|
||||
--- a/src/api/thread.c
|
||||
+++ b/src/api/thread.c
|
||||
@@ -497,7 +497,7 @@ out_err:
|
||||
*/
|
||||
int sys_thread_control(unsigned int flags, struct task_ids *ids)
|
||||
{
|
||||
- struct ktcb *task = 0, *pager = 0;
|
||||
+ struct ktcb *task = 0;
|
||||
int err, ret = 0;
|
||||
|
||||
if ((err = check_access((unsigned long)ids, sizeof(*ids),
|
||||
@@ -508,8 +508,6 @@ int sys_thread_control(unsigned int flags, struct task_ids *ids)
|
||||
if (!(task = tcb_find(ids->tid)))
|
||||
return -ESRCH;
|
||||
|
||||
- pager = task->pager;
|
||||
-
|
||||
/*
|
||||
* Caller may operate on a thread if it shares
|
||||
* the same address space with that thread's pager
|
||||
diff --git a/src/arch/arm/mapping-common.c b/src/arch/arm/mapping-common.c
|
||||
index 385f7c2..55b4bea 100644
|
||||
--- a/src/arch/arm/mapping-common.c
|
||||
+++ b/src/arch/arm/mapping-common.c
|
||||
@@ -313,12 +313,11 @@ int check_mapping(unsigned long vaddr, unsigned long size,
|
||||
int remove_mapping_space(struct address_space *space, unsigned long vaddr)
|
||||
{
|
||||
pmd_table_t *pmd_table;
|
||||
- int pgd_i, pmd_i;
|
||||
+ int pmd_i;
|
||||
pmd_t *pmd;
|
||||
unsigned int pmd_type, pte_type;
|
||||
|
||||
vaddr = page_align(vaddr);
|
||||
- pgd_i = PGD_INDEX(vaddr);
|
||||
pmd_i = PMD_INDEX(vaddr);
|
||||
|
||||
/*
|
||||
diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c
|
||||
index 2373c66..43c6fda 100644
|
||||
--- a/src/glue/arm/init.c
|
||||
+++ b/src/glue/arm/init.c
|
||||
@@ -68,8 +68,6 @@ void print_sections(void)
|
||||
/* The kip is non-standard, using 0xBB to indicate mine for now ;-) */
|
||||
void kip_init()
|
||||
{
|
||||
- struct utcb **utcb_ref;
|
||||
-
|
||||
/*
|
||||
* TODO: Adding utcb size might be useful
|
||||
*/
|
||||
@@ -86,9 +84,6 @@ void kip_init()
|
||||
|
||||
kip_init_syscalls();
|
||||
|
||||
- /* KIP + 0xFF0 is pointer to UTCB segment start address */
|
||||
- utcb_ref = (struct utcb **)((unsigned long)&kip + UTCB_KIP_OFFSET);
|
||||
-
|
||||
add_boot_mapping(virt_to_phys(&kip), USER_KIP_PAGE, PAGE_SIZE,
|
||||
MAP_USR_RO);
|
||||
printk("%s: Kernel built on %s, %s\n", __KERNELNAME__,
|
||||
diff --git a/loader/libs/elf/src/elf.c b/loader/libs/elf/src/elf.c
|
||||
index 4a1b5e0..f97273b 100644
|
||||
--- a/loader/libs/elf/src/elf.c
|
||||
+++ b/loader/libs/elf/src/elf.c
|
||||
@@ -339,16 +339,12 @@ elf_loadFile(void *elfFile, bool phys)
|
||||
{
|
||||
int i;
|
||||
int num_pheaders;
|
||||
- int pheader_offset;
|
||||
- int pheader_type;
|
||||
if (elf_checkFile(elfFile) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
num_pheaders = elf_getNumProgramHeaders(elfFile);
|
||||
- pheader_offset = elf_getProgramHeaderOffset(elfFile, 0);
|
||||
//printf("Number of program headers: %d\n", num_pheaders);
|
||||
- //printf("Program header offset of first header from file beginning: 0x%p\n",pheader_offset);
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
@@ -373,8 +369,6 @@ elf_loadFile(void *elfFile, bool phys)
|
||||
// printf("This section's size in file: %p\n", len);
|
||||
src = (uint64_t) (uintptr_t) elfFile + elf_getProgramHeaderOffset(elfFile, i);
|
||||
// printf("Elf program header offset: %p\n", src);
|
||||
- pheader_type = elf_getProgramHeaderType(elfFile, i);
|
||||
- // printf("Elf program header type: %p\n", pheader_type);
|
||||
// Comment
|
||||
printf("Copying to range from 0x%x to 0x%x of size: 0x%x\n", (unsigned int)dest, (unsigned int)dest + (unsigned int)len, (unsigned int)len);
|
||||
memcpy((void*) (uintptr_t) dest, (void*) (uintptr_t) src, len);
|
||||
diff --git a/loader/libs/elf/src/elf32.c b/loader/libs/elf/src/elf32.c
|
||||
index 2d13798..78bbf33 100644
|
||||
--- a/loader/libs/elf/src/elf32.c
|
||||
+++ b/loader/libs/elf/src/elf32.c
|
||||
@@ -248,7 +248,6 @@ elf32_fprintf(FILE *f, struct Elf32_Header *file, int size, const char *name, in
|
||||
struct Elf32_Shdr *sections;
|
||||
unsigned numSections;
|
||||
int i, r;
|
||||
- char *str_table;
|
||||
|
||||
fprintf(f, "Found an elf32 file called \"%s\" located "
|
||||
"at address 0x%p\n", name, file);
|
||||
@@ -307,7 +306,6 @@ elf32_fprintf(FILE *f, struct Elf32_Header *file, int size, const char *name, in
|
||||
}
|
||||
}
|
||||
if (flags & ELF_PRINT_SECTIONS) {
|
||||
- str_table = elf32_getSegmentStringTable(file);
|
||||
|
||||
printf("Section Headers:\n");
|
||||
printf(" [Nr] Name Type Addr Off\n");
|
||||
diff --git a/src/generic/capability.c b/src/generic/capability.c
|
||||
index 0860ea5..ef44445 100644
|
||||
--- a/src/generic/capability.c
|
||||
+++ b/src/generic/capability.c
|
||||
@@ -403,7 +403,7 @@ struct capability *cap_match_mem(struct capability *cap,
|
||||
{
|
||||
struct sys_map_args *args = args_ptr;
|
||||
struct ktcb *target = args->task;
|
||||
- unsigned long long start, end, pfn_point;
|
||||
+ unsigned long long start, pfn_point;
|
||||
unsigned long pfn;
|
||||
unsigned int perms;
|
||||
|
||||
@@ -415,7 +415,6 @@ struct capability *cap_match_mem(struct capability *cap,
|
||||
|
||||
/* Long long range check to avoid overflow */
|
||||
start = cap->start;
|
||||
- end = cap->end;
|
||||
pfn_point = pfn;
|
||||
if (start > pfn_point || cap->end < pfn_point + args->npages)
|
||||
return 0;
|
||||
diff --git a/loader/main.c b/loader/main.c
|
||||
index 7d21a4c..8d7d6db 100644
|
||||
--- a/loader/main.c
|
||||
+++ b/loader/main.c
|
||||
@@ -26,7 +26,6 @@ int load_elf_image(unsigned long **entry, void *filebuf);
|
||||
int load_container_image(void *cont_section)
|
||||
{
|
||||
struct Elf32_Header *elf_header = (struct Elf32_Header *)cont_section;
|
||||
- struct Elf32_Shdr *sect_header;
|
||||
int nsect;
|
||||
int nimgs = 0;
|
||||
unsigned long *image_entry;
|
||||
@@ -36,7 +35,6 @@ int load_container_image(void *cont_section)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- sect_header = elf32_getSectionTable(elf_header);
|
||||
nsect = elf32_getNumSections(elf_header);
|
||||
|
||||
for (int i = 0; i < nsect; i++) {
|
||||
@@ -59,7 +57,6 @@ int load_container_image(void *cont_section)
|
||||
int load_container_images(unsigned long start, unsigned long end)
|
||||
{
|
||||
struct Elf32_Header *elf_header = (struct Elf32_Header *)start;
|
||||
- struct Elf32_Shdr *sect_header;
|
||||
int nsect = 0;
|
||||
int nconts = 0;
|
||||
|
||||
@@ -68,7 +65,6 @@ int load_container_images(unsigned long start, unsigned long end)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- sect_header = elf32_getSectionTable(elf_header);
|
||||
nsect = elf32_getNumSections(elf_header);
|
||||
|
||||
for (int i = 0; i < nsect; i++) {
|
10
base-codezero/patches/gcc_shared_enabled.patch
Normal file
10
base-codezero/patches/gcc_shared_enabled.patch
Normal file
@ -0,0 +1,10 @@
|
||||
diff --git a/loader/main.c b/loader/main.c
|
||||
index 7d21a4c..ee03918 100644
|
||||
--- a/loader/main.c
|
||||
+++ b/loader/main.c
|
||||
@@ -135,3 +135,5 @@ int main(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+
|
||||
+asm(".global __aeabi_unwind_cpp_pr0; __aeabi_unwind_cpp_pr0:");
|
21
base-codezero/patches/libc_search_dir.patch
Normal file
21
base-codezero/patches/libc_search_dir.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff --git a/conts/userlibs/SConstruct b/conts/userlibs/SConstruct
|
||||
index 41c7913..421b563 100644
|
||||
--- a/conts/userlibs/SConstruct
|
||||
+++ b/conts/userlibs/SConstruct
|
||||
@@ -11,6 +11,7 @@ PROJRELROOT = '../..'
|
||||
sys.path.append(PROJRELROOT)
|
||||
|
||||
from scripts.config.config_invoke import *
|
||||
+from scripts.config.projpaths import *
|
||||
|
||||
config = configuration_retrieve()
|
||||
gcc_arch_flag = config.gcc_arch_flag
|
||||
@@ -28,7 +29,7 @@ env = Environment(CC = config.toolchain_userspace + 'gcc',
|
||||
ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag],
|
||||
ENV = {'PATH' : os.environ['PATH']},
|
||||
LIBS = 'gcc', # libgcc.a - Required for division routines.
|
||||
- CPPPATH = KERNEL_HEADERS,
|
||||
+ CPPPATH = [KERNEL_HEADERS, LIBC_INCLUDE],
|
||||
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
|
||||
|
||||
# Set the build directory for this source tree
|
97
base-codezero/patches/scons-2.0.1.patch
Normal file
97
base-codezero/patches/scons-2.0.1.patch
Normal file
@ -0,0 +1,97 @@
|
||||
diff --git a/src/drivers/SConscript b/src/drivers/SConscript
|
||||
index eedb59f..8f5cd5d 100644
|
||||
--- a/src/drivers/SConscript
|
||||
+++ b/src/drivers/SConscript
|
||||
@@ -8,24 +8,24 @@ src_local = []
|
||||
objs = []
|
||||
|
||||
objs += SConscript("uart/pl011/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'pl011'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'pl011'))
|
||||
|
||||
objs += SConscript("timer/sp804/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'timer'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'timer'))
|
||||
|
||||
objs += SConscript("irq/pl190/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'vic'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'vic'))
|
||||
|
||||
objs += SConscript("irq/gic/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'gic'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'gic'))
|
||||
|
||||
objs += SConscript("irq/omap3/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'omap/intc'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'omap/intc'))
|
||||
|
||||
objs += SConscript("uart/omap/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'omap/uart'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'omap/uart'))
|
||||
|
||||
objs += SConscript("timer/omap/SConscript", exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = join(bdir, 'omap/timer'))
|
||||
+ duplicate=0, variant_dir = join(bdir, 'omap/timer'))
|
||||
|
||||
Return('objs')
|
||||
diff --git a/conts/baremetal/empty/SConstruct b/conts/baremetal/empty/SConstruct
|
||||
index b70d69a..4889d8e 100644
|
||||
--- a/conts/baremetal/empty/SConstruct
|
||||
+++ b/conts/baremetal/empty/SConstruct
|
||||
@@ -48,7 +48,7 @@ env = Environment(CC = config.toolchain_userspace + 'gcc',
|
||||
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
|
||||
|
||||
objs = SConscript('SConscript', exports = { 'env' : env },
|
||||
- duplicate=0, build_dir = builddir)
|
||||
+ duplicate=0, variant_dir = builddir)
|
||||
|
||||
Depends(objs, join(PROJROOT, CONFIG_H))
|
||||
prog = env.Program(join(builddir, 'main.elf'), objs)
|
||||
diff --git a/SConstruct b/SConstruct
|
||||
index 2abc190..58c983d 100644
|
||||
--- a/SConstruct
|
||||
+++ b/SConstruct
|
||||
@@ -71,35 +71,35 @@ env = Environment(CC = config.toolchain_kernel + 'gcc',
|
||||
objects = []
|
||||
objects += SConscript('src/generic/SConscript',
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, 'generic'))
|
||||
+ variant_dir = join(builddir, 'generic'))
|
||||
|
||||
objects += SConscript(join(join('src/glue', arch), 'SConscript'),
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, join('glue',arch)))
|
||||
+ variant_dir = join(builddir, join('glue',arch)))
|
||||
|
||||
objects += SConscript(join(join('src/arch', arch), 'SConscript'),
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, join('arch', arch)))
|
||||
+ variant_dir = join(builddir, join('arch', arch)))
|
||||
|
||||
objects += SConscript(join(join('src/arch', arch), join(subarch, 'SConscript')),
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, join(join('arch',arch), subarch)))
|
||||
+ variant_dir = join(builddir, join(join('arch',arch), subarch)))
|
||||
|
||||
objects += SConscript('src/lib/SConscript',
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, 'lib'))
|
||||
+ variant_dir = join(builddir, 'lib'))
|
||||
|
||||
objects += SConscript('src/api/SConscript',
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, 'api'))
|
||||
+ variant_dir = join(builddir, 'api'))
|
||||
|
||||
objects += SConscript('src/drivers/SConscript',
|
||||
exports = { 'env' : env, 'bdir' : 'driver/'}, duplicate = 0,
|
||||
- build_dir = join(builddir, 'driver'))
|
||||
+ variant_dir = join(builddir, 'driver'))
|
||||
|
||||
objects += SConscript(join(join('src/platform', platform), 'SConscript'),
|
||||
exports = { 'env' : env }, duplicate = 0,
|
||||
- build_dir = join(builddir, join('platform', platform)))
|
||||
+ variant_dir = join(builddir, join('platform', platform)))
|
||||
|
||||
|
||||
# Add builders for generating kernel linker scripts
|
13
base-codezero/patches/set_fixed_pager.patch
Normal file
13
base-codezero/patches/set_fixed_pager.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h
|
||||
index 7b315b8..ace38d8 100644
|
||||
--- a/include/l4/generic/tcb.h
|
||||
+++ b/include/l4/generic/tcb.h
|
||||
@@ -70,7 +70,7 @@ struct task_ids {
|
||||
|
||||
struct container;
|
||||
|
||||
-#define tcb_pagerid(tcb) ((tcb)->pager->tid)
|
||||
+#define tcb_pagerid(tcb) 3
|
||||
|
||||
#define space_is_pager(tcb) \
|
||||
((tcb)->space->spid == (tcb)->pager->space->spid)
|
88
base-codezero/run/env
Normal file
88
base-codezero/run/env
Normal file
@ -0,0 +1,88 @@
|
||||
#
|
||||
# \brief Codezero-specific test-environment supplements
|
||||
# \author Norman Feske
|
||||
# \date 2011-08-05
|
||||
#
|
||||
# This file is meant to be used as '--include' argument for 'tool/run'.
|
||||
#
|
||||
|
||||
|
||||
##
|
||||
# Return location of prebuilt mirror of codezero source tree
|
||||
#
|
||||
proc kernel_dir { } { return [pwd]/kernel/codezero }
|
||||
|
||||
|
||||
##
|
||||
# Return container directory where the Genode binaries should be copied to
|
||||
#
|
||||
proc container_dir { } { return [kernel_dir]/build/cont0/empty0 }
|
||||
|
||||
|
||||
##
|
||||
# Return location of 'gen_romfs' tool
|
||||
#
|
||||
proc gen_romfs { } { return "[genode_dir]/base-codezero/tool/gen_romfs" }
|
||||
|
||||
|
||||
##
|
||||
# Print and execute shell command
|
||||
#
|
||||
proc exec_sh { command } {
|
||||
puts "$command"
|
||||
exec sh -c $command
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
## Test framework API functions ##
|
||||
##################################
|
||||
|
||||
proc create_boot_directory { } {
|
||||
|
||||
# create only intermediate directries hosting the run directory
|
||||
exec mkdir -p [run_dir]
|
||||
exec rm -rf [run_dir]
|
||||
|
||||
exec mkdir -p [run_dir]/genode
|
||||
}
|
||||
|
||||
|
||||
proc build_boot_image {binaries} {
|
||||
|
||||
if {![file exists kernel]} { build kernel }
|
||||
|
||||
copy_and_strip_genode_binaries_to_run_dir $binaries
|
||||
|
||||
# the codezero build system expects that the pager binary is named 'main.elf'
|
||||
exec cp [run_dir]/genode/core [container_dir]/main.elf
|
||||
|
||||
# obtain list of modules
|
||||
set modules [glob [run_dir]/genode/*]
|
||||
|
||||
# remove core from list of modules
|
||||
set core_idx [lsearch -exact $modules [run_dir]/genode/core]
|
||||
set modules [lreplace $modules $core_idx $core_idx]
|
||||
|
||||
# generate elf image containing the boot modules
|
||||
exec_sh "[gen_romfs] -p [cross_dev_prefix] -c [run_dir]/genode/core -o [container_dir]/modules.elf $modules"
|
||||
|
||||
set tool_chain_dir [file dirname [cross_dev_prefix]]
|
||||
set prepend_path ""
|
||||
if {[file isdirectory $tool_chain_dir]} {
|
||||
set prepend_path $tool_chain_dir }
|
||||
|
||||
# force re-generation of 'cinfo.c', which depends on the container content
|
||||
exec_sh "rm -f [kernel_dir]/src/generic/cinfo.c"
|
||||
|
||||
# rebuild codezero, linking the new container content
|
||||
exec_sh "cd [kernel_dir]; PATH=$prepend_path:\$PATH ./build.py"
|
||||
|
||||
# copy result to [run_dir]/image.elf (to be picked up by spawn_qemu)
|
||||
exec_sh "cp [kernel_dir]/build/final.elf [run_dir]/image.elf"
|
||||
}
|
||||
|
||||
|
||||
proc run_genode_until {{wait_for_re forever} {timeout_value 0}} {
|
||||
spawn_qemu $wait_for_re $timeout_value }
|
||||
|
78
base-codezero/src/base/console/pl011/core_console.h
Normal file
78
base-codezero/src/base/console/pl011/core_console.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* \brief Console backend for PL011 UART on Codezero
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-03
|
||||
*
|
||||
* This code assumes a PL011 UART as provided by 'qemu -M versatilepb'. Prior
|
||||
* executing this code, the kernel already initialized the UART to print some
|
||||
* startup message. So we can skip the UART initialization here. The kernel
|
||||
* maps the UART registers to the magic address PL011_BASE when starting mm0.
|
||||
* So we can just start using the device without any precautions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/console.h>
|
||||
|
||||
/* codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
/**
|
||||
* Base address of default-mapped UART device
|
||||
*
|
||||
* defined in 'l4/arch/arm/io.h'
|
||||
*/
|
||||
enum { PL011_BASE = USERSPACE_CONSOLE_VBASE };
|
||||
|
||||
/**
|
||||
* UART registers
|
||||
*/
|
||||
enum { PL011_REG_UARTDR = PL011_BASE + 0x00 };
|
||||
enum { PL011_REG_UARTFR = PL011_BASE + 0x18 };
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if UART is ready to transmit a character
|
||||
*/
|
||||
static bool pl011_tx_ready()
|
||||
{
|
||||
enum { PL011_TX_FIFO_FULL = 1 << 5 };
|
||||
return !(*((volatile unsigned *)PL011_REG_UARTFR) & PL011_TX_FIFO_FULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output character to serial port
|
||||
*/
|
||||
static void pl011_out_char(uint8_t c)
|
||||
{
|
||||
/* wait until serial port is ready */
|
||||
while (!pl011_tx_ready());
|
||||
|
||||
/* output character */
|
||||
*((volatile unsigned int *)PL011_REG_UARTDR) = c;
|
||||
}
|
||||
|
||||
|
||||
namespace Genode
|
||||
{
|
||||
class Core_console : public Console
|
||||
{
|
||||
protected:
|
||||
|
||||
void _out_char(char c) {
|
||||
if(c == '\n')
|
||||
pl011_out_char('\r');
|
||||
pl011_out_char(c);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
53
base-codezero/src/base/cxx/exception.cc
Normal file
53
base-codezero/src/base/cxx/exception.cc
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* \brief Support for exceptions libsupc++
|
||||
* \author Norman Feske
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2006-07-21
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
extern "C" char __eh_frame_start__[]; /* from linker script */
|
||||
extern "C" void __register_frame (const void *begin); /* from libgcc_eh */
|
||||
|
||||
/*
|
||||
* This symbol is set by Genode's dynamic linker (ldso) during binary setup.
|
||||
* After setup, the symbol will point to the actual implementation of
|
||||
* 'dl_iterate_phdr', which is located within the linker. 'dl_iterate_phdr'
|
||||
* iterates through all (linker loaded) binaries and shared libraries. This
|
||||
* function has to be implemented in order to support C++ exceptions within
|
||||
* shared libraries.
|
||||
* Return values of dl_iterate_phdr (gcc 4.2.4):
|
||||
* < 0 = error
|
||||
* 0 = continue program header iteration
|
||||
* > 0 = stop iteration (no errors occured)
|
||||
*
|
||||
* See also: man dl_iterate_phdr
|
||||
*/
|
||||
int (*genode__dl_iterate_phdr) (int (*callback) (void *info, unsigned long size, void *data), void *data) = 0;
|
||||
|
||||
extern "C" int dl_iterate_phdr(int (*callback) (void *info, unsigned long size, void *data), void *data) __attribute__((weak));
|
||||
extern "C" int dl_iterate_phdr(int (*callback) (void *info, unsigned long size, void *data), void *data)
|
||||
{
|
||||
if (!genode__dl_iterate_phdr)
|
||||
return -1;
|
||||
|
||||
return genode__dl_iterate_phdr(callback, data);
|
||||
}
|
||||
|
||||
extern "C" void raise()
|
||||
{
|
||||
PDBG("raise called - not implemented\n");
|
||||
}
|
||||
|
||||
void init_exception_handling()
|
||||
{
|
||||
// __register_frame(__eh_frame_start__);
|
||||
}
|
24
base-codezero/src/base/cxx/memcmp.cc
Normal file
24
base-codezero/src/base/cxx/memcmp.cc
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* \brief Functions required for using the arm-none-linux-gnueabi tool chain
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
#include <base/stdint.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
extern "C" int raise(int sig)
|
||||
{
|
||||
PWRN("raise - not yet implemented");
|
||||
return 0;
|
||||
}
|
175
base-codezero/src/base/ipc/ipc.cc
Normal file
175
base-codezero/src/base/ipc/ipc.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* \brief Codezero implementation of the IPC API
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/ipc.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/blocking.h>
|
||||
#include <util/misc_math.h>
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Codezero;
|
||||
|
||||
enum { verbose_ipc = false };
|
||||
|
||||
|
||||
/*****************
|
||||
** Ipc_ostream **
|
||||
*****************/
|
||||
|
||||
void Ipc_ostream::_send()
|
||||
{
|
||||
if (verbose_ipc)
|
||||
PDBG("thread %d sends IPC to %d, write_offset=%d",
|
||||
thread_myself(), _dst.tid().tid, _write_offset);
|
||||
|
||||
umword_t snd_size = min(_write_offset, (unsigned)L4_IPC_EXTENDED_MAX_SIZE);
|
||||
|
||||
*(umword_t *)_snd_msg->addr() = _dst.local_name();
|
||||
|
||||
int ret = l4_send_extended(_dst.tid().tid, L4_IPC_TAG_SYNC_EXTENDED,
|
||||
snd_size, _snd_msg->addr());
|
||||
if (ret < 0)
|
||||
PERR("l4_send_extended (to thread %d) returned ret=%d",
|
||||
_dst.tid().tid, ret);
|
||||
|
||||
_write_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg)
|
||||
:
|
||||
Ipc_marshaller((char *)snd_msg->addr(), snd_msg->size()),
|
||||
_snd_msg(snd_msg), _dst(dst)
|
||||
{
|
||||
_write_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
/*****************
|
||||
** Ipc_istream **
|
||||
*****************/
|
||||
|
||||
void Ipc_istream::_wait()
|
||||
{
|
||||
umword_t *rcv_buf = (umword_t *)_rcv_msg->addr();
|
||||
umword_t rcv_size = min(_rcv_msg->size(), (unsigned)L4_IPC_EXTENDED_MAX_SIZE);
|
||||
|
||||
if (verbose_ipc)
|
||||
PDBG("thread %d waits for IPC from %d, rcv_buf at %p, rcv_size=%d",
|
||||
tid().tid, _rcv_cs, rcv_buf, (int)rcv_size);
|
||||
|
||||
int ret = l4_receive_extended(_rcv_cs, rcv_size, rcv_buf);
|
||||
if (ret < 0)
|
||||
PERR("l4_receive_extended (from any) returned ret=%d", ret);
|
||||
|
||||
if (verbose_ipc)
|
||||
PDBG("thread %d received IPC from %d",
|
||||
tid().tid, l4_get_sender());
|
||||
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg)
|
||||
:
|
||||
Ipc_unmarshaller((char *)rcv_msg->addr(), rcv_msg->size()),
|
||||
Native_capability(thread_myself(), 0),
|
||||
_rcv_msg(rcv_msg)
|
||||
{
|
||||
_rcv_cs = L4_ANYTHREAD;
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_istream::~Ipc_istream() { }
|
||||
|
||||
|
||||
/****************
|
||||
** Ipc_client **
|
||||
****************/
|
||||
|
||||
void Ipc_client::_call()
|
||||
{
|
||||
#warning l4_sendrecv_extended is not yet implemented in l4lib/arch/syslib.h
|
||||
_send();
|
||||
_rcv_cs = _dst.tid().tid;
|
||||
_wait();
|
||||
_rcv_cs = L4_ANYTHREAD;
|
||||
|
||||
_write_offset = _read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_client::Ipc_client(Native_capability const &srv,
|
||||
Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
|
||||
: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
|
||||
{ }
|
||||
|
||||
|
||||
/****************
|
||||
** Ipc_server **
|
||||
****************/
|
||||
|
||||
void Ipc_server::_prepare_next_reply_wait()
|
||||
{
|
||||
/* now we have a request to reply */
|
||||
_reply_needed = true;
|
||||
|
||||
/* leave space for return value at the beginning of the msgbuf */
|
||||
_write_offset = 2*sizeof(umword_t);
|
||||
|
||||
/* receive buffer offset */
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_wait()
|
||||
{
|
||||
/* wait for new server request */
|
||||
try { Ipc_istream::_wait(); } catch (Blocking_canceled) { }
|
||||
|
||||
/* define destination of next reply */
|
||||
_dst = Native_capability(l4_get_sender(), badge());
|
||||
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_reply()
|
||||
{
|
||||
try { _send(); } catch (Ipc_error) { }
|
||||
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_reply_wait()
|
||||
{
|
||||
if (_reply_needed)
|
||||
_reply();
|
||||
|
||||
_wait();
|
||||
}
|
||||
|
||||
|
||||
Ipc_server::Ipc_server(Msgbuf_base *snd_msg,
|
||||
Msgbuf_base *rcv_msg)
|
||||
:
|
||||
Ipc_istream(rcv_msg), Ipc_ostream(Native_capability(), snd_msg),
|
||||
_reply_needed(false)
|
||||
{ }
|
175
base-codezero/src/base/ipc/pager.cc
Normal file
175
base-codezero/src/base/ipc/pager.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* \brief Pager support for Codezero
|
||||
* \author Norman Feske
|
||||
* \date 2010-02-16
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/ipc_pager.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Codezero;
|
||||
|
||||
enum { verbose_page_faults = false };
|
||||
|
||||
|
||||
/************************
|
||||
** Page-fault utility **
|
||||
************************/
|
||||
|
||||
class Fault
|
||||
{
|
||||
public:
|
||||
|
||||
enum Type { READ, WRITE, EXEC, UNKNOWN };
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Translate Codezero page-fault information to generic fault type
|
||||
*
|
||||
* \param sr status
|
||||
* \param pte page-table entry
|
||||
*/
|
||||
static Type _fault_type(umword_t sr, umword_t pte)
|
||||
{
|
||||
if (is_prefetch_abort(sr))
|
||||
return EXEC;
|
||||
|
||||
if ((pte & PTE_PROT_MASK) == (__MAP_USR_RO & PTE_PROT_MASK))
|
||||
return WRITE;
|
||||
|
||||
return READ;
|
||||
}
|
||||
|
||||
Type _type;
|
||||
umword_t _addr;
|
||||
umword_t _ip;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param kdata Codezero-specific page-fault information
|
||||
*/
|
||||
Fault(struct fault_kdata const &kdata)
|
||||
:
|
||||
_type(_fault_type(kdata.fsr, kdata.pte)),
|
||||
_addr(_type == EXEC ? kdata.faulty_pc : kdata.far),
|
||||
_ip(kdata.faulty_pc)
|
||||
{ }
|
||||
|
||||
Type type() const { return _type; }
|
||||
umword_t addr() const { return _addr; }
|
||||
umword_t ip() const { return _ip; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Print page-fault information in a human-readable form
|
||||
*/
|
||||
inline void print_page_fault(Fault &fault, int from)
|
||||
{
|
||||
printf("page (%s%s%s) fault from %d at pf_addr=%lx, pf_ip=%lx\n",
|
||||
fault.type() == Fault::READ ? "r" : "-",
|
||||
fault.type() == Fault::WRITE ? "w" : "-",
|
||||
fault.type() == Fault::EXEC ? "x" : "-",
|
||||
from, fault.addr(), fault.ip());
|
||||
}
|
||||
|
||||
|
||||
/***************
|
||||
** IPC pager **
|
||||
***************/
|
||||
|
||||
void Ipc_pager::wait_for_fault()
|
||||
{
|
||||
for (;;) {
|
||||
int ret = l4_receive(L4_ANYTHREAD);
|
||||
|
||||
if (ret < 0) {
|
||||
PERR("pager: l4_received returned ret=%d", ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
umword_t tag = l4_get_tag();
|
||||
int faulter_tid = l4_get_sender();
|
||||
|
||||
if (tag != L4_IPC_TAG_PFAULT) {
|
||||
PWRN("got an unexpected IPC from %d", faulter_tid);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* copy fault information from message registers */
|
||||
struct fault_kdata fault_kdata;
|
||||
for (unsigned i = 0; i < sizeof(fault_kdata_t)/sizeof(umword_t); i++)
|
||||
((umword_t *)&fault_kdata)[i] = read_mr(MR_UNUSED_START + i);
|
||||
|
||||
Fault fault(fault_kdata);
|
||||
|
||||
if (verbose_page_faults)
|
||||
print_page_fault(fault, faulter_tid);
|
||||
|
||||
/* determine corresponding page in our own address space */
|
||||
_pf_addr = fault.addr();
|
||||
_pf_write = fault.type() == Fault::WRITE;
|
||||
_pf_ip = fault.ip();
|
||||
_last = faulter_tid;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ipc_pager::reply_and_wait_for_fault()
|
||||
{
|
||||
/* install mapping */
|
||||
umword_t flags = _reply_mapping.writeable() ? MAP_USR_RW
|
||||
: MAP_USR_RO;
|
||||
|
||||
/*
|
||||
* XXX: remove heuristics for mapping device registers.
|
||||
*/
|
||||
if (_reply_mapping.from_phys() == 0x10120000 /* LCD */
|
||||
|| _reply_mapping.from_phys() == 0x10006000 /* keyboard */
|
||||
|| _reply_mapping.from_phys() == 0x10007000) /* mouse */
|
||||
flags = MAP_USR_IO;
|
||||
|
||||
int ret = l4_map((void *)_reply_mapping.from_phys(),
|
||||
(void *)_reply_mapping.to_virt(),
|
||||
_reply_mapping.num_pages(), flags, _last.tid);
|
||||
|
||||
/* wake up faulter if mapping succeeded */
|
||||
if (ret < 0)
|
||||
PERR("l4_map returned %d, putting thread %d to sleep", ret, _last.tid);
|
||||
else
|
||||
acknowledge_wakeup();
|
||||
|
||||
/* wait for next page fault */
|
||||
wait_for_fault();
|
||||
}
|
||||
|
||||
|
||||
void Ipc_pager::acknowledge_wakeup()
|
||||
{
|
||||
enum { SUCCESS = 0 };
|
||||
l4_set_sender(_last.tid);
|
||||
l4_ipc_return(SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Ipc_pager::Ipc_pager() : Native_capability(thread_myself(), 0) { }
|
||||
|
48
base-codezero/src/base/lock/cmpxchg.cc
Normal file
48
base-codezero/src/base/lock/cmpxchg.cc
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* \brief Codezero-specific implementation of cmpxchg
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-12
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <cpu/atomic.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/lock.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
|
||||
static bool mutex_initialized;
|
||||
static Codezero::l4_mutex mutex;
|
||||
|
||||
int Genode::cmpxchg(volatile int *dest, int cmp_val, int new_val)
|
||||
{
|
||||
if (!mutex_initialized) {
|
||||
Codezero::l4_mutex_init(&mutex);
|
||||
mutex_initialized = true;
|
||||
}
|
||||
|
||||
int ret = Codezero::l4_mutex_lock(&mutex);
|
||||
if (ret < 0)
|
||||
mutex_initialized = false;
|
||||
|
||||
bool result = false;
|
||||
if (*dest == cmp_val) {
|
||||
*dest = new_val;
|
||||
result = true;
|
||||
}
|
||||
|
||||
ret = Codezero::l4_mutex_unlock(&mutex);
|
||||
if (ret < 0)
|
||||
mutex_initialized = false;
|
||||
|
||||
return result;
|
||||
}
|
63
base-codezero/src/base/lock/lock.cc
Normal file
63
base-codezero/src/base/lock/lock.cc
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* \brief Lock implementation
|
||||
* \author Norman Feske
|
||||
* \date 2007-10-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/cancelable_lock.h>
|
||||
#include <base/printf.h>
|
||||
#include <cpu/atomic.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
|
||||
:
|
||||
_native_lock(UNLOCKED)
|
||||
{
|
||||
if (initial == LOCKED)
|
||||
lock();
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::lock()
|
||||
{
|
||||
while (!cmpxchg(&_native_lock, UNLOCKED, LOCKED))
|
||||
Codezero::l4_thread_switch(-1);
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::unlock()
|
||||
{
|
||||
_native_lock = UNLOCKED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Printf implementation to make Codezero's syscall bindings happy.
|
||||
*
|
||||
* We need a better place for this function - actually, the best would be not
|
||||
* to need this function at all. As of now, 'printf' is referenced by
|
||||
* Codezero's libl4, in particular by the mutex implementation.
|
||||
*/
|
||||
extern "C" void printf(const char *format, ...) __attribute__((weak));
|
||||
extern "C" void printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
|
||||
vprintf(format, list);
|
||||
|
||||
va_end(list);
|
||||
}
|
112
base-codezero/src/base/lock/lock_helper.h
Normal file
112
base-codezero/src/base/lock/lock_helper.h
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* \brief Helper functions for the Lock implementation
|
||||
* \author Norman Feske
|
||||
* \date 2010-04-20
|
||||
*
|
||||
* For documentation about the interface, please revisit the 'base-pistachio'
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/native_types.h>
|
||||
#include <base/thread.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
|
||||
/**
|
||||
* Resolve 'Thread_base::myself' when not linking the thread library
|
||||
*
|
||||
* This weak symbol is primarily used by test cases. Most other Genode programs
|
||||
* use the thread library. If the thread library is not used, 'myself' can only
|
||||
* be called by the main thread, for which 'myself' is defined as zero.
|
||||
*/
|
||||
Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; }
|
||||
|
||||
|
||||
Genode::Native_utcb *Genode::Thread_base::utcb()
|
||||
{
|
||||
/*
|
||||
* If 'utcb' is called on the object returned by 'myself',
|
||||
* the 'this' pointer may be NULL (if the calling thread is
|
||||
* the main thread). Therefore we handle this special case
|
||||
* here.
|
||||
*/
|
||||
if (this == 0) return 0;
|
||||
|
||||
return &_context->utcb;
|
||||
}
|
||||
|
||||
|
||||
static Codezero::l4_mutex main_running_lock = { -1 };
|
||||
|
||||
|
||||
static inline void thread_yield()
|
||||
{
|
||||
Codezero::l4_thread_switch(-1);
|
||||
}
|
||||
|
||||
|
||||
static inline bool thread_id_valid(Genode::Native_thread_id tid)
|
||||
{
|
||||
return tid.tid != Codezero::NILTHREAD;
|
||||
}
|
||||
|
||||
|
||||
static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid)
|
||||
{
|
||||
if (!thread_id_valid(tid))
|
||||
return false;
|
||||
|
||||
Codezero::l4_mutex_unlock(tid.running_lock);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static inline Genode::Native_thread_id thread_get_my_native_id()
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
Codezero::l4_mutex *running_lock = 0;
|
||||
|
||||
/* obtain pointer to running lock of calling thread */
|
||||
if (Thread_base::myself())
|
||||
running_lock = Thread_base::myself()->utcb()->running_lock();
|
||||
else {
|
||||
running_lock = &main_running_lock;
|
||||
if (running_lock->lock == -1) {
|
||||
Codezero::l4_mutex_init(running_lock);
|
||||
Codezero::l4_mutex_lock(running_lock); /* block on first mutex lock */
|
||||
}
|
||||
}
|
||||
|
||||
return Genode::Native_thread_id(Codezero::thread_myself(), running_lock);
|
||||
}
|
||||
|
||||
|
||||
static inline Genode::Native_thread_id thread_invalid_id()
|
||||
{
|
||||
return Genode::Native_thread_id(Codezero::NILTHREAD, 0);
|
||||
}
|
||||
|
||||
|
||||
static inline void thread_switch_to(Genode::Native_thread_id tid)
|
||||
{
|
||||
if (thread_id_valid(tid))
|
||||
Codezero::l4_thread_switch(tid.tid);
|
||||
}
|
||||
|
||||
|
||||
static inline void thread_stop_myself()
|
||||
{
|
||||
Genode::Native_thread_id myself = thread_get_my_native_id();
|
||||
Codezero::l4_mutex_lock(myself.running_lock);
|
||||
}
|
101
base-codezero/src/base/pager/pager.cc
Normal file
101
base-codezero/src/base/pager/pager.cc
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* \brief Dummy pager framework
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/pager.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**********************
|
||||
** Pager activation **
|
||||
**********************/
|
||||
|
||||
void Pager_activation_base::entry()
|
||||
{
|
||||
Ipc_pager pager;
|
||||
_cap = pager;
|
||||
_cap_valid.unlock();
|
||||
|
||||
pager.wait_for_fault();
|
||||
while (1) {
|
||||
|
||||
/* lookup referenced object */
|
||||
Pager_object *obj = _ep ? _ep->obj_by_id(pager.badge()) : 0;
|
||||
|
||||
/* handle request */
|
||||
if (obj) {
|
||||
if (obj->pager(pager))
|
||||
/* something strange occured - leave thread in pagefault */
|
||||
pager.wait_for_fault();
|
||||
else
|
||||
pager.reply_and_wait_for_fault();
|
||||
} else {
|
||||
|
||||
/*
|
||||
* We got a request from one of cores region-manager sessions
|
||||
* to answer the pending page fault of a resolved region-manager
|
||||
* client. Hence, we have to send the page-fault reply to the
|
||||
* specified thread and answer the call of the region-manager
|
||||
* session.
|
||||
*
|
||||
* When called from a region-manager session, we receive the
|
||||
* core-local address of the targeted pager object via the
|
||||
* first message word, which corresponds to the 'fault_ip'
|
||||
* argument of normal page-fault messages.
|
||||
*/
|
||||
obj = reinterpret_cast<Pager_object *>(pager.fault_ip());
|
||||
|
||||
/* send reply to the calling region-manager session */
|
||||
pager.acknowledge_wakeup();
|
||||
|
||||
/* answer page fault of resolved pager object */
|
||||
pager.set_reply_dst(obj->cap());
|
||||
pager.acknowledge_wakeup();
|
||||
pager.wait_for_fault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
** Pager entrypoint **
|
||||
**********************/
|
||||
|
||||
Pager_entrypoint::Pager_entrypoint(Cap_session *, Pager_activation_base *a)
|
||||
: _activation(a)
|
||||
{ _activation->ep(this); }
|
||||
|
||||
|
||||
void Pager_entrypoint::dissolve(Pager_object *obj)
|
||||
{
|
||||
remove(obj);
|
||||
}
|
||||
|
||||
|
||||
Pager_capability Pager_entrypoint::manage(Pager_object *obj)
|
||||
{
|
||||
/* return invalid capability if no activation is present */
|
||||
if (!_activation) return Pager_capability();
|
||||
|
||||
_activation->cap();
|
||||
|
||||
Untyped_capability cap = Native_capability(_activation->cap().tid(), obj->badge());
|
||||
|
||||
/* add server object to object pool */
|
||||
obj->cap(cap);
|
||||
insert(obj);
|
||||
|
||||
/* return capability that uses the object id as badge */
|
||||
return reinterpret_cap_cast<Pager_object>(cap);
|
||||
}
|
79
base-codezero/src/base/thread/thread_start.cc
Normal file
79
base-codezero/src/base/thread/thread_start.cc
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* \brief NOVA-specific implementation of the Thread API
|
||||
* \author Norman Feske
|
||||
* \date 2010-01-19
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/thread.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/env.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**
|
||||
* Entry point entered by new threads
|
||||
*/
|
||||
void Thread_base::_thread_start()
|
||||
{
|
||||
Thread_base::myself()->_thread_bootstrap();
|
||||
Thread_base::myself()->entry();
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
|
||||
|
||||
/*****************
|
||||
** Thread base **
|
||||
*****************/
|
||||
|
||||
void Thread_base::_init_platform_thread()
|
||||
{
|
||||
Codezero::l4_mutex_init(utcb()->running_lock());
|
||||
Codezero::l4_mutex_lock(utcb()->running_lock()); /* block on first mutex lock */
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::_deinit_platform_thread()
|
||||
{
|
||||
env()->cpu_session()->kill_thread(_thread_cap);
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::start()
|
||||
{
|
||||
/* create thread at core */
|
||||
char buf[48];
|
||||
name(buf, sizeof(buf));
|
||||
_thread_cap = env()->cpu_session()->create_thread(buf);
|
||||
|
||||
/* assign thread to protection domain */
|
||||
env()->pd_session()->bind_thread(_thread_cap);
|
||||
|
||||
/* create new pager object and assign it to the new thread */
|
||||
Pager_capability pager_cap = env()->rm_session()->add_client(_thread_cap);
|
||||
env()->cpu_session()->set_pager(_thread_cap, pager_cap);
|
||||
|
||||
/* register initial IP and SP at core */
|
||||
addr_t thread_sp = (addr_t)&_context->stack[-4];
|
||||
thread_sp &= ~0xf; /* align initial stack to 16 byte boundary */
|
||||
env()->cpu_session()->start(_thread_cap, (addr_t)_thread_start, thread_sp);
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::cancel_blocking()
|
||||
{
|
||||
Codezero::l4_mutex_unlock(utcb()->running_lock());
|
||||
env()->cpu_session()->cancel_blocking(_thread_cap);
|
||||
}
|
67
base-codezero/src/core/core_rm_session.cc
Normal file
67
base-codezero/src/core/core_rm_session.cc
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* \brief Core-local RM session
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_rm_session.h>
|
||||
#include <platform.h>
|
||||
#include <map_local.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Rm_session::Local_addr
|
||||
Core_rm_session::attach(Dataspace_capability ds_cap, size_t size,
|
||||
off_t offset, bool use_local_addr,
|
||||
Rm_session::Local_addr local_addr)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
Dataspace_component *ds = static_cast<Dataspace_component *>(_ds_ep->obj_by_cap(ds_cap));
|
||||
if (!ds)
|
||||
throw Invalid_dataspace();
|
||||
|
||||
if (size == 0)
|
||||
size = ds->size();
|
||||
|
||||
size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask();
|
||||
size_t num_pages = page_rounded_size >> get_page_size_log2();
|
||||
|
||||
if (use_local_addr) {
|
||||
PERR("Parameter 'use_local_addr' not supported within core");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (offset) {
|
||||
PERR("Parameter 'offset' not supported within core");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate range in core's virtual address space */
|
||||
void *virt_addr;
|
||||
if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) {
|
||||
PERR("Could not allocate virtual address range in core of size %zd\n",
|
||||
page_rounded_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) {
|
||||
PERR("core-local memory mapping failed virt=%lx, phys=%lx\n",
|
||||
(addr_t)virt_addr, ds->phys_addr());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return virt_addr;
|
||||
}
|
52
base-codezero/src/core/include/core_rm_session.h
Normal file
52
base-codezero/src/core/include/core_rm_session.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* \brief Core-local region manager session
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__CORE_RM_SESSION_H_
|
||||
#define _CORE__INCLUDE__CORE_RM_SESSION_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <rm_session/rm_session.h>
|
||||
|
||||
/* core includes */
|
||||
#include <dataspace_component.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Core_rm_session : public Rm_session
|
||||
{
|
||||
private:
|
||||
|
||||
Rpc_entrypoint *_ds_ep;
|
||||
|
||||
public:
|
||||
|
||||
Core_rm_session(Rpc_entrypoint *ds_ep) : _ds_ep(ds_ep) { }
|
||||
|
||||
Local_addr attach(Dataspace_capability ds_cap, size_t size = 0,
|
||||
off_t offset = 0, bool use_local_addr = false,
|
||||
Local_addr local_addr = 0);
|
||||
|
||||
void detach(Local_addr) { }
|
||||
|
||||
Pager_capability add_client(Thread_capability) {
|
||||
return Pager_capability(); }
|
||||
|
||||
void fault_handler(Signal_context_capability) { }
|
||||
|
||||
State state() { return State(); }
|
||||
|
||||
Dataspace_capability dataspace() { return Dataspace_capability(); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_RM_SESSION_H_ */
|
71
base-codezero/src/core/include/irq_session_component.h
Normal file
71
base-codezero/src/core/include/irq_session_component.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* \brief IRQ session interface for NOVA
|
||||
* \author Norman Feske
|
||||
* \date 2010-01-30
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
|
||||
#define _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
|
||||
|
||||
#include <base/lock.h>
|
||||
#include <util/list.h>
|
||||
|
||||
#include <irq_session/capability.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Irq_session_component : public Rpc_object<Irq_session>,
|
||||
public List<Irq_session_component>::Element
|
||||
{
|
||||
private:
|
||||
|
||||
enum { STACK_SIZE = 4096 };
|
||||
|
||||
unsigned _irq_number;
|
||||
Range_allocator *_irq_alloc;
|
||||
Rpc_entrypoint _entrypoint;
|
||||
Irq_session_capability _cap;
|
||||
bool _attached;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param cap_session capability session to use
|
||||
* \param irq_alloc platform-dependent IRQ allocator
|
||||
* \param args session construction arguments
|
||||
*/
|
||||
Irq_session_component(Cap_session *cap_session,
|
||||
Range_allocator *irq_alloc,
|
||||
const char *args);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Irq_session_component();
|
||||
|
||||
/**
|
||||
* Return capability to this session
|
||||
*
|
||||
* If an initialization error occurs, returned capability is invalid.
|
||||
*/
|
||||
Irq_session_capability cap() const { return _cap; }
|
||||
|
||||
|
||||
/***************************
|
||||
** Irq session interface **
|
||||
***************************/
|
||||
|
||||
void wait_for_irq();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */
|
66
base-codezero/src/core/include/map_local.h
Normal file
66
base-codezero/src/core/include/map_local.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* \brief Core-local mapping
|
||||
* \author Norman Feske
|
||||
* \date 2010-02-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__MAP_LOCAL_H_
|
||||
#define _CORE__INCLUDE__MAP_LOCAL_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
|
||||
/* core includes */
|
||||
#include <util.h>
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Map physical pages to core-local virtual address range
|
||||
*
|
||||
* On Codezero, mappings originate from the physical address space.
|
||||
*
|
||||
* \param from_phys physical source address
|
||||
* \param to_virt core-local destination address
|
||||
* \param num_pages number of pages to map
|
||||
*
|
||||
* \return true on success
|
||||
*/
|
||||
inline bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
int res = l4_map((void *)from_phys, (void *)to_virt,
|
||||
num_pages, MAP_USR_RW, thread_myself());
|
||||
if (res < 0) {
|
||||
PERR("l4_map phys 0x%lx -> 0x%lx returned %d", from_phys, to_virt, res);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool unmap_local(addr_t virt_addr, size_t num_pages)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
int res = l4_unmap((void *)virt_addr, num_pages, thread_myself());
|
||||
if (res < 0) {
|
||||
PERR("l4_unmap returned %d", res);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */
|
72
base-codezero/src/core/include/platform.h
Normal file
72
base-codezero/src/core/include/platform.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* \brief Platform interface
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
|
||||
/* local includes */
|
||||
#include <platform_generic.h>
|
||||
#include <core_mem_alloc.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform : public Platform_generic
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Core_mem_allocator::Phys_allocator Phys_allocator;
|
||||
|
||||
Core_mem_allocator _core_mem_alloc; /* core-accessible memory */
|
||||
Phys_allocator _io_mem_alloc; /* MMIO allocator */
|
||||
Phys_allocator _io_port_alloc; /* I/O port allocator */
|
||||
Phys_allocator _irq_alloc; /* IRQ allocator */
|
||||
Rom_fs _rom_fs; /* ROM file system */
|
||||
|
||||
/**
|
||||
* Virtual address range usable by non-core processes
|
||||
*/
|
||||
addr_t _vm_base;
|
||||
size_t _vm_size;
|
||||
|
||||
int _init_rom_fs();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform();
|
||||
|
||||
|
||||
/********************************
|
||||
** Generic platform interface **
|
||||
********************************/
|
||||
|
||||
Range_allocator *ram_alloc() { return _core_mem_alloc.phys_alloc(); }
|
||||
Range_allocator *io_mem_alloc() { return &_io_mem_alloc; }
|
||||
Range_allocator *io_port_alloc() { return &_io_port_alloc; }
|
||||
Range_allocator *irq_alloc() { return &_irq_alloc; }
|
||||
Range_allocator *region_alloc() { return _core_mem_alloc.virt_alloc(); }
|
||||
Allocator *core_mem_alloc() { return &_core_mem_alloc; }
|
||||
addr_t vm_start() const { return _vm_base; }
|
||||
size_t vm_size() const { return _vm_size; }
|
||||
Rom_fs *rom_fs() { return &_rom_fs; }
|
||||
|
||||
void wait_for_exit();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_H_ */
|
74
base-codezero/src/core/include/platform_pd.h
Normal file
74
base-codezero/src/core/include/platform_pd.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* \brief Protection-domain facility
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||
|
||||
/* core includes */
|
||||
#include <platform_thread.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_thread;
|
||||
class Platform_pd
|
||||
{
|
||||
private:
|
||||
|
||||
enum { MAX_THREADS_PER_PD = 32 };
|
||||
enum { UTCB_VIRT_BASE = 0x30000000 };
|
||||
enum { UTCB_AREA_SIZE = MAX_THREADS_PER_PD*sizeof(struct Codezero::utcb) };
|
||||
|
||||
int _space_id;
|
||||
|
||||
bool utcb_in_use[MAX_THREADS_PER_PD];
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* Constructors
|
||||
*/
|
||||
Platform_pd(bool core);
|
||||
Platform_pd(signed pd_id = -1, bool create = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Platform_pd();
|
||||
|
||||
/**
|
||||
* Bind thread to protection domain
|
||||
*
|
||||
* \return 0 on success or
|
||||
* -1 if thread ID allocation failed.
|
||||
*/
|
||||
int bind_thread(Platform_thread *thread);
|
||||
|
||||
/**
|
||||
* Unbind thread from protection domain
|
||||
*
|
||||
* Free the thread's slot and update thread object.
|
||||
*/
|
||||
void unbind_thread(Platform_thread *thread);
|
||||
|
||||
/**
|
||||
* Assign parent interface to protection domain
|
||||
*/
|
||||
int assign_parent(Native_capability parent) { return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */
|
135
base-codezero/src/core/include/platform_thread.h
Normal file
135
base-codezero/src/core/include/platform_thread.h
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* \brief Thread facility
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/pager.h>
|
||||
#include <base/thread_state.h>
|
||||
#include <base/native_types.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_pd;
|
||||
class Platform_thread
|
||||
{
|
||||
private:
|
||||
|
||||
friend class Platform_pd;
|
||||
|
||||
enum { PD_NAME_MAX_LEN = 64 };
|
||||
|
||||
int _tid; /* global codezero thread ID */
|
||||
int _space_id;
|
||||
addr_t _utcb;
|
||||
char _name[PD_NAME_MAX_LEN];
|
||||
Pager_object *_pager;
|
||||
|
||||
/**
|
||||
* Assign physical thread ID and UTCB address to thread
|
||||
*
|
||||
* This function is called from 'Platform_pd::bind_thread'.
|
||||
*/
|
||||
void _assign_physical_thread(int tid, int space_id, addr_t utcb) {
|
||||
_tid = tid; _space_id = space_id; _utcb = utcb; }
|
||||
|
||||
public:
|
||||
|
||||
enum { THREAD_INVALID = -1 }; /* invalid thread number */
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_thread(const char *name = 0, unsigned priority = 0,
|
||||
int thread_id = THREAD_INVALID);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Platform_thread();
|
||||
|
||||
/**
|
||||
* Start thread
|
||||
*
|
||||
* \param ip instruction pointer to start at
|
||||
* \param sp stack pointer to use
|
||||
* \param cpu_no target cpu
|
||||
*
|
||||
* \retval 0 successful
|
||||
* \retval -1 thread could not be started
|
||||
*/
|
||||
int start(void *ip, void *sp, unsigned int cpu_no = 0);
|
||||
|
||||
/**
|
||||
* Pause this thread
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resume this thread
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* Cancel currently blocking operation
|
||||
*/
|
||||
void cancel_blocking();
|
||||
|
||||
/**
|
||||
* Request thread state
|
||||
*
|
||||
* \param state_dst destination state buffer
|
||||
*
|
||||
* \retval 0 successful
|
||||
* \retval -1 thread state not accessible
|
||||
*/
|
||||
int state(Genode::Thread_state *state_dst);
|
||||
|
||||
|
||||
/************************
|
||||
** Accessor functions **
|
||||
************************/
|
||||
|
||||
/**
|
||||
* Set pager capability
|
||||
*/
|
||||
Pager_object *pager(Pager_object *pager) const { return _pager; }
|
||||
void pager(Pager_object *pager) { _pager = pager; }
|
||||
Pager_object *pager() { return _pager; }
|
||||
|
||||
/**
|
||||
* Return identification of thread when faulting
|
||||
*/
|
||||
unsigned long pager_object_badge() const { return _tid; }
|
||||
|
||||
/**
|
||||
* Set the executing CPU for this thread.
|
||||
*/
|
||||
void set_cpu(unsigned int cpu_no);
|
||||
|
||||
/**
|
||||
* Get thread name
|
||||
*/
|
||||
const char *name() const { return "noname"; }
|
||||
|
||||
|
||||
/***********************
|
||||
** Codezero specific **
|
||||
***********************/
|
||||
|
||||
addr_t utcb() const { return _utcb; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */
|
46
base-codezero/src/core/include/util.h
Normal file
46
base-codezero/src/core/include/util.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* \brief Core-internal utilities
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__UTIL_H_
|
||||
#define _CORE__INCLUDE__UTIL_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <rm_session/rm_session.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
inline size_t get_page_size_log2() { return 12; }
|
||||
inline size_t get_page_size() { return 1 << get_page_size_log2(); }
|
||||
inline addr_t get_page_mask() { return ~(get_page_size() - 1); }
|
||||
inline addr_t trunc_page(addr_t addr) { return addr & get_page_mask(); }
|
||||
inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); }
|
||||
|
||||
inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; }
|
||||
inline size_t constrain_map_size_log2(size_t size_log2) { return get_page_size_log2(); }
|
||||
|
||||
inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip,
|
||||
Rm_session::Fault_type pf_type,
|
||||
unsigned long faulter_badge)
|
||||
{
|
||||
printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)\n", msg,
|
||||
pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ",
|
||||
(void *)pf_addr, (void *)pf_ip,
|
||||
faulter_badge);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__UTIL_H_ */
|
27
base-codezero/src/core/io_mem_session_support.cc
Normal file
27
base-codezero/src/core/io_mem_session_support.cc
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* \brief Implementation of the IO_MEM session interface
|
||||
* \author Norman Feske
|
||||
* \date 2009-03-29
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <io_mem_session_component.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Io_mem_session_component::_unmap_local(addr_t base, size_t size)
|
||||
{ }
|
||||
|
||||
|
||||
addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
|
||||
{ return 0; }
|
58
base-codezero/src/core/io_port_session_component.cc
Normal file
58
base-codezero/src/core/io_port_session_component.cc
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* \brief Implementation of the IO_PORT session interface
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include "io_port_session_component.h"
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**************
|
||||
** Port API **
|
||||
**************/
|
||||
|
||||
unsigned char Io_port_session_component::inb(unsigned short address) {
|
||||
return 0; }
|
||||
|
||||
|
||||
unsigned short Io_port_session_component::inw(unsigned short address) {
|
||||
return 0; }
|
||||
|
||||
|
||||
unsigned Io_port_session_component::inl(unsigned short address) {
|
||||
return 0; }
|
||||
|
||||
|
||||
void Io_port_session_component::outb(unsigned short address, unsigned char value)
|
||||
{ }
|
||||
|
||||
|
||||
void Io_port_session_component::outw(unsigned short address, unsigned short value)
|
||||
{ }
|
||||
|
||||
|
||||
void Io_port_session_component::outl(unsigned short address, unsigned value)
|
||||
{ }
|
||||
|
||||
|
||||
/******************************
|
||||
** Constructor / destructor **
|
||||
******************************/
|
||||
|
||||
Io_port_session_component::Io_port_session_component(Range_allocator *io_port_alloc,
|
||||
const char *args)
|
||||
: _io_port_alloc(io_port_alloc)
|
||||
{ }
|
||||
|
||||
|
||||
Io_port_session_component::~Io_port_session_component()
|
||||
{ }
|
72
base-codezero/src/core/irq_session_component.cc
Normal file
72
base-codezero/src/core/irq_session_component.cc
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* \brief Implementation of IRQ session component
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
|
||||
/* core includes */
|
||||
#include <irq_root.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Irq_session_component::wait_for_irq()
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
/* attach thread to IRQ when first called */
|
||||
if (!_attached) {
|
||||
int ret = l4_irq_control(IRQ_CONTROL_REGISTER, 0, _irq_number);
|
||||
if (ret < 0) {
|
||||
PERR("l4_irq_control(IRQ_CONTROL_REGISTER) returned %d", ret);
|
||||
sleep_forever();
|
||||
}
|
||||
_attached = true;
|
||||
}
|
||||
|
||||
/* block for IRQ */
|
||||
int ret = l4_irq_control(IRQ_CONTROL_WAIT, 0, _irq_number);
|
||||
if (ret < 0)
|
||||
PWRN("l4_irq_control(IRQ_CONTROL_WAIT) returned %d", ret);
|
||||
}
|
||||
|
||||
|
||||
Irq_session_component::Irq_session_component(Cap_session *cap_session,
|
||||
Range_allocator *irq_alloc,
|
||||
const char *args)
|
||||
:
|
||||
_irq_alloc(irq_alloc),
|
||||
_entrypoint(cap_session, STACK_SIZE, "irq"),
|
||||
_attached(false)
|
||||
{
|
||||
long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1);
|
||||
if (!irq_alloc || (irq_number == -1)||
|
||||
irq_alloc->alloc_addr(1, irq_number) != Range_allocator::ALLOC_OK) {
|
||||
PERR("unavailable IRQ %lx requested", irq_number);
|
||||
return;
|
||||
}
|
||||
_irq_number = irq_number;
|
||||
_cap = Irq_session_capability(_entrypoint.manage(this));
|
||||
}
|
||||
|
||||
|
||||
Irq_session_component::~Irq_session_component()
|
||||
{
|
||||
PERR("not yet implemented");
|
||||
}
|
||||
|
293
base-codezero/src/core/platform.cc
Normal file
293
base-codezero/src/core/platform.cc
Normal file
@ -0,0 +1,293 @@
|
||||
/*
|
||||
* \brief Platform interface implementation
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/thread.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_parent.h>
|
||||
#include <platform.h>
|
||||
#include <map_local.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
enum { verbose_boot_info = true };
|
||||
|
||||
/*
|
||||
* Memory-layout information provided by the linker script
|
||||
*/
|
||||
|
||||
/* virtual address range consumed by core's program image */
|
||||
extern unsigned _prog_img_beg, _prog_img_end;
|
||||
|
||||
/* physical address range occupied by core */
|
||||
extern addr_t _vma_start, _lma_start;
|
||||
|
||||
|
||||
/**************************
|
||||
** Boot-module handling **
|
||||
**************************/
|
||||
|
||||
/**
|
||||
* Scan ROM module image for boot modules
|
||||
*
|
||||
* By convention, the boot modules start at the page after core's BSS segment.
|
||||
*/
|
||||
int Platform::_init_rom_fs()
|
||||
{
|
||||
/**
|
||||
* Format of module meta-data as found in the ROM module image
|
||||
*/
|
||||
struct Module
|
||||
{
|
||||
long name; /* physical address of null-terminated string */
|
||||
long base; /* physical address of module data */
|
||||
long size; /* size of module data in bytes */
|
||||
};
|
||||
|
||||
/* find base address of ROM module image */
|
||||
addr_t phys_base = round_page((addr_t)&_prog_img_end);
|
||||
|
||||
/* map the first page of the image containing the module meta data */
|
||||
class Out_of_virtual_memory_during_rom_fs_init { };
|
||||
void *virt_base = 0;
|
||||
if (!_core_mem_alloc.virt_alloc()->alloc(get_page_size(), &virt_base))
|
||||
throw Out_of_virtual_memory_during_rom_fs_init();
|
||||
|
||||
if (!map_local(phys_base, (addr_t)virt_base, 1)) {
|
||||
PERR("map_local failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* remove page containing module infos from physical memory allocator */
|
||||
_core_mem_alloc.phys_alloc()->remove_range(phys_base, get_page_size());
|
||||
|
||||
/* validate the presence of a ROM image by checking the magic cookie */
|
||||
const char cookie[4] = {'G', 'R', 'O', 'M'};
|
||||
for (size_t i = 0; i < sizeof(cookie); i++)
|
||||
if (cookie[i] != ((char *)virt_base)[i]) {
|
||||
PERR("could not detect ROM modules");
|
||||
return -2;
|
||||
}
|
||||
|
||||
printf("detected ROM module image at 0x%p\n", (void *)phys_base);
|
||||
|
||||
/* detect overly large meta data, we only support 4K */
|
||||
addr_t end_of_header = ((long *)virt_base)[1];
|
||||
size_t header_size = end_of_header - (long)phys_base;
|
||||
if (header_size > get_page_size()) {
|
||||
PERR("ROM fs module header exceeds %d bytes", get_page_size());
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* start of module list */
|
||||
Module *module = (Module *)((addr_t)virt_base + 2*sizeof(long));
|
||||
|
||||
/*
|
||||
* Interate over module list and populate core's ROM file system with
|
||||
* 'Rom_module' objects.
|
||||
*/
|
||||
for (; module->name; module++) {
|
||||
|
||||
/* convert physical address of module name to core-local address */
|
||||
char *name = (char *)(module->name - phys_base + (addr_t)virt_base);
|
||||
|
||||
printf("ROM module \"%s\" at physical address 0x%p, size=%zd\n",
|
||||
name, (void *)module->base, (size_t)module->size);
|
||||
|
||||
Rom_module *rom_module = new (core_mem_alloc())
|
||||
Rom_module(module->base, module->size, name);
|
||||
|
||||
_rom_fs.insert(rom_module);
|
||||
|
||||
/* remove module from physical memory allocator */
|
||||
_core_mem_alloc.phys_alloc()->remove_range(module->base, round_page(module->size));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************************************
|
||||
** Support for core memory management **
|
||||
****************************************/
|
||||
|
||||
bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, unsigned size_log2)
|
||||
{
|
||||
return map_local(phys_addr, virt_addr, 1 << (size_log2 - get_page_size_log2()));
|
||||
}
|
||||
|
||||
|
||||
/************************
|
||||
** Platform interface **
|
||||
************************/
|
||||
|
||||
Platform::Platform() :
|
||||
_io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()),
|
||||
_irq_alloc(core_mem_alloc()), _vm_base(0), _vm_size(0)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
/* init core UTCB */
|
||||
static char main_utcb[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
|
||||
static struct exregs_data exregs;
|
||||
exregs_set_utcb(&exregs, (unsigned long)&main_utcb[0]);
|
||||
l4_exchange_registers(&exregs, thread_myself());
|
||||
|
||||
/* error handling is futile at this point */
|
||||
|
||||
/* read number of capabilities */
|
||||
int num_caps;
|
||||
int ret;
|
||||
if ((ret = l4_capability_control(CAP_CONTROL_NCAPS,
|
||||
0, &num_caps)) < 0) {
|
||||
PERR("l4_capability_control(CAP_CONTROL_NCAPS) returned %d", ret);
|
||||
class Could_not_obtain_num_of_capabilities { };
|
||||
throw Could_not_obtain_num_of_capabilities();
|
||||
}
|
||||
|
||||
struct capability cap_array[num_caps];
|
||||
|
||||
if (verbose_boot_info)
|
||||
printf("allocated cap array[%d] of size %d on stack\n",
|
||||
num_caps, sizeof(cap_array));
|
||||
|
||||
/* read all capabilities */
|
||||
if ((ret = l4_capability_control(CAP_CONTROL_READ,
|
||||
0, cap_array)) < 0) {
|
||||
PERR("l4_capability_control(CAP_CONTROL_READ) returned %d", ret);
|
||||
class Read_caps_failed { };
|
||||
throw Read_caps_failed();
|
||||
}
|
||||
|
||||
/* initialize core allocators */
|
||||
bool phys_mem_defined = false;
|
||||
addr_t dev_mem_base = 0;
|
||||
for (int i = 0; i < num_caps; i++) {
|
||||
struct capability *cap = &cap_array[i];
|
||||
|
||||
addr_t base = cap->start << get_page_size_log2(),
|
||||
size = cap->size << get_page_size_log2();
|
||||
|
||||
if (verbose_boot_info)
|
||||
printf("cap type=%x, rtype=%x, base=%lx, size=%lx\n",
|
||||
cap_type(cap), cap_rtype(cap), base, size);
|
||||
|
||||
switch (cap_type(cap)) {
|
||||
|
||||
case CAP_TYPE_MAP_VIRTMEM:
|
||||
|
||||
/*
|
||||
* Use first non-UTCB virtual address range as default
|
||||
* virtual memory range usable for all processes.
|
||||
*/
|
||||
if (_vm_size == 0) {
|
||||
|
||||
/* exclude page at virtual address 0 */
|
||||
if (base == 0 && size >= get_page_size()) {
|
||||
base += get_page_size();
|
||||
size -= get_page_size();
|
||||
}
|
||||
|
||||
_vm_base = base;
|
||||
_vm_size = size;
|
||||
|
||||
/* add range as free range to core's virtual address allocator */
|
||||
_core_mem_alloc.virt_alloc()->add_range(base, size);
|
||||
break;
|
||||
}
|
||||
|
||||
PWRN("ignoring additional virtual address range [%lx,%lx)",
|
||||
base, base + size);
|
||||
break;
|
||||
|
||||
case CAP_TYPE_MAP_PHYSMEM:
|
||||
|
||||
/*
|
||||
* We interpret the first physical memory resource that is bigger
|
||||
* than typical device resources as RAM.
|
||||
*/
|
||||
enum { RAM_SIZE_MIN = 16*1024*1024 };
|
||||
if (!phys_mem_defined && size > RAM_SIZE_MIN) {
|
||||
_core_mem_alloc.phys_alloc()->add_range(base, size);
|
||||
phys_mem_defined = true;
|
||||
dev_mem_base = base + size;
|
||||
}
|
||||
break;
|
||||
|
||||
case CAP_TYPE_IPC:
|
||||
case CAP_TYPE_UMUTEX:
|
||||
case CAP_TYPE_IRQCTRL:
|
||||
case CAP_TYPE_QUANTITY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addr_t core_virt_beg = trunc_page((addr_t)&_prog_img_beg),
|
||||
core_virt_end = round_page((addr_t)&_prog_img_end);
|
||||
size_t core_size = core_virt_end - core_virt_beg;
|
||||
|
||||
printf("core image:\n");
|
||||
printf(" virtual address range [%08lx,%08lx) size=0x%zx\n",
|
||||
core_virt_beg, core_virt_end, core_size);
|
||||
printf(" physically located at 0x%08lx\n", _lma_start);
|
||||
|
||||
/* remove core image from core's virtual address allocator */
|
||||
_core_mem_alloc.virt_alloc()->remove_range(core_virt_beg, core_size);
|
||||
|
||||
/* preserve context area in core's virtual address space */
|
||||
_core_mem_alloc.virt_alloc()->raw()->remove_range(Thread_base::CONTEXT_AREA_VIRTUAL_BASE,
|
||||
Thread_base::CONTEXT_AREA_VIRTUAL_SIZE);
|
||||
|
||||
/* remove used core memory from physical memory allocator */
|
||||
_core_mem_alloc.phys_alloc()->remove_range(_lma_start, core_size);
|
||||
|
||||
/* remove magically mapped UART from core virtual memory */
|
||||
_core_mem_alloc.virt_alloc()->remove_range(USERSPACE_CONSOLE_VBASE, get_page_size());
|
||||
|
||||
/* add boot modules to ROM fs */
|
||||
if (_init_rom_fs() < 0) {
|
||||
PERR("initialization of romfs failed - halt.");
|
||||
while(1);
|
||||
}
|
||||
|
||||
/* initialize interrupt allocator */
|
||||
_irq_alloc.add_range(0, 255);
|
||||
|
||||
/* regard physical addresses higher than memory area as MMIO */
|
||||
_io_mem_alloc.add_range(dev_mem_base, 0x80000000 - dev_mem_base);
|
||||
|
||||
/*
|
||||
* Print statistics about allocator initialization
|
||||
*/
|
||||
printf("VM area at [%08lx,%08lx)\n", _vm_base, _vm_base + _vm_size);
|
||||
|
||||
if (verbose_boot_info) {
|
||||
printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree();
|
||||
printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree();
|
||||
printf(":io_mem_alloc: "); _io_mem_alloc.raw()->dump_addr_tree();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Platform::wait_for_exit()
|
||||
{
|
||||
sleep_forever();
|
||||
}
|
||||
|
||||
|
||||
void Core_parent::exit(int exit_value) { }
|
124
base-codezero/src/core/platform_pd.cc
Normal file
124
base-codezero/src/core/platform_pd.cc
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* \brief Protection-domain facility
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform_pd.h>
|
||||
#include <platform.h>
|
||||
#include <util.h>
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Codezero;
|
||||
|
||||
|
||||
/***************************
|
||||
** Public object members **
|
||||
***************************/
|
||||
|
||||
int Platform_pd::bind_thread(Platform_thread *thread)
|
||||
{
|
||||
/* allocate new thread at the kernel */
|
||||
struct task_ids ids = { 1, _space_id, TASK_ID_INVALID };
|
||||
int ret = l4_thread_control(THREAD_CREATE | TC_SHARE_SPACE, &ids);
|
||||
if (ret < 0) {
|
||||
PERR("l4_thread_control returned %d, tid=%d\n", ret, ids.tid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allocate UTCB for new thread */
|
||||
int utcb_idx;
|
||||
for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++)
|
||||
if (!utcb_in_use[utcb_idx]) break;
|
||||
|
||||
if (utcb_idx == MAX_THREADS_PER_PD) {
|
||||
PERR("UTCB allocation failed");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* mark UTCB as being in use */
|
||||
utcb_in_use[utcb_idx] = true;
|
||||
|
||||
/* map UTCB area for the first thread of a new PD */
|
||||
if (utcb_idx == 0) {
|
||||
void *utcb_phys = 0;
|
||||
if (!platform()->ram_alloc()->alloc(UTCB_AREA_SIZE, &utcb_phys)) {
|
||||
PERR("could not allocate physical pages for UTCB");
|
||||
return -3;
|
||||
}
|
||||
|
||||
ret = l4_map(utcb_phys, (void *)UTCB_VIRT_BASE,
|
||||
UTCB_AREA_SIZE/get_page_size(), MAP_USR_RW, ids.tid);
|
||||
if (ret < 0) {
|
||||
PERR("UTCB mapping into new PD failed, ret=%d", ret);
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
|
||||
addr_t utcb_addr = UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb);
|
||||
thread->_assign_physical_thread(ids.tid, _space_id, utcb_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::unbind_thread(Platform_thread *thread)
|
||||
{
|
||||
/* find UTCB index of thread */
|
||||
unsigned utcb_idx;
|
||||
for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++)
|
||||
if (thread->utcb() == UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb))
|
||||
break;
|
||||
|
||||
if (utcb_idx == MAX_THREADS_PER_PD) {
|
||||
PWRN("could not find UTCB index of thread");
|
||||
return;
|
||||
}
|
||||
|
||||
utcb_in_use[utcb_idx] = false;
|
||||
|
||||
PWRN("not fully implemented");
|
||||
}
|
||||
|
||||
|
||||
Platform_pd::Platform_pd(bool core)
|
||||
{
|
||||
PWRN("not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
Platform_pd::Platform_pd(signed pd_id, bool create) : _space_id(-1)
|
||||
{
|
||||
_space_id = -1;
|
||||
|
||||
/* mark all UTCBs of the new PD as free */
|
||||
for (int i = 0; i < MAX_THREADS_PER_PD; i++)
|
||||
utcb_in_use[i] = false;
|
||||
|
||||
struct task_ids ids = { -1, -1, -1 };
|
||||
|
||||
int ret = l4_thread_control(THREAD_CREATE | TC_NEW_SPACE, &ids);
|
||||
if (ret < 0) {
|
||||
PERR("l4_thread_control(THREAD_CREATE | TC_NEW_SPACE) returned %d", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* set space ID to valid value to indicate success */
|
||||
_space_id = ids.spid;
|
||||
}
|
||||
|
||||
|
||||
Platform_pd::~Platform_pd()
|
||||
{
|
||||
PWRN("not yet implemented");
|
||||
}
|
104
base-codezero/src/core/platform_thread.cc
Normal file
104
base-codezero/src/core/platform_thread.cc
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* \brief Thread facility
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <util/string.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform_thread.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
enum { verbose_thread_start = true };
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Codezero;
|
||||
|
||||
|
||||
void Platform_thread::set_cpu(unsigned int cpu_no)
|
||||
{
|
||||
PDBG("not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
|
||||
{
|
||||
Native_thread_id pager = _pager ? _pager->cap().tid() : -1;
|
||||
|
||||
/* setup thread context */
|
||||
struct exregs_data exregs;
|
||||
exregs.flags = 0;
|
||||
exregs_set_stack(&exregs, (unsigned long)sp);
|
||||
exregs_set_pc (&exregs, (unsigned long)ip);
|
||||
exregs_set_pager(&exregs, pager.tid);
|
||||
exregs_set_utcb (&exregs, _utcb);
|
||||
|
||||
int ret = l4_exchange_registers(&exregs, _tid);
|
||||
if (ret < 0) {
|
||||
printf("l4_exchange_registers returned ret=%d\n", ret);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* start execution */
|
||||
struct task_ids ids = { _tid, _space_id, _tid };
|
||||
ret = l4_thread_control(THREAD_RUN, &ids);
|
||||
if (ret < 0) {
|
||||
printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret);
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (verbose_thread_start)
|
||||
printf("core started thread \"%s\" with ID %d inside space ID %d\n",
|
||||
_name, _tid, _space_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::pause()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::resume()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
||||
|
||||
|
||||
int Platform_thread::state(Thread_state *state_dst)
|
||||
{
|
||||
PDBG("not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::cancel_blocking()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
||||
|
||||
|
||||
Platform_thread::Platform_thread(const char *name, unsigned, int thread_id)
|
||||
: _tid(-1)
|
||||
{
|
||||
strncpy(_name, name, sizeof(_name));
|
||||
}
|
||||
|
||||
|
||||
Platform_thread::~Platform_thread()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
65
base-codezero/src/core/ram_session_support.cc
Normal file
65
base-codezero/src/core/ram_session_support.cc
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* \brief Export RAM dataspace as shared memory object (dummy)
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <util/misc_math.h>
|
||||
|
||||
/* core includes */
|
||||
#include <ram_session_component.h>
|
||||
#include <platform.h>
|
||||
#include <map_local.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { }
|
||||
void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { }
|
||||
|
||||
void Ram_session_component::_clear_ds (Dataspace_component *ds)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
/*
|
||||
* Map dataspace core-locally, memset, unmap dataspace
|
||||
*/
|
||||
|
||||
size_t page_rounded_size = (ds->size() + get_page_size() - 1) & get_page_mask();
|
||||
size_t num_pages = page_rounded_size >> get_page_size_log2();
|
||||
|
||||
/* allocate range in core's virtual address space */
|
||||
void *virt_addr;
|
||||
if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) {
|
||||
PERR("Could not allocate virtual address range in core of size %zd\n",
|
||||
page_rounded_size);
|
||||
return;
|
||||
}
|
||||
|
||||
/* map the dataspace's physical pages to corresponding virtual addresses */
|
||||
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) {
|
||||
PERR("core-local memory mapping failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(virt_addr, 0, ds->size());
|
||||
|
||||
/* unmap dataspace from core */
|
||||
if (!unmap_local((addr_t)virt_addr, num_pages)) {
|
||||
PERR("could not unmap %zd pages from virtual address range at %p",
|
||||
num_pages, virt_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* free core's virtual address space */
|
||||
platform()->region_alloc()->free(virt_addr, page_rounded_size);
|
||||
}
|
28
base-codezero/src/core/rm_session_support.cc
Normal file
28
base-codezero/src/core/rm_session_support.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* \brief RM-session implementation
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <rm_session_component.h>
|
||||
#include <util.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Codezero;
|
||||
|
||||
|
||||
void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size)
|
||||
{
|
||||
l4_unmap((void *)virt_base, size >> get_page_size_log2(), badge());
|
||||
}
|
55
base-codezero/src/core/target.inc
Normal file
55
base-codezero/src/core/target.inc
Normal file
@ -0,0 +1,55 @@
|
||||
TARGET = core
|
||||
LIBS = cxx ipc heap core_printf process pager lock \
|
||||
raw_signal raw_server
|
||||
|
||||
GEN_CORE_DIR = $(BASE_DIR)/src/core
|
||||
|
||||
SRC_CC = \
|
||||
main.cc \
|
||||
ram_session_component.cc \
|
||||
ram_session_support.cc \
|
||||
rom_session_component.cc \
|
||||
cpu_session_component.cc \
|
||||
pd_session_component.cc \
|
||||
io_mem_session_component.cc \
|
||||
io_mem_session_support.cc \
|
||||
thread.cc \
|
||||
thread_start.cc \
|
||||
thread_bootstrap.cc \
|
||||
platform_thread.cc \
|
||||
platform_pd.cc \
|
||||
platform.cc \
|
||||
dataspace_component.cc \
|
||||
rm_session_component.cc \
|
||||
rm_session_support.cc \
|
||||
io_port_session_component.cc \
|
||||
irq_session_component.cc \
|
||||
signal_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
core_rm_session.cc \
|
||||
core_mem_alloc.cc \
|
||||
dump_alloc.cc \
|
||||
context_area.cc
|
||||
|
||||
INC_DIR = $(REP_DIR)/src/core/include \
|
||||
$(GEN_CORE_DIR)/include \
|
||||
$(REP_DIR)/include/codezero/dummies
|
||||
|
||||
vpath main.cc $(GEN_CORE_DIR)
|
||||
vpath ram_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath rom_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath cpu_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath pd_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath rm_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath signal_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath signal_source_component.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath dump_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath context_area.cc $(GEN_CORE_DIR)
|
||||
vpath %.cc $(REP_DIR)/src/core
|
||||
vpath thread_bootstrap.cc $(BASE_DIR)/src/base/thread
|
||||
vpath thread.cc $(BASE_DIR)/src/base/thread
|
||||
|
4
base-codezero/src/core/target.mk
Normal file
4
base-codezero/src/core/target.mk
Normal file
@ -0,0 +1,4 @@
|
||||
include $(PRG_DIR)/target.inc
|
||||
|
||||
LD_TEXT_ADDR = 0x100000
|
||||
|
121
base-codezero/src/core/thread_start.cc
Normal file
121
base-codezero/src/core/thread_start.cc
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* \brief Implementation of Thread API interface for core
|
||||
* \author Norman Feske
|
||||
* \date 2006-05-03
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/thread.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <platform_thread.h>
|
||||
|
||||
enum { verbose_thread_start = true };
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Thread_base::_init_platform_thread() { }
|
||||
|
||||
|
||||
void Thread_base::_deinit_platform_thread() { }
|
||||
|
||||
|
||||
/**
|
||||
* Create and start new thread
|
||||
*
|
||||
* \param space_no space ID in which the new thread will be executed
|
||||
* \param sp initial stack pointer
|
||||
* \param ip initial instruction pointer
|
||||
* \return new thread ID, or
|
||||
* negative error code
|
||||
*/
|
||||
inline int create_thread(int space_no,
|
||||
void *sp, void *ip,
|
||||
int pager_tid = 1)
|
||||
{
|
||||
using namespace Codezero;
|
||||
|
||||
struct task_ids ids = { 1, space_no, TASK_ID_INVALID };
|
||||
|
||||
/* allocate new thread at the kernel */
|
||||
unsigned long flags = THREAD_CREATE | TC_SHARE_SPACE | TC_SHARE_GROUP;
|
||||
int ret = l4_thread_control(flags, &ids);
|
||||
if (ret < 0) {
|
||||
PERR("l4_thread_control returned %d, spid=%d\n",
|
||||
ret, ids.spid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned long utcb_base_addr = (unsigned long)l4_get_utcb();
|
||||
|
||||
/* calculate utcb address of new thread */
|
||||
unsigned long new_utcb = utcb_base_addr + ids.tid*sizeof(struct utcb);
|
||||
|
||||
/* setup thread context */
|
||||
struct exregs_data exregs;
|
||||
exregs_set_stack(&exregs, (unsigned long)sp);
|
||||
exregs_set_pc (&exregs, (unsigned long)ip);
|
||||
exregs_set_pager(&exregs, pager_tid);
|
||||
exregs_set_utcb (&exregs, new_utcb);
|
||||
|
||||
ret = l4_exchange_registers(&exregs, ids.tid);
|
||||
if (ret < 0) {
|
||||
printf("l4_exchange_registers returned ret=%d\n", ret);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* start execution */
|
||||
ret = l4_thread_control(THREAD_RUN, &ids);
|
||||
if (ret < 0) {
|
||||
printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret);
|
||||
return -3;
|
||||
}
|
||||
|
||||
/* return new thread ID allocated by the kernel */
|
||||
return ids.tid;
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::_thread_start()
|
||||
{
|
||||
Thread_base::myself()->_thread_bootstrap();
|
||||
Thread_base::myself()->entry();
|
||||
sleep_forever();
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::start()
|
||||
{
|
||||
/* create and start platform thread */
|
||||
_tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name);
|
||||
|
||||
_tid.l4id = create_thread(1, &_context->stack[-4], (void *)&_thread_start);
|
||||
if (_tid.l4id.tid < 0)
|
||||
PERR("create_thread returned %d", _tid.l4id.tid);
|
||||
|
||||
if (verbose_thread_start)
|
||||
printf("core started local thread \"%s\" with ID %d\n",
|
||||
_context->name, _tid.l4id.tid);
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::cancel_blocking()
|
||||
{
|
||||
PWRN("not implemented");
|
||||
}
|
||||
|
||||
|
74
base-codezero/src/kernel/target.mk
Normal file
74
base-codezero/src/kernel/target.mk
Normal file
@ -0,0 +1,74 @@
|
||||
TARGET = codezero
|
||||
|
||||
-include $(BUILD_BASE_DIR)/etc/codezero.conf
|
||||
ifeq ($(wildcard $(CODEZERO_DIR)),)
|
||||
$(error No valid kernel configured in 'etc/codezero.conf')
|
||||
endif
|
||||
|
||||
include $(REP_DIR)/lib/mk/codezero_cml.inc
|
||||
|
||||
TOOL_CHAIN_DIR = $(dir $(CROSS_DEV_PREFIX))
|
||||
CODEZERO_DST_DIR = $(BUILD_BASE_DIR)/kernel/codezero
|
||||
CODEZERO_BUILD_DIR = $(CODEZERO_DST_DIR)/build
|
||||
|
||||
.PHONY: $(TARGET)
|
||||
|
||||
MIRROR_COPY := conts/baremetal/empty conts/userlibs \
|
||||
build.py include SConstruct src loader
|
||||
|
||||
MIRROR_SYMLINK := scripts tools
|
||||
|
||||
update_copy = $(VERBOSE)tar c -C $(CODEZERO_DIR) $(MIRROR_COPY) | tar x -C $(CODEZERO_DST_DIR)
|
||||
|
||||
ifneq ($(VERBOSE),)
|
||||
CODEZERO_STDOUT := > /dev/null
|
||||
endif
|
||||
|
||||
#
|
||||
# Environment variables passed to the Codezero build system
|
||||
#
|
||||
BUILD_ENV = PATH=$(dir $(CROSS_DEV_PREFIX)):$$PATH
|
||||
|
||||
#
|
||||
# Local copy of the CML file used for supplying the configuration
|
||||
# to the Codezero build system.
|
||||
#
|
||||
LOCAL_CONFIG_CML := $(shell pwd)/config.cml
|
||||
|
||||
$(TARGET): $(CODEZERO_BUILD_DIR)
|
||||
$(MSG_BUILD)kernel
|
||||
$(update_copy)
|
||||
$(VERBOSE)cd $(CODEZERO_DST_DIR); $(BUILD_ENV) ./build.py $(CODEZERO_STDOUT)
|
||||
|
||||
#
|
||||
# Mirror the parts of the Codezero source tree that are relevant for building
|
||||
# the kernel
|
||||
#
|
||||
$(CODEZERO_DST_DIR): $(CODEZERO_DIR)
|
||||
$(VERBOSE)test -d $@ || mkdir -p $@
|
||||
$(VERBOSE)for d in $(MIRROR_SYMLINK); do ln -sf $(realpath $^)/$$d $@/$$d; done
|
||||
|
||||
$(CODEZERO_BUILD_DIR): $(CODEZERO_DST_DIR) $(CODEZERO_CML)
|
||||
$(update_copy)
|
||||
$(VERBOSE)cp $(CODEZERO_CML) $(LOCAL_CONFIG_CML)
|
||||
@#
|
||||
@# Create copy of the CML config in the local build directory to update
|
||||
@# the tool chain parameters according to the CROSS_DEV_PREFIX configured
|
||||
@# for Genode.
|
||||
@#
|
||||
$(VERBOSE)sed -i "/TOOLCHAIN_USERSPACE/s/\".*\"/\"$(notdir $(CROSS_DEV_PREFIX))\"/" $(LOCAL_CONFIG_CML)
|
||||
$(VERBOSE)sed -i "/TOOLCHAIN_KERNEL/s/\".*\"/\"$(notdir $(CROSS_DEV_PREFIX))\"/" $(LOCAL_CONFIG_CML)
|
||||
$(VERBOSE)cd $(CODEZERO_DST_DIR); $(BUILD_ENV) ./build.py -C -b -f $(LOCAL_CONFIG_CML) $(CODEZERO_STDOUT)
|
||||
|
||||
clean cleanall: clean_codezero
|
||||
|
||||
#
|
||||
# Make sure to execute the 'clean_codezero' rule prior the generic clean
|
||||
# rule in 'prg.mk' because the generic rule will attempt to remove $(TARGET)
|
||||
# file, which is a directory in our case.
|
||||
#
|
||||
clean_prg_objects: clean_codezero
|
||||
|
||||
clean_codezero:
|
||||
$(VERBOSE)rm -f $(LOCAL_CONFIG_CML)
|
||||
$(VERBOSE)rm -rf $(CODEZERO_DST_DIR)
|
67
base-codezero/src/platform/_main_helper.h
Normal file
67
base-codezero/src/platform/_main_helper.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* \brief Platform-specific helper functions for the _main() function
|
||||
* \author Norman Feske
|
||||
* \date 2009-10-02
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
||||
#define _PLATFORM___MAIN_HELPER_H_
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
/* make Codezero includes happy */
|
||||
extern "C" char *strncpy(char *dest, const char *src, Genode::size_t n);
|
||||
extern "C" void *memcpy(void *dest, const void *src, Genode::size_t n);
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
|
||||
/****************************
|
||||
** Codezero libl4 support **
|
||||
****************************/
|
||||
|
||||
/*
|
||||
* Unfortunately, the function 'exregs_print_registers' in 'exregs.c' refers to
|
||||
* 'memset'. Because we do not want to link core against a C library, we have to
|
||||
* resolve this function here.
|
||||
*/
|
||||
extern "C" void *memset(void *s, int c, Genode::size_t n) __attribute__((weak));
|
||||
extern "C" void *memset(void *s, int c, Genode::size_t n)
|
||||
{
|
||||
return Genode::memset(s, c, n);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Same problem as for 'memset'. The 'printf' symbol is referenced from
|
||||
* 'mutex.c' and 'exregs.c' of Codezero's libl4.
|
||||
*/
|
||||
extern "C" int printf(const char *format, ...) __attribute__((weak));
|
||||
extern "C" int printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
Genode::vprintf(format, list);
|
||||
va_end(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**************************
|
||||
** Startup-code helpers **
|
||||
**************************/
|
||||
|
||||
static void main_thread_bootstrap()
|
||||
{
|
||||
Codezero::__l4_init();
|
||||
}
|
||||
|
||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
131
base-codezero/src/platform/genode.ld
Normal file
131
base-codezero/src/platform/genode.ld
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* \brief Linker script for Genode programs
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-12
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* values taken from Codezero's mm0 linker script */
|
||||
/*physical_base = 0x00208000;*/
|
||||
/*virtual_base = 0xe0000000;*/
|
||||
/*offset = virtual_base - physical_base;*/
|
||||
|
||||
/*
|
||||
* Addresses correspond to the linker script generated by
|
||||
* the Codezero build system.
|
||||
*/
|
||||
vma_start = 0x100000;
|
||||
lma_start = 0x40000;
|
||||
offset = vma_start - lma_start;
|
||||
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
ro PT_LOAD;
|
||||
rw PT_LOAD;
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = vma_start;
|
||||
|
||||
.text : AT (ADDR(.text) - offset) {
|
||||
/* begin of program image (link address) */
|
||||
_prog_img_beg = .;
|
||||
|
||||
*(.text.crt0)
|
||||
*(.init)
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
*(.fini)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
|
||||
. = ALIGN(0x08);
|
||||
|
||||
_ctors_start = .;
|
||||
KEEP (*(.ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.init_array)) /* list of constructors specific for ARM eabi */
|
||||
_ctors_end = .;
|
||||
_dtors_start = .;
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
_dtors_end = .;
|
||||
} : ro = 0x90909090
|
||||
|
||||
/* Linux: exception section for uaccess mechanism */
|
||||
__ex_table : { *(__ex_table) }
|
||||
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
|
||||
_prog_img_data = .;
|
||||
|
||||
.data : AT (ADDR(.data) - offset) {
|
||||
/*
|
||||
* Leave space for parent capability parameters at start of data
|
||||
* section. The protection domain creator is reponsible for storing
|
||||
* sane values here.
|
||||
*/
|
||||
_parent_cap = .;
|
||||
LONG(0xffffffff);
|
||||
LONG(0xffffffff);
|
||||
_vma_start = .;
|
||||
LONG(vma_start);
|
||||
_lma_start = .;
|
||||
LONG(lma_start);
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
} : rw
|
||||
|
||||
/* exception frames for C++ */
|
||||
.eh_frame : {
|
||||
__eh_frame_start__ = .;
|
||||
KEEP (*(.eh_frame))
|
||||
LONG(0)
|
||||
} : rw
|
||||
|
||||
.init_array : {
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
}
|
||||
|
||||
.gcc_except_table : { KEEP(*(.gcc_except_table)) }
|
||||
.dynamic : { *(.dynamic) }
|
||||
|
||||
/* .ARM.exidx is sorted, so has to go in its own output section */
|
||||
__exidx_start = .;
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
}
|
||||
__exidx_end = .;
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} : rw
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
.bss : AT (ADDR(.bss) - offset) {
|
||||
*(.bss .bss.* .gnu.linkonce.b.* COMMON)
|
||||
}
|
||||
|
||||
/* end of program image -- must be after last section */
|
||||
_prog_img_end = .;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.note)
|
||||
*(.note.ABI-tag)
|
||||
*(.comment)
|
||||
}
|
||||
}
|
202
base-codezero/tool/gen_romfs
Executable file
202
base-codezero/tool/gen_romfs
Executable file
@ -0,0 +1,202 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os, re, getopt, sys
|
||||
from stat import ST_SIZE
|
||||
from subprocess import PIPE, Popen
|
||||
|
||||
verbose = 0
|
||||
|
||||
|
||||
# return address of 4K page following the spefified address
|
||||
def round_page(addr):
|
||||
page_size = 0x1000
|
||||
return (addr + page_size) & ~(page_size - 1)
|
||||
|
||||
|
||||
def first_free_addr_after_program(elf, cross_prefix = ""):
|
||||
try:
|
||||
objdump = cross_prefix + "objdump"
|
||||
objdump_output = Popen([objdump, "-p", elf],
|
||||
stdout=PIPE).communicate()[0]
|
||||
except OSError:
|
||||
print "Error: execution of " + objdump + " failed, invalid cross-tool prefix?"
|
||||
exit(3)
|
||||
|
||||
#
|
||||
# The output of 'objdump -p' contains the list of program segments. Each
|
||||
# segment has two lines of text, the first containing the 'vaddr' value and
|
||||
# the latter containing the 'memsz' value. For each line, we match for both
|
||||
# 'vaddr' and 'memsz' fields. When observing a line with a 'memsz' field,
|
||||
# we know that the previous line contained the corresponding 'vaddr' and
|
||||
# that the end address of the segment is the sum of the current 'vaddr'
|
||||
# and 'memsz' values.
|
||||
#
|
||||
max_end_addr = 0
|
||||
for line in objdump_output.splitlines():
|
||||
match_vaddr = re.compile(".*vaddr (0x[0-9a-f]*).*").match(line)
|
||||
match_memsz = re.compile(".*memsz (0x[0-9a-f]*).*").match(line)
|
||||
if (match_vaddr):
|
||||
vaddr = int(match_vaddr.group(1), 0)
|
||||
if (match_memsz):
|
||||
memsz = int(match_memsz.group(1), 0)
|
||||
max_end_addr = max(max_end_addr, vaddr + memsz)
|
||||
|
||||
# align the first free address at the next page boundary
|
||||
return round_page(max_end_addr)
|
||||
|
||||
|
||||
def generate_modules_asm(modules):
|
||||
"""
|
||||
Generate assembly code aggregating boot-module data from specified files.
|
||||
The generated assembly code looks as follows:
|
||||
|
||||
/*
|
||||
* The ELF image consists only of a data section. At file offset 0, there
|
||||
* is a magic cookie that core validates when accessing the ROM fs. It is
|
||||
* followed by the end address of the meta data.
|
||||
*/
|
||||
.section .data
|
||||
.string "GROM" /* magic cookie used by core to identify a ROM fs image*/
|
||||
.long header_end /* end of ROM fs meta data */
|
||||
|
||||
/*
|
||||
* Each module is represented by a struct of 3 long values. The first
|
||||
* value is pointer to the module name. A null-pointer marks the end of
|
||||
* the module list.
|
||||
*/
|
||||
.long mod1_name /* pointer to the null-terminated module name */
|
||||
.long mod1_start /* pointer to the module data */
|
||||
.long mod1_end - mod1_start /* size of the module data */
|
||||
|
||||
.long 0
|
||||
|
||||
/*
|
||||
* For each module, there exists a null-terminated string labeled with
|
||||
* 'mod<index>_name' referenced by the module list above.
|
||||
*/
|
||||
mod1_name:
|
||||
.string "name of data module"
|
||||
.byte 0
|
||||
|
||||
header_end:
|
||||
|
||||
/*
|
||||
* The data of each module must be aligned at a page boundary to enable
|
||||
* the mapping of individual modules to different address spaces.
|
||||
*/
|
||||
.align 4096
|
||||
mod1_start: .incbin "data"
|
||||
mod1_end:
|
||||
"""
|
||||
|
||||
asm_src = ""
|
||||
|
||||
# header
|
||||
asm_src += ".section .data\nmodule_list:\n"
|
||||
asm_src += ".ascii \"GROM\"\n"
|
||||
asm_src += ".long header_end\n"
|
||||
|
||||
# module list
|
||||
i = 1
|
||||
for module in modules:
|
||||
asm_src += ".long mod" + str(i) + "_name\n"
|
||||
asm_src += ".long mod" + str(i) + "_start\n"
|
||||
asm_src += ".long mod" + str(i) + "_end - mod" + str(i) + "_start\n"
|
||||
i = i + 1
|
||||
asm_src += ".long 0\n"
|
||||
|
||||
# module names
|
||||
i = 1
|
||||
for module in modules:
|
||||
asm_src += "mod" + str(i) + "_name: .string \"" + os.path.split(module)[1] + "\"; .byte 0\n"
|
||||
i = i + 1
|
||||
|
||||
asm_src += "header_end:\n"
|
||||
|
||||
# module data
|
||||
i = 1
|
||||
for module in modules:
|
||||
asm_src += ".p2align 12,0\n"
|
||||
asm_src += "mod" + str(i) + "_start: .incbin \"" + module + "\"; "
|
||||
asm_src += "mod" + str(i) + "_end:\n"
|
||||
i = i + 1
|
||||
|
||||
return asm_src
|
||||
|
||||
instructions = """
|
||||
usage: gen_romfs [-v] [-p <cross-prefix>] -c <core-elf> -o <output> [modules ...]
|
||||
|
||||
Generates Genode ROM file system as ELF file loadable into a Codezero container
|
||||
|
||||
-c|--core ELF binary of Genode's core
|
||||
-o|--output name of ELF image to generate
|
||||
-p|--prefix cross toolchain prefix
|
||||
-v|--verbose print details about generated ROM file systemn
|
||||
"""
|
||||
|
||||
def usage():
|
||||
print instructions
|
||||
|
||||
def user_error(message):
|
||||
print "Error: " + message
|
||||
usage
|
||||
sys.exit(2)
|
||||
|
||||
# default values for command-line arguments
|
||||
cross_prefix = ""
|
||||
core_elf = ""
|
||||
dst_elf = ""
|
||||
|
||||
# parse command line arguments
|
||||
try:
|
||||
opts, modules = getopt.getopt(sys.argv[1:],
|
||||
"c:o:p:v",
|
||||
["core=", "output=", "prefix=", "verbose"])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt in ("-c", "--core"):
|
||||
core_elf = arg
|
||||
elif opt in ("-o", "--output"):
|
||||
dst_elf = arg
|
||||
elif opt in ("-p", "--prefix"):
|
||||
cross_prefix = arg
|
||||
elif opt in ("-v", "--verbose"):
|
||||
verbose = 1
|
||||
else:
|
||||
user_error("invalid argument \"" + arg + "\"")
|
||||
|
||||
# validate arguments
|
||||
if (core_elf == ""): user_error("no core binary specified")
|
||||
if (len(modules) == 0): user_error("no modules specified")
|
||||
if (dst_elf == ""): user_error("no output file spefied")
|
||||
|
||||
# determine destination address of the modules ELF image
|
||||
modules_start_addr = first_free_addr_after_program(core_elf, cross_prefix)
|
||||
|
||||
if (verbose):
|
||||
print "module address: " + hex(modules_start_addr)
|
||||
|
||||
# generate assembly code aggregating the module data
|
||||
asm_src = generate_modules_asm(modules)
|
||||
|
||||
if (verbose):
|
||||
print "generated assember code:"
|
||||
for line in asm_src.splitlines():
|
||||
print " " + line
|
||||
|
||||
# invoke assembler and linker through the gcc front end
|
||||
gcc_cmd = [cross_prefix + "gcc",
|
||||
"-nostdlib",
|
||||
"-x", "assembler",
|
||||
"-Wl,--entry=0",
|
||||
"-Wl,--section-start=.data=" + hex(modules_start_addr),
|
||||
"-o", dst_elf,
|
||||
"-"]
|
||||
|
||||
if (verbose):
|
||||
print "gcc command line:"
|
||||
print " " + ' '.join(gcc_cmd)
|
||||
|
||||
Popen(gcc_cmd, stdin=PIPE).communicate(asm_src)[0]
|
44
base-fiasco/Makefile
Normal file
44
base-fiasco/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#
|
||||
# \brief Download, and unpack Fiasco and addtional needed tools (sigma0, bootstrap)
|
||||
# \author Stefan Kalkowski
|
||||
# \date 2011-07-18
|
||||
#
|
||||
|
||||
VERBOSE ?= @
|
||||
ECHO = @echo
|
||||
DOWNLOAD_DIR = download
|
||||
CONTRIB_DIR = contrib
|
||||
FIASCO_ARCHIVE = 3rd_fiasco.tar.bz2
|
||||
FIASCO_URI = http://downloads.sourceforge.net/project/genode/3rd/$(FIASCO_ARCHIVE)
|
||||
|
||||
#
|
||||
# Print help information by default
|
||||
#
|
||||
help:
|
||||
$(ECHO)
|
||||
$(ECHO) "Prepare the Fiasco base repository"
|
||||
$(ECHO)
|
||||
$(ECHO) "--- available commands ---"
|
||||
$(ECHO) "prepare - download and extract the Fiasco source code"
|
||||
$(ECHO) "clean - clean everything except downloaded archives"
|
||||
$(ECHO) "cleanall - clean everything including downloaded archives"
|
||||
$(ECHO)
|
||||
|
||||
$(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE):
|
||||
$(ECHO) "downloading source code to '$(DOWNLOAD_DIR)/'"
|
||||
$(VERBOSE)mkdir -p $(DOWNLOAD_DIR)
|
||||
$(VERBOSE)wget -c $(FIASCO_URI) -O $@
|
||||
|
||||
$(CONTRIB_DIR): $(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE)
|
||||
$(ECHO) "unpacking source code to '$(CONTRIB_DIR)/'"
|
||||
$(VERBOSE)tar xjf $<
|
||||
$(VERBOSE)mv 3rd $@
|
||||
$(VERBOSE)touch $@
|
||||
|
||||
prepare: $(CONTRIB_DIR)
|
||||
|
||||
clean:
|
||||
$(VERBOSE)rm -rf $(CONTRIB_DIR)
|
||||
|
||||
cleanall: clean
|
||||
$(VERBOSE)rm -rf $(DOWNLOAD_DIR)
|
4
base-fiasco/README
Normal file
4
base-fiasco/README
Normal file
@ -0,0 +1,4 @@
|
||||
This repository contains the L4/Fiasco-specific implementation of Genode.
|
||||
|
||||
For instructions to build and start the Fiasco version of Genode, please
|
||||
consult the documentation located at 'base-fiasco/doc/fiasco.txt'.
|
95
base-fiasco/config/kernel-config.x86
Normal file
95
base-fiasco/config/kernel-config.x86
Normal file
@ -0,0 +1,95 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Fiasco kernel version: SVN
|
||||
# Thu Jul 21 16:51:09 2011
|
||||
#
|
||||
|
||||
#
|
||||
# Target configuration
|
||||
#
|
||||
CONFIG_IA32=y
|
||||
# CONFIG_AMD64 is not set
|
||||
# CONFIG_ARM is not set
|
||||
CONFIG_PF_PC=y
|
||||
# CONFIG_PF_UX is not set
|
||||
# CONFIG_PF_REALVIEW is not set
|
||||
# CONFIG_PF_INTEGRATOR is not set
|
||||
# CONFIG_PF_XSCALE is not set
|
||||
# CONFIG_PF_SA1100 is not set
|
||||
CONFIG_ABI_V2=y
|
||||
# CONFIG_ARM_PXA is not set
|
||||
# CONFIG_ARM_SA is not set
|
||||
# CONFIG_ARM_920T is not set
|
||||
# CONFIG_ARM_926 is not set
|
||||
# CONFIG_ARM_1176 is not set
|
||||
# CONFIG_ARM_MPCORE is not set
|
||||
# CONFIG_ARM_CORTEX_A8 is not set
|
||||
# CONFIG_IA32_486 is not set
|
||||
CONFIG_IA32_586=y
|
||||
# CONFIG_IA32_686 is not set
|
||||
# CONFIG_IA32_P2 is not set
|
||||
# CONFIG_IA32_P3 is not set
|
||||
# CONFIG_IA32_P4 is not set
|
||||
# CONFIG_IA32_PM is not set
|
||||
# CONFIG_IA32_K6 is not set
|
||||
# CONFIG_IA32_K7 is not set
|
||||
# CONFIG_IA32_K8 is not set
|
||||
# CONFIG_AMD64_K8 is not set
|
||||
CONFIG_SCHED_PIT=y
|
||||
# CONFIG_SCHED_RTC is not set
|
||||
# CONFIG_SCHED_APIC is not set
|
||||
# CONFIG_WORKAROUND_AMD_FPU_LEAK is not set
|
||||
CONFIG_REGPARM3=y
|
||||
|
||||
#
|
||||
# Kernel options
|
||||
#
|
||||
CONFIG_HANDLE_SEGMENTS=y
|
||||
# CONFIG_PL0_HACK is not set
|
||||
CONFIG_TASK_CAPS=y
|
||||
# CONFIG_USER_LOCKS is not set
|
||||
CONFIG_CONTEXT_4K=y
|
||||
CONFIG_IO_PROT=y
|
||||
# CONFIG_IO_PROT_IOPL_3 is not set
|
||||
CONFIG_SYNC_TSC=y
|
||||
CONFIG_FINE_GRAINED_CPUTIME=y
|
||||
|
||||
#
|
||||
# Debugging
|
||||
#
|
||||
CONFIG_INLINE=y
|
||||
# CONFIG_NDEBUG is not set
|
||||
# CONFIG_NO_FRAME_PTR is not set
|
||||
# CONFIG_STACK_DEPTH is not set
|
||||
# CONFIG_LIST_ALLOC_SANITY is not set
|
||||
# CONFIG_BEFORE_IRET_SANITY is not set
|
||||
CONFIG_GSTABS=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_JDB=y
|
||||
# CONFIG_JDB_LOGGING is not set
|
||||
# CONFIG_JDB_ACCOUNTING is not set
|
||||
# CONFIG_JDB_MISC is not set
|
||||
CONFIG_POWERSAVE_GETCHAR=y
|
||||
# CONFIG_WARN_NONE is not set
|
||||
# CONFIG_WARN_WARNING is not set
|
||||
CONFIG_WARN_ANY=y
|
||||
|
||||
#
|
||||
# Compiling
|
||||
#
|
||||
CONFIG_CC="gcc"
|
||||
CONFIG_CXX="g++"
|
||||
CONFIG_HOST_CC="gcc"
|
||||
CONFIG_HOST_CXX="g++"
|
||||
# CONFIG_VERBOSE is not set
|
||||
# CONFIG_MAINTAINER_MODE is not set
|
||||
CONFIG_LABEL=""
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_PERF_CNT=y
|
||||
CONFIG_BIT32=y
|
||||
CONFIG_WARN_LEVEL=2
|
||||
CONFIG_XARCH="ia32"
|
||||
CONFIG_IA32_TARGET="Intel Pentium"
|
||||
CONFIG_ABI="v2"
|
||||
CONFIG_DECEIT_BIT_DISABLES_SWITCH=y
|
83
base-fiasco/config/l4env-config.x86
Normal file
83
base-fiasco/config/l4env-config.x86
Normal file
@ -0,0 +1,83 @@
|
||||
#
|
||||
# Automatically generated by configuration tool: don't edit
|
||||
#
|
||||
|
||||
#
|
||||
# Target Architecture
|
||||
#
|
||||
BUILD_ARCH_x86=y
|
||||
BUILD_ARCH_arm=n
|
||||
BUILD_ARCH_amd64=n
|
||||
BUILD_ARCH='x86'
|
||||
CPU='586'
|
||||
BUILD_ABI_l4v2=y
|
||||
BUILD_ABI_linux=n
|
||||
BUILD_ABI='l4v2'
|
||||
|
||||
#
|
||||
# Paths and Directories
|
||||
#
|
||||
DROPS_INSTDIR='$(DROPS_STDDIR)'
|
||||
|
||||
#
|
||||
# Verboseness and Messages
|
||||
#
|
||||
DEPEND_VERBOSE_SWITCH=n
|
||||
DEPEND_VERBOSE='@'
|
||||
VERBOSE_SWITCH=n
|
||||
SHOWMESSAGES=y
|
||||
BID_COLORED_PHASES=y
|
||||
|
||||
#
|
||||
# Compilers and Tools
|
||||
#
|
||||
BIDc_USE_SPECIAL_CC=y
|
||||
HOST_CC="gcc -m32"
|
||||
HOST_CXX="g++ -m32"
|
||||
CC="$(SYSTEM_TARGET)gcc -m32"
|
||||
CXX="$(SYSTEM_TARGET)g++ -m32"
|
||||
|
||||
#
|
||||
# Tools
|
||||
#
|
||||
YACC='byacc'
|
||||
LEX='flex'
|
||||
CTAGS='ctags'
|
||||
ETAGS='etags'
|
||||
|
||||
#
|
||||
# Options
|
||||
#
|
||||
HAVE_LDSO=n
|
||||
INT_CPP_NAME_SWITCH=y
|
||||
INT_LD_NAME_SWITCH=y
|
||||
BID_STRIP_PROGS=n
|
||||
BID_GSTAB_SW=y
|
||||
BID_CFLAGS_GSTAB='-gstabs+'
|
||||
BID_GCC_OMIT_FP=n
|
||||
BID_GENERATE_MAPFILE=n
|
||||
BID_BUILD_DOC=y
|
||||
|
||||
#
|
||||
# Advanced
|
||||
#
|
||||
USE_UCLIBC=y
|
||||
USE_DIETLIBC=n
|
||||
BUILD_LOADER=n
|
||||
BUILD_LOADER_PICS='libl4util.a libl4util_root.a libsigma0.a libnames.a libloaderif.a libcon.a libl4rm.a libbootmod.a libcon.a libconstream-server.a libdm_generic.a libdm_mem.a libgeneric_ts.a liblogserver.a liblogserver_capsule.a libsemaphore.a libthread.a libslab.a libgeneric_fprov.a libl4env_err.a libl4env.a libroot.a libc_be_l4env_start_stop.a libc_be_minimal_log_io.a libc_be_simple_mem.a libc_be_mmap.a libc_be_mmap_util.a libuclibc_support.a librtc.a libl4env-l4lx.a'
|
||||
L4_CALL_SYSCALLS=y
|
||||
L4_ABS_SYSCALLS=y
|
||||
BID_CPPFLAGS_SYSCALLS='-DCONFIG_L4_CALL_SYSCALLS -DCONFIG_L4_ABS_SYSCALLS'
|
||||
USE_TASKLIB=n
|
||||
RELEASE_MODE=n
|
||||
BID_BUILD_L4DIR_ONLY=n
|
||||
CONFIG_LABEL='__none__'
|
||||
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
LINUX24_INCDIR='$(OBJ_BASE)/include/linux-24 $(DROPS_STDDIR)/include/linux-24'
|
||||
LINUX26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/linux-26-headers $(DROPS_STDDIR)/include/$(ARCH)/l4/linux-26-headers $(OBJ_BASE)/include/l4/linux-26-headers $(DROPS_STDDIR)/include/l4/linux-26-headers'
|
||||
DDE_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux'
|
||||
DDE26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux26 $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux26 $(OBJ_BASE)/include/l4/dde_linux26 $(DROPS_STDDIR)/include/l4/dde_linux26'
|
||||
SDL_INCDIR='$(OBJ_BASE)/include/l4/sdl $(DROPS_STDDIR)/include/l4/sdl'
|
130
base-fiasco/doc/fiasco.txt
Normal file
130
base-fiasco/doc/fiasco.txt
Normal file
@ -0,0 +1,130 @@
|
||||
|
||||
=============================================
|
||||
How to use Genode with the Fiasco microkernel
|
||||
=============================================
|
||||
|
||||
|
||||
Norman Feske, Christian Helmuth
|
||||
|
||||
Abstract
|
||||
########
|
||||
|
||||
This documentation describes the process of building and booting the L4/Fiasco
|
||||
version of Genode. It assumes that you are familiar with basic concepts
|
||||
described in the introductory documentation of Genode, namely the "How to start
|
||||
exploring Genode" document.
|
||||
|
||||
|
||||
Preconditions
|
||||
#############
|
||||
|
||||
The Fiasco version of Genode relies on the following components from
|
||||
the source tree of the Fiasco microkernel and the L4 environment (which also
|
||||
need additional tools).
|
||||
|
||||
|
||||
Tools
|
||||
=====
|
||||
|
||||
* Gawk
|
||||
* Bison
|
||||
* Python
|
||||
|
||||
|
||||
The Fiasco microkernel
|
||||
======================
|
||||
|
||||
Information about Fiasco are provided at its official website:
|
||||
|
||||
! http://os.inf.tu-dresden.de/fiasco/prev/
|
||||
|
||||
To download the kernel and integrate it with Genode, issue the following
|
||||
command from within the 'base-fiasco' directory:
|
||||
|
||||
! make prepare
|
||||
|
||||
This command will download a prepackaged version of the kernel tested
|
||||
with Genode. The build process of the kernel is integrated with Genode's
|
||||
build system. After creating a build directory using 'create_builddir'
|
||||
with 'fiasco_x86' as argument:
|
||||
|
||||
! <genode-dir>/tool/create_builddir fiasco_x86 \
|
||||
! BUILD_DIR=<build-dir>
|
||||
|
||||
From within the new <build-dir>, the kernel can be compiled via
|
||||
|
||||
! make kernel
|
||||
|
||||
When using Genode's run mechanism, there is no need to explicitly
|
||||
build the kernel. The run environment (see 'base-fiasco/run/env')
|
||||
takes care of it. So you can simple execute run scripts from within
|
||||
the build directory, for example:
|
||||
|
||||
! make run/demo
|
||||
|
||||
|
||||
Behind the scenes
|
||||
=================
|
||||
|
||||
For using the L4/Fiasco kernel, some basic user-level components and libraries
|
||||
are needed. These are subsumed under the name L4 environment an are organized
|
||||
as a number of packages. These packages provide two types of components. There
|
||||
are low-level components for booting up and interfacing to Fiasco and there are
|
||||
higher-level components that compose a basic OS infrastructure. For Genode, we
|
||||
only rely on the low-level packages.
|
||||
|
||||
Previous versions of Genode included all necessary sources from the L4
|
||||
environment in the '3rd/fiasco/snapshot' subdirectory. From release 10.02, the
|
||||
'3rd' directory is no longer part of the release archive and also removed from
|
||||
the subversion repository. Please download the '3rd_fiasco.tar.bz2' archive.
|
||||
The source are organized as follows
|
||||
|
||||
:'tool': contains the tools that are used by the build processes of
|
||||
the L4 environment and Fiasco. For example, the build process of Fiasco
|
||||
relies on the 'preprocess' tool.
|
||||
|
||||
:'kernel': contains the Fiasco microkernel.
|
||||
|
||||
:'l4': contains the L4-environment source tree. The single packages
|
||||
are located at 'l4/pkg'.
|
||||
|
||||
From all the packages of the L4 environment, the following three are of
|
||||
interest for using Genode:
|
||||
|
||||
:'pkg/l4sys': contains the Fiasco system-call bindings.
|
||||
|
||||
The system-call bindings are a set of C-header files that define the
|
||||
application-programming interface for invoking the system calls of
|
||||
Fiasco.
|
||||
|
||||
:'pkg/sigma0':
|
||||
|
||||
Sigma0 is the initial memory manager required to use Fiasco.
|
||||
|
||||
:'pkg/bootstrap':
|
||||
|
||||
Bootstrap is the program that is started by the boot loader.
|
||||
After being started, Bootstrap prepares the bare machine to
|
||||
accommodate Fiasco. On many embedded architectures, bootstrap
|
||||
is used to create a single binary image containing all boot-time
|
||||
OS components.
|
||||
|
||||
To build all components under '3rd/fiasco' after extracting the
|
||||
archive, issue the following commands:
|
||||
|
||||
! mkdir <build-dir>
|
||||
! make -C 3rd/fiasco BUILD_DIR=<build-dir>/3rd build
|
||||
|
||||
The specified '<build-dir>' must be the absolute path to the
|
||||
directory, which will contain the build directories for the third party
|
||||
software and the Genode build directory. After the build, your compound
|
||||
build directory contains the following subdirectories:
|
||||
|
||||
:'fiasco_x86':
|
||||
|
||||
All generated files and the final binary of Fiasco reside here.
|
||||
|
||||
:'l4env':
|
||||
|
||||
L4 environment binaries and header files.
|
||||
|
11
base-fiasco/etc/fiasco.conf
Normal file
11
base-fiasco/etc/fiasco.conf
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# Fiasco-specific default configuration options
|
||||
#
|
||||
|
||||
#
|
||||
# Directory, where to search for L4 headers
|
||||
#
|
||||
# When using this file as template for a customized
|
||||
# '<builddir>/etc/fiasco.conf'.
|
||||
#
|
||||
#L4_DIR = $(HOME)/src/l4build.x86
|
15
base-fiasco/etc/specs.conf
Normal file
15
base-fiasco/etc/specs.conf
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# Description of build platform
|
||||
#
|
||||
|
||||
#
|
||||
# To build the Fiasco-specific Genode binaries,
|
||||
# use one of the the following config options.
|
||||
#
|
||||
SPECS = genode fiasco_x86
|
||||
|
||||
#
|
||||
# To build for the ARM integrator platform,
|
||||
# use the following SPECS value.
|
||||
#
|
||||
#SPECS = genode platform_integrator fiasco_arm
|
8
base-fiasco/etc/tools.conf
Normal file
8
base-fiasco/etc/tools.conf
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
# The following options let you define your cross-compile tool chain
|
||||
#
|
||||
|
||||
include $(BASE_DIR)/etc/tools.conf
|
||||
|
||||
#CROSS_DEV_PREFIX = arm-softfloat-linux-gnu-
|
||||
|
39
base-fiasco/include/arm/cpu/atomic.h
Normal file
39
base-fiasco/include/arm/cpu/atomic.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* \brief Atomic operations for ARM
|
||||
* \author Norman Feske
|
||||
* \date 2007-04-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__ARM__CPU__ATOMIC_H_
|
||||
#define _INCLUDE__ARM__CPU__ATOMIC_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
extern "C" long int
|
||||
l4_atomic_cmpxchg(volatile long int*, long int, long int);
|
||||
|
||||
/**
|
||||
* Atomic compare and exchange
|
||||
*
|
||||
* This function compares the value at dest with cmp_val.
|
||||
* If both values are equal, dest is set to new_val. If
|
||||
* both values are different, the value at dest remains
|
||||
* unchanged.
|
||||
*
|
||||
* \return 1 if the value was successfully changed to new_val,
|
||||
* 0 if cmp_val and the value at dest differ.
|
||||
*/
|
||||
inline int cmpxchg(volatile int *dest, int cmp_val, int new_val)
|
||||
{
|
||||
return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__ARM__CPU__ATOMIC_H_ */
|
57
base-fiasco/include/base/cancelable_lock.h
Normal file
57
base-fiasco/include/base/cancelable_lock.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* \brief Basic locking primitive
|
||||
* \author Norman Feske
|
||||
* \date 2006-07-26
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
||||
#define _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
||||
|
||||
#include <base/lock_guard.h>
|
||||
#include <base/native_types.h>
|
||||
#include <base/blocking.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Cancelable_lock
|
||||
{
|
||||
private:
|
||||
|
||||
Native_lock _native_lock;
|
||||
|
||||
public:
|
||||
|
||||
enum State { LOCKED, UNLOCKED };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Cancelable_lock(State initial = UNLOCKED);
|
||||
|
||||
/**
|
||||
* Try to aquire lock an block while lock is not free
|
||||
*
|
||||
* This function may throw a Genode::Blocking_canceled exception.
|
||||
*/
|
||||
void lock();
|
||||
|
||||
/**
|
||||
* Release lock
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
/**
|
||||
* Lock guard
|
||||
*/
|
||||
typedef Genode::Lock_guard<Cancelable_lock> Guard;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__CANCELABLE_LOCK_H_ */
|
65
base-fiasco/include/base/ipc_msgbuf.h
Normal file
65
base-fiasco/include/base/ipc_msgbuf.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* \brief Fiasco-specific layout of IPC message buffer
|
||||
* \author Norman Feske
|
||||
* \date 2006-06-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
#define _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* IPC message buffer layout
|
||||
*/
|
||||
class Msgbuf_base
|
||||
{
|
||||
protected:
|
||||
|
||||
Genode::size_t _size;
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* Begin of message buffer layout
|
||||
*/
|
||||
|
||||
Fiasco::l4_fpage_t rcv_fpage;
|
||||
Fiasco::l4_msgdope_t size_dope;
|
||||
Fiasco::l4_msgdope_t send_dope;
|
||||
char buf[];
|
||||
|
||||
/**
|
||||
* Return size of message buffer
|
||||
*/
|
||||
inline size_t size() const { return _size; };
|
||||
|
||||
/**
|
||||
* Return address of message buffer
|
||||
*/
|
||||
inline void *addr() { return &rcv_fpage; };
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Instance of IPC message buffer with specified buffer size
|
||||
*/
|
||||
template <unsigned BUF_SIZE>
|
||||
class Msgbuf : public Msgbuf_base
|
||||
{
|
||||
public:
|
||||
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
Msgbuf() { _size = BUF_SIZE; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */
|
173
base-fiasco/include/base/ipc_pager.h
Normal file
173
base-fiasco/include/base/ipc_pager.h
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* \brief Fiasco pager support
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-06-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_PAGER_H_
|
||||
#define _INCLUDE__BASE__IPC_PAGER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/ipc.h>
|
||||
#include <base/stdint.h>
|
||||
#include <base/native_types.h>
|
||||
#include <fiasco/thread_helper.h>
|
||||
#include <util/touch.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Mapping
|
||||
{
|
||||
private:
|
||||
|
||||
addr_t _dst_addr;
|
||||
Fiasco::l4_fpage_t _fpage;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Mapping(addr_t dst_addr, addr_t src_addr,
|
||||
bool write_combined, unsigned l2size = L4_LOG2_PAGESIZE,
|
||||
bool rw = true, bool grant = false)
|
||||
:
|
||||
_dst_addr(dst_addr),
|
||||
_fpage(Fiasco::l4_fpage(src_addr, l2size, rw, grant))
|
||||
{
|
||||
if (write_combined)
|
||||
_fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct invalid flexpage
|
||||
*/
|
||||
Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage(0, 0, 0, 0)) { }
|
||||
|
||||
Fiasco::l4_umword_t dst_addr() const { return _dst_addr; }
|
||||
Fiasco::l4_fpage_t fpage() const { return _fpage; }
|
||||
|
||||
/**
|
||||
* Prepare map operation
|
||||
*
|
||||
* On Fiasco, we need to map a page locally to be able to map it to
|
||||
* another address space.
|
||||
*/
|
||||
void prepare_map_operation()
|
||||
{
|
||||
addr_t core_local_addr = _fpage.fp.page << 12;
|
||||
size_t mapping_size = 1 << _fpage.fp.size;
|
||||
|
||||
for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) {
|
||||
if (_fpage.fp.write)
|
||||
touch_read_write((unsigned char volatile *)(core_local_addr + i));
|
||||
else
|
||||
touch_read((unsigned char const volatile *)(core_local_addr + i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Special paging server class
|
||||
*/
|
||||
class Ipc_pager : public Native_capability
|
||||
{
|
||||
private:
|
||||
|
||||
Native_thread_id _last; /* origin of last fault message */
|
||||
addr_t _pf_addr; /* page-fault address */
|
||||
addr_t _pf_ip; /* instruction pointer of faulter */
|
||||
Mapping _reply_mapping; /* page-fault answer */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ipc_pager();
|
||||
|
||||
/**
|
||||
* Wait for a new page fault received as short message IPC
|
||||
*/
|
||||
void wait_for_fault();
|
||||
|
||||
/**
|
||||
* Reply current page-fault and wait for a new one
|
||||
*
|
||||
* Send short flex page and wait for next short-message (register)
|
||||
* IPC -- pagefault
|
||||
*/
|
||||
void reply_and_wait_for_fault();
|
||||
|
||||
/**
|
||||
* Request instruction pointer of current page fault
|
||||
*/
|
||||
addr_t fault_ip() { return _pf_ip; }
|
||||
|
||||
/**
|
||||
* Request fault address of current page fault
|
||||
*/
|
||||
addr_t fault_addr() { return _pf_addr & ~3; }
|
||||
|
||||
/**
|
||||
* Set parameters for next reply
|
||||
*/
|
||||
void set_reply_mapping(Mapping m) { _reply_mapping = m; }
|
||||
|
||||
/**
|
||||
* Set destination for next reply
|
||||
*/
|
||||
void set_reply_dst(Native_capability pager_object) {
|
||||
_last.raw = pager_object.local_name(); }
|
||||
|
||||
/**
|
||||
* Answer call without sending a flex-page mapping
|
||||
*
|
||||
* This function is used to acknowledge local calls from one of
|
||||
* core's region-manager sessions.
|
||||
*/
|
||||
void acknowledge_wakeup();
|
||||
|
||||
/**
|
||||
* Return thread ID of last faulter
|
||||
*/
|
||||
Native_thread_id last() const { return _last; }
|
||||
|
||||
/**
|
||||
* Return badge for faulting thread
|
||||
*
|
||||
* As Fiasco has no server-defined badges for page-fault messages, we
|
||||
* interpret the sender ID as badge.
|
||||
*/
|
||||
unsigned long badge() const {
|
||||
return convert_native_thread_id_to_badge(_last); }
|
||||
|
||||
bool is_write_fault() const { return (_pf_addr & 2); }
|
||||
|
||||
/**
|
||||
* Return true if last fault was an exception
|
||||
*/
|
||||
bool is_exception() const
|
||||
{
|
||||
/*
|
||||
* Reflection of exceptions is not supported on this platform.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */
|
115
base-fiasco/include/base/native_types.h
Normal file
115
base-fiasco/include/base/native_types.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* \brief Native types on L4/Fiasco
|
||||
* \author Norman Feske
|
||||
* \date 2008-07-26
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
|
||||
/**
|
||||
* Return invalid L4 thread ID
|
||||
*/
|
||||
inline l4_threadid_t invalid_l4_threadid_t() { return L4_INVALID_ID; }
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
typedef Fiasco::l4_threadid_t Native_thread_id;
|
||||
|
||||
struct Native_thread
|
||||
{
|
||||
Native_thread_id l4id;
|
||||
|
||||
/**
|
||||
* Only used in core
|
||||
*
|
||||
* For 'Thread' objects created within core, 'pt' points to
|
||||
* the physical thread object, which is going to be destroyed
|
||||
* on destruction of the 'Thread'.
|
||||
*/
|
||||
Platform_thread *pt;
|
||||
};
|
||||
|
||||
inline unsigned long convert_native_thread_id_to_badge(Native_thread_id tid)
|
||||
{
|
||||
/*
|
||||
* Fiasco has no server-defined badges for page-fault messages.
|
||||
* Therefore, we have to interpret the sender ID as badge.
|
||||
*/
|
||||
return tid.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty UTCB type expected by the thread library
|
||||
*
|
||||
* On this kernel, UTCBs are not placed within the the context area. Each
|
||||
* thread can request its own UTCB pointer using the kernel interface.
|
||||
*/
|
||||
typedef struct { } Native_utcb;
|
||||
|
||||
/*
|
||||
* On Fiasco, the local_name member of a capability is global
|
||||
* to the whole system. Therefore, capabilities are to be
|
||||
* created at a central place that prevents id clashes.
|
||||
*/
|
||||
class Native_capability
|
||||
{
|
||||
protected:
|
||||
|
||||
Fiasco::l4_threadid_t _tid;
|
||||
long _local_name;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Native_capability()
|
||||
: _tid(Fiasco::invalid_l4_threadid_t()), _local_name(0) { }
|
||||
|
||||
long local_name() const { return _local_name; }
|
||||
Fiasco::l4_threadid_t dst() const { return _tid; }
|
||||
|
||||
bool valid() const { return l4_is_invalid_id(_tid) == 0; }
|
||||
|
||||
|
||||
/*****************************************************
|
||||
** Functions to be used by the Fiasco backend only **
|
||||
*****************************************************/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* This constructor can be called to create a Fiasco
|
||||
* capability by hand. It must never be used from
|
||||
* generic code!
|
||||
*/
|
||||
Native_capability(Fiasco::l4_threadid_t tid,
|
||||
Fiasco::l4_umword_t local_name)
|
||||
: _tid(tid), _local_name(local_name) { }
|
||||
|
||||
/**
|
||||
* Access raw capability data
|
||||
*/
|
||||
Fiasco::l4_threadid_t tid() const { return _tid; }
|
||||
};
|
||||
|
||||
typedef Fiasco::l4_threadid_t Native_connection_state;
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */
|
40
base-fiasco/include/fiasco/thread_helper.h
Normal file
40
base-fiasco/include/fiasco/thread_helper.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* \brief Fiasco-specific thread helper functions
|
||||
* \author Norman Feske
|
||||
* \date 2007-05-03
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-2011 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__FIASCO__THREAD_HELPER_H_
|
||||
#define _INCLUDE__FIASCO__THREAD_HELPER_H_
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
|
||||
inline void print_l4_threadid(l4_threadid_t t)
|
||||
{
|
||||
Genode::printf("THREAD %x.%02x\n", t.id.task, t.id.lthread);
|
||||
Genode::printf(" unsigned version_low:10 = %x\n", t.id.version_low);
|
||||
Genode::printf(" unsigned lthread:7 = %x\n", t.id.lthread);
|
||||
Genode::printf(" unsigned task:11 = %x\n", t.id.task);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sigma0 thread ID
|
||||
*
|
||||
* We must use a raw hex value initializer since we're using C++ and
|
||||
* l4_threadid_t is an union.
|
||||
*/
|
||||
const l4_threadid_t sigma0_threadid = { 0x00040000 };
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__FIASCO__THREAD_HELPER_H_ */
|
8
base-fiasco/lib/mk/arm/startup.mk
Normal file
8
base-fiasco/lib/mk/arm/startup.mk
Normal file
@ -0,0 +1,8 @@
|
||||
REQUIRES = fiasco arm
|
||||
LIBS = cxx lock
|
||||
SRC_S = crt0.s
|
||||
SRC_CC = _main.cc
|
||||
INC_DIR += $(REP_DIR)/src/platform
|
||||
|
||||
vpath crt0.s $(REP_DIR)/src/platform/arm
|
||||
vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc))
|
5
base-fiasco/lib/mk/core_printf.mk
Normal file
5
base-fiasco/lib/mk/core_printf.mk
Normal file
@ -0,0 +1,5 @@
|
||||
SRC_CC = core_printf.cc
|
||||
LIBS = cxx console
|
||||
INC_DIR += $(REP_DIR)/src/base/console
|
||||
|
||||
vpath core_printf.cc $(BASE_DIR)/src/base/console
|
3
base-fiasco/lib/mk/ipc.mk
Normal file
3
base-fiasco/lib/mk/ipc.mk
Normal file
@ -0,0 +1,3 @@
|
||||
SRC_CC = ipc.cc pager.cc
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/base/ipc
|
19
base-fiasco/lib/mk/l4v2_support.mk
Normal file
19
base-fiasco/lib/mk/l4v2_support.mk
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Build L4env base libraries, needed by sigma0 and bootstrap
|
||||
|
||||
|
||||
# ignore stage one, visit the L4 build system at second build stage
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
# packages in 'l4/pkg/'
|
||||
PKGS = l4sys/lib \
|
||||
uclibc/lib/uclibc \
|
||||
uclibc/lib/include \
|
||||
crtx \
|
||||
l4util/lib \
|
||||
cxx
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
all: $(PKG_TAGS)
|
||||
|
||||
endif
|
3
base-fiasco/lib/mk/lock.mk
Normal file
3
base-fiasco/lib/mk/lock.mk
Normal file
@ -0,0 +1,3 @@
|
||||
SRC_CC = lock.cc
|
||||
|
||||
vpath lock.cc $(REP_DIR)/src/base/lock
|
3
base-fiasco/lib/mk/pager.mk
Normal file
3
base-fiasco/lib/mk/pager.mk
Normal file
@ -0,0 +1,3 @@
|
||||
SRC_CC = pager.cc
|
||||
|
||||
vpath pager.cc $(REP_DIR)/src/base/pager
|
56
base-fiasco/lib/mk/platform.inc
Normal file
56
base-fiasco/lib/mk/platform.inc
Normal file
@ -0,0 +1,56 @@
|
||||
#
|
||||
# Create prerequisites for building Genode for Fiasco
|
||||
#
|
||||
# Prior building Genode programs for Fiasco, the kernel bindings must be
|
||||
# generated. This is done by building a minimalistic subset of the original
|
||||
# userland that comes with Fiasco.
|
||||
#
|
||||
|
||||
#
|
||||
# Execute the rules in this file only at the second build stage when we know
|
||||
# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'.
|
||||
#
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
#
|
||||
# Sanity checks
|
||||
#
|
||||
ifeq ($(L4_BUILD_DIR),$(BUILD_BASE_DIR)/l4)
|
||||
all: $(L4_SRC_DIR)
|
||||
|
||||
$(L4_SRC_DIR):
|
||||
$(VERBOSE)$(ECHO) "--> Please, execute 'make prepare' in $(REP_DIR)"
|
||||
$(VERBOSE)$(ECHO) "--> before compiling Genode apps for Fiasco."
|
||||
$(VERBOSE)exit 1
|
||||
endif
|
||||
|
||||
#
|
||||
# Create L4 build directory
|
||||
#
|
||||
$(BUILD_BASE_DIR)/l4/.Makeconf.bid.old:
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)cp $(L4_CONFIG) $(@:.old=)
|
||||
$(VERBOSE_MK) MAKEFLAGS= make $(VERBOSE_DIR) -C $(L4_SRC_DIR)/l4 \
|
||||
O=$(BUILD_BASE_DIR)/l4 SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" oldconfig
|
||||
|
||||
$(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc:
|
||||
$(VERBOSE)mkdir -p $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
$(VERBOSE)tar cf - --exclude .svn -C $(L4_SRC_DIR)/../uclibc ARCH-all ARCH-x86 \
|
||||
| tar xf - -C $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
|
||||
PKGS = input/include \
|
||||
drivers/uart/include \
|
||||
l4sys/include \
|
||||
l4util/include \
|
||||
libc_support/include \
|
||||
libsigma0/include
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
|
||||
all: $(PKG_TAGS)
|
||||
|
||||
$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/.Makeconf.bid.old
|
||||
$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
|
||||
endif
|
||||
|
6
base-fiasco/lib/mk/x86/platform.mk
Normal file
6
base-fiasco/lib/mk/x86/platform.mk
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap).
|
||||
#
|
||||
L4_CONFIG = $(REP_DIR)/config/l4env-config.x86
|
||||
|
||||
include $(REP_DIR)/lib/mk/platform.inc
|
8
base-fiasco/lib/mk/x86/startup.mk
Normal file
8
base-fiasco/lib/mk/x86/startup.mk
Normal file
@ -0,0 +1,8 @@
|
||||
REQUIRES = fiasco x86
|
||||
LIBS = cxx lock
|
||||
SRC_S = crt0.s
|
||||
SRC_CC = _main.cc
|
||||
INC_DIR += $(BASE_DIR)/src/platform $(REP_DIR)/src/platform
|
||||
|
||||
vpath crt0.s $(dir $(call select_from_repositories,src/platform/x86_32/crt0.s))
|
||||
vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc))
|
69
base-fiasco/mk/l4_pkg.mk
Normal file
69
base-fiasco/mk/l4_pkg.mk
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Utility for building L4 contrib packages
|
||||
#
|
||||
# Variables that steer the behaviour of this makefile:
|
||||
#
|
||||
# TARGET - name of target
|
||||
# PKGS - list of L4 packages to visit in order to create
|
||||
# the target
|
||||
#
|
||||
|
||||
LIBS += platform
|
||||
|
||||
ifeq ($(filter-out $(SPECS),x86_32),)
|
||||
L4_BUILD_ARCH := x86
|
||||
endif
|
||||
|
||||
ifeq ($(filter-out $(SPECS),arm),)
|
||||
L4_BUILD_ARCH := arm
|
||||
endif
|
||||
|
||||
ifeq ($(L4_BUILD_ARCH),)
|
||||
all: l4_build_arch_undefined
|
||||
$(VERBOSE)$(ECHO) "Error: L4_BUILD_ARCH undefined, architecture not supported"
|
||||
$(VERBOSE)false
|
||||
endif
|
||||
|
||||
L4_PKG_DIR = $(L4_SRC_DIR)/l4/pkg
|
||||
STARTUP_LIB =
|
||||
PKG_TAGS = $(addsuffix .tag,$(PKGS))
|
||||
|
||||
ifeq ($(VERBOSE),)
|
||||
L4_VERBOSE = V=1
|
||||
endif
|
||||
|
||||
$(TARGET): $(PKG_TAGS)
|
||||
|
||||
#
|
||||
# We preserve the order of processing 'l4/pkg/' directories because of
|
||||
# inter-package dependencies. However, within each directory, make is working
|
||||
# in parallel.
|
||||
#
|
||||
.NOTPARALLEL: $(PKG_TAGS)
|
||||
|
||||
#
|
||||
# The '_GNU_SOURCE' definition is needed to convince uClibc to define the
|
||||
# 'off64_t' type, which is used by bootstrap.
|
||||
#
|
||||
%.tag:
|
||||
$(VERBOSE_MK) MAKEFLAGS= CPPFLAGS="$(CC_MARCH)" \
|
||||
CFLAGS="$(CC_MARCH)" CXXFLAGS="$(CC_MARCH) -D_GNU_SOURCE" \
|
||||
ASFLAGS="$(CC_MARCH)" LDFLAGS="$(LD_MARCH)" \
|
||||
$(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) $(L4_VERBOSE) \
|
||||
-C $(L4_PKG_DIR)/$* \
|
||||
CC="$(CROSS_DEV_PREFIX)gcc" \
|
||||
CXX="$(CROSS_DEV_PREFIX)g++" \
|
||||
LD="$(CROSS_DEV_PREFIX)ld"
|
||||
$(VERBOSE)mkdir -p $(dir $@) && touch $@
|
||||
|
||||
clean cleanall: clean_tags
|
||||
|
||||
# if (pseudo) target is named after a directory, remove the whole subtree
|
||||
clean_prg_objects: clean_dir_named_as_target
|
||||
|
||||
clean_dir_named_as_target:
|
||||
$(VERBOSE)(test -d $(TARGET) && rm -rf $(TARGET)) || true
|
||||
|
||||
clean_tags:
|
||||
$(VERBOSE)rm -f $(PKG_TAGS)
|
||||
|
32
base-fiasco/mk/spec-fiasco.mk
Normal file
32
base-fiasco/mk/spec-fiasco.mk
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Specifics for the l4v2 kernel API
|
||||
#
|
||||
|
||||
#
|
||||
# Read default and builddir-specific config files
|
||||
#
|
||||
# In these config files, we find the definition of L4_DIR
|
||||
#
|
||||
-include $(call select_from_repositories,etc/fiasco.conf)
|
||||
-include $(BUILD_BASE_DIR)/etc/fiasco.conf
|
||||
|
||||
L4_BUILD_DIR ?= $(BUILD_BASE_DIR)/l4
|
||||
L4_SRC_DIR ?= $(REP_DIR)/contrib/fiasco/snapshot
|
||||
|
||||
|
||||
#
|
||||
# L4/sys headers
|
||||
#
|
||||
L4_INC_DIR += $(L4_BUILD_DIR)/include \
|
||||
$(L4_BUILD_DIR)/include/l4v2
|
||||
|
||||
#
|
||||
# Startup code to be used when building a program
|
||||
#
|
||||
STARTUP_LIB ?= startup
|
||||
PRG_LIBS += $(STARTUP_LIB)
|
||||
|
||||
clean_contrib:
|
||||
$(VERBOSE)rm -rf $(BUILD_BASE_DIR)/l4
|
||||
|
||||
cleanall: clean_contrib
|
50
base-fiasco/mk/spec-fiasco_arm.mk
Normal file
50
base-fiasco/mk/spec-fiasco_arm.mk
Normal file
@ -0,0 +1,50 @@
|
||||
#
|
||||
# Specifics for Fiasco on ARM
|
||||
#
|
||||
# The following variables must be defined by a platform spec file:
|
||||
#
|
||||
# L4SYS_ARM_CPU - Platform identifiert used for constructing l4sys path
|
||||
# names corresponding to the ARM platform. For example,
|
||||
# specify 'arm_int' for the ARM integrator board.
|
||||
# RAM_BASE - Start address of physical memory. If not specified,
|
||||
# the start adress 0x0 is used.
|
||||
#
|
||||
|
||||
SPECS += arm fiasco 32bit
|
||||
|
||||
#
|
||||
# ARM-specific L4/sys headers
|
||||
#
|
||||
L4_INC_DIR += $(L4_BUILD_DIR)/include/arm/l4v2 \
|
||||
$(L4_BUILD_DIR)/include/arm
|
||||
|
||||
#
|
||||
# Support for Fiasco's ARM-specific extensions of L4
|
||||
# and ARM-specific utility functions.
|
||||
#
|
||||
REP_INC_DIR += include/arm
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DSYSTEM_$(L4SYS_ARM_CPU)_l4v2
|
||||
CC_OPT += -DCONFIG_L4_CALL_SYSCALLS -DL4API_l4v2 -DARCH_arm
|
||||
CC_OPT += -msoft-float -fomit-frame-pointer
|
||||
AS_OPT += -mfpu=softfpa
|
||||
|
||||
#
|
||||
# Linker options that are specific for L4 on ARM
|
||||
#
|
||||
RAM_BASE ?= 0x0
|
||||
LD_TEXT_ADDR ?= $(shell printf "0x%x" $$(($(RAM_BASE) + 0x00078000)))
|
||||
CXX_LINK_OPT += -Wl,-Ttext=$(LINK_TEXT_ADDR)
|
||||
CXX_LINK_OPT += -L$(L4_BUILD_DIR)/lib/$(L4SYS_ARM_CPU)/l4v2
|
||||
EXT_OBJECTS += -ll4sys
|
||||
|
||||
#
|
||||
# Also include less-specific configuration last
|
||||
#
|
||||
include $(call select_from_repositories,mk/spec-32bit.mk)
|
||||
include $(call select_from_repositories,mk/spec-fiasco.mk)
|
||||
|
||||
INC_DIR += $(L4_INC_DIR)
|
25
base-fiasco/mk/spec-fiasco_x86.mk
Normal file
25
base-fiasco/mk/spec-fiasco_x86.mk
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Specifics for Fiasco L4v2 on x86
|
||||
#
|
||||
|
||||
SPECS += x86_32 fiasco
|
||||
SPECS += pci ps2 vesa
|
||||
|
||||
#
|
||||
# x86-specific L4v2/sys headers
|
||||
#
|
||||
L4_INC_DIR += $(L4_BUILD_DIR)/include/x86/l4v2 \
|
||||
$(L4_BUILD_DIR)/include/x86
|
||||
|
||||
#
|
||||
# Linker options that are specific for x86
|
||||
#
|
||||
LD_TEXT_ADDR ?= 0x01000000
|
||||
|
||||
#
|
||||
# Also include less-specific configuration last
|
||||
#
|
||||
include $(call select_from_repositories,mk/spec-x86_32.mk)
|
||||
include $(call select_from_repositories,mk/spec-fiasco.mk)
|
||||
|
||||
INC_DIR += $(L4_INC_DIR)
|
16
base-fiasco/mk/spec-platform_imx.mk
Normal file
16
base-fiasco/mk/spec-platform_imx.mk
Normal file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# Specifics for Freescale i.MX21 platform
|
||||
#
|
||||
|
||||
RAM_BASE = 0xc0000000
|
||||
|
||||
#
|
||||
# Configure target CPU for gcc
|
||||
#
|
||||
CC_OPT += -march=armv5
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DCPUTYPE_imx
|
||||
L4SYS_ARM_CPU = arm_imx
|
14
base-fiasco/mk/spec-platform_integrator.mk
Normal file
14
base-fiasco/mk/spec-platform_integrator.mk
Normal file
@ -0,0 +1,14 @@
|
||||
#
|
||||
# Specifics for ARM integrator platform
|
||||
#
|
||||
|
||||
#
|
||||
# Configure target CPU for gcc
|
||||
#
|
||||
CC_OPT += -march=armv5
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DCPUTYPE_int
|
||||
L4SYS_ARM_CPU = arm_int
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user