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