mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 04:26:39 +00:00
Fix workspace clippy usage
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
7eac2772d0
commit
f415585dff
25
.github/workflows/framework_test.yml
vendored
25
.github/workflows/framework_test.yml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: Framework Test
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
unit-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 10
|
|
||||||
container: asterinas/asterinas:0.4.0
|
|
||||||
steps:
|
|
||||||
- run: echo "Running in asterinas/asterinas:0.4.0"
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- run: make install_osdk
|
|
||||||
|
|
||||||
- run: make update_initramfs
|
|
||||||
|
|
||||||
- name: Unit test
|
|
||||||
id: test
|
|
||||||
run: cd framework/aster-frame && cargo osdk test
|
|
2
.github/workflows/kernel_test.yml
vendored
2
.github/workflows/kernel_test.yml
vendored
@ -9,7 +9,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 15
|
||||||
container: asterinas/asterinas:0.4.0
|
container: asterinas/asterinas:0.4.0
|
||||||
steps:
|
steps:
|
||||||
- run: echo "Running in asterinas/asterinas:0.4.0"
|
- run: echo "Running in asterinas/asterinas:0.4.0"
|
||||||
|
@ -8,6 +8,7 @@ members = [
|
|||||||
"framework/libs/linux-bzimage/boot-params",
|
"framework/libs/linux-bzimage/boot-params",
|
||||||
"framework/libs/linux-bzimage/setup",
|
"framework/libs/linux-bzimage/setup",
|
||||||
"framework/libs/ktest",
|
"framework/libs/ktest",
|
||||||
|
"framework/libs/ktest-proc-macro",
|
||||||
"framework/libs/tdx-guest",
|
"framework/libs/tdx-guest",
|
||||||
"kernel",
|
"kernel",
|
||||||
"kernel/aster-nix",
|
"kernel/aster-nix",
|
||||||
@ -29,10 +30,10 @@ members = [
|
|||||||
"kernel/libs/typeflags-util",
|
"kernel/libs/typeflags-util",
|
||||||
]
|
]
|
||||||
exclude = [
|
exclude = [
|
||||||
"osdk",
|
|
||||||
"target/osdk/base",
|
|
||||||
"kernel/libs/comp-sys/cargo-component",
|
"kernel/libs/comp-sys/cargo-component",
|
||||||
"kernel/libs/comp-sys/component",
|
"kernel/libs/comp-sys/component",
|
||||||
"kernel/libs/comp-sys/component-macro",
|
"kernel/libs/comp-sys/component-macro",
|
||||||
"kernel/libs/comp-sys/controlled",
|
"kernel/libs/comp-sys/controlled",
|
||||||
|
"osdk",
|
||||||
|
"target/osdk/base",
|
||||||
]
|
]
|
||||||
|
50
Makefile
50
Makefile
@ -63,14 +63,16 @@ endif
|
|||||||
# Pass make variables to all subdirectory makes
|
# Pass make variables to all subdirectory makes
|
||||||
export
|
export
|
||||||
|
|
||||||
# Maintain a list of usermode crates that can be tested with `cargo test`
|
# Basically, non-OSDK crates do not depend on Aster Frame and can be checked
|
||||||
USERMODE_TESTABLE := \
|
# or tested without OSDK.
|
||||||
|
NON_OSDK_CRATES := \
|
||||||
framework/libs/align_ext \
|
framework/libs/align_ext \
|
||||||
framework/libs/aster-main \
|
framework/libs/aster-main \
|
||||||
framework/libs/linux-bzimage/builder \
|
framework/libs/linux-bzimage/builder \
|
||||||
framework/libs/linux-bzimage/boot-params \
|
framework/libs/linux-bzimage/boot-params \
|
||||||
framework/libs/ktest \
|
framework/libs/ktest \
|
||||||
framework/libs/ktest-proc-macro \
|
framework/libs/ktest-proc-macro \
|
||||||
|
framework/libs/tdx-guest \
|
||||||
kernel/libs/cpio-decoder \
|
kernel/libs/cpio-decoder \
|
||||||
kernel/libs/int-to-c-enum \
|
kernel/libs/int-to-c-enum \
|
||||||
kernel/libs/int-to-c-enum/derive \
|
kernel/libs/int-to-c-enum/derive \
|
||||||
@ -80,17 +82,21 @@ USERMODE_TESTABLE := \
|
|||||||
kernel/libs/typeflags \
|
kernel/libs/typeflags \
|
||||||
kernel/libs/typeflags-util
|
kernel/libs/typeflags-util
|
||||||
|
|
||||||
# Maintain a list of kernel crates that can be tested with `cargo osdk test`
|
# In contrast, OSDK crates depend on Aster Frame (or being aster-frame itself)
|
||||||
# The framework is tested independently, thus not included here
|
# and need to be built or tested with OSDK.
|
||||||
KTEST_TESTABLE := \
|
OSDK_CRATES := \
|
||||||
"kernel/aster-nix" \
|
framework/aster-frame \
|
||||||
"kernel/comps/block" \
|
framework/libs/linux-bzimage/setup \
|
||||||
"kernel/comps/console" \
|
kernel \
|
||||||
"kernel/comps/framebuffer" \
|
kernel/aster-nix \
|
||||||
"kernel/comps/input" \
|
kernel/comps/block \
|
||||||
"kernel/comps/network" \
|
kernel/comps/console \
|
||||||
"kernel/comps/time" \
|
kernel/comps/framebuffer \
|
||||||
"kernel/comps/virtio"
|
kernel/comps/input \
|
||||||
|
kernel/comps/network \
|
||||||
|
kernel/comps/time \
|
||||||
|
kernel/comps/virtio \
|
||||||
|
kernel/libs/aster-util
|
||||||
|
|
||||||
.PHONY: all install_osdk build tools run test docs check clean update_initramfs
|
.PHONY: all install_osdk build tools run test docs check clean update_initramfs
|
||||||
|
|
||||||
@ -110,12 +116,14 @@ run: build
|
|||||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
|
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@for dir in $(USERMODE_TESTABLE); do \
|
@for dir in $(NON_OSDK_CRATES); do \
|
||||||
(cd $$dir && cargo test) || exit 1; \
|
(cd $$dir && cargo test) || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
ktest:
|
ktest:
|
||||||
@for dir in $(KTEST_TESTABLE); do \
|
@# Exclude linux-bzimage-setup from ktest since it's hard to be unit tested
|
||||||
|
@for dir in $(OSDK_CRATES); do \
|
||||||
|
[ $$dir = "framework/libs/linux-bzimage/setup" ] && continue; \
|
||||||
(cd $$dir && cargo osdk test) || exit 1; \
|
(cd $$dir && cargo osdk test) || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -129,7 +137,17 @@ format:
|
|||||||
|
|
||||||
check:
|
check:
|
||||||
@./tools/format_all.sh --check # Check Rust format issues
|
@./tools/format_all.sh --check # Check Rust format issues
|
||||||
@cargo osdk clippy
|
@# Check if STD_CRATES and NOSTD_CRATES combined is the same as all workspace members
|
||||||
|
@sed -n '/^\[workspace\]/,/^\[.*\]/{/members = \[/,/\]/p}' Cargo.toml | grep -v "members = \[" | tr -d '", \]' | sort > /tmp/all_crates
|
||||||
|
@echo $(NON_OSDK_CRATES) $(OSDK_CRATES) | tr ' ' '\n' | sort > /tmp/combined_crates
|
||||||
|
@diff -B /tmp/all_crates /tmp/combined_crates || (echo "Error: STD_CRATES and NOSTD_CRATES combined is not the same as all workspace members" && exit 1)
|
||||||
|
@rm /tmp/all_crates /tmp/combined_crates
|
||||||
|
@for dir in $(NON_OSDK_CRATES); do \
|
||||||
|
(cd $$dir && cargo clippy -- -D warnings) || exit 1; \
|
||||||
|
done
|
||||||
|
@for dir in $(OSDK_CRATES); do \
|
||||||
|
(cd $$dir && cargo osdk clippy) || exit 1; \
|
||||||
|
done
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@cargo clean
|
@cargo clean
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
[](https://github.com/asterinas/asterinas/actions/workflows/license_check.yml)
|
[](https://github.com/asterinas/asterinas/actions/workflows/license_check.yml)
|
||||||
[](https://github.com/asterinas/asterinas/actions/workflows/framework_test.yml)
|
|
||||||
[](https://github.com/asterinas/asterinas/actions/workflows/kernel_test.yml)
|
[](https://github.com/asterinas/asterinas/actions/workflows/kernel_test.yml)
|
||||||
|
|
||||||
English | [中文版](README_CN.md)
|
English | [中文版](README_CN.md)
|
||||||
|
@ -105,7 +105,7 @@ pub fn legacy32_rust_target_json() -> &'static str {
|
|||||||
/// Interestingly, the resulting binary should be the same as the memory
|
/// Interestingly, the resulting binary should be the same as the memory
|
||||||
/// dump of the kernel setup header when it's loaded by the bootloader.
|
/// dump of the kernel setup header when it's loaded by the bootloader.
|
||||||
fn to_flat_binary(elf_file: &[u8]) -> Vec<u8> {
|
fn to_flat_binary(elf_file: &[u8]) -> Vec<u8> {
|
||||||
let elf = xmas_elf::ElfFile::new(&elf_file).unwrap();
|
let elf = xmas_elf::ElfFile::new(elf_file).unwrap();
|
||||||
let mut bin = Vec::<u8>::new();
|
let mut bin = Vec::<u8>::new();
|
||||||
|
|
||||||
for program in elf.program_iter() {
|
for program in elf.program_iter() {
|
||||||
|
@ -166,6 +166,8 @@ bitflags::bitflags! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The `flags` field choices in the PE section header.
|
// The `flags` field choices in the PE section header.
|
||||||
|
// We follow the Linux naming, thus ignoring the clippy name warnings.
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
#[derive(Serialize, Clone, Copy)]
|
#[derive(Serialize, Clone, Copy)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
enum PeSectionHdrFlagsAlign {
|
enum PeSectionHdrFlagsAlign {
|
||||||
@ -238,10 +240,10 @@ impl ImageSectionAddrInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
text: SetupVA::from(text_start.unwrap())..SetupVA::from(text_end.unwrap()),
|
text: text_start.unwrap()..text_end.unwrap(),
|
||||||
data: SetupVA::from(data_start.unwrap())..SetupVA::from(data_end.unwrap()),
|
data: data_start.unwrap()..data_end.unwrap(),
|
||||||
bss: SetupVA::from(bss_start.unwrap())..SetupVA::from(bss_end.unwrap()),
|
bss: bss_start.unwrap()..bss_end.unwrap(),
|
||||||
rodata: SetupVA::from(rodata_start.unwrap())..SetupVA::from(rodata_end.unwrap()),
|
rodata: rodata_start.unwrap()..rodata_end.unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,9 +353,9 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
let addr_info = ImageSectionAddrInfo::from(&elf);
|
let addr_info = ImageSectionAddrInfo::from(&elf);
|
||||||
|
|
||||||
// PE section headers
|
// PE section headers
|
||||||
let mut sec_hdrs = Vec::<PeSectionHdr>::new();
|
let sec_hdrs = [
|
||||||
// .reloc
|
// .reloc
|
||||||
sec_hdrs.push(PeSectionHdr {
|
PeSectionHdr {
|
||||||
name: [b'.', b'r', b'e', b'l', b'o', b'c', 0, 0],
|
name: [b'.', b'r', b'e', b'l', b'o', b'c', 0, 0],
|
||||||
virtual_size: relocs.len() as u32,
|
virtual_size: relocs.len() as u32,
|
||||||
virtual_address: usize::from(SetupVA::from(reloc_offset)) as u32,
|
virtual_address: usize::from(SetupVA::from(reloc_offset)) as u32,
|
||||||
@ -368,9 +370,9 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
| PeSectionHdrFlags::MEM_DISCARDABLE)
|
| PeSectionHdrFlags::MEM_DISCARDABLE)
|
||||||
.bits
|
.bits
|
||||||
| PeSectionHdrFlagsAlign::_1Bytes as u32,
|
| PeSectionHdrFlagsAlign::_1Bytes as u32,
|
||||||
});
|
},
|
||||||
// .text
|
// .text
|
||||||
sec_hdrs.push(PeSectionHdr {
|
PeSectionHdr {
|
||||||
name: [b'.', b't', b'e', b'x', b't', 0, 0, 0],
|
name: [b'.', b't', b'e', b'x', b't', 0, 0, 0],
|
||||||
virtual_size: addr_info.text_virt_size() as u32,
|
virtual_size: addr_info.text_virt_size() as u32,
|
||||||
virtual_address: usize::from(addr_info.text.start) as u32,
|
virtual_address: usize::from(addr_info.text.start) as u32,
|
||||||
@ -385,9 +387,9 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
| PeSectionHdrFlags::MEM_EXECUTE)
|
| PeSectionHdrFlags::MEM_EXECUTE)
|
||||||
.bits
|
.bits
|
||||||
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
||||||
});
|
},
|
||||||
// .data
|
// .data
|
||||||
sec_hdrs.push(PeSectionHdr {
|
PeSectionHdr {
|
||||||
name: [b'.', b'd', b'a', b't', b'a', 0, 0, 0],
|
name: [b'.', b'd', b'a', b't', b'a', 0, 0, 0],
|
||||||
virtual_size: addr_info.data_virt_size() as u32,
|
virtual_size: addr_info.data_virt_size() as u32,
|
||||||
virtual_address: usize::from(addr_info.data.start) as u32,
|
virtual_address: usize::from(addr_info.data.start) as u32,
|
||||||
@ -402,9 +404,9 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
| PeSectionHdrFlags::MEM_WRITE)
|
| PeSectionHdrFlags::MEM_WRITE)
|
||||||
.bits
|
.bits
|
||||||
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
||||||
});
|
},
|
||||||
// .bss
|
// .bss
|
||||||
sec_hdrs.push(PeSectionHdr {
|
PeSectionHdr {
|
||||||
name: [b'.', b'b', b's', b's', 0, 0, 0, 0],
|
name: [b'.', b'b', b's', b's', 0, 0, 0, 0],
|
||||||
virtual_size: addr_info.bss_virt_size() as u32,
|
virtual_size: addr_info.bss_virt_size() as u32,
|
||||||
virtual_address: usize::from(addr_info.bss.start) as u32,
|
virtual_address: usize::from(addr_info.bss.start) as u32,
|
||||||
@ -419,9 +421,9 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
| PeSectionHdrFlags::MEM_WRITE)
|
| PeSectionHdrFlags::MEM_WRITE)
|
||||||
.bits
|
.bits
|
||||||
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
||||||
});
|
},
|
||||||
// .rodata
|
// .rodata
|
||||||
sec_hdrs.push(PeSectionHdr {
|
PeSectionHdr {
|
||||||
name: [b'.', b'r', b'o', b'd', b'a', b't', b'a', 0],
|
name: [b'.', b'r', b'o', b'd', b'a', b't', b'a', 0],
|
||||||
virtual_size: addr_info.rodata_virt_size() as u32,
|
virtual_size: addr_info.rodata_virt_size() as u32,
|
||||||
virtual_address: usize::from(addr_info.rodata.start) as u32,
|
virtual_address: usize::from(addr_info.rodata.start) as u32,
|
||||||
@ -433,8 +435,8 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
|
|||||||
num_lin_numbers: 0,
|
num_lin_numbers: 0,
|
||||||
flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA | PeSectionHdrFlags::MEM_READ).bits
|
flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA | PeSectionHdrFlags::MEM_READ).bits
|
||||||
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
| PeSectionHdrFlagsAlign::_16Bytes as u32,
|
||||||
});
|
},
|
||||||
|
];
|
||||||
// Write the MS-DOS header
|
// Write the MS-DOS header
|
||||||
bin.extend_from_slice(&MZ_MAGIC.to_le_bytes());
|
bin.extend_from_slice(&MZ_MAGIC.to_le_bytes());
|
||||||
// Write the MS-DOS stub at 0x3c
|
// Write the MS-DOS stub at 0x3c
|
||||||
|
@ -19,7 +19,7 @@ pub fn load_elf(file: &[u8]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_segment(file: &xmas_elf::ElfFile, program: &xmas_elf::program::ProgramHeader64) {
|
fn load_segment(file: &xmas_elf::ElfFile, program: &xmas_elf::program::ProgramHeader64) {
|
||||||
let SegmentData::Undefined(header_data) = program.get_data(&file).unwrap() else {
|
let SegmentData::Undefined(header_data) = program.get_data(file).unwrap() else {
|
||||||
panic!("[setup] Unexpected segment data type!");
|
panic!("[setup] Unexpected segment data type!");
|
||||||
};
|
};
|
||||||
// Safety: the physical address from the ELF file is valid
|
// Safety: the physical address from the ELF file is valid
|
||||||
|
@ -40,5 +40,5 @@ fn get_payload(boot_params: &BootParams) -> &'static [u8] {
|
|||||||
let payload_length = hdr.payload_length as usize;
|
let payload_length = hdr.payload_length as usize;
|
||||||
// Safety: the payload_offset and payload_length is valid if we assume that the
|
// Safety: the payload_offset and payload_length is valid if we assume that the
|
||||||
// boot_params struct is correct.
|
// boot_params struct is correct.
|
||||||
unsafe { core::slice::from_raw_parts_mut(payload_offset as *mut u8, payload_length as usize) }
|
unsafe { core::slice::from_raw_parts_mut(payload_offset as *mut u8, payload_length) }
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ use super::{
|
|||||||
relocation::apply_rela_dyn_relocations,
|
relocation::apply_rela_dyn_relocations,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Suppress warnings since using todo!.
|
||||||
|
#[allow(unreachable_code)]
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[allow(clippy::diverging_sub_expression)]
|
||||||
#[export_name = "efi_stub_entry"]
|
#[export_name = "efi_stub_entry"]
|
||||||
extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<Boot>) -> ! {
|
extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<Boot>) -> ! {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -19,13 +23,9 @@ extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<
|
|||||||
}
|
}
|
||||||
uefi_services::init(&mut system_table).unwrap();
|
uefi_services::init(&mut system_table).unwrap();
|
||||||
|
|
||||||
// Suppress TODO warning.
|
let boot_params_ptr = todo!("Use EFI boot services to fill boot params");
|
||||||
#[allow(unreachable_code)]
|
|
||||||
efi_phase_boot(
|
efi_phase_boot(handle, system_table, boot_params_ptr);
|
||||||
handle,
|
|
||||||
system_table,
|
|
||||||
todo!("Use EFI boot services to fill boot params"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[export_name = "efi_handover_entry"]
|
#[export_name = "efi_handover_entry"]
|
||||||
@ -65,7 +65,7 @@ fn efi_phase_boot(
|
|||||||
let Ok(loaded_image) = boot_services.open_protocol_exclusive::<LoadedImage>(handle) else {
|
let Ok(loaded_image) = boot_services.open_protocol_exclusive::<LoadedImage>(handle) else {
|
||||||
panic!("Failed to open LoadedImage protocol");
|
panic!("Failed to open LoadedImage protocol");
|
||||||
};
|
};
|
||||||
loaded_image.data_type().clone()
|
loaded_image.data_type()
|
||||||
};
|
};
|
||||||
let (system_table, memory_map) = system_table.exit_boot_services(memory_type);
|
let (system_table, memory_map) = system_table.exit_boot_services(memory_type);
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ fn efi_phase_runtime(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
e820_table[e820_entries] = linux_boot_params::BootE820Entry {
|
e820_table[e820_entries] = linux_boot_params::BootE820Entry {
|
||||||
addr: md.phys_start as u64,
|
addr: md.phys_start,
|
||||||
size: md.page_count as u64 * 4096,
|
size: md.page_count * 4096,
|
||||||
typ: match md.ty {
|
typ: match md.ty {
|
||||||
uefi::table::boot::MemoryType::CONVENTIONAL => linux_boot_params::E820Type::Ram,
|
uefi::table::boot::MemoryType::CONVENTIONAL => linux_boot_params::E820Type::Ram,
|
||||||
uefi::table::boot::MemoryType::RESERVED => linux_boot_params::E820Type::Reserved,
|
uefi::table::boot::MemoryType::RESERVED => linux_boot_params::E820Type::Reserved,
|
||||||
|
@ -13,8 +13,8 @@ global_asm!(include_str!("setup.S"));
|
|||||||
pub const ASTER_ENTRY_POINT: u32 = 0x8001200;
|
pub const ASTER_ENTRY_POINT: u32 = 0x8001200;
|
||||||
|
|
||||||
unsafe fn call_aster_entrypoint(entrypoint: u64, boot_params_ptr: u64) -> ! {
|
unsafe fn call_aster_entrypoint(entrypoint: u64, boot_params_ptr: u64) -> ! {
|
||||||
asm!("mov rsi, {}", in(reg) boot_params_ptr as u64);
|
asm!("mov rsi, {}", in(reg) boot_params_ptr);
|
||||||
asm!("mov rax, {}", in(reg) entrypoint as u64);
|
asm!("mov rax, {}", in(reg) entrypoint);
|
||||||
asm!("jmp rax");
|
asm!("jmp rax");
|
||||||
|
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
@ -30,7 +30,7 @@ fn get_rela_array() -> &'static [Elf64Rela] {
|
|||||||
end = in(reg) end,
|
end = in(reg) end,
|
||||||
start = in(reg) start,
|
start = in(reg) start,
|
||||||
);
|
);
|
||||||
len / core::mem::size_of::<Elf64Rela>() as usize
|
len / core::mem::size_of::<Elf64Rela>()
|
||||||
};
|
};
|
||||||
#[cfg(feature = "debug_print")]
|
#[cfg(feature = "debug_print")]
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -44,7 +44,7 @@ fn get_rela_array() -> &'static [Elf64Rela] {
|
|||||||
print_str("\n");
|
print_str("\n");
|
||||||
}
|
}
|
||||||
// Safety: the linker will ensure that the symbols are valid.
|
// Safety: the linker will ensure that the symbols are valid.
|
||||||
unsafe { core::slice::from_raw_parts(start as *const Elf64Rela, len) }
|
unsafe { core::slice::from_raw_parts(start, len) }
|
||||||
}
|
}
|
||||||
|
|
||||||
const R_X86_64_RELATIVE: u32 = 8;
|
const R_X86_64_RELATIVE: u32 = 8;
|
||||||
|
@ -16,6 +16,7 @@ const START_OF_SETUP32_VA: usize = 0x100000;
|
|||||||
/// The setup is a position-independent executable. We can get the loaded base
|
/// The setup is a position-independent executable. We can get the loaded base
|
||||||
/// address from the symbol.
|
/// address from the symbol.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(clippy::fn_to_numeric_cast)]
|
||||||
pub fn get_image_loaded_offset() -> isize {
|
pub fn get_image_loaded_offset() -> isize {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn start_of_setup32();
|
fn start_of_setup32();
|
||||||
|
@ -9,5 +9,5 @@ edition = "2021"
|
|||||||
x86_64 = "0.14.10"
|
x86_64 = "0.14.10"
|
||||||
bitflags = "1.3"
|
bitflags = "1.3"
|
||||||
raw-cpuid = "10"
|
raw-cpuid = "10"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Copyright(c) 2023-2024 Intel Corporation.
|
// Copyright(c) 2023-2024 Intel Corporation.
|
||||||
|
|
||||||
#![no_std]
|
#![cfg_attr(not(test), no_std)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::{vec, vec::Vec};
|
||||||
use core::{
|
use core::{
|
||||||
fmt,
|
fmt,
|
||||||
ops::{Index, IndexMut},
|
ops::{Index, IndexMut},
|
||||||
@ -26,13 +26,16 @@ fn framebuffer_init() -> Result<(), ComponentInitError> {
|
|||||||
|
|
||||||
pub(crate) static WRITER: Once<SpinLock<Writer>> = Once::new();
|
pub(crate) static WRITER: Once<SpinLock<Writer>> = Once::new();
|
||||||
|
|
||||||
|
// ignore the warnings since we use the `todo!` macro.
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[allow(unreachable_code)]
|
||||||
|
#[allow(clippy::diverging_sub_expression)]
|
||||||
pub(crate) fn init() {
|
pub(crate) fn init() {
|
||||||
let mut writer = {
|
let mut writer = {
|
||||||
let framebuffer = boot::framebuffer_arg();
|
let framebuffer = boot::framebuffer_arg();
|
||||||
let mut writer = None;
|
|
||||||
let mut size = 0;
|
let mut size = 0;
|
||||||
for i in aster_frame::vm::FRAMEBUFFER_REGIONS.get().unwrap().iter() {
|
for i in aster_frame::vm::FRAMEBUFFER_REGIONS.get().unwrap().iter() {
|
||||||
size = i.len() as usize;
|
size = i.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
let page_size = size / PAGE_SIZE;
|
let page_size = size / PAGE_SIZE;
|
||||||
@ -40,13 +43,10 @@ pub(crate) fn init() {
|
|||||||
let start_paddr = framebuffer.address;
|
let start_paddr = framebuffer.address;
|
||||||
let io_mem = todo!("IoMem is private for components now, should fix it.");
|
let io_mem = todo!("IoMem is private for components now, should fix it.");
|
||||||
|
|
||||||
let mut buffer: Vec<u8> = Vec::with_capacity(size);
|
let mut buffer: Vec<u8> = vec![0; size];
|
||||||
for _ in 0..size {
|
|
||||||
buffer.push(0);
|
|
||||||
}
|
|
||||||
log::debug!("Found framebuffer:{:?}", framebuffer);
|
log::debug!("Found framebuffer:{:?}", framebuffer);
|
||||||
|
|
||||||
writer = Some(Writer {
|
Writer {
|
||||||
io_mem,
|
io_mem,
|
||||||
x_pos: 0,
|
x_pos: 0,
|
||||||
y_pos: 0,
|
y_pos: 0,
|
||||||
@ -54,9 +54,7 @@ pub(crate) fn init() {
|
|||||||
width: framebuffer.width as usize,
|
width: framebuffer.width as usize,
|
||||||
height: framebuffer.height as usize,
|
height: framebuffer.height as usize,
|
||||||
buffer: buffer.leak(),
|
buffer: buffer.leak(),
|
||||||
});
|
}
|
||||||
|
|
||||||
writer.unwrap()
|
|
||||||
};
|
};
|
||||||
writer.clear();
|
writer.clear();
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
//! It will depend on the kernel crate.
|
//! It will depend on the kernel crate.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::{fs, path::{Path, PathBuf}, str::FromStr};
|
use std::{
|
||||||
|
fs,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::util::get_cargo_metadata;
|
use crate::util::get_cargo_metadata;
|
||||||
|
|
||||||
|
@ -117,7 +117,11 @@ pub fn do_build(
|
|||||||
bundle
|
bundle
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_kernel_elf(args: &CargoArgs, cargo_target_directory: impl AsRef<Path>, rustflags: &[&str]) -> AsterBin {
|
fn build_kernel_elf(
|
||||||
|
args: &CargoArgs,
|
||||||
|
cargo_target_directory: impl AsRef<Path>,
|
||||||
|
rustflags: &[&str],
|
||||||
|
) -> AsterBin {
|
||||||
let target = "x86_64-unknown-none";
|
let target = "x86_64-unknown-none";
|
||||||
|
|
||||||
let env_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
|
let env_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
|
||||||
|
@ -10,7 +10,7 @@ pub fn execute_check_command() {
|
|||||||
command
|
command
|
||||||
.arg("check")
|
.arg("check")
|
||||||
.arg("--target")
|
.arg("--target")
|
||||||
.arg("x86_64-unkown-none");
|
.arg("x86_64-unknown-none");
|
||||||
command.args(COMMON_CARGO_ARGS);
|
command.args(COMMON_CARGO_ARGS);
|
||||||
let status = command.status().unwrap();
|
let status = command.status().unwrap();
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
|
Reference in New Issue
Block a user