Skip to content

Commit

Permalink
build for multiple platforms; add mkfs command line option to specify…
Browse files Browse the repository at this point in the history
… kernel image; initial aarch64 definitions and 'virt' platform hello world; utilize aarch64 tag feature for userspace runtime use
  • Loading branch information
wjhun committed Aug 14, 2020
1 parent ac46169 commit f44463b
Show file tree
Hide file tree
Showing 92 changed files with 1,001 additions and 452 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -40,7 +40,7 @@ jobs:
- run: sudo gcloud config set project ${GOOGLE_PROJECT_ID}
- run: gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}

- run: mkdir temp && cp output/stage3/bin/stage3.img temp/ && cp output/boot/boot.img temp/ && cp output/tools/bin/mkfs temp/
- run: mkdir temp && cp output/platform/pc/bin/kernel.img temp/ && cp output/platform/pc/boot/boot.img temp/ && cp output/tools/bin/mkfs temp/
- run: cd temp && tar cvzf nanos-nightly-linux.tar.gz * && gsutil cp nanos-nightly-linux.tar.gz gs://nanos/release/nightly
- run: gsutil acl ch -u AllUsers:R gs://nanos/release/nightly/nanos-nightly-linux.tar.gz
- run: rm -r temp
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- run: sudo gcloud config set project ${GOOGLE_PROJECT_ID}
- run: gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}

- run: mkdir temp && cp output/stage3/bin/stage3.img temp/ && cp output/boot/boot.img temp/ && cp output/tools/bin/mkfs temp/
- run: mkdir temp && cp output/platform/pc/bin/kernel.img temp/ && cp output/platform/pc/boot/boot.img temp/ && cp output/tools/bin/mkfs temp/
- run: cd temp && tar cvzf nanos-nightly-darwin.tar.gz * && gsutil cp nanos-nightly-darwin.tar.gz gs://nanos/release/nightly
- run: gsutil acl ch -u AllUsers:R gs://nanos/release/nightly/nanos-nightly-darwin.tar.gz
- run: rm -r temp
Expand Down
2 changes: 1 addition & 1 deletion .gdbinit
@@ -1,5 +1,5 @@
set architecture i386:x86-64
display/i $pc
target remote :1234
symbol-file ./output/stage3/bin/stage3.img
symbol-file ./output/platform/pc/bin/kernel.img

3 changes: 3 additions & 0 deletions .gitignore
@@ -1,6 +1,9 @@
Makefile.local
/tags
/TAGS
/GTAGS
/GPATH
/GRTAGS

# test artifacts
/test/go/go.sum
Expand Down
137 changes: 18 additions & 119 deletions Makefile
@@ -1,19 +1,10 @@
SUBDIR= boot stage3 test tools
SUBDIR= $(PLATFORMDIR) test tools

# runtime tests / ready-to-use targets
TARGET= webg

ifneq ($(NANOS_TARGET_ROOT),)
TARGET_ROOT_OPT= -r $(NANOS_TARGET_ROOT)
endif

MKFS= $(OUTDIR)/tools/bin/mkfs
BOOTIMG= $(OUTDIR)/boot/boot.img
STAGE3= $(OUTDIR)/stage3/bin/stage3.img

IMAGE= $(OUTDIR)/image/disk.raw
CLEANFILES+= $(IMAGE)
CLEANDIRS+= $(OUTDIR)/image
CLEANDIRS+= $(OUTDIR)/image $(OUTDIR)/platform/$(PLATFORM) $(OUTDIR)/platform

LWIPDIR= $(VENDORDIR)/lwip
GITFLAGS+= --depth 1 https://github.com/nanovms/lwip.git -b STABLE-2_1_2_RELEASE
Expand All @@ -39,40 +30,12 @@ AWS_AMI_IMAGE= nanos-$(TARGET)

all: image

include rules.mk

.PHONY: image release contgen mkfs boot stage3 target stage distclean

