Skip to content

Commit

Permalink
Use actual gcc & rust cross-compilers, vendor libcore, libcollections…
Browse files Browse the repository at this point in the history
…, liballoc, sadface
  • Loading branch information
jonasschneider committed Dec 28, 2015
1 parent 29157fe commit 6391903
Show file tree
Hide file tree
Showing 154 changed files with 56,072 additions and 773 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@
lit
**/*.elf
**/*.iso
target
44 changes: 44 additions & 0 deletions Cargo.lock

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

13 changes: 13 additions & 0 deletions Cargo.toml
@@ -0,0 +1,13 @@
[package]
name = "cor"
version = "0.0.1"
authors = ["Jonas Schneider <mail@jonasschneider.com>"]

[lib]
crate_type = ["staticlib"]

[dependencies]
core = { path = "src/lib/libcore" }
kalloc = { path = "src/lib/libkalloc" }
alloc = { path = "src/lib/liballoc" }
collections = { path = "src/lib/libcollections" }
38 changes: 4 additions & 34 deletions Makefile
Expand Up @@ -2,41 +2,11 @@ ROOT=.
include Makefile.conf
.PHONY: all clean

OBJS=main.o printk.o chrdev_serial.o chrdev_console.o io.o interrupthandler.o tss.o mm.o task.o pci.o timer.o pic.o interrupt.o
OBJS+=context_switch.o trampoline.o idle.o

all:
$(MAKE) -C src/
$(MAKE) cor.iso
$(MAKE) -C arch/x86-multiboot/
$(MAKE) -C userspace/

clean:
rm -f *.o *.bin *~ init *.so cor.elf cor.iso
$(MAKE) -C userspace clean
$(MAKE) -C arch/boot_stage1 clean
$(MAKE) -C src clean

%.o: %.c
$(CC) $(KCCFLAGS) $< -c -o $@

stage2_entrypoint.o: stage2_entrypoint.s
$(CC) $(KCFLAGS) -c stage2_entrypoint.s -o stage2_entrypoint.o

context_switch.o: context_switch.s
$(CC) $(KCFLAGS) -c $< -o $@

trampoline.o: trampoline.s
$(CC) $(KCFLAGS) -c $< -o $@

interrupthandler.o: interrupthandler.s include/cor/syscall.h intstubs.s~
$(CC) $(KCFLAGS) -c -x assembler-with-cpp -Iinclude $< -o $@

cor.iso: cor.elf
cp cor.elf arch/boot_multiboot/iso/boot/cor.elf && grub-mkrescue -o $@ arch/boot_multiboot/iso

cor.elf: $(OBJS) src/lib.o Makefile arch/boot_multiboot/boot.o arch/boot_multiboot/multiboot.ld
echo LONG\(0x$(shell git rev-parse HEAD | cut -c 1-6)\) > versionstamp~
gcc -mcmodel=large -Wl,-n,--build-id=none,--gc-sections -ffreestanding -O2 -nostdlib -lgcc -o $@ $(OBJS) src/lib.o -L./src -lcor arch/boot_multiboot/boot.o -T arch/boot_multiboot/multiboot.ld

intstubs.s~: Makefile
ruby -e '0.upto(255) { |i| puts ".align 16\n.global intrstub_#{i}\nintrstub_#{i}:\n push %rax\n mov $$#{i}, %rax\n jmp isr_dispatcher\n\n" }' > $@
rm -fr target
$(MAKE) -C arch/x86-multiboot/ clean
$(MAKE) -C userspace/ clean
16 changes: 4 additions & 12 deletions Makefile.conf
Expand Up @@ -3,8 +3,10 @@
CFLAGS=-Wall -Wextra -Werror -m64 -std=c11

## Add debugging flags
CFLAGS+=-ggdb
#for release, CFLAGS+=-O3 -flto
## http://mail-index.netbsd.org/port-sparc64/2014/06/15/msg002197.html
## gcc sometimes loses debug stack info, apparently
CFLAGS+=-ggdb -fvar-tracking -fvar-tracking-assignments
#CFLAGS+=-Os -flto

## Disable all the crap we usually include from system libraries.
## Also, tell GCC (again?) that no standard library is availible, not even
Expand All @@ -14,20 +16,10 @@ CFLAGS+=-nostdlib -nostdinc -nostartfiles -nodefaultlibs -ffreestanding
## Add our include directory
CFLAGS+=-I$(ROOT)/include

## http://mail-index.netbsd.org/port-sparc64/2014/06/15/msg002197.html
## gcc sometimes loses debug stack info, apparently
CFLAGS+=-fvar-tracking -fvar-tracking-assignments

CCFLAGS=$(CFLAGS) -include stddef.h

# FIXME: the whole CFLAGS two-dimensional extension space is ugly
# https://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/i386-and-x86_002d64-Options.html
# TODO: look at mcmodel again
KCFLAGS=$(CFLAGS) -mcmodel=large
KCCFLAGS=$(CCFLAGS) -mcmodel=large $(DEBUGFLAGS)

CC=gcc
OBJCOPY=objcopy
LD=ld
AS=as
MAKE=make
9 changes: 4 additions & 5 deletions Vagrantfile
@@ -1,11 +1,10 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
Vagrant.configure("2") do |config|
config.vm.define "arch" do
config.vm.box = "archlinux-x86_64"
end
end

# apt-get update && apt-get -y install gdb ruby qemu git-core
Expand Down
11 changes: 0 additions & 11 deletions arch/boot_multiboot/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions arch/boot_stage1/Makefile

This file was deleted.

Binary file removed arch/boot_stage1/blank_mbr
Binary file not shown.

0 comments on commit 6391903

Please sign in to comment.