Skip to content

Commit

Permalink
Bits: Remove hw crate and move hw_macro to bits_macro for bette…
Browse files Browse the repository at this point in the history
…r naming
  • Loading branch information
corigan01 committed Jan 30, 2025
1 parent c93c71f commit cab57c4
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 280 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ members = [
"crates/lldebug",
"crates/serial",
"crates/lldebug-macro",
"crates/hw",
"crates/hw-macro",
"crates/bits-macro",
"crates/util",
"crates/elf",
"crates/mem",
Expand Down Expand Up @@ -52,8 +51,7 @@ bootgfx = { path = "crates/bootgfx" }
serial = { path = "crates/serial" }
lldebug = { path = "crates/lldebug" }
lldebug-macro = { path = "crates/lldebug-macro" }
hw = { path = "crates/hw" }
hw-macro = { path = "crates/hw-macro" }
bits-macro = { path = "crates/bits-macro" }
util = { path = "crates/util" }
elf = { path = "crates/elf" }
mem = { path = "crates/mem" }
Expand Down
1 change: 0 additions & 1 deletion crates/arch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ documentation.workspace = true

[dependencies]
bits = {workspace = true}
hw = {workspace = true}
util = {workspace = true}
arch-macro = {workspace = true}
lldebug = {workspace = true}
7 changes: 3 additions & 4 deletions crates/arch/src/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
*/

use core::arch::asm;
use hw::make_hw;

#[repr(C)]
pub struct GlobalDescriptorTable<const TABLE_SIZE: usize>([u64; TABLE_SIZE]);
Expand Down Expand Up @@ -68,7 +67,7 @@ impl GdtPointer {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0..16, segment_limit_lo),
field(RW, 16..32, base_address_lo),
field(RW, 32..40, base_address_mi),
Expand All @@ -89,7 +88,7 @@ impl GdtPointer {
#[derive(Clone, Copy)]
pub struct DataSegmentDesc(u64);

#[make_hw(
#[bits::bits(
field(RW, 0..16, segment_limit_lo),
field(RW, 16..32, base_address_lo),
field(RW, 32..40, base_address_mi),
Expand Down Expand Up @@ -144,7 +143,7 @@ impl SegmentEntry for DataSegmentDesc {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0..16, segment_limit_lo),
field(RW, 16..32, base_address_lo),
field(RW, 32..40, base_address_mi),
Expand Down
3 changes: 1 addition & 2 deletions crates/arch/src/idt64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use crate::{
};
pub use arch_macro::interrupt;
use core::fmt::Debug;
use hw::make_hw;

#[derive(Clone, Copy, Debug)]
pub enum GateKind {
Expand Down Expand Up @@ -74,7 +73,7 @@ impl IdtPointer {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0..=15, offset_1),
field(RW, 16..=31, segment_selector),
field(RW, 32..=34, pub ist),
Expand Down
16 changes: 7 additions & 9 deletions crates/arch/src/paging64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
*/

use core::{fmt::Display, marker::PhantomPinned};

use hw::make_hw;
use util::consts::PAGE_4K;

/// The max 'bits' of physical memory the system supports.
pub const MAX_PHY_MEMORY_WIDTH: usize = 48;

#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -62,7 +60,7 @@ impl PageEntry4K {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -103,7 +101,7 @@ impl PageEntry2M {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -160,7 +158,7 @@ impl PageEntry1G {
/// It would be a good idea to verify that all 'bit' or options set in this entry does exactly
/// what you intend it to do before loading it. Page tables can cause the entire system to become
/// unstable if mapped wrong -- **this is very important.**
#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -213,7 +211,7 @@ impl PageEntryLvl2 {
/// It would be a good idea to verify that all 'bit' or options set in this entry does exactly
/// what you intend it to do before loading it. Page tables can cause the entire system to become
/// unstable if mapped wrong -- **this is very important.**
#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -266,7 +264,7 @@ impl PageEntryLvl3 {
/// It would be a good idea to verify that all 'bit' or options set in this entry does exactly
/// what you intend it to do before loading it. Page tables can cause the entire system to become
/// unstable if mapped wrong -- **this is very important.**
#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down Expand Up @@ -319,7 +317,7 @@ impl PageEntryLvl4 {
/// It would be a good idea to verify that all 'bit' or options set in this entry does exactly
/// what you intend it to do before loading it. Page tables can cause the entire system to become
/// unstable if mapped wrong -- **this is very important.**
#[make_hw(
#[bits::bits(
field(RW, 0, pub present),
field(RW, 1, pub read_write),
field(RW, 2, pub user_access),
Expand Down
16 changes: 7 additions & 9 deletions crates/arch/src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

use hw::make_hw;

use crate::CpuPrivilege;

#[repr(C)]
Expand Down Expand Up @@ -195,7 +193,7 @@ impl SegmentRegisters {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0, pub protected_mode),
field(RW, 1, pub monitor_co_processor),
field(RW, 2, pub x87_fpu_emulation),
Expand Down Expand Up @@ -306,7 +304,7 @@ pub mod cr2 {
}
}

#[make_hw(
#[bits::bits(
field(RW, 3, pub page_level_write_through),
field(RW, 4, pub page_level_cache_disable),
field(RWNS, 12..=63, pub page_directory_base_register)
Expand Down Expand Up @@ -360,7 +358,7 @@ pub mod cr3 {
}
}

#[make_hw(
#[bits::bits(
field(RW, 0, pub v8086),
field(RW, 1, pub protected_mode_virtual_interrupts),
field(RW, 2, pub time_stamp_disable),
Expand Down Expand Up @@ -434,7 +432,7 @@ pub mod cr4 {
}
}