image: mkfs boot stage3 target
@ echo "MKFS $@"
@ $(MKDIR) $(dir $(IMAGE))
$(Q) $(MKFS) $(TARGET_ROOT_OPT) -b $(BOOTIMG) $(IMAGE) <test/runtime/$(TARGET).manifest

release: mkfs boot stage3
$(Q) $(RM) -r release
$(Q) $(MKDIR) release
$(CP) $(MKFS) release
$(CP) $(BOOTIMG) release
$(CP) $(STAGE3) release
cd release && $(TAR) -czvf nanos-release-$(REL_OS)-${version}.tar.gz *

contgen mkfs vdsogen:
$(Q) $(MAKE) -C tools $@

boot: contgen
$(Q) $(MAKE) -C $@

stage3: $(LWIPDIR)/.vendored contgen
$(Q) $(MAKE) -C $@
.PHONY: image release target distclean

target: contgen
$(Q) $(MAKE) -C test/runtime $(TARGET)
include rules.mk

stage: mkfs boot stage3
$(Q) $(MKDIR) .staging
$(Q) $(CP) -a $(MKFS) .staging/mkfs
$(Q) $(CP) -a $(BOOTIMG) .staging/boot.img
$(Q) $(CP) -a $(STAGE3) .staging/stage3.img
image: $(LWIPDIR)/.vendored contgen
$(Q) $(MAKE) -C $(PLATFORMDIR) image TARGET=$(TARGET)

distclean: clean
$(Q) $(RM) -rf $(VENDORDIR)
Expand All @@ -82,85 +45,31 @@ distclean: clean

.PHONY: test-all test test-noaccel

contgen mkfs:
$(Q) $(MAKE) -C tools $@

test-all:
$(Q) $(MAKE) -C test

test test-noaccel: mkfs boot stage3
test test-noaccel: mkfs image
$(Q) $(MAKE) -C test test
$(Q) $(MAKE) runtime-tests$(subst test,,$@)

RUNTIME_TESTS= aio creat dup epoll eventfd fallocate fcntl fst getdents getrandom hw hws io_uring mkdir mmap netsock pipe readv rename sendfile signal socketpair time unlink thread_test vsyscall write writev

.PHONY: runtime-tests runtime-tests-noaccel

runtime-tests runtime-tests-noaccel:
runtime-tests runtime-tests-noaccel: mkfs image
$(foreach t,$(RUNTIME_TESTS),$(call execute_command,$(Q) $(MAKE) run$(subst runtime-tests,,$@) TARGET=$t))

##############################################################################
# run

.PHONY: run run-bridge run-nokvm

QEMU= qemu-system-x86_64
MACHINE_TYPE= q35
QEMU_CPU= -cpu max
DISPLAY= none
STORAGE= virtio-scsi
STORAGE_BUS= ,bus=pci.2,addr=0x0
NETWORK= virtio-net
NETWORK_BUS= ,bus=pci.3,addr=0x0

QEMU_MACHINE= -machine $(MACHINE_TYPE)
QEMU_MEMORY= -m 2G
QEMU_PCI= -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=$(PCI_BUS),multifunction=on,addr=0x3 \
-device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=$(PCI_BUS),addr=0x3.0x1 \
-device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=$(PCI_BUS),addr=0x3.0x2

