Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
KERNEL_CONFIG_TYPE = Union[bool, str]
KERNEL_OPTIONS = Dict[str, KERNEL_CONFIG_TYPE]

X86_64_TOOLCHAIN = ""
X86_64_TOOLCHAIN = "x86_64-linux-gnu-"
AARCH64_TOOLCHAIN = "aarch64-none-elf-"
# We can use the same toolchain for both 32-bit and 64-bit RISC-V builds.
RISCV_TOOLCHAIN = "riscv64-unknown-elf-"
Expand Down Expand Up @@ -456,18 +456,39 @@ class ConfigInfo:
"hello": Path("example/polarfire/hello")
}
),
# BoardInfo(
# name="x86_64",
# arch=BoardArch.X86_64,
# gcc_flags = "",
# loader_link_address=0x80200000,
# kernel_options = {
# "KernelIsMCS": True,
# "KernelPlatform": "pc99",
# "KernelSel4Arch": "x86_64",
# },
# examples = {}
# ),
BoardInfo(
name="x86_64_virt",
arch=BoardArch.X86_64,
gcc_flags = "GCC_MARCH=nehalem",
loader_link_address=0x10000000, # 256MB
kernel_options = {
"KernelIsMCS": True,
"KernelPlatform": "pc99",
"KernelSel4Arch": "x86_64",
"KernelVTX": True,
"KernelX86MicroArch": "nehalem",
},
examples = {
"hello": Path("example/x86_64_virt/hello")
}
),
BoardInfo(
name="x86_64_supermicro",
arch=BoardArch.X86_64,
gcc_flags = "GCC_MARCH=skylake",
loader_link_address=0x10000000, # 256MB
kernel_options = {
"KernelIsMCS": True,
"KernelPlatform": "pc99",
"KernelSel4Arch": "x86_64",
"KernelVTX": True,
"KernelLAPICMode": "X2APIC",
"KernelX86MicroArch": "skylake",
},
examples = {
"hello": Path("example/x86_64_supermicro/hello")
}
),
)

