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
|
sudo: required
|
||||||
go:
|
go:
|
||||||
- 1.8
|
- 1.8
|
||||||
before_install:
|
|
||||||
- go get -t -v ./...
|
|
||||||
script:
|
script:
|
||||||
- make lint
|
- make lint
|
||||||
- bash coverage.sh
|
- make collect-coverage
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
37
Makefile
37
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
|
# If your go is called something else set it on the commandline, like
|
||||||
# this: make run GO=go1.8
|
# this: make run GO=go1.8
|
||||||
GO ?= go
|
GO ?= go
|
||||||
|
GOPATH := $(GOPATH):$(shell pwd)
|
||||||
|
|
||||||
ifeq ($(OS), Linux)
|
ifeq ($(OS), Linux)
|
||||||
export SHELL := /bin/bash -o pipefail
|
export SHELL := /bin/bash -o pipefail
|
||||||
@ -22,13 +23,14 @@ GOROOT := $(shell $(GO) env GOROOT)
|
|||||||
|
|
||||||
GC_FLAGS ?=
|
GC_FLAGS ?=
|
||||||
LD_FLAGS := -n -T $(BUILD_DIR)/linker.ld -static --no-ld-generated-unwind-info
|
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
|
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")
|
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_src_files := $(wildcard src/arch/$(ARCH)/asm/*.s)
|
||||||
asm_obj_files := $(patsubst arch/$(ARCH)/asm/%.s, $(BUILD_DIR)/arch/$(ARCH)/asm/%.o, $(asm_src_files))
|
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
|
.PHONY: kernel iso clean binutils_version_check
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ kernel: binutils_version_check kernel_image
|
|||||||
|
|
||||||
kernel_image: $(kernel_target)
|
kernel_image: $(kernel_target)
|
||||||
@echo "[tools:redirects] populating kernel image redirect table"
|
@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
|
$(kernel_target): asm_files linker_script go.o
|
||||||
@echo "[$(LD)] linking kernel-$(ARCH).bin"
|
@echo "[$(LD)] linking kernel-$(ARCH).bin"
|
||||||
@ -46,7 +48,7 @@ go.o:
|
|||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
@echo "[go] compiling go sources into a standalone .o file"
|
@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|^|set -e\n|" \
|
||||||
-e "1s|^|export GOOS=$(GOOS)\n|" \
|
-e "1s|^|export GOOS=$(GOOS)\n|" \
|
||||||
-e "1s|^|export GOARCH=$(GOARCH)\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
|
@# 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
|
@# objcopy to make that symbol exportable. Since nasm does not support externs
|
||||||
@# with slashes we create a global symbol alias for kernel.Kmain
|
@# 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 \
|
@objcopy \
|
||||||
--add-symbol kernel.Kmain=.text:0x`nm $(BUILD_DIR)/go.o | grep "kmain.Kmain$$" | cut -d' ' -f1` \
|
--add-symbol kernel.Kmain=.text:0x`nm $(BUILD_DIR)/go.o | grep "kmain.Kmain$$" | cut -d' ' -f1` \
|
||||||
--globalize-symbol _rt0_interrupt_handlers \
|
--globalize-symbol _rt0_interrupt_handlers \
|
||||||
@ -85,17 +88,17 @@ grub-pc-bin_check:
|
|||||||
linker_script:
|
linker_script:
|
||||||
@echo "[sed] extracting LMA and VMA from constants.inc"
|
@echo "[sed] extracting LMA and VMA from constants.inc"
|
||||||
@echo "[gcc] pre-processing arch/$(ARCH)/script/linker.ld.in"
|
@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 \
|
-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:
|
$(BUILD_DIR)/go_asm_offsets.inc:
|
||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
@echo "[tools:offsets] calculating OS/arch-specific offsets for g, m and stack structs"
|
@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 $@
|
@GOPATH=$(GOPATH) $(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
|
$(BUILD_DIR)/arch/$(ARCH)/asm/%.o: src/arch/$(ARCH)/asm/%.s
|
||||||
@mkdir -p $(shell dirname $@)
|
@mkdir -p $(shell dirname $@)
|
||||||
@echo "[$(AS)] $<"
|
@echo "[$(AS)] $<"
|
||||||
@$(AS) $(AS_FLAGS) $< -o $@
|
@$(AS) $(AS_FLAGS) $< -o $@
|
||||||
@ -109,14 +112,14 @@ $(iso_target): iso_prereq kernel_image
|
|||||||
|
|
||||||
@mkdir -p $(BUILD_DIR)/isofiles/boot/grub
|
@mkdir -p $(BUILD_DIR)/isofiles/boot/grub
|
||||||
@cp $(kernel_target) $(BUILD_DIR)/isofiles/boot/kernel.bin
|
@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"
|
@grub-mkrescue -o $(iso_target) $(BUILD_DIR)/isofiles 2>&1 | sed -e "s/^/ | /g"
|
||||||
@rm -r $(BUILD_DIR)/isofiles
|
@rm -r $(BUILD_DIR)/isofiles
|
||||||
|
|
||||||
else
|
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:
|
kernel:
|
||||||
vagrant ssh -c 'cd $(VAGRANT_SRC_FOLDER); make GC_FLAGS="$(GC_FLAGS)" 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:
|
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
|
@gometalinter.v1 --install >/dev/null
|
||||||
|
|
||||||
test:
|
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.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
|
config.vm.provision "shell", inline: <<-SHELL
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y nasm make xorriso
|
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
|
[ ! -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 GOROOT=/usr/local/go" > /etc/profile.d/go.sh
|
||||||
echo "export GOBIN=/usr/local/go/bin" >> /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
|
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile.d/go.sh
|
||||||
SHELL
|
SHELL
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
echo "" > coverage.txt
|
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
|
go test -v -race -coverprofile=profile.out -covermode=atomic $d
|
||||||
if [ -f profile.out ]; then
|
if [ -f profile.out ]; then
|
||||||
cat profile.out >> coverage.txt
|
cat profile.out >> coverage.txt
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package tty
|
package tty
|
||||||
|
|
||||||
import "github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
import "gopheros/kernel/driver/video/console"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultFg = console.LightGrey
|
defaultFg = console.LightGrey
|
@ -1,10 +1,9 @@
|
|||||||
package tty
|
package tty
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/driver/video/console"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestVtPosition(t *testing.T) {
|
func TestVtPosition(t *testing.T) {
|
@ -3,12 +3,11 @@
|
|||||||
package goruntime
|
package goruntime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm/allocator"
|
||||||
|
"gopheros/kernel/mem/vmm"
|
||||||
"unsafe"
|
"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 (
|
var (
|
@ -1,15 +1,14 @@
|
|||||||
package goruntime
|
package goruntime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
|
"gopheros/kernel/mem/pmm/allocator"
|
||||||
|
"gopheros/kernel/mem/vmm"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestSysReserve(t *testing.T) {
|
@ -1,9 +1,9 @@
|
|||||||
package hal
|
package hal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel/driver/tty"
|
"gopheros/kernel/driver/tty"
|
||||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
"gopheros/kernel/driver/video/console"
|
||||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
"gopheros/kernel/hal/multiboot"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,6 +1,6 @@
|
|||||||
package irq
|
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.
|
// Regs contains a snapshot of the register values when an interrupt occurred.
|
||||||
type Regs struct {
|
type Regs struct {
|
@ -2,11 +2,10 @@ package irq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"gopheros/kernel/driver/video/console"
|
||||||
|
"gopheros/kernel/hal"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/driver/video/console"
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRegsPrint(t *testing.T) {
|
func TestRegsPrint(t *testing.T) {
|
@ -1,6 +1,6 @@
|
|||||||
package early
|
package early
|
||||||
|
|
||||||
import "github.com/achilleasa/gopher-os/kernel/hal"
|
import "gopheros/kernel/hal"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errMissingArg = []byte("(MISSING)")
|
errMissingArg = []byte("(MISSING)")
|
@ -2,12 +2,11 @@ package early
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"gopheros/kernel/driver/tty"
|
||||||
|
"gopheros/kernel/driver/video/console"
|
||||||
|
"gopheros/kernel/hal"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestPrintf(t *testing.T) {
|
@ -1,12 +1,12 @@
|
|||||||
package kmain
|
package kmain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel"
|
"gopheros/kernel"
|
||||||
"github.com/achilleasa/gopher-os/kernel/goruntime"
|
"gopheros/kernel/goruntime"
|
||||||
"github.com/achilleasa/gopher-os/kernel/hal"
|
"gopheros/kernel/hal"
|
||||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
"gopheros/kernel/hal/multiboot"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm/allocator"
|
"gopheros/kernel/mem/pmm/allocator"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/vmm"
|
"gopheros/kernel/mem/vmm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,16 +1,15 @@
|
|||||||
package allocator
|
package allocator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/hal/multiboot"
|
||||||
|
"gopheros/kernel/kfmt/early"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
|
"gopheros/kernel/mem/vmm"
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unsafe"
|
"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 (
|
var (
|
@ -1,16 +1,15 @@
|
|||||||
package allocator
|
package allocator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/hal/multiboot"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
|
"gopheros/kernel/mem/vmm"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestSetupPoolBitmaps(t *testing.T) {
|
@ -1,11 +1,11 @@
|
|||||||
package allocator
|
package allocator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel"
|
"gopheros/kernel"
|
||||||
"github.com/achilleasa/gopher-os/kernel/hal/multiboot"
|
"gopheros/kernel/hal/multiboot"
|
||||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
"gopheros/kernel/kfmt/early"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
"gopheros/kernel/mem"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
"gopheros/kernel/mem/pmm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,12 +1,11 @@
|
|||||||
package allocator
|
package allocator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/driver/video/console"
|
||||||
|
"gopheros/kernel/hal"
|
||||||
|
"gopheros/kernel/hal/multiboot"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestBootMemoryAllocator(t *testing.T) {
|
@ -2,9 +2,8 @@
|
|||||||
package pmm
|
package pmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Frame describes a physical memory page index.
|
// Frame describes a physical memory page index.
|
@ -1,9 +1,8 @@
|
|||||||
package pmm
|
package pmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFrameMethods(t *testing.T) {
|
func TestFrameMethods(t *testing.T) {
|
@ -1,8 +1,8 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel"
|
"gopheros/kernel"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
"gopheros/kernel/mem"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,12 +1,11 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/cpu"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"unsafe"
|
"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
|
// ReservedZeroedFrame is a special zero-cleared frame allocated by the
|
@ -1,13 +1,12 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestNextAddrFn(t *testing.T) {
|
@ -1,6 +1,6 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import "github.com/achilleasa/gopher-os/kernel/mem"
|
import "gopheros/kernel/mem"
|
||||||
|
|
||||||
// Page describes a virtual memory page index.
|
// Page describes a virtual memory page index.
|
||||||
type Page uintptr
|
type Page uintptr
|
@ -1,9 +1,8 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPageMethods(t *testing.T) {
|
func TestPageMethods(t *testing.T) {
|
@ -1,12 +1,11 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/cpu"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"unsafe"
|
"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 (
|
var (
|
@ -1,13 +1,12 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel"
|
||||||
|
"gopheros/kernel/mem"
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestPageDirectoryTableInitAmd64(t *testing.T) {
|
@ -1,9 +1,9 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel"
|
"gopheros/kernel"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
"gopheros/kernel/mem"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
"gopheros/kernel/mem/pmm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,9 +1,8 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPageTableEntryFlags(t *testing.T) {
|
func TestPageTableEntryFlags(t *testing.T) {
|
@ -1,6 +1,6 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import "github.com/achilleasa/gopher-os/kernel"
|
import "gopheros/kernel"
|
||||||
|
|
||||||
// Translate returns the physical address that corresponds to the supplied
|
// Translate returns the physical address that corresponds to the supplied
|
||||||
// virtual address or ErrInvalidMapping if the virtual address does not
|
// virtual address or ErrInvalidMapping if the virtual address does not
|
@ -1,11 +1,10 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem/pmm"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTranslateAmd64(t *testing.T) {
|
func TestTranslateAmd64(t *testing.T) {
|
@ -1,12 +1,12 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel"
|
"gopheros/kernel"
|
||||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
"gopheros/kernel/cpu"
|
||||||
"github.com/achilleasa/gopher-os/kernel/irq"
|
"gopheros/kernel/irq"
|
||||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
"gopheros/kernel/kfmt/early"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
"gopheros/kernel/mem"
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem/pmm"
|
"gopheros/kernel/mem/pmm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -3,17 +3,16 @@ package vmm
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"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"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestRecoverablePageFault(t *testing.T) {
|
@ -1,9 +1,8 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,11 +1,10 @@
|
|||||||
package vmm
|
package vmm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gopheros/kernel/mem"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/achilleasa/gopher-os/kernel/mem"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPtePtrFn(t *testing.T) {
|
func TestPtePtrFn(t *testing.T) {
|
@ -1,8 +1,8 @@
|
|||||||
package kernel
|
package kernel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/achilleasa/gopher-os/kernel/cpu"
|
"gopheros/kernel/cpu"
|
||||||
"github.com/achilleasa/gopher-os/kernel/kfmt/early"
|
"gopheros/kernel/kfmt/early"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -3,12 +3,11 @@ package kernel
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"gopheros/kernel/cpu"
|
||||||
|
"gopheros/kernel/driver/video/console"
|
||||||
|
"gopheros/kernel/hal"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"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) {
|
func TestPanic(t *testing.T) {
|
@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/achilleasa/gopher-os/kernel/kmain"
|
import "gopheros/kernel/kmain"
|
||||||
|
|
||||||
var multibootInfoPtr uintptr
|
var multibootInfoPtr uintptr
|
||||||
|
|
@ -15,6 +15,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const pathToKernel = "src/gopheros/"
|
||||||
|
|
||||||
type redirect struct {
|
type redirect struct {
|
||||||
src string
|
src string
|
||||||
dst string
|
dst string
|
||||||
@ -28,16 +30,6 @@ func exit(err error) {
|
|||||||
os.Exit(1)
|
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) {
|
func collectGoFiles(root string) ([]string, error) {
|
||||||
var goFiles []string
|
var goFiles []string
|
||||||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
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) {
|
func findRedirects(goFiles []string) ([]*redirect, error) {
|
||||||
var redirects []*redirect
|
var redirects []*redirect
|
||||||
|
|
||||||
prefix, err := pkgPrefix()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, goFile := range goFiles {
|
for _, goFile := range goFiles {
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
|
|
||||||
@ -88,9 +75,8 @@ func findRedirects(goFiles []string) ([]*redirect, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build qualified name to fn
|
// build qualified name to fn
|
||||||
fqName := fmt.Sprintf("%s/%s.%s",
|
fqName := fmt.Sprintf("%s.%s",
|
||||||
prefix,
|
goFile[strings.Index(goFile, "gopheros"):strings.LastIndexByte(goFile, '/')],
|
||||||
goFile[:strings.LastIndexByte(goFile, '/')],
|
|
||||||
fnDecl.Name,
|
fnDecl.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -185,8 +171,8 @@ func elfResolveRedirectSymbols(redirects []*redirect, imgFile string) error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if matches, _ := filepath.Glob("kernel/"); len(matches) != 1 {
|
if matches, _ := filepath.Glob(pathToKernel); len(matches) != 1 {
|
||||||
exit(errors.New("this tool must be run from the kernel root folder"))
|
exit(errors.New("this tool must be run from the gopher-os root folder"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(flag.Args()) == 0 {
|
if len(flag.Args()) == 0 {
|
||||||
@ -206,7 +192,7 @@ func main() {
|
|||||||
exit(fmt.Errorf("unknown command %q", cmd))
|
exit(fmt.Errorf("unknown command %q", cmd))
|
||||||
}
|
}
|
||||||
|
|
||||||
goFiles, err := collectGoFiles("kernel/")
|
goFiles, err := collectGoFiles(pathToKernel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit(err)
|
exit(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user