mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Merge pull request #36 from achilleasa/use-project-specific-go-workspace
Use project-specific go workspace and rewrite import paths
This commit is contained in:
commit
e580dea9d1
@ -2,10 +2,8 @@ language: go
|
||||
sudo: required
|
||||
go:
|
||||
- 1.8
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
script:
|
||||
- make lint
|
||||
- bash coverage.sh
|
||||
- make collect-coverage
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
43
Makefile
43
Makefile
@ -9,6 +9,7 @@ iso_target := $(BUILD_DIR)/kernel-$(ARCH).iso
|
||||
# If your go is called something else set it on the commandline, like
|
||||
# this: make run GO=go1.8
|
||||
GO ?= go
|
||||
GOPATH := $(GOPATH):$(shell pwd)
|
||||
|
||||
ifeq ($(OS), Linux)
|
||||
export SHELL := /bin/bash -o pipefail
|
||||
@ -22,13 +23,14 @@ GOROOT := $(shell $(GO) env GOROOT)
|
||||
|
||||
GC_FLAGS ?=
|
||||
LD_FLAGS := -n -T $(BUILD_DIR)/linker.ld -static --no-ld-generated-unwind-info
|
||||
AS_FLAGS := -g -f elf64 -F dwarf -I $(BUILD_DIR)/ -I arch/$(ARCH)/asm/ -dNUM_REDIRECTS=$(shell $(GO) run tools/redirects/redirects.go count)
|
||||
AS_FLAGS := -g -f elf64 -F dwarf -I $(BUILD_DIR)/ -I src/arch/$(ARCH)/asm/ \
|
||||
-dNUM_REDIRECTS=$(shell GOPATH=$(GOPATH) $(GO) run tools/redirects/redirects.go count)
|
||||
|
||||
MIN_OBJCOPY_VERSION := 2.26.0
|
||||
HAVE_VALID_OBJCOPY := $(shell objcopy -V | head -1 | awk -F ' ' '{print "$(MIN_OBJCOPY_VERSION)\n" $$NF}' | sort -ct. -k1,1n -k2,2n && echo "y")
|
||||
|
||||
asm_src_files := $(wildcard arch/$(ARCH)/asm/*.s)
|
||||
asm_obj_files := $(patsubst arch/$(ARCH)/asm/%.s, $(BUILD_DIR)/arch/$(ARCH)/asm/%.o, $(asm_src_files))
|
||||
asm_src_files := $(wildcard src/arch/$(ARCH)/asm/*.s)
|
||||
asm_obj_files := $(patsubst src/arch/$(ARCH)/asm/%.s, $(BUILD_DIR)/arch/$(ARCH)/asm/%.o, $(asm_src_files))
|
||||
|
||||
.PHONY: kernel iso clean binutils_version_check
|
||||
|
||||
@ -36,8 +38,8 @@ kernel: binutils_version_check kernel_image
|
||||
|
||||
kernel_image: $(kernel_target)
|
||||
@echo "[tools:redirects] populating kernel image redirect table"
|
||||
@$(GO) run tools/redirects/redirects.go populate-table $(kernel_target)
|
||||
|
||||
@GOPATH=$(GOPATH) $(GO) run tools/redirects/redirects.go populate-table $(kernel_target)
|
||||
|
||||
$(kernel_target): asm_files linker_script go.o
|
||||
@echo "[$(LD)] linking kernel-$(ARCH).bin"
|
||||
@$(LD) $(LD_FLAGS) -o $(kernel_target) $(asm_obj_files) $(BUILD_DIR)/go.o
|
||||
@ -46,7 +48,7 @@ go.o:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
|
||||
@echo "[go] compiling go sources into a standalone .o file"
|
||||
@GOARCH=$(GOARCH) GOOS=$(GOOS) $(GO) build -gcflags '$(GC_FLAGS)' -n 2>&1 | sed \
|
||||
@GOARCH=$(GOARCH) GOOS=$(GOOS) GOPATH=$(GOPATH) $(GO) build -gcflags '$(GC_FLAGS)' -n gopheros 2>&1 | sed \
|
||||
-e "1s|^|set -e\n|" \
|
||||
-e "1s|^|export GOOS=$(GOOS)\n|" \
|
||||
-e "1s|^|export GOARCH=$(GOARCH)\n|" \
|
||||
@ -61,7 +63,8 @@ go.o:
|
||||
@# asm entrypoint code needs to know the address to 'main.main' so we use
|
||||
@# objcopy to make that symbol exportable. Since nasm does not support externs
|
||||
@# with slashes we create a global symbol alias for kernel.Kmain
|
||||
@echo "[objcopy] creating global symbol alias 'kernel.Kmain' for 'github.com/achilleasa/gopher-os/kernel.Kmain' in go.o"
|
||||
@echo "[objcopy] create kernel.Kmain alias to gopheros/kernel/kmain.Kmain"
|
||||
@echo "[objcopy] globalizing symbols {_rt0_interrupt_handlers, runtime.g0/m0/physPageSize}"
|
||||
@objcopy \
|
||||
--add-symbol kernel.Kmain=.text:0x`nm $(BUILD_DIR)/go.o | grep "kmain.Kmain$$" | cut -d' ' -f1` \
|
||||
--globalize-symbol _rt0_interrupt_handlers \
|
||||
@ -85,17 +88,17 @@ grub-pc-bin_check:
|
||||
linker_script:
|
||||
@echo "[sed] extracting LMA and VMA from constants.inc"
|
||||
@echo "[gcc] pre-processing arch/$(ARCH)/script/linker.ld.in"
|
||||
@gcc `cat arch/$(ARCH)/asm/constants.inc | sed -e "/^$$/d; /^;/d; s/^/-D/g; s/\s*equ\s*/=/g;" | tr '\n' ' '` \
|
||||
@gcc `cat src/arch/$(ARCH)/asm/constants.inc | sed -e "/^$$/d; /^;/d; s/^/-D/g; s/\s*equ\s*/=/g;" | tr '\n' ' '` \
|
||||
-E -x \
|
||||
c arch/$(ARCH)/script/linker.ld.in | grep -v "^#" > $(BUILD_DIR)/linker.ld
|
||||
c src/arch/$(ARCH)/script/linker.ld.in | grep -v "^#" > $(BUILD_DIR)/linker.ld
|
||||
|
||||
$(BUILD_DIR)/go_asm_offsets.inc:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
|
||||
@echo "[tools:offsets] calculating OS/arch-specific offsets for g, m and stack structs"
|
||||
@$(GO) run tools/offsets/offsets.go -target-os $(GOOS) -target-arch $(GOARCH) -go-binary $(GO) -out $@
|
||||
|
||||
$(BUILD_DIR)/arch/$(ARCH)/asm/%.o: arch/$(ARCH)/asm/%.s
|
||||
@echo "[tools:offsets] calculating OS/arch-specific offsets for g, m and stack structs"
|
||||
@GOPATH=$(GOPATH) $(GO) run tools/offsets/offsets.go -target-os $(GOOS) -target-arch $(GOARCH) -go-binary $(GO) -out $@
|
||||
|
||||
$(BUILD_DIR)/arch/$(ARCH)/asm/%.o: src/arch/$(ARCH)/asm/%.s
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@echo "[$(AS)] $<"
|
||||
@$(AS) $(AS_FLAGS) $< -o $@
|
||||
@ -109,14 +112,14 @@ $(iso_target): iso_prereq kernel_image
|
||||
|
||||
@mkdir -p $(BUILD_DIR)/isofiles/boot/grub
|
||||
@cp $(kernel_target) $(BUILD_DIR)/isofiles/boot/kernel.bin
|
||||
@cp arch/$(ARCH)/script/grub.cfg $(BUILD_DIR)/isofiles/boot/grub
|
||||
@cp src/arch/$(ARCH)/script/grub.cfg $(BUILD_DIR)/isofiles/boot/grub
|
||||
@grub-mkrescue -o $(iso_target) $(BUILD_DIR)/isofiles 2>&1 | sed -e "s/^/ | /g"
|
||||
@rm -r $(BUILD_DIR)/isofiles
|
||||
|
||||
else
|
||||
VAGRANT_SRC_FOLDER = /home/vagrant/workspace/src/github.com/achilleasa/gopher-os
|
||||
VAGRANT_SRC_FOLDER = /home/vagrant/workspace
|
||||
|
||||
.PHONY: kernel iso vagrant-up vagrant-down vagrant-ssh run gdb clean
|
||||
.PHONY: kernel iso vagrant-up vagrant-down vagrant-ssh run gdb clean lint lint-check-deps test collect-coverage
|
||||
|
||||
kernel:
|
||||
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make GC_FLAGS="$(GC_FLAGS)" kernel'
|
||||
@ -170,8 +173,12 @@ lint: lint-check-deps
|
||||
./...
|
||||
|
||||
lint-check-deps:
|
||||
@$(GO) get -u gopkg.in/alecthomas/gometalinter.v1
|
||||
@GOPATH=$(GOPATH) $(GO) get -u -t gopkg.in/alecthomas/gometalinter.v1
|
||||
@gometalinter.v1 --install >/dev/null
|
||||
|
||||
test:
|
||||
$(GO) test -cover ./...
|
||||
GOPATH=$(GOPATH) $(GO) test -cover gopheros/...
|
||||
|
||||
collect-coverage:
|
||||
GOPATH=$(GOPATH) sh coverage.sh
|
||||
|
||||
|
8
Vagrantfile
vendored
8
Vagrantfile
vendored
@ -13,15 +13,19 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
config.vm.box = "minimal/xenial64"
|
||||
|
||||
config.vm.synced_folder "./", "/home/vagrant/workspace/src/github.com/achilleasa/gopher-os"
|
||||
config.vm.synced_folder "./", "/home/vagrant/workspace"
|
||||
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
apt-get update
|
||||
apt-get install -y nasm make xorriso
|
||||
[ ! -d "/usr/local/go" ] && wget -qO- https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar xz -C /usr/local
|
||||
mkdir -p /home/vagrant/go/src
|
||||
mkdir -p /home/vagrant/go/bin
|
||||
mkdir -p /home/vagrant/go/pkg
|
||||
chown -R vagrant:vagrant /home/vagrant/go
|
||||
echo "export GOROOT=/usr/local/go" > /etc/profile.d/go.sh
|
||||
echo "export GOBIN=/usr/local/go/bin" >> /etc/profile.d/go.sh
|
||||
echo "export GOPATH=/home/vagrant/workspace" >> /etc/profile.d/go.sh
|
||||
echo "export GOPATH=/home/vagrant/go" >> /etc/profile.d/go.sh
|
||||
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile.d/go.sh
|
||||
SHELL
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ set -e
|
||||
|
||||
echo "" > coverage.txt
|
||||
|
||||
for d in $(go list ./... | grep -v vendor); do
|
||||
for d in $(go list ./... | grep gopheros); do
|
||||
go test -v -race -coverprofile=profile.out -covermode=atomic $d
|
||||
if [ -f profile.out ]; then
|
||||
cat profile.out >> coverage.txt
|
||||
|
@ -1,6 +1,6 @@
|
||||
package tty
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
import "gopheros/kernel/driver/video/console"
|
||||
|
||||
const (
|
||||
defaultFg = console.LightGrey
|
@ -1,10 +1,9 @@
|
||||
package tty
|
||||
|
||||
import (
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
)
|
||||
|
||||
func TestVtPosition(t *testing.T) {
|
@ -3,12 +3,11 @@
|
||||
package goruntime
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm/allocator"
|
||||
"gopheros/kernel/mem/vmm"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm/allocator"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,15 +1,14 @@
|
||||
package goruntime
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"gopheros/kernel/mem/pmm/allocator"
|
||||
"gopheros/kernel/mem/vmm"
|
||||
"reflect"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm/allocator"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
||||
)
|
||||
|
||||
func TestSysReserve(t *testing.T) {
|
@ -1,9 +1,9 @@
|
||||
package hal
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/tty"
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
"gopheros/kernel/driver/tty"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
)
|
||||
|
||||
var (
|
@ -1,6 +1,6 @@
|
||||
package irq
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
||||
import "gopheros/kernel/kfmt/early"
|
||||
|
||||
// Regs contains a snapshot of the register values when an interrupt occurred.
|
||||
type Regs struct {
|
@ -2,11 +2,10 @@ package irq
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
)
|
||||
|
||||
func TestRegsPrint(t *testing.T) {
|
@ -1,6 +1,6 @@
|
||||
package early
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel/hal"
|
||||
import "gopheros/kernel/hal"
|
||||
|
||||
var (
|
||||
errMissingArg = []byte("(MISSING)")
|
@ -2,12 +2,11 @@ package early
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"gopheros/kernel/driver/tty"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/tty"
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
)
|
||||
|
||||
func TestPrintf(t *testing.T) {
|
@ -1,12 +1,12 @@
|
||||
package kmain
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/goruntime"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm/allocator"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/goruntime"
|
||||
"gopheros/kernel/hal"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
"gopheros/kernel/mem/pmm/allocator"
|
||||
"gopheros/kernel/mem/vmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,16 +1,15 @@
|
||||
package allocator
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
"gopheros/kernel/kfmt/early"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"gopheros/kernel/mem/vmm"
|
||||
"math"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,16 +1,15 @@
|
||||
package allocator
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"gopheros/kernel/mem/vmm"
|
||||
"math"
|
||||
"strconv"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
||||
)
|
||||
|
||||
func TestSetupPoolBitmaps(t *testing.T) {
|
@ -1,11 +1,11 @@
|
||||
package allocator
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
"gopheros/kernel/kfmt/early"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,12 +1,11 @@
|
||||
package allocator
|
||||
|
||||
import (
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
"gopheros/kernel/hal/multiboot"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
||||
)
|
||||
|
||||
func TestBootMemoryAllocator(t *testing.T) {
|
@ -2,9 +2,8 @@
|
||||
package pmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem"
|
||||
"math"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
)
|
||||
|
||||
// Frame describes a physical memory page index.
|
@ -1,9 +1,8 @@
|
||||
package pmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem"
|
||||
"testing"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
)
|
||||
|
||||
func TestFrameMethods(t *testing.T) {
|
@ -1,8 +1,8 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
)
|
||||
|
||||
var (
|
@ -1,12 +1,11 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
// ReservedZeroedFrame is a special zero-cleared frame allocated by the
|
@ -1,13 +1,12 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"runtime"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
func TestNextAddrFn(t *testing.T) {
|
@ -1,6 +1,6 @@
|
||||
package vmm
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel/mem"
|
||||
import "gopheros/kernel/mem"
|
||||
|
||||
// Page describes a virtual memory page index.
|
||||
type Page uintptr
|
@ -1,9 +1,8 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem"
|
||||
"testing"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
)
|
||||
|
||||
func TestPageMethods(t *testing.T) {
|
@ -1,12 +1,11 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,13 +1,12 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"runtime"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
func TestPageDirectoryTableInitAmd64(t *testing.T) {
|
@ -1,9 +1,9 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
var (
|
@ -1,9 +1,8 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"testing"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
func TestPageTableEntryFlags(t *testing.T) {
|
@ -1,6 +1,6 @@
|
||||
package vmm
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel"
|
||||
import "gopheros/kernel"
|
||||
|
||||
// Translate returns the physical address that corresponds to the supplied
|
||||
// virtual address or ErrInvalidMapping if the virtual address does not
|
@ -1,11 +1,10 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"runtime"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
func TestTranslateAmd64(t *testing.T) {
|
@ -1,12 +1,12 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/irq"
|
||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/irq"
|
||||
"gopheros/kernel/kfmt/early"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
var (
|
@ -3,17 +3,16 @@ package vmm
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"gopheros/kernel"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
"gopheros/kernel/irq"
|
||||
"gopheros/kernel/mem"
|
||||
"gopheros/kernel/mem/pmm"
|
||||
"strings"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel"
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
"github.com/achilleasa/gopher-os/kernel/irq"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
||||
)
|
||||
|
||||
func TestRecoverablePageFault(t *testing.T) {
|
@ -1,9 +1,8 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
)
|
||||
|
||||
var (
|
@ -1,11 +1,10 @@
|
||||
package vmm
|
||||
|
||||
import (
|
||||
"gopheros/kernel/mem"
|
||||
"runtime"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
||||
)
|
||||
|
||||
func TestPtePtrFn(t *testing.T) {
|
@ -1,8 +1,8 @@
|
||||
package kernel
|
||||
|
||||
import (
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/kfmt/early"
|
||||
)
|
||||
|
||||
var (
|
@ -3,12 +3,11 @@ package kernel
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"gopheros/kernel/cpu"
|
||||
"gopheros/kernel/driver/video/console"
|
||||
"gopheros/kernel/hal"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
||||
)
|
||||
|
||||
func TestPanic(t *testing.T) {
|
@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/achilleasa/gopher-os/kernel/kmain"
|
||||
import "gopheros/kernel/kmain"
|
||||
|
||||
var multibootInfoPtr uintptr
|
||||
|
@ -15,6 +15,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const pathToKernel = "src/gopheros/"
|
||||
|
||||
type redirect struct {
|
||||
src string
|
||||
dst string
|
||||
@ -28,16 +30,6 @@ func exit(err error) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func pkgPrefix() (string, error) {
|
||||
goPath := os.Getenv("GOPATH") + "/src/"
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.TrimPrefix(cwd, goPath), nil
|
||||
}
|
||||
|
||||
func collectGoFiles(root string) ([]string, error) {
|
||||
var goFiles []string
|
||||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
@ -61,11 +53,6 @@ func collectGoFiles(root string) ([]string, error) {
|
||||
func findRedirects(goFiles []string) ([]*redirect, error) {
|
||||
var redirects []*redirect
|
||||
|
||||
prefix, err := pkgPrefix()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, goFile := range goFiles {
|
||||
fset := token.NewFileSet()
|
||||
|
||||
@ -88,9 +75,8 @@ func findRedirects(goFiles []string) ([]*redirect, error) {
|
||||
}
|
||||
|
||||
// build qualified name to fn
|
||||
fqName := fmt.Sprintf("%s/%s.%s",
|
||||
prefix,
|
||||
goFile[:strings.LastIndexByte(goFile, '/')],
|
||||
fqName := fmt.Sprintf("%s.%s",
|
||||
goFile[strings.Index(goFile, "gopheros"):strings.LastIndexByte(goFile, '/')],
|
||||
fnDecl.Name,
|
||||
)
|
||||
|
||||
@ -185,8 +171,8 @@ func elfResolveRedirectSymbols(redirects []*redirect, imgFile string) error {
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if matches, _ := filepath.Glob("kernel/"); len(matches) != 1 {
|
||||
exit(errors.New("this tool must be run from the kernel root folder"))
|
||||
if matches, _ := filepath.Glob(pathToKernel); len(matches) != 1 {
|
||||
exit(errors.New("this tool must be run from the gopher-os root folder"))
|
||||
}
|
||||
|
||||
if len(flag.Args()) == 0 {
|
||||
@ -206,7 +192,7 @@ func main() {
|
||||
exit(fmt.Errorf("unknown command %q", cmd))
|
||||
}
|
||||
|
||||
goFiles, err := collectGoFiles("kernel/")
|
||||
goFiles, err := collectGoFiles(pathToKernel)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user