Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from UteroOS/201803
Browse files Browse the repository at this point in the history
v0.6.0
  • Loading branch information
noriyotcp authored Mar 30, 2018
2 parents 0f98d60 + b26f132 commit 273ece3
Show file tree
Hide file tree
Showing 1,398 changed files with 2,190,624 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CC = $(EXT_MUSL)/bin/musl-gcc
LD ?= ld
AR ?= ar
NASM ?= nasm
CRYSTAL := crystal-0.24.2/bin/crystal

OS_NAME = utero
BUILD_DIR = build
Expand Down Expand Up @@ -41,7 +42,7 @@ sources:

$(KERNEL): musl build_dirs $(CRYSTAL_OS) $(OBJECTS) $(LIB)
mkdir -p $(KERNEL_DIR)
$(LD) --nmagic --output=$@ --script=$(LINKER) $(CRYSTAL_OS) $(OBJECTS) $(LIB) $(EXT_MUSL)/lib/libc.a
$(CC) -Xlinker --nmagic -T$(LINKER) $(CRYSTAL_OS) -o $(KERNEL) $(OBJECTS) $(LIB) -L$(EXT_MUSL)/lib

build/asm/%.o: asm/%.asm
$(NASM) -f elf64 $< -o $@
Expand All @@ -50,7 +51,7 @@ build/src/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@

$(CRYSTAL_OS): $(CRYSTAL_SOURCES)
crystal build src/kernel/main.cr --cross-compile --target $(TARGET) --prelude=empty --verbose
$(CRYSTAL) build src/kernel/main.cr --cross-compile -Dgc_none --prelude=empty --target $(TARGET) --verbose
mv -f main.o $@

$(LIB): $(SOURCES)
Expand All @@ -73,12 +74,13 @@ $(ISO): cleansrcs $(KERNEL)
grub-mkrescue -o $@ $(ISO_DIR)

run: $(ISO)
qemu-system-x86_64 -cdrom $<
qemu-system-x86_64 -cdrom $< -monitor stdio -rtc base=localtime
.PHONY: run

debug: CFLAGS += -DENABLE_KERNEL_DEBUG
debug: cleaniso $(ISO)
qemu-system-x86_64 -cdrom $(ISO) -serial file:/tmp/serial.log
qemu-system-x86_64 -cdrom $(ISO) -serial stdio -m 256M
# qemu-system-x86_64 -cdrom $(ISO) -serial file:/tmp/serial.log
.PHONY: debug

clean:
Expand Down
104 changes: 104 additions & 0 deletions crystal-0.24.2/bin/crystal
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/sh

################## https://github.com/mkropat/sh-realpath #####################
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Michael Kropat
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

realpath() {
canonicalize_path "$(resolve_symlinks "$1")"
}

resolve_symlinks() {
_resolve_symlinks "$1"
}

_resolve_symlinks() {
_assert_no_path_cycles "$@" || return

local dir_context path
path=$(readlink -- "$1")
if [ $? -eq 0 ]; then
dir_context=$(dirname -- "$1")
_resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"
else
printf '%s\n' "$1"
fi
}

_prepend_dir_context_if_necessary() {
if [ "$1" = . ]; then
printf '%s\n' "$2"
else
_prepend_path_if_relative "$1" "$2"
fi
}

_prepend_path_if_relative() {
case "$2" in
/* ) printf '%s\n' "$2" ;;
* ) printf '%s\n' "$1/$2" ;;
esac
}

_assert_no_path_cycles() {
local target path

target=$1
shift

for path in "$@"; do
if [ "$path" = "$target" ]; then
return 1
fi
done
}

canonicalize_path() {
if [ -d "$1" ]; then
_canonicalize_dir_path "$1"
else
_canonicalize_file_path "$1"
fi
}

_canonicalize_dir_path() {
(cd "$1" 2>/dev/null && pwd -P)
}

_canonicalize_file_path() {
local dir file
dir=$(dirname -- "$1")
file=$(basename -- "$1")
(cd "$dir" 2>/dev/null >/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
}

##############################################################################

SCRIPT_DIR="$(dirname "$(realpath "$0" || echo "$0")")"
ROOT_DIR="$SCRIPT_DIR/.."

export CRYSTAL_PATH="${CRYSTAL_PATH:-"$ROOT_DIR/share/crystal/src:lib"}"
export PATH="$ROOT_DIR/lib/crystal/bin:$PATH"
export LIBRARY_PATH="$ROOT_DIR/lib/crystal/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"

exec "$ROOT_DIR/lib/crystal/bin/crystal" "${@}"
1 change: 1 addition & 0 deletions crystal-0.24.2/bin/shards
Binary file added crystal-0.24.2/lib/crystal/bin/crystal
Binary file not shown.
Binary file added crystal-0.24.2/lib/crystal/bin/shards
Binary file not shown.
20 changes: 20 additions & 0 deletions crystal-0.24.2/share/crystal/src/adler32/adler32.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "lib_z"

module Adler32
def self.initial : UInt32
LibZ.adler32(0, nil, 0).to_u32
end

def self.checksum(data) : UInt32
update(data, initial)
end

def self.update(data, adler32 : UInt32) : UInt32
slice = data.to_slice
LibZ.adler32(adler32, slice, slice.size).to_u32
end

def self.combine(adler1 : UInt32, adler2 : UInt32, len) : UInt32
LibZ.adler32_combine(adler1, adler2, len).to_u32
end
end
Loading

0 comments on commit 273ece3

Please sign in to comment.