Changeset a4bd537 in mainline for kernel/genarch


Ignore:
Timestamp:
2019-04-06T13:39:58Z (7 years ago)
Author:
Petr Pavlu <setup@…>
Children:
f7842ef
Parents:
0d073b8
git-author:
Petr Pavlu <setup@…> (2019-03-31 14:09:57)
git-committer:
Petr Pavlu <setup@…> (2019-04-06 13:39:58)
Message:

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.

Location:
kernel/genarch
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/Makefile.inc

    r0d073b8 ra4bd537  
    127127endif
    128128
     129ifeq ($(CONFIG_GICV2), y)
     130GENARCH_SOURCES += \
     131        genarch/src/drivers/gicv2/gicv2.c
     132endif
     133
    129134ifeq ($(CONFIG_VIA_CUDA),y)
    130135GENARCH_SOURCES += \
  • kernel/genarch/include/genarch/drivers/pl011/pl011.h

    r0d073b8 ra4bd537  
    3838#define KERN_PL011_H_
    3939
     40#include <ddi/ddi.h>
    4041#include <ddi/irq.h>
    4142#include <console/chardev.h>
     
    150151        outdev_t outdev;
    151152        irq_t irq;
     153        parea_t parea;
    152154} pl011_uart_t;
    153155
  • kernel/genarch/src/drivers/pl011/pl011.c

    r0d073b8 ra4bd537  
    6060        pl011_uart_t *uart = dev->data;
    6161
    62         if (!ascii_check(ch)) {
     62        /* If the userspace owns the console, do not output anything. */
     63        if (uart->parea.mapped && !console_override)
     64                return;
     65
     66        if (!ascii_check(ch))
    6367                pl011_uart_sendb(uart, U_SPECIAL);
    64         } else {
     68        else {
    6569                if (ch == '\n')
    6670                        pl011_uart_sendb(uart, (uint8_t) '\r');
     
    100104        assert(uart);
    101105        uart->regs = (void *)km_map(addr, sizeof(pl011_uart_regs_t),
    102             KM_NATURAL_ALIGNMENT, PAGE_NOT_CACHEABLE);
     106            KM_NATURAL_ALIGNMENT, PAGE_WRITE | PAGE_NOT_CACHEABLE);
    103107        assert(uart->regs);
    104108
     
    131135        uart->irq.instance = uart;
    132136
     137        ddi_parea_init(&uart->parea);
     138        uart->parea.pbase = addr;
     139        uart->parea.frames = 1;
     140        uart->parea.unpriv = false;
     141        uart->parea.mapped = false;
     142        ddi_parea_register(&uart->parea);
     143
    133144        return true;
    134145}
  • kernel/genarch/src/mm/as_pt.c

    r0d073b8 ra4bd537  
    7676            PA2KA(frame_alloc(PTL0_FRAMES, FRAME_LOWMEM, PTL0_SIZE - 1));
    7777
    78         if (flags & FLAG_AS_KERNEL)
    79                 memsetb(dst_ptl0, PTL0_SIZE, 0);
    80         else {
     78        memsetb(dst_ptl0, PTL0_SIZE, 0);
     79
     80        if (!KERNEL_SEPARATE_PTL0 && !(flags & FLAG_AS_KERNEL)) {
    8181                /*
    8282                 * Copy the kernel address space portion to new PTL0.
     
    9393                    &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
    9494
    95                 memsetb(dst_ptl0, PTL0_SIZE, 0);
    9695                memcpy((void *) dst, (void *) src,
    9796                    PTL0_SIZE - (src - (uintptr_t) src_ptl0));
Note: See TracChangeset for help on using the changeset viewer.