First bootable kernel

This commit is contained in:
Guillaume DIDIER 2019-10-02 09:52:19 +02:00
parent 7db6d00a42
commit 49d7c3e508
8 changed files with 141 additions and 18 deletions

5
.cargo/config Normal file
View File

@ -0,0 +1,5 @@
[build]
target = "x86_64-D.TinctoriusAzureaus.json"
[target.'cfg(target_os = "none")']
runner = "bootimage runner"

View File

@ -8,8 +8,20 @@
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations> </configurations>
</component> </component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7ddf063a-3554-4ac7-a5a5-6e243077d67d" name="Default Changelist" comment="" /> <list default="true" id="7ddf063a-3554-4ac7-a5a5-6e243077d67d" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.cargo/config" afterDir="false" />
<change afterPath="$PROJECT_DIR$/rust-toolchain" afterDir="false" />
<change afterPath="$PROJECT_DIR$/x86_64-D.TinctoriusAzureaus.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kernel/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/kernel/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/kernel/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/kernel/src/main.rs" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -29,6 +41,13 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="settings.editor.selected.configurable" value="language.rust.rustfmt" /> <property name="settings.editor.selected.configurable" value="language.rust.rustfmt" />
</component> </component>
<component name="RunDashboard"> <component name="RunDashboard">
@ -43,7 +62,33 @@
</list> </list>
</option> </option>
</component> </component>
<component name="RunManager"> <component name="RunManager" selected="Cargo Command.Build kernel">
<configuration name="Build kernel" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="NIGHTLY" />
<option name="command" value="xbuild" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="true" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$/kernel" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Run kernel" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="NIGHTLY" />
<option name="command" value="xrun" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="emulateTerminal" value="true" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$/kernel" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration default="true" type="CargoCommandRunConfiguration" factoryName="Cargo Command"> <configuration default="true" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" /> <option name="channel" value="DEFAULT" />
<option name="command" value="run" /> <option name="command" value="run" />
@ -56,18 +101,15 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" /> <option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="run" type="CargoCommandRunConfiguration" factoryName="Cargo Command"> <list>
<option name="channel" value="DEFAULT" /> <item itemvalue="Cargo Command.Build kernel" />
<option name="command" value="run" /> <item itemvalue="Cargo Command.Run kernel" />
<option name="allFeatures" value="false" /> </list>
<option name="nocapture" value="false" /> <recent_temporary>
<option name="emulateTerminal" value="true" /> <list>
<option name="backtrace" value="SHORT" /> <item itemvalue="Cargo Command.Run kernel" />
<envs /> </list>
<method v="2"> </recent_temporary>
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component> </component>
<component name="RustProjectSettings"> <component name="RustProjectSettings">
<option name="externalLinter" value="Clippy" /> <option name="externalLinter" value="Clippy" />
@ -85,8 +127,16 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1569934487744</updated> <updated>1569934487744</updated>
<workItem from="1569934492535" duration="453000" /> <workItem from="1569934492535" duration="5355000" />
</task> </task>
<task id="LOCAL-00001" summary="Add CLion config files">
<created>1569934966982</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1569934966982</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -103,4 +153,8 @@
</map> </map>
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Add CLion config files" />
<option name="LAST_COMMIT_MESSAGE" value="Add CLion config files" />
</component>
</project> </project>

19
Cargo.lock generated
View File

@ -1,6 +1,25 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "bit_field"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bootloader"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "kernel" name = "kernel"
version = "0.1.0" version = "0.1.0"
dependencies = [
"bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0"
"checksum bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "45dd858bd74a742ec0fe887722952c263abd0825aa8d33a3704917a97d7bd41e"

View File

@ -3,3 +3,4 @@
members = [ members = [
"kernel", "kernel",
] ]

View File

@ -1,9 +1,13 @@
[package] [package]
name = "kernel" name = "kernel"
version = "0.1.0" version = "0.1.0"
authors = ["Guillaume DIDIER <guillaume.didier@polytechnique.edu>"] authors = ["Guillaume DIDIER <guillaume.didier.2014@polytechnique.org>"]
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
[dependencies.bootloader]
version = "^0.8.1"
features = ["sse"]

View File

@ -1,3 +1,28 @@
fn main() { // main.rs
println!("Hello, world!"); // main file of the kernel
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
static HELLO: &[u8] = b"Hello Frog!";
#[no_mangle]
pub extern "C" fn _start() -> ! {
let vga_buffer = 0xb8000 as *mut u8;
for (i, &byte) in HELLO.iter().enumerate() {
unsafe {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
}
}
loop {}
} }

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
nightly-2019-09-28

View File

@ -0,0 +1,14 @@
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true
}