SUPPORTED_CONFIGS = (
Expand Down Expand Up @@ -615,7 +636,7 @@ def build_sel4(
elif board.arch == BoardArch.AARCH64:
toolchain_config = f"-DCROSS_COMPILER_PREFIX={AARCH64_TOOLCHAIN}"
elif board.arch == BoardArch.X86_64:
if host_arch != "x86_64":
if host_platform.machine() != "x86_64":
assert False, "@ivanv: Figure out cross-compiling to x86-64"
else:
toolchain_config = ""
Expand Down Expand Up @@ -734,6 +755,8 @@ def build_lib_component(
arch_args = f"ARCH=riscv64 TOOLCHAIN={RISCV_TOOLCHAIN}"
elif board.arch == BoardArch.RISCV32:
arch_args = f"ARCH=riscv32 TOOLCHAIN={RISCV_TOOLCHAIN}"
elif board.arch == BoardArch.X86_64:
arch_args = f"ARCH=x86_64 TOOLCHAIN={X86_64_TOOLCHAIN}"
else:
raise Exception(f"Unexpected arch given: {board.arch}", board.arch)

Expand Down
55 changes: 55 additions & 0 deletions example/x86_64_supermicro/hello/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright 2021, Breakaway Consulting Pty. Ltd.
#
# SPDX-License-Identifier: BSD-2-Clause
#
ifeq ($(strip $(BUILD_DIR)),)
$(error BUILD_DIR must be specified)
endif

ifeq ($(strip $(MICROKIT_SDK)),)
$(error MICROKIT_SDK must be specified)
endif

ifeq ($(strip $(MICROKIT_BOARD)),)
$(error MICROKIT_BOARD must be specified)
endif

ifeq ($(strip $(MICROKIT_CONFIG)),)
$(error MICROKIT_CONFIG must be specified)
endif

TOOLCHAIN := x86_64-linux-gnu

ARCH := skylake

CC := $(TOOLCHAIN)-gcc
LD := $(TOOLCHAIN)-ld
AS := $(TOOLCHAIN)-as
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

HELLO_OBJS := hello.o

BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG)

IMAGES := hello.elf
CFLAGS := -march=$(ARCH) -DARCH_x86_64 -nostdlib -ffreestanding -g3 -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include
LDFLAGS := -L$(BOARD_DIR)/lib
LIBS := -lmicrokit -Tmicrokit.ld

IMAGE_FILE = $(BUILD_DIR)/loader.img
REPORT_FILE = $(BUILD_DIR)/report.txt

all: $(IMAGE_FILE)

$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile
$(AS) -g3 -march=$(ARCH) $< -o $@

$(BUILD_DIR)/hello.elf: $(addprefix $(BUILD_DIR)/, $(HELLO_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(IMAGE_FILE) $(REPORT_FILE): $(addprefix $(BUILD_DIR)/, $(IMAGES)) hello.system
$(MICROKIT_TOOL) hello.system --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) --x86-machine machine.json -o $(IMAGE_FILE) -r $(REPORT_FILE)
18 changes: 18 additions & 0 deletions example/x86_64_supermicro/hello/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2021, Breakaway Consulting Pty. Ltd.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <stdint.h>
#include <microkit.h>

void
init(void)
{
microkit_dbg_puts("hello, world\n");
}

void
notified(microkit_channel ch)
{
}
11 changes: 11 additions & 0 deletions example/x86_64_supermicro/hello/hello.system
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021, Breakaway Consulting Pty. Ltd.

SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="hello" priority="1">
<program_image path="hello.elf" />
</protection_domain>
</system>
62 changes: 62 additions & 0 deletions example/x86_64_supermicro/hello/machine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"memory": [
{
"base": 1048576,
"size": 1768484864
},
{
"base": 1812037632,
"size": 1839104
},
{
"base": 1859203072,
"size": 19845120
},
{
"base": 4294967296,
"size": 32212254720
}
],
"kdevs": [
{
"name": "apic",
"base": 4276092928,
"size": 4096
},
{
"name": "ioapic.0",
"base": 4273995776,
"size": 4096
},
{
"name": "drhu.0",
"base": 3321872384,
"size": 4096
},
{
"name": "drhu.1",
"base": 3774857216,
"size": 4096
},
{
"name": "drhu.2",
"base": 4227842048,
"size": 4096
},
{
"name": "drhu.3",
"base": 2868887552,
"size": 4096
}
],
"rmrrs": [
{
"device": 160,
"base": 1853911040,
"limit": 1853980671
}
],
"bootinfo": {
"numIOPTLevels": 4
}
}
55 changes: 55 additions & 0 deletions example/x86_64_virt/hello/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright 2021, Breakaway Consulting Pty. Ltd.
#
# SPDX-License-Identifier: BSD-2-Clause
#
ifeq ($(strip $(BUILD_DIR)),)
$(error BUILD_DIR must be specified)
endif

ifeq ($(strip $(MICROKIT_SDK)),)
$(error MICROKIT_SDK must be specified)
endif

ifeq ($(strip $(MICROKIT_BOARD)),)
$(error MICROKIT_BOARD must be specified)
endif

ifeq ($(strip $(MICROKIT_CONFIG)),)
$(error MICROKIT_CONFIG must be specified)
endif

TOOLCHAIN := x86_64-linux-gnu

ARCH := nehalem

CC := $(TOOLCHAIN)-gcc
LD := $(TOOLCHAIN)-ld
AS := $(TOOLCHAIN)-as
MICROKIT_TOOL ?= $(MICROKIT_SDK)/bin/microkit

HELLO_OBJS := hello.o

BOARD_DIR := $(MICROKIT_SDK)/board/$(MICROKIT_BOARD)/$(MICROKIT_CONFIG)

IMAGES := hello.elf
CFLAGS := -march=$(ARCH) -DARCH_x86_64 -nostdlib -ffreestanding -g3 -O3 -Wall -Wno-unused-function -Werror -I$(BOARD_DIR)/include
LDFLAGS := -L$(BOARD_DIR)/lib
LIBS := -lmicrokit -Tmicrokit.ld

IMAGE_FILE = $(BUILD_DIR)/loader.img
REPORT_FILE = $(BUILD_DIR)/report.txt

all: $(IMAGE_FILE)

$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile
$(AS) -g3 -march=$(ARCH) $< -o $@

$(BUILD_DIR)/hello.elf: $(addprefix $(BUILD_DIR)/, $(HELLO_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(IMAGE_FILE) $(REPORT_FILE): $(addprefix $(BUILD_DIR)/, $(IMAGES)) hello.system
$(MICROKIT_TOOL) hello.system --search-path $(BUILD_DIR) --board $(MICROKIT_BOARD) --config $(MICROKIT_CONFIG) --x86-machine machine.json -o $(IMAGE_FILE) -r $(REPORT_FILE)
18 changes: 18 additions & 0 deletions example/x86_64_virt/hello/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2021, Breakaway Consulting Pty. Ltd.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <stdint.h>
#include <microkit.h>

void
init(void)
{
microkit_dbg_puts("hello, world\n");
}

void
notified(microkit_channel ch)
{
}
11 changes: 11 additions & 0 deletions example/x86_64_virt/hello/hello.system
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021, Breakaway Consulting Pty. Ltd.

SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<protection_domain name="hello" priority="1">
<program_image path="hello.elf" />
</protection_domain>
</system>
33 changes: 33 additions & 0 deletions example/x86_64_virt/hello/machine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"memory": [
{
"base": 1048576,
"size": 2146299904
},
{
"base": 4294967296,
"size": 2147483648
}
],
"kdevs": [
{
"name": "apic",
"base": 4276092928,
"size": 4096
},
{
"name": "ioapic.0",
"base": 4273995776,
"size": 4096
},
{
"name": "drhu.0",
"base": 4275634176,
"size": 4096
}
],
"rmrrs": [],
"bootinfo": {
"numIOPTLevels": 3
}
}
Loading