Skip to content
Merged
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
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION=0
PATCHLEVEL=0
SUBLEVEL=3
EXTRAVERSION=
EXTRAVERSION=-$(shell git rev-parse HEAD | head -c 7)

export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION

Expand All @@ -15,6 +15,9 @@ RUST_KERNEL=target/$(TARGET)/$(DEBUG_RELEASE)/libelsos.a
LD=$(ARCH)-elf-ld
CC=$(ARCH)-elf-gcc
AR=$(ARCH)-elf-ar
QEMU=qemu-system-i386
QEMU_ARGS=-drive format=raw,file=$(ISO) -serial stdio
QEMU_MEMORY=-m 500M

CFLAGS=-m32 -std=gnu99 -ffreestanding -Wall -Wextra -c
ARFLAGS=rcs
Expand All @@ -37,13 +40,13 @@ LIBC_A=build/libc/libc.a
all: $(KERNEL)

run: $(ISO)
qemu-system-i386 -drive format=raw,file=$(ISO) -serial stdio
$(QEMU) $(QEMU_ARGS) $(QEMU_MEMORY)

rund: $(ISO)
qemu-system-i386 -drive format=raw,file=$(ISO) -serial stdio -d int
$(QEMU) $(QEMU_ARGS) $(QEMU_MEMORY) -d int

rundd: $(ISO)
qemu-system-i386 -drive format=raw,file=$(ISO) -serial stdio -d int -s -S
$(QEMU) $(QEMU_ARGS) $(QEMU_MEMORY) -d int -s -S

iso: $(ISO)

Expand Down Expand Up @@ -84,3 +87,5 @@ clean:
mrproper: clean
cargo clean

re: mrproper
make all
47 changes: 40 additions & 7 deletions src/elsos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ fn panic(info: &PanicInfo) -> !
vga::panic();
logln!("\n\x1B[31;49m{}\x1B[39;49m\n", info);

print_memory_state(false);

logln!("");
loop {}
}

fn print_memory_state(serial_only: bool)
{
let eax: u32;
let ebx: u32;
let ecx: u32;
Expand All @@ -109,24 +117,49 @@ fn panic(info: &PanicInfo) -> !
ebp = crate::get_reg!("ebp");
}

logln!("eax: {:08x} ebx: {:08x} ecx: {:08x} edx: {:08x}", eax, ebx, ecx, edx);
logln!("esi: {:08x} edi: {:08x} esp: {:08x} ebp: {:08x}", esi, edi, esp, ebp);
if !serial_only
{
crate::vga_println!("eax: {:08x} ebx: {:08x} ecx: {:08x} edx: {:08x}", eax, ebx, ecx, edx);
crate::vga_println!("esi: {:08x} edi: {:08x} esp: {:08x} ebp: {:08x}", esi, edi, esp, ebp);
}
crate::serial_println!("eax: {:08x} ebx: {:08x} ecx: {:08x} edx: {:08x}", eax, ebx, ecx, edx);
crate::serial_println!("esi: {:08x} edi: {:08x} esp: {:08x} ebp: {:08x}", esi, edi, esp, ebp);

log!("\nstack: ");
if !serial_only
{
crate::vga_print!("\nstack: ");
}
crate::serial_print!("\nstack: ");
for i in 0..24
{
unsafe
{
log!("{:08x} ", *(esp as *const u32).add(i * 4));
if !serial_only
{
crate::vga_print!("{:08x} ", *(esp as *const u32).add(i * 4));
}
crate::serial_print!("{:08x} ", *(esp as *const u32).add(i * 4));
if (i + 1) % 8 == 0
{
log!("\n ");
if !serial_only
{
crate::vga_print!("\n ");
}
crate::serial_print!("\n ");
}
}
}
}

logln!("");
loop {}
#[macro_export]
macro_rules! oops
{
($($arg:tt)*) =>
{
$crate::logln!("\x1B[33;49moops at '{}', {}:{}:{}\x1B[39;49m\n", format_args!($($arg)*), file!(), line!(), column!());
$crate::print_memory_state(true);
$crate::serial_println!("");
}
}

#[macro_export]
Expand Down
41 changes: 32 additions & 9 deletions src/ferramenta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ pub unsafe fn print_memory(ptr: *const u8, n: usize)
{
if i % 16 == 0
{
crate::log!("{:08x}: ", ptr.add(i) as u32);
crate::serial_print!("{:08x}: ", ptr.add(i) as u32);
}
crate::log!("{:02x?} ", *ptr.add(i));
crate::serial_print!("{:02x?} ", *ptr.add(i));
i += 1;
if i % 16 == 0
{
crate::log!(" |");
crate::serial_print!(" |");
for i in i - 16..i
{
let chr = *ptr.add(i);
crate::log!("{}", if chr > 0x1f && chr < 0x7f {chr as char } else { '.' });
crate::serial_print!("{}", if chr > 0x1f && chr < 0x7f {chr as char } else { '.' });
}
crate::log!("|");
crate::logln!();
crate::serial_print!("|");
crate::serial_println!();
}
else if i % 8 == 0
{
crate::log!(" ");
crate::serial_print!(" ");
}
}
crate::logln!();
crate::serial_println!();
}

pub unsafe fn print_memory_bin(ptr: *const u8, n: usize)
Expand Down Expand Up @@ -190,6 +190,29 @@ impl Bitmap
return false;
}

pub fn get_n_pages(&self, index: usize, n: usize) -> usize
{
for i in index..index + n
{
if self.get(i)
{
return i;
}
}
0
}

pub fn get_chunk32(&self, index: usize) -> u32
{
let mut chunk: u32 = 0;

for i in 0..4
{
chunk += self.buffer[index * 4 + i] as u32;
}
chunk
}

pub fn set(&mut self, index: usize, value: bool)
{
let byte_index: usize = index / 8;
Expand Down Expand Up @@ -248,4 +271,4 @@ pub fn align(val: usize, bound: usize) -> usize
pub fn in_range(input: usize, start: usize, range: usize) -> bool
{
input >= start && input < start + range
}
}
Loading