Skip to content

Commit

Permalink
Merge branch 'development' into ps2-enhancement
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	README.md
#	kernel/Cargo.toml
#	kernel/src/lib.rs
#	kernel/src/memory/mod.rs
  • Loading branch information
Gegy committed Oct 21, 2018
2 parents a546c6f + 2540a9b commit 3e6ddf8
Show file tree
Hide file tree
Showing 26 changed files with 1,179 additions and 399 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us fix problems and bugs

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Platform**
Whichever platform was used to test the bug. E.g QEMU, Virtualbox, real Lenovo laptop.

**Additional context**
Add any other context about the problem here.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/Enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Enhancement
about: Suggest an enhancement or improvement to an already existing feature

---

**Description of enhancement**
Description of the enhancement. Include which feature is being enhanced, too.

**Why?**
How does this enhancement benefit the project? What is its usecase?
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project

---

**What feature would you like?**
What feature would you like to be implemented? Any other details go here too.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Why?**
What does this feature provide? What usecase does it fulfill?
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ kernel/Cargo.lock
build/
kernel/target/

/target/
**/*.rs.bk
*.bxrc
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ endif
ifeq ($(debug), 1)
nasm_flags := -f elf64 -F dwarf -g
build_type := debug
qemu_flags := -s -S
qemu_flags := -s -m 256M
cargo_flags := --features $(log_level)
else
nasm_flags := -f elf64
cargo_flags := --release --features $(log_level)
build_type := release
qemu_flags := -m 256M
endif

ifeq ($(wait_for_gdb), 1)
qemu_flags := -s -S
endif

linker_script := cfg/linker.ld
Expand Down Expand Up @@ -51,7 +56,7 @@ iso: $(grub_iso)

# Run with qemu
run: $(grub_iso)
@qemu-system-x86_64 -cdrom $(grub_iso) $(qemu_flags)
@qemu-system-x86_64 -cdrom $(grub_iso) $(qemu_flags) -m 128M

# Clean build dir
clean:
Expand All @@ -69,6 +74,7 @@ makedirs:
$(rust_kernel): $(rust_crate_dir)/**/*
@cd $(rust_crate_dir) && \
RUST_TARGET_PATH=$(shell pwd)/$(rust_crate_dir) cargo xbuild --target $(target) $(cargo_flags)
@rm -f $(rust_kernel)
@mv $(rust_crate_dir)/target/$(target)/$(build_type)/libflower_kernel.a $(rust_kernel)

# Compile kernel.elf
Expand Down
52 changes: 41 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FlowerOS
# FlowerOS [![Gitter](https://badges.gitter.im/flower-os/Lobby.png)](https://gitter.im/flower-os/Lobby)

*A small learning OS*

