some stuff
This commit is contained in:
parent
ba108d9e3e
commit
f02df6577e
8 changed files with 84 additions and 47 deletions
|
|
@ -6,8 +6,8 @@ TARGET ?= $(ARCH)-$(OS)
|
|||
|
||||
all:
|
||||
@printf "make kernel\t# build kernel binary\n"
|
||||
@printf "make iso\t# build iso cdrom with grub\n"
|
||||
@printf "make qemu\t# run qemu+gdb in tmux window\n"
|
||||
@printf "make iso\t# build iso cdrom\n"
|
||||
@printf "make qemu\t# run iso in qemu\n"
|
||||
|
||||
## COMPILE ASM (nasm)
|
||||
asm_source := $(wildcard src/arch/$(ARCH)/*.asm)
|
||||
|
|
@ -35,11 +35,12 @@ clean:
|
|||
|
||||
.PHONY: clean kernel iso $(rust_os)
|
||||
|
||||
# Bootloader recipes
|
||||
ISO := $(kernel:.bin=.iso)
|
||||
iso: $(ISO)
|
||||
include mk/grub.mk
|
||||
|
||||
# Emulation recipes
|
||||
include mk/qemu.mk
|
||||
|
||||
# Bootloader recipes
|
||||
include mk/grub.mk
|
||||
iso: $(grub-iso)
|
||||
|
||||
kernel: $(kernel)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
grub-iso := $(kernel:.bin=.iso)
|
||||
grub-cfg := src/arch/$(ARCH)/grub.cfg
|
||||
isodir := build/isofiles
|
||||
|
||||
$(grub-iso): $(kernel) $(grub-cfg) Makefile
|
||||
$(ISO): $(kernel) $(grub-cfg) Makefile
|
||||
@mkdir -p $(isodir)/boot/grub
|
||||
@cp $(grub-cfg) $(isodir)/boot/grub
|
||||
@cp $(kernel) $(isodir)/boot/$(OS)
|
||||
|
|
|
|||
|
|
@ -1,35 +1,24 @@
|
|||
ifeq ($(shell whoami), jack)
|
||||
PORT_MONIT := 4242
|
||||
PORT_GDB := 4244
|
||||
else
|
||||
PORT_MONIT := 4342
|
||||
PORT_GDB := 4344
|
||||
endif
|
||||
QEMU_SOCKET := /tmp/qemu.sock
|
||||
QEMU_MONITOR := socat - unix-connect:$(QEMU_SOCKET)
|
||||
QEMU_GDB_PORT := 4242
|
||||
|
||||
QEMU := qemu-system-i386\
|
||||
-cdrom build/bluesnow-x86.iso\
|
||||
qemu:
|
||||
qemu-system-i386\
|
||||
-cdrom $(ISO)\
|
||||
-S\
|
||||
-enable-kvm\
|
||||
-curses\
|
||||
-gdb tcp::$(PORT_GDB)\
|
||||
-monitor telnet:127.0.0.1:$(PORT_MONIT),server,nowait
|
||||
qemu:
|
||||
$(QEMU)
|
||||
-gdb tcp::$(QEMU_GDB_PORT)\
|
||||
-monitor unix:${QEMU_SOCKET},server,nowait
|
||||
|
||||
GDB := gdb -q\
|
||||
qemu-gdb:
|
||||
gdb -q\
|
||||
-symbols "$(kernel)" \
|
||||
-ex "target remote :$(PORT_GDB)"\
|
||||
-ex "target remote :$(QEMU_GDB_PORT)"\
|
||||
-ex "set arch i386"
|
||||
gdb:
|
||||
$(GDB)
|
||||
|
||||
MONITOR := telnet 127.0.0.1 $(PORT_MONIT);\
|
||||
kill \`ps -x | grep \"[g]db -q\" | cut -d \ -f 1 \`;\
|
||||
kill \`ps -x | grep \"[g]db -q\" | cut -d \ -f 2 \`
|
||||
monitor:
|
||||
telnet 127.0.0.1 $(PORT_MONIT)
|
||||
|
||||
#not using this anymore
|
||||
william:
|
||||
@tmux info >&- || { echo -e "\033[38;5;16mPlease run inside a tmux session\033[0m" ; exit 1; }
|
||||
@tmux new-window 'tmux split-window -h "$(MONITOR)"; tmux split-window -fv "$(GDB)"; tmux select-pane -t 1; tmux resize-pane -x 80 -y 25; $(QEMU)'
|
||||
qemu-monitor:
|
||||
$(QEMU_MONITOR)
|
||||
qemu-reload:
|
||||
echo "change ide1-cd0 $(ISO)" | $(QEMU_MONITOR) &>-
|
||||
echo "system_reset" | $(QEMU_MONITOR) &>-
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ interrupt!(0, pit, {
|
|||
let sum = offset.1 + PIT_RATE;
|
||||
offset.1 = sum % 1_000_000;
|
||||
offset.0 += sum / 1_000_000;
|
||||
if sum > 1_000_000 {
|
||||
// fprintln!("uptime: {}s", offset.0);
|
||||
}
|
||||
}
|
||||
unsafe { pic::MASTER.ack() };
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ extern crate core;
|
|||
// extern crate multiboot2;
|
||||
|
||||
use acpi;
|
||||
use time;
|
||||
use keyboard::PS2;
|
||||
use core::char;
|
||||
use vga::*;
|
||||
|
|
@ -28,6 +29,9 @@ fn dispatch(command: &str) -> Result<(), &'static str> {
|
|||
"overflow" => self::overflow(),
|
||||
"page_fault" => self::page_fault(),
|
||||
|
||||
// time
|
||||
"uptime" => self::uptime(),
|
||||
|
||||
_ => Err("Command unknown. (h|help for help)"),
|
||||
}
|
||||
}
|
||||
|
|
@ -59,6 +63,13 @@ fn help() -> Result<(), &'static str> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn uptime() -> Result<(), &'static str> {
|
||||
let mut offset = time::OFFSET.lock();
|
||||
fprintln!("{}s", offset.0 + offset.1 / 1_000_000);
|
||||
flush!();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
use x86::instructions::halt;
|
||||
/// Reboot the kernel
|
||||
///
|
||||
|
|
|
|||
|
|
@ -54,10 +54,11 @@ pub fn kmain() -> ! {
|
|||
// memory init after heap is available
|
||||
memory::init_noncore();
|
||||
|
||||
// vga is *not* cpu specific I think
|
||||
// load vga after core because is *not* cpu specific I think
|
||||
vga::init();
|
||||
|
||||
scheduling::schedule();
|
||||
// scheduler WIP
|
||||
// scheduling::schedule();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
mod process;
|
||||
mod sleep;
|
||||
|
||||
mod fifo;
|
||||
|
||||
use spin::Mutex;
|
||||
pub use self::process::*;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref SCHEDULER: Mutex<fifo::Fifo> = Mutex::new({
|
||||
let init_process: u32 = self::init as *const () as u32;
|
||||
|
|
@ -13,6 +14,7 @@ lazy_static! {
|
|||
});
|
||||
}
|
||||
|
||||
/// Scheduler algorithm needs to implement this
|
||||
pub trait Scheduler {
|
||||
fn add_task(&mut self, ip: u32);
|
||||
fn next(&mut self) -> Option<Process>;
|
||||
|
|
@ -42,7 +44,9 @@ pub fn fork() -> i32 {
|
|||
0
|
||||
}
|
||||
|
||||
pub fn sleep() {}
|
||||
pub fn sleep() {
|
||||
|
||||
}
|
||||
|
||||
pub fn init() {
|
||||
fprintln!("init first line");
|
||||
|
|
|
|||
|
|
@ -4,3 +4,38 @@
|
|||
//! managing these
|
||||
//!
|
||||
//! inspired from https://wiki.osdev.org/Blocking_Process
|
||||
|
||||
use alloc::VecDeque;
|
||||
use super::*;
|
||||
|
||||
struct Sleeper {
|
||||
process: Process,
|
||||
// ms
|
||||
ticks: u32,
|
||||
}
|
||||
|
||||
/// osdev calls this a delta queue but google doesnt know
|
||||
struct DeltaQueue {
|
||||
queue: VecDeque<Sleeper>,
|
||||
}
|
||||
|
||||
impl DeltaQueue {
|
||||
pub fn insert(&mut self, process: Process, ticks: u32) {
|
||||
let sleeper = Sleeper { process, ticks };
|
||||
}
|
||||
|
||||
/// decreases timer on the list and returns the number
|
||||
/// of finished sleepers
|
||||
pub fn tick(&mut self) -> u32 {
|
||||
let mut i: u32 = 0;
|
||||
while let Some(link) = self.queue.get_mut(i as usize) {
|
||||
// find how many links have 0 ticks left
|
||||
if link.ticks > 0 {
|
||||
link.ticks -= 1;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
i
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue