Skip to content

Commit

Permalink
Merge pull request #45 from rellermeyer/newvm
Browse files Browse the repository at this point in the history
Revised Virtual Memory
  • Loading branch information
NULLx76 committed Mar 11, 2020
2 parents d741dfe + 8600bb6 commit 3361b45
Show file tree
Hide file tree
Showing 164 changed files with 2,338 additions and 14,124 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/os_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@ jobs:
path: toolchain
key: toolchain

- name: Cache Qemu
id: cache-qemu
uses: actions/cache@v1
with:
path: qemu/qemu
key: qemu

- name: Install Dependencies
run: |
sudo apt-get update &&
sudo apt-get install build-essential qemu-system-arm python3 wget texinfo zlib1g-dev -y
sudo apt-get install build-essential python3 wget texinfo zlib1g-dev -y
- name: Install Toolchain
#if: steps.cache-toolchain.outputs.cache-hit != 'true'
- name: Build Toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: rm -rf toolchain/arm-none-eabi/ && make toolchain

- name: Build Qemu
if: steps.cache-qemu.outputs.cache-hit != 'true'
run: rm -rf qemu/qemu* && make qemu

- name: Compile
run: make build

Expand Down
52 changes: 33 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
#these were not originally apart of the repo -- appeared after build
/kernel/kernel.bin
/kernel/flash.bin
/kernel/boot-commands
/kernel/card.sd
/kernel/src/test/test.c
/toolchain/target/
/u-boot/u-boot-*
# Build files
kernel/kernel.bin
kernel/flash.bin
kernel/boot-commands
kernel/card.sd
kernel/src/test/test.c

# Toolchain dir, but not the build script
/toolchain/
!/toolchain/build.sh

# Qemu dir, again without its buildscript
/qemu/
!/qemu/build.sh

# Generic build dirs
build/
/cmake-build-*/

# Generated docs
/html/
/latex/
/course_os_docs.pdf

# Editor specific
.settings/
.cproject
.project
/.idea/
!/.idea/runConfigurations
/.vscode/
*~
*.swp
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist

#always exclude these from being pushed
# CCLS files
.ccls-cache/
compile_commands.json

# Binary files
*.o
*.img
*.map
*.elf
*.bin
*~
*.swp
/user/hello/hello
/user/hello/hello1
/user/hello/hello2
/user/libc/libc.a

[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist

# Floobits (CLion collabrative editing plugin)
.floo
.flooignore

uboot-commands.ubt

# Misc
NOTES
/server.PID

5 changes: 5 additions & 0 deletions .idea/runConfigurations/debug.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"gdbpath": "${workspaceFolder}/toolchain/arm-none-eabi/bin/arm-none-eabi-gdb",
"name": "Debug",
"executable": "${workspaceFolder}/kernel/build/kernel.sym",
"target": ":1234",
"remote": true,
"cwd": "${workspaceRoot}",
// "preLaunchTask": "run_debug",
"valuesFormatting": "prettyPrinters"
},
]
}
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make test",
"detail": "Runs the course_os test suite",
"type": "shell",
"command": "make test",
"problemMatcher": "$gcc",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "run_debug",
"detail": "Runs qemu with gdbserver",
"type": "shell",
"command": "make -C kernel debug",
}
]
}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
all: toolchain kernel
all: requirements kernel

toolchain:
cd ./toolchain && ./build.sh
.PHONY: toolchain

qemu:
cd ./qemu && ./build.sh
.PHONY: qemu

requirements: toolchain qemu

libc:
$(MAKE) -C user/libc

Expand Down
1 change: 0 additions & 1 deletion a.s

This file was deleted.

4 changes: 1 addition & 3 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ TOOLCHAIN_DIR=toolchain
BARE_METAL_TUPLE=arm-none-eabi
BARE_METAL_TARGET:=$(BARE_METAL_TUPLE)

QEMU=qemu-system-arm

UBOOT_VERSION=2014.10
QEMU=./qemu/qemu/bin/qemu-system-arm

#CFLAGS = -mcpu=arm1136j-s
CFLAGS = -mcpu=arm1176jz-s
19 changes: 15 additions & 4 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CFLAGS += -pipe -std=gnu99 -ffreestanding -Wall -Werror -g -O0 -mcpu=arm1176jzf-
#PI_CFLAGS = -mfpu=vfp -march=armv6zk -mtune=arm1176jzf-s -nostartfiles

# variables to define in the preprocessor.
MEMORY = 128M
MEMORY = 1G
DEFINITIONS = MEM_DEBUG
test: DEFINITIONS += ENABLE_TESTS # if we execute the test: rule, enable tests before recompiling
KERNEL_PARAMS = root=/dev/ram mem=$(MEMORY)
Expand All @@ -17,6 +17,7 @@ BUILDDIR = build
# every directory named `include` will have it's contents autoincluded
INCLUDEDIR = include
TEST_MAIN_FILE = $(SOURCEDIR)/test/test.c
CPU = cortex-a7

# =================== End Configuration ===================

Expand All @@ -25,8 +26,8 @@ CC:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gcc
AS:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-as
LD:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gcc
OBJCOPY:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-objcopy
MKIMAGE:=$(CURDIR)/../u-boot/u-boot-$(UBOOT_VERSION)/tools/mkimage
GDB:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gdb
QEMU := $(CURDIR)/../${QEMU}

DIRS = $(shell find $(SOURCEDIR)/ -type d -print)
C_SOURCE_FILES := $(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)) $(TEST_MAIN_FILE)
Expand All @@ -48,17 +49,27 @@ build_pi: $(BUILDDIR)/kernelPi.img | builddir

test: build | builddir
#${QEMU} -M versatilepb -cpu arm1176 -sd $(BUILDDIR)/card.sd -m $(MEMORY) -nographic -semihosting -kernel build/flash.bin -append "-load 0x410000 0x14000"
${QEMU} -kernel $(BUILDDIR)/kernel.elf -m $(MEMORY) -serial stdio -monitor none -M raspi2 -cpu arm1176 -nographic -append "-load 0x410000 0x14000" -semihosting
${QEMU} -kernel $(BUILDDIR)/kernel.elf -m $(MEMORY) -serial stdio -monitor none -M raspi2 -cpu $(CPU) -nographic -append "-load 0x410000 0x14000" -semihosting

run: build | builddir
# nographic to turn off the gui
# monitor none to disable stdio monitoring so
# serial stdio works
#${QEMU} -M versatilepb -cpu arm1176 -sd $(BUILDDIR)/card.sd -m $(MEMORY) -nographic -semihosting -monitor none -serial stdio -kernel build/flash.bin -append "-load 0x410000 0x14000"
${QEMU} -kernel $(BUILDDIR)/kernel.elf -m $(MEMORY) -serial stdio -monitor none -M raspi2 -cpu arm1176 -nographic -append "-load 0x410000 0x14000" -semihosting
${QEMU} -kernel $(BUILDDIR)/kernel.elf -m $(MEMORY) -serial stdio -monitor none -M raspi2 -cpu $(CPU) -nographic -append "-load 0x410000 0x14000" -semihosting

debug: build | builddir
${QEMU} -kernel $(BUILDDIR)/kernel.elf -m $(MEMORY) -serial stdio -monitor none -M raspi2 -cpu $(CPU) -nographic -append "-load 0x410000 0x14000" -semihosting -S -s

start_debug: build | builddir
$(GDB) -ex "target remote localhost:1234" -ex "symbol-file $(BUILDDIR)/kernel.sym"

$(BUILDDIR)/kernel.elf: $(OBJECT_FILES) | builddir
$(LD) -T linker/kernel.ld -nostartfiles -Wl,-Map,kernel.map $^ -o $@
$(OBJCOPY) --only-keep-debug $(BUILDDIR)/kernel.elf $(BUILDDIR)/kernel.sym
$(OBJCOPY) --strip-debug $(BUILDDIR)/kernel.elf



# Begin Pi Make
$(BUILDDIR)/kernelPi.elf: $(C_OBJECT_FILES) | builddir
Expand Down
44 changes: 33 additions & 11 deletions kernel/linker/kernel.ld
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
ENTRY(_Reset)

__KERNEL_VIRTUAL_OFFSET = 0x80000000;
__BOOT_ADDRESS = 0x8000;

SECTIONS
{
. = 0x8000;
P_KERNBASE = .;
.startup . : { build/common/startup.o(.text) }
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss COMMON) }
P_KERNTOP = .;
. = ALIGN(8);
. = . + 0x1000;
stack_top = .;
}
. = __BOOT_ADDRESS;
__BOOT_START = .;
.boot : {
*/startup.o (.text)
*/startup.o (.data)
*/stacks.o (.text)
*/startup.o (.bss)
}
__BOOT_END = .;
. += __KERNEL_VIRTUAL_OFFSET;

__KERNEL_BASE = .;
.text : AT(ADDR(.text) - __KERNEL_VIRTUAL_OFFSET) {
*(EXCLUDE_FILE (*/startup.o */stacks.o) .text)
*(.rodata*)
}

.data : AT(ADDR(.data) - __KERNEL_VIRTUAL_OFFSET){
*(EXCLUDE_FILE (*/startup.o) .data)
}

.bss : AT(ADDR(.bss) - __KERNEL_VIRTUAL_OFFSET) {
*(EXCLUDE_FILE (*/startup.o) COMMON)
*(EXCLUDE_FILE (*/startup.o) .bss)
}

/*make kernel top megabyte aligned*/
. = ALIGN(1024 * 1024);
__KERNEL_TOP = .;
}
12 changes: 0 additions & 12 deletions kernel/linker/kernelPi.ld

This file was deleted.

21 changes: 0 additions & 21 deletions kernel/old/drivers/clock.c

This file was deleted.

Loading

0 comments on commit 3361b45

Please sign in to comment.