Made building and emulation architecture independent

This commit is contained in:
Arthur Beck 2025-02-12 06:56:59 -06:00
parent 04ee0a1cb2
commit f33a187adc
12 changed files with 71 additions and 42 deletions

11
.gitignore vendored
View file

@ -20,15 +20,14 @@ Cargo.lock
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# Generated grub files
kernel/grub/
kernel/aphrodite-grub.iso
kernel/aphrodite.iso
# Generated files # Generated files
kernel/kernel.flat kernel/grub/
kernel/aphrodite-grub-*.iso
kernel/aphrodite-*.iso
kernel/kernel-*
kernel/config.aphro.tmp kernel/config.aphro.tmp
kernel/targets.tmp kernel/targets.tmp
emulation/bochsrc
# Per-developer files # Per-developer files
kernel/config.aphro kernel/config.aphro

View file

@ -3,6 +3,6 @@ port_e9_hack: enabled=1
cpu: reset_on_triple_fault=0, model=corei7_icelake_u cpu: reset_on_triple_fault=0, model=corei7_icelake_u
magic_break: enabled=1 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 boot: cdrom
memory: guest=512, host=512 memory: guest=512, host=512

View 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

View file

@ -22,5 +22,5 @@ DockOrder = 0x123
ListWidthPix[0] = 179 ListWidthPix[0] = 179
ListWidthPix[1] = 245 ListWidthPix[1] = 245
ListWidthPix[2] = 281 ListWidthPix[2] = 281
MainWindow = 0, 0, 709, 500 MainWindow = 819, 38, 709, 500
FontName = Normal FontName = Normal

View file

@ -3,7 +3,6 @@
( (
set -e set -e
export KERNEL_DIR=$(readlink -e .) export KERNEL_DIR=$(readlink -e .)
DIR="${BASH_SOURCE%/*}" DIR="${BASH_SOURCE%/*}"
@ -34,26 +33,37 @@
echo echo
fi fi
cd ../kernel function compile_one {
target=$1
for target in $TARGETS; do
real_target=${!target} 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 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 if [[ "$CONFIG_BUILD_GRUB" = "true" ]]; then
rm -rf grub aphrodite-grub.iso if [[ "$target" = "x86" || "$target" = "mips64" || "$target" = "mipsel" || "$target" = "mipsle" ]]; then
if [[ "$target" = "x86" ]]; then rm -rf grub aphrodite-grub-$target.iso
cp -r ./grub_template ./grub 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 sed -i "s@%{VERSION}@$VERSION@g" ./grub/boot/grub/grub.cfg
grub-mkrescue -o aphrodite-grub.iso grub grub-mkrescue -o aphrodite-grub-$target.iso grub
cp aphrodite-grub.iso aphrodite.iso cp aphrodite-grub-$target.iso aphrodite-$target.iso
fi fi
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 done
reset_version_vars reset_version_vars

View file

@ -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_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_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_PREUSER_OUTPUT_FATAL, values("true", "false", none()))"#);
println!(r#"cargo:rustc-check-cfg=cfg(CONFIG_BUILD_GRUB, values("true", "false", none()))"#);
// End checks // End checks
// Configuration name used when a config is required but should always evaluate to true // Configuration name used when a config is required but should always evaluate to true

View file

@ -5,5 +5,8 @@ set -e
DIR="${BASH_SOURCE%/*}" DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
. $DIR/build . $DIR/build $!
. $DIR/emulate
if [[ $# -ge 1 ]]; then
. $DIR/emulate $!
fi

View file

@ -1,6 +1,20 @@
#!/bin/bash #!/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 set -e
cd ../emulation 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 bochs -q

View file

@ -20,5 +20,6 @@
"host_tools": false, "host_tools": false,
"std": false, "std": false,
"tier": 3 "tier": 3
} },
"rustc-abi": "x86-softfloat"
} }

View file

@ -15,8 +15,7 @@ const MEM_TEST_SIZES: [usize; 8] = [1, 2, 4, 8, 16, 32, 64, 128];
#[kernel_item(IndepBootEntry)] #[kernel_item(IndepBootEntry)]
fn indep_boot_entry( fn indep_boot_entry(
display: Option<&dyn crate::display::TextDisplay>, display: Option<&dyn crate::display::TextDisplay>,
#[allow(non_snake_case)] #[allow(non_snake_case)] BI: &crate::boot::BootInfo,
BI: &crate::boot::BootInfo,
) -> ! { ) -> ! {
crate::arch::output::sdebugsln("Entrypoint called"); crate::arch::output::sdebugsln("Entrypoint called");

View file

@ -78,9 +78,7 @@ fn get_allocator() -> Option<&'static MemoryMapAlloc<'static>> {
} }
#[kernel_item(MemMapAllocInit)] #[kernel_item(MemMapAllocInit)]
fn memory_map_alloc_init( fn memory_map_alloc_init(memmap: crate::boot::MemoryMap) -> Result<(), crate::Error<'static>> {
memmap: crate::boot::MemoryMap,
) -> Result<(), crate::Error<'static>> {
#[allow(static_mut_refs)] #[allow(static_mut_refs)]
unsafe { unsafe {
ALLOCATOR_MEMMAP.write(memmap); ALLOCATOR_MEMMAP.write(memmap);

View file

@ -2,7 +2,7 @@ use proc_macro::TokenStream;
use quote::{ToTokens, quote}; use quote::{ToTokens, quote};
use syn::{ use syn::{
ItemFn, Signature, Token, ItemFn, Signature, Token,
parse::{Parse, ParseStream} parse::{Parse, ParseStream},
}; };
struct KernelItemNameInput { struct KernelItemNameInput {
@ -24,9 +24,7 @@ fn to_tokens(signature: Signature, tokens: &mut proc_macro2::TokenStream) {
signature.abi.to_tokens(ts.into()); signature.abi.to_tokens(ts.into());
signature.fn_token.to_tokens(ts.into()); signature.fn_token.to_tokens(ts.into());
signature.generics.to_tokens(ts.into()); signature.generics.to_tokens(ts.into());
signature signature.paren_token.surround(ts.into(), |tokens| {
.paren_token
.surround(ts.into(), |tokens| {
signature.inputs.to_tokens(tokens); signature.inputs.to_tokens(tokens);
if let Some(variadic) = &signature.variadic { if let Some(variadic) = &signature.variadic {
if !signature.inputs.empty_or_trailing() { 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.output.to_tokens(ts.into());
signature signature.generics.where_clause.to_tokens(ts.into());
.generics
.where_clause
.to_tokens(ts.into());
} }
fn to_token_stream(signature: Signature) -> proc_macro2::TokenStream { fn to_token_stream(signature: Signature) -> proc_macro2::TokenStream {