parent
c701cd00ce
commit
db0c174f52
@ -0,0 +1,7 @@
|
||||
[build]
|
||||
target = "riscv64gc-unknown-none-elf"
|
||||
|
||||
[target.riscv64gc-unknown-none-elf]
|
||||
rustflags = [
|
||||
"-Clink-args=-Tsrc/linker.ld",
|
||||
]
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/user.iml" filepath="$PROJECT_DIR$/.idea/user.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BranchesTreeState">
|
||||
<expand>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
|
||||
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</component>
|
||||
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
|
||||
<generated />
|
||||
</component>
|
||||
<component name="CMakeSettings">
|
||||
<configurations>
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="CargoProjects">
|
||||
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9d2c81d6-8bd5-4e25-9cbc-05239b61cb03" name="Default Changelist" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ClangdSettings">
|
||||
<option name="formatViaClangd" value="false" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Rust File" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="MacroExpansionManager">
|
||||
<option name="directoryName" value="pj78n19s" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1kRYab1CFt0tWlh7oWQCFlCsT1u" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="cf.first.check.clang-format" value="false" />
|
||||
<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" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/src/" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="run" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration default="true" type="GradleAppRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.cpp.gradle.execution.GradleNativeBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="RustProjectSettings">
|
||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="9d2c81d6-8bd5-4e25-9cbc-05239b61cb03" name="Default Changelist" comment="" />
|
||||
<created>1605664935096</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1605664935096</updated>
|
||||
<workItem from="1605664936289" duration="5782000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,5 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "user_lib"
|
||||
version = "0.1.0"
|
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "user_lib"
|
||||
version = "0.1.0"
|
||||
authors = ["Yifan Wu <shinbokuow@163.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,11 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
#[no_mangle]
|
||||
fn main() -> i32 {
|
||||
println!("Hello, world!");
|
||||
0
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
use core::fmt::{self, Write};
|
||||
use crate::syscall::{STDOUT, sys_write};
|
||||
|
||||
struct Stdout;
|
||||
|
||||
impl Write for Stdout {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
sys_write(STDOUT, s.as_bytes());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print(args: fmt::Arguments) {
|
||||
Stdout.write_fmt(args).unwrap();
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
($fmt: literal $(, $($arg: tt)+)?) => {
|
||||
$crate::console::print(format_args!($fmt $(, $($arg)+)?));
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
($fmt: literal $(, $($arg: tt)+)?) => {
|
||||
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#[panic_handler]
|
||||
fn panic_handler(panic_info: &core::panic::PanicInfo) -> ! {
|
||||
let err = panic_info.message().unwrap();
|
||||
if let Some(location) = panic_info.location() {
|
||||
println!("Panicked at {}:{}, {}", location.file(), location.line(), err);
|
||||
} else {
|
||||
println!("Panicked: {}", err);
|
||||
}
|
||||
loop {}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#![no_std]
|
||||
#![feature(llvm_asm)]
|
||||
#![feature(linkage)]
|
||||
#![feature(panic_info_message)]
|
||||
|
||||
#[macro_use]
|
||||
pub mod console;
|
||||
mod syscall;
|
||||
mod lang_items;
|
||||
|
||||
#[no_mangle]
|
||||
#[link_section = ".text.entry"]
|
||||
pub extern "C" fn _start() -> ! {
|
||||
main();
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[linkage = "weak"]
|
||||
#[no_mangle]
|
||||
fn main() -> i32 {
|
||||
panic!("Cannot find main!");
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
|
||||
BASE_ADDRESS = 0x80040000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = BASE_ADDRESS;
|
||||
.text : {
|
||||
*(.text.entry)
|
||||
*(.text .text.*)
|
||||
}
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
}
|
||||
.bss : {
|
||||
*(.bss .bss.*)
|
||||
}
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
*(.debug*)
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
pub const STDOUT: usize = 1;
|
||||
|
||||
const SYSCALL_WRITE: usize = 64;
|
||||
|
||||
fn syscall(id: usize, args: [usize; 3]) -> isize {
|
||||
let mut ret: isize;
|
||||
unsafe {
|
||||
llvm_asm!("ecall"
|
||||
: "={x10}" (ret)
|
||||
: "{x10}" (args[0]), "{x11}" (args[1]), "{x12}" (args[2]), "{x17}" (id)
|
||||
: "memory"
|
||||
: "volatile"
|
||||
);
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn sys_write(fd: usize, buffer: &[u8]) -> isize {
|
||||
syscall(SYSCALL_WRITE, [fd, buffer.as_ptr() as usize, buffer.len()])
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
41937feca2aff630
|
@ -0,0 +1 @@
|
||||
{"rustc":457852275655460692,"features":"[]","target":3375593478374818422,"profile":18074012566298724745,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"riscv64gc-unknown-none-elf/debug/.fingerprint/user_lib-ac05933ae451745f/dep-lib-user_lib"}}],"rustflags":["-Clink-args=-Tsrc/linker.ld"],"metadata":4791657899108178287,"config":0}
|
@ -0,0 +1 @@
|
||||
e51f381f878f6eda
|
@ -0,0 +1 @@
|
||||
{"rustc":457852275655460692,"features":"[]","target":10036166384340519867,"profile":18074012566298724745,"path":10402765361534072892,"deps":[[1196176764371957,"user_lib",false,3528200472378708801]],"local":[{"CheckDepInfo":{"dep_info":"riscv64gc-unknown-none-elf/debug/.fingerprint/user_lib-b4124dce0aef8d75/dep-bin-hello_world"}}],"rustflags":["-Clink-args=-Tsrc/linker.ld"],"metadata":4791657899108178287,"config":0}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/deps/hello_world-b4124dce0aef8d75: src/bin/hello_world.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/deps/hello_world-b4124dce0aef8d75.d: src/bin/hello_world.rs
|
||||
|
||||
src/bin/hello_world.rs:
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/deps/user_lib-ac05933ae451745f.rmeta: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/deps/libuser_lib-ac05933ae451745f.rlib: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/deps/user_lib-ac05933ae451745f.d: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
src/lib.rs:
|
||||
src/console.rs:
|
||||
src/syscall.rs:
|
||||
src/lang_items.rs:
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/hello_world: /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/bin/hello_world.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/console.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lang_items.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lib.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/syscall.rs
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/debug/libuser_lib.rlib: /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/console.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lang_items.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lib.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/syscall.rs
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
8ec22604a7e65d6d
|
@ -0,0 +1 @@
|
||||
{"rustc":457852275655460692,"features":"[]","target":3375593478374818422,"profile":4339006351771724982,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"riscv64gc-unknown-none-elf/release/.fingerprint/user_lib-0fdba27c1d499ab2/dep-lib-user_lib"}}],"rustflags":["-Clink-args=-Tsrc/linker.ld"],"metadata":4791657899108178287,"config":0}
|
@ -0,0 +1 @@
|
||||
81ce7e0677cd11c5
|
@ -0,0 +1 @@
|
||||
{"rustc":457852275655460692,"features":"[]","target":10036166384340519867,"profile":4339006351771724982,"path":10402765361534072892,"deps":[[1196176764371957,"user_lib",false,7880708527971811982]],"local":[{"CheckDepInfo":{"dep_info":"riscv64gc-unknown-none-elf/release/.fingerprint/user_lib-65513b09835dd0af/dep-bin-hello_world"}}],"rustflags":["-Clink-args=-Tsrc/linker.ld"],"metadata":4791657899108178287,"config":0}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/deps/hello_world-65513b09835dd0af: src/bin/hello_world.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/deps/hello_world-65513b09835dd0af.d: src/bin/hello_world.rs
|
||||
|
||||
src/bin/hello_world.rs:
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/deps/user_lib-0fdba27c1d499ab2.rmeta: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/deps/libuser_lib-0fdba27c1d499ab2.rlib: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/deps/user_lib-0fdba27c1d499ab2.d: src/lib.rs src/console.rs src/syscall.rs src/lang_items.rs
|
||||
|
||||
src/lib.rs:
|
||||
src/console.rs:
|
||||
src/syscall.rs:
|
||||
src/lang_items.rs:
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
/home/oslab/workspace/v3/rCore-Tutorial-v3/user/target/riscv64gc-unknown-none-elf/release/hello_world: /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/bin/hello_world.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/console.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lang_items.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/lib.rs /home/oslab/workspace/v3/rCore-Tutorial-v3/user/src/syscall.rs
|
Loading…
Reference in new issue