<commit_before>//
//  SOS: the Stupid Operating System
//  by <NAME> (<EMAIL>)
//
//  Copyright (c) 2015 <NAME>
//  Released under the terms of the MIT license. See `LICENSE` in the root
//  directory of this repository for more information.
//
//! `x86` and `x86_64` descriptor tables (IDT, GDT, or LDT)

use memory::PAddr;

/// A pointer to a descriptor table.
/// This is a format suitable
#[repr(C, packed)]
pub struct Pointer { /// the length of the descriptor table
                     pub limit: u16
                   , /// pointer to the region in memory
                     /// containing the descriptor table.
                     pub base: PAddr
                   }

/// A descriptor table (IDT or GDT)
pub trait DTable {
    fn get_ptr(&self) -> Pointer;

    /// Load the descriptor table with the appropriate load instruction
    unsafe fn load(&self);
}<commit_msg>[x86_all] Generalized `DTable::get_ptr()` to trait<commit_after>//
//  SOS: the Stupid Operating System
//  by <NAME> (<EMAIL>)
//
//  Copyright (c) 2015 <NAME>
//  Released under the terms of the MIT license. See `LICENSE` in the root
//  directory of this repository for more information.
//
//! `x86` and `x86_64` descriptor tables (IDT, GDT, or LDT)

use memory::PAddr;
use core::mem::size_of;

/// A pointer to a descriptor table.
/// This is a format suitable
#[repr(C, packed)]
pub struct Pointer { /// the length of the descriptor table
                     pub limit: u16
                   , /// pointer to the region in memory
                     /// containing the descriptor table.
                     pub base: PAddr
                   }

/// A descriptor table (IDT or GDT)
pub trait DTable: Sized {
    /// Get the IDT pointer struct to pass to `lidt` or `lgdt`
    fn get_ptr(&self) -> Pointer {
        Pointer {
            limit: size_of::<Self>() as u16
          , base: PAddr::from(self as *const _)
        }
    }

    /// Load the descriptor table with the appropriate load instruction
    unsafe fn load(&self);
}
{'fraction_non_alphanumeric': 0.11352418558736427, 'fraction_numerical': 0.013820335636722606, 'mean_word_length': 2.034431137724551, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2205896', 'n_tokens_mistral': 603, 'n_tokens_neox': 566, 'n_words': 239}