Lines Matching refs:val
338 fn from(val: $name) -> $storage {
339 val.into_raw()
345 fn from(val: $storage) -> $name {
346 Self::from_raw(val)
398 let val = ::kernel::num::Bounded::<$storage, { $storage::BITS }>::from( localVariable
401 val.shr::<ALIGN_BOTTOM, { $hi + 1 - $lo } >()
652 let mut val = TestU64::zeroed(); in test_basic_access() localVariable
653 assert_eq!(val.into_raw(), 0x0); in test_basic_access()
655 val = val.with_field_0(true); in test_basic_access()
656 assert!(val.field_0().into_bool()); in test_basic_access()
657 assert_eq!(val.into_raw(), 0x1); in test_basic_access()
659 val = val.with_field_1(true); in test_basic_access()
660 assert!(val.field_1().into_bool()); in test_basic_access()
661 val = val.with_field_1(false); in test_basic_access()
662 assert!(!val.field_1().into_bool()); in test_basic_access()
663 assert_eq!(val.into_raw(), 0x1); in test_basic_access()
665 val = val.with_const_field_11_9::<0x5>(); in test_basic_access()
666 assert_eq!(val.field_11_9(), 0x5); in test_basic_access()
667 assert_eq!(val.into_raw(), 0xA01); in test_basic_access()
669 val = val.with_const_field_51_16::<0x123456>(); in test_basic_access()
670 assert_eq!(val.field_51_16(), 0x123456); in test_basic_access()
671 assert_eq!(val.into_raw(), 0x0012_3456_0A01); in test_basic_access()
674 val = val.with_const_field_51_16::<{ MAX_FIELD_51_16 }>(); in test_basic_access()
675 assert_eq!(val.field_51_16(), MAX_FIELD_51_16); in test_basic_access()
677 val = val.with_const_field_61_52::<0x3FF>(); in test_basic_access()
678 assert_eq!(val.field_61_52(), 0x3FF); in test_basic_access()
680 val = val.with_field_63(true); in test_basic_access()
681 assert!(val.field_63().into_bool()); in test_basic_access()
684 let mut val = TestU16::zeroed(); in test_basic_access() localVariable
685 assert_eq!(val.into_raw(), 0x0); in test_basic_access()
687 val = val.with_field_0(true); in test_basic_access()
688 assert!(val.field_0().into_bool()); in test_basic_access()
689 assert_eq!(val.into_raw(), 0x1); in test_basic_access()
691 val = val.with_const_field_3_1::<0x5>(); in test_basic_access()
692 assert_eq!(val.field_3_1(), 0x5); in test_basic_access()
693 assert_eq!(val.into_raw(), 0xB); in test_basic_access()
695 val = val.with_const_field_7_4::<0xA>(); in test_basic_access()
696 assert_eq!(val.field_7_4(), 0xA); in test_basic_access()
697 assert_eq!(val.into_raw(), 0xAB); in test_basic_access()
699 val = val.with_const_field_15_8::<0x42>(); in test_basic_access()
700 assert_eq!(val.field_15_8(), 0x42); in test_basic_access()
701 assert_eq!(val.into_raw(), 0x42AB); in test_basic_access()
704 let mut val = TestU8::zeroed(); in test_basic_access() localVariable
705 assert_eq!(val.into_raw(), 0x0); in test_basic_access()
707 val = val.with_field_0(true); in test_basic_access()
708 assert!(val.field_0().into_bool()); in test_basic_access()
709 assert_eq!(val.into_raw(), 0x1); in test_basic_access()
711 val = val.with_field_1(true); in test_basic_access()
712 assert!(val.field_1().into_bool()); in test_basic_access()
713 assert_eq!(val.into_raw(), 0x3); in test_basic_access()
715 val = val.with_const_field_3_2::<0x3>(); in test_basic_access()
716 assert_eq!(val.field_3_2(), 0x3); in test_basic_access()
717 assert_eq!(val.into_raw(), 0xF); in test_basic_access()
719 val = val.with_const_field_7_4::<0xA>(); in test_basic_access()
720 assert_eq!(val.field_7_4(), 0xA); in test_basic_access()
721 assert_eq!(val.into_raw(), 0xAF); in test_basic_access()
727 let mut val = TestU16::zeroed(); in test_infallible_conversion() localVariable
729 val = val.with_field_5_4(Priority::Low); in test_infallible_conversion()
730 assert_eq!(val.field_5_4(), Priority::Low); in test_infallible_conversion()
731 assert_eq!(val.into_raw() & 0x30, 0x00); in test_infallible_conversion()
733 val = val.with_field_5_4(Priority::Medium); in test_infallible_conversion()
734 assert_eq!(val.field_5_4(), Priority::Medium); in test_infallible_conversion()
735 assert_eq!(val.into_raw() & 0x30, 0x10); in test_infallible_conversion()
737 val = val.with_field_5_4(Priority::High); in test_infallible_conversion()
738 assert_eq!(val.field_5_4(), Priority::High); in test_infallible_conversion()
739 assert_eq!(val.into_raw() & 0x30, 0x20); in test_infallible_conversion()
741 val = val.with_field_5_4(Priority::Critical); in test_infallible_conversion()
742 assert_eq!(val.field_5_4(), Priority::Critical); in test_infallible_conversion()
743 assert_eq!(val.into_raw() & 0x30, 0x30); in test_infallible_conversion()
749 let mut val = TestU64::zeroed(); in test_fallible_conversion() localVariable
751 val = val.with_field_15_12(MemoryType::Unmapped); in test_fallible_conversion()
752 assert_eq!(val.field_15_12(), Ok(MemoryType::Unmapped)); in test_fallible_conversion()
753 val = val.with_field_15_12(MemoryType::Normal); in test_fallible_conversion()
754 assert_eq!(val.field_15_12(), Ok(MemoryType::Normal)); in test_fallible_conversion()
755 val = val.with_field_15_12(MemoryType::Device); in test_fallible_conversion()
756 assert_eq!(val.field_15_12(), Ok(MemoryType::Device)); in test_fallible_conversion()
757 val = val.with_field_15_12(MemoryType::Reserved); in test_fallible_conversion()
758 assert_eq!(val.field_15_12(), Ok(MemoryType::Reserved)); in test_fallible_conversion()
761 let raw = (val.into_raw() & !::kernel::bits::genmask_u64(12..=15)) | (0x7 << 12); in test_fallible_conversion()
768 let mut val = TestU16::zeroed(); in test_overlapping_fields() localVariable
770 val = val.with_field_5_4(Priority::High); // High == 2 == 0b10. in test_overlapping_fields()
771 assert_eq!(val.field_5_4(), Priority::High); in test_overlapping_fields()
772 assert_eq!(val.field_7_4(), 0x2); // Bits 7:6 == 0, bits 5:4 == 0b10. in test_overlapping_fields()
774 val = val.with_const_field_7_4::<0xF>(); in test_overlapping_fields()
775 assert_eq!(val.field_7_4(), 0xF); in test_overlapping_fields()
776 assert_eq!(val.field_5_4(), Priority::Critical); // Bits 5:4 == 0b11. in test_overlapping_fields()
779 let mut val = TestU8::zeroed() in test_overlapping_fields() localVariable
784 assert_eq!(val.into_raw(), 0xAF); in test_overlapping_fields()
786 val = val.with_field_7_0(0x55); in test_overlapping_fields()
787 assert_eq!(val.field_7_0(), 0x55); in test_overlapping_fields()
788 assert!(val.field_0().into_bool()); in test_overlapping_fields()
789 assert!(!val.field_1().into_bool()); in test_overlapping_fields()
790 assert_eq!(val.field_3_2(), 0x1); in test_overlapping_fields()
791 assert_eq!(val.field_7_4(), 0x5); in test_overlapping_fields()
799 let set_all_fields = |val: TestU64| { in test_unallocated_bits()
800 val.with_field_63(true) in test_unallocated_bits()
810 let val = set_all_fields(TestU64::from_raw(0)); in test_unallocated_bits() localVariable
811 assert_eq!(val.into_raw() & gap_bits, 0); in test_unallocated_bits()
814 let val = set_all_fields(TestU64::from_raw(gap_bits)); in test_unallocated_bits() localVariable
815 assert_eq!(val.into_raw() & gap_bits, gap_bits); in test_unallocated_bits()
820 let val = TestU64::zeroed().try_with_field_51_16(0x123456).unwrap(); in test_try_with() localVariable
821 assert_eq!(val.field_51_16(), 0x123456); in test_try_with()
826 let val = TestU64::zeroed() in test_try_with() localVariable
830 assert_eq!(val.field_51_16(), 0xABCDEF); in test_try_with()
831 assert!(val.field_0().into_bool()); in test_try_with()
838 let val = TestU64::from_raw(raw); in test_raw() localVariable
839 assert_eq!(u64::from(val), raw); in test_raw()
840 assert!(val.field_0().into_bool()); in test_raw()
841 assert!(val.field_1().into_bool()); in test_raw()
842 assert_eq!(val.field_11_9(), 0x7); in test_raw()
843 assert_eq!(val.field_51_16(), 0x3123); in test_raw()
844 assert_eq!(val.field_15_12(), Ok(MemoryType::Reserved)); in test_raw()
845 assert_eq!(val.field_61_52(), 0x3FF); in test_raw()
846 assert!(val.field_63().into_bool()); in test_raw()
849 let val = TestU16::from_raw(raw); in test_raw() localVariable
850 assert_eq!(u16::from(val), raw); in test_raw()
851 assert!(val.field_0().into_bool()); in test_raw()
852 assert_eq!(val.field_3_1(), 0x5); in test_raw()
853 assert_eq!(val.field_7_4(), 0xA); in test_raw()
854 assert_eq!(val.field_15_8(), 0x42); in test_raw()
857 let val = TestU8::from_raw(raw); in test_raw() localVariable
858 assert_eq!(u8::from(val), raw); in test_raw()
859 assert!(val.field_0().into_bool()); in test_raw()
860 assert!(val.field_1().into_bool()); in test_raw()
861 assert_eq!(val.field_3_2(), 0x3); in test_raw()
862 assert_eq!(val.field_7_4(), 0xA); in test_raw()
863 assert_eq!(val.field_7_0(), 0xAF); in test_raw()