source: mainline/boot/Makefile.build@ ebbc03c7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ebbc03c7 was 84176f3, checked in by Jakub Jermář <jakub@…>, 6 years ago

arm64: Add support for the architecture

This changeset adds basic support to run HelenOS on AArch64, targeting
the QEMU virt platform.

Boot:

  • Boot relies on the EDK II firmware, GRUB2 for EFI and the HelenOS bootloader (UEFI application). EDK II loads GRUB2 from a CD, GRUB2 loads the HelenOS bootloader (via UEFI) which loads OS components.
  • UEFI applications use the PE/COFF format and must be relocatable. The first problem is solved by manually having the PE/COFF headers and tables written in assembler. The relocatable requirement is addressed by compiling the code with -fpic and having the bootloader relocate itself at its startup.

Kernel:

  • Kernel code for AArch64 consists mostly of stubbing out various architecture-specific hooks: virtual memory management, interrupt and exception handling, context switching (including FPU lazy switching), support for virtual timer, atomic sequences and barriers, cache and TLB maintenance, thread and process initialization.
  • The patch adds a kernel driver for GICv2 (interrupt controller).
  • The PL011 kernel driver is extended to allow userspace to take ownership of the console.
  • The current code is not able to dynamically obtain information about available devices on the underlying machine. The port instead implements a machine-func interface similar to the one implemented by arm32. It defines a machine for the QEMU AArch64 virt platform. The configuration (device addresses and IRQ numbers) is then baked into the machine definition.

User space:

  • Uspace code for AArch64 similarly mostly implements architecture-specific hooks: context saving/restoring, syscall support, TLS support.

The patchset allows to boot the system but user interaction with the OS
is not yet possible.

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[4872160]1#
2# Copyright (c) 2006 Martin Decky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
[4761f54]29.PHONY: all clean depend
[4872160]30
31include Makefile.common
32
[e344422]33INCLUDES = -Igeneric/include -Iarch/$(KARCH)/include -Igenarch/include -I$(ROOT_PATH)/abi/arch/$(KARCH)/include -I$(ROOT_PATH)/abi/include
[4872160]34OPTIMIZATION = 3
35
[2a5d1751]36DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
[4872160]37
[fe171357]38AFLAGS = --fatal-warnings
[84176f3]39LDFLAGS = -Wl,--fatal-warnings,--warn-common $(EXTRA_LDFLAGS)
[ae7bbfd0]40
[a0a273e]41COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
[173b3bd]42 -ffreestanding -nostdlib \
[dd162f6]43 -fexec-charset=UTF-8 -finput-charset=UTF-8 -fno-common \
44 -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
[a0a273e]45
46GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
[e8c5c11]47 -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
[e805e2f]48 -pipe
[4872160]49
[a0a273e]50CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
[4872160]51 -Werror-implicit-function-declaration -Wwrite-strings \
[a0a273e]52 -pipe -fno-stack-protector -fno-PIC
[4872160]53
[e805e2f]54ifeq ($(CONFIG_DEBUG),y)
[a0a273e]55 COMMON_CFLAGS += -Werror
[e805e2f]56endif
57
[9ded977]58ifeq ($(CONFIG_LINE_DEBUG),y)
[a0a273e]59 COMMON_CFLAGS += -g
[9ded977]60endif
61
[4872160]62ifeq ($(COMPILER),clang)
[a0a273e]63 CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
[4761f54]64else
65 CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
[4872160]66endif
67
68OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
[4761f54]69DEPENDS := $(addsuffix .d,$(basename $(SOURCES)))
[4872160]70
[dcc2c5d]71ifeq ($(CONFIG_COMPRESSED_INIT),y)
72 COMPONENTS := $(addsuffix .gz, $(COMPONENTS))
73endif
74
[4872160]75all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
76
77clean:
[0798689]78 rm -f $(RAW) $(MAP)
[4872160]79
[4761f54]80-include $(DEPENDS)
[4872160]81
[a0a273e]82AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
83
[4872160]84$(BOOT_OUTPUT): $(RAW)
85 $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
86
[4646710]87$(RAW): $(OBJECTS) $(LINK)
[009c485]88 $(CC) $(CFLAGS) -Wl,-n $(LDFLAGS) -T $(LINK) -Wl,-M,-Map,$(MAP) -o $@ $(OBJECTS)
[4872160]89
[4761f54]90$(LINK): | depend
[53ad43c]91 $(CC) $(DEFS) $(CFLAGS) -D__ASSEMBLER__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
[f4660690]92
[7f881cd8]93%.o: %.s | depend
[53ad43c]94 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
[7f881cd8]95
[4761f54]96%.o: %.S | depend
[53ad43c]97 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(AS_CFLAGS)
[4872160]98
[4761f54]99%.o: %.c | depend
[c631734]100 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS)
[4646710]101
[0798689]102depend: $(PRE_DEPEND)
[4872160]103
[63a045c]104%.gz: %
[3bf8a75]105 gzip -n -k -9 -f $<
[4646710]106
[dcc2c5d]107$(COMPS).tar: $(COMPONENTS)
[63a045c]108 tar --mtime='2032-01-01 00:00:00' --group=0 --owner=0 --no-acls --no-selinux --no-xattrs --format=ustar --transform 's/.*\///g' -cvf $@ $^
[4646710]109
[63a045c]110$(COMPS).o: $(COMPS).tar
111 # Create empty object file.
112 $(CC) -x c -c -o $@.new $(DEFS) $(CFLAGS) - </dev/null
113 # Add .payload section to it.
114 $(OBJCOPY) --add-section '.payload'=$< $@.new $@
[4646710]115
[239e32b8]116include Makefile.initrd
Note: See TracBrowser for help on using the repository browser.