-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9044b0
Showing
61 changed files
with
61,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
build/ | ||
target/ | ||
**/*.rs.bk | ||
Cargo.lock | ||
.DS_Store | ||
**/.DS_Store | ||
virtual.log | ||
bc_flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"files.associations": { | ||
"*.inc": "cpp", | ||
"*.def": "cpp", | ||
"array": "cpp", | ||
"string_view": "cpp", | ||
"initializer_list": "cpp", | ||
"optional": "cpp", | ||
"type_traits": "cpp", | ||
"utility": "cpp", | ||
"bitset": "cpp", | ||
"list": "cpp" | ||
}, | ||
"C_Cpp.errorSquiggles": "Disabled" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"taskName": "make run", | ||
"type": "shell", | ||
"command": "make run", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"taskName": "make run-debug", | ||
"type": "shell", | ||
"command": "make run-debug", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"taskName": "make clean", | ||
"type": "shell", | ||
"command": "make clean", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"taskName": "make all", | ||
"type": "shell", | ||
"command": "make all", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"taskName": "x86_64-linux env", | ||
"type": "shell", | ||
"command": "sh x86_64-linux_env.sh", | ||
}, | ||
{ | ||
"taskName": "gdb", | ||
"type": "shell", | ||
"command": "rust-gdb build/kernel/kernel.bin.sym -ex 'target remote :1234'", | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017, SnowWhiteOS | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
arch ?= x86_64 | ||
target ?= $(arch)-snowflake | ||
boot2snow := build/arch/$(arch)/boot2snow/bootx64.efi | ||
kernel := build/kernel/kernel.bin | ||
img := build/snowflake-$(arch).img | ||
|
||
CARGO = cargo | ||
NASM = nasm | ||
|
||
LD = $(arch)-elf-ld | ||
AS = $(arch)-elf-as | ||
OBJCOPY = $(arch)-elf-objcopy | ||
STRIP = $(arch)-elf-strip | ||
|
||
.PHONY: all clean run run-debug img | ||
all: $(img) | ||
|
||
clean: | ||
@rm -r build #target | ||
|
||
run: $(img) | ||
@qemu-system-x86_64 -bios ovmf.fd $(img) | ||
|
||
run-debug: $(img) | ||
@qemu-system-x86_64 -s -S -bios ovmf.fd $(img) | ||
|
||
img: $(img) | ||
|
||
$(img): | ||
@make -C arch/$(arch)/boot2snow | ||
@make -C kernel | ||
@dd if=/dev/zero of=$(img).tmp bs=512 count=98304 | ||
@mkfs.vfat $(img).tmp | ||
@mmd -i $(img).tmp ::/boot2snow | ||
@mmd -i $(img).tmp ::/efi | ||
@mmd -i $(img).tmp ::/efi/boot | ||
@mcopy -i $(img).tmp $(kernel) ::/boot2snow | ||
@mcopy -i $(img).tmp res/only_logo.bmp ::/boot2snow | ||
@mcopy -i $(img).tmp res/full_logo.bmp ::/boot2snow | ||
@mcopy -i $(img).tmp res/boot2snow.conf ::/boot2snow | ||
@mcopy -i $(img).tmp $(boot2snow) ::/efi/boot | ||
@dd if=/dev/zero of=$@ bs=512 count=100352 | ||
@parted $@ -s -a minimal mklabel gpt | ||
@parted $@ -s -a minimal mkpart EFI FAT32 2048s 93716s | ||
@parted $@ -s -a minimal toggle 1 boot | ||
@dd if=$@.tmp of=$@ bs=512 count=98304 seek=2048 conv=notrunc | ||
@rm -rf $@.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#  | ||
|
||
[![BSD-3-Clause][s1]][li] | ||
|
||
[s1]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg | ||
|
||
[li]: LICENSE | ||
|
||
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/SnowFlakeOS/rust-uefi) | ||
- x86 (https://github.com/gz/rust-x86) | ||
|
||
## TODO | ||
### Boot2Snow (x86_64, UEFI) | ||
- [x] Basical UI (from https://github.com/system76/firmware-update) | ||
- [x] Load kernel from disk | ||
### SnowKernel (ExoKernel) | ||
- [ ] Load kernel as higher half (0xffffffff80000000) | ||
- [ ] Better GUI library support | ||
- [ ] Write I/O drivers (keyboard, mouse, etc.) | ||
- [ ] Multitasking support | ||
- [ ] Write syscall | ||
- [ ] Write init process | ||
### FlakeOS (LibOS) | ||
|
||
## 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 | ||
|
||
### Mac | ||
The default linker of the macOS is BSD linker so it can't linked Snowflake. | ||
If you want build SnowFlake on macOS | ||
- Need HomeBrew (https://brew.sh/) | ||
- Need Xcode Command Line Tools (This will install both HomeBrew) | ||
- Need NASM (can install in HomeBrew) | ||
- Need QEMU (if you want run SnowFlake) | ||
``` | ||
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
$ homebrew install nasm qemu crystal | ||
$ git clone https://github.com/SnowFlake/mac-binutils-script.git | ||
$ cd mac-binutils-script | ||
$ sudo ./compile.sh | ||
$ git clone https://github.com/SnowFlake/SnowFlake.git | ||
$ cd SnowWhite | ||
$ make run | ||
``` | ||
|
||
### Linux | ||
To build SnowFlake as an x86_64 target, x86_64-elf cross-compilation is required. | ||
If you do not have the x86_64-elf compiler, and your system is x86_64, you can use the 'x86_64-linux_env.sh' script. | ||
``` | ||
$ sh x86_64-linux_env.sh | ||
``` | ||
#### Arch Linux | ||
``` | ||
$ pacman -S qemu nasm mtools | ||
$ git clone https://github.com/SnowFlake/SnowFlake.git | ||
$ cd SnowWhite | ||
$ make run | ||
``` | ||
|
||
## Thanks to | ||
- https://github.com/phil-opp/blog_os | ||
- https://github.com/beevik/MonkOS | ||
- https://github.com/thepowersgang/rust_os | ||
- https://github.com/wichtounet/thor-os | ||
- https://github.com/anchovieshat/cathode | ||
- https://github.com/TheKernelCorp/NuummiteOS | ||
- https://github.com/redox-os/orbclient | ||
- https://github.com/redox-os/uefi | ||
- https://github.com/system76/firmware-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "Boot2Snow" | ||
version = "0.1.0" | ||
authors = ["xuserwhat <[email protected]>"] | ||
|
||
[dependencies] | ||
uefi = {path = "../../../share/libuefi"} | ||
rlibc = "1.0" | ||
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" } | ||
utf16_literal = "0.1.0" | ||
|
||
[lib] | ||
name = "Boot2Snow" | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
arch ?= x86_64 | ||
target_arch ?= $(arch)-boot2snow | ||
|
||
LD = $(arch)-efi-pe-ld | ||
AS = $(arch)-efi-pe-as | ||
AR = $(arch)-efi-pe-ar | ||
STRIP = $(arch)-efi-pe-strip | ||
OBJDUMP = $(arch)-efi-pe-objdump | ||
|
||
CARGO = xargo | ||
CARGOFLAGS = --target $(target_arch) --release -- -C soft-float | ||
|
||
BUILD_DIR = ../../../build/arch/x86_64/boot2snow | ||
|
||
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) | ||
@mkdir -p $(shell dirname $@) | ||
@$(LD) --gc-sections --oformat pei-x86-64 --subsystem 10 -pie -e _start $< -o $@ | ||
@$(OBJDUMP) -d $@ > $@.dsm | ||
@$(STRIP) $@ | ||
|
||
$(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=$@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[dependencies.alloc] |
Oops, something went wrong.