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: 8 additions & 5 deletions kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# The MIT License (MIT)
#
#
# Copyright (c) 2014 Kashyap
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -24,10 +24,13 @@ include $(SOURCE_ROOT)/Rules.inc

all: libcompiler-rt.a libmorestack.a
cp -f $(LINUX_RUST_DIR)/lib/rustlib/$(LINUX_TARGET)/lib/libcore-*.rlib libcore.rlib
$(RUSTC) --target=$(LINUX_TARGET) -C no-stack-check kernel.rs --extern core=libcore.rlib -L.
$(RUSTC) --target=$(LINUX_TARGET) -C no-stack-check kernel.rs \
--extern core=libcore.rlib -L.

libcore.rlib:
cp $(LINUX_RUST_DIR)/lib/rustlib/$(LINUX_TARGET)/lib/libcore-*.rlib libcore.rlib
cp $(LINUX_RUST_DIR)/lib/rustlib/$(LINUX_TARGET)/lib/libstd-*.rlib libstd.rlib

#$(RUSTC) --target=$(TARGET) -C no-stack-check --crate-type lib $(LIB_RS) --crate-name core

libcompiler-rt.a:
Expand Down
9 changes: 5 additions & 4 deletions kernel/kernel.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// The MIT License (MIT)
//
//
// Copyright (c) 2014 Kashyap
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -41,6 +41,7 @@ mod mmu;
mod memlayout;
mod rlibc;
mod console;
mod task;


fn main (end : u64) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/spinlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Spinlock {
pub const DUMMY_LOCK: Spinlock = Spinlock {locked:0, name:"" } ;


pub fn init_lock(lk : &mut Spinlock, name : &'static str )
pub fn init_lock(lk: &mut Spinlock, name : &'static str )
{
lk.name = name;
lk.locked = 0;
Expand Down
58 changes: 58 additions & 0 deletions kernel/task.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Kashyap
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use core::str::StrExt;
use core::marker::Copy;
use super::spinlock::{Spinlock, DUMMY_LOCK, init_lock};

pub const TASK_NUM: usize = 1024;

pub struct Task {
sz: usize,
pid: usize,
killed: isize,
name: &'static str
}

impl Copy for Task {}

struct TaskTable {
lock: Spinlock,
procs: &'static [Task; TASK_NUM]
}

static mut procs : TaskTable = TaskTable{
lock: DUMMY_LOCK,
procs: &[
Task {
sz: 0us,
pid: 0us,
killed: 0is,
name: "undef"
}; TASK_NUM]
};

pub fn init_proc() {
unsafe {
init_lock(&mut procs.lock, "task_table");
}
}
13 changes: 5 additions & 8 deletions kernel/uart.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// The MIT License (MIT)
//
//
// Copyright (c) 2014 Kashyap
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -33,7 +33,7 @@ const COM1 : u16 = 0x3f8;
static mut uart_initialized : bool = false;


pub fn early_init () {
pub fn early_init () {
outb(COM1+2 , 0);
outb(COM1+3, 0x80); // Unlock divisor
outb(COM1+0, 12);
Expand Down Expand Up @@ -83,9 +83,6 @@ pub fn uart_put_str(text: &str) {
}
}




fn uart_putc(byte : u8) {
outb(COM1, byte);
}