Fix thread locals
This commit is contained in:
parent
8ddd0ad3f0
commit
7a59e08e70
|
@ -150,6 +150,3 @@ pub mod serial;
|
||||||
|
|
||||||
/// Initialization and start function
|
/// Initialization and start function
|
||||||
pub mod start;
|
pub mod start;
|
||||||
|
|
||||||
/// Thread control block
|
|
||||||
pub mod tcb;
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ use core::ops::{Deref, DerefMut};
|
||||||
use x86::tlb;
|
use x86::tlb;
|
||||||
|
|
||||||
use memory::{allocate_frame, Frame};
|
use memory::{allocate_frame, Frame};
|
||||||
use tcb::ThreadControlBlock;
|
|
||||||
|
|
||||||
use self::entry::{EntryFlags, PRESENT, WRITABLE, NO_EXECUTE};
|
use self::entry::{EntryFlags, PRESENT, WRITABLE, NO_EXECUTE};
|
||||||
use self::mapper::Mapper;
|
use self::mapper::Mapper;
|
||||||
|
@ -45,8 +44,6 @@ pub unsafe fn init(stack_start: usize, stack_end: usize) -> ActivePageTable {
|
||||||
static mut __tbss_start: u8;
|
static mut __tbss_start: u8;
|
||||||
/// The ending byte of the thread BSS segment
|
/// The ending byte of the thread BSS segment
|
||||||
static mut __tbss_end: u8;
|
static mut __tbss_end: u8;
|
||||||
/// The start of the thread control block
|
|
||||||
static mut __tcb: ThreadControlBlock;
|
|
||||||
/// The starting byte of the _.bss_ (uninitialized data) segment.
|
/// The starting byte of the _.bss_ (uninitialized data) segment.
|
||||||
static mut __bss_start: u8;
|
static mut __bss_start: u8;
|
||||||
/// The ending byte of the _.bss_ (uninitialized data) segment.
|
/// The ending byte of the _.bss_ (uninitialized data) segment.
|
||||||
|
@ -136,18 +133,9 @@ pub unsafe fn init(stack_start: usize, stack_end: usize) -> ActivePageTable {
|
||||||
tlb::flush_all();
|
tlb::flush_all();
|
||||||
::externs::memset(page.start_address().get() as *mut u8, 0, 4096);
|
::externs::memset(page.start_address().get() as *mut u8, 0, 4096);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map and set TCB
|
*(end as *mut usize).offset(-1) = end;
|
||||||
{
|
}
|
||||||
let start = & __tcb as *const _ as usize;
|
|
||||||
println!("TCB: {:X}", start);
|
|
||||||
let page = Page::containing_address(VirtualAddress::new(start));
|
|
||||||
active_table.map(page, PRESENT | NO_EXECUTE | WRITABLE);
|
|
||||||
tlb::flush_all();
|
|
||||||
::externs::memset(page.start_address().get() as *mut u8, 0, 4096);
|
|
||||||
__tcb.offset = start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
active_table
|
active_table
|
||||||
|
|
|
@ -12,7 +12,6 @@ use gdt;
|
||||||
use idt;
|
use idt;
|
||||||
use memory::{self, Frame};
|
use memory::{self, Frame};
|
||||||
use paging::{self, entry, Page, PhysicalAddress, VirtualAddress};
|
use paging::{self, entry, Page, PhysicalAddress, VirtualAddress};
|
||||||
use tcb::ThreadControlBlock;
|
|
||||||
|
|
||||||
/// Test of zero values in BSS.
|
/// Test of zero values in BSS.
|
||||||
static BSS_TEST_ZERO: usize = 0;
|
static BSS_TEST_ZERO: usize = 0;
|
||||||
|
@ -45,8 +44,8 @@ pub unsafe extern fn kstart() -> ! {
|
||||||
static mut __bss_start: u8;
|
static mut __bss_start: u8;
|
||||||
/// The ending byte of the _.bss_ (uninitialized data) segment.
|
/// The ending byte of the _.bss_ (uninitialized data) segment.
|
||||||
static mut __bss_end: u8;
|
static mut __bss_end: u8;
|
||||||
/// The thread descriptor.
|
/// The end of the tbss.
|
||||||
static mut __tcb: ThreadControlBlock;
|
static mut __tbss_end: u8;
|
||||||
/// The end of the kernel
|
/// The end of the kernel
|
||||||
static mut __end: u8;
|
static mut __end: u8;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,7 @@ pub unsafe extern fn kstart() -> ! {
|
||||||
let mut active_table = paging::init(stack_start, stack_end);
|
let mut active_table = paging::init(stack_start, stack_end);
|
||||||
|
|
||||||
// Set up GDT
|
// Set up GDT
|
||||||
gdt::init(__tcb.offset);
|
gdt::init((&__tbss_end as *const u8 as *const usize).offset(-1) as usize);
|
||||||
|
|
||||||
// Set up IDT
|
// Set up IDT
|
||||||
idt::init();
|
idt::init();
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
/// Thread control block
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct ThreadControlBlock {
|
|
||||||
pub offset: usize
|
|
||||||
}
|
|
|
@ -35,19 +35,11 @@ SECTIONS {
|
||||||
*(.tdata*)
|
*(.tdata*)
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
__tdata_end = .;
|
__tdata_end = .;
|
||||||
}
|
|
||||||
|
|
||||||
.tbss : AT(ADDR(.tbss) - KERNEL_OFFSET) {
|
|
||||||
__tbss_start = .;
|
__tbss_start = .;
|
||||||
*(.tbss*)
|
*(.tbss*)
|
||||||
. = ALIGN(4096);
|
|
||||||
__tbss_end = .;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tcb : AT(ADDR(.tcb) - KERNEL_OFFSET) {
|
|
||||||
__tcb = .;
|
|
||||||
. += 8;
|
. += 8;
|
||||||
. = ALIGN(4096);
|
. = ALIGN(4096);
|
||||||
|
__tbss_end = .;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bss : AT(ADDR(.bss) - KERNEL_OFFSET) {
|
.bss : AT(ADDR(.bss) - KERNEL_OFFSET) {
|
||||||
|
|
Loading…
Reference in a new issue