File tree Expand file tree Collapse file tree 12 files changed +201
-3
lines changed Expand file tree Collapse file tree 12 files changed +201
-3
lines changed Original file line number Diff line number Diff line change @@ -2,20 +2,25 @@ cmake_minimum_required(VERSION 3.16)
2
2
3
3
if (NOT ULTRA_ARCH )
4
4
set (ULTRA_ARCH x86 )
5
- elseif (NOT ULTRA_ARCH STREQUAL "x86" )
5
+ elseif (NOT ULTRA_ARCH STREQUAL "x86" AND
6
+ NOT ULTRA_ARCH STREQUAL "arm" )
6
7
message (FATAL_ERROR "Invalid architecture ${ULTRA_ARCH} " )
7
8
endif ()
8
9
9
10
if (NOT ULTRA_ARCH_EXECUTION_MODE )
10
11
if (ULTRA_ARCH STREQUAL "x86" )
11
12
set (ULTRA_ARCH_EXECUTION_MODE "x86_64" )
13
+ elseif (ULTRA_ARCH STREQUAL "arm" )
14
+ set (ULTRA_ARCH_EXECUTION_MODE "aarch64" )
12
15
endif ()
13
16
endif ()
14
17
15
18
set (ULTRA_FULL_ARCH "${ULTRA_ARCH} /${ULTRA_ARCH_EXECUTION_MODE} " )
16
19
17
20
if (ULTRA_ARCH STREQUAL "x86" )
18
21
set (ULTRA_VALID_EXECUTION_MODES i686 x86_64 )
22
+ elseif (ULTRA_ARCH STREQUAL "arm" )
23
+ set (ULTRA_VALID_EXECUTION_MODES aarch32 aarch64 )
19
24
endif ()
20
25
21
26
if (NOT ULTRA_ARCH_EXECUTION_MODE IN_LIST ULTRA_VALID_EXECUTION_MODES )
Original file line number Diff line number Diff line change
1
+ link-aarch32.ld
2
+ link-aarch64.ld
Original file line number Diff line number Diff line change
1
+ if (ULTRA_ARCH_EXECUTION_MODE STREQUAL "aarch32" )
2
+ target_compile_definitions (${ULTRA_KERNEL} PUBLIC ULTRA_ARCH_WIDTH=4 )
3
+ target_compile_definitions (${ULTRA_KERNEL} PUBLIC ULTRA_PHYS_ADDR_WIDTH=4 )
4
+ ultra_target_compile_options (
5
+ ${ULTRA_KERNEL}
6
+ -mfloat-abi=soft
7
+ )
8
+ message (
9
+ FATAL_ERROR
10
+ "aarch32 is not implemented (TODO: soft math helpers, loader support)"
11
+ )
12
+ else ()
13
+ target_compile_definitions (${ULTRA_KERNEL} PUBLIC ULTRA_ARCH_WIDTH=8 )
14
+ target_compile_definitions (${ULTRA_KERNEL} PUBLIC ULTRA_PHYS_ADDR_WIDTH=8 )
15
+ ultra_target_compile_options (
16
+ ${ULTRA_KERNEL}
17
+ -mgeneral-regs-only
18
+ )
19
+
20
+ # GCC doesn't support red-zone on aarch64
21
+ if (ULTRA_TOOLCHAIN STREQUAL "clang" )
22
+ ultra_target_compile_options (
23
+ ${ULTRA_KERNEL}
24
+ PRIVATE
25
+ -mno-red-zone
26
+ )
27
+ endif ()
28
+ endif ()
29
+
30
+ target_sources (
31
+ ${ULTRA_KERNEL}
32
+ PRIVATE
33
+ entry.c
34
+ io.c
35
+ )
36
+ target_include_directories (
37
+ ${ULTRA_KERNEL}
38
+ PRIVATE
39
+ include
40
+ )
41
+
42
+ set (ULTRA_LD_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR} /link.ld.template" )
43
+ set (ULTRA_LD_SCRIPT
44
+ "${CMAKE_CURRENT_SOURCE_DIR} /link-${ULTRA_ARCH_EXECUTION_MODE} .ld" )
45
+ add_ultra_ld_template (
46
+ NAME
47
+ kernel-link-script
48
+ TEMPLATE_PATH
49
+ ${ULTRA_LD_TEMPLATE}
50
+ OUT_PATH
51
+ ${ULTRA_LD_SCRIPT}
52
+ DEPENDANT
53
+ ${ULTRA_KERNEL}
54
+ )
55
+
56
+ ultra_target_link_options (
57
+ ${ULTRA_KERNEL}
58
+ -T${ULTRA_LD_SCRIPT}
59
+ -z max-page-size=4096
60
+ )
Original file line number Diff line number Diff line change
1
+ #include <boot/ultra_protocol.h>
2
+ #include <boot/entry.h>
3
+ #include <common/helpers.h>
4
+
5
+ void arm_entry (struct ultra_boot_context * ctx , uint32_t magic )
6
+ {
7
+ if (magic != ULTRA_MAGIC )
8
+ for (;;);
9
+
10
+ UNUSED (ctx );
11
+ entry ();
12
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #define PAGE_SIZE 4096
4
+ #define PAGE_SHIFT 12
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include <common/types.h>
4
+ #include <common/error.h>
5
+
6
+ #define ULTRA_ARCH_PORT_IO_WINDOW_OFFSET 0x1000000
7
+ #define ULTRA_ARCH_PORT_IO_WINDOW_LEN 0x1000000
8
+ #define ULTRA_ARCH_PORT_IO_WINDOW_END \
9
+ (ULTRA_ARCH_PORT_IO_WINDOW_OFFSET + ULTRA_ARCH_PORT_IO_WINDOW_LEN + 1)
10
+
11
+ typedef void * pio_addr_t ;
12
+ typedef pio_addr_t pio_addr_or_error_t ;
13
+
14
+ #define encode_error_pio_addr (ret ) encode_error_ptr(ret)
15
+ #define decode_error_pio_addr (ret ) decode_error_ptr(ret)
16
+ #define error_pio_addr (ret ) error_ptr(ret)
Original file line number Diff line number Diff line change
1
+ #include <common/types.h>
2
+ #include <common/error.h>
3
+ #include <private/arch/io.h>
4
+
5
+ ptr_or_error_t arch_map_memory_io (phys_addr_t phys_base , size_t length )
6
+ {
7
+ UNUSED (phys_base );
8
+ UNUSED (length );
9
+ return encode_error_ptr (ENOTSUP );
10
+ }
11
+
12
+ pio_addr_t arch_map_port_io (phys_addr_t phys_base , size_t length )
13
+ {
14
+ UNUSED (phys_base );
15
+ UNUSED (length );
16
+ return encode_error_pio_addr (ENOTSUP );
17
+ }
Original file line number Diff line number Diff line change
1
+ ENTRY(arm_entry)
2
+
3
+ #ifdef ULTRA_ARCH_EXECUTION_MODE_AARCH32
4
+ VIRTUAL_BASE = 0xC0000000;
5
+ PHYSICAL_OFFSET = 0;
6
+ #else
7
+ VIRTUAL_BASE = 0xFFFFFFFF80000000;
8
+ PHYSICAL_OFFSET = 0;
9
+ #endif
10
+
11
+ #include <linker_common.ld.h>
12
+
13
+ // NOTE: These flags are currently not enforced by anyone
14
+ PHDRS
15
+ {
16
+ text PT_LOAD FLAGS(PHDR_READ | PHDR_EXEC);
17
+ rodata PT_LOAD FLAGS(PHDR_READ);
18
+ data PT_LOAD FLAGS(PHDR_READ | PHDR_WRITE);
19
+ }
20
+
21
+ SECTIONS
22
+ {
23
+ . = VIRTUAL_BASE + PHYSICAL_OFFSET;
24
+
25
+ NORELOCS_GUARD
26
+
27
+ .text : VIRTUAL_BASE_RELATIVE(.text)
28
+ {
29
+ TEXT
30
+ } :text
31
+
32
+ . = ALIGN(4K);
33
+
34
+ .rodata : VIRTUAL_BASE_RELATIVE(.rodata)
35
+ {
36
+ RODATA(ULTRA_ARCH_WIDTH)
37
+ } :rodata =0xDEADBEEF
38
+
39
+ . = ALIGN(4K);
40
+
41
+ .data : VIRTUAL_BASE_RELATIVE(.data)
42
+ {
43
+ DATA
44
+ } :data
45
+
46
+ .bss : VIRTUAL_BASE_RELATIVE(.bss)
47
+ {
48
+ BSS
49
+ } :data
50
+
51
+ SECTION_DEBUG
52
+ SECTION_TABS
53
+
54
+ . = ALIGN(8);
55
+
56
+ /*
57
+ * We don't use these for now but keep them anyway,
58
+ * otherwise linker complains.
59
+ */
60
+ .ARM.exidx : {
61
+ unwind_idx_begin = .;
62
+ *(.ARM.exidx*)
63
+ unwind_idx_end = .;
64
+ }
65
+ .ARM.extab : {
66
+ unwind_table_begin = .;
67
+ *(.ARM.extab*)
68
+ unwind_table_end = .;
69
+ }
70
+
71
+ ARM.attributes 0x000000000 : {
72
+ *(.ARM.attributes)
73
+ }
74
+
75
+ DISCARDS
76
+ }
Original file line number Diff line number Diff line change 45
45
.debug_frame 0x000000000 : { *(.debug_frame) } \
46
46
.debug_line 0x000000000 : { *(.debug_line) } \
47
47
.debug_line_str 0x000000000 : { *(.debug_line_str) } \
48
+ .debug_loc 0x000000000 : { *(.debug_loc) } \
48
49
.debug_addr 0x000000000 : { *(.debug_addr) } \
49
50
.debug_macro 0x000000000 : { *(.debug_macro) *(.debug_macro[*]) } \
50
51
.debug_aranges 0x000000000 : { *(.debug_aranges) } \
Original file line number Diff line number Diff line change @@ -16,6 +16,6 @@ endif ()
16
16
# Do this because cmake attempts to link against -lc and crt0
17
17
set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
18
18
19
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --target=${ULTRA_ARCH_EXECUTION_MODE } -none-none" )
19
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --target=${ULTRA_TARGET_PREFIX } -none-none" )
20
20
set (CMAKE_C_COMPILER clang )
21
21
set (CMAKE_LINKER ${LLD_LINKER} )
You can’t perform that action at this time.
0 commit comments