Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
fxlin committed Feb 25, 2021
1 parent 99643c3 commit 800250f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 49 deletions.
29 changes: 24 additions & 5 deletions src/lesson03-bonus/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# export USE_QEMU=1
# make

# export USE_QEMU=
# make

ARMGNU ?= aarch64-linux-gnu

COPS = -Wall -nostdlib -nostartfiles -ffreestanding -Iinclude -mgeneral-regs-only -g -O0
ASMOPS = -Iinclude -g
COPS = -Wall -nostdlib -nostartfiles -ffreestanding -Iinclude -mgeneral-regs-only -g -O0
ASMOPS = -Iinclude -g

ifeq ($(USE_QEMU),1)
COPS += -DUSE_QEMU=1
ASMOPS += -DUSE_QEMU=1
START_ADDR = 0x80000
BUILD_DIR = build-qemu
else
BUILD_DIR = build-rpi
START_ADDR = 0x0
endif

BUILD_DIR = build
SRC_DIR = src

all : kernel8.img
Expand All @@ -26,6 +41,10 @@ OBJ_FILES += $(ASM_FILES:$(SRC_DIR)/%.S=$(BUILD_DIR)/%_s.o)
DEP_FILES = $(OBJ_FILES:%.o=%.d)
-include $(DEP_FILES)

kernel8.img: $(SRC_DIR)/linker.ld $(OBJ_FILES)
$(ARMGNU)-ld -T $(SRC_DIR)/linker.ld -o $(BUILD_DIR)/kernel8.elf $(OBJ_FILES)
$(BUILD_DIR)/linker.ld : $(SRC_DIR)/linker.in.ld
mkdir -p $(@D)
$(ARMGNU)-gcc -E -DSTART_ADDR=$(START_ADDR) -x c $^ | grep -v '^#' > $@

kernel8.img: $(BUILD_DIR)/linker.ld $(OBJ_FILES)
$(ARMGNU)-ld -T $(BUILD_DIR)/linker.ld -o $(BUILD_DIR)/kernel8.elf $(OBJ_FILES)
$(ARMGNU)-objcopy $(BUILD_DIR)/kernel8.elf -O binary kernel8.img
31 changes: 0 additions & 31 deletions src/lesson03-bonus/Makefile.qemu

This file was deleted.

2 changes: 1 addition & 1 deletion src/lesson03-bonus/src/boot.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ master:
ldr x0, =HCR_VALUE // Hypervisor Configuration (EL2)
msr hcr_el2, x0

#ifdef USE_QEMU // xzl: qemu boots from EL2. cannot do things to EL3
#ifdef USE_QEMU // xzl: qemu boots from EL2. cannot do things to EL3
ldr x0, =SPSR_VALUE
msr spsr_el2, x0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SECTIONS
{
. = 0x80000;
. = START_ADDR;
.text.boot : { *(.text.boot) }
.text : { *(.text) }
. = ALIGN(0x8);
Expand Down
11 changes: 0 additions & 11 deletions src/lesson03-bonus/src/linker.ld

This file was deleted.

0 comments on commit 800250f

Please sign in to comment.