ifeq ($(DISPLAY),none)
QEMU_DISPLAY= -display none
else ifeq ($(DISPLAY),vga)
QEMU_DISPLAY=
else
$(error Unsupported DISPLAY=$(DISPLAY))
endif
QEMU_SERIAL= -serial stdio
QEMU_STORAGE= -drive if=none,id=hd0,format=raw,file=$(IMAGE)
ifeq ($(STORAGE),virtio-scsi)
QEMU_STORAGE+= -device virtio-scsi-pci$(STORAGE_BUS),id=scsi0 -device scsi-hd,bus=scsi0.0,drive=hd0
else ifeq ($(STORAGE),pvscsi)
QEMU_STORAGE+= -device pvscsi$(STORAGE_BUS),id=scsi0 -device scsi-hd,bus=scsi0.0,drive=hd0
else ifeq ($(STORAGE),virtio-blk)
QEMU_STORAGE+= -device virtio-blk-pci$(STORAGE_BUS),drive=hd0
else ifeq ($(STORAGE),ide)
MACHINE_TYPE= pc # no AHCI support yet
QEMU_STORAGE+= -device ide-hd,bus=ide.0,drive=hd0
else
$(error Unsupported STORAGE=$(STORAGE))
endif
ifeq ($(MACHINE_TYPE),q35)
PCI_BUS= pcie.0
else
PCI_BUS= pci.0
endif
QEMU_TAP= -netdev tap,id=n0,ifname=tap0,script=no,downscript=no
QEMU_NET= -device $(NETWORK)$(NETWORK_BUS),mac=7e:b8:7e:87:4a:ea,netdev=n0 $(QEMU_TAP)
QEMU_USERNET= -device $(NETWORK)$(NETWORK_BUS),netdev=n0 -netdev user,id=n0,hostfwd=tcp::8080-:8080,hostfwd=tcp::9090-:9090,hostfwd=udp::5309-:5309 -object filter-dump,id=filter0,netdev=n0,file=/tmp/nanos.pcap
QEMU_FLAGS=
#QEMU_FLAGS+= -smp 4
#QEMU_FLAGS+= -d int -D int.log
#QEMU_FLAGS+= -s -S

QEMU_COMMON= $(QEMU_MACHINE) $(QEMU_MEMORY) $(QEMU_DISPLAY) $(QEMU_PCI) $(QEMU_SERIAL) $(QEMU_STORAGE) -device isa-debug-exit -no-reboot $(QEMU_FLAGS)

run: image
$(QEMU) $(QEMU_COMMON) $(QEMU_USERNET) $(QEMU_ACCEL) || exit $$(($$?>>1))

run-bridge: image
$(QEMU) $(QEMU_COMMON) $(QEMU_NET) $(QEMU_ACCEL) || exit $$(($$?>>1))

run-noaccel: image
$(QEMU) $(QEMU_COMMON) $(QEMU_USERNET) $(QEMU_CPU) || exit $$(($$?>>1))
run:
$(Q) $(MAKE) -C $(PLATFORMDIR) TARGET=$(TARGET) run

run-bridge:
$(Q) $(MAKE) -C $(PLATFORMDIR) TARGET=$(TARGET) run-bridge

run-noaccel:
$(Q) $(MAKE) -C $(PLATFORMDIR) TARGET=$(TARGET) run-noaccel

##############################################################################
# VMware
Expand Down Expand Up @@ -238,13 +147,3 @@ create-ec2-snapshot: upload-ec2-image
status_message=`$(ECHO) "$$json" | $(JQ) -r ".ImportSnapshotTasks[0].SnapshotTaskDetail.StatusMessage?"`; \
$(PRINTF) "$(CLEAR_LINE)Task $$import_task_id: $$status_message ($$progress%%)"; \
done

ifeq ($(UNAME_s),Darwin)
REL_OS= darwin
QEMU_ACCEL= -accel $(ACCEL) -cpu host
ACCEL?= hvf
# ACCEL=? hax
else
REL_OS= linux
QEMU_ACCEL= -enable-kvm -cpu host
endif
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -113,8 +113,8 @@ copy the 3 required files to an appropriate release:

```
cp output/tools/bin/mkfs ~/.ops/0.1.17/.
cp output/boot/boot.img ~/.ops/0.1.17/.
cp output/stage3/bin/stage3.img ~/.ops/0.1.17/.
cp output/platform/pc/boot/boot.img ~/.ops/0.1.17/.
cp output/platform/pc/bin/kernel.img ~/.ops/0.1.17/.
```

### Contributing
Expand Down
File renamed without changes.

0 comments on commit f44463b

Please sign in to comment.