Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assembler and disassembler commands #550

Draft
wants to merge 10 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ aml = "0.16.4"
base64 = { version = "0.13.1", default-features = false }
bit_field = "0.10.2"
bootloader = { version = "0.9.23", features = ["map_physical_memory"] }
iced-x86 = { version = "1.20.0", default-features = false, features = ["no_std", "decoder", "encoder", "block_encoder", "code_asm", "nasm"] }
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
libm = "0.2.8"
linked_list_allocator = "0.10.5"
Expand Down
2 changes: 1 addition & 1 deletion run/moros-fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from threading import Lock

BLOCK_SIZE = 512
SUPERBLOCK_ADDR = 4096 * BLOCK_SIZE
SUPERBLOCK_ADDR = 2 * 4096 * BLOCK_SIZE
BITMAP_ADDR = SUPERBLOCK_ADDR + 2 * BLOCK_SIZE
ENTRY_SIZE = (1 + 4 + 4 + 8 + 1)

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod usr;

use bootloader::BootInfo;

const KERNEL_SIZE: usize = 2 << 20; // 2 MB
const KERNEL_SIZE: usize = 4 << 20; // 2 MB

pub fn init(boot_info: &'static BootInfo) {
sys::vga::init();
Expand Down
6 changes: 3 additions & 3 deletions src/sys/acpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub fn shutdown() {
if let Ok(fadt) = acpi.find_table::<acpi::fadt::Fadt>() {
if let Ok(block) = fadt.pm1a_control_block() {
pm1a_control_block = block.address as u32;
//debug!("ACPI Found PM1a Control Block: {:#x}", pm1a_control_block);
//debug!("ACPI Found PM1a Control Block: {:#X}", pm1a_control_block);
}
}
if let Ok(dsdt) = &acpi.dsdt() {
let address = sys::mem::phys_to_virt(PhysAddr::new(dsdt.address as u64));
//debug!("ACPI Found DSDT at {:#x} {:#x}", dsdt.address, address);
//debug!("ACPI Found DSDT at {:#X} {:#X}", dsdt.address, address);
let table = unsafe { core::slice::from_raw_parts(address.as_ptr(), dsdt.length as usize) };
if aml.parse_table(table).is_ok() {
let name = AmlName::from_str("\\_S5").unwrap();
Expand Down Expand Up @@ -69,7 +69,7 @@ pub struct MorosAcpiHandler;
impl AcpiHandler for MorosAcpiHandler {
unsafe fn map_physical_region<T>(&self, physical_address: usize, size: usize) -> PhysicalMapping<Self, T> {
let virtual_address = sys::mem::phys_to_virt(PhysAddr::new(physical_address as u64));
//debug!("ACPI mapping phys {:#x} -> virt {:#x}", physical_address, virtual_address);
//debug!("ACPI mapping phys {:#X} -> virt {:#X}", physical_address, virtual_address);
PhysicalMapping::new(physical_address, NonNull::new(virtual_address.as_mut_ptr()).unwrap(), size, size, Self)
}

Expand Down
2 changes: 1 addition & 1 deletion src/sys/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn init_heap() -> Result<(), MapToError<Size4KiB>> {
}

pub fn alloc_pages(mapper: &mut OffsetPageTable, addr: u64, size: usize) -> Result<(), ()> {
//debug!("Alloc pages (addr={:#x}, size={})", addr, size);
//debug!("Alloc pages (addr={:#X}, size={})", addr, size);
let mut frame_allocator = sys::mem::frame_allocator();
let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE | PageTableFlags::USER_ACCESSIBLE;
let pages = {
Expand Down
4 changes: 2 additions & 2 deletions src/sys/fs/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Block {
let mut buf = [0; super::BLOCK_SIZE];
if let Some(ref mut block_device) = *super::block_device::BLOCK_DEVICE.lock() {
if block_device.read(addr, &mut buf).is_err() {
debug!("MFS: could not read block {:#x}", addr);
debug!("MFS: could not read block {:#X}", addr);
}
}
Self { addr, buf }
Expand All @@ -53,7 +53,7 @@ impl Block {
pub fn write(&self) {
if let Some(ref mut block_device) = *super::block_device::BLOCK_DEVICE.lock() {
if block_device.write(self.addr, &self.buf).is_err() {
debug!("MFS: could not write block {:#x}", self.addr);
debug!("MFS: could not write block {:#X}", self.addr);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extern "x86-interrupt" fn page_fault_handler(_stack_frame: InterruptStackFrame,
if sys::allocator::alloc_pages(&mut mapper, addr, 1).is_err() {
let csi_color = api::console::Style::color("LightRed");
let csi_reset = api::console::Style::reset();
printk!("{}Error:{} Could not allocate address {:#x}\n", csi_color, csi_reset, addr);
printk!("{}Error:{} Could not allocate address {:#X}\n", csi_color, csi_reset, addr);
if error_code.contains(PageFaultErrorCode::USER_MODE) {
api::syscall::exit(ExitCode::PageFaultError);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/sys/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ impl Process {
let proc_size = MAX_PROC_SIZE as u64;
let code_addr = CODE_ADDR.fetch_add(proc_size, Ordering::SeqCst);
let stack_addr = code_addr + proc_size - 4096;
//debug!("code_addr: {:#x}", code_addr);
//debug!("stack_addr: {:#x}", stack_addr);
//debug!("code_addr: {:#X}", code_addr);
//debug!("stack_addr: {:#X}", stack_addr);

let mut entry_point_addr = 0;
let code_ptr = code_addr as *mut u8;
Expand All @@ -356,7 +356,7 @@ impl Process {
let addr = segment.address() as usize;
if let Ok(data) = segment.data() {
for (i, b) in data.iter().enumerate() {
//debug!("code: {:#x}", unsafe { code_ptr.add(addr + i) as usize });
//debug!("code: {:#X}", unsafe { code_ptr.add(addr + i) as usize });
unsafe { core::ptr::write(code_ptr.add(addr + i), *b) };
}
}
Expand Down Expand Up @@ -401,7 +401,7 @@ impl Process {
let mut mapper = unsafe { OffsetPageTable::new(page_table, VirtAddr::new(phys_mem_offset)) };

let heap_addr = self.code_addr + (self.stack_addr - self.code_addr) / 2;
//debug!("user-args: {:#016x}", heap_addr);
//debug!("user-args: {:#016X}", heap_addr);
sys::allocator::alloc_pages(&mut mapper, heap_addr, 1).expect("proc heap alloc");

let args_ptr = ptr_from_addr(args_ptr as u64) as usize;
Expand Down Expand Up @@ -429,7 +429,7 @@ impl Process {

let heap_addr = addr;
let heap_size = (self.stack_addr - heap_addr) / 2;
//debug!("user-heap: {:#016x}..{:#016x}", heap_addr, heap_addr + heap_size);
//debug!("user-heap: {:#016X}..{:#016X}", heap_addr, heap_addr + heap_size);
unsafe { self.allocator.lock().init(heap_addr as *mut u8, heap_size as usize) };

set_id(self.id); // Change PID
Expand Down
4 changes: 2 additions & 2 deletions src/sys/syscall/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn close(handle: usize) {
}

pub fn spawn(path: &str, args_ptr: usize, args_len: usize) -> ExitCode {
//debug!("syscall::spawn(path={}, args_ptr={:#x}, args_len={})", path, args_ptr, args_len);
//debug!("syscall::spawn(path={}, args_ptr={:#X}, args_len={})", path, args_ptr, args_len);
let path = match sys::fs::canonicalize(path) {
Ok(path) => path,
Err(_) => return ExitCode::OpenError,
Expand Down Expand Up @@ -127,7 +127,7 @@ pub fn stop(code: usize) -> usize {
sys::acpi::shutdown();
}
_ => {
debug!("STOP SYSCALL: Invalid code '{:#x}' received", code);
debug!("STOP SYSCALL: Invalid code '{:#X}' received", code);
}
}
0
Expand Down
Loading