diff --git a/arch/x86_64/src/lib.rs b/arch/x86_64/src/lib.rs index 5d2eea5..eaa0e5b 100644 --- a/arch/x86_64/src/lib.rs +++ b/arch/x86_64/src/lib.rs @@ -150,6 +150,3 @@ pub mod serial; /// Initialization and start function pub mod start; - -/// Thread control block -pub mod tcb; diff --git a/arch/x86_64/src/paging/mod.rs b/arch/x86_64/src/paging/mod.rs index bad0649..f9c7d64 100644 --- a/arch/x86_64/src/paging/mod.rs +++ b/arch/x86_64/src/paging/mod.rs @@ -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 diff --git a/arch/x86_64/src/start.rs b/arch/x86_64/src/start.rs index 0265ed5..fa12b10 100644 --- a/arch/x86_64/src/start.rs +++ b/arch/x86_64/src/start.rs @@ -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(); diff --git a/arch/x86_64/src/tcb.rs b/arch/x86_64/src/tcb.rs deleted file mode 100644 index b4c425e..0000000 --- a/arch/x86_64/src/tcb.rs +++ /dev/null @@ -1,5 +0,0 @@ -/// Thread control block -#[repr(C)] -pub struct ThreadControlBlock { - pub offset: usize -} diff --git a/bootloader/x86/kernel.ld b/bootloader/x86/kernel.ld index 3f524a8..c5e3a9d 100644 --- a/bootloader/x86/kernel.ld +++ b/bootloader/x86/kernel.ld @@ -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) {