#[make_hw(
#[bits::bits(
field(RO, 0, pub carry),
field(RO, 2, pub parity),
field(RO, 4, pub auxiliary),
Expand Down Expand Up @@ -515,7 +513,7 @@ pub unsafe fn write_msr(msr_number: u32, value: u64) {
)
}

#[make_hw(
#[bits::bits(
field(RW, 0, pub syscall_extensions),
field(RW, 8, pub long_mode_enable),
field(RW, 10, pub long_mode_active),
Expand All @@ -542,13 +540,13 @@ pub mod ia32_efer {
pub mod amd_syscall {
use crate::CpuPrivilege;

use super::{make_hw, read_msr, write_msr, Segment};
use super::{read_msr, write_msr, Segment};
const STAR: u32 = 0xC0000081;
const LSTAR: u32 = 0xC0000082;
const CSTAR: u32 = 0xC0000083;
const SFMASK: u32 = 0xC0000084;

#[make_hw(
#[bits::bits(
field(RW, 32..48, pub syscall_target_code_segment),
field(RW, 48..64, pub sysret_target_code_segment),
)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "hw-macro"
name = "bits-macro"
edition = "2021"
version.workspace = true
authors.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) mod make_hw_parse;
pub(crate) mod provider_parse;

#[proc_macro_attribute]
pub fn make_hw(args: TokenStream, input: TokenStream) -> TokenStream {
pub fn bits(args: TokenStream, input: TokenStream) -> TokenStream {
let macro_fields = parse_macro_input!(args as make_hw_parse::MakeHwMacroInput);

// Parse the Struct/Module
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions crates/bits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ description.workspace = true
documentation.workspace = true

[dependencies]
bits-macro = { workspace = true}
2 changes: 2 additions & 0 deletions crates/bits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
*/

#![no_std]

pub use bits_macro::*;
use core::ops::RangeBounds;

/// # Bit Manipulation
Expand Down
13 changes: 0 additions & 13 deletions crates/hw/Cargo.toml

This file was deleted.

28 changes: 0 additions & 28 deletions crates/hw/src/lib.rs

This file was deleted.

15 changes: 0 additions & 15 deletions crates/hw/tests/mod/mod.rs

This file was deleted.

19 changes: 0 additions & 19 deletions crates/hw/tests/mod/unsafe_fn.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/hw/tests/one/one.rs

This file was deleted.

13 changes: 0 additions & 13 deletions crates/hw/tests/struct/struct.rs

This file was deleted.

Loading

0 comments on commit cab57c4

Please sign in to comment.