Changeset a4bd537 in mainline for boot/genarch/include/genarch/efi.h


Ignore:
Timestamp:
2019-04-06T13:39:58Z (5 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/include/genarch/efi.h

    r0d073b8 ra4bd537  
    3232#include <arch/types.h>
    3333
     34#define EFI_SUCCESS  0
     35#define EFI_ERROR(code) (((sysarg_t) 1 << (sizeof(sysarg_t) * 8 - 1)) | (code))
     36#define EFI_LOAD_ERROR  EFI_ERROR(1)
     37#define EFI_UNSUPPORTED  EFI_ERROR(3)
     38#define EFI_BUFFER_TOO_SMALL  EFI_ERROR(5)
     39
     40typedef uint64_t efi_status_t;
     41
    3442typedef struct {
    3543        uint64_t signature;
     
    5664} efi_guid_t;
    5765
    58 typedef struct {
    59         efi_guid_t guid;
    60         void *table;
    61 } efi_configuration_table_t;
    62 
    63 typedef struct {
    64         efi_table_header_t hdr;
    65         char *fw_vendor;
    66         uint32_t fw_revision;
    67         void *cons_in_handle;
    68         void *cons_in;
    69         void *cons_out_handle;
    70         void *cons_out;
    71         void *cons_err_handle;
    72         void *cons_err;
    73         void *runtime_services;
    74         void *boot_services;
    75         sysarg_t conf_table_entries;
    76         efi_configuration_table_t *conf_table;
    77 } efi_system_table_t;
     66typedef enum {
     67        EFI_ALLOCATE_ANY_PAGES,
     68        EFI_ALLOCATE_MAX_ADDRESS,
     69        EFI_ALLOCATE_ADDRESS
     70} efi_allocate_type_t;
    7871
    7972typedef enum {
     
    9184        EFI_MEMORY_MAPPED_IO,
    9285        EFI_MEMORY_MAPPED_IO_PORT_SPACE,
    93         EFI_PAL_CODE
     86        EFI_PAL_CODE,
     87        EFI_PERSISTENT_MEMORY
    9488} efi_memory_type_t;
     89
     90#define EFI_MEMORY_UC             UINT64_C(0x0000000000000001)
     91#define EFI_MEMORY_WC             UINT64_C(0x0000000000000002)
     92#define EFI_MEMORY_WT             UINT64_C(0x0000000000000004)
     93#define EFI_MEMORY_WB             UINT64_C(0x0000000000000008)
     94#define EFI_MEMORY_UCE            UINT64_C(0x0000000000000010)
     95#define EFI_MEMORY_WP             UINT64_C(0x0000000000001000)
     96#define EFI_MEMORY_RP             UINT64_C(0x0000000000002000)
     97#define EFI_MEMORY_XP             UINT64_C(0x0000000000004000)
     98#define EFI_MEMORY_NV             UINT64_C(0x0000000000008000)
     99#define EFI_MEMORY_MORE_RELIABLE  UINT64_C(0x0000000000010000)
     100#define EFI_MEMORY_RO             UINT64_C(0x0000000000020000)
     101#define EFI_MEMORY_RUNTIME        UINT64_C(0x8000000000000000)
    95102
    96103typedef struct {
     
    102109} efi_v1_memdesc_t;
    103110
     111typedef struct {
     112        efi_guid_t guid;
     113        void *table;
     114} efi_configuration_table_t;
     115
     116typedef struct efi_simple_text_output_protocol {
     117        void *reset;
     118        efi_status_t (*output_string)(struct efi_simple_text_output_protocol *,
     119            int16_t *);
     120        void *test_string;
     121        void *query_mode;
     122        void *set_mode;
     123        void *set_attribute;
     124        void *clear_screen;
     125        void *set_cursor_position;
     126        void *enable_cursor;
     127        void *mode;
     128} efi_simple_text_output_protocol_t;
     129
     130typedef struct {
     131        efi_table_header_t hdr;
     132        void *raise_TPL;
     133        void *restore_TPL;
     134        efi_status_t (*allocate_pages)(efi_allocate_type_t, efi_memory_type_t,
     135            sysarg_t, uint64_t *);
     136        efi_status_t (*free_pages)(uint64_t, sysarg_t);
     137        efi_status_t (*get_memory_map)(sysarg_t *, efi_v1_memdesc_t *,
     138            sysarg_t *, sysarg_t *, uint32_t *);
     139        efi_status_t (*allocate_pool)(efi_memory_type_t, sysarg_t, void **);
     140        efi_status_t (*free_pool)(void *);
     141        void *create_event;
     142        void *set_timer;
     143        void *wait_for_event;
     144        void *signal_event;
     145        void *close_event;
     146        void *check_event;
     147        void *install_protocol_interface;
     148        void *reinstall_protocol_interface;
     149        void *uninstall_protocol_interface;
     150        void *handle_protocol;
     151        void *reserved;
     152        void *register_protocol_notify;
     153        void *locate_handle;
     154        void *locate_device_path;
     155        void *install_configuration_table;
     156        void *load_image;
     157        void *start_image;
     158        void *exit;
     159        void *unload_image;
     160        efi_status_t (*exit_boot_services)(void *, sysarg_t);
     161        void *get_next_monotonic_count;
     162        void *stall;
     163        void *set_watchdog_timer;
     164        void *connect_controller;
     165        void *disconnect_controller;
     166        void *open_protocol;
     167        void *close_protocol;
     168        void *open_protocol_information;
     169        void *protocols_per_handle;
     170        void *locate_handle_buffer;
     171        void *locate_protocol;
     172        void *install_multiple_protocol_interfaces;
     173        void *uninstall_multiple_protocol_intefaces;
     174        void *calculate_crc32;
     175        void *copy_mem;
     176        void *set_mem;
     177        void *create_event_ex;
     178} efi_boot_services_t;
     179
     180typedef struct {
     181        efi_table_header_t hdr;
     182        char *fw_vendor;
     183        uint32_t fw_revision;
     184        void *cons_in_handle;
     185        void *cons_in;
     186        void *cons_out_handle;
     187        efi_simple_text_output_protocol_t *cons_out;
     188        void *cons_err_handle;
     189        efi_simple_text_output_protocol_t *cons_err;
     190        void *runtime_services;
     191        efi_boot_services_t *boot_services;
     192        sysarg_t conf_table_entries;
     193        efi_configuration_table_t *conf_table;
     194} efi_system_table_t;
     195
    104196#define EFI_PAGE_SIZE   4096
    105197
    106198extern void *efi_vendor_table_find(efi_system_table_t *, efi_guid_t);
     199extern efi_status_t efi_get_memory_map(efi_system_table_t *, sysarg_t *,
     200    efi_v1_memdesc_t **, sysarg_t *, sysarg_t *, uint32_t *);
    107201
    108202#endif
Note: See TracChangeset for help on using the changeset viewer.