Skip to content

Commit

Permalink
Change to ELF64 and add memory management (kernel heap)
Browse files Browse the repository at this point in the history
Moved the Boot2Snow folder to the SnowFlake parent folder.
Replaced the ELF32 load with an ELF64 load.
Kernel heap has been added, and Alloc is also supported.
  • Loading branch information
ANEP-ET committed May 15, 2018
1 parent 50931ce commit c3fe017
Show file tree
Hide file tree
Showing 39 changed files with 1,156 additions and 325 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ build/
target/
**/*.rs.bk
Cargo.lock
**/Cargo.lock
.DS_Store
**/.DS_Store
virtual.log
bc_flags
bc_flags
prefix/
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
arch ?= x86_64
target ?= $(arch)-snowflake
boot2snow := build/arch/$(arch)/boot2snow/bootx64.efi
boot2snow := build/boot2snow/bootx64.efi
kernel := build/kernel/kernel.bin
img := build/snowflake-$(arch).img

Expand All @@ -19,15 +19,15 @@ clean:
@rm -r build #target

run: $(img)
@qemu-system-x86_64 -bios ovmf.fd -m 2048 $(img)
@qemu-system-x86_64 -m 1024 -serial mon:stdio -net none -vga std -bios ovmf.fd $(img)

run-debug: $(img)
@qemu-system-x86_64 -s -S -bios ovmf.fd $(img)
@qemu-system-x86_64 -s -S -m 1024 -serial mon:stdio -net none -vga std -bios ovmf.fd $(img)

img: $(img)

$(img):
@make -C arch/$(arch)/boot2snow
@make -C boot2snow
@make -C kernel
@dd if=/dev/zero of=$(img).tmp bs=512 count=98304
@mkfs.vfat $(img).tmp
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ![SnowFlake](./logo.png)

[![BSD-3-Clause][s1]][li]
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.jparrowsec.cn%2FSnowFlakeOS%2FSnowFlake.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.jparrowsec.cn%2FSnowFlakeOS%2FSnowFlake?ref=badge_shield)

[s1]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg

Expand All @@ -12,17 +11,17 @@ Technology is free, SnowFlakeOS
## Library used
- utf16_literal (https://github.com/thepowersgang/rust_os/tree/master/Bootloaders/libuefi/utf16_literal)
- uefi (forked, https://github.com/thepowersgang/rust_os/tree/master/Bootloaders/libuefi)
- slab_allocator (https://github.com/redox-os/slab_allocator)

## TODO
### Boot2Snow (x86_64, UEFI)
- [x] Add uefi_alloc support
- [x] Load kernel from disk
- [x] Set virtual memory map
- [ ] Basical UI
- [ ] Enable boot timeout
- [ ] Add fs.rs (Filesystem)
### SnowKernel
- [ ] Add alloc support
- [x] Kernel heap
- [ ] IDT
- [ ] Better GUI library support
- [ ] Add modular support
- [ ] Multitasking support
Expand All @@ -37,8 +36,6 @@ Technology is free, SnowFlakeOS
## Building
Requirements to build
- Rust (https://www.rust-lang.org)
- NASM (http://www.nasm.us/)
- GCC Toolchain or GCC (https://gcc.gnu.org/)

### Windows
Will be added later
Expand All @@ -54,7 +51,7 @@ $ sh x86_64-linux_env.sh
```
#### Arch Linux
```
$ pacman -S qemu nasm mtools
$ pacman -S qemu mtools
$ git clone https://github.com/SnowFlake/SnowFlake.git
$ cd SnowWhite
$ make run
Expand All @@ -66,6 +63,3 @@ $ make run
- https://github.com/redox-os/orbclient (MIT License)
- https://github.com/redox-os/uefi (MIT License)
- https://github.com/system76/firmware-update

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.jparrowsec.cn%2FSnowFlakeOS%2FSnowFlake.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.jparrowsec.cn%2FSnowFlakeOS%2FSnowFlake?ref=badge_large)
36 changes: 0 additions & 36 deletions arch/x86_64/boot2snow/Makefile

This file was deleted.

17 changes: 0 additions & 17 deletions arch/x86_64/boot2snow/x86_64-boot2snow.json

This file was deleted.

43 changes: 0 additions & 43 deletions arch/x86_64/linker.ld

This file was deleted.

6 changes: 4 additions & 2 deletions arch/x86_64/boot2snow/Cargo.toml → boot2snow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ git = "https://github.com/rust-lang-nursery/compiler-builtins"
features = ["mem"]

[dependencies]
uefi = {git = "https://github.com/SnowFlakeOS/uefi"}
uefi_alloc = {git = "https://github.com/SnowFlakeOS/uefi_alloc"}
uefi = {git = "https://github.com/SnowFlakeOS/uefi", rev = "ad7346f"}
uefi_alloc = {git = "https://github.com/SnowFlakeOS/uefi_alloc", rev = "9e75de6"}
rlibc = "1.0"
utf16_literal = "0.1.0"
bitflags = "1"
x86_64 = "0.1.2"

[lib]
name = "Boot2Snow"
Expand Down
63 changes: 63 additions & 0 deletions boot2snow/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
arch ?= x86_64
target_arch ?= $(arch)-boot2snow

BUILD_DIR = ../build/boot2snow
PREFIX = $(shell readlink -f ..//prefix)

LD = $(PREFIX)/bin/$(arch)-efi-pe-ld

CARGO = xargo
CARGOFLAGS = --target $(target_arch) --release -- -C soft-float

BINUTILS = 2.30

boot2snow = $(BUILD_DIR)/bootx64.efi
boot2snow_obj = $(BUILD_DIR)/target/$(target_arch)/release/libBoot2Snow.a

objs = $(boot2snow_obj).o

.PHONY: all

all: $(boot2snow)

$(boot2snow): $(objs) $(LD)
@mkdir -p $(shell dirname $@)
@$(LD) \
--oformat pei-x86-64 \
--dll \
--image-base 0 \
--section-alignment 32 \
--file-alignment 32 \
--major-os-version 0 \
--minor-os-version 0 \
--major-image-version 0 \
--minor-image-version 0 \
--major-subsystem-version 0 \
--minor-subsystem-version 0 \
--subsystem 10 \
--heap 0,0 \
--stack 0,0 \
--pic-executable \
--entry _start \
--no-insert-timestamp \
$< -o $@

$(boot2snow_obj).o: $(boot2snow_obj)
@cd $(shell dirname $<) && $(AR) x libBoot2Snow.a
@ld -r $(shell dirname $<)/*.o -o $@

$(boot2snow_obj):
@mkdir -p $(shell dirname $@)
@RUST_TARGET_PATH=$(abspath .) CARGO_TARGET_DIR=$(BUILD_DIR)/target $(CARGO) rustc --lib $(CARGOFLAGS) -C lto --emit link=$@

$(PREFIX)/binutils-$(BINUTILS).tar.gz:
@mkdir -p $(shell dirname $@)
@curl -o $@ https://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS).tar.gz

$(LD): $(PREFIX)/binutils-$(BINUTILS).tar.gz
@tar -zxvf $< -C $(PREFIX)
@mkdir -p $(PREFIX)/build
@cd $(PREFIX)/build && \
../binutils-$(BINUTILS)/configure --target="$(arch)-efi-pe" --disable-werror --prefix="$(PREFIX)" && \
make all-ld -j `nproc` && \
make install-ld -j `nproc`
File renamed without changes.
1 change: 1 addition & 0 deletions boot2snow/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2018-03-31
Loading

0 comments on commit c3fe017

Please sign in to comment.