Skip to content

Commit

Permalink
Merge pull request #6 from chenyukang/task
Browse files Browse the repository at this point in the history
Task

oh, now I understand!
I think it will be a good idea to maintain a file where we do a mapping of symbol/filenames between rustix and xv6.
  • Loading branch information
ckkashyap committed Jan 22, 2015
2 parents c8f89e4 + 82d2461 commit 9d6c34f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 18 deletions.
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);
}

0 comments on commit 9d6c34f

Please sign in to comment.