Expand All @@ -25,7 +25,30 @@ You can also get builds from [Flower's CI/CD](https://ci.gegy1000.net/job/Flower

## Contributing

If you wish to PR something to Flower, thanks so much! Just note to please **pull request into development, not master**.
If you wish to PR something to Flower, thanks so much! Just note to please **pull request into development, not master**
if you are making a change to the codebase.

Generally, the workflow for submitting a pull request goes like this:

1. Open an issue that your PR aims to solve and request to be assigned. This is just so we don't have multiple people working on
the same thing on different branches/forks.
2. Fork flower
3. Create a new branch from `development` (if you're editing code and not e.g the README) which briefly describes the thing you
are doing, e.g `acpi`.
4. Commit your things
5. Open a pull request. Select base as `development` (again, if you're editing code).
6. Wait for review. Sorry if the reviews are a bit nitpicky -- @gegy1000 and I (@Restioson) usually write reviews like that. It
does help to keep code quality good though.
7. Debate review comments/implement requested changes.
8. Repeat until everyone is happy with the changes.
9. Your PR should be merged Soon™!

## Code Style

Generally, we try to follow [the rust style guidline](https://github.com/rust-lang-nursery/fmt-rfcs/blob/master/guide/guide.md).
To keep the code consistent, we ask if all contributors could also adhere to these guidelines. Unfortunately, we haven't run
Clippy or Rustfmt on flower [just yet](https://github.com/Restioson/flower/issues/13), but this is slated to be done just before
0.2.0. Thus, please refrain from formatting things unrelated to the PR you are working on. This is to avoid merge conflicts.

## Thanks

Expand All @@ -35,14 +58,21 @@ Much thanks to:
- [Phil Opp](https://phil-opp.com) and his [blog OS](https://os.phil-opp.com);
- [Redox](https://github.com/redox-os);
- the people over on the [Rust discord](https://discord.me/rust-lang), such as:
- toor,
- rep nop,
- evrey,
- nyrox,
- cult pony;
- and the people over on the [Rust gitter](https://gitter.im/rust-lang/rust), such as:
- tanriol,
- and vorner;
- [Toor](https://github.com/too-r),
- [Rep nop](https://github.com/repnop),
- [Evrey](https://github.com/Evrey),
- Cult Pony,
- [Oberien](https://github.com/oberien)
- and [Nyrox](https://github.com/Nyrox),
- the people on the [OSDev discord](https://discordapp.com/invite/aJPTY8Y) such as:
- Omarrx024,
- [Mintsuki](https://github.com/mintsuki),
- [Korona](https://github.com/avdgrinten),
- and [Safsom](https://github.com/asfsom);
- the people part of the [rust-osdev](https://github.com/rust-osdev), such as
- [Isaac Woods](https://github.com/IsaacWoods);
- the [OsDev wiki](http://wiki.osdev.org);
- [Bare Metal Rust](http://www.randomhacks.net/bare-metal-rust/);
- [Wikipedia](https://wikipedia.org) (of course!)
- and [Wikipedia](https://wikipedia.org) (of course!);

This is not, of course, an exhaustive list!
56 changes: 56 additions & 0 deletions bochsrc.bxrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1
config_interface: win32config
display_library: win32
memory: host=32, guest=32
romimage: file="C:\Program Files (x86)\Bochs-2.6.9/BIOS-bochs-latest", address=0x0, options=none
vgaromimage: file="C:\Program Files (x86)\Bochs-2.6.9/VGABIOS-lgpl-latest"
boot: cdrom
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="C:\Users\caelm_000\IdeaProjects\flower\build\release\bochs_flower.img", status=inserted, model="Generic 1234", biosdetect=auto
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
optromimage1: file=none
optromimage2: file=none
optromimage3: file=none
optromimage4: file=none
optramimage1: file=none
optramimage2: file=none
optramimage3: file=none
optramimage4: file=none
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5, realtime=1
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0
cpuid: smep=0, smap=0, mwait=1, vmx=1
print_timestamps: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
sound: waveoutdrv=win, waveout=none, waveindrv=win, wavein=none, midioutdrv=win, midiout=none
speaker: enabled=1, mode=sound
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0
12 changes: 7 additions & 5 deletions cfg/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ SECTIONS {
*(.bss .bss.*)
}

.guard_page :
{
/* Make sure the guard page is before the stack and is not gc'd */
KEEP(*(.guard_page))
}
/* TODO where put guard page */

.stack :
{
*(.stack)
}

.guard_page :
{
/* Make sure the guard page is before the stack and is not gc'd */
KEEP(*(.guard_page))
}
}
32 changes: 22 additions & 10 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "flower_kernel"
version = "0.1.0"
authors = ["Restioson <[email protected]>", "Gegy1000 <[email protected]"]
authors = ["Restioson <[email protected]>", "Gegy1000 <[email protected]>"]

[lib]
crate-type = ["staticlib"]
Expand All @@ -11,22 +11,34 @@ panic = "abort"

[profile.dev]
panic = "abort"
opt-level = 3

[dependencies]
rlibc = "1.0.0"
volatile = "0.2.3"
spin = "0.4.6"
x86_64 = "0.1.2"
bitflags = "1.0.1"
multiboot2 = { git = "https://github.com/rust-osdev/multiboot2-elf64" }
bit_field = "0.9.0"
rlibc = "^1.0.0"
volatile = "^0.2.3"
spin = "^0.4.6"
x86_64 = "^0.1.2"
bitflags = "^1.0.1"
bit_field = "^0.9.0"
log = "^0.4.3"
static_assertions = "^0.2.5"

[dependencies.multiboot2]
git = "https://github.com/rust-osdev/multiboot2-elf64"

[dependencies.acpi]
git = "https://github.com/rust-osdev/acpi"

[dependencies.arrayvec]
version = "^0.4.7"
default-features = false

[dependencies.array-init]
version = "0.0.3"
version = "^0.0.3"
features = ["nightly"]

[dependencies.lazy_static]
version = "1.0.0"
version = "^1.0.0"
features = ["spin_no_std"]

[features]
Expand Down
52 changes: 52 additions & 0 deletions kernel/src/acpi_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use acpi::{self, AcpiHandler, Acpi, AcpiError};
use core::ptr::NonNull;
use memory::{self, PhysicalMapping};
use util;

pub fn acpi_init() -> Result<Acpi, AcpiError> {
info!("acpi: initializing");
let mut handler = FlowerAcpiHandler;
// We're BIOS. We'd have crashed by now if we weren't.
let search_result = unsafe { acpi::search_for_rsdp_bios(&mut handler) };
match search_result {
Ok(acpi) => {
info!("acpi: init successful");
Ok(acpi)
}
Err(e) => {
error!("acpi: init unsuccessful {:?}", e);
Err(e)
}
}
}

struct FlowerAcpiHandler;

impl AcpiHandler for FlowerAcpiHandler {
fn map_physical_region<T>(
&mut self,
physical_address: usize,
size: usize,
) -> acpi::PhysicalMapping<T> {
// Map immutable region
let region: PhysicalMapping<T> = unsafe {
memory::map_physical_region(physical_address, size, false)
};

region.into()
}

fn unmap_physical_region<T>(&mut self, region: acpi::PhysicalMapping<T>) {
let obj_addr = region.virtual_start.as_ptr() as *mut T as usize;

// Clear lower page offset bits
let page_begin = obj_addr & !0xFFF;

unsafe {
::HEAP.dealloc_specific(
page_begin as *mut u8,
region.mapped_length / 4096,
);
}
}
}
4 changes: 2 additions & 2 deletions kernel/src/asm/boot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ section .guard_page
align 4096

guard_page_begin:
times 4096 db 0
times 4096 db 0xAA

section .stack
; Stack grows the other way
stack_bottom:
times 1024 * 64 db 0 ; 64 kilobytes
times 1024 * 256 db 0 ; 256 kilobytes
stack_top:

section .rodata
Expand Down
Loading

0 comments on commit 3e6ddf8

Please sign in to comment.