Skip to content

Commit

Permalink
Added const constructor for x2APIC.
Browse files Browse the repository at this point in the history
  • Loading branch information
gz committed Jun 4, 2022
1 parent 37e6758 commit 10092fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

## [0.48.0] - 2022-05-23

- Added `const new` constructor for X2APIC struct
- Use fully qualified `asm!` import for `int!` macro so clients do no longer
need to import `asm!` themselves.
17 changes: 9 additions & 8 deletions src/apic/x2apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ use crate::msr::{
/// Represents an x2APIC driver instance.
#[derive(Debug)]
pub struct X2APIC {
/// Initial BASE msr register value.
/// Initial base msr register value.
base: u64,
}

impl Default for X2APIC {
fn default() -> Self {
unsafe {
X2APIC {
base: rdmsr(IA32_APIC_BASE),
}
}
X2APIC { base: 0x0 }
}
}

impl X2APIC {
/// Create a new x2APIC driver object for the local core.
pub fn new() -> X2APIC {
Default::default()
///
/// # Notes
/// The object needs to be initialized by calling `attach()` first which
/// enables the x2APIC. There should be only one x2APIC object created per
/// core.
pub const fn new() -> Self {
X2APIC { base: 0x0 }
}

/// Attach to APIC (enable x2APIC mode, initialize LINT0)
Expand Down

0 comments on commit 10092fd

Please sign in to comment.