Made building and emulation architecture independent
This commit is contained in:
parent
04ee0a1cb2
commit
f33a187adc
12 changed files with 71 additions and 42 deletions
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -20,15 +20,14 @@ Cargo.lock
|
|||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# Generated grub files
|
||||
kernel/grub/
|
||||
kernel/aphrodite-grub.iso
|
||||
kernel/aphrodite.iso
|
||||
|
||||
# Generated files
|
||||
kernel/kernel.flat
|
||||
kernel/grub/
|
||||
kernel/aphrodite-grub-*.iso
|
||||
kernel/aphrodite-*.iso
|
||||
kernel/kernel-*
|
||||
kernel/config.aphro.tmp
|
||||
kernel/targets.tmp
|
||||
emulation/bochsrc
|
||||
|
||||
# Per-developer files
|
||||
kernel/config.aphro
|
||||
|
|
|
@ -3,6 +3,6 @@ port_e9_hack: enabled=1
|
|||
cpu: reset_on_triple_fault=0, model=corei7_icelake_u
|
||||
magic_break: enabled=1
|
||||
|
||||
ata0-master: type=cdrom, path=../kernel/aphrodite.iso, status=inserted
|
||||
ata0-master: type=cdrom, path=../kernel/aphrodite-x86.iso, status=inserted
|
||||
boot: cdrom
|
||||
memory: guest=512, host=512
|
8
emulation/bochsrc.template
Normal file
8
emulation/bochsrc.template
Normal file
|
@ -0,0 +1,8 @@
|
|||
display_library: x, options="gui_debug"
|
||||
port_e9_hack: enabled=1
|
||||
cpu: reset_on_triple_fault=0, model=corei7_icelake_u
|
||||
magic_break: enabled=1
|
||||
|
||||
ata0-master: type=cdrom, path=../kernel/%{BUILT_FILE}, status=inserted
|
||||
boot: cdrom
|
||||
memory: guest=512, host=512
|
|
@ -22,5 +22,5 @@ DockOrder = 0x123
|
|||
ListWidthPix[0] = 179
|
||||
ListWidthPix[1] = 245
|
||||
ListWidthPix[2] = 281
|
||||
MainWindow = 0, 0, 709, 500
|
||||
MainWindow = 819, 38, 709, 500
|
||||
FontName = Normal
|
||||
|
|
30
kernel/build
30
kernel/build
|
@ -3,7 +3,6 @@
|
|||
(
|
||||
set -e
|
||||
|
||||
|
||||
export KERNEL_DIR=$(readlink -e .)
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
|
@ -34,26 +33,37 @@
|
|||
echo
|
||||
fi
|
||||
|
||||
cd ../kernel
|
||||
|
||||
for target in $TARGETS; do
|
||||
function compile_one {
|
||||
target=$1
|
||||
real_target=${!target}
|
||||
real_target=$(basename $real_target)
|
||||
echo "Compiling target $target(with rust target of $real_target)"
|
||||
cargo build --target "$real_target" --release -Zbuild-std --bin entrypoint_$target
|
||||
cp target/i686-unknown-none/release/entrypoint_$target kernel.flat
|
||||
cp "target/$(echo $real_target | sed 's/\.json//')/release/entrypoint_$target" kernel-$target
|
||||
|
||||
if [[ "$CONFIG_BUILD_GRUB" = "true" ]]; then
|
||||
rm -rf grub aphrodite-grub.iso
|
||||
if [[ "$target" = "x86" ]]; then
|
||||
if [[ "$target" = "x86" || "$target" = "mips64" || "$target" = "mipsel" || "$target" = "mipsle" ]]; then
|
||||
rm -rf grub aphrodite-grub-$target.iso
|
||||
cp -r ./grub_template ./grub
|
||||
|
||||
cp kernel.flat ./grub/boot/aphrodite.kernel
|
||||
cp kernel-$target ./grub/boot/aphrodite.kernel
|
||||
|
||||
sed -i "s@%{VERSION}@$VERSION@g" ./grub/boot/grub/grub.cfg
|
||||
|
||||
grub-mkrescue -o aphrodite-grub.iso grub
|
||||
cp aphrodite-grub.iso aphrodite.iso
|
||||
grub-mkrescue -o aphrodite-grub-$target.iso grub
|
||||
cp aphrodite-grub-$target.iso aphrodite-$target.iso
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
echo "[INFO] Compiling only target $1"
|
||||
compile_one $1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for target in $TARGETS; do
|
||||
compile_one $target
|
||||
done
|
||||
|
||||
reset_version_vars
|
||||
|
|
|
@ -17,6 +17,8 @@ fn main() {
|
|||
println!(r#"cargo:rustc-check-cfg=cfg(CONFIG_PREUSER_OUTPUT_WARN, values("true", "false", none()))"#);
|
||||
println!(r#"cargo:rustc-check-cfg=cfg(CONFIG_PREUSER_OUTPUT_ERROR, values("true", "false", none()))"#);
|
||||
println!(r#"cargo:rustc-check-cfg=cfg(CONFIG_PREUSER_OUTPUT_FATAL, values("true", "false", none()))"#);
|
||||
|
||||
println!(r#"cargo:rustc-check-cfg=cfg(CONFIG_BUILD_GRUB, values("true", "false", none()))"#);
|
||||
// End checks
|
||||
|
||||
// Configuration name used when a config is required but should always evaluate to true
|
||||
|
|
|
@ -5,5 +5,8 @@ set -e
|
|||
DIR="${BASH_SOURCE%/*}"
|
||||
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
||||
|
||||
. $DIR/build
|
||||
. $DIR/emulate
|
||||
. $DIR/build $!
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
. $DIR/emulate $!
|
||||
fi
|
|
@ -1,6 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Error: expected target to be passed to $0"
|
||||
echo ""
|
||||
echo "Run in the format: $0 target"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
cd ../emulation
|
||||
|
||||
# -f makes it so it won't error out if the file doesn't exist
|
||||
rm -f bochsrc
|
||||
cp bochsrc.template bochsrc
|
||||
|
||||
sed -i "s@%{BUILT_FILE}@aphrodite-$1.iso@g" bochsrc
|
||||
|
||||
bochs -q
|
|
@ -20,5 +20,6 @@
|
|||
"host_tools": false,
|
||||
"std": false,
|
||||
"tier": 3
|
||||
}
|
||||
},
|
||||
"rustc-abi": "x86-softfloat"
|
||||
}
|
|
@ -15,8 +15,7 @@ const MEM_TEST_SIZES: [usize; 8] = [1, 2, 4, 8, 16, 32, 64, 128];
|
|||
#[kernel_item(IndepBootEntry)]
|
||||
fn indep_boot_entry(
|
||||
display: Option<&dyn crate::display::TextDisplay>,
|
||||
#[allow(non_snake_case)]
|
||||
BI: &crate::boot::BootInfo,
|
||||
#[allow(non_snake_case)] BI: &crate::boot::BootInfo,
|
||||
) -> ! {
|
||||
crate::arch::output::sdebugsln("Entrypoint called");
|
||||
|
||||
|
|
|
@ -78,9 +78,7 @@ fn get_allocator() -> Option<&'static MemoryMapAlloc<'static>> {
|
|||
}
|
||||
|
||||
#[kernel_item(MemMapAllocInit)]
|
||||
fn memory_map_alloc_init(
|
||||
memmap: crate::boot::MemoryMap,
|
||||
) -> Result<(), crate::Error<'static>> {
|
||||
fn memory_map_alloc_init(memmap: crate::boot::MemoryMap) -> Result<(), crate::Error<'static>> {
|
||||
#[allow(static_mut_refs)]
|
||||
unsafe {
|
||||
ALLOCATOR_MEMMAP.write(memmap);
|
||||
|
|
|
@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
|||
use quote::{ToTokens, quote};
|
||||
use syn::{
|
||||
ItemFn, Signature, Token,
|
||||
parse::{Parse, ParseStream}
|
||||
parse::{Parse, ParseStream},
|
||||
};
|
||||
|
||||
struct KernelItemNameInput {
|
||||
|
@ -24,9 +24,7 @@ fn to_tokens(signature: Signature, tokens: &mut proc_macro2::TokenStream) {
|
|||
signature.abi.to_tokens(ts.into());
|
||||
signature.fn_token.to_tokens(ts.into());
|
||||
signature.generics.to_tokens(ts.into());
|
||||
signature
|
||||
.paren_token
|
||||
.surround(ts.into(), |tokens| {
|
||||
signature.paren_token.surround(ts.into(), |tokens| {
|
||||
signature.inputs.to_tokens(tokens);
|
||||
if let Some(variadic) = &signature.variadic {
|
||||
if !signature.inputs.empty_or_trailing() {
|
||||
|
@ -36,10 +34,7 @@ fn to_tokens(signature: Signature, tokens: &mut proc_macro2::TokenStream) {
|
|||
}
|
||||
});
|
||||
signature.output.to_tokens(ts.into());
|
||||
signature
|
||||
.generics
|
||||
.where_clause
|
||||
.to_tokens(ts.into());
|
||||
signature.generics.where_clause.to_tokens(ts.into());
|
||||
}
|
||||
|
||||
fn to_token_stream(signature: Signature) -> proc_macro2::TokenStream {
|
||||
|
@ -58,7 +53,7 @@ pub fn kernel_item(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let fn_name = input_fn.clone().sig.ident;
|
||||
let fn_sig = to_token_stream(input_fn.clone().sig);
|
||||
|
||||
quote!{
|
||||
quote! {
|
||||
/// The #item_name kernel item.
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const #item_name: #fn_sig = #fn_name;
|
||||
|
|
Loading…
Add table
Reference in a new issue