Implement Default for TSS.

- Some documentation.
This commit is contained in:
ticki 2016-08-14 18:10:28 +02:00
parent 42c9ba12dc
commit 938b1a73a4
5 changed files with 35 additions and 26 deletions

View file

@ -45,3 +45,7 @@ If the condition is (or should be) unreachable, but if not upheld, leading to UB
### Be gentle ### Be gentle
Don't just write as much code as you can as quick as possible. Take your time and be careful. Don't just write as much code as you can as quick as possible. Take your time and be careful.
### Commits
Use descriptive commits. One way to force yourself to do that is to not pass the `-m` flag, which will make your editor pop up, so that you can conviniently write long commit messages.

View file

@ -1,7 +1,9 @@
//! # IRQ handling //! # IRQ handling
//!
//! This module defines IRQ handling functions. These functions should all be #[naked], //! This module defines IRQ handling functions. These functions should all be #[naked],
//! unsafe, extern, and end in `iretq` //! unsafe, extern, and end in `iretq`
/// Interupt Request handler.
#[naked] #[naked]
pub unsafe extern fn irq() { pub unsafe extern fn irq() {

View file

@ -2,8 +2,7 @@
/// ///
/// Copy N bytes of memory from one location to another. /// Copy N bytes of memory from one location to another.
#[no_mangle] #[no_mangle]
pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8, pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 {
n: usize) -> *mut u8 {
let mut i = 0; let mut i = 0;
while i < n { while i < n {
*dest.offset(i as isize) = *src.offset(i as isize); *dest.offset(i as isize) = *src.offset(i as isize);

View file

@ -1,23 +1,25 @@
/// Global descriptor table //! X86_64 architecture primitives.
/// Global descriptor table.
pub mod gdt; pub mod gdt;
/// Interrupt descriptor table /// Interrupt descriptor table.
pub mod idt; pub mod idt;
/// IO Handling /// IO handling.
pub mod io; pub mod io;
/// IRQ Handling /// IRQ handling.
pub mod irq; pub mod irq;
/// Initialization and main function /// Initialization and main function.
pub mod main; pub mod main;
/// Memcpy, memmove, etc. /// Core memory routines.
pub mod mem; pub mod mem;
/// Serial driver and print! support /// Serial driver and `print!` support.
pub mod serial; pub mod serial;
/// Task state segment /// Task state segment.
pub mod tss; pub mod tss;

View file

@ -1,20 +1,22 @@
#[repr(packed)] /// The Task State Segment.
#[repr(C, packed)]
#[derive(Debug, Default, Clone)]
pub struct Tss { pub struct Tss {
pub reserved1: u32, /// Reserved.
pub sp0: u64, pub _reserved1: u32,
pub sp1: u64, /// The stack-pointers (reg RSP) for the IO privilege level 0 through 2.
pub sp2: u64, pub rsp: [u64; 3],
pub reserved2: u32, /// Reserved.
pub reserved3: u32, pub _reserved2: u32,
pub ist1: u64, /// Reserved.
pub ist2: u64, pub _reserved3: u32,
pub ist3: u64, pub ist: [u64; 7],
pub ist4: u64, /// Reserved.
pub ist5: u64, pub _reserved4: u32,
pub ist6: u64, /// Reserved.
pub ist7: u64, pub _reserved5: u32,
pub reserved4: u32, // Reserved.
pub reserved5: u32,
pub reserved6: u16, pub reserved6: u16,
/// The offset to the IOPB.
pub iomap_base: u16, pub iomap_base: u16,
} }