diff --git a/lib/libc/include/aarch64-freebsd-none/arm/_align.h b/lib/libc/include/aarch64-freebsd-none/arm/_align.h index 61c22df04881e6a07cef5ed3c045d59a9c33c01d..5a6acf9624fba3a59f1684adbc70196715bcd94e 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/_align.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/_align.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _ARM_INCLUDE__ALIGN_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/_limits.h b/lib/libc/include/aarch64-freebsd-none/arm/_limits.h index bdcfd4d9797d382471b921fe9008193c1680c0d4..8dfdf8299b90c6053ac6733080d6c5805f80e4bf 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/_limits.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/_limits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE__LIMITS_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/_types.h b/lib/libc/include/aarch64-freebsd-none/arm/_types.h index ad50fd62c74e4d6c818be3ff66621d2d01f1a42d..847aff8d2b898bbd7252020084929ac2002c59a7 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/_types.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/_types.h @@ -32,9 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifndef _MACHINE__TYPES_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h b/lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h index d63a1132e55da1e2aaa010ea8dfc02f58db9f87a..8791e469f8a83a4f3bf9edb98518b4a6e38decbc 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/acle-compat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 ARM Ltd + * Copyright (c) 2024 Arm Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,157 +27,5 @@ */ #ifndef __ARM_ARCH - -/* ACLE standardises a set of pre-defines that describe the ARM architecture. - These were mostly implemented in GCC around GCC-4.8; older versions - have no, or only partial support. To provide a level of backwards - compatibility we try to work out what the definitions should be, given - the older pre-defines that GCC did produce. This isn't complete, but - it should be enough for use by routines that depend on this header. */ - -/* No need to handle ARMv8, GCC had ACLE support before that. */ - -#define __ARM_ACLE 101 - -# ifdef __ARM_ARCH_7__ -/* The common subset of ARMv7 in all profiles. */ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# endif - -# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 15 -# define __ARM_FEATURE_UNALIGNED -# ifdef __ARM_ARCH_7A__ -# define __ARM_ARCH_PROFILE 'A' -# else -# define __ARM_ARCH_PROFILE 'R' -# endif -# endif - -# ifdef __ARM_ARCH_7EM__ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# define __ARM_ARCH_PROFILE 'M' -# endif - -# ifdef __ARM_ARCH_7M__ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# define __ARM_ARCH_PROFILE 'M' -# endif - -# ifdef __ARM_ARCH_6T2__ -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 4 -# define __ARM_FEATURE_UNALIGNED -# endif - -# ifdef __ARM_ARCH_6M__ -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 1 -# define __ARM_ARCH_PROFILE 'M' -# endif - -# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \ - || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \ - || defined (__ARM_ARCH_6ZK__) -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 1 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_UNALIGNED -# ifndef __thumb__ -# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__) -# define __ARM_FEATURE_LDREX 15 -# else -# define __ARM_FEATURE_LDREX 4 -# endif -# endif -# endif - -# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__) -# define __ARM_ARCH 5 -# define __ARM_ARCH_ISA_ARM -# ifdef __ARM_ARCH_5TE__ -# define __ARM_ARCH_ISA_THUMB 1 -# endif -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_DSP -# endif - -# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__) -# define __ARM_ARCH 5 -# define __ARM_ARCH_ISA_ARM -# ifdef __ARM_ARCH_5TE__ -# define __ARM_ARCH_ISA_THUMB 1 -# endif -# define __ARM_FEATURE_CLZ -# endif - -# ifdef __ARM_ARCH_4T__ -# define __ARM_ARCH 4 -# define __ARM_ARCH_ISA_ARM -# define __ARM_ARCH_ISA_THUMB 1 -# endif - -# ifdef __ARM_ARCH_4__ -# define __ARM_ARCH 4 -# define __ARM_ARCH_ISA_ARM -# endif - -# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__) -# define __ARM_ARCH 3 -# define __ARM_ARCH_ISA_ARM -# endif - -# ifdef __ARM_ARCH_2__ -# define __ARM_ARCH 2 -# define __ARM_ARCH_ISA_ARM -# endif - -# ifdef __ARMEB__ -# define __ARM_BIG_ENDIAN -# endif - -/* If we still don't know what the target architecture is, then we're - probably not using GCC. */ -# ifndef __ARM_ARCH -# error Unable to determine architecture version. -# endif - -#endif /* __ARM_ARCH */ \ No newline at end of file +#error Your compiler is too old +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/asm.h b/lib/libc/include/aarch64-freebsd-none/arm/asm.h index fa7cbd6694327a80af79f049c9419f165ac8509a..52acdd60dbe92c7d56b3f981920e0f49603e6270 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/asm.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/asm.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 */ #ifndef _MACHINE_ASM_H_ @@ -176,7 +174,6 @@ # define RETne bxne lr # define RETc(c) bx##c lr -#if __ARM_ARCH >= 7 #define ISB isb #define DSB dsb #define DMB dmb @@ -190,12 +187,5 @@ #define ERET .word 0xe160006e #endif -#elif __ARM_ARCH == 6 -#include -#define ISB mcr CP15_CP15ISB -#define DSB mcr CP15_CP15DSB -#define DMB mcr CP15_CP15DMB -#define WFI mcr CP15_CP15WFI -#endif #endif /* !_MACHINE_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/atomic.h b/lib/libc/include/aarch64-freebsd-none/arm/atomic.h index f4e9fb5c1b294a638866678922b06896ba9eae09..9a8ae6bc124e57726e026638b30bf77c668cc0dc 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/atomic.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/atomic.h @@ -41,15 +41,9 @@ #include -#if __ARM_ARCH >= 7 #define isb() __asm __volatile("isb" : : : "memory") #define dsb() __asm __volatile("dsb" : : : "memory") #define dmb() __asm __volatile("dmb" : : : "memory") -#else -#define isb() __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory") -#define dsb() __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory") -#define dmb() __asm __volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory") -#endif #define mb() dmb() #define wmb() dmb() @@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val) } static __inline uint32_t -atomic_load_acq_32(volatile uint32_t *p) +atomic_load_acq_32(const volatile uint32_t *p) { uint32_t v; @@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p) } static __inline uint64_t -atomic_load_64(volatile uint64_t *p) +atomic_load_64(const volatile uint64_t *p) { uint64_t ret; @@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p) } static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) +atomic_load_acq_64(const volatile uint64_t *p) { uint64_t ret; @@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p) } static __inline u_long -atomic_load_acq_long(volatile u_long *p) +atomic_load_acq_long(const volatile u_long *p) { u_long v; @@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v) return (atomic_testandclear_32((volatile uint32_t *)p, v)); } -#define atomic_testandclear_long atomic_testandclear_long - static __inline int atomic_testandclear_64(volatile uint64_t *p, u_int v) @@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v) return (atomic_testandset_32((volatile uint32_t *)p, v)); } -#define atomic_testandset_long atomic_testandset_long + +static __inline int +atomic_testandset_acq_long(volatile u_long *p, u_int v) +{ + int ret; + + ret = atomic_testandset_32((volatile uint32_t *)p, v); + dmb(); + return (ret); +} static __inline int atomic_testandset_64(volatile uint64_t *p, u_int v) @@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void) dmb(); } +#define atomic_add_ptr atomic_add_32 +#define atomic_add_acq_ptr atomic_add_acq_32 +#define atomic_add_rel_ptr atomic_add_rel_32 +#define atomic_subtract_ptr atomic_subtract_32 +#define atomic_subtract_acq_ptr atomic_subtract_acq_32 +#define atomic_subtract_rel_ptr atomic_subtract_rel_32 #define atomic_clear_ptr atomic_clear_32 #define atomic_clear_acq_ptr atomic_clear_acq_32 #define atomic_clear_rel_ptr atomic_clear_rel_32 @@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void) #define atomic_set_acq_ptr atomic_set_acq_32 #define atomic_set_rel_ptr atomic_set_rel_32 #define atomic_fcmpset_ptr atomic_fcmpset_32 -#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32 #define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32 +#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32 #define atomic_cmpset_ptr atomic_cmpset_32 #define atomic_cmpset_acq_ptr atomic_cmpset_acq_32 #define atomic_cmpset_rel_ptr atomic_cmpset_rel_32 +#define atomic_fetchadd_ptr atomic_fetchadd_32 +#define atomic_readandclear_ptr atomic_readandclear_32 #define atomic_load_acq_ptr atomic_load_acq_32 #define atomic_store_rel_ptr atomic_store_rel_32 #define atomic_swap_ptr atomic_swap_32 -#define atomic_readandclear_ptr atomic_readandclear_32 +#define atomic_testandset_ptr atomic_testandset_32 +#define atomic_testandclear_ptr atomic_testandclear_32 #define atomic_add_int atomic_add_32 #define atomic_add_acq_int atomic_add_acq_32 @@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void) #define atomic_store_rel_int atomic_store_rel_32 #define atomic_swap_int atomic_swap_32 -/* - * For: - * - atomic_load_acq_8 - * - atomic_load_acq_16 - * - atomic_testandset_acq_long - */ #include +#define atomic_set_short atomic_set_16 +#define atomic_clear_short atomic_clear_16 + #endif /* _MACHINE_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/cpu.h b/lib/libc/include/aarch64-freebsd-none/arm/cpu.h index cc6c423703cfc57fe832e904227d4fbcc22886fe..edba80742197b00e68694d05177236c8f5c9dbfe 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/cpu.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/cpu.h @@ -45,13 +45,7 @@ void cpu_halt(void); * unconditionally with -DSMP. Although it looks like a bug, * handle this case here and in #elif condition in ARM_SMP_UP macro. */ -#if __ARM_ARCH <= 6 && defined(SMP) && !defined(KLD_MODULE) -#error SMP option is not supported on ARMv6 -#endif -#if __ARM_ARCH <= 6 && defined(SMP_ON_UP) -#error SMP_ON_UP option is only supported on ARMv7+ CPUs -#endif #if !defined(SMP) && defined(SMP_ON_UP) #error SMP option must be defined for SMP_ON_UP option @@ -68,7 +62,7 @@ do { \ up_code; \ } \ } while (0) -#elif defined(SMP) && __ARM_ARCH > 6 +#elif defined(SMP) #define ARM_SMP_UP(smp_code, up_code) \ do { \ smp_code; \ @@ -146,15 +140,15 @@ fname(uint64_t reg) \ /* TLB */ _WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */ #endif _WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */ #endif _WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */ #endif _WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */ @@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0)) /* Cache and Branch predictor */ _WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */ #endif _WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */ _WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */ _WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */ _WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */ -#if __ARM_ARCH >= 7 _WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */ -#endif _WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */ _WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */ _WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */ _WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */ #endif _WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */ @@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0)) _WF1(cp15_nmrr_set, CP15_NMRR(%0)) _RF0(cp15_ttbr_get, CP15_TTBR0(%0)) _RF0(cp15_dfar_get, CP15_DFAR(%0)) -#if __ARM_ARCH >= 7 _RF0(cp15_ifar_get, CP15_IFAR(%0)) _RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0)) -#endif _RF0(cp15_actlr_get, CP15_ACTLR(%0)) _WF1(cp15_actlr_set, CP15_ACTLR(%0)) _WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0)) @@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0)) /* Performance Monitor registers */ -#if __ARM_ARCH == 6 && defined(CPU_ARM1176) -_RF0(cp15_pmuserenr_get, CP15_PMUSERENR(%0)) -_WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0)) -_RF0(cp15_pmcr_get, CP15_PMCR(%0)) -_WF1(cp15_pmcr_set, CP15_PMCR(%0)) -_RF0(cp15_pmccntr_get, CP15_PMCCNTR(%0)) -_WF1(cp15_pmccntr_set, CP15_PMCCNTR(%0)) -#elif __ARM_ARCH > 6 _RF0(cp15_pmcr_get, CP15_PMCR(%0)) _WF1(cp15_pmcr_set, CP15_PMCR(%0)) _RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0)) @@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0)) _RF0(cp15_pminten_get, CP15_PMINTENSET(%0)) _WF1(cp15_pminten_set, CP15_PMINTENSET(%0)) _WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0)) -#endif _RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0)) _WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0)) @@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size) } /* Broadcasting operations. */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) static __inline void tlb_flush_all(void) @@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size) ); dsb(); } -#else /* __ARM_ARCH < 7 */ +#else /* !SMP */ #define tlb_flush_all() tlb_flush_all_local() #define tlb_flush_all_ng() tlb_flush_all_ng_local() #define tlb_flush(va) tlb_flush_local(va) #define tlb_flush_range(va, size) tlb_flush_range_local(va, size) -#endif /* __ARM_ARCH < 7 */ +#endif /* !SMP */ /* * Cache maintenance operations. @@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size) va &= ~cpuinfo.dcache_line_mask; for ( ; va < eva; va += cpuinfo.dcache_line_size) { -#if __ARM_ARCH >= 7 _CP15_DCCMVAU(va); -#else - _CP15_DCCMVAC(va); -#endif } dsb(); ARM_SMP_UP( @@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size) dsb(); va &= ~cpuinfo.dcache_line_mask; for ( ; va < eva; va += cpuinfo.dcache_line_size) { -#if __ARM_ARCH >= 7 _CP15_DCCMVAU(va); -#else - _CP15_DCCMVAC(va); -#endif } dsb(); } @@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr) static __inline uint64_t get_cyclecount(void) { -#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176)) -#if (__ARM_ARCH > 6) && defined(DEV_PMU) +#if defined(DEV_PMU) if (pmu_attched) { u_int cpu; uint64_t h, h2; @@ -711,12 +683,6 @@ get_cyclecount(void) } else #endif return cp15_pmccntr_get(); -#else /* No performance counters, so use nanotime(9). */ - struct timespec tv; - - nanotime(&tv); - return (tv.tv_sec * (uint64_t)1000000000ull + tv.tv_nsec); -#endif } #endif @@ -729,7 +695,7 @@ get_cyclecount(void) #define cpu_spinwait() /* nothing */ #define cpu_lock_delay() DELAY(1) -#define ARM_NVEC 8 +#define ARM_NVEC 7 #define ARM_VEC_ALL 0xffffffff extern vm_offset_t vector_page; diff --git a/lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h b/lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h index 0f3b1a139be94c1c0082d4c9ac3acc7c02ef4bee..95bcd2b27b0da189e186bbd725ef5d84301c19a9 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/cpufunc.h @@ -97,9 +97,6 @@ void armv7_cpu_sleep (int); void pj4b_config (void); #endif -#if defined(CPU_ARM1176) -void arm11x6_sleep (int); /* no ref. for errata */ -#endif /* diff --git a/lib/libc/include/aarch64-freebsd-none/arm/fenv.h b/lib/libc/include/aarch64-freebsd-none/arm/fenv.h index 4aa93a759c26ab4f0833e575ebeca5a096fd2500..ca9d01ef40f0ad138ac9dba0666d2d9c8195f4dd 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/fenv.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/fenv.h @@ -29,6 +29,7 @@ #ifndef _FENV_H_ #define _FENV_H_ +#include #include #ifndef __fenv_static diff --git a/lib/libc/include/aarch64-freebsd-none/arm/float.h b/lib/libc/include/aarch64-freebsd-none/arm/float.h index 8f8a41e8562d266052d13b8758aaf49dbb3eab3a..b0ab1592b2ad5e4c455bd10be0937b8f0363afc3 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/float.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/float.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h b/lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h index f3ef2992bc3bb958ee3ce0893619b1ae7d6ba02d..417517432cf5ede516d892c610415fa71808332a 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/ieeefp.h @@ -49,4 +49,14 @@ typedef enum { #define fp_except_t int +/* Augment the userland declarations. */ +__BEGIN_DECLS +extern fp_rnd_t fpgetround(void); +extern fp_rnd_t fpsetround(fp_rnd_t); +extern fp_except_t fpgetmask(void); +extern fp_except_t fpsetmask(fp_except_t); +extern fp_except_t fpgetsticky(void); +extern fp_except_t fpsetsticky(fp_except_t); +__END_DECLS + #endif /* _MACHINE_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/param.h b/lib/libc/include/aarch64-freebsd-none/arm/param.h index edab4a72b46fbcf10753ac01d44055ca62bef11a..6fab13f3955c2531bc990470d532b2484bad6516 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/param.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/param.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _ARM_INCLUDE_PARAM_H_ @@ -51,17 +49,11 @@ #define STACKALIGNBYTES (8 - 1) #define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES) -#define __PCI_REROUTE_INTERRUPT - #ifndef MACHINE #define MACHINE "arm" #endif #ifndef MACHINE_ARCH -#if __ARM_ARCH >= 7 #define MACHINE_ARCH "armv7" -#else -#define MACHINE_ARCH "armv6" -#endif #endif #ifdef SMP @@ -76,6 +68,8 @@ #define MAXMEMDOM 1 #endif +#define __HAVE_STATIC_DEVMAP + #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) /* @@ -129,17 +123,10 @@ /* * Mach derived conversion macros */ -#define trunc_page(x) ((x) & ~PAGE_MASK) -#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) #define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK) #define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) -#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) - #define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT) #define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT) -#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) - #endif /* !_ARM_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/pmap.h b/lib/libc/include/aarch64-freebsd-none/arm/pmap.h index 78b6e5b2c14820fb55bba7abd7bd5e1927f0f100..3b18349d881383f7727d1c2800b43c7b6b0f5f15 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/pmap.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/pmap.h @@ -39,9 +39,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 */ @@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */ * vtopte2(). */ void pmap_bootstrap(vm_offset_t); -void pmap_kenter(vm_offset_t, vm_paddr_t); +void pmap_kenter(vm_offset_t, vm_size_t, vm_paddr_t, int); void pmap_kremove(vm_offset_t); -boolean_t pmap_page_is_mapped(vm_page_t); +bool pmap_page_is_mapped(vm_page_t); bool pmap_ps_enabled(pmap_t pmap); void pmap_tlb_flush(pmap_t, vm_offset_t); @@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t); #define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva) void *pmap_mapdev(vm_paddr_t, vm_size_t); +void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t); void pmap_unmapdev(void *, vm_size_t); -static inline void * -pmap_mapdev_attr(vm_paddr_t addr __unused, vm_size_t size __unused, - int attr __unused) -{ - panic("%s is not implemented yet!\n", __func__); -} - struct pcb; void pmap_set_pcb_pagedir(pmap_t, struct pcb *); diff --git a/lib/libc/include/aarch64-freebsd-none/arm/proc.h b/lib/libc/include/aarch64-freebsd-none/arm/proc.h index b37f5a690ecdccf4ce08016d4a540443b6dc6532..a142642becf5b36fbb2ee8a0db6084c262db3699 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/proc.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/proc.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 */ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/profile.h b/lib/libc/include/aarch64-freebsd-none/arm/profile.h index 6154b6b662863e09d51e30695d89ed821568f438..83f743ca16cfaf99f4f1b3e93d7a19a7a57cf723 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/profile.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/profile.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_PROFILE_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/reloc.h b/lib/libc/include/aarch64-freebsd-none/arm/reloc.h index 9a7855cbeeda86d88bf011e9719fda225eb87101..f318d27664e39c84712f8ee23bbb601e405619f0 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/reloc.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/reloc.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)reloc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _MACHINE_RELOC_H_ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/resource.h b/lib/libc/include/aarch64-freebsd-none/arm/resource.h index 8edfc1ab1ea31fb4f509c044e40b8fd29b4e9a6d..c22c873f6b011a3382b8a58020fe7e6c93c43788 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/resource.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/resource.h @@ -40,8 +40,6 @@ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ #define SYS_RES_GPIO 5 /* general purpose i/o */ -#ifdef NEW_PCIB #define PCI_RES_BUS 6 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/runq.h b/lib/libc/include/aarch64-freebsd-none/arm/runq.h deleted file mode 100644 index 63b30d582a975d12398ac7d6df338e6f19996202..0000000000000000000000000000000000000000 --- a/lib/libc/include/aarch64-freebsd-none/arm/runq.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (2) /* Number of priority status words. */ -#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (ffs(word) - 1) - -/* - * Type of run queue status word. - */ -typedef u_int32_t rqb_word_t; - -#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/arm/signal.h b/lib/libc/include/aarch64-freebsd-none/arm/signal.h index d81c04382e06b8ab59e503c98b4fde5cb99a259e..df41f25faac956746109b3dc9874d551cbb8797f 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/signal.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/signal.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17 */ diff --git a/lib/libc/include/aarch64-freebsd-none/arm/sysarch.h b/lib/libc/include/aarch64-freebsd-none/arm/sysarch.h index 4a37651d15dd44134c800eb01c9ab477133559c1..4536de8ecb208eb4695f8f3e9aeb2383c3fc6eb8 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/sysarch.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/sysarch.h @@ -38,6 +38,8 @@ #ifndef _ARM_SYSARCH_H_ #define _ARM_SYSARCH_H_ +#include + #include #ifndef LOCORE diff --git a/lib/libc/include/aarch64-freebsd-none/arm/sysreg.h b/lib/libc/include/aarch64-freebsd-none/arm/sysreg.h index d83305a478d43234d11847d2d4477775f0b424e1..ce88a0a4b92e9268bad84204a7e5c1ef7ddeaabe 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/sysreg.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/sysreg.h @@ -127,11 +127,9 @@ /* From ARMv6: */ #define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */ -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */ #define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */ -#endif /* * CP15 C6 registers @@ -147,7 +145,7 @@ /* * CP15 C7 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) /* From ARMv7: */ #define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */ #define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */ @@ -157,17 +155,9 @@ #define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */ #define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */ -#if __ARM_ARCH == 6 -/* Deprecated in ARMv7 */ -#define CP15_CP15ISB p15, 0, r0, c7, c5, 4 /* ISB */ -#endif #define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */ #define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */ -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCIALL p15, 0, r0, c7, c6, 0 /* Data cache invalidate all */ -#endif #define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */ #define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */ @@ -176,43 +166,25 @@ #define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */ #define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */ -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */ #define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */ #define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */ #define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */ -#endif -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCCALL p15, 0, r0, c7, c10, 0 /* Data cache clean all */ -#endif #define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */ #define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */ -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_CP15DSB p15, 0, r0, c7, c10, 4 /* DSB */ -#define CP15_CP15DMB p15, 0, r0, c7, c10, 5 /* DMB */ -#define CP15_CP15WFI p15, 0, r0, c7, c0, 4 /* WFI */ -#endif -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */ -#endif -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCCIALL p15, 0, r0, c7, c14, 0 /* Data cache clean and invalidate all */ -#endif #define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */ #define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */ /* * CP15 C8 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) /* From ARMv7: */ #define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */ #define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */ @@ -232,11 +204,6 @@ /* * CP15 C9 registers */ -#if __ARM_ARCH == 6 && defined(CPU_ARM1176) -#define CP15_PMUSERENR(rr) p15, 0, rr, c15, c9, 0 /* Access Validation Control Register */ -#define CP15_PMCR(rr) p15, 0, rr, c15, c12, 0 /* Performance Monitor Control Register */ -#define CP15_PMCCNTR(rr) p15, 0, rr, c15, c12, 1 /* PM Cycle Count Register */ -#else #define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */ #define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */ #define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */ @@ -250,7 +217,6 @@ #define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */ #define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */ #define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */ -#endif /* * CP15 C10 registers diff --git a/lib/libc/include/aarch64-freebsd-none/arm/vmparam.h b/lib/libc/include/aarch64-freebsd-none/arm/vmparam.h index e5b6b491f701a9dc9600d5d100b1a420b8a6c9e0..92285fcfdc2546a6bedbb107f46ac97b9bb0614a 100644 --- a/lib/libc/include/aarch64-freebsd-none/arm/vmparam.h +++ b/lib/libc/include/aarch64-freebsd-none/arm/vmparam.h @@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address; * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 0 #endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/fenv.h b/lib/libc/include/aarch64-freebsd-none/fenv.h index 089f228e668e73e27fda509ff087a65ce2e0da6b..280ffa22a2b02cbcc18be3aa1f6dfeb7f2bef7dd 100644 --- a/lib/libc/include/aarch64-freebsd-none/fenv.h +++ b/lib/libc/include/aarch64-freebsd-none/fenv.h @@ -31,6 +31,7 @@ #ifndef _FENV_H_ #define _FENV_H_ +#include #include #ifndef __fenv_static diff --git a/lib/libc/include/aarch64-freebsd-none/float.h b/lib/libc/include/aarch64-freebsd-none/float.h index 2ac1797774570db93ef280375904c96e0d351541..c6f1432f6226122adbbc377d26cee067b44ee1f5 100644 --- a/lib/libc/include/aarch64-freebsd-none/float.h +++ b/lib/libc/include/aarch64-freebsd-none/float.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifdef __arm__ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/_align.h b/lib/libc/include/aarch64-freebsd-none/machine/_align.h index 1fa6ddf1e4c1b19bb5349a6c7a7b04441dd21181..b416b0198ab789bc6242d4d44ef9680aae291317 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/_align.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/_align.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifdef __arm__ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/_bus.h b/lib/libc/include/aarch64-freebsd-none/machine/_bus.h deleted file mode 100644 index 8e9a287dc2ee9cf4479e64d850b296b5cf26598c..0000000000000000000000000000000000000000 --- a/lib/libc/include/aarch64-freebsd-none/machine/_bus.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE__BUS_H_ -#define _MACHINE__BUS_H_ - -/* - * Addresses (in bus space). - */ -typedef u_long bus_addr_t; -typedef u_long bus_size_t; - -/* - * Access methods for bus space. - */ -typedef u_long bus_space_handle_t; -typedef struct bus_space *bus_space_tag_t; - -#endif /* !_MACHINE__BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/_limits.h b/lib/libc/include/aarch64-freebsd-none/machine/_limits.h index d8080f73d7b4e3e046e65ba10f9076a60eef36a7..44fbd2c293fbe127c4f06e5e57215c5180f66be6 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/_limits.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/_limits.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifdef __arm__ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/_types.h b/lib/libc/include/aarch64-freebsd-none/machine/_types.h index 0b42e2cc2999006cff3a46da9f46b8ad30226254..78f216342bf2e9ce0c0e1934424e0713ecdabbb6 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/_types.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/_types.h @@ -26,9 +26,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifdef __arm__ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/armreg.h b/lib/libc/include/aarch64-freebsd-none/machine/armreg.h index 166b8912f9067adf1c9a2572f0e9ba0df2f94a17..7f51a632a40c95d036839bb4e3d6278a9b724115 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/armreg.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/armreg.h @@ -36,29 +36,6 @@ #define INSN_SIZE 4 -#define MRS_MASK 0xfff00000 -#define MRS_VALUE 0xd5300000 -#define MRS_SPECIAL(insn) ((insn) & 0x000fffe0) -#define MRS_REGISTER(insn) ((insn) & 0x0000001f) -#define MRS_Op0_SHIFT 19 -#define MRS_Op0_MASK 0x00080000 -#define MRS_Op1_SHIFT 16 -#define MRS_Op1_MASK 0x00070000 -#define MRS_CRn_SHIFT 12 -#define MRS_CRn_MASK 0x0000f000 -#define MRS_CRm_SHIFT 8 -#define MRS_CRm_MASK 0x00000f00 -#define MRS_Op2_SHIFT 5 -#define MRS_Op2_MASK 0x000000e0 -#define MRS_Rt_SHIFT 0 -#define MRS_Rt_MASK 0x0000001f -#define __MRS_REG(op0, op1, crn, crm, op2) \ - (((op0) << MRS_Op0_SHIFT) | ((op1) << MRS_Op1_SHIFT) | \ - ((crn) << MRS_CRn_SHIFT) | ((crm) << MRS_CRm_SHIFT) | \ - ((op2) << MRS_Op2_SHIFT)) -#define MRS_REG(reg) \ - __MRS_REG(reg##_op0, reg##_op1, reg##_CRn, reg##_CRm, reg##_op2) - #define __MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \ S##op0##_##op1##_C##crn##_C##crm##_##op2 #define _MRS_REG_ALT_NAME(op0, op1, crn, crm, op2) \ @@ -231,8 +208,21 @@ #define CLIDR_CTYPE_ID 0x3 /* Split instruction and data */ #define CLIDR_CTYPE_UNIFIED 0x4 /* Unified */ +/* CNTKCTL_EL1 - Counter-timer Kernel Control Register */ +#define CNTKCTL_EL1_op0 3 +#define CNTKCTL_EL1_op1 0 +#define CNTKCTL_EL1_CRn 14 +#define CNTKCTL_EL1_CRm 1 +#define CNTKCTL_EL1_op2 0 + +/* CNTKCTL_EL12 - Counter-timer Kernel Control Register */ +#define CNTKCTL_EL12_op0 3 +#define CNTKCTL_EL12_op1 5 +#define CNTKCTL_EL12_CRn 14 +#define CNTKCTL_EL12_CRm 1 +#define CNTKCTL_EL12_op2 0 + /* CNTP_CTL_EL0 - Counter-timer Physical Timer Control register */ -#define CNTP_CTL_EL0 MRS_REG(CNTP_CTL_EL0) #define CNTP_CTL_EL0_op0 3 #define CNTP_CTL_EL0_op1 3 #define CNTP_CTL_EL0_CRn 14 @@ -243,7 +233,6 @@ #define CNTP_CTL_ISTATUS (1 << 2) /* CNTP_CVAL_EL0 - Counter-timer Physical Timer CompareValue register */ -#define CNTP_CVAL_EL0 MRS_REG(CNTP_CVAL_EL0) #define CNTP_CVAL_EL0_op0 3 #define CNTP_CVAL_EL0_op1 3 #define CNTP_CVAL_EL0_CRn 14 @@ -251,7 +240,6 @@ #define CNTP_CVAL_EL0_op2 2 /* CNTP_TVAL_EL0 - Counter-timer Physical Timer TimerValue register */ -#define CNTP_TVAL_EL0 MRS_REG(CNTP_TVAL_EL0) #define CNTP_TVAL_EL0_op0 3 #define CNTP_TVAL_EL0_op1 3 #define CNTP_TVAL_EL0_CRn 14 @@ -259,15 +247,42 @@ #define CNTP_TVAL_EL0_op2 0 /* CNTPCT_EL0 - Counter-timer Physical Count register */ -#define CNTPCT_EL0 MRS_REG(CNTPCT_EL0) +#define CNTPCT_EL0_ISS ISS_MSR_REG(CNTPCT_EL0) #define CNTPCT_EL0_op0 3 #define CNTPCT_EL0_op1 3 #define CNTPCT_EL0_CRn 14 #define CNTPCT_EL0_CRm 0 #define CNTPCT_EL0_op2 1 +/* CNTV_CTL_EL0 - Counter-timer Virtual Timer Control register */ +#define CNTV_CTL_EL0_op0 3 +#define CNTV_CTL_EL0_op1 3 +#define CNTV_CTL_EL0_CRn 14 +#define CNTV_CTL_EL0_CRm 3 +#define CNTV_CTL_EL0_op2 1 + +/* CNTV_CTL_EL02 - Counter-timer Virtual Timer Control register */ +#define CNTV_CTL_EL02_op0 3 +#define CNTV_CTL_EL02_op1 5 +#define CNTV_CTL_EL02_CRn 14 +#define CNTV_CTL_EL02_CRm 3 +#define CNTV_CTL_EL02_op2 1 + +/* CNTV_CVAL_EL0 - Counter-timer Virtual Timer CompareValue register */ +#define CNTV_CVAL_EL0_op0 3 +#define CNTV_CVAL_EL0_op1 3 +#define CNTV_CVAL_EL0_CRn 14 +#define CNTV_CVAL_EL0_CRm 3 +#define CNTV_CVAL_EL0_op2 2 + +/* CNTV_CVAL_EL02 - Counter-timer Virtual Timer CompareValue register */ +#define CNTV_CVAL_EL02_op0 3 +#define CNTV_CVAL_EL02_op1 5 +#define CNTV_CVAL_EL02_CRn 14 +#define CNTV_CVAL_EL02_CRm 3 +#define CNTV_CVAL_EL02_op2 2 + /* CONTEXTIDR_EL1 - Context ID register */ -#define CONTEXTIDR_EL1 MRS_REG(CONTEXTIDR_EL1) #define CONTEXTIDR_EL1_REG MRS_REG_ALT_NAME(CONTEXTIDR_EL1) #define CONTEXTIDR_EL1_op0 3 #define CONTEXTIDR_EL1_op1 0 @@ -315,36 +330,52 @@ #define CSSELR_InD 0x00000001 /* CTR_EL0 - Cache Type Register */ +#define CTR_EL0_REG MRS_REG_ALT_NAME(CTR_EL0) +#define CTR_EL0_ISS ISS_MSR_REG(CTR_EL0) +#define CTR_EL0_op0 3 +#define CTR_EL0_op1 3 +#define CTR_EL0_CRn 0 +#define CTR_EL0_CRm 0 +#define CTR_EL0_op2 1 #define CTR_RES1 (1 << 31) #define CTR_TminLine_SHIFT 32 #define CTR_TminLine_MASK (UL(0x3f) << CTR_TminLine_SHIFT) #define CTR_TminLine_VAL(reg) ((reg) & CTR_TminLine_MASK) #define CTR_DIC_SHIFT 29 +#define CTR_DIC_WIDTH 1 #define CTR_DIC_MASK (0x1 << CTR_DIC_SHIFT) #define CTR_DIC_VAL(reg) ((reg) & CTR_DIC_MASK) +#define CTR_DIC_NONE (0x0 << CTR_DIC_SHIFT) +#define CTR_DIC_IMPL (0x1 << CTR_DIC_SHIFT) #define CTR_IDC_SHIFT 28 +#define CTR_IDC_WIDTH 1 #define CTR_IDC_MASK (0x1 << CTR_IDC_SHIFT) #define CTR_IDC_VAL(reg) ((reg) & CTR_IDC_MASK) +#define CTR_IDC_NONE (0x0 << CTR_IDC_SHIFT) +#define CTR_IDC_IMPL (0x1 << CTR_IDC_SHIFT) #define CTR_CWG_SHIFT 24 +#define CTR_CWG_WIDTH 4 #define CTR_CWG_MASK (0xf << CTR_CWG_SHIFT) #define CTR_CWG_VAL(reg) ((reg) & CTR_CWG_MASK) #define CTR_CWG_SIZE(reg) (4 << (CTR_CWG_VAL(reg) >> CTR_CWG_SHIFT)) #define CTR_ERG_SHIFT 20 +#define CTR_ERG_WIDTH 4 #define CTR_ERG_MASK (0xf << CTR_ERG_SHIFT) #define CTR_ERG_VAL(reg) ((reg) & CTR_ERG_MASK) #define CTR_ERG_SIZE(reg) (4 << (CTR_ERG_VAL(reg) >> CTR_ERG_SHIFT)) #define CTR_DLINE_SHIFT 16 +#define CTR_DLINE_WIDTH 4 #define CTR_DLINE_MASK (0xf << CTR_DLINE_SHIFT) #define CTR_DLINE_VAL(reg) ((reg) & CTR_DLINE_MASK) #define CTR_DLINE_SIZE(reg) (4 << (CTR_DLINE_VAL(reg) >> CTR_DLINE_SHIFT)) #define CTR_L1IP_SHIFT 14 +#define CTR_L1IP_WIDTH 2 #define CTR_L1IP_MASK (0x3 << CTR_L1IP_SHIFT) #define CTR_L1IP_VAL(reg) ((reg) & CTR_L1IP_MASK) -#define CTR_L1IP_VPIPT (0 << CTR_L1IP_SHIFT) -#define CTR_L1IP_AIVIVT (1 << CTR_L1IP_SHIFT) #define CTR_L1IP_VIPT (2 << CTR_L1IP_SHIFT) #define CTR_L1IP_PIPT (3 << CTR_L1IP_SHIFT) #define CTR_ILINE_SHIFT 0 +#define CTR_ILINE_WIDTH 4 #define CTR_ILINE_MASK (0xf << CTR_ILINE_SHIFT) #define CTR_ILINE_VAL(reg) ((reg) & CTR_ILINE_MASK) #define CTR_ILINE_SIZE(reg) (4 << (CTR_ILINE_VAL(reg) >> CTR_ILINE_SHIFT)) @@ -363,7 +394,7 @@ #define DAIF_I (1 << 1) #define DAIF_F (1 << 0) #define DAIF_ALL (DAIF_D | DAIF_A | DAIF_I | DAIF_F) -#define DAIF_INTR (DAIF_I) /* All exceptions that pass */ +#define DAIF_INTR (DAIF_I | DAIF_F) /* All exceptions that pass */ /* through the intr framework */ /* DBGBCR_EL1 - Debug Breakpoint Control Registers */ @@ -435,7 +466,6 @@ #define DCZID_BS_SIZE(reg) (((reg) & DCZID_BS_MASK) >> DCZID_BS_SHIFT) /* DBGAUTHSTATUS_EL1 */ -#define DBGAUTHSTATUS_EL1 MRS_REG(DBGAUTHSTATUS_EL1) #define DBGAUTHSTATUS_EL1_op0 2 #define DBGAUTHSTATUS_EL1_op1 0 #define DBGAUTHSTATUS_EL1_CRn 7 @@ -443,7 +473,6 @@ #define DBGAUTHSTATUS_EL1_op2 6 /* DBGCLAIMCLR_EL1 */ -#define DBGCLAIMCLR_EL1 MRS_REG(DBGCLAIMCLR_EL1) #define DBGCLAIMCLR_EL1_op0 2 #define DBGCLAIMCLR_EL1_op1 0 #define DBGCLAIMCLR_EL1_CRn 7 @@ -451,7 +480,6 @@ #define DBGCLAIMCLR_EL1_op2 6 /* DBGCLAIMSET_EL1 */ -#define DBGCLAIMSET_EL1 MRS_REG(DBGCLAIMSET_EL1) #define DBGCLAIMSET_EL1_op0 2 #define DBGCLAIMSET_EL1_op1 0 #define DBGCLAIMSET_EL1_CRn 7 @@ -459,7 +487,6 @@ #define DBGCLAIMSET_EL1_op2 6 /* DBGPRCR_EL1 */ -#define DBGPRCR_EL1 MRS_REG(DBGPRCR_EL1) #define DBGPRCR_EL1_op0 2 #define DBGPRCR_EL1_op1 0 #define DBGPRCR_EL1_CRn 1 @@ -540,12 +567,14 @@ #define ISS_MSR_REG_MASK \ (ISS_MSR_OP0_MASK | ISS_MSR_OP2_MASK | ISS_MSR_OP1_MASK | \ ISS_MSR_CRn_MASK | ISS_MSR_CRm_MASK) +#define __ISS_MSR_REG(op0, op1, crn, crm, op2) \ + (((op0) << ISS_MSR_OP0_SHIFT) | \ + ((op1) << ISS_MSR_OP1_SHIFT) | \ + ((crn) << ISS_MSR_CRn_SHIFT) | \ + ((crm) << ISS_MSR_CRm_SHIFT) | \ + ((op2) << ISS_MSR_OP2_SHIFT)) #define ISS_MSR_REG(reg) \ - (((reg ## _op0) << ISS_MSR_OP0_SHIFT) | \ - ((reg ## _op1) << ISS_MSR_OP1_SHIFT) | \ - ((reg ## _CRn) << ISS_MSR_CRn_SHIFT) | \ - ((reg ## _CRm) << ISS_MSR_CRm_SHIFT) | \ - ((reg ## _op2) << ISS_MSR_OP2_SHIFT)) + __ISS_MSR_REG(reg##_op0, reg##_op1, reg##_CRn, reg##_CRm, reg##_op2) #define ISS_DATA_ISV_SHIFT 24 #define ISS_DATA_ISV (0x01 << ISS_DATA_ISV_SHIFT) @@ -667,7 +696,6 @@ #define ICC_PMR_EL1_PRIO_MASK (0xFFUL) /* ICC_SGI1R_EL1 */ -#define ICC_SGI1R_EL1 MRS_REG(ICC_SGI1R_EL1) #define ICC_SGI1R_EL1_op0 3 #define ICC_SGI1R_EL1_op1 0 #define ICC_SGI1R_EL1_CRn 12 @@ -697,8 +725,8 @@ #define ICC_SRE_EL1_SRE (1U << 0) /* ID_AA64AFR0_EL1 */ -#define ID_AA64AFR0_EL1 MRS_REG(ID_AA64AFR0_EL1) #define ID_AA64AFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR0_EL1) +#define ID_AA64AFR0_EL1_ISS ISS_MSR_REG(ID_AA64AFR0_EL1) #define ID_AA64AFR0_EL1_op0 3 #define ID_AA64AFR0_EL1_op1 0 #define ID_AA64AFR0_EL1_CRn 0 @@ -706,8 +734,8 @@ #define ID_AA64AFR0_EL1_op2 4 /* ID_AA64AFR1_EL1 */ -#define ID_AA64AFR1_EL1 MRS_REG(ID_AA64AFR1_EL1) #define ID_AA64AFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64AFR1_EL1) +#define ID_AA64AFR1_EL1_ISS ISS_MSR_REG(ID_AA64AFR1_EL1) #define ID_AA64AFR1_EL1_op0 3 #define ID_AA64AFR1_EL1_op1 0 #define ID_AA64AFR1_EL1_CRn 0 @@ -715,14 +743,15 @@ #define ID_AA64AFR1_EL1_op2 5 /* ID_AA64DFR0_EL1 */ -#define ID_AA64DFR0_EL1 MRS_REG(ID_AA64DFR0_EL1) #define ID_AA64DFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR0_EL1) +#define ID_AA64DFR0_EL1_ISS ISS_MSR_REG(ID_AA64DFR0_EL1) #define ID_AA64DFR0_EL1_op0 3 #define ID_AA64DFR0_EL1_op1 0 #define ID_AA64DFR0_EL1_CRn 0 #define ID_AA64DFR0_EL1_CRm 5 #define ID_AA64DFR0_EL1_op2 0 #define ID_AA64DFR0_DebugVer_SHIFT 0 +#define ID_AA64DFR0_DebugVer_WIDTH 4 #define ID_AA64DFR0_DebugVer_MASK (UL(0xf) << ID_AA64DFR0_DebugVer_SHIFT) #define ID_AA64DFR0_DebugVer_VAL(x) ((x) & ID_AA64DFR0_DebugVer_MASK) #define ID_AA64DFR0_DebugVer_8 (UL(0x6) << ID_AA64DFR0_DebugVer_SHIFT) @@ -730,12 +759,15 @@ #define ID_AA64DFR0_DebugVer_8_2 (UL(0x8) << ID_AA64DFR0_DebugVer_SHIFT) #define ID_AA64DFR0_DebugVer_8_4 (UL(0x9) << ID_AA64DFR0_DebugVer_SHIFT) #define ID_AA64DFR0_DebugVer_8_8 (UL(0xa) << ID_AA64DFR0_DebugVer_SHIFT) +#define ID_AA64DFR0_DebugVer_8_9 (UL(0xb) << ID_AA64DFR0_DebugVer_SHIFT) #define ID_AA64DFR0_TraceVer_SHIFT 4 +#define ID_AA64DFR0_TraceVer_WIDTH 4 #define ID_AA64DFR0_TraceVer_MASK (UL(0xf) << ID_AA64DFR0_TraceVer_SHIFT) #define ID_AA64DFR0_TraceVer_VAL(x) ((x) & ID_AA64DFR0_TraceVer_MASK) #define ID_AA64DFR0_TraceVer_NONE (UL(0x0) << ID_AA64DFR0_TraceVer_SHIFT) #define ID_AA64DFR0_TraceVer_IMPL (UL(0x1) << ID_AA64DFR0_TraceVer_SHIFT) #define ID_AA64DFR0_PMUVer_SHIFT 8 +#define ID_AA64DFR0_PMUVer_WIDTH 4 #define ID_AA64DFR0_PMUVer_MASK (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT) #define ID_AA64DFR0_PMUVer_VAL(x) ((x) & ID_AA64DFR0_PMUVer_MASK) #define ID_AA64DFR0_PMUVer_NONE (UL(0x0) << ID_AA64DFR0_PMUVer_SHIFT) @@ -745,25 +777,31 @@ #define ID_AA64DFR0_PMUVer_3_5 (UL(0x6) << ID_AA64DFR0_PMUVer_SHIFT) #define ID_AA64DFR0_PMUVer_3_7 (UL(0x7) << ID_AA64DFR0_PMUVer_SHIFT) #define ID_AA64DFR0_PMUVer_3_8 (UL(0x8) << ID_AA64DFR0_PMUVer_SHIFT) +#define ID_AA64DFR0_PMUVer_3_9 (UL(0x9) << ID_AA64DFR0_PMUVer_SHIFT) #define ID_AA64DFR0_PMUVer_IMPL (UL(0xf) << ID_AA64DFR0_PMUVer_SHIFT) #define ID_AA64DFR0_BRPs_SHIFT 12 +#define ID_AA64DFR0_BRPs_WIDTH 4 #define ID_AA64DFR0_BRPs_MASK (UL(0xf) << ID_AA64DFR0_BRPs_SHIFT) #define ID_AA64DFR0_BRPs_VAL(x) \ ((((x) >> ID_AA64DFR0_BRPs_SHIFT) & 0xf) + 1) #define ID_AA64DFR0_PMSS_SHIFT 16 +#define ID_AA64DFR0_PMSS_WIDTH 4 #define ID_AA64DFR0_PMSS_MASK (UL(0xf) << ID_AA64DFR0_PMSS_SHIFT) #define ID_AA64DFR0_PMSS_VAL(x) ((x) & ID_AA64DFR0_PMSS_MASK) #define ID_AA64DFR0_PMSS_NONE (UL(0x0) << ID_AA64DFR0_PMSS_SHIFT) #define ID_AA64DFR0_PMSS_IMPL (UL(0x1) << ID_AA64DFR0_PMSS_SHIFT) #define ID_AA64DFR0_WRPs_SHIFT 20 +#define ID_AA64DFR0_WRPs_WIDTH 4 #define ID_AA64DFR0_WRPs_MASK (UL(0xf) << ID_AA64DFR0_WRPs_SHIFT) #define ID_AA64DFR0_WRPs_VAL(x) \ ((((x) >> ID_AA64DFR0_WRPs_SHIFT) & 0xf) + 1) #define ID_AA64DFR0_CTX_CMPs_SHIFT 28 +#define ID_AA64DFR0_CTX_CMPs_WIDTH 4 #define ID_AA64DFR0_CTX_CMPs_MASK (UL(0xf) << ID_AA64DFR0_CTX_CMPs_SHIFT) #define ID_AA64DFR0_CTX_CMPs_VAL(x) \ ((((x) >> ID_AA64DFR0_CTX_CMPs_SHIFT) & 0xf) + 1) #define ID_AA64DFR0_PMSVer_SHIFT 32 +#define ID_AA64DFR0_PMSVer_WIDTH 4 #define ID_AA64DFR0_PMSVer_MASK (UL(0xf) << ID_AA64DFR0_PMSVer_SHIFT) #define ID_AA64DFR0_PMSVer_VAL(x) ((x) & ID_AA64DFR0_PMSVer_MASK) #define ID_AA64DFR0_PMSVer_NONE (UL(0x0) << ID_AA64DFR0_PMSVer_SHIFT) @@ -771,150 +809,192 @@ #define ID_AA64DFR0_PMSVer_SPE_1_1 (UL(0x2) << ID_AA64DFR0_PMSVer_SHIFT) #define ID_AA64DFR0_PMSVer_SPE_1_2 (UL(0x3) << ID_AA64DFR0_PMSVer_SHIFT) #define ID_AA64DFR0_PMSVer_SPE_1_3 (UL(0x4) << ID_AA64DFR0_PMSVer_SHIFT) +#define ID_AA64DFR0_PMSVer_SPE_1_4 (UL(0x5) << ID_AA64DFR0_PMSVer_SHIFT) #define ID_AA64DFR0_DoubleLock_SHIFT 36 +#define ID_AA64DFR0_DoubleLock_WIDTH 4 #define ID_AA64DFR0_DoubleLock_MASK (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT) #define ID_AA64DFR0_DoubleLock_VAL(x) ((x) & ID_AA64DFR0_DoubleLock_MASK) #define ID_AA64DFR0_DoubleLock_IMPL (UL(0x0) << ID_AA64DFR0_DoubleLock_SHIFT) #define ID_AA64DFR0_DoubleLock_NONE (UL(0xf) << ID_AA64DFR0_DoubleLock_SHIFT) #define ID_AA64DFR0_TraceFilt_SHIFT 40 +#define ID_AA64DFR0_TraceFilt_WIDTH 4 #define ID_AA64DFR0_TraceFilt_MASK (UL(0xf) << ID_AA64DFR0_TraceFilt_SHIFT) #define ID_AA64DFR0_TraceFilt_VAL(x) ((x) & ID_AA64DFR0_TraceFilt_MASK) #define ID_AA64DFR0_TraceFilt_NONE (UL(0x0) << ID_AA64DFR0_TraceFilt_SHIFT) #define ID_AA64DFR0_TraceFilt_8_4 (UL(0x1) << ID_AA64DFR0_TraceFilt_SHIFT) #define ID_AA64DFR0_TraceBuffer_SHIFT 44 +#define ID_AA64DFR0_TraceBuffer_WIDTH 4 #define ID_AA64DFR0_TraceBuffer_MASK (UL(0xf) << ID_AA64DFR0_TraceBuffer_SHIFT) #define ID_AA64DFR0_TraceBuffer_VAL(x) ((x) & ID_AA64DFR0_TraceBuffer_MASK) #define ID_AA64DFR0_TraceBuffer_NONE (UL(0x0) << ID_AA64DFR0_TraceBuffer_SHIFT) #define ID_AA64DFR0_TraceBuffer_IMPL (UL(0x1) << ID_AA64DFR0_TraceBuffer_SHIFT) #define ID_AA64DFR0_MTPMU_SHIFT 48 +#define ID_AA64DFR0_MTPMU_WIDTH 4 #define ID_AA64DFR0_MTPMU_MASK (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT) #define ID_AA64DFR0_MTPMU_VAL(x) ((x) & ID_AA64DFR0_MTPMU_MASK) #define ID_AA64DFR0_MTPMU_NONE (UL(0x0) << ID_AA64DFR0_MTPMU_SHIFT) #define ID_AA64DFR0_MTPMU_IMPL (UL(0x1) << ID_AA64DFR0_MTPMU_SHIFT) #define ID_AA64DFR0_MTPMU_NONE_MT_RES0 (UL(0xf) << ID_AA64DFR0_MTPMU_SHIFT) #define ID_AA64DFR0_BRBE_SHIFT 52 +#define ID_AA64DFR0_BRBE_WIDTH 4 #define ID_AA64DFR0_BRBE_MASK (UL(0xf) << ID_AA64DFR0_BRBE_SHIFT) #define ID_AA64DFR0_BRBE_VAL(x) ((x) & ID_AA64DFR0_BRBE_MASK) #define ID_AA64DFR0_BRBE_NONE (UL(0x0) << ID_AA64DFR0_BRBE_SHIFT) #define ID_AA64DFR0_BRBE_IMPL (UL(0x1) << ID_AA64DFR0_BRBE_SHIFT) #define ID_AA64DFR0_BRBE_EL3 (UL(0x2) << ID_AA64DFR0_BRBE_SHIFT) #define ID_AA64DFR0_HPMN0_SHIFT 60 +#define ID_AA64DFR0_HPMN0_WIDTH 4 #define ID_AA64DFR0_HPMN0_MASK (UL(0xf) << ID_AA64DFR0_HPMN0_SHIFT) #define ID_AA64DFR0_HPMN0_VAL(x) ((x) & ID_AA64DFR0_HPMN0_MASK) #define ID_AA64DFR0_HPMN0_CONSTR (UL(0x0) << ID_AA64DFR0_HPMN0_SHIFT) #define ID_AA64DFR0_HPMN0_DEFINED (UL(0x1) << ID_AA64DFR0_HPMN0_SHIFT) /* ID_AA64DFR1_EL1 */ -#define ID_AA64DFR1_EL1 MRS_REG(ID_AA64DFR1_EL1) #define ID_AA64DFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64DFR1_EL1) +#define ID_AA64DFR1_EL1_ISS ISS_MSR_REG(ID_AA64DFR1_EL1) #define ID_AA64DFR1_EL1_op0 3 #define ID_AA64DFR1_EL1_op1 0 #define ID_AA64DFR1_EL1_CRn 0 #define ID_AA64DFR1_EL1_CRm 5 #define ID_AA64DFR1_EL1_op2 1 +#define ID_AA64DFR1_SPMU_SHIFT 32 +#define ID_AA64DFR1_SPMU_WIDTH 4 +#define ID_AA64DFR1_SPMU_MASK (UL(0xf) << ID_AA64DFR1_SPMU_SHIFT) +#define ID_AA64DFR1_SPMU_VAL(x) ((x) & ID_AA64DFR1_SPMU_MASK) +#define ID_AA64DFR1_SPMU_NONE (UL(0x0) << ID_AA64DFR1_SPMU_SHIFT) +#define ID_AA64DFR1_SPMU_IMPL (UL(0x1) << ID_AA64DFR1_SPMU_SHIFT) +#define ID_AA64DFR1_PMICNTR_SHIFT 36 +#define ID_AA64DFR1_PMICNTR_WIDTH 4 +#define ID_AA64DFR1_PMICNTR_MASK (UL(0xf) << ID_AA64DFR1_PMICNTR_SHIFT) +#define ID_AA64DFR1_PMICNTR_VAL(x) ((x) & ID_AA64DFR1_PMICNTR_MASK) +#define ID_AA64DFR1_PMICNTR_NONE (UL(0x0) << ID_AA64DFR1_PMICNTR_SHIFT) +#define ID_AA64DFR1_PMICNTR_IMPL (UL(0x1) << ID_AA64DFR1_PMICNTR_SHIFT) +#define ID_AA64DFR1_DPFZS_SHIFT 52 +#define ID_AA64DFR1_DPFZS_WIDTH 4 +#define ID_AA64DFR1_DPFZS_MASK (UL(0xf) << ID_AA64DFR1_DPFZS_SHIFT) +#define ID_AA64DFR1_DPFZS_VAL(x) ((x) & ID_AA64DFR1_DPFZS_MASK) +#define ID_AA64DFR1_DPFZS_NONE (UL(0x0) << ID_AA64DFR1_DPFZS_SHIFT) +#define ID_AA64DFR1_DPFZS_IMPL (UL(0x1) << ID_AA64DFR1_DPFZS_SHIFT) /* ID_AA64ISAR0_EL1 */ -#define ID_AA64ISAR0_EL1 MRS_REG(ID_AA64ISAR0_EL1) #define ID_AA64ISAR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR0_EL1) +#define ID_AA64ISAR0_EL1_ISS ISS_MSR_REG(ID_AA64ISAR0_EL1) #define ID_AA64ISAR0_EL1_op0 3 #define ID_AA64ISAR0_EL1_op1 0 #define ID_AA64ISAR0_EL1_CRn 0 #define ID_AA64ISAR0_EL1_CRm 6 #define ID_AA64ISAR0_EL1_op2 0 #define ID_AA64ISAR0_AES_SHIFT 4 +#define ID_AA64ISAR0_AES_WIDTH 4 #define ID_AA64ISAR0_AES_MASK (UL(0xf) << ID_AA64ISAR0_AES_SHIFT) #define ID_AA64ISAR0_AES_VAL(x) ((x) & ID_AA64ISAR0_AES_MASK) #define ID_AA64ISAR0_AES_NONE (UL(0x0) << ID_AA64ISAR0_AES_SHIFT) #define ID_AA64ISAR0_AES_BASE (UL(0x1) << ID_AA64ISAR0_AES_SHIFT) #define ID_AA64ISAR0_AES_PMULL (UL(0x2) << ID_AA64ISAR0_AES_SHIFT) #define ID_AA64ISAR0_SHA1_SHIFT 8 +#define ID_AA64ISAR0_SHA1_WIDTH 4 #define ID_AA64ISAR0_SHA1_MASK (UL(0xf) << ID_AA64ISAR0_SHA1_SHIFT) #define ID_AA64ISAR0_SHA1_VAL(x) ((x) & ID_AA64ISAR0_SHA1_MASK) #define ID_AA64ISAR0_SHA1_NONE (UL(0x0) << ID_AA64ISAR0_SHA1_SHIFT) #define ID_AA64ISAR0_SHA1_BASE (UL(0x1) << ID_AA64ISAR0_SHA1_SHIFT) #define ID_AA64ISAR0_SHA2_SHIFT 12 +#define ID_AA64ISAR0_SHA2_WIDTH 4 #define ID_AA64ISAR0_SHA2_MASK (UL(0xf) << ID_AA64ISAR0_SHA2_SHIFT) #define ID_AA64ISAR0_SHA2_VAL(x) ((x) & ID_AA64ISAR0_SHA2_MASK) #define ID_AA64ISAR0_SHA2_NONE (UL(0x0) << ID_AA64ISAR0_SHA2_SHIFT) #define ID_AA64ISAR0_SHA2_BASE (UL(0x1) << ID_AA64ISAR0_SHA2_SHIFT) #define ID_AA64ISAR0_SHA2_512 (UL(0x2) << ID_AA64ISAR0_SHA2_SHIFT) #define ID_AA64ISAR0_CRC32_SHIFT 16 +#define ID_AA64ISAR0_CRC32_WIDTH 4 #define ID_AA64ISAR0_CRC32_MASK (UL(0xf) << ID_AA64ISAR0_CRC32_SHIFT) #define ID_AA64ISAR0_CRC32_VAL(x) ((x) & ID_AA64ISAR0_CRC32_MASK) #define ID_AA64ISAR0_CRC32_NONE (UL(0x0) << ID_AA64ISAR0_CRC32_SHIFT) #define ID_AA64ISAR0_CRC32_BASE (UL(0x1) << ID_AA64ISAR0_CRC32_SHIFT) #define ID_AA64ISAR0_Atomic_SHIFT 20 +#define ID_AA64ISAR0_Atomic_WIDTH 4 #define ID_AA64ISAR0_Atomic_MASK (UL(0xf) << ID_AA64ISAR0_Atomic_SHIFT) #define ID_AA64ISAR0_Atomic_VAL(x) ((x) & ID_AA64ISAR0_Atomic_MASK) #define ID_AA64ISAR0_Atomic_NONE (UL(0x0) << ID_AA64ISAR0_Atomic_SHIFT) #define ID_AA64ISAR0_Atomic_IMPL (UL(0x2) << ID_AA64ISAR0_Atomic_SHIFT) #define ID_AA64ISAR0_TME_SHIFT 24 +#define ID_AA64ISAR0_TME_WIDTH 4 #define ID_AA64ISAR0_TME_MASK (UL(0xf) << ID_AA64ISAR0_TME_SHIFT) #define ID_AA64ISAR0_TME_NONE (UL(0x0) << ID_AA64ISAR0_TME_SHIFT) #define ID_AA64ISAR0_TME_IMPL (UL(0x1) << ID_AA64ISAR0_TME_SHIFT) #define ID_AA64ISAR0_RDM_SHIFT 28 +#define ID_AA64ISAR0_RDM_WIDTH 4 #define ID_AA64ISAR0_RDM_MASK (UL(0xf) << ID_AA64ISAR0_RDM_SHIFT) #define ID_AA64ISAR0_RDM_VAL(x) ((x) & ID_AA64ISAR0_RDM_MASK) #define ID_AA64ISAR0_RDM_NONE (UL(0x0) << ID_AA64ISAR0_RDM_SHIFT) #define ID_AA64ISAR0_RDM_IMPL (UL(0x1) << ID_AA64ISAR0_RDM_SHIFT) #define ID_AA64ISAR0_SHA3_SHIFT 32 +#define ID_AA64ISAR0_SHA3_WIDTH 4 #define ID_AA64ISAR0_SHA3_MASK (UL(0xf) << ID_AA64ISAR0_SHA3_SHIFT) #define ID_AA64ISAR0_SHA3_VAL(x) ((x) & ID_AA64ISAR0_SHA3_MASK) #define ID_AA64ISAR0_SHA3_NONE (UL(0x0) << ID_AA64ISAR0_SHA3_SHIFT) #define ID_AA64ISAR0_SHA3_IMPL (UL(0x1) << ID_AA64ISAR0_SHA3_SHIFT) #define ID_AA64ISAR0_SM3_SHIFT 36 +#define ID_AA64ISAR0_SM3_WIDTH 4 #define ID_AA64ISAR0_SM3_MASK (UL(0xf) << ID_AA64ISAR0_SM3_SHIFT) #define ID_AA64ISAR0_SM3_VAL(x) ((x) & ID_AA64ISAR0_SM3_MASK) #define ID_AA64ISAR0_SM3_NONE (UL(0x0) << ID_AA64ISAR0_SM3_SHIFT) #define ID_AA64ISAR0_SM3_IMPL (UL(0x1) << ID_AA64ISAR0_SM3_SHIFT) #define ID_AA64ISAR0_SM4_SHIFT 40 +#define ID_AA64ISAR0_SM4_WIDTH 4 #define ID_AA64ISAR0_SM4_MASK (UL(0xf) << ID_AA64ISAR0_SM4_SHIFT) #define ID_AA64ISAR0_SM4_VAL(x) ((x) & ID_AA64ISAR0_SM4_MASK) #define ID_AA64ISAR0_SM4_NONE (UL(0x0) << ID_AA64ISAR0_SM4_SHIFT) #define ID_AA64ISAR0_SM4_IMPL (UL(0x1) << ID_AA64ISAR0_SM4_SHIFT) #define ID_AA64ISAR0_DP_SHIFT 44 +#define ID_AA64ISAR0_DP_WIDTH 4 #define ID_AA64ISAR0_DP_MASK (UL(0xf) << ID_AA64ISAR0_DP_SHIFT) #define ID_AA64ISAR0_DP_VAL(x) ((x) & ID_AA64ISAR0_DP_MASK) #define ID_AA64ISAR0_DP_NONE (UL(0x0) << ID_AA64ISAR0_DP_SHIFT) #define ID_AA64ISAR0_DP_IMPL (UL(0x1) << ID_AA64ISAR0_DP_SHIFT) #define ID_AA64ISAR0_FHM_SHIFT 48 +#define ID_AA64ISAR0_FHM_WIDTH 4 #define ID_AA64ISAR0_FHM_MASK (UL(0xf) << ID_AA64ISAR0_FHM_SHIFT) #define ID_AA64ISAR0_FHM_VAL(x) ((x) & ID_AA64ISAR0_FHM_MASK) #define ID_AA64ISAR0_FHM_NONE (UL(0x0) << ID_AA64ISAR0_FHM_SHIFT) #define ID_AA64ISAR0_FHM_IMPL (UL(0x1) << ID_AA64ISAR0_FHM_SHIFT) #define ID_AA64ISAR0_TS_SHIFT 52 +#define ID_AA64ISAR0_TS_WIDTH 4 #define ID_AA64ISAR0_TS_MASK (UL(0xf) << ID_AA64ISAR0_TS_SHIFT) #define ID_AA64ISAR0_TS_VAL(x) ((x) & ID_AA64ISAR0_TS_MASK) #define ID_AA64ISAR0_TS_NONE (UL(0x0) << ID_AA64ISAR0_TS_SHIFT) #define ID_AA64ISAR0_TS_CondM_8_4 (UL(0x1) << ID_AA64ISAR0_TS_SHIFT) #define ID_AA64ISAR0_TS_CondM_8_5 (UL(0x2) << ID_AA64ISAR0_TS_SHIFT) #define ID_AA64ISAR0_TLB_SHIFT 56 +#define ID_AA64ISAR0_TLB_WIDTH 4 #define ID_AA64ISAR0_TLB_MASK (UL(0xf) << ID_AA64ISAR0_TLB_SHIFT) #define ID_AA64ISAR0_TLB_VAL(x) ((x) & ID_AA64ISAR0_TLB_MASK) #define ID_AA64ISAR0_TLB_NONE (UL(0x0) << ID_AA64ISAR0_TLB_SHIFT) #define ID_AA64ISAR0_TLB_TLBIOS (UL(0x1) << ID_AA64ISAR0_TLB_SHIFT) #define ID_AA64ISAR0_TLB_TLBIOSR (UL(0x2) << ID_AA64ISAR0_TLB_SHIFT) #define ID_AA64ISAR0_RNDR_SHIFT 60 +#define ID_AA64ISAR0_RNDR_WIDTH 4 #define ID_AA64ISAR0_RNDR_MASK (UL(0xf) << ID_AA64ISAR0_RNDR_SHIFT) #define ID_AA64ISAR0_RNDR_VAL(x) ((x) & ID_AA64ISAR0_RNDR_MASK) #define ID_AA64ISAR0_RNDR_NONE (UL(0x0) << ID_AA64ISAR0_RNDR_SHIFT) #define ID_AA64ISAR0_RNDR_IMPL (UL(0x1) << ID_AA64ISAR0_RNDR_SHIFT) /* ID_AA64ISAR1_EL1 */ -#define ID_AA64ISAR1_EL1 MRS_REG(ID_AA64ISAR1_EL1) #define ID_AA64ISAR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR1_EL1) +#define ID_AA64ISAR1_EL1_ISS ISS_MSR_REG(ID_AA64ISAR1_EL1) #define ID_AA64ISAR1_EL1_op0 3 #define ID_AA64ISAR1_EL1_op1 0 #define ID_AA64ISAR1_EL1_CRn 0 #define ID_AA64ISAR1_EL1_CRm 6 #define ID_AA64ISAR1_EL1_op2 1 #define ID_AA64ISAR1_DPB_SHIFT 0 +#define ID_AA64ISAR1_DPB_WIDTH 4 #define ID_AA64ISAR1_DPB_MASK (UL(0xf) << ID_AA64ISAR1_DPB_SHIFT) #define ID_AA64ISAR1_DPB_VAL(x) ((x) & ID_AA64ISAR1_DPB_MASK) #define ID_AA64ISAR1_DPB_NONE (UL(0x0) << ID_AA64ISAR1_DPB_SHIFT) #define ID_AA64ISAR1_DPB_DCCVAP (UL(0x1) << ID_AA64ISAR1_DPB_SHIFT) #define ID_AA64ISAR1_DPB_DCCVADP (UL(0x2) << ID_AA64ISAR1_DPB_SHIFT) #define ID_AA64ISAR1_APA_SHIFT 4 +#define ID_AA64ISAR1_APA_WIDTH 4 #define ID_AA64ISAR1_APA_MASK (UL(0xf) << ID_AA64ISAR1_APA_SHIFT) #define ID_AA64ISAR1_APA_VAL(x) ((x) & ID_AA64ISAR1_APA_MASK) #define ID_AA64ISAR1_APA_NONE (UL(0x0) << ID_AA64ISAR1_APA_SHIFT) @@ -924,6 +1004,7 @@ #define ID_AA64ISAR1_APA_FPAC (UL(0x4) << ID_AA64ISAR1_APA_SHIFT) #define ID_AA64ISAR1_APA_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_APA_SHIFT) #define ID_AA64ISAR1_API_SHIFT 8 +#define ID_AA64ISAR1_API_WIDTH 4 #define ID_AA64ISAR1_API_MASK (UL(0xf) << ID_AA64ISAR1_API_SHIFT) #define ID_AA64ISAR1_API_VAL(x) ((x) & ID_AA64ISAR1_API_MASK) #define ID_AA64ISAR1_API_NONE (UL(0x0) << ID_AA64ISAR1_API_SHIFT) @@ -933,68 +1014,82 @@ #define ID_AA64ISAR1_API_FPAC (UL(0x4) << ID_AA64ISAR1_API_SHIFT) #define ID_AA64ISAR1_API_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR1_API_SHIFT) #define ID_AA64ISAR1_JSCVT_SHIFT 12 +#define ID_AA64ISAR1_JSCVT_WIDTH 4 #define ID_AA64ISAR1_JSCVT_MASK (UL(0xf) << ID_AA64ISAR1_JSCVT_SHIFT) #define ID_AA64ISAR1_JSCVT_VAL(x) ((x) & ID_AA64ISAR1_JSCVT_MASK) #define ID_AA64ISAR1_JSCVT_NONE (UL(0x0) << ID_AA64ISAR1_JSCVT_SHIFT) #define ID_AA64ISAR1_JSCVT_IMPL (UL(0x1) << ID_AA64ISAR1_JSCVT_SHIFT) #define ID_AA64ISAR1_FCMA_SHIFT 16 +#define ID_AA64ISAR1_FCMA_WIDTH 4 #define ID_AA64ISAR1_FCMA_MASK (UL(0xf) << ID_AA64ISAR1_FCMA_SHIFT) #define ID_AA64ISAR1_FCMA_VAL(x) ((x) & ID_AA64ISAR1_FCMA_MASK) #define ID_AA64ISAR1_FCMA_NONE (UL(0x0) << ID_AA64ISAR1_FCMA_SHIFT) #define ID_AA64ISAR1_FCMA_IMPL (UL(0x1) << ID_AA64ISAR1_FCMA_SHIFT) #define ID_AA64ISAR1_LRCPC_SHIFT 20 +#define ID_AA64ISAR1_LRCPC_WIDTH 4 #define ID_AA64ISAR1_LRCPC_MASK (UL(0xf) << ID_AA64ISAR1_LRCPC_SHIFT) #define ID_AA64ISAR1_LRCPC_VAL(x) ((x) & ID_AA64ISAR1_LRCPC_MASK) #define ID_AA64ISAR1_LRCPC_NONE (UL(0x0) << ID_AA64ISAR1_LRCPC_SHIFT) #define ID_AA64ISAR1_LRCPC_RCPC_8_3 (UL(0x1) << ID_AA64ISAR1_LRCPC_SHIFT) #define ID_AA64ISAR1_LRCPC_RCPC_8_4 (UL(0x2) << ID_AA64ISAR1_LRCPC_SHIFT) #define ID_AA64ISAR1_GPA_SHIFT 24 +#define ID_AA64ISAR1_GPA_WIDTH 4 #define ID_AA64ISAR1_GPA_MASK (UL(0xf) << ID_AA64ISAR1_GPA_SHIFT) #define ID_AA64ISAR1_GPA_VAL(x) ((x) & ID_AA64ISAR1_GPA_MASK) #define ID_AA64ISAR1_GPA_NONE (UL(0x0) << ID_AA64ISAR1_GPA_SHIFT) #define ID_AA64ISAR1_GPA_IMPL (UL(0x1) << ID_AA64ISAR1_GPA_SHIFT) #define ID_AA64ISAR1_GPI_SHIFT 28 +#define ID_AA64ISAR1_GPI_WIDTH 4 #define ID_AA64ISAR1_GPI_MASK (UL(0xf) << ID_AA64ISAR1_GPI_SHIFT) #define ID_AA64ISAR1_GPI_VAL(x) ((x) & ID_AA64ISAR1_GPI_MASK) #define ID_AA64ISAR1_GPI_NONE (UL(0x0) << ID_AA64ISAR1_GPI_SHIFT) #define ID_AA64ISAR1_GPI_IMPL (UL(0x1) << ID_AA64ISAR1_GPI_SHIFT) #define ID_AA64ISAR1_FRINTTS_SHIFT 32 +#define ID_AA64ISAR1_FRINTTS_WIDTH 4 #define ID_AA64ISAR1_FRINTTS_MASK (UL(0xf) << ID_AA64ISAR1_FRINTTS_SHIFT) #define ID_AA64ISAR1_FRINTTS_VAL(x) ((x) & ID_AA64ISAR1_FRINTTS_MASK) #define ID_AA64ISAR1_FRINTTS_NONE (UL(0x0) << ID_AA64ISAR1_FRINTTS_SHIFT) #define ID_AA64ISAR1_FRINTTS_IMPL (UL(0x1) << ID_AA64ISAR1_FRINTTS_SHIFT) #define ID_AA64ISAR1_SB_SHIFT 36 +#define ID_AA64ISAR1_SB_WIDTH 4 #define ID_AA64ISAR1_SB_MASK (UL(0xf) << ID_AA64ISAR1_SB_SHIFT) #define ID_AA64ISAR1_SB_VAL(x) ((x) & ID_AA64ISAR1_SB_MASK) #define ID_AA64ISAR1_SB_NONE (UL(0x0) << ID_AA64ISAR1_SB_SHIFT) #define ID_AA64ISAR1_SB_IMPL (UL(0x1) << ID_AA64ISAR1_SB_SHIFT) #define ID_AA64ISAR1_SPECRES_SHIFT 40 +#define ID_AA64ISAR1_SPECRES_WIDTH 4 #define ID_AA64ISAR1_SPECRES_MASK (UL(0xf) << ID_AA64ISAR1_SPECRES_SHIFT) #define ID_AA64ISAR1_SPECRES_VAL(x) ((x) & ID_AA64ISAR1_SPECRES_MASK) #define ID_AA64ISAR1_SPECRES_NONE (UL(0x0) << ID_AA64ISAR1_SPECRES_SHIFT) -#define ID_AA64ISAR1_SPECRES_IMPL (UL(0x1) << ID_AA64ISAR1_SPECRES_SHIFT) +#define ID_AA64ISAR1_SPECRES_8_5 (UL(0x1) << ID_AA64ISAR1_SPECRES_SHIFT) +#define ID_AA64ISAR1_SPECRES_8_9 (UL(0x2) << ID_AA64ISAR1_SPECRES_SHIFT) #define ID_AA64ISAR1_BF16_SHIFT 44 +#define ID_AA64ISAR1_BF16_WIDTH 4 #define ID_AA64ISAR1_BF16_MASK (UL(0xf) << ID_AA64ISAR1_BF16_SHIFT) #define ID_AA64ISAR1_BF16_VAL(x) ((x) & ID_AA64ISAR1_BF16_MASK) #define ID_AA64ISAR1_BF16_NONE (UL(0x0) << ID_AA64ISAR1_BF16_SHIFT) #define ID_AA64ISAR1_BF16_IMPL (UL(0x1) << ID_AA64ISAR1_BF16_SHIFT) #define ID_AA64ISAR1_BF16_EBF (UL(0x2) << ID_AA64ISAR1_BF16_SHIFT) #define ID_AA64ISAR1_DGH_SHIFT 48 +#define ID_AA64ISAR1_DGH_WIDTH 4 #define ID_AA64ISAR1_DGH_MASK (UL(0xf) << ID_AA64ISAR1_DGH_SHIFT) #define ID_AA64ISAR1_DGH_VAL(x) ((x) & ID_AA64ISAR1_DGH_MASK) #define ID_AA64ISAR1_DGH_NONE (UL(0x0) << ID_AA64ISAR1_DGH_SHIFT) #define ID_AA64ISAR1_DGH_IMPL (UL(0x1) << ID_AA64ISAR1_DGH_SHIFT) #define ID_AA64ISAR1_I8MM_SHIFT 52 +#define ID_AA64ISAR1_I8MM_WIDTH 4 #define ID_AA64ISAR1_I8MM_MASK (UL(0xf) << ID_AA64ISAR1_I8MM_SHIFT) #define ID_AA64ISAR1_I8MM_VAL(x) ((x) & ID_AA64ISAR1_I8MM_MASK) #define ID_AA64ISAR1_I8MM_NONE (UL(0x0) << ID_AA64ISAR1_I8MM_SHIFT) #define ID_AA64ISAR1_I8MM_IMPL (UL(0x1) << ID_AA64ISAR1_I8MM_SHIFT) #define ID_AA64ISAR1_XS_SHIFT 56 +#define ID_AA64ISAR1_XS_WIDTH 4 #define ID_AA64ISAR1_XS_MASK (UL(0xf) << ID_AA64ISAR1_XS_SHIFT) #define ID_AA64ISAR1_XS_VAL(x) ((x) & ID_AA64ISAR1_XS_MASK) #define ID_AA64ISAR1_XS_NONE (UL(0x0) << ID_AA64ISAR1_XS_SHIFT) #define ID_AA64ISAR1_XS_IMPL (UL(0x1) << ID_AA64ISAR1_XS_SHIFT) #define ID_AA64ISAR1_LS64_SHIFT 60 +#define ID_AA64ISAR1_LS64_WIDTH 4 #define ID_AA64ISAR1_LS64_MASK (UL(0xf) << ID_AA64ISAR1_LS64_SHIFT) #define ID_AA64ISAR1_LS64_VAL(x) ((x) & ID_AA64ISAR1_LS64_MASK) #define ID_AA64ISAR1_LS64_NONE (UL(0x0) << ID_AA64ISAR1_LS64_SHIFT) @@ -1003,29 +1098,33 @@ #define ID_AA64ISAR1_LS64_ACCDATA (UL(0x3) << ID_AA64ISAR1_LS64_SHIFT) /* ID_AA64ISAR2_EL1 */ -#define ID_AA64ISAR2_EL1 MRS_REG(ID_AA64ISAR2_EL1) #define ID_AA64ISAR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64ISAR2_EL1) +#define ID_AA64ISAR2_EL1_ISS ISS_MSR_REG(ID_AA64ISAR2_EL1) #define ID_AA64ISAR2_EL1_op0 3 #define ID_AA64ISAR2_EL1_op1 0 #define ID_AA64ISAR2_EL1_CRn 0 #define ID_AA64ISAR2_EL1_CRm 6 #define ID_AA64ISAR2_EL1_op2 2 #define ID_AA64ISAR2_WFxT_SHIFT 0 +#define ID_AA64ISAR2_WFxT_WIDTH 4 #define ID_AA64ISAR2_WFxT_MASK (UL(0xf) << ID_AA64ISAR2_WFxT_SHIFT) #define ID_AA64ISAR2_WFxT_VAL(x) ((x) & ID_AA64ISAR2_WFxT_MASK) #define ID_AA64ISAR2_WFxT_NONE (UL(0x0) << ID_AA64ISAR2_WFxT_SHIFT) -#define ID_AA64ISAR2_WFxT_IMPL (UL(0x1) << ID_AA64ISAR2_WFxT_SHIFT) +#define ID_AA64ISAR2_WFxT_IMPL (UL(0x2) << ID_AA64ISAR2_WFxT_SHIFT) #define ID_AA64ISAR2_RPRES_SHIFT 4 +#define ID_AA64ISAR2_RPRES_WIDTH 4 #define ID_AA64ISAR2_RPRES_MASK (UL(0xf) << ID_AA64ISAR2_RPRES_SHIFT) #define ID_AA64ISAR2_RPRES_VAL(x) ((x) & ID_AA64ISAR2_RPRES_MASK) #define ID_AA64ISAR2_RPRES_NONE (UL(0x0) << ID_AA64ISAR2_RPRES_SHIFT) #define ID_AA64ISAR2_RPRES_IMPL (UL(0x1) << ID_AA64ISAR2_RPRES_SHIFT) #define ID_AA64ISAR2_GPA3_SHIFT 8 +#define ID_AA64ISAR2_GPA3_WIDTH 4 #define ID_AA64ISAR2_GPA3_MASK (UL(0xf) << ID_AA64ISAR2_GPA3_SHIFT) #define ID_AA64ISAR2_GPA3_VAL(x) ((x) & ID_AA64ISAR2_GPA3_MASK) #define ID_AA64ISAR2_GPA3_NONE (UL(0x0) << ID_AA64ISAR2_GPA3_SHIFT) #define ID_AA64ISAR2_GPA3_IMPL (UL(0x1) << ID_AA64ISAR2_GPA3_SHIFT) #define ID_AA64ISAR2_APA3_SHIFT 12 +#define ID_AA64ISAR2_APA3_WIDTH 4 #define ID_AA64ISAR2_APA3_MASK (UL(0xf) << ID_AA64ISAR2_APA3_SHIFT) #define ID_AA64ISAR2_APA3_VAL(x) ((x) & ID_AA64ISAR2_APA3_MASK) #define ID_AA64ISAR2_APA3_NONE (UL(0x0) << ID_AA64ISAR2_APA3_SHIFT) @@ -1035,30 +1134,64 @@ #define ID_AA64ISAR2_APA3_FPAC (UL(0x4) << ID_AA64ISAR2_APA3_SHIFT) #define ID_AA64ISAR2_APA3_FPAC_COMBINED (UL(0x5) << ID_AA64ISAR2_APA3_SHIFT) #define ID_AA64ISAR2_MOPS_SHIFT 16 +#define ID_AA64ISAR2_MOPS_WIDTH 4 #define ID_AA64ISAR2_MOPS_MASK (UL(0xf) << ID_AA64ISAR2_MOPS_SHIFT) #define ID_AA64ISAR2_MOPS_VAL(x) ((x) & ID_AA64ISAR2_MOPS_MASK) #define ID_AA64ISAR2_MOPS_NONE (UL(0x0) << ID_AA64ISAR2_MOPS_SHIFT) #define ID_AA64ISAR2_MOPS_IMPL (UL(0x1) << ID_AA64ISAR2_MOPS_SHIFT) #define ID_AA64ISAR2_BC_SHIFT 20 +#define ID_AA64ISAR2_BC_WIDTH 4 #define ID_AA64ISAR2_BC_MASK (UL(0xf) << ID_AA64ISAR2_BC_SHIFT) #define ID_AA64ISAR2_BC_VAL(x) ((x) & ID_AA64ISAR2_BC_MASK) #define ID_AA64ISAR2_BC_NONE (UL(0x0) << ID_AA64ISAR2_BC_SHIFT) #define ID_AA64ISAR2_BC_IMPL (UL(0x1) << ID_AA64ISAR2_BC_SHIFT) -#define ID_AA64ISAR2_PAC_frac_SHIFT 28 +#define ID_AA64ISAR2_PAC_frac_SHIFT 24 +#define ID_AA64ISAR2_PAC_frac_WIDTH 4 #define ID_AA64ISAR2_PAC_frac_MASK (UL(0xf) << ID_AA64ISAR2_PAC_frac_SHIFT) #define ID_AA64ISAR2_PAC_frac_VAL(x) ((x) & ID_AA64ISAR2_PAC_frac_MASK) #define ID_AA64ISAR2_PAC_frac_NONE (UL(0x0) << ID_AA64ISAR2_PAC_frac_SHIFT) #define ID_AA64ISAR2_PAC_frac_IMPL (UL(0x1) << ID_AA64ISAR2_PAC_frac_SHIFT) +#define ID_AA64ISAR2_CLRBHB_SHIFT 28 +#define ID_AA64ISAR2_CLRBHB_WIDTH 4 +#define ID_AA64ISAR2_CLRBHB_MASK (UL(0xf) << ID_AA64ISAR2_CLRBHB_SHIFT) +#define ID_AA64ISAR2_CLRBHB_VAL(x) ((x) & ID_AA64ISAR2_CLRBHB_MASK) +#define ID_AA64ISAR2_CLRBHB_NONE (UL(0x0) << ID_AA64ISAR2_CLRBHB_SHIFT) +#define ID_AA64ISAR2_CLRBHB_IMPL (UL(0x1) << ID_AA64ISAR2_CLRBHB_SHIFT) +#define ID_AA64ISAR2_PRFMSLC_SHIFT 40 +#define ID_AA64ISAR2_PRFMSLC_WIDTH 4 +#define ID_AA64ISAR2_PRFMSLC_MASK (UL(0xf) << ID_AA64ISAR2_PRFMSLC_SHIFT) +#define ID_AA64ISAR2_PRFMSLC_VAL(x) ((x) & ID_AA64ISAR2_PRFMSLC_MASK) +#define ID_AA64ISAR2_PRFMSLC_NONE (UL(0x0) << ID_AA64ISAR2_PRFMSLC_SHIFT) +#define ID_AA64ISAR2_PRFMSLC_IMPL (UL(0x1) << ID_AA64ISAR2_PRFMSLC_SHIFT) +#define ID_AA64ISAR2_RPRFM_SHIFT 48 +#define ID_AA64ISAR2_RPRFM_WIDTH 4 +#define ID_AA64ISAR2_RPRFM_MASK (UL(0xf) << ID_AA64ISAR2_RPRFM_SHIFT) +#define ID_AA64ISAR2_RPRFM_VAL(x) ((x) & ID_AA64ISAR2_RPRFM_MASK) +#define ID_AA64ISAR2_RPRFM_NONE (UL(0x0) << ID_AA64ISAR2_RPRFM_SHIFT) +#define ID_AA64ISAR2_RPRFM_IMPL (UL(0x1) << ID_AA64ISAR2_RPRFM_SHIFT) +#define ID_AA64ISAR2_CSSC_SHIFT 52 +#define ID_AA64ISAR2_CSSC_WIDTH 4 +#define ID_AA64ISAR2_CSSC_MASK (UL(0xf) << ID_AA64ISAR2_CSSC_SHIFT) +#define ID_AA64ISAR2_CSSC_VAL(x) ((x) & ID_AA64ISAR2_CSSC_MASK) +#define ID_AA64ISAR2_CSSC_NONE (UL(0x0) << ID_AA64ISAR2_CSSC_SHIFT) +#define ID_AA64ISAR2_CSSC_IMPL (UL(0x1) << ID_AA64ISAR2_CSSC_SHIFT) +#define ID_AA64ISAR2_ATS1A_SHIFT 60 +#define ID_AA64ISAR2_ATS1A_WIDTH 4 +#define ID_AA64ISAR2_ATS1A_MASK (UL(0xf) << ID_AA64ISAR2_ATS1A_SHIFT) +#define ID_AA64ISAR2_ATS1A_VAL(x) ((x) & ID_AA64ISAR2_ATS1A_MASK) +#define ID_AA64ISAR2_ATS1A_NONE (UL(0x0) << ID_AA64ISAR2_ATS1A_SHIFT) +#define ID_AA64ISAR2_ATS1A_IMPL (UL(0x1) << ID_AA64ISAR2_ATS1A_SHIFT) /* ID_AA64MMFR0_EL1 */ -#define ID_AA64MMFR0_EL1 MRS_REG(ID_AA64MMFR0_EL1) #define ID_AA64MMFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR0_EL1) +#define ID_AA64MMFR0_EL1_ISS ISS_MSR_REG(ID_AA64MMFR0_EL1) #define ID_AA64MMFR0_EL1_op0 3 #define ID_AA64MMFR0_EL1_op1 0 #define ID_AA64MMFR0_EL1_CRn 0 #define ID_AA64MMFR0_EL1_CRm 7 #define ID_AA64MMFR0_EL1_op2 0 #define ID_AA64MMFR0_PARange_SHIFT 0 +#define ID_AA64MMFR0_PARange_WIDTH 4 #define ID_AA64MMFR0_PARange_MASK (UL(0xf) << ID_AA64MMFR0_PARange_SHIFT) #define ID_AA64MMFR0_PARange_VAL(x) ((x) & ID_AA64MMFR0_PARange_MASK) #define ID_AA64MMFR0_PARange_4G (UL(0x0) << ID_AA64MMFR0_PARange_SHIFT) @@ -1069,43 +1202,51 @@ #define ID_AA64MMFR0_PARange_256T (UL(0x5) << ID_AA64MMFR0_PARange_SHIFT) #define ID_AA64MMFR0_PARange_4P (UL(0x6) << ID_AA64MMFR0_PARange_SHIFT) #define ID_AA64MMFR0_ASIDBits_SHIFT 4 +#define ID_AA64MMFR0_ASIDBits_WIDTH 4 #define ID_AA64MMFR0_ASIDBits_MASK (UL(0xf) << ID_AA64MMFR0_ASIDBits_SHIFT) #define ID_AA64MMFR0_ASIDBits_VAL(x) ((x) & ID_AA64MMFR0_ASIDBits_MASK) #define ID_AA64MMFR0_ASIDBits_8 (UL(0x0) << ID_AA64MMFR0_ASIDBits_SHIFT) #define ID_AA64MMFR0_ASIDBits_16 (UL(0x2) << ID_AA64MMFR0_ASIDBits_SHIFT) #define ID_AA64MMFR0_BigEnd_SHIFT 8 +#define ID_AA64MMFR0_BigEnd_WIDTH 4 #define ID_AA64MMFR0_BigEnd_MASK (UL(0xf) << ID_AA64MMFR0_BigEnd_SHIFT) #define ID_AA64MMFR0_BigEnd_VAL(x) ((x) & ID_AA64MMFR0_BigEnd_MASK) #define ID_AA64MMFR0_BigEnd_FIXED (UL(0x0) << ID_AA64MMFR0_BigEnd_SHIFT) #define ID_AA64MMFR0_BigEnd_MIXED (UL(0x1) << ID_AA64MMFR0_BigEnd_SHIFT) #define ID_AA64MMFR0_SNSMem_SHIFT 12 +#define ID_AA64MMFR0_SNSMem_WIDTH 4 #define ID_AA64MMFR0_SNSMem_MASK (UL(0xf) << ID_AA64MMFR0_SNSMem_SHIFT) #define ID_AA64MMFR0_SNSMem_VAL(x) ((x) & ID_AA64MMFR0_SNSMem_MASK) #define ID_AA64MMFR0_SNSMem_NONE (UL(0x0) << ID_AA64MMFR0_SNSMem_SHIFT) #define ID_AA64MMFR0_SNSMem_DISTINCT (UL(0x1) << ID_AA64MMFR0_SNSMem_SHIFT) #define ID_AA64MMFR0_BigEndEL0_SHIFT 16 +#define ID_AA64MMFR0_BigEndEL0_WIDTH 4 #define ID_AA64MMFR0_BigEndEL0_MASK (UL(0xf) << ID_AA64MMFR0_BigEndEL0_SHIFT) #define ID_AA64MMFR0_BigEndEL0_VAL(x) ((x) & ID_AA64MMFR0_BigEndEL0_MASK) #define ID_AA64MMFR0_BigEndEL0_FIXED (UL(0x0) << ID_AA64MMFR0_BigEndEL0_SHIFT) #define ID_AA64MMFR0_BigEndEL0_MIXED (UL(0x1) << ID_AA64MMFR0_BigEndEL0_SHIFT) #define ID_AA64MMFR0_TGran16_SHIFT 20 +#define ID_AA64MMFR0_TGran16_WIDTH 4 #define ID_AA64MMFR0_TGran16_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_SHIFT) #define ID_AA64MMFR0_TGran16_VAL(x) ((x) & ID_AA64MMFR0_TGran16_MASK) #define ID_AA64MMFR0_TGran16_NONE (UL(0x0) << ID_AA64MMFR0_TGran16_SHIFT) #define ID_AA64MMFR0_TGran16_IMPL (UL(0x1) << ID_AA64MMFR0_TGran16_SHIFT) #define ID_AA64MMFR0_TGran16_LPA2 (UL(0x2) << ID_AA64MMFR0_TGran16_SHIFT) #define ID_AA64MMFR0_TGran64_SHIFT 24 +#define ID_AA64MMFR0_TGran64_WIDTH 4 #define ID_AA64MMFR0_TGran64_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT) #define ID_AA64MMFR0_TGran64_VAL(x) ((x) & ID_AA64MMFR0_TGran64_MASK) #define ID_AA64MMFR0_TGran64_IMPL (UL(0x0) << ID_AA64MMFR0_TGran64_SHIFT) #define ID_AA64MMFR0_TGran64_NONE (UL(0xf) << ID_AA64MMFR0_TGran64_SHIFT) #define ID_AA64MMFR0_TGran4_SHIFT 28 +#define ID_AA64MMFR0_TGran4_WIDTH 4 #define ID_AA64MMFR0_TGran4_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT) #define ID_AA64MMFR0_TGran4_VAL(x) ((x) & ID_AA64MMFR0_TGran4_MASK) #define ID_AA64MMFR0_TGran4_IMPL (UL(0x0) << ID_AA64MMFR0_TGran4_SHIFT) #define ID_AA64MMFR0_TGran4_LPA2 (UL(0x1) << ID_AA64MMFR0_TGran4_SHIFT) #define ID_AA64MMFR0_TGran4_NONE (UL(0xf) << ID_AA64MMFR0_TGran4_SHIFT) #define ID_AA64MMFR0_TGran16_2_SHIFT 32 +#define ID_AA64MMFR0_TGran16_2_WIDTH 4 #define ID_AA64MMFR0_TGran16_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran16_2_SHIFT) #define ID_AA64MMFR0_TGran16_2_VAL(x) ((x) & ID_AA64MMFR0_TGran16_2_MASK) #define ID_AA64MMFR0_TGran16_2_TGran16 (UL(0x0) << ID_AA64MMFR0_TGran16_2_SHIFT) @@ -1113,12 +1254,14 @@ #define ID_AA64MMFR0_TGran16_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran16_2_SHIFT) #define ID_AA64MMFR0_TGran16_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran16_2_SHIFT) #define ID_AA64MMFR0_TGran64_2_SHIFT 36 +#define ID_AA64MMFR0_TGran64_2_WIDTH 4 #define ID_AA64MMFR0_TGran64_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran64_2_SHIFT) #define ID_AA64MMFR0_TGran64_2_VAL(x) ((x) & ID_AA64MMFR0_TGran64_2_MASK) #define ID_AA64MMFR0_TGran64_2_TGran64 (UL(0x0) << ID_AA64MMFR0_TGran64_2_SHIFT) #define ID_AA64MMFR0_TGran64_2_NONE (UL(0x1) << ID_AA64MMFR0_TGran64_2_SHIFT) #define ID_AA64MMFR0_TGran64_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran64_2_SHIFT) #define ID_AA64MMFR0_TGran4_2_SHIFT 40 +#define ID_AA64MMFR0_TGran4_2_WIDTH 4 #define ID_AA64MMFR0_TGran4_2_MASK (UL(0xf) << ID_AA64MMFR0_TGran4_2_SHIFT) #define ID_AA64MMFR0_TGran4_2_VAL(x) ((x) & ID_AA64MMFR0_TGran4_2_MASK) #define ID_AA64MMFR0_TGran4_2_TGran4 (UL(0x0) << ID_AA64MMFR0_TGran4_2_SHIFT) @@ -1126,229 +1269,328 @@ #define ID_AA64MMFR0_TGran4_2_IMPL (UL(0x2) << ID_AA64MMFR0_TGran4_2_SHIFT) #define ID_AA64MMFR0_TGran4_2_LPA2 (UL(0x3) << ID_AA64MMFR0_TGran4_2_SHIFT) #define ID_AA64MMFR0_ExS_SHIFT 44 +#define ID_AA64MMFR0_ExS_WIDTH 4 #define ID_AA64MMFR0_ExS_MASK (UL(0xf) << ID_AA64MMFR0_ExS_SHIFT) #define ID_AA64MMFR0_ExS_VAL(x) ((x) & ID_AA64MMFR0_ExS_MASK) #define ID_AA64MMFR0_ExS_ALL (UL(0x0) << ID_AA64MMFR0_ExS_SHIFT) #define ID_AA64MMFR0_ExS_IMPL (UL(0x1) << ID_AA64MMFR0_ExS_SHIFT) #define ID_AA64MMFR0_FGT_SHIFT 56 +#define ID_AA64MMFR0_FGT_WIDTH 4 #define ID_AA64MMFR0_FGT_MASK (UL(0xf) << ID_AA64MMFR0_FGT_SHIFT) #define ID_AA64MMFR0_FGT_VAL(x) ((x) & ID_AA64MMFR0_FGT_MASK) #define ID_AA64MMFR0_FGT_NONE (UL(0x0) << ID_AA64MMFR0_FGT_SHIFT) -#define ID_AA64MMFR0_FGT_IMPL (UL(0x1) << ID_AA64MMFR0_FGT_SHIFT) +#define ID_AA64MMFR0_FGT_8_6 (UL(0x1) << ID_AA64MMFR0_FGT_SHIFT) +#define ID_AA64MMFR0_FGT_8_9 (UL(0x2) << ID_AA64MMFR0_FGT_SHIFT) #define ID_AA64MMFR0_ECV_SHIFT 60 +#define ID_AA64MMFR0_ECV_WIDTH 4 #define ID_AA64MMFR0_ECV_MASK (UL(0xf) << ID_AA64MMFR0_ECV_SHIFT) #define ID_AA64MMFR0_ECV_VAL(x) ((x) & ID_AA64MMFR0_ECV_MASK) #define ID_AA64MMFR0_ECV_NONE (UL(0x0) << ID_AA64MMFR0_ECV_SHIFT) #define ID_AA64MMFR0_ECV_IMPL (UL(0x1) << ID_AA64MMFR0_ECV_SHIFT) -#define ID_AA64MMFR0_ECV_CNTHCTL (UL(0x2) << ID_AA64MMFR0_ECV_SHIFT) +#define ID_AA64MMFR0_ECV_POFF (UL(0x2) << ID_AA64MMFR0_ECV_SHIFT) /* ID_AA64MMFR1_EL1 */ -#define ID_AA64MMFR1_EL1 MRS_REG(ID_AA64MMFR1_EL1) #define ID_AA64MMFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR1_EL1) +#define ID_AA64MMFR1_EL1_ISS ISS_MSR_REG(ID_AA64MMFR1_EL1) #define ID_AA64MMFR1_EL1_op0 3 #define ID_AA64MMFR1_EL1_op1 0 #define ID_AA64MMFR1_EL1_CRn 0 #define ID_AA64MMFR1_EL1_CRm 7 #define ID_AA64MMFR1_EL1_op2 1 #define ID_AA64MMFR1_HAFDBS_SHIFT 0 +#define ID_AA64MMFR1_HAFDBS_WIDTH 4 #define ID_AA64MMFR1_HAFDBS_MASK (UL(0xf) << ID_AA64MMFR1_HAFDBS_SHIFT) #define ID_AA64MMFR1_HAFDBS_VAL(x) ((x) & ID_AA64MMFR1_HAFDBS_MASK) #define ID_AA64MMFR1_HAFDBS_NONE (UL(0x0) << ID_AA64MMFR1_HAFDBS_SHIFT) #define ID_AA64MMFR1_HAFDBS_AF (UL(0x1) << ID_AA64MMFR1_HAFDBS_SHIFT) #define ID_AA64MMFR1_HAFDBS_AF_DBS (UL(0x2) << ID_AA64MMFR1_HAFDBS_SHIFT) #define ID_AA64MMFR1_VMIDBits_SHIFT 4 +#define ID_AA64MMFR1_VMIDBits_WIDTH 4 #define ID_AA64MMFR1_VMIDBits_MASK (UL(0xf) << ID_AA64MMFR1_VMIDBits_SHIFT) #define ID_AA64MMFR1_VMIDBits_VAL(x) ((x) & ID_AA64MMFR1_VMIDBits_MASK) #define ID_AA64MMFR1_VMIDBits_8 (UL(0x0) << ID_AA64MMFR1_VMIDBits_SHIFT) #define ID_AA64MMFR1_VMIDBits_16 (UL(0x2) << ID_AA64MMFR1_VMIDBits_SHIFT) #define ID_AA64MMFR1_VH_SHIFT 8 +#define ID_AA64MMFR1_VH_WIDTH 4 #define ID_AA64MMFR1_VH_MASK (UL(0xf) << ID_AA64MMFR1_VH_SHIFT) #define ID_AA64MMFR1_VH_VAL(x) ((x) & ID_AA64MMFR1_VH_MASK) #define ID_AA64MMFR1_VH_NONE (UL(0x0) << ID_AA64MMFR1_VH_SHIFT) #define ID_AA64MMFR1_VH_IMPL (UL(0x1) << ID_AA64MMFR1_VH_SHIFT) #define ID_AA64MMFR1_HPDS_SHIFT 12 +#define ID_AA64MMFR1_HPDS_WIDTH 4 #define ID_AA64MMFR1_HPDS_MASK (UL(0xf) << ID_AA64MMFR1_HPDS_SHIFT) #define ID_AA64MMFR1_HPDS_VAL(x) ((x) & ID_AA64MMFR1_HPDS_MASK) #define ID_AA64MMFR1_HPDS_NONE (UL(0x0) << ID_AA64MMFR1_HPDS_SHIFT) #define ID_AA64MMFR1_HPDS_HPD (UL(0x1) << ID_AA64MMFR1_HPDS_SHIFT) #define ID_AA64MMFR1_HPDS_TTPBHA (UL(0x2) << ID_AA64MMFR1_HPDS_SHIFT) #define ID_AA64MMFR1_LO_SHIFT 16 +#define ID_AA64MMFR1_LO_WIDTH 4 #define ID_AA64MMFR1_LO_MASK (UL(0xf) << ID_AA64MMFR1_LO_SHIFT) #define ID_AA64MMFR1_LO_VAL(x) ((x) & ID_AA64MMFR1_LO_MASK) #define ID_AA64MMFR1_LO_NONE (UL(0x0) << ID_AA64MMFR1_LO_SHIFT) #define ID_AA64MMFR1_LO_IMPL (UL(0x1) << ID_AA64MMFR1_LO_SHIFT) #define ID_AA64MMFR1_PAN_SHIFT 20 +#define ID_AA64MMFR1_PAN_WIDTH 4 #define ID_AA64MMFR1_PAN_MASK (UL(0xf) << ID_AA64MMFR1_PAN_SHIFT) #define ID_AA64MMFR1_PAN_VAL(x) ((x) & ID_AA64MMFR1_PAN_MASK) #define ID_AA64MMFR1_PAN_NONE (UL(0x0) << ID_AA64MMFR1_PAN_SHIFT) #define ID_AA64MMFR1_PAN_IMPL (UL(0x1) << ID_AA64MMFR1_PAN_SHIFT) #define ID_AA64MMFR1_PAN_ATS1E1 (UL(0x2) << ID_AA64MMFR1_PAN_SHIFT) -#define ID_AA64MMFR1_PAN_EPAN (UL(0x2) << ID_AA64MMFR1_PAN_SHIFT) +#define ID_AA64MMFR1_PAN_EPAN (UL(0x3) << ID_AA64MMFR1_PAN_SHIFT) #define ID_AA64MMFR1_SpecSEI_SHIFT 24 +#define ID_AA64MMFR1_SpecSEI_WIDTH 4 #define ID_AA64MMFR1_SpecSEI_MASK (UL(0xf) << ID_AA64MMFR1_SpecSEI_SHIFT) #define ID_AA64MMFR1_SpecSEI_VAL(x) ((x) & ID_AA64MMFR1_SpecSEI_MASK) #define ID_AA64MMFR1_SpecSEI_NONE (UL(0x0) << ID_AA64MMFR1_SpecSEI_SHIFT) #define ID_AA64MMFR1_SpecSEI_IMPL (UL(0x1) << ID_AA64MMFR1_SpecSEI_SHIFT) #define ID_AA64MMFR1_XNX_SHIFT 28 +#define ID_AA64MMFR1_XNX_WIDTH 4 #define ID_AA64MMFR1_XNX_MASK (UL(0xf) << ID_AA64MMFR1_XNX_SHIFT) #define ID_AA64MMFR1_XNX_VAL(x) ((x) & ID_AA64MMFR1_XNX_MASK) #define ID_AA64MMFR1_XNX_NONE (UL(0x0) << ID_AA64MMFR1_XNX_SHIFT) #define ID_AA64MMFR1_XNX_IMPL (UL(0x1) << ID_AA64MMFR1_XNX_SHIFT) #define ID_AA64MMFR1_TWED_SHIFT 32 +#define ID_AA64MMFR1_TWED_WIDTH 4 #define ID_AA64MMFR1_TWED_MASK (UL(0xf) << ID_AA64MMFR1_TWED_SHIFT) #define ID_AA64MMFR1_TWED_VAL(x) ((x) & ID_AA64MMFR1_TWED_MASK) #define ID_AA64MMFR1_TWED_NONE (UL(0x0) << ID_AA64MMFR1_TWED_SHIFT) #define ID_AA64MMFR1_TWED_IMPL (UL(0x1) << ID_AA64MMFR1_TWED_SHIFT) #define ID_AA64MMFR1_ETS_SHIFT 36 +#define ID_AA64MMFR1_ETS_WIDTH 4 #define ID_AA64MMFR1_ETS_MASK (UL(0xf) << ID_AA64MMFR1_ETS_SHIFT) #define ID_AA64MMFR1_ETS_VAL(x) ((x) & ID_AA64MMFR1_ETS_MASK) #define ID_AA64MMFR1_ETS_NONE (UL(0x0) << ID_AA64MMFR1_ETS_SHIFT) -#define ID_AA64MMFR1_ETS_IMPL (UL(0x1) << ID_AA64MMFR1_ETS_SHIFT) +#define ID_AA64MMFR1_ETS_NONE2 (UL(0x1) << ID_AA64MMFR1_ETS_SHIFT) +#define ID_AA64MMFR1_ETS_IMPL (UL(0x2) << ID_AA64MMFR1_ETS_SHIFT) #define ID_AA64MMFR1_HCX_SHIFT 40 +#define ID_AA64MMFR1_HCX_WIDTH 4 #define ID_AA64MMFR1_HCX_MASK (UL(0xf) << ID_AA64MMFR1_HCX_SHIFT) #define ID_AA64MMFR1_HCX_VAL(x) ((x) & ID_AA64MMFR1_HCX_MASK) #define ID_AA64MMFR1_HCX_NONE (UL(0x0) << ID_AA64MMFR1_HCX_SHIFT) #define ID_AA64MMFR1_HCX_IMPL (UL(0x1) << ID_AA64MMFR1_HCX_SHIFT) #define ID_AA64MMFR1_AFP_SHIFT 44 +#define ID_AA64MMFR1_AFP_WIDTH 4 #define ID_AA64MMFR1_AFP_MASK (UL(0xf) << ID_AA64MMFR1_AFP_SHIFT) #define ID_AA64MMFR1_AFP_VAL(x) ((x) & ID_AA64MMFR1_AFP_MASK) #define ID_AA64MMFR1_AFP_NONE (UL(0x0) << ID_AA64MMFR1_AFP_SHIFT) #define ID_AA64MMFR1_AFP_IMPL (UL(0x1) << ID_AA64MMFR1_AFP_SHIFT) #define ID_AA64MMFR1_nTLBPA_SHIFT 48 +#define ID_AA64MMFR1_nTLBPA_WIDTH 4 #define ID_AA64MMFR1_nTLBPA_MASK (UL(0xf) << ID_AA64MMFR1_nTLBPA_SHIFT) #define ID_AA64MMFR1_nTLBPA_VAL(x) ((x) & ID_AA64MMFR1_nTLBPA_MASK) #define ID_AA64MMFR1_nTLBPA_NONE (UL(0x0) << ID_AA64MMFR1_nTLBPA_SHIFT) #define ID_AA64MMFR1_nTLBPA_IMPL (UL(0x1) << ID_AA64MMFR1_nTLBPA_SHIFT) #define ID_AA64MMFR1_TIDCP1_SHIFT 52 +#define ID_AA64MMFR1_TIDCP1_WIDTH 4 #define ID_AA64MMFR1_TIDCP1_MASK (UL(0xf) << ID_AA64MMFR1_TIDCP1_SHIFT) #define ID_AA64MMFR1_TIDCP1_VAL(x) ((x) & ID_AA64MMFR1_TIDCP1_MASK) #define ID_AA64MMFR1_TIDCP1_NONE (UL(0x0) << ID_AA64MMFR1_TIDCP1_SHIFT) #define ID_AA64MMFR1_TIDCP1_IMPL (UL(0x1) << ID_AA64MMFR1_TIDCP1_SHIFT) #define ID_AA64MMFR1_CMOVW_SHIFT 56 +#define ID_AA64MMFR1_CMOVW_WIDTH 4 #define ID_AA64MMFR1_CMOVW_MASK (UL(0xf) << ID_AA64MMFR1_CMOVW_SHIFT) #define ID_AA64MMFR1_CMOVW_VAL(x) ((x) & ID_AA64MMFR1_CMOVW_MASK) #define ID_AA64MMFR1_CMOVW_NONE (UL(0x0) << ID_AA64MMFR1_CMOVW_SHIFT) #define ID_AA64MMFR1_CMOVW_IMPL (UL(0x1) << ID_AA64MMFR1_CMOVW_SHIFT) +#define ID_AA64MMFR1_ECBHB_SHIFT 60 +#define ID_AA64MMFR1_ECBHB_WIDTH 4 +#define ID_AA64MMFR1_ECBHB_MASK (UL(0xf) << ID_AA64MMFR1_ECBHB_SHIFT) +#define ID_AA64MMFR1_ECBHB_VAL(x) ((x) & ID_AA64MMFR1_ECBHB_MASK) +#define ID_AA64MMFR1_ECBHB_NONE (UL(0x0) << ID_AA64MMFR1_ECBHB_SHIFT) +#define ID_AA64MMFR1_ECBHB_IMPL (UL(0x1) << ID_AA64MMFR1_ECBHB_SHIFT) /* ID_AA64MMFR2_EL1 */ -#define ID_AA64MMFR2_EL1 MRS_REG(ID_AA64MMFR2_EL1) #define ID_AA64MMFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR2_EL1) +#define ID_AA64MMFR2_EL1_ISS ISS_MSR_REG(ID_AA64MMFR2_EL1) #define ID_AA64MMFR2_EL1_op0 3 #define ID_AA64MMFR2_EL1_op1 0 #define ID_AA64MMFR2_EL1_CRn 0 #define ID_AA64MMFR2_EL1_CRm 7 #define ID_AA64MMFR2_EL1_op2 2 #define ID_AA64MMFR2_CnP_SHIFT 0 +#define ID_AA64MMFR2_CnP_WIDTH 4 #define ID_AA64MMFR2_CnP_MASK (UL(0xf) << ID_AA64MMFR2_CnP_SHIFT) #define ID_AA64MMFR2_CnP_VAL(x) ((x) & ID_AA64MMFR2_CnP_MASK) #define ID_AA64MMFR2_CnP_NONE (UL(0x0) << ID_AA64MMFR2_CnP_SHIFT) #define ID_AA64MMFR2_CnP_IMPL (UL(0x1) << ID_AA64MMFR2_CnP_SHIFT) #define ID_AA64MMFR2_UAO_SHIFT 4 +#define ID_AA64MMFR2_UAO_WIDTH 4 #define ID_AA64MMFR2_UAO_MASK (UL(0xf) << ID_AA64MMFR2_UAO_SHIFT) #define ID_AA64MMFR2_UAO_VAL(x) ((x) & ID_AA64MMFR2_UAO_MASK) #define ID_AA64MMFR2_UAO_NONE (UL(0x0) << ID_AA64MMFR2_UAO_SHIFT) #define ID_AA64MMFR2_UAO_IMPL (UL(0x1) << ID_AA64MMFR2_UAO_SHIFT) #define ID_AA64MMFR2_LSM_SHIFT 8 +#define ID_AA64MMFR2_LSM_WIDTH 4 #define ID_AA64MMFR2_LSM_MASK (UL(0xf) << ID_AA64MMFR2_LSM_SHIFT) #define ID_AA64MMFR2_LSM_VAL(x) ((x) & ID_AA64MMFR2_LSM_MASK) #define ID_AA64MMFR2_LSM_NONE (UL(0x0) << ID_AA64MMFR2_LSM_SHIFT) #define ID_AA64MMFR2_LSM_IMPL (UL(0x1) << ID_AA64MMFR2_LSM_SHIFT) #define ID_AA64MMFR2_IESB_SHIFT 12 +#define ID_AA64MMFR2_IESB_WIDTH 4 #define ID_AA64MMFR2_IESB_MASK (UL(0xf) << ID_AA64MMFR2_IESB_SHIFT) #define ID_AA64MMFR2_IESB_VAL(x) ((x) & ID_AA64MMFR2_IESB_MASK) #define ID_AA64MMFR2_IESB_NONE (UL(0x0) << ID_AA64MMFR2_IESB_SHIFT) #define ID_AA64MMFR2_IESB_IMPL (UL(0x1) << ID_AA64MMFR2_IESB_SHIFT) #define ID_AA64MMFR2_VARange_SHIFT 16 +#define ID_AA64MMFR2_VARange_WIDTH 4 #define ID_AA64MMFR2_VARange_MASK (UL(0xf) << ID_AA64MMFR2_VARange_SHIFT) #define ID_AA64MMFR2_VARange_VAL(x) ((x) & ID_AA64MMFR2_VARange_MASK) #define ID_AA64MMFR2_VARange_48 (UL(0x0) << ID_AA64MMFR2_VARange_SHIFT) #define ID_AA64MMFR2_VARange_52 (UL(0x1) << ID_AA64MMFR2_VARange_SHIFT) #define ID_AA64MMFR2_CCIDX_SHIFT 20 +#define ID_AA64MMFR2_CCIDX_WIDTH 4 #define ID_AA64MMFR2_CCIDX_MASK (UL(0xf) << ID_AA64MMFR2_CCIDX_SHIFT) #define ID_AA64MMFR2_CCIDX_VAL(x) ((x) & ID_AA64MMFR2_CCIDX_MASK) #define ID_AA64MMFR2_CCIDX_32 (UL(0x0) << ID_AA64MMFR2_CCIDX_SHIFT) #define ID_AA64MMFR2_CCIDX_64 (UL(0x1) << ID_AA64MMFR2_CCIDX_SHIFT) #define ID_AA64MMFR2_NV_SHIFT 24 +#define ID_AA64MMFR2_NV_WIDTH 4 #define ID_AA64MMFR2_NV_MASK (UL(0xf) << ID_AA64MMFR2_NV_SHIFT) #define ID_AA64MMFR2_NV_VAL(x) ((x) & ID_AA64MMFR2_NV_MASK) #define ID_AA64MMFR2_NV_NONE (UL(0x0) << ID_AA64MMFR2_NV_SHIFT) #define ID_AA64MMFR2_NV_8_3 (UL(0x1) << ID_AA64MMFR2_NV_SHIFT) #define ID_AA64MMFR2_NV_8_4 (UL(0x2) << ID_AA64MMFR2_NV_SHIFT) #define ID_AA64MMFR2_ST_SHIFT 28 +#define ID_AA64MMFR2_ST_WIDTH 4 #define ID_AA64MMFR2_ST_MASK (UL(0xf) << ID_AA64MMFR2_ST_SHIFT) #define ID_AA64MMFR2_ST_VAL(x) ((x) & ID_AA64MMFR2_ST_MASK) #define ID_AA64MMFR2_ST_NONE (UL(0x0) << ID_AA64MMFR2_ST_SHIFT) #define ID_AA64MMFR2_ST_IMPL (UL(0x1) << ID_AA64MMFR2_ST_SHIFT) #define ID_AA64MMFR2_AT_SHIFT 32 +#define ID_AA64MMFR2_AT_WIDTH 4 #define ID_AA64MMFR2_AT_MASK (UL(0xf) << ID_AA64MMFR2_AT_SHIFT) #define ID_AA64MMFR2_AT_VAL(x) ((x) & ID_AA64MMFR2_AT_MASK) #define ID_AA64MMFR2_AT_NONE (UL(0x0) << ID_AA64MMFR2_AT_SHIFT) #define ID_AA64MMFR2_AT_IMPL (UL(0x1) << ID_AA64MMFR2_AT_SHIFT) #define ID_AA64MMFR2_IDS_SHIFT 36 +#define ID_AA64MMFR2_IDS_WIDTH 4 #define ID_AA64MMFR2_IDS_MASK (UL(0xf) << ID_AA64MMFR2_IDS_SHIFT) #define ID_AA64MMFR2_IDS_VAL(x) ((x) & ID_AA64MMFR2_IDS_MASK) #define ID_AA64MMFR2_IDS_NONE (UL(0x0) << ID_AA64MMFR2_IDS_SHIFT) #define ID_AA64MMFR2_IDS_IMPL (UL(0x1) << ID_AA64MMFR2_IDS_SHIFT) #define ID_AA64MMFR2_FWB_SHIFT 40 +#define ID_AA64MMFR2_FWB_WIDTH 4 #define ID_AA64MMFR2_FWB_MASK (UL(0xf) << ID_AA64MMFR2_FWB_SHIFT) #define ID_AA64MMFR2_FWB_VAL(x) ((x) & ID_AA64MMFR2_FWB_MASK) #define ID_AA64MMFR2_FWB_NONE (UL(0x0) << ID_AA64MMFR2_FWB_SHIFT) #define ID_AA64MMFR2_FWB_IMPL (UL(0x1) << ID_AA64MMFR2_FWB_SHIFT) #define ID_AA64MMFR2_TTL_SHIFT 48 +#define ID_AA64MMFR2_TTL_WIDTH 4 #define ID_AA64MMFR2_TTL_MASK (UL(0xf) << ID_AA64MMFR2_TTL_SHIFT) #define ID_AA64MMFR2_TTL_VAL(x) ((x) & ID_AA64MMFR2_TTL_MASK) #define ID_AA64MMFR2_TTL_NONE (UL(0x0) << ID_AA64MMFR2_TTL_SHIFT) #define ID_AA64MMFR2_TTL_IMPL (UL(0x1) << ID_AA64MMFR2_TTL_SHIFT) #define ID_AA64MMFR2_BBM_SHIFT 52 +#define ID_AA64MMFR2_BBM_WIDTH 4 #define ID_AA64MMFR2_BBM_MASK (UL(0xf) << ID_AA64MMFR2_BBM_SHIFT) #define ID_AA64MMFR2_BBM_VAL(x) ((x) & ID_AA64MMFR2_BBM_MASK) #define ID_AA64MMFR2_BBM_LEVEL0 (UL(0x0) << ID_AA64MMFR2_BBM_SHIFT) #define ID_AA64MMFR2_BBM_LEVEL1 (UL(0x1) << ID_AA64MMFR2_BBM_SHIFT) #define ID_AA64MMFR2_BBM_LEVEL2 (UL(0x2) << ID_AA64MMFR2_BBM_SHIFT) #define ID_AA64MMFR2_EVT_SHIFT 56 +#define ID_AA64MMFR2_EVT_WIDTH 4 #define ID_AA64MMFR2_EVT_MASK (UL(0xf) << ID_AA64MMFR2_EVT_SHIFT) #define ID_AA64MMFR2_EVT_VAL(x) ((x) & ID_AA64MMFR2_EVT_MASK) #define ID_AA64MMFR2_EVT_NONE (UL(0x0) << ID_AA64MMFR2_EVT_SHIFT) #define ID_AA64MMFR2_EVT_8_2 (UL(0x1) << ID_AA64MMFR2_EVT_SHIFT) #define ID_AA64MMFR2_EVT_8_5 (UL(0x2) << ID_AA64MMFR2_EVT_SHIFT) #define ID_AA64MMFR2_E0PD_SHIFT 60 +#define ID_AA64MMFR2_E0PD_WIDTH 4 #define ID_AA64MMFR2_E0PD_MASK (UL(0xf) << ID_AA64MMFR2_E0PD_SHIFT) #define ID_AA64MMFR2_E0PD_VAL(x) ((x) & ID_AA64MMFR2_E0PD_MASK) #define ID_AA64MMFR2_E0PD_NONE (UL(0x0) << ID_AA64MMFR2_E0PD_SHIFT) #define ID_AA64MMFR2_E0PD_IMPL (UL(0x1) << ID_AA64MMFR2_E0PD_SHIFT) /* ID_AA64MMFR3_EL1 */ -#define ID_AA64MMFR3_EL1 MRS_REG(ID_AA64MMFR3_EL1) #define ID_AA64MMFR3_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR3_EL1) +#define ID_AA64MMFR3_EL1_ISS ISS_MSR_REG(ID_AA64MMFR3_EL1) #define ID_AA64MMFR3_EL1_op0 3 #define ID_AA64MMFR3_EL1_op1 0 #define ID_AA64MMFR3_EL1_CRn 0 #define ID_AA64MMFR3_EL1_CRm 7 #define ID_AA64MMFR3_EL1_op2 3 #define ID_AA64MMFR3_TCRX_SHIFT 0 +#define ID_AA64MMFR3_TCRX_WIDTH 4 #define ID_AA64MMFR3_TCRX_MASK (UL(0xf) << ID_AA64MMFR3_TCRX_SHIFT) #define ID_AA64MMFR3_TCRX_VAL(x) ((x) & ID_AA64MMFR3_TCRX_MASK) #define ID_AA64MMFR3_TCRX_NONE (UL(0x0) << ID_AA64MMFR3_TCRX_SHIFT) #define ID_AA64MMFR3_TCRX_IMPL (UL(0x1) << ID_AA64MMFR3_TCRX_SHIFT) #define ID_AA64MMFR3_SCTLRX_SHIFT 4 +#define ID_AA64MMFR3_SCTLRX_WIDTH 4 #define ID_AA64MMFR3_SCTLRX_MASK (UL(0xf) << ID_AA64MMFR3_SCTLRX_SHIFT) #define ID_AA64MMFR3_SCTLRX_VAL(x) ((x) & ID_AA64MMFR3_SCTLRX_MASK) #define ID_AA64MMFR3_SCTLRX_NONE (UL(0x0) << ID_AA64MMFR3_SCTLRX_SHIFT) #define ID_AA64MMFR3_SCTLRX_IMPL (UL(0x1) << ID_AA64MMFR3_SCTLRX_SHIFT) +#define ID_AA64MMFR3_S1PIE_SHIFT 8 +#define ID_AA64MMFR3_S1PIE_WIDTH 4 +#define ID_AA64MMFR3_S1PIE_MASK (UL(0xf) << ID_AA64MMFR3_S1PIE_SHIFT) +#define ID_AA64MMFR3_S1PIE_VAL(x) ((x) & ID_AA64MMFR3_S1PIE_MASK) +#define ID_AA64MMFR3_S1PIE_NONE (UL(0x0) << ID_AA64MMFR3_S1PIE_SHIFT) +#define ID_AA64MMFR3_S1PIE_IMPL (UL(0x1) << ID_AA64MMFR3_S1PIE_SHIFT) +#define ID_AA64MMFR3_S2PIE_SHIFT 12 +#define ID_AA64MMFR3_S2PIE_WIDTH 4 +#define ID_AA64MMFR3_S2PIE_MASK (UL(0xf) << ID_AA64MMFR3_S2PIE_SHIFT) +#define ID_AA64MMFR3_S2PIE_VAL(x) ((x) & ID_AA64MMFR3_S2PIE_MASK) +#define ID_AA64MMFR3_S2PIE_NONE (UL(0x0) << ID_AA64MMFR3_S2PIE_SHIFT) +#define ID_AA64MMFR3_S2PIE_IMPL (UL(0x1) << ID_AA64MMFR3_S2PIE_SHIFT) +#define ID_AA64MMFR3_S1POE_SHIFT 16 +#define ID_AA64MMFR3_S1POE_WIDTH 4 +#define ID_AA64MMFR3_S1POE_MASK (UL(0xf) << ID_AA64MMFR3_S1POE_SHIFT) +#define ID_AA64MMFR3_S1POE_VAL(x) ((x) & ID_AA64MMFR3_S1POE_MASK) +#define ID_AA64MMFR3_S1POE_NONE (UL(0x0) << ID_AA64MMFR3_S1POE_SHIFT) +#define ID_AA64MMFR3_S1POE_IMPL (UL(0x1) << ID_AA64MMFR3_S1POE_SHIFT) +#define ID_AA64MMFR3_S2POE_SHIFT 20 +#define ID_AA64MMFR3_S2POE_WIDTH 4 +#define ID_AA64MMFR3_S2POE_MASK (UL(0xf) << ID_AA64MMFR3_S2POE_SHIFT) +#define ID_AA64MMFR3_S2POE_VAL(x) ((x) & ID_AA64MMFR3_S2POE_MASK) +#define ID_AA64MMFR3_S2POE_NONE (UL(0x0) << ID_AA64MMFR3_S2POE_SHIFT) +#define ID_AA64MMFR3_S2POE_IMPL (UL(0x1) << ID_AA64MMFR3_S2POE_SHIFT) +#define ID_AA64MMFR3_AIE_SHIFT 24 +#define ID_AA64MMFR3_AIE_WIDTH 4 +#define ID_AA64MMFR3_AIE_MASK (UL(0xf) << ID_AA64MMFR3_AIE_SHIFT) +#define ID_AA64MMFR3_AIE_VAL(x) ((x) & ID_AA64MMFR3_AIE_MASK) +#define ID_AA64MMFR3_AIE_NONE (UL(0x0) << ID_AA64MMFR3_AIE_SHIFT) +#define ID_AA64MMFR3_AIE_IMPL (UL(0x1) << ID_AA64MMFR3_AIE_SHIFT) #define ID_AA64MMFR3_MEC_SHIFT 28 +#define ID_AA64MMFR3_MEC_WIDTH 4 #define ID_AA64MMFR3_MEC_MASK (UL(0xf) << ID_AA64MMFR3_MEC_SHIFT) #define ID_AA64MMFR3_MEC_VAL(x) ((x) & ID_AA64MMFR3_MEC_MASK) #define ID_AA64MMFR3_MEC_NONE (UL(0x0) << ID_AA64MMFR3_MEC_SHIFT) #define ID_AA64MMFR3_MEC_IMPL (UL(0x1) << ID_AA64MMFR3_MEC_SHIFT) +#define ID_AA64MMFR3_SNERR_SHIFT 40 +#define ID_AA64MMFR3_SNERR_WIDTH 4 +#define ID_AA64MMFR3_SNERR_MASK (UL(0xf) << ID_AA64MMFR3_SNERR_SHIFT) +#define ID_AA64MMFR3_SNERR_VAL(x) ((x) & ID_AA64MMFR3_SNERR_MASK) +#define ID_AA64MMFR3_SNERR_NONE (UL(0x0) << ID_AA64MMFR3_SNERR_SHIFT) +#define ID_AA64MMFR3_SNERR_ALL (UL(0x1) << ID_AA64MMFR3_SNERR_SHIFT) +#define ID_AA64MMFR3_ANERR_SHIFT 44 +#define ID_AA64MMFR3_ANERR_WIDTH 4 +#define ID_AA64MMFR3_ANERR_MASK (UL(0xf) << ID_AA64MMFR3_ANERR_SHIFT) +#define ID_AA64MMFR3_ANERR_VAL(x) ((x) & ID_AA64MMFR3_ANERR_MASK) +#define ID_AA64MMFR3_ANERR_NONE (UL(0x0) << ID_AA64MMFR3_ANERR_SHIFT) +#define ID_AA64MMFR3_ANERR_SOME (UL(0x1) << ID_AA64MMFR3_ANERR_SHIFT) +#define ID_AA64MMFR3_SDERR_SHIFT 52 +#define ID_AA64MMFR3_SDERR_WIDTH 4 +#define ID_AA64MMFR3_SDERR_MASK (UL(0xf) << ID_AA64MMFR3_SDERR_SHIFT) +#define ID_AA64MMFR3_SDERR_VAL(x) ((x) & ID_AA64MMFR3_SDERR_MASK) +#define ID_AA64MMFR3_SDERR_NONE (UL(0x0) << ID_AA64MMFR3_SDERR_SHIFT) +#define ID_AA64MMFR3_SDERR_ALL (UL(0x1) << ID_AA64MMFR3_SDERR_SHIFT) +#define ID_AA64MMFR3_ADERR_SHIFT 56 +#define ID_AA64MMFR3_ADERR_WIDTH 4 +#define ID_AA64MMFR3_ADERR_MASK (UL(0xf) << ID_AA64MMFR3_ADERR_SHIFT) +#define ID_AA64MMFR3_ADERR_VAL(x) ((x) & ID_AA64MMFR3_ADERR_MASK) +#define ID_AA64MMFR3_ADERR_NONE (UL(0x0) << ID_AA64MMFR3_ADERR_SHIFT) +#define ID_AA64MMFR3_ADERR_SOME (UL(0x1) << ID_AA64MMFR3_ADERR_SHIFT) #define ID_AA64MMFR3_Spec_FPACC_SHIFT 60 +#define ID_AA64MMFR3_Spec_FPACC_WIDTH 4 #define ID_AA64MMFR3_Spec_FPACC_MASK (UL(0xf) << ID_AA64MMFR3_Spec_FPACC_SHIFT) #define ID_AA64MMFR3_Spec_FPACC_VAL(x) ((x) & ID_AA64MMFR3_Spec_FPACC_MASK) #define ID_AA64MMFR3_Spec_FPACC_NONE (UL(0x0) << ID_AA64MMFR3_Spec_FPACC_SHIFT) #define ID_AA64MMFR3_Spec_FPACC_IMPL (UL(0x1) << ID_AA64MMFR3_Spec_FPACC_SHIFT) /* ID_AA64MMFR4_EL1 */ -#define ID_AA64MMFR4_EL1 MRS_REG(ID_AA64MMFR4_EL1) #define ID_AA64MMFR4_EL1_REG MRS_REG_ALT_NAME(ID_AA64MMFR4_EL1) +#define ID_AA64MMFR4_EL1_ISS ISS_MSR_REG(ID_AA64MMFR4_EL1) #define ID_AA64MMFR4_EL1_op0 3 #define ID_AA64MMFR4_EL1_op1 0 #define ID_AA64MMFR4_EL1_CRn 0 @@ -1356,42 +1598,48 @@ #define ID_AA64MMFR4_EL1_op2 4 /* ID_AA64PFR0_EL1 */ -#define ID_AA64PFR0_EL1 MRS_REG(ID_AA64PFR0_EL1) #define ID_AA64PFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR0_EL1) +#define ID_AA64PFR0_EL1_ISS ISS_MSR_REG(ID_AA64PFR0_EL1) #define ID_AA64PFR0_EL1_op0 3 #define ID_AA64PFR0_EL1_op1 0 #define ID_AA64PFR0_EL1_CRn 0 #define ID_AA64PFR0_EL1_CRm 4 #define ID_AA64PFR0_EL1_op2 0 #define ID_AA64PFR0_EL0_SHIFT 0 +#define ID_AA64PFR0_EL0_WIDTH 4 #define ID_AA64PFR0_EL0_MASK (UL(0xf) << ID_AA64PFR0_EL0_SHIFT) #define ID_AA64PFR0_EL0_VAL(x) ((x) & ID_AA64PFR0_EL0_MASK) #define ID_AA64PFR0_EL0_64 (UL(0x1) << ID_AA64PFR0_EL0_SHIFT) #define ID_AA64PFR0_EL0_64_32 (UL(0x2) << ID_AA64PFR0_EL0_SHIFT) #define ID_AA64PFR0_EL1_SHIFT 4 +#define ID_AA64PFR0_EL1_WIDTH 4 #define ID_AA64PFR0_EL1_MASK (UL(0xf) << ID_AA64PFR0_EL1_SHIFT) #define ID_AA64PFR0_EL1_VAL(x) ((x) & ID_AA64PFR0_EL1_MASK) #define ID_AA64PFR0_EL1_64 (UL(0x1) << ID_AA64PFR0_EL1_SHIFT) #define ID_AA64PFR0_EL1_64_32 (UL(0x2) << ID_AA64PFR0_EL1_SHIFT) #define ID_AA64PFR0_EL2_SHIFT 8 +#define ID_AA64PFR0_EL2_WIDTH 4 #define ID_AA64PFR0_EL2_MASK (UL(0xf) << ID_AA64PFR0_EL2_SHIFT) #define ID_AA64PFR0_EL2_VAL(x) ((x) & ID_AA64PFR0_EL2_MASK) #define ID_AA64PFR0_EL2_NONE (UL(0x0) << ID_AA64PFR0_EL2_SHIFT) #define ID_AA64PFR0_EL2_64 (UL(0x1) << ID_AA64PFR0_EL2_SHIFT) #define ID_AA64PFR0_EL2_64_32 (UL(0x2) << ID_AA64PFR0_EL2_SHIFT) #define ID_AA64PFR0_EL3_SHIFT 12 +#define ID_AA64PFR0_EL3_WIDTH 4 #define ID_AA64PFR0_EL3_MASK (UL(0xf) << ID_AA64PFR0_EL3_SHIFT) #define ID_AA64PFR0_EL3_VAL(x) ((x) & ID_AA64PFR0_EL3_MASK) #define ID_AA64PFR0_EL3_NONE (UL(0x0) << ID_AA64PFR0_EL3_SHIFT) #define ID_AA64PFR0_EL3_64 (UL(0x1) << ID_AA64PFR0_EL3_SHIFT) #define ID_AA64PFR0_EL3_64_32 (UL(0x2) << ID_AA64PFR0_EL3_SHIFT) #define ID_AA64PFR0_FP_SHIFT 16 +#define ID_AA64PFR0_FP_WIDTH 4 #define ID_AA64PFR0_FP_MASK (UL(0xf) << ID_AA64PFR0_FP_SHIFT) #define ID_AA64PFR0_FP_VAL(x) ((x) & ID_AA64PFR0_FP_MASK) #define ID_AA64PFR0_FP_IMPL (UL(0x0) << ID_AA64PFR0_FP_SHIFT) #define ID_AA64PFR0_FP_HP (UL(0x1) << ID_AA64PFR0_FP_SHIFT) #define ID_AA64PFR0_FP_NONE (UL(0xf) << ID_AA64PFR0_FP_SHIFT) #define ID_AA64PFR0_AdvSIMD_SHIFT 20 +#define ID_AA64PFR0_AdvSIMD_WIDTH 4 #define ID_AA64PFR0_AdvSIMD_MASK (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT) #define ID_AA64PFR0_AdvSIMD_VAL(x) ((x) & ID_AA64PFR0_AdvSIMD_MASK) #define ID_AA64PFR0_AdvSIMD_IMPL (UL(0x0) << ID_AA64PFR0_AdvSIMD_SHIFT) @@ -1399,49 +1647,59 @@ #define ID_AA64PFR0_AdvSIMD_NONE (UL(0xf) << ID_AA64PFR0_AdvSIMD_SHIFT) #define ID_AA64PFR0_GIC_BITS 0x4 /* Number of bits in GIC field */ #define ID_AA64PFR0_GIC_SHIFT 24 +#define ID_AA64PFR0_GIC_WIDTH 4 #define ID_AA64PFR0_GIC_MASK (UL(0xf) << ID_AA64PFR0_GIC_SHIFT) #define ID_AA64PFR0_GIC_VAL(x) ((x) & ID_AA64PFR0_GIC_MASK) #define ID_AA64PFR0_GIC_CPUIF_NONE (UL(0x0) << ID_AA64PFR0_GIC_SHIFT) #define ID_AA64PFR0_GIC_CPUIF_EN (UL(0x1) << ID_AA64PFR0_GIC_SHIFT) #define ID_AA64PFR0_GIC_CPUIF_4_1 (UL(0x3) << ID_AA64PFR0_GIC_SHIFT) #define ID_AA64PFR0_RAS_SHIFT 28 +#define ID_AA64PFR0_RAS_WIDTH 4 #define ID_AA64PFR0_RAS_MASK (UL(0xf) << ID_AA64PFR0_RAS_SHIFT) #define ID_AA64PFR0_RAS_VAL(x) ((x) & ID_AA64PFR0_RAS_MASK) #define ID_AA64PFR0_RAS_NONE (UL(0x0) << ID_AA64PFR0_RAS_SHIFT) #define ID_AA64PFR0_RAS_IMPL (UL(0x1) << ID_AA64PFR0_RAS_SHIFT) #define ID_AA64PFR0_RAS_8_4 (UL(0x2) << ID_AA64PFR0_RAS_SHIFT) +#define ID_AA64PFR0_RAS_8_9 (UL(0x3) << ID_AA64PFR0_RAS_SHIFT) #define ID_AA64PFR0_SVE_SHIFT 32 +#define ID_AA64PFR0_SVE_WIDTH 4 #define ID_AA64PFR0_SVE_MASK (UL(0xf) << ID_AA64PFR0_SVE_SHIFT) #define ID_AA64PFR0_SVE_VAL(x) ((x) & ID_AA64PFR0_SVE_MASK) #define ID_AA64PFR0_SVE_NONE (UL(0x0) << ID_AA64PFR0_SVE_SHIFT) #define ID_AA64PFR0_SVE_IMPL (UL(0x1) << ID_AA64PFR0_SVE_SHIFT) #define ID_AA64PFR0_SEL2_SHIFT 36 +#define ID_AA64PFR0_SEL2_WIDTH 4 #define ID_AA64PFR0_SEL2_MASK (UL(0xf) << ID_AA64PFR0_SEL2_SHIFT) #define ID_AA64PFR0_SEL2_VAL(x) ((x) & ID_AA64PFR0_SEL2_MASK) #define ID_AA64PFR0_SEL2_NONE (UL(0x0) << ID_AA64PFR0_SEL2_SHIFT) #define ID_AA64PFR0_SEL2_IMPL (UL(0x1) << ID_AA64PFR0_SEL2_SHIFT) #define ID_AA64PFR0_MPAM_SHIFT 40 +#define ID_AA64PFR0_MPAM_WIDTH 4 #define ID_AA64PFR0_MPAM_MASK (UL(0xf) << ID_AA64PFR0_MPAM_SHIFT) #define ID_AA64PFR0_MPAM_VAL(x) ((x) & ID_AA64PFR0_MPAM_MASK) #define ID_AA64PFR0_MPAM_NONE (UL(0x0) << ID_AA64PFR0_MPAM_SHIFT) #define ID_AA64PFR0_MPAM_IMPL (UL(0x1) << ID_AA64PFR0_MPAM_SHIFT) #define ID_AA64PFR0_AMU_SHIFT 44 +#define ID_AA64PFR0_AMU_WIDTH 4 #define ID_AA64PFR0_AMU_MASK (UL(0xf) << ID_AA64PFR0_AMU_SHIFT) #define ID_AA64PFR0_AMU_VAL(x) ((x) & ID_AA64PFR0_AMU_MASK) #define ID_AA64PFR0_AMU_NONE (UL(0x0) << ID_AA64PFR0_AMU_SHIFT) #define ID_AA64PFR0_AMU_V1 (UL(0x1) << ID_AA64PFR0_AMU_SHIFT) #define ID_AA64PFR0_AMU_V1_1 (UL(0x2) << ID_AA64PFR0_AMU_SHIFT) #define ID_AA64PFR0_DIT_SHIFT 48 +#define ID_AA64PFR0_DIT_WIDTH 4 #define ID_AA64PFR0_DIT_MASK (UL(0xf) << ID_AA64PFR0_DIT_SHIFT) #define ID_AA64PFR0_DIT_VAL(x) ((x) & ID_AA64PFR0_DIT_MASK) #define ID_AA64PFR0_DIT_NONE (UL(0x0) << ID_AA64PFR0_DIT_SHIFT) #define ID_AA64PFR0_DIT_PSTATE (UL(0x1) << ID_AA64PFR0_DIT_SHIFT) #define ID_AA64PFR0_RME_SHIFT 52 +#define ID_AA64PFR0_RME_WIDTH 4 #define ID_AA64PFR0_RME_MASK (UL(0xf) << ID_AA64PFR0_RME_SHIFT) #define ID_AA64PFR0_RME_VAL(x) ((x) & ID_AA64PFR0_RME_MASK) #define ID_AA64PFR0_RME_NONE (UL(0x0) << ID_AA64PFR0_RME_SHIFT) #define ID_AA64PFR0_RME_IMPL (UL(0x1) << ID_AA64PFR0_RME_SHIFT) #define ID_AA64PFR0_CSV2_SHIFT 56 +#define ID_AA64PFR0_CSV2_WIDTH 4 #define ID_AA64PFR0_CSV2_MASK (UL(0xf) << ID_AA64PFR0_CSV2_SHIFT) #define ID_AA64PFR0_CSV2_VAL(x) ((x) & ID_AA64PFR0_CSV2_MASK) #define ID_AA64PFR0_CSV2_NONE (UL(0x0) << ID_AA64PFR0_CSV2_SHIFT) @@ -1449,31 +1707,35 @@ #define ID_AA64PFR0_CSV2_SCXTNUM (UL(0x2) << ID_AA64PFR0_CSV2_SHIFT) #define ID_AA64PFR0_CSV2_3 (UL(0x3) << ID_AA64PFR0_CSV2_SHIFT) #define ID_AA64PFR0_CSV3_SHIFT 60 +#define ID_AA64PFR0_CSV3_WIDTH 4 #define ID_AA64PFR0_CSV3_MASK (UL(0xf) << ID_AA64PFR0_CSV3_SHIFT) #define ID_AA64PFR0_CSV3_VAL(x) ((x) & ID_AA64PFR0_CSV3_MASK) #define ID_AA64PFR0_CSV3_NONE (UL(0x0) << ID_AA64PFR0_CSV3_SHIFT) #define ID_AA64PFR0_CSV3_ISOLATED (UL(0x1) << ID_AA64PFR0_CSV3_SHIFT) /* ID_AA64PFR1_EL1 */ -#define ID_AA64PFR1_EL1 MRS_REG(ID_AA64PFR1_EL1) #define ID_AA64PFR1_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR1_EL1) +#define ID_AA64PFR1_EL1_ISS ISS_MSR_REG(ID_AA64PFR1_EL1) #define ID_AA64PFR1_EL1_op0 3 #define ID_AA64PFR1_EL1_op1 0 #define ID_AA64PFR1_EL1_CRn 0 #define ID_AA64PFR1_EL1_CRm 4 #define ID_AA64PFR1_EL1_op2 1 #define ID_AA64PFR1_BT_SHIFT 0 +#define ID_AA64PFR1_BT_WIDTH 4 #define ID_AA64PFR1_BT_MASK (UL(0xf) << ID_AA64PFR1_BT_SHIFT) #define ID_AA64PFR1_BT_VAL(x) ((x) & ID_AA64PFR1_BT_MASK) #define ID_AA64PFR1_BT_NONE (UL(0x0) << ID_AA64PFR1_BT_SHIFT) #define ID_AA64PFR1_BT_IMPL (UL(0x1) << ID_AA64PFR1_BT_SHIFT) #define ID_AA64PFR1_SSBS_SHIFT 4 +#define ID_AA64PFR1_SSBS_WIDTH 4 #define ID_AA64PFR1_SSBS_MASK (UL(0xf) << ID_AA64PFR1_SSBS_SHIFT) #define ID_AA64PFR1_SSBS_VAL(x) ((x) & ID_AA64PFR1_SSBS_MASK) #define ID_AA64PFR1_SSBS_NONE (UL(0x0) << ID_AA64PFR1_SSBS_SHIFT) #define ID_AA64PFR1_SSBS_PSTATE (UL(0x1) << ID_AA64PFR1_SSBS_SHIFT) #define ID_AA64PFR1_SSBS_PSTATE_MSR (UL(0x2) << ID_AA64PFR1_SSBS_SHIFT) #define ID_AA64PFR1_MTE_SHIFT 8 +#define ID_AA64PFR1_MTE_WIDTH 4 #define ID_AA64PFR1_MTE_MASK (UL(0xf) << ID_AA64PFR1_MTE_SHIFT) #define ID_AA64PFR1_MTE_VAL(x) ((x) & ID_AA64PFR1_MTE_MASK) #define ID_AA64PFR1_MTE_NONE (UL(0x0) << ID_AA64PFR1_MTE_SHIFT) @@ -1481,41 +1743,77 @@ #define ID_AA64PFR1_MTE_MTE2 (UL(0x2) << ID_AA64PFR1_MTE_SHIFT) #define ID_AA64PFR1_MTE_MTE3 (UL(0x3) << ID_AA64PFR1_MTE_SHIFT) #define ID_AA64PFR1_RAS_frac_SHIFT 12 +#define ID_AA64PFR1_RAS_frac_WIDTH 4 #define ID_AA64PFR1_RAS_frac_MASK (UL(0xf) << ID_AA64PFR1_RAS_frac_SHIFT) #define ID_AA64PFR1_RAS_frac_VAL(x) ((x) & ID_AA64PFR1_RAS_frac_MASK) #define ID_AA64PFR1_RAS_frac_p0 (UL(0x0) << ID_AA64PFR1_RAS_frac_SHIFT) #define ID_AA64PFR1_RAS_frac_p1 (UL(0x1) << ID_AA64PFR1_RAS_frac_SHIFT) #define ID_AA64PFR1_MPAM_frac_SHIFT 16 +#define ID_AA64PFR1_MPAM_frac_WIDTH 4 #define ID_AA64PFR1_MPAM_frac_MASK (UL(0xf) << ID_AA64PFR1_MPAM_frac_SHIFT) #define ID_AA64PFR1_MPAM_frac_VAL(x) ((x) & ID_AA64PFR1_MPAM_frac_MASK) #define ID_AA64PFR1_MPAM_frac_p0 (UL(0x0) << ID_AA64PFR1_MPAM_frac_SHIFT) #define ID_AA64PFR1_MPAM_frac_p1 (UL(0x1) << ID_AA64PFR1_MPAM_frac_SHIFT) #define ID_AA64PFR1_SME_SHIFT 24 +#define ID_AA64PFR1_SME_WIDTH 4 #define ID_AA64PFR1_SME_MASK (UL(0xf) << ID_AA64PFR1_SME_SHIFT) #define ID_AA64PFR1_SME_VAL(x) ((x) & ID_AA64PFR1_SME_MASK) #define ID_AA64PFR1_SME_NONE (UL(0x0) << ID_AA64PFR1_SME_SHIFT) #define ID_AA64PFR1_SME_SME (UL(0x1) << ID_AA64PFR1_SME_SHIFT) #define ID_AA64PFR1_SME_SME2 (UL(0x2) << ID_AA64PFR1_SME_SHIFT) #define ID_AA64PFR1_RNDR_trap_SHIFT 28 +#define ID_AA64PFR1_RNDR_trap_WIDTH 4 #define ID_AA64PFR1_RNDR_trap_MASK (UL(0xf) << ID_AA64PFR1_RNDR_trap_SHIFT) #define ID_AA64PFR1_RNDR_trap_VAL(x) ((x) & ID_AA64PFR1_RNDR_trap_MASK) #define ID_AA64PFR1_RNDR_trap_NONE (UL(0x0) << ID_AA64PFR1_RNDR_trap_SHIFT) #define ID_AA64PFR1_RNDR_trap_IMPL (UL(0x1) << ID_AA64PFR1_RNDR_trap_SHIFT) #define ID_AA64PFR1_CSV2_frac_SHIFT 32 +#define ID_AA64PFR1_CSV2_frac_WIDTH 4 #define ID_AA64PFR1_CSV2_frac_MASK (UL(0xf) << ID_AA64PFR1_CSV2_frac_SHIFT) #define ID_AA64PFR1_CSV2_frac_VAL(x) ((x) & ID_AA64PFR1_CSV2_frac_MASK) #define ID_AA64PFR1_CSV2_frac_p0 (UL(0x0) << ID_AA64PFR1_CSV2_frac_SHIFT) #define ID_AA64PFR1_CSV2_frac_p1 (UL(0x1) << ID_AA64PFR1_CSV2_frac_SHIFT) #define ID_AA64PFR1_CSV2_frac_p2 (UL(0x2) << ID_AA64PFR1_CSV2_frac_SHIFT) #define ID_AA64PFR1_NMI_SHIFT 36 +#define ID_AA64PFR1_NMI_WIDTH 4 #define ID_AA64PFR1_NMI_MASK (UL(0xf) << ID_AA64PFR1_NMI_SHIFT) #define ID_AA64PFR1_NMI_VAL(x) ((x) & ID_AA64PFR1_NMI_MASK) #define ID_AA64PFR1_NMI_NONE (UL(0x0) << ID_AA64PFR1_NMI_SHIFT) #define ID_AA64PFR1_NMI_IMPL (UL(0x1) << ID_AA64PFR1_NMI_SHIFT) +#define ID_AA64PFR1_MTE_frac_SHIFT 40 +#define ID_AA64PFR1_MTE_frac_WIDTH 4 +#define ID_AA64PFR1_MTE_frac_MASK (UL(0xf) << ID_AA64PFR1_MTE_frac_SHIFT) +#define ID_AA64PFR1_MTE_frac_VAL(x) ((x) & ID_AA64PFR1_MTE_frac_MASK) +#define ID_AA64PFR1_MTE_frac_IMPL (UL(0x0) << ID_AA64PFR1_MTE_frac_SHIFT) +#define ID_AA64PFR1_MTE_frac_NONE (UL(0xf) << ID_AA64PFR1_MTE_frac_SHIFT) +#define ID_AA64PFR1_THE_SHIFT 48 +#define ID_AA64PFR1_THE_WIDTH 4 +#define ID_AA64PFR1_THE_MASK (UL(0xf) << ID_AA64PFR1_THE_SHIFT) +#define ID_AA64PFR1_THE_VAL(x) ((x) & ID_AA64PFR1_THE_MASK) +#define ID_AA64PFR1_THE_NONE (UL(0x0) << ID_AA64PFR1_THE_SHIFT) +#define ID_AA64PFR1_THE_IMPL (UL(0x1) << ID_AA64PFR1_THE_SHIFT) +#define ID_AA64PFR1_MTEX_SHIFT 52 +#define ID_AA64PFR1_MTEX_WIDTH 4 +#define ID_AA64PFR1_MTEX_MASK (UL(0xf) << ID_AA64PFR1_MTEX_SHIFT) +#define ID_AA64PFR1_MTEX_VAL(x) ((x) & ID_AA64PFR1_MTEX_MASK) +#define ID_AA64PFR1_MTEX_NONE (UL(0x0) << ID_AA64PFR1_MTEX_SHIFT) +#define ID_AA64PFR1_MTEX_IMPL (UL(0x1) << ID_AA64PFR1_MTEX_SHIFT) +#define ID_AA64PFR1_DF2_SHIFT 56 +#define ID_AA64PFR1_DF2_WIDTH 4 +#define ID_AA64PFR1_DF2_MASK (UL(0xf) << ID_AA64PFR1_DF2_SHIFT) +#define ID_AA64PFR1_DF2_VAL(x) ((x) & ID_AA64PFR1_DF2_MASK) +#define ID_AA64PFR1_DF2_NONE (UL(0x0) << ID_AA64PFR1_DF2_SHIFT) +#define ID_AA64PFR1_DF2_IMPL (UL(0x1) << ID_AA64PFR1_DF2_SHIFT) +#define ID_AA64PFR1_PFAR_SHIFT 60 +#define ID_AA64PFR1_PFAR_WIDTH 4 +#define ID_AA64PFR1_PFAR_MASK (UL(0xf) << ID_AA64PFR1_PFAR_SHIFT) +#define ID_AA64PFR1_PFAR_VAL(x) ((x) & ID_AA64PFR1_PFAR_MASK) +#define ID_AA64PFR1_PFAR_NONE (UL(0x0) << ID_AA64PFR1_PFAR_SHIFT) +#define ID_AA64PFR1_PFAR_IMPL (UL(0x1) << ID_AA64PFR1_PFAR_SHIFT) /* ID_AA64PFR2_EL1 */ -#define ID_AA64PFR2_EL1 MRS_REG(ID_AA64PFR2_EL1) #define ID_AA64PFR2_EL1_REG MRS_REG_ALT_NAME(ID_AA64PFR2_EL1) +#define ID_AA64PFR2_EL1_ISS ISS_MSR_REG(ID_AA64PFR2_EL1) #define ID_AA64PFR2_EL1_op0 3 #define ID_AA64PFR2_EL1_op1 0 #define ID_AA64PFR2_EL1_CRn 0 @@ -1523,101 +1821,117 @@ #define ID_AA64PFR2_EL1_op2 2 /* ID_AA64ZFR0_EL1 */ -#define ID_AA64ZFR0_EL1 MRS_REG(ID_AA64ZFR0_EL1) #define ID_AA64ZFR0_EL1_REG MRS_REG_ALT_NAME(ID_AA64ZFR0_EL1) +#define ID_AA64ZFR0_EL1_ISS ISS_MSR_REG(ID_AA64ZFR0_EL1) #define ID_AA64ZFR0_EL1_op0 3 #define ID_AA64ZFR0_EL1_op1 0 #define ID_AA64ZFR0_EL1_CRn 0 #define ID_AA64ZFR0_EL1_CRm 4 #define ID_AA64ZFR0_EL1_op2 4 #define ID_AA64ZFR0_SVEver_SHIFT 0 +#define ID_AA64ZFR0_SVEver_WIDTH 4 #define ID_AA64ZFR0_SVEver_MASK (UL(0xf) << ID_AA64ZFR0_SVEver_SHIFT) -#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK -#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT) -#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT) -#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT) +#define ID_AA64ZFR0_SVEver_VAL(x) ((x) & ID_AA64ZFR0_SVEver_MASK) +#define ID_AA64ZFR0_SVEver_SVE1 (UL(0x0) << ID_AA64ZFR0_SVEver_SHIFT) +#define ID_AA64ZFR0_SVEver_SVE2 (UL(0x1) << ID_AA64ZFR0_SVEver_SHIFT) +#define ID_AA64ZFR0_SVEver_SVE2P1 (UL(0x2) << ID_AA64ZFR0_SVEver_SHIFT) #define ID_AA64ZFR0_AES_SHIFT 4 +#define ID_AA64ZFR0_AES_WIDTH 4 #define ID_AA64ZFR0_AES_MASK (UL(0xf) << ID_AA64ZFR0_AES_SHIFT) -#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK -#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT) -#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT) -#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT) +#define ID_AA64ZFR0_AES_VAL(x) ((x) & ID_AA64ZFR0_AES_MASK) +#define ID_AA64ZFR0_AES_NONE (UL(0x0) << ID_AA64ZFR0_AES_SHIFT) +#define ID_AA64ZFR0_AES_BASE (UL(0x1) << ID_AA64ZFR0_AES_SHIFT) +#define ID_AA64ZFR0_AES_PMULL (UL(0x2) << ID_AA64ZFR0_AES_SHIFT) #define ID_AA64ZFR0_BitPerm_SHIFT 16 +#define ID_AA64ZFR0_BitPerm_WIDTH 4 #define ID_AA64ZFR0_BitPerm_MASK (UL(0xf) << ID_AA64ZFR0_BitPerm_SHIFT) -#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK -#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT) -#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT) +#define ID_AA64ZFR0_BitPerm_VAL(x) ((x) & ID_AA64ZFR0_BitPerm_MASK) +#define ID_AA64ZFR0_BitPerm_NONE (UL(0x0) << ID_AA64ZFR0_BitPerm_SHIFT) +#define ID_AA64ZFR0_BitPerm_IMPL (UL(0x1) << ID_AA64ZFR0_BitPerm_SHIFT) #define ID_AA64ZFR0_BF16_SHIFT 20 +#define ID_AA64ZFR0_BF16_WIDTH 4 #define ID_AA64ZFR0_BF16_MASK (UL(0xf) << ID_AA64ZFR0_BF16_SHIFT) -#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK -#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT) -#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT) -#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT) +#define ID_AA64ZFR0_BF16_VAL(x) ((x) & ID_AA64ZFR0_BF16_MASK) +#define ID_AA64ZFR0_BF16_NONE (UL(0x0) << ID_AA64ZFR0_BF16_SHIFT) +#define ID_AA64ZFR0_BF16_BASE (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT) +#define ID_AA64ZFR0_BF16_EBF (UL(0x1) << ID_AA64ZFR0_BF16_SHIFT) #define ID_AA64ZFR0_SHA3_SHIFT 32 +#define ID_AA64ZFR0_SHA3_WIDTH 4 #define ID_AA64ZFR0_SHA3_MASK (UL(0xf) << ID_AA64ZFR0_SHA3_SHIFT) -#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK -#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT) -#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT) +#define ID_AA64ZFR0_SHA3_VAL(x) ((x) & ID_AA64ZFR0_SHA3_MASK) +#define ID_AA64ZFR0_SHA3_NONE (UL(0x0) << ID_AA64ZFR0_SHA3_SHIFT) +#define ID_AA64ZFR0_SHA3_IMPL (UL(0x1) << ID_AA64ZFR0_SHA3_SHIFT) #define ID_AA64ZFR0_SM4_SHIFT 40 +#define ID_AA64ZFR0_SM4_WIDTH 4 #define ID_AA64ZFR0_SM4_MASK (UL(0xf) << ID_AA64ZFR0_SM4_SHIFT) -#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK -#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT) -#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT) +#define ID_AA64ZFR0_SM4_VAL(x) ((x) & ID_AA64ZFR0_SM4_MASK) +#define ID_AA64ZFR0_SM4_NONE (UL(0x0) << ID_AA64ZFR0_SM4_SHIFT) +#define ID_AA64ZFR0_SM4_IMPL (UL(0x1) << ID_AA64ZFR0_SM4_SHIFT) #define ID_AA64ZFR0_I8MM_SHIFT 44 +#define ID_AA64ZFR0_I8MM_WIDTH 4 #define ID_AA64ZFR0_I8MM_MASK (UL(0xf) << ID_AA64ZFR0_I8MM_SHIFT) -#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK -#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT) -#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT) +#define ID_AA64ZFR0_I8MM_VAL(x) ((x) & ID_AA64ZFR0_I8MM_MASK) +#define ID_AA64ZFR0_I8MM_NONE (UL(0x0) << ID_AA64ZFR0_I8MM_SHIFT) +#define ID_AA64ZFR0_I8MM_IMPL (UL(0x1) << ID_AA64ZFR0_I8MM_SHIFT) #define ID_AA64ZFR0_F32MM_SHIFT 52 +#define ID_AA64ZFR0_F32MM_WIDTH 4 #define ID_AA64ZFR0_F32MM_MASK (UL(0xf) << ID_AA64ZFR0_F32MM_SHIFT) -#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK -#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT) -#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT) +#define ID_AA64ZFR0_F32MM_VAL(x) ((x) & ID_AA64ZFR0_F32MM_MASK) +#define ID_AA64ZFR0_F32MM_NONE (UL(0x0) << ID_AA64ZFR0_F32MM_SHIFT) +#define ID_AA64ZFR0_F32MM_IMPL (UL(0x1) << ID_AA64ZFR0_F32MM_SHIFT) #define ID_AA64ZFR0_F64MM_SHIFT 56 +#define ID_AA64ZFR0_F64MM_WIDTH 4 #define ID_AA64ZFR0_F64MM_MASK (UL(0xf) << ID_AA64ZFR0_F64MM_SHIFT) -#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK -#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT) -#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT) +#define ID_AA64ZFR0_F64MM_VAL(x) ((x) & ID_AA64ZFR0_F64MM_MASK) +#define ID_AA64ZFR0_F64MM_NONE (UL(0x0) << ID_AA64ZFR0_F64MM_SHIFT) +#define ID_AA64ZFR0_F64MM_IMPL (UL(0x1) << ID_AA64ZFR0_F64MM_SHIFT) /* ID_ISAR5_EL1 */ -#define ID_ISAR5_EL1 MRS_REG(ID_ISAR5_EL1) +#define ID_ISAR5_EL1_ISS ISS_MSR_REG(ID_ISAR5_EL1) #define ID_ISAR5_EL1_op0 0x3 #define ID_ISAR5_EL1_op1 0x0 #define ID_ISAR5_EL1_CRn 0x0 #define ID_ISAR5_EL1_CRm 0x2 #define ID_ISAR5_EL1_op2 0x5 #define ID_ISAR5_SEVL_SHIFT 0 +#define ID_ISAR5_SEVL_WIDTH 4 #define ID_ISAR5_SEVL_MASK (UL(0xf) << ID_ISAR5_SEVL_SHIFT) #define ID_ISAR5_SEVL_VAL(x) ((x) & ID_ISAR5_SEVL_MASK) #define ID_ISAR5_SEVL_NOP (UL(0x0) << ID_ISAR5_SEVL_SHIFT) #define ID_ISAR5_SEVL_IMPL (UL(0x1) << ID_ISAR5_SEVL_SHIFT) #define ID_ISAR5_AES_SHIFT 4 +#define ID_ISAR5_AES_WIDTH 4 #define ID_ISAR5_AES_MASK (UL(0xf) << ID_ISAR5_AES_SHIFT) #define ID_ISAR5_AES_VAL(x) ((x) & ID_ISAR5_AES_MASK) #define ID_ISAR5_AES_NONE (UL(0x0) << ID_ISAR5_AES_SHIFT) #define ID_ISAR5_AES_BASE (UL(0x1) << ID_ISAR5_AES_SHIFT) #define ID_ISAR5_AES_VMULL (UL(0x2) << ID_ISAR5_AES_SHIFT) #define ID_ISAR5_SHA1_SHIFT 8 +#define ID_ISAR5_SHA1_WIDTH 4 #define ID_ISAR5_SHA1_MASK (UL(0xf) << ID_ISAR5_SHA1_SHIFT) #define ID_ISAR5_SHA1_VAL(x) ((x) & ID_ISAR5_SHA1_MASK) #define ID_ISAR5_SHA1_NONE (UL(0x0) << ID_ISAR5_SHA1_SHIFT) #define ID_ISAR5_SHA1_IMPL (UL(0x1) << ID_ISAR5_SHA1_SHIFT) #define ID_ISAR5_SHA2_SHIFT 12 +#define ID_ISAR5_SHA2_WIDTH 4 #define ID_ISAR5_SHA2_MASK (UL(0xf) << ID_ISAR5_SHA2_SHIFT) #define ID_ISAR5_SHA2_VAL(x) ((x) & ID_ISAR5_SHA2_MASK) #define ID_ISAR5_SHA2_NONE (UL(0x0) << ID_ISAR5_SHA2_SHIFT) #define ID_ISAR5_SHA2_IMPL (UL(0x1) << ID_ISAR5_SHA2_SHIFT) #define ID_ISAR5_CRC32_SHIFT 16 +#define ID_ISAR5_CRC32_WIDTH 4 #define ID_ISAR5_CRC32_MASK (UL(0xf) << ID_ISAR5_CRC32_SHIFT) #define ID_ISAR5_CRC32_VAL(x) ((x) & ID_ISAR5_CRC32_MASK) #define ID_ISAR5_CRC32_NONE (UL(0x0) << ID_ISAR5_CRC32_SHIFT) #define ID_ISAR5_CRC32_IMPL (UL(0x1) << ID_ISAR5_CRC32_SHIFT) #define ID_ISAR5_RDM_SHIFT 24 +#define ID_ISAR5_RDM_WIDTH 4 #define ID_ISAR5_RDM_MASK (UL(0xf) << ID_ISAR5_RDM_SHIFT) #define ID_ISAR5_RDM_VAL(x) ((x) & ID_ISAR5_RDM_MASK) #define ID_ISAR5_RDM_NONE (UL(0x0) << ID_ISAR5_RDM_SHIFT) #define ID_ISAR5_RDM_IMPL (UL(0x1) << ID_ISAR5_RDM_SHIFT) #define ID_ISAR5_VCMA_SHIFT 28 +#define ID_ISAR5_VCMA_WIDTH 4 #define ID_ISAR5_VCMA_MASK (UL(0xf) << ID_ISAR5_VCMA_SHIFT) #define ID_ISAR5_VCMA_VAL(x) ((x) & ID_ISAR5_VCMA_MASK) #define ID_ISAR5_VCMA_NONE (UL(0x0) << ID_ISAR5_VCMA_SHIFT) @@ -1647,7 +1961,6 @@ #define MAIR_EL12_op2 0 /* MDCCINT_EL1 */ -#define MDCCINT_EL1 MRS_REG(MDCCINT_EL1) #define MDCCINT_EL1_op0 2 #define MDCCINT_EL1_op1 0 #define MDCCINT_EL1_CRn 0 @@ -1655,7 +1968,6 @@ #define MDCCINT_EL1_op2 0 /* MDCCSR_EL0 */ -#define MDCCSR_EL0 MRS_REG(MDCCSR_EL0) #define MDCCSR_EL0_op0 2 #define MDCCSR_EL0_op1 3 #define MDCCSR_EL0_CRn 0 @@ -1663,7 +1975,6 @@ #define MDCCSR_EL0_op2 0 /* MDSCR_EL1 - Monitor Debug System Control Register */ -#define MDSCR_EL1 MRS_REG(MDSCR_EL1) #define MDSCR_EL1_op0 2 #define MDSCR_EL1_op1 0 #define MDSCR_EL1_CRn 0 @@ -1677,7 +1988,6 @@ #define MDSCR_MDE (UL(0x1) << MDSCR_MDE_SHIFT) /* MIDR_EL1 - Main ID Register */ -#define MIDR_EL1 MRS_REG(MIDR_EL1) #define MIDR_EL1_op0 3 #define MIDR_EL1_op1 0 #define MIDR_EL1_CRn 0 @@ -1685,7 +1995,6 @@ #define MIDR_EL1_op2 0 /* MPIDR_EL1 - Multiprocessor Affinity Register */ -#define MPIDR_EL1 MRS_REG(MPIDR_EL1) #define MPIDR_EL1_op0 3 #define MPIDR_EL1_op1 0 #define MPIDR_EL1_CRn 0 @@ -1709,95 +2018,110 @@ #define MPIDR_AFF3_VAL(x) ((x) & MPIDR_AFF3_MASK) /* MVFR0_EL1 */ -#define MVFR0_EL1 MRS_REG(MVFR0_EL1) +#define MVFR0_EL1_ISS ISS_MSR_REG(MVFR0_EL1) #define MVFR0_EL1_op0 0x3 #define MVFR0_EL1_op1 0x0 #define MVFR0_EL1_CRn 0x0 #define MVFR0_EL1_CRm 0x3 #define MVFR0_EL1_op2 0x0 #define MVFR0_SIMDReg_SHIFT 0 +#define MVFR0_SIMDReg_WIDTH 4 #define MVFR0_SIMDReg_MASK (UL(0xf) << MVFR0_SIMDReg_SHIFT) #define MVFR0_SIMDReg_VAL(x) ((x) & MVFR0_SIMDReg_MASK) #define MVFR0_SIMDReg_NONE (UL(0x0) << MVFR0_SIMDReg_SHIFT) #define MVFR0_SIMDReg_FP (UL(0x1) << MVFR0_SIMDReg_SHIFT) #define MVFR0_SIMDReg_AdvSIMD (UL(0x2) << MVFR0_SIMDReg_SHIFT) #define MVFR0_FPSP_SHIFT 4 +#define MVFR0_FPSP_WIDTH 4 #define MVFR0_FPSP_MASK (UL(0xf) << MVFR0_FPSP_SHIFT) #define MVFR0_FPSP_VAL(x) ((x) & MVFR0_FPSP_MASK) #define MVFR0_FPSP_NONE (UL(0x0) << MVFR0_FPSP_SHIFT) #define MVFR0_FPSP_VFP_v2 (UL(0x1) << MVFR0_FPSP_SHIFT) #define MVFR0_FPSP_VFP_v3_v4 (UL(0x2) << MVFR0_FPSP_SHIFT) #define MVFR0_FPDP_SHIFT 8 +#define MVFR0_FPDP_WIDTH 4 #define MVFR0_FPDP_MASK (UL(0xf) << MVFR0_FPDP_SHIFT) #define MVFR0_FPDP_VAL(x) ((x) & MVFR0_FPDP_MASK) #define MVFR0_FPDP_NONE (UL(0x0) << MVFR0_FPDP_SHIFT) #define MVFR0_FPDP_VFP_v2 (UL(0x1) << MVFR0_FPDP_SHIFT) #define MVFR0_FPDP_VFP_v3_v4 (UL(0x2) << MVFR0_FPDP_SHIFT) #define MVFR0_FPTrap_SHIFT 12 +#define MVFR0_FPTrap_WIDTH 4 #define MVFR0_FPTrap_MASK (UL(0xf) << MVFR0_FPTrap_SHIFT) #define MVFR0_FPTrap_VAL(x) ((x) & MVFR0_FPTrap_MASK) #define MVFR0_FPTrap_NONE (UL(0x0) << MVFR0_FPTrap_SHIFT) #define MVFR0_FPTrap_IMPL (UL(0x1) << MVFR0_FPTrap_SHIFT) #define MVFR0_FPDivide_SHIFT 16 +#define MVFR0_FPDivide_WIDTH 4 #define MVFR0_FPDivide_MASK (UL(0xf) << MVFR0_FPDivide_SHIFT) #define MVFR0_FPDivide_VAL(x) ((x) & MVFR0_FPDivide_MASK) #define MVFR0_FPDivide_NONE (UL(0x0) << MVFR0_FPDivide_SHIFT) #define MVFR0_FPDivide_IMPL (UL(0x1) << MVFR0_FPDivide_SHIFT) #define MVFR0_FPSqrt_SHIFT 20 +#define MVFR0_FPSqrt_WIDTH 4 #define MVFR0_FPSqrt_MASK (UL(0xf) << MVFR0_FPSqrt_SHIFT) #define MVFR0_FPSqrt_VAL(x) ((x) & MVFR0_FPSqrt_MASK) #define MVFR0_FPSqrt_NONE (UL(0x0) << MVFR0_FPSqrt_SHIFT) #define MVFR0_FPSqrt_IMPL (UL(0x1) << MVFR0_FPSqrt_SHIFT) #define MVFR0_FPShVec_SHIFT 24 +#define MVFR0_FPShVec_WIDTH 4 #define MVFR0_FPShVec_MASK (UL(0xf) << MVFR0_FPShVec_SHIFT) #define MVFR0_FPShVec_VAL(x) ((x) & MVFR0_FPShVec_MASK) #define MVFR0_FPShVec_NONE (UL(0x0) << MVFR0_FPShVec_SHIFT) #define MVFR0_FPShVec_IMPL (UL(0x1) << MVFR0_FPShVec_SHIFT) #define MVFR0_FPRound_SHIFT 28 +#define MVFR0_FPRound_WIDTH 4 #define MVFR0_FPRound_MASK (UL(0xf) << MVFR0_FPRound_SHIFT) #define MVFR0_FPRound_VAL(x) ((x) & MVFR0_FPRound_MASK) #define MVFR0_FPRound_NONE (UL(0x0) << MVFR0_FPRound_SHIFT) #define MVFR0_FPRound_IMPL (UL(0x1) << MVFR0_FPRound_SHIFT) /* MVFR1_EL1 */ -#define MVFR1_EL1 MRS_REG(MVFR1_EL1) +#define MVFR1_EL1_ISS ISS_MSR_REG(MVFR1_EL1) #define MVFR1_EL1_op0 0x3 #define MVFR1_EL1_op1 0x0 #define MVFR1_EL1_CRn 0x0 #define MVFR1_EL1_CRm 0x3 #define MVFR1_EL1_op2 0x1 #define MVFR1_FPFtZ_SHIFT 0 +#define MVFR1_FPFtZ_WIDTH 4 #define MVFR1_FPFtZ_MASK (UL(0xf) << MVFR1_FPFtZ_SHIFT) #define MVFR1_FPFtZ_VAL(x) ((x) & MVFR1_FPFtZ_MASK) #define MVFR1_FPFtZ_NONE (UL(0x0) << MVFR1_FPFtZ_SHIFT) #define MVFR1_FPFtZ_IMPL (UL(0x1) << MVFR1_FPFtZ_SHIFT) #define MVFR1_FPDNaN_SHIFT 4 +#define MVFR1_FPDNaN_WIDTH 4 #define MVFR1_FPDNaN_MASK (UL(0xf) << MVFR1_FPDNaN_SHIFT) #define MVFR1_FPDNaN_VAL(x) ((x) & MVFR1_FPDNaN_MASK) #define MVFR1_FPDNaN_NONE (UL(0x0) << MVFR1_FPDNaN_SHIFT) #define MVFR1_FPDNaN_IMPL (UL(0x1) << MVFR1_FPDNaN_SHIFT) #define MVFR1_SIMDLS_SHIFT 8 +#define MVFR1_SIMDLS_WIDTH 4 #define MVFR1_SIMDLS_MASK (UL(0xf) << MVFR1_SIMDLS_SHIFT) #define MVFR1_SIMDLS_VAL(x) ((x) & MVFR1_SIMDLS_MASK) #define MVFR1_SIMDLS_NONE (UL(0x0) << MVFR1_SIMDLS_SHIFT) #define MVFR1_SIMDLS_IMPL (UL(0x1) << MVFR1_SIMDLS_SHIFT) #define MVFR1_SIMDInt_SHIFT 12 +#define MVFR1_SIMDInt_WIDTH 4 #define MVFR1_SIMDInt_MASK (UL(0xf) << MVFR1_SIMDInt_SHIFT) #define MVFR1_SIMDInt_VAL(x) ((x) & MVFR1_SIMDInt_MASK) #define MVFR1_SIMDInt_NONE (UL(0x0) << MVFR1_SIMDInt_SHIFT) #define MVFR1_SIMDInt_IMPL (UL(0x1) << MVFR1_SIMDInt_SHIFT) #define MVFR1_SIMDSP_SHIFT 16 +#define MVFR1_SIMDSP_WIDTH 4 #define MVFR1_SIMDSP_MASK (UL(0xf) << MVFR1_SIMDSP_SHIFT) #define MVFR1_SIMDSP_VAL(x) ((x) & MVFR1_SIMDSP_MASK) #define MVFR1_SIMDSP_NONE (UL(0x0) << MVFR1_SIMDSP_SHIFT) #define MVFR1_SIMDSP_IMPL (UL(0x1) << MVFR1_SIMDSP_SHIFT) #define MVFR1_SIMDHP_SHIFT 20 +#define MVFR1_SIMDHP_WIDTH 4 #define MVFR1_SIMDHP_MASK (UL(0xf) << MVFR1_SIMDHP_SHIFT) #define MVFR1_SIMDHP_VAL(x) ((x) & MVFR1_SIMDHP_MASK) #define MVFR1_SIMDHP_NONE (UL(0x0) << MVFR1_SIMDHP_SHIFT) #define MVFR1_SIMDHP_CONV_SP (UL(0x1) << MVFR1_SIMDHP_SHIFT) #define MVFR1_SIMDHP_ARITH (UL(0x2) << MVFR1_SIMDHP_SHIFT) #define MVFR1_FPHP_SHIFT 24 +#define MVFR1_FPHP_WIDTH 4 #define MVFR1_FPHP_MASK (UL(0xf) << MVFR1_FPHP_SHIFT) #define MVFR1_FPHP_VAL(x) ((x) & MVFR1_FPHP_MASK) #define MVFR1_FPHP_NONE (UL(0x0) << MVFR1_FPHP_SHIFT) @@ -1805,13 +2129,13 @@ #define MVFR1_FPHP_CONV_DP (UL(0x2) << MVFR1_FPHP_SHIFT) #define MVFR1_FPHP_ARITH (UL(0x3) << MVFR1_FPHP_SHIFT) #define MVFR1_SIMDFMAC_SHIFT 28 +#define MVFR1_SIMDFMAC_WIDTH 4 #define MVFR1_SIMDFMAC_MASK (UL(0xf) << MVFR1_SIMDFMAC_SHIFT) #define MVFR1_SIMDFMAC_VAL(x) ((x) & MVFR1_SIMDFMAC_MASK) #define MVFR1_SIMDFMAC_NONE (UL(0x0) << MVFR1_SIMDFMAC_SHIFT) #define MVFR1_SIMDFMAC_IMPL (UL(0x1) << MVFR1_SIMDFMAC_SHIFT) /* OSDLR_EL1 */ -#define OSDLR_EL1 MRS_REG(OSDLR_EL1) #define OSDLR_EL1_op0 2 #define OSDLR_EL1_op1 0 #define OSDLR_EL1_CRn 1 @@ -1819,20 +2143,23 @@ #define OSDLR_EL1_op2 4 /* OSLAR_EL1 */ -#define OSLAR_EL1 MRS_REG(OSLAR_EL1) #define OSLAR_EL1_op0 2 #define OSLAR_EL1_op1 0 #define OSLAR_EL1_CRn 1 #define OSLAR_EL1_CRm 0 #define OSLAR_EL1_op2 4 +#define OSLAR_OSLK (0x1ul << 0) /* OSLSR_EL1 */ -#define OSLSR_EL1 MRS_REG(OSLSR_EL1) #define OSLSR_EL1_op0 2 #define OSLSR_EL1_op1 0 #define OSLSR_EL1_CRn 1 #define OSLSR_EL1_CRm 1 #define OSLSR_EL1_op2 4 +#define OSLSR_OSLM_1 (0x1ul << 3) +#define OSLSR_nTT (0x1ul << 2) +#define OSLSR_OSLK (0x1ul << 1) +#define OSLSR_OSLM_0 (0x1ul << 0) /* PAR_EL1 - Physical Address Register */ #define PAR_F_SHIFT 0 @@ -1845,7 +2172,7 @@ #define PAR_NS_SHIFT 9 #define PAR_NS_MASK (0x3 << PAR_NS_SHIFT) #define PAR_PA_SHIFT 12 -#define PAR_PA_MASK 0x0000fffffffff000 +#define PAR_PA_MASK 0x000ffffffffff000 #define PAR_ATTR_SHIFT 56 #define PAR_ATTR_MASK (0xff << PAR_ATTR_SHIFT) /* When PAR_F == 1 (aborted) */ @@ -1857,7 +2184,6 @@ #define PAR_S_MASK (0x1 << PAR_S_SHIFT) /* PMBIDR_EL1 */ -#define PMBIDR_EL1 MRS_REG(PMBIDR_EL1) #define PMBIDR_EL1_REG MRS_REG_ALT_NAME(PMBIDR_EL1) #define PMBIDR_EL1_op0 3 #define PMBIDR_EL1_op1 0 @@ -1872,7 +2198,6 @@ #define PMBIDR_F (UL(0x1) << PMBIDR_F_SHIFT) /* PMBLIMITR_EL1 */ -#define PMBLIMITR_EL1 MRS_REG(PMBLIMITR_EL1) #define PMBLIMITR_EL1_REG MRS_REG_ALT_NAME(PMBLIMITR_EL1) #define PMBLIMITR_EL1_op0 3 #define PMBLIMITR_EL1_op1 0 @@ -1890,7 +2215,6 @@ (UL(0xfffffffffffff) << PMBLIMITR_LIMIT_SHIFT) /* PMBPTR_EL1 */ -#define PMBPTR_EL1 MRS_REG(PMBPTR_EL1) #define PMBPTR_EL1_REG MRS_REG_ALT_NAME(PMBPTR_EL1) #define PMBPTR_EL1_op0 3 #define PMBPTR_EL1_op1 0 @@ -1902,7 +2226,6 @@ (UL(0xffffffffffffffff) << PMBPTR_PTR_SHIFT) /* PMBSR_EL1 */ -#define PMBSR_EL1 MRS_REG(PMBSR_EL1) #define PMBSR_EL1_REG MRS_REG_ALT_NAME(PMBSR_EL1) #define PMBSR_EL1_op0 3 #define PMBSR_EL1_op1 0 @@ -1925,7 +2248,6 @@ #define PMBSR_EC_MASK (UL(0x3f) << PMBSR_EC_SHIFT) /* PMCCFILTR_EL0 */ -#define PMCCFILTR_EL0 MRS_REG(PMCCFILTR_EL0) #define PMCCFILTR_EL0_op0 3 #define PMCCFILTR_EL0_op1 3 #define PMCCFILTR_EL0_CRn 14 @@ -1933,7 +2255,6 @@ #define PMCCFILTR_EL0_op2 7 /* PMCCNTR_EL0 */ -#define PMCCNTR_EL0 MRS_REG(PMCCNTR_EL0) #define PMCCNTR_EL0_op0 3 #define PMCCNTR_EL0_op1 3 #define PMCCNTR_EL0_CRn 9 @@ -1941,7 +2262,6 @@ #define PMCCNTR_EL0_op2 0 /* PMCEID0_EL0 */ -#define PMCEID0_EL0 MRS_REG(PMCEID0_EL0) #define PMCEID0_EL0_op0 3 #define PMCEID0_EL0_op1 3 #define PMCEID0_EL0_CRn 9 @@ -1949,7 +2269,6 @@ #define PMCEID0_EL0_op2 6 /* PMCEID1_EL0 */ -#define PMCEID1_EL0 MRS_REG(PMCEID1_EL0) #define PMCEID1_EL0_op0 3 #define PMCEID1_EL0_op1 3 #define PMCEID1_EL0_CRn 9 @@ -1957,7 +2276,6 @@ #define PMCEID1_EL0_op2 7 /* PMCNTENCLR_EL0 */ -#define PMCNTENCLR_EL0 MRS_REG(PMCNTENCLR_EL0) #define PMCNTENCLR_EL0_op0 3 #define PMCNTENCLR_EL0_op1 3 #define PMCNTENCLR_EL0_CRn 9 @@ -1965,7 +2283,6 @@ #define PMCNTENCLR_EL0_op2 2 /* PMCNTENSET_EL0 */ -#define PMCNTENSET_EL0 MRS_REG(PMCNTENSET_EL0) #define PMCNTENSET_EL0_op0 3 #define PMCNTENSET_EL0_op1 3 #define PMCNTENSET_EL0_CRn 9 @@ -1973,24 +2290,24 @@ #define PMCNTENSET_EL0_op2 1 /* PMCR_EL0 - Perfomance Monitoring Counters */ -#define PMCR_EL0 MRS_REG(PMCR_EL0) #define PMCR_EL0_op0 3 #define PMCR_EL0_op1 3 #define PMCR_EL0_CRn 9 #define PMCR_EL0_CRm 12 #define PMCR_EL0_op2 0 -#define PMCR_E (1 << 0) /* Enable all counters */ -#define PMCR_P (1 << 1) /* Reset all counters */ -#define PMCR_C (1 << 2) /* Clock counter reset */ -#define PMCR_D (1 << 3) /* CNTR counts every 64 clk cycles */ -#define PMCR_X (1 << 4) /* Export to ext. monitoring (ETM) */ -#define PMCR_DP (1 << 5) /* Disable CCNT if non-invasive debug*/ -#define PMCR_LC (1 << 6) /* Long cycle count enable */ -#define PMCR_IMP_SHIFT 24 /* Implementer code */ -#define PMCR_IMP_MASK (0xff << PMCR_IMP_SHIFT) -#define PMCR_IMP_ARM 0x41 +#define PMCR_E (1ul << 0) /* Enable all counters */ +#define PMCR_P (1ul << 1) /* Reset all counters */ +#define PMCR_C (1ul << 2) /* Clock counter reset */ +#define PMCR_D (1ul << 3) /* CNTR counts every 64 clk cycles */ +#define PMCR_X (1ul << 4) /* Export to ext. monitoring (ETM) */ +#define PMCR_DP (1ul << 5) /* Disable CCNT if non-invasive debug*/ +#define PMCR_LC (1ul << 6) /* Long cycle count enable */ +#define PMCR_LP (1ul << 7) /* Long event count enable */ +#define PMCR_FZO (1ul << 9) /* Freeze-on-overflow */ +#define PMCR_N_SHIFT 11 /* Number of counters implemented */ +#define PMCR_N_MASK (0x1ful << PMCR_N_SHIFT) #define PMCR_IDCODE_SHIFT 16 /* Identification code */ -#define PMCR_IDCODE_MASK (0xff << PMCR_IDCODE_SHIFT) +#define PMCR_IDCODE_MASK (0xfful << PMCR_IDCODE_SHIFT) #define PMCR_IDCODE_CORTEX_A57 0x01 #define PMCR_IDCODE_CORTEX_A72 0x02 #define PMCR_IDCODE_CORTEX_A53 0x03 @@ -2002,8 +2319,10 @@ #define PMCR_IDCODE_CORTEX_A55 0x45 #define PMCR_IDCODE_NEOVERSE_E1 0x46 #define PMCR_IDCODE_CORTEX_A75 0x4a -#define PMCR_N_SHIFT 11 /* Number of counters implemented */ -#define PMCR_N_MASK (0x1f << PMCR_N_SHIFT) +#define PMCR_IMP_SHIFT 24 /* Implementer code */ +#define PMCR_IMP_MASK (0xfful << PMCR_IMP_SHIFT) +#define PMCR_IMP_ARM 0x41 +#define PMCR_FZS (1ul << 32) /* Freeze-on-SPE event */ /* PMEVCNTR_EL0 */ #define PMEVCNTR_EL0_op0 3 @@ -2035,7 +2354,6 @@ #define PMEVTYPER_P (1 << 31) /* Privileged filtering */ /* PMINTENCLR_EL1 */ -#define PMINTENCLR_EL1 MRS_REG(PMINTENCLR_EL1) #define PMINTENCLR_EL1_op0 3 #define PMINTENCLR_EL1_op1 0 #define PMINTENCLR_EL1_CRn 9 @@ -2043,7 +2361,6 @@ #define PMINTENCLR_EL1_op2 2 /* PMINTENSET_EL1 */ -#define PMINTENSET_EL1 MRS_REG(PMINTENSET_EL1) #define PMINTENSET_EL1_op0 3 #define PMINTENSET_EL1_op1 0 #define PMINTENSET_EL1_CRn 9 @@ -2051,7 +2368,6 @@ #define PMINTENSET_EL1_op2 1 /* PMMIR_EL1 */ -#define PMMIR_EL1 MRS_REG(PMMIR_EL1) #define PMMIR_EL1_op0 3 #define PMMIR_EL1_op1 0 #define PMMIR_EL1_CRn 9 @@ -2059,7 +2375,6 @@ #define PMMIR_EL1_op2 6 /* PMOVSCLR_EL0 */ -#define PMOVSCLR_EL0 MRS_REG(PMOVSCLR_EL0) #define PMOVSCLR_EL0_op0 3 #define PMOVSCLR_EL0_op1 3 #define PMOVSCLR_EL0_CRn 9 @@ -2067,7 +2382,6 @@ #define PMOVSCLR_EL0_op2 3 /* PMOVSSET_EL0 */ -#define PMOVSSET_EL0 MRS_REG(PMOVSSET_EL0) #define PMOVSSET_EL0_op0 3 #define PMOVSSET_EL0_op1 3 #define PMOVSSET_EL0_CRn 9 @@ -2075,7 +2389,6 @@ #define PMOVSSET_EL0_op2 3 /* PMSCR_EL1 */ -#define PMSCR_EL1 MRS_REG(PMSCR_EL1) #define PMSCR_EL1_REG MRS_REG_ALT_NAME(PMSCR_EL1) #define PMSCR_EL1_op0 3 #define PMSCR_EL1_op1 0 @@ -2096,7 +2409,6 @@ #define PMSCR_PCT_MASK (UL(0x3) << PMSCR_PCT_SHIFT) /* PMSELR_EL0 */ -#define PMSELR_EL0 MRS_REG(PMSELR_EL0) #define PMSELR_EL0_op0 3 #define PMSELR_EL0_op1 3 #define PMSELR_EL0_CRn 9 @@ -2105,7 +2417,6 @@ #define PMSELR_SEL_MASK 0x1f /* PMSEVFR_EL1 */ -#define PMSEVFR_EL1 MRS_REG(PMSEVFR_EL1) #define PMSEVFR_EL1_REG MRS_REG_ALT_NAME(PMSEVFR_EL1) #define PMSEVFR_EL1_op0 3 #define PMSEVFR_EL1_op1 0 @@ -2114,7 +2425,6 @@ #define PMSEVFR_EL1_op2 5 /* PMSFCR_EL1 */ -#define PMSFCR_EL1 MRS_REG(PMSFCR_EL1) #define PMSFCR_EL1_REG MRS_REG_ALT_NAME(PMSFCR_EL1) #define PMSFCR_EL1_op0 3 #define PMSFCR_EL1_op1 0 @@ -2137,7 +2447,6 @@ #define PMSFCR_ST (UL(0x1) << PMSFCR_ST_SHIFT) /* PMSICR_EL1 */ -#define PMSICR_EL1 MRS_REG(PMSICR_EL1) #define PMSICR_EL1_REG MRS_REG_ALT_NAME(PMSICR_EL1) #define PMSICR_EL1_op0 3 #define PMSICR_EL1_op1 0 @@ -2150,7 +2459,6 @@ #define PMSICR_ECOUNT_MASK (UL(0xff) << PMSICR_ECOUNT_SHIFT) /* PMSIDR_EL1 */ -#define PMSIDR_EL1 MRS_REG(PMSIDR_EL1) #define PMSIDR_EL1_REG MRS_REG_ALT_NAME(PMSIDR_EL1) #define PMSIDR_EL1_op0 3 #define PMSIDR_EL1_op1 0 @@ -2183,7 +2491,6 @@ #define PMSIDR_PBT (UL(0x1) << PMSIDR_PBT_SHIFT) /* PMSIRR_EL1 */ -#define PMSIRR_EL1 MRS_REG(PMSIRR_EL1) #define PMSIRR_EL1_REG MRS_REG_ALT_NAME(PMSIRR_EL1) #define PMSIRR_EL1_op0 3 #define PMSIRR_EL1_op1 0 @@ -2196,7 +2503,6 @@ #define PMSIRR_INTERVAL_MASK (UL(0xffffff) << PMSIRR_INTERVAL_SHIFT) /* PMSLATFR_EL1 */ -#define PMSLATFR_EL1 MRS_REG(PMSLATFR_EL1) #define PMSLATFR_EL1_REG MRS_REG_ALT_NAME(PMSLATFR_EL1) #define PMSLATFR_EL1_op0 3 #define PMSLATFR_EL1_op1 0 @@ -2207,7 +2513,6 @@ #define PMSLATFR_MINLAT_MASK (UL(0xfff) << PMSLATFR_MINLAT_SHIFT) /* PMSNEVFR_EL1 */ -#define PMSNEVFR_EL1 MRS_REG(PMSNEVFR_EL1) #define PMSNEVFR_EL1_REG MRS_REG_ALT_NAME(PMSNEVFR_EL1) #define PMSNEVFR_EL1_op0 3 #define PMSNEVFR_EL1_op1 0 @@ -2216,7 +2521,6 @@ #define PMSNEVFR_EL1_op2 1 /* PMSWINC_EL0 */ -#define PMSWINC_EL0 MRS_REG(PMSWINC_EL0) #define PMSWINC_EL0_op0 3 #define PMSWINC_EL0_op1 3 #define PMSWINC_EL0_CRn 9 @@ -2224,7 +2528,6 @@ #define PMSWINC_EL0_op2 4 /* PMUSERENR_EL0 */ -#define PMUSERENR_EL0 MRS_REG(PMUSERENR_EL0) #define PMUSERENR_EL0_op0 3 #define PMUSERENR_EL0_op1 3 #define PMUSERENR_EL0_CRn 9 @@ -2232,7 +2535,6 @@ #define PMUSERENR_EL0_op2 0 /* PMXEVCNTR_EL0 */ -#define PMXEVCNTR_EL0 MRS_REG(PMXEVCNTR_EL0) #define PMXEVCNTR_EL0_op0 3 #define PMXEVCNTR_EL0_op1 3 #define PMXEVCNTR_EL0_CRn 9 @@ -2240,7 +2542,6 @@ #define PMXEVCNTR_EL0_op2 2 /* PMXEVTYPER_EL0 */ -#define PMXEVTYPER_EL0 MRS_REG(PMXEVTYPER_EL0) #define PMXEVTYPER_EL0_op0 3 #define PMXEVTYPER_EL0_op1 3 #define PMXEVTYPER_EL0_CRn 9 @@ -2248,7 +2549,6 @@ #define PMXEVTYPER_EL0_op2 1 /* RNDRRS */ -#define RNDRRS MRS_REG(RNDRRS) #define RNDRRS_REG MRS_REG_ALT_NAME(RNDRRS) #define RNDRRS_op0 3 #define RNDRRS_op1 3 @@ -2313,6 +2613,26 @@ #define SCTLR_EnALS (UL(0x1) << 56) #define SCTLR_EPAN (UL(0x1) << 57) +#define SCTLR_MMU_OFF \ + (SCTLR_LSMAOE | SCTLR_nTLSMD | SCTLR_EIS | SCTLR_TSCXT | SCTLR_EOS) +#define SCTLR_MMU_ON \ + (SCTLR_MMU_OFF | \ + SCTLR_BT1 | \ + SCTLR_BT0 | \ + SCTLR_UCI | \ + SCTLR_SPAN | \ + SCTLR_nTWE | \ + SCTLR_nTWI | \ + SCTLR_UCT | \ + SCTLR_DZE | \ + SCTLR_I | \ + SCTLR_SED | \ + SCTLR_CP15BEN | \ + SCTLR_SA0 | \ + SCTLR_SA | \ + SCTLR_C | \ + SCTLR_M) + /* SCTLR_EL12 */ #define SCTLR_EL12_REG MRS_REG_ALT_NAME(SCTLR_EL12) #define SCTLR_EL12_op0 3 @@ -2354,7 +2674,8 @@ #define PSR_D 0x00000200UL #define PSR_DAIF (PSR_D | PSR_A | PSR_I | PSR_F) /* The default DAIF mask. These bits are valid in spsr_el1 and daif */ -#define PSR_DAIF_DEFAULT (PSR_F) +#define PSR_DAIF_DEFAULT (0) +#define PSR_DAIF_INTR (PSR_I | PSR_F) #define PSR_BTYPE 0x00000c00UL #define PSR_SSBS 0x00001000UL #define PSR_ALLINT 0x00002000UL @@ -2382,7 +2703,6 @@ #define SPSR_EL12_op2 0 /* REVIDR_EL1 - Revision ID Register */ -#define REVIDR_EL1 MRS_REG(REVIDR_EL1) #define REVIDR_EL1_op0 3 #define REVIDR_EL1_op1 0 #define REVIDR_EL1_CRn 0 @@ -2496,14 +2816,6 @@ #define TCR_T0SZ(x) ((x) << TCR_T0SZ_SHIFT) #define TCR_TxSZ(x) (TCR_T1SZ(x) | TCR_T0SZ(x)) -#define TCR_CACHE_ATTRS ((TCR_IRGN0_WBWA | TCR_IRGN1_WBWA) |\ - (TCR_ORGN0_WBWA | TCR_ORGN1_WBWA)) -#ifdef SMP -#define TCR_SMP_ATTRS (TCR_SH0_IS | TCR_SH1_IS) -#else -#define TCR_SMP_ATTRS 0 -#endif - /* TCR_EL12 */ #define TCR_EL12_REG MRS_REG_ALT_NAME(TCR_EL12) #define TCR_EL12_op0 3 @@ -2568,13 +2880,12 @@ #define VBAR_EL12_op2 0 /* ZCR_EL1 - SVE Control Register */ -#define ZCR_EL1 MRS_REG(ZCR_EL1) -#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1_REG) -#define ZCR_EL1_REG_op0 3 -#define ZCR_EL1_REG_op1 0 -#define ZCR_EL1_REG_CRn 1 -#define ZCR_EL1_REG_CRm 2 -#define ZCR_EL1_REG_op2 0 +#define ZCR_EL1_REG MRS_REG_ALT_NAME(ZCR_EL1) +#define ZCR_EL1_op0 3 +#define ZCR_EL1_op1 0 +#define ZCR_EL1_CRn 1 +#define ZCR_EL1_CRm 2 +#define ZCR_EL1_op2 0 #define ZCR_LEN_SHIFT 0 #define ZCR_LEN_MASK (0xf << ZCR_LEN_SHIFT) #define ZCR_LEN_BYTES(x) ((((x) & ZCR_LEN_MASK) + 1) * 16) diff --git a/lib/libc/include/aarch64-freebsd-none/machine/asm.h b/lib/libc/include/aarch64-freebsd-none/machine/asm.h index 79114a1a86cb5b431bdb9ac82f31f720c1011121..2b8d5a97ec72de1db6ad7453bee82f0bf76bd919 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/asm.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/asm.h @@ -72,6 +72,17 @@ /* Alias for link register x30 */ #define lr x30 +/* + * Check whether a given cpu feature is present, in the case it is not we jump + * to the given label. The tmp register should be a register able to hold the + * temporary data. + */ +#define CHECK_CPU_FEAT(tmp, feat_reg, feat, min_val, label) \ + mrs tmp, ##feat_reg##_el1; \ + ubfx tmp, tmp, ##feat_reg##_##feat##_SHIFT, ##feat_reg##_##feat##_WIDTH; \ + cmp tmp, #(##feat_reg##_##feat##_##min_val## >> ##feat_reg##_##feat##_SHIFT); \ + b.lt label + /* * Sets the trap fault handler. The exception handler will return to the * address in the handler register on a data abort or the xzr register to @@ -87,19 +98,25 @@ ldr tmp, =has_pan; /* Get the addr of has_pan */ \ ldr reg, [tmp]; /* Read it */ \ cbz reg, 997f; /* If no PAN skip */ \ - .inst 0xd500409f | (0 << 8); /* Clear PAN */ \ + .arch_extension pan; \ + msr pan, #0; /* Disable PAN checks */ \ + .arch_extension nopan; \ 997: #define EXIT_USER_ACCESS(reg) \ cbz reg, 998f; /* If no PAN skip */ \ - .inst 0xd500409f | (1 << 8); /* Set PAN */ \ + .arch_extension pan; \ + msr pan, #1; /* Enable PAN checks */ \ + .arch_extension nopan; \ 998: #define EXIT_USER_ACCESS_CHECK(reg, tmp) \ ldr tmp, =has_pan; /* Get the addr of has_pan */ \ ldr reg, [tmp]; /* Read it */ \ cbz reg, 999f; /* If no PAN skip */ \ - .inst 0xd500409f | (1 << 8); /* Set PAN */ \ + .arch_extension pan; \ + msr pan, #1; /* Enable PAN checks */ \ + .arch_extension nopan; \ 999: /* diff --git a/lib/libc/include/aarch64-freebsd-none/machine/atomic.h b/lib/libc/include/aarch64-freebsd-none/machine/atomic.h index 48ee9fa9223204c0d28d60a4f101836a718abcf6..5bb323add634077b22a0511aa0e9f537bde0f1c5 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/atomic.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/atomic.h @@ -465,7 +465,7 @@ _ATOMIC_TEST_OP(set, orr, set) #define _ATOMIC_LOAD_ACQ_IMPL(t, w, s) \ static __inline uint##t##_t \ -atomic_load_acq_##t(volatile uint##t##_t *p) \ +atomic_load_acq_##t(const volatile uint##t##_t *p) \ { \ uint##t##_t ret; \ \ @@ -609,6 +609,8 @@ _ATOMIC_STORE_REL_IMPL(64, , ) #define atomic_set_ptr atomic_set_64 #define atomic_swap_ptr atomic_swap_64 #define atomic_subtract_ptr atomic_subtract_64 +#define atomic_testandclear_ptr atomic_testandclear_64 +#define atomic_testandset_ptr atomic_testandset_64 #define atomic_add_acq_long atomic_add_acq_64 #define atomic_fcmpset_acq_long atomic_fcmpset_acq_64 diff --git a/lib/libc/include/aarch64-freebsd-none/machine/bus.h b/lib/libc/include/aarch64-freebsd-none/machine/bus.h index 76e656e758c462edbc45abecca143acbc975abf5..6bf95d3d4f7bc4751f7dc7a6033ade00683abeb4 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/bus.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/bus.h @@ -76,6 +76,7 @@ #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL +#define BUS_SPACE_MAXADDR_36BIT 0xFFFFFFFFFUL #define BUS_SPACE_MAXADDR_40BIT 0xFFFFFFFFFFUL #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL diff --git a/lib/libc/include/aarch64-freebsd-none/machine/bus_dma.h b/lib/libc/include/aarch64-freebsd-none/machine/bus_dma.h index 75c2fc74449a68a05baf8e7cf2956a0c726b7954..754781d049237fff8e041d228661046cff220c0b 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/bus_dma.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/bus_dma.h @@ -61,7 +61,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, /* * Free a piece of memory and it's allociated dmamap, that was allocated - * via bus_dmamem_alloc. Make the same choice for free/contigfree. + * via bus_dmamem_alloc. */ static inline void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) @@ -148,4 +148,16 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map, return (tc->impl->map_complete(dmat, map, segs, nsegs, error)); } +#ifdef KMSAN +static inline void +_bus_dmamap_load_kmsan(bus_dma_tag_t dmat, bus_dmamap_t map, + struct memdesc *mem) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->load_kmsan(map, mem)); +} +#endif + #endif /* !_MACHINE_BUS_DMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/bus_dma_impl.h b/lib/libc/include/aarch64-freebsd-none/machine/bus_dma_impl.h index 1973cf688c5eecf4f12575625739cf3185568c8e..24ed3e3ac683e089a56850178fbe83b983a50867 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/bus_dma_impl.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/bus_dma_impl.h @@ -31,28 +31,23 @@ struct bus_dma_tag_common { struct bus_dma_impl *impl; - struct bus_dma_tag_common *parent; bus_size_t alignment; bus_addr_t boundary; bus_addr_t lowaddr; bus_addr_t highaddr; - bus_dma_filter_t *filter; - void *filterarg; bus_size_t maxsize; u_int nsegments; bus_size_t maxsegsz; int flags; bus_dma_lock_t *lockfunc; void *lockfuncarg; - int ref_count; int domain; }; struct bus_dma_impl { int (*tag_create)(bus_dma_tag_t parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, - bus_addr_t highaddr, bus_dma_filter_t *filter, - void *filterarg, bus_size_t maxsize, int nsegments, + bus_addr_t highaddr, bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat); int (*tag_destroy)(bus_dma_tag_t dmat); @@ -80,14 +75,15 @@ struct bus_dma_impl { void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map); void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op); +#ifdef KMSAN + void (*load_kmsan)(bus_dmamap_t map, struct memdesc *mem); +#endif }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, - bus_size_t alignment, - bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, - bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, - int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, + bus_addr_t highaddr, bus_size_t maxsize, int nsegments, + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat); extern struct bus_dma_impl bus_dma_bounce_impl; diff --git a/lib/libc/include/aarch64-freebsd-none/machine/cpu.h b/lib/libc/include/aarch64-freebsd-none/machine/cpu.h index c516b89a9f706919d64f9bb550a87306dd092213..755f3404e1af6e892fce85b3a0e7dba2ff701480 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/cpu.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/cpu.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29 */ @@ -77,6 +75,7 @@ #define CPU_IMPL_CAVIUM 0x43 #define CPU_IMPL_DEC 0x44 #define CPU_IMPL_FUJITSU 0x46 +#define CPU_IMPL_HISILICON 0x48 #define CPU_IMPL_INFINEON 0x49 #define CPU_IMPL_FREESCALE 0x4D #define CPU_IMPL_NVIDIA 0x4E @@ -86,6 +85,7 @@ #define CPU_IMPL_APPLE 0x61 #define CPU_IMPL_INTEL 0x69 #define CPU_IMPL_AMPERE 0xC0 +#define CPU_IMPL_MICROSOFT 0x6D /* ARM Part numbers */ #define CPU_PART_FOUNDATION 0xD00 @@ -105,6 +105,7 @@ #define CPU_PART_AEM_V8 0xD0F #define CPU_PART_NEOVERSE_V1 0xD40 #define CPU_PART_CORTEX_A78 0xD41 +#define CPU_PART_CORTEX_A78AE 0xD42 #define CPU_PART_CORTEX_A65AE 0xD43 #define CPU_PART_CORTEX_X1 0xD44 #define CPU_PART_CORTEX_A510 0xD46 @@ -117,6 +118,18 @@ #define CPU_PART_CORTEX_A715 0xD4D #define CPU_PART_CORTEX_X3 0xD4E #define CPU_PART_NEOVERSE_V2 0xD4F +#define CPU_PART_CORTEX_A520 0xD80 +#define CPU_PART_CORTEX_A720 0xD81 +#define CPU_PART_CORTEX_X4 0xD82 +#define CPU_PART_NEOVERSE_V3AE 0xD83 +#define CPU_PART_NEOVERSE_V3 0xD84 +#define CPU_PART_CORTEX_X925 0xD85 +#define CPU_PART_CORTEX_A725 0xD87 +#define CPU_PART_C1_NANO 0xD8A +#define CPU_PART_C1_PRO 0xD8B +#define CPU_PART_C1_ULTRA 0xD8C +#define CPU_PART_NEOVERSE_N3 0xD8E +#define CPU_PART_C1_PREMIUM 0xD90 /* Cavium Part numbers */ #define CPU_PART_THUNDERX 0x0A1 @@ -129,9 +142,16 @@ #define CPU_REV_THUNDERX2_0 0x00 -/* APM / Ampere Part Number */ +/* APM (now Ampere) Part number */ #define CPU_PART_EMAG8180 0x000 +/* Ampere Part numbers */ +#define CPU_PART_AMPERE1 0xAC3 +#define CPU_PART_AMPERE1A 0xAC4 + +/* Microsoft Part numbers */ +#define CPU_PART_AZURE_COBALT_100 0xD49 + /* Qualcomm */ #define CPU_PART_KRYO400_GOLD 0x804 #define CPU_PART_KRYO400_SILVER 0x805 @@ -177,8 +197,30 @@ (((mask) & PCPU_GET(midr)) == \ ((mask) & CPU_ID_RAW((impl), (part), (var), (rev)))) -#define CPU_MATCH_RAW(mask, devid) \ - (((mask) & PCPU_GET(midr)) == ((mask) & (devid))) +#if !defined(__ASSEMBLER__) +static inline bool +midr_check_var_part_range(u_int midr, u_int impl, u_int part, u_int var_low, + u_int part_low, u_int var_high, u_int part_high) +{ + /* Check for the correct part */ + if (CPU_IMPL(midr) != impl || CPU_PART(midr) != part) + return (false); + + /* Check if the variant is between var_low and var_high inclusive */ + if (CPU_VAR(midr) < var_low || CPU_VAR(midr) > var_high) + return (false); + + /* If the variant is the low value, check if the part is high enough */ + if (CPU_VAR(midr) == var_low && CPU_PART(midr) < part_low) + return (false); + + /* If the variant is the high value, check if the part is low enough */ + if (CPU_VAR(midr) == var_high && CPU_PART(midr) > part_high) + return (false); + + return (true); +} +#endif /* * Chip-specific errata. This defines are intended to be @@ -210,6 +252,12 @@ extern uint64_t __cpu_affinity[]; struct arm64_addr_mask; extern struct arm64_addr_mask elf64_addr_mask; +#ifdef COMPAT_FREEBSD14 +extern struct arm64_addr_mask elf64_addr_mask_14; +#endif + +typedef void (*cpu_reset_hook_t)(void); +extern cpu_reset_hook_t cpu_reset_hook; void cpu_halt(void) __dead2; void cpu_reset(void) __dead2; @@ -231,9 +279,18 @@ void ptrauth_mp_start(uint64_t); /* Functions to read the sanitised view of the special registers */ void update_special_regs(u_int); -bool extract_user_id_field(u_int, u_int, uint8_t *); -bool get_kernel_reg(u_int, uint64_t *); -bool get_kernel_reg_masked(u_int, uint64_t *, uint64_t); +void update_special_reg_iss(u_int, uint64_t, uint64_t); +#define update_special_reg(reg, clear, set) \ + update_special_reg_iss(reg ## _ISS, clear, set) +bool get_kernel_reg_iss(u_int, uint64_t *); +#define get_kernel_reg(reg, valp) \ + get_kernel_reg_iss(reg ## _ISS, valp) +bool get_kernel_reg_iss_masked(u_int, uint64_t *, uint64_t); +#define get_kernel_reg_masked(reg, valp, mask) \ + get_kernel_reg_iss_masked(reg ## _ISS, valp, mask) +bool get_user_reg_iss(u_int, uint64_t *, bool); +#define get_user_reg(reg, valp, fbsd) \ + get_user_reg_iss(reg ## _ISS, valp, fbsd) void cpu_desc_init(void); diff --git a/lib/libc/include/aarch64-freebsd-none/machine/cpu_feat.h b/lib/libc/include/aarch64-freebsd-none/machine/cpu_feat.h new file mode 100644 index 0000000000000000000000000000000000000000..79f7cd753230c713b6dcda7a2618f09921fff3f3 --- /dev/null +++ b/lib/libc/include/aarch64-freebsd-none/machine/cpu_feat.h @@ -0,0 +1,136 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Arm Ltd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_CPU_FEAT_H_ +#define _MACHINE_CPU_FEAT_H_ + +#include +#include + +typedef enum { + ERRATA_UNKNOWN, /* Unknown erratum */ + ERRATA_NONE, /* No errata for this feature on this system. */ + ERRATA_AFFECTED, /* There is errata on this system. */ + ERRATA_FW_MITIGAION, /* There is errata, and a firmware */ + /* mitigation. The mitigation may need a */ + /* kernel component. */ +} cpu_feat_errata; + +typedef enum { + /* + * Don't implement the feature or erratum wrokarount, + * e.g. the feature is not implemented or erratum is + * for another CPU. + */ + FEAT_ALWAYS_DISABLE, + + /* + * Disable by default, but allow the user to enable, + * e.g. For a rare erratum with a workaround, Arm + * Category B (rare) or similar. + */ + FEAT_DEFAULT_DISABLE, + + /* + * Enabled by default, bit allow the user to disable, + * e.g. For a common erratum with a workaround, Arm + * Category A or B or similar. + */ + FEAT_DEFAULT_ENABLE, + + /* We could add FEAT_ALWAYS_ENABLE if a need was found. */ +} cpu_feat_en; + +#define CPU_FEAT_STAGE_MASK 0x00000001 +#define CPU_FEAT_EARLY_BOOT 0x00000000 +#define CPU_FEAT_AFTER_DEV 0x00000001 + +#define CPU_FEAT_SCOPE_MASK 0x00000010 +#define CPU_FEAT_PER_CPU 0x00000000 +#define CPU_FEAT_SYSTEM 0x00000010 + +#define CPU_FEAT_USER_ENABLED 0x40000000 +#define CPU_FEAT_USER_DISABLED 0x80000000 + +struct cpu_feat; + +typedef cpu_feat_en (cpu_feat_check)(const struct cpu_feat *, u_int); +typedef bool (cpu_feat_has_errata)(const struct cpu_feat *, u_int, + u_int **, u_int *); +typedef bool (cpu_feat_enable)(const struct cpu_feat *, cpu_feat_errata, + u_int *, u_int); +typedef void (cpu_feat_disabled)(const struct cpu_feat *); + +struct cpu_feat { + const char *feat_name; + cpu_feat_check *feat_check; + cpu_feat_has_errata *feat_has_errata; + cpu_feat_enable *feat_enable; + cpu_feat_disabled *feat_disabled; + uint32_t feat_flags; + bool feat_enabled; +}; +SET_DECLARE(cpu_feat_set, struct cpu_feat); + +SYSCTL_DECL(_hw_feat); + +#define CPU_FEAT(name, descr, check, has_errata, enable, disabled, flags) \ +static struct cpu_feat name = { \ + .feat_name = #name, \ + .feat_check = check, \ + .feat_has_errata = has_errata, \ + .feat_enable = enable, \ + .feat_disabled = disabled, \ + .feat_flags = flags, \ + .feat_enabled = false, \ +}; \ +DATA_SET(cpu_feat_set, name); \ +SYSCTL_BOOL(_hw_feat, OID_AUTO, name, CTLFLAG_RD, &name.feat_enabled, \ + 0, descr) + +/* + * Allow drivers to mark an erratum as worked around, e.g. the Errata + * Management ABI may know the workaround isn't needed on a given system. + */ +typedef cpu_feat_errata (*cpu_feat_errata_check_fn)(const struct cpu_feat *, + u_int); +void cpu_feat_register_errata_check(cpu_feat_errata_check_fn); + +void enable_cpu_feat(uint32_t); + +/* Check if an erratum is in the list of errata */ +static inline bool +cpu_feat_has_erratum(u_int *errata_list, u_int errata_count, u_int erratum) +{ + for (u_int i = 0; i < errata_count; i++) + if (errata_list[0] == erratum) + return (true); + + return (false); +} + +#endif /* _MACHINE_CPU_FEAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/cpufunc.h b/lib/libc/include/aarch64-freebsd-none/machine/cpufunc.h index 1d8fb2a88ee5166453e94ea45c839d9ad820f872..645f5a47e2ae2c8d8e3890059508564699bdc0d8 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/cpufunc.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/cpufunc.h @@ -41,8 +41,6 @@ breakpoint(void) #ifdef _KERNEL #include -void pan_enable(void); - static __inline register_t dbg_disable(void) { @@ -160,6 +158,26 @@ invalidate_local_icache(void) "isb \n"); } +static __inline void +wfet(uint64_t val) +{ + __asm __volatile( + "msr s0_3_c1_c0_0, %0\n" + : + : "r" ((val)) + : "memory"); +} + +static __inline void +wfit(uint64_t val) +{ + __asm __volatile( + "msr s0_3_c1_c0_1, %0\n" + : + : "r" ((val)) + : "memory"); +} + extern bool icache_aliasing; extern bool icache_vmid; @@ -177,21 +195,21 @@ extern int64_t dczva_line_size; #define cpu_dcache_inv_range(a, s) arm64_dcache_inv_range((a), (s)) #define cpu_dcache_wb_range(a, s) arm64_dcache_wb_range((a), (s)) -extern void (*arm64_icache_sync_range)(vm_offset_t, vm_size_t); +extern void (*arm64_icache_sync_range)(void *, vm_size_t); #define cpu_icache_sync_range(a, s) arm64_icache_sync_range((a), (s)) #define cpu_icache_sync_range_checked(a, s) arm64_icache_sync_range_checked((a), (s)) void arm64_nullop(void); void arm64_tlb_flushID(void); -void arm64_dic_idc_icache_sync_range(vm_offset_t, vm_size_t); -void arm64_idc_aliasing_icache_sync_range(vm_offset_t, vm_size_t); -void arm64_aliasing_icache_sync_range(vm_offset_t, vm_size_t); -int arm64_icache_sync_range_checked(vm_offset_t, vm_size_t); -void arm64_dcache_wbinv_range(vm_offset_t, vm_size_t); -void arm64_dcache_inv_range(vm_offset_t, vm_size_t); -void arm64_dcache_wb_range(vm_offset_t, vm_size_t); -bool arm64_get_writable_addr(vm_offset_t, vm_offset_t *); +void arm64_dic_idc_icache_sync_range(void *, vm_size_t); +void arm64_idc_aliasing_icache_sync_range(void *, vm_size_t); +void arm64_aliasing_icache_sync_range(void *, vm_size_t); +int arm64_icache_sync_range_checked(void *, vm_size_t); +void arm64_dcache_wbinv_range(void *, vm_size_t); +void arm64_dcache_inv_range(void *, vm_size_t); +void arm64_dcache_wb_range(void *, vm_size_t); +bool arm64_get_writable_addr(void *, void **); #endif /* _KERNEL */ #endif /* _MACHINE_CPUFUNC_H_ */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h b/lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h index ac7dfeaf9ad1ab2975bdd9d3cd7b56604ff11479..f66ac49cef1330e6d178f48774fff7885e0e814c 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/db_machdep.h @@ -40,6 +40,9 @@ #define T_SINGLESTEP (EXCP_SOFTSTP_EL1) #define T_WATCHPOINT (EXCP_WATCHPT_EL1) +#define HAS_HW_BREAKPOINT +#define NHBREAKPOINTS 16 + typedef vm_offset_t db_addr_t; typedef long db_expr_t; diff --git a/lib/libc/include/aarch64-freebsd-none/machine/debug_monitor.h b/lib/libc/include/aarch64-freebsd-none/machine/debug_monitor.h index f72b8288d437a449691e767f5378a8ee9d0de1e4..6545f6ee2b5a9d13638c3cb9f21303630298c925 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/debug_monitor.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/debug_monitor.h @@ -56,6 +56,7 @@ void dbg_monitor_init(void); void dbg_register_sync(struct debug_monitor_state *); #ifdef DDB +void dbg_show_breakpoint(void); void dbg_show_watchpoint(void); #endif diff --git a/lib/libc/include/aarch64-freebsd-none/machine/efi.h b/lib/libc/include/aarch64-freebsd-none/machine/efi.h index d7bd4536f53d0a4f45cfa70075ed543c1b05b042..491dcd733559aff2be5e7c6ffdd1afbbc3df1460 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/efi.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/efi.h @@ -35,6 +35,8 @@ #ifndef __ARM64_INCLUDE_EFI_H_ #define __ARM64_INCLUDE_EFI_H_ +#include + #define EFIABI_ATTR #ifdef _KERNEL @@ -44,7 +46,7 @@ #define EFI_TIME_UNLOCK() #define EFI_TIME_OWNED() -#define EFI_RT_HANDLE_FAULTS_DEFAULT 0 +#define EFI_RT_HANDLE_FAULTS_DEFAULT 1 #endif struct efirt_callinfo { diff --git a/lib/libc/include/aarch64-freebsd-none/machine/elf.h b/lib/libc/include/aarch64-freebsd-none/machine/elf.h index 1f9c59e80558c871bce2c5c38ada44d8c4f09afd..04423cb37b49e92a0b3763762132ba5b18c91239 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/elf.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/elf.h @@ -93,91 +93,114 @@ __ElfType(Auxinfo); #define ET_DYN_LOAD_ADDR 0x100000 #endif +/* First __FreeBSD_version that supports Top Byte Ignore (TBI) */ +#define TBI_VERSION 1500058 + /* HWCAP */ -#define HWCAP_FP 0x00000001 -#define HWCAP_ASIMD 0x00000002 -#define HWCAP_EVTSTRM 0x00000004 -#define HWCAP_AES 0x00000008 -#define HWCAP_PMULL 0x00000010 -#define HWCAP_SHA1 0x00000020 -#define HWCAP_SHA2 0x00000040 -#define HWCAP_CRC32 0x00000080 -#define HWCAP_ATOMICS 0x00000100 -#define HWCAP_FPHP 0x00000200 -#define HWCAP_ASIMDHP 0x00000400 +#define HWCAP_FP (1 << 0) +#define HWCAP_ASIMD (1 << 1) +#define HWCAP_EVTSTRM (1 << 2) +#define HWCAP_AES (1 << 3) +#define HWCAP_PMULL (1 << 4) +#define HWCAP_SHA1 (1 << 5) +#define HWCAP_SHA2 (1 << 6) +#define HWCAP_CRC32 (1 << 7) +#define HWCAP_ATOMICS (1 << 8) +#define HWCAP_FPHP (1 << 9) +#define HWCAP_ASIMDHP (1 << 10) /* * XXX: The following bits (from CPUID to FLAGM) were originally incorrect, * but later changed to match the Linux definitions. No compatibility code is * provided, as the fix was expected to result in near-zero fallout. */ -#define HWCAP_CPUID 0x00000800 -#define HWCAP_ASIMDRDM 0x00001000 -#define HWCAP_JSCVT 0x00002000 -#define HWCAP_FCMA 0x00004000 -#define HWCAP_LRCPC 0x00008000 -#define HWCAP_DCPOP 0x00010000 -#define HWCAP_SHA3 0x00020000 -#define HWCAP_SM3 0x00040000 -#define HWCAP_SM4 0x00080000 -#define HWCAP_ASIMDDP 0x00100000 -#define HWCAP_SHA512 0x00200000 -#define HWCAP_SVE 0x00400000 -#define HWCAP_ASIMDFHM 0x00800000 -#define HWCAP_DIT 0x01000000 -#define HWCAP_USCAT 0x02000000 -#define HWCAP_ILRCPC 0x04000000 -#define HWCAP_FLAGM 0x08000000 -#define HWCAP_SSBS 0x10000000 -#define HWCAP_SB 0x20000000 -#define HWCAP_PACA 0x40000000 -#define HWCAP_PACG 0x80000000 +#define HWCAP_CPUID (1 << 11) +#define HWCAP_ASIMDRDM (1 << 12) +#define HWCAP_JSCVT (1 << 13) +#define HWCAP_FCMA (1 << 14) +#define HWCAP_LRCPC (1 << 15) +#define HWCAP_DCPOP (1 << 16) +#define HWCAP_SHA3 (1 << 17) +#define HWCAP_SM3 (1 << 18) +#define HWCAP_SM4 (1 << 19) +#define HWCAP_ASIMDDP (1 << 20) +#define HWCAP_SHA512 (1 << 21) +#define HWCAP_SVE (1 << 22) +#define HWCAP_ASIMDFHM (1 << 23) +#define HWCAP_DIT (1 << 24) +#define HWCAP_USCAT (1 << 25) +#define HWCAP_ILRCPC (1 << 26) +#define HWCAP_FLAGM (1 << 27) +#define HWCAP_SSBS (1 << 28) +#define HWCAP_SB (1 << 29) +#define HWCAP_PACA (1 << 30) +#define HWCAP_PACG (1UL << 31) +#define HWCAP_GCS (1UL << 32) /* HWCAP2 */ -#define HWCAP2_DCPODP 0x0000000000000001ul -#define HWCAP2_SVE2 0x0000000000000002ul -#define HWCAP2_SVEAES 0x0000000000000004ul -#define HWCAP2_SVEPMULL 0x0000000000000008ul -#define HWCAP2_SVEBITPERM 0x0000000000000010ul -#define HWCAP2_SVESHA3 0x0000000000000020ul -#define HWCAP2_SVESM4 0x0000000000000040ul -#define HWCAP2_FLAGM2 0x0000000000000080ul -#define HWCAP2_FRINT 0x0000000000000100ul -#define HWCAP2_SVEI8MM 0x0000000000000200ul -#define HWCAP2_SVEF32MM 0x0000000000000400ul -#define HWCAP2_SVEF64MM 0x0000000000000800ul -#define HWCAP2_SVEBF16 0x0000000000001000ul -#define HWCAP2_I8MM 0x0000000000002000ul -#define HWCAP2_BF16 0x0000000000004000ul -#define HWCAP2_DGH 0x0000000000008000ul -#define HWCAP2_RNG 0x0000000000010000ul -#define HWCAP2_BTI 0x0000000000020000ul -#define HWCAP2_MTE 0x0000000000040000ul -#define HWCAP2_ECV 0x0000000000080000ul -#define HWCAP2_AFP 0x0000000000100000ul -#define HWCAP2_RPRES 0x0000000000200000ul -#define HWCAP2_MTE3 0x0000000000400000ul -#define HWCAP2_SME 0x0000000000800000ul -#define HWCAP2_SME_I16I64 0x0000000001000000ul -#define HWCAP2_SME_F64F64 0x0000000002000000ul -#define HWCAP2_SME_I8I32 0x0000000004000000ul -#define HWCAP2_SME_F16F32 0x0000000008000000ul -#define HWCAP2_SME_B16F32 0x0000000010000000ul -#define HWCAP2_SME_F32F32 0x0000000020000000ul -#define HWCAP2_SME_FA64 0x0000000040000000ul -#define HWCAP2_WFXT 0x0000000080000000ul -#define HWCAP2_EBF16 0x0000000100000000ul -#define HWCAP2_SVE_EBF16 0x0000000200000000ul -#define HWCAP2_CSSC 0x0000000400000000ul -#define HWCAP2_RPRFM 0x0000000800000000ul -#define HWCAP2_SVE2P1 0x0000001000000000ul -#define HWCAP2_SME2 0x0000002000000000ul -#define HWCAP2_SME2P1 0x0000004000000000ul -#define HWCAP2_SME_I16I32 0x0000008000000000ul -#define HWCAP2_SME_BI32I32 0x0000010000000000ul -#define HWCAP2_SME_B16B16 0x0000020000000000ul -#define HWCAP2_SME_F16F16 0x0000040000000000ul -#define HWCAP2_MOPS 0x0000080000000000ul -#define HWCAP2_HBC 0x0000100000000000ul +#define HWCAP2_DCPODP (1 << 0) +#define HWCAP2_SVE2 (1 << 1) +#define HWCAP2_SVEAES (1 << 2) +#define HWCAP2_SVEPMULL (1 << 3) +#define HWCAP2_SVEBITPERM (1 << 4) +#define HWCAP2_SVESHA3 (1 << 5) +#define HWCAP2_SVESM4 (1 << 6) +#define HWCAP2_FLAGM2 (1 << 7) +#define HWCAP2_FRINT (1 << 8) +#define HWCAP2_SVEI8MM (1 << 9) +#define HWCAP2_SVEF32MM (1 << 10) +#define HWCAP2_SVEF64MM (1 << 11) +#define HWCAP2_SVEBF16 (1 << 12) +#define HWCAP2_I8MM (1 << 13) +#define HWCAP2_BF16 (1 << 14) +#define HWCAP2_DGH (1 << 15) +#define HWCAP2_RNG (1 << 16) +#define HWCAP2_BTI (1 << 17) +#define HWCAP2_MTE (1 << 18) +#define HWCAP2_ECV (1 << 19) +#define HWCAP2_AFP (1 << 20) +#define HWCAP2_RPRES (1 << 21) +#define HWCAP2_MTE3 (1 << 22) +#define HWCAP2_SME (1 << 23) +#define HWCAP2_SME_I16I64 (1 << 24) +#define HWCAP2_SME_F64F64 (1 << 25) +#define HWCAP2_SME_I8I32 (1 << 26) +#define HWCAP2_SME_F16F32 (1 << 27) +#define HWCAP2_SME_B16F32 (1 << 28) +#define HWCAP2_SME_F32F32 (1 << 29) +#define HWCAP2_SME_FA64 (1 << 30) +#define HWCAP2_WFXT (1UL << 31) +#define HWCAP2_EBF16 (1UL << 32) +#define HWCAP2_SVE_EBF16 (1UL << 33) +#define HWCAP2_CSSC (1UL << 34) +#define HWCAP2_RPRFM (1UL << 35) +#define HWCAP2_SVE2P1 (1UL << 36) +#define HWCAP2_SME2 (1UL << 37) +#define HWCAP2_SME2P1 (1UL << 38) +#define HWCAP2_SME_I16I32 (1UL << 39) +#define HWCAP2_SME_BI32I32 (1UL << 40) +#define HWCAP2_SME_B16B16 (1UL << 41) +#define HWCAP2_SME_F16F16 (1UL << 42) +#define HWCAP2_MOPS (1UL << 43) +#define HWCAP2_HBC (1UL << 44) +#define HWCAP2_SVE_B16B16 (1UL << 45) +#define HWCAP2_LRCPC3 (1UL << 46) +#define HWCAP2_LSE128 (1UL << 47) +#define HWCAP2_FPMR (1UL << 48) +#define HWCAP2_LUT (1UL << 49) +#define HWCAP2_FAMINMAX (1UL << 50) +#define HWCAP2_F8CVT (1UL << 51) +#define HWCAP2_F8FMA (1UL << 52) +#define HWCAP2_F8DP4 (1UL << 53) +#define HWCAP2_F8DP2 (1UL << 54) +#define HWCAP2_F8E4M3 (1UL << 55) +#define HWCAP2_F8E5M2 (1UL << 56) +#define HWCAP2_SME_LUTV2 (1UL << 57) +#define HWCAP2_SME_F8F16 (1UL << 58) +#define HWCAP2_SME_F8F32 (1UL << 59) +#define HWCAP2_SME_SF8FMA (1UL << 60) +#define HWCAP2_SME_SF8DP4 (1UL << 61) +#define HWCAP2_SME_SF8DP2 (1UL << 62) +#define HWCAP2_POE (1UL << 63) #ifdef COMPAT_FREEBSD32 /* ARM HWCAP */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/endian.h b/lib/libc/include/aarch64-freebsd-none/machine/endian.h index 69d16e3fc53c4c197619b48b82ba407768fe29a4..6b21c3cb51ced2247589a9c7d87c36bfd3e6e48b 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/endian.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/endian.h @@ -24,8 +24,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)endian.h 8.1 (Berkeley) 6/10/93 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $ */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/float.h b/lib/libc/include/aarch64-freebsd-none/machine/float.h index 2ac1797774570db93ef280375904c96e0d351541..c6f1432f6226122adbbc377d26cee067b44ee1f5 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/float.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/float.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifdef __arm__ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/frame.h b/lib/libc/include/aarch64-freebsd-none/machine/frame.h index 0f513846333cbd639aa6c608c08d733d7a82230b..74cdd46e67ce8ce5f8dff1aabefaaba8c5546684 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/frame.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/frame.h @@ -70,7 +70,7 @@ struct frame { #ifdef COMPAT_FREEBSD32 struct sigframe32 { - struct siginfo32 sf_si; + struct __siginfo32 sf_si; ucontext32_t sf_uc; mcontext32_vfp_t sf_vfp; }; diff --git a/lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h b/lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h index 210fafb16955a4074bb15cf9c1e34d8ae61cdc3b..fbb9267675dc5401786b902db3e84858f7600520 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/hypervisor.h @@ -41,21 +41,38 @@ #define CNTHCTL_EL1PCTEN (1 << 0) /* Allow physical counter access */ #define CNTHCTL_EL1PCEN (1 << 1) /* Allow physical timer access */ /* Valid if HCR_EL2.E2H == 1 */ +#define CNTHCTL_E2H_EL0PCTEN (1 << 0) /* Allow EL0 physical counter access */ +#define CNTHCTL_E2H_EL0VCTEN (1 << 1) /* Allow EL0 virtual counter access */ +#define CNTHCTL_E2H_EL0VTEN (1 << 8) +#define CNTHCTL_E2H_EL0PTEN (1 << 9) #define CNTHCTL_E2H_EL1PCTEN (1 << 10) /* Allow physical counter access */ #define CNTHCTL_E2H_EL1PTEN (1 << 11) /* Allow physical timer access */ /* Unconditionally valid */ #define CNTHCTL_EVNTDIR (1 << 3) /* Control transition trigger bit */ #define CNTHCTL_EVNTEN (1 << 2) /* Enable event stream */ +/* CNTPOFF_EL2 - Counter-timer Physical Offset Register */ +#define CNTPOFF_EL2_REG MRS_REG_ALT_NAME(CNTPOFF_EL2) +#define CNTPOFF_EL2_op0 3 +#define CNTPOFF_EL2_op1 4 +#define CNTPOFF_EL2_CRn 14 +#define CNTPOFF_EL2_CRm 0 +#define CNTPOFF_EL2_op2 6 + /* CPTR_EL2 - Architecture feature trap register */ /* Valid if HCR_EL2.E2H == 0 */ +#define CPTR_TRAP_ALL 0xc01037ff /* Enable all traps */ #define CPTR_RES0 0x7fefc800 #define CPTR_RES1 0x000032ff +#define CPTR_TZ 0x00000100 #define CPTR_TFP 0x00000400 -/* Valid if HCR_EL2.E2H == 1 */ -#define CPTR_FPEN 0x00300000 -/* Unconditionally valid */ #define CPTR_TTA 0x00100000 +/* Valid if HCR_EL2.E2H == 1 */ +#define CPTR_E2H_TRAP_ALL 0xd0000000 +#define CPTR_E2H_ZPEN 0x00030000 +#define CPTR_E2H_FPEN 0x00300000 +#define CPTR_E2H_TTA 0x10000000 +/* Unconditionally valid */ #define CPTR_TCPAC 0x80000000 /* HCR_EL2 - Hypervisor Config Register */ @@ -123,6 +140,41 @@ #define HCR_TWEDEn (UL(0x1) << 59) #define HCR_TWEDEL_MASK (UL(0xf) << 60) +/* HCRX_EL2 - Extended Hypervisor Configuration Register */ +#define HCRX_EL2_REG MRS_REG_ALT_NAME(HCRX_EL2) +#define HCRX_EL2_op0 3 +#define HCRX_EL2_op1 4 +#define HCRX_EL2_CRn 1 +#define HCRX_EL2_CRm 2 +#define HCRX_EL2_op2 2 + +#define HCRX_EnAS0 (UL(0x1) << 0) +#define HCRX_EnALS (UL(0x1) << 1) +#define HCRX_EnASR (UL(0x1) << 2) +#define HCRX_FnXS (UL(0x1) << 3) +#define HCRX_FGTnXS (UL(0x1) << 4) +#define HCRX_SMPME (UL(0x1) << 5) +#define HCRX_TALLINT (UL(0x1) << 6) +#define HCRX_VINMI (UL(0x1) << 7) +#define HCRX_VFNMI (UL(0x1) << 8) +#define HCRX_CMOW (UL(0x1) << 9) +#define HCRX_MCE2 (UL(0x1) << 10) +#define HCRX_MSCEn (UL(0x1) << 11) +/* Bits 12 & 13 are reserved */ +#define HCRX_TCR2En (UL(0x1) << 14) +#define HCRX_SCTLR2En (UL(0x1) << 15) +#define HCRX_PTTWI (UL(0x1) << 16) +#define HCRX_D128En (UL(0x1) << 17) +#define HCRX_EnSNERR (UL(0x1) << 18) +#define HCRX_TMEA (UL(0x1) << 19) +#define HCRX_EnSDERR (UL(0x1) << 20) +#define HCRX_EnIDCP128 (UL(0x1) << 21) +#define HCRX_GCSEn (UL(0x1) << 22) +#define HCRX_EnFPM (UL(0x1) << 23) +#define HCRX_PACMEn (UL(0x1) << 24) +/* Bit 25 is reserved */ +#define HCRX_SRMASKEn (UL(0x1) << 26) + /* HPFAR_EL2 - Hypervisor IPA Fault Address Register */ #define HPFAR_EL2_FIPA_SHIFT 4 #define HPFAR_EL2_FIPA_MASK 0xfffffffff0 @@ -138,6 +190,54 @@ #define ICC_SRE_EL2_SRE (1UL << 0) #define ICC_SRE_EL2_EN (1UL << 3) +/* MDCR_EL2 - Hyp Debug Control Register */ +#define MDCR_EL2_HPMN_MASK 0x1f +#define MDCR_EL2_HPMN_SHIFT 0 +#define MDCR_EL2_TPMCR_SHIFT 5 +#define MDCR_EL2_TPMCR (0x1UL << MDCR_EL2_TPMCR_SHIFT) +#define MDCR_EL2_TPM_SHIFT 6 +#define MDCR_EL2_TPM (0x1UL << MDCR_EL2_TPM_SHIFT) +#define MDCR_EL2_HPME_SHIFT 7 +#define MDCR_EL2_HPME (0x1UL << MDCR_EL2_HPME_SHIFT) +#define MDCR_EL2_TDE_SHIFT 8 +#define MDCR_EL2_TDE (0x1UL << MDCR_EL2_TDE_SHIFT) +#define MDCR_EL2_TDA_SHIFT 9 +#define MDCR_EL2_TDA (0x1UL << MDCR_EL2_TDA_SHIFT) +#define MDCR_EL2_TDOSA_SHIFT 10 +#define MDCR_EL2_TDOSA (0x1UL << MDCR_EL2_TDOSA_SHIFT) +#define MDCR_EL2_TDRA_SHIFT 11 +#define MDCR_EL2_TDRA (0x1UL << MDCR_EL2_TDRA_SHIFT) +#define MDCR_EL2_E2PB_SHIFT 12 +#define MDCR_EL2_E2PB_MASK (0x3UL << MDCR_EL2_E2PB_SHIFT) +#define MDCR_EL2_TPMS_SHIFT 14 +#define MDCR_EL2_TPMS (0x1UL << MDCR_EL2_TPMS_SHIFT) +#define MDCR_EL2_EnSPM_SHIFT 15 +#define MDCR_EL2_EnSPM (0x1UL << MDCR_EL2_EnSPM_SHIFT) +#define MDCR_EL2_HPMD_SHIFT 17 +#define MDCR_EL2_HPMD (0x1UL << MDCR_EL2_HPMD_SHIFT) +#define MDCR_EL2_TTRF_SHIFT 19 +#define MDCR_EL2_TTRF (0x1UL << MDCR_EL2_TTRF_SHIFT) +#define MDCR_EL2_HCCD_SHIFT 23 +#define MDCR_EL2_HCCD (0x1UL << MDCR_EL2_HCCD_SHIFT) +#define MDCR_EL2_E2TB_SHIFT 24 +#define MDCR_EL2_E2TB_MASK (0x3UL << MDCR_EL2_E2TB_SHIFT) +#define MDCR_EL2_HLP_SHIFT 26 +#define MDCR_EL2_HLP (0x1UL << MDCR_EL2_HLP_SHIFT) +#define MDCR_EL2_TDCC_SHIFT 27 +#define MDCR_EL2_TDCC (0x1UL << MDCR_EL2_TDCC_SHIFT) +#define MDCR_EL2_MTPME_SHIFT 28 +#define MDCR_EL2_MTPME (0x1UL << MDCR_EL2_MTPME_SHIFT) +#define MDCR_EL2_HPMFZO_SHIFT 29 +#define MDCR_EL2_HPMFZO (0x1UL << MDCR_EL2_HPMFZO_SHIFT) +#define MDCR_EL2_PMSSE_SHIFT 30 +#define MDCR_EL2_PMSSE_MASK (0x3UL << MDCR_EL2_PMSSE_SHIFT) +#define MDCR_EL2_HPMFZS_SHIFT 36 +#define MDCR_EL2_HPMFZS (0x1UL << MDCR_EL2_HPMFZS_SHIFT) +#define MDCR_EL2_PMEE_SHIFT 40 +#define MDCR_EL2_PMEE_MASK (0x3UL << MDCR_EL2_PMEE_SHIFT) +#define MDCR_EL2_EBWE_SHIFT 43 +#define MDCR_EL2_EBWE (0x1UL << MDCR_EL2_EBWE_SHIFT) + /* SCTLR_EL2 - System Control Register */ #define SCTLR_EL2_RES1 0x30c50830 #define SCTLR_EL2_M_SHIFT 0 @@ -237,6 +337,9 @@ #define VTCR_EL2_PS_42BIT (0x3UL << VTCR_EL2_PS_SHIFT) #define VTCR_EL2_PS_44BIT (0x4UL << VTCR_EL2_PS_SHIFT) #define VTCR_EL2_PS_48BIT (0x5UL << VTCR_EL2_PS_SHIFT) +#define VTCR_EL2_PS_52BIT (0x6UL << VTCR_EL2_PS_SHIFT) +#define VTCR_EL2_DS_SHIFT 32 +#define VTCR_EL2_DS (0x1UL << VTCR_EL2_DS_SHIFT) /* VTTBR_EL2 - Virtualization Translation Table Base Register */ #define VTTBR_VMID_MASK 0xffff000000000000 @@ -244,52 +347,4 @@ /* Assumed to be 0 by locore.S */ #define VTTBR_HOST 0x0000000000000000 -/* MDCR_EL2 - Hyp Debug Control Register */ -#define MDCR_EL2_HPMN_MASK 0x1f -#define MDCR_EL2_HPMN_SHIFT 0 -#define MDCR_EL2_TPMCR_SHIFT 5 -#define MDCR_EL2_TPMCR (0x1UL << MDCR_EL2_TPMCR_SHIFT) -#define MDCR_EL2_TPM_SHIFT 6 -#define MDCR_EL2_TPM (0x1UL << MDCR_EL2_TPM_SHIFT) -#define MDCR_EL2_HPME_SHIFT 7 -#define MDCR_EL2_HPME (0x1UL << MDCR_EL2_HPME_SHIFT) -#define MDCR_EL2_TDE_SHIFT 8 -#define MDCR_EL2_TDE (0x1UL << MDCR_EL2_TDE_SHIFT) -#define MDCR_EL2_TDA_SHIFT 9 -#define MDCR_EL2_TDA (0x1UL << MDCR_EL2_TDA_SHIFT) -#define MDCR_EL2_TDOSA_SHIFT 10 -#define MDCR_EL2_TDOSA (0x1UL << MDCR_EL2_TDOSA_SHIFT) -#define MDCR_EL2_TDRA_SHIFT 11 -#define MDCR_EL2_TDRA (0x1UL << MDCR_EL2_TDRA_SHIFT) -#define MDCR_E2PB_SHIFT 12 -#define MDCR_E2PB_MASK (0x3UL << MDCR_E2PB_SHIFT) -#define MDCR_TPMS_SHIFT 14 -#define MDCR_TPMS (0x1UL << MDCR_TPMS_SHIFT) -#define MDCR_EnSPM_SHIFT 15 -#define MDCR_EnSPM (0x1UL << MDCR_EnSPM_SHIFT) -#define MDCR_HPMD_SHIFT 17 -#define MDCR_HPMD (0x1UL << MDCR_HPMD_SHIFT) -#define MDCR_TTRF_SHIFT 19 -#define MDCR_TTRF (0x1UL << MDCR_TTRF_SHIFT) -#define MDCR_HCCD_SHIFT 23 -#define MDCR_HCCD (0x1UL << MDCR_HCCD_SHIFT) -#define MDCR_E2TB_SHIFT 24 -#define MDCR_E2TB_MASK (0x3UL << MDCR_E2TB_SHIFT) -#define MDCR_HLP_SHIFT 26 -#define MDCR_HLP (0x1UL << MDCR_HLP_SHIFT) -#define MDCR_TDCC_SHIFT 27 -#define MDCR_TDCC (0x1UL << MDCR_TDCC_SHIFT) -#define MDCR_MTPME_SHIFT 28 -#define MDCR_MTPME (0x1UL << MDCR_MTPME_SHIFT) -#define MDCR_HPMFZO_SHIFT 29 -#define MDCR_HPMFZO (0x1UL << MDCR_HPMFZO_SHIFT) -#define MDCR_PMSSE_SHIFT 30 -#define MDCR_PMSSE_MASK (0x3UL << MDCR_PMSSE_SHIFT) -#define MDCR_HPMFZS_SHIFT 36 -#define MDCR_HPMFZS (0x1UL << MDCR_HPMFZS_SHIFT) -#define MDCR_PMEE_SHIFT 40 -#define MDCR_PMEE_MASK (0x3UL << MDCR_PMEE_SHIFT) -#define MDCR_EBWE_SHIFT 43 -#define MDCR_EBWE (0x1UL << MDCR_EBWE_SHIFT) - #endif /* !_MACHINE_HYPERVISOR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/in_cksum.h b/lib/libc/include/aarch64-freebsd-none/machine/in_cksum.h index b6519929ca3ce4cd461585ac3be90ceb0cfd80d4..ad5bd81eae39ec55236808fecb64cc6d4ba5fb10 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/in_cksum.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/in_cksum.h @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/intr.h b/lib/libc/include/aarch64-freebsd-none/machine/intr.h index de9bf6b658d47485ad9171de6970e3534f87ea48..533b60b3a1ab70b437900e35698696ba70dd4494 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/intr.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/intr.h @@ -27,20 +27,20 @@ #ifndef _MACHINE_INTR_H_ #define _MACHINE_INTR_H_ +#ifndef LOCORE #ifdef FDT #include #endif -#include - -#ifndef NIRQ -#define NIRQ 16384 /* XXX - It should be an option. */ -#endif - static inline void arm_irq_memory_barrier(uintptr_t irq) { } +#endif /* !LOCORE */ + +#ifndef NIRQ +#define NIRQ 16384 /* XXX - It should be an option. */ +#endif #ifdef DEV_ACPI #define ACPI_INTR_XREF 1 @@ -48,4 +48,8 @@ arm_irq_memory_barrier(uintptr_t irq) #define ACPI_GPIO_XREF 3 #endif +#define INTR_ROOT_IRQ 0 +#define INTR_ROOT_FIQ 1 +#define INTR_ROOT_COUNT 2 + #endif /* _MACHINE_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/kdb.h b/lib/libc/include/aarch64-freebsd-none/machine/kdb.h index b7799037867c34a69e54b624e30e027a7d842cdb..3ab07f98145c13254ddf324f16066147a88949bd 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/kdb.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/kdb.h @@ -37,6 +37,8 @@ void kdb_cpu_clear_singlestep(void); void kdb_cpu_set_singlestep(void); +int kdb_cpu_set_breakpoint(vm_offset_t addr); +int kdb_cpu_clr_breakpoint(vm_offset_t addr); int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access); int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size); @@ -44,7 +46,7 @@ static __inline void kdb_cpu_sync_icache(unsigned char *addr, size_t size) { - cpu_icache_sync_range((vm_offset_t)addr, size); + cpu_icache_sync_range(addr, size); } static __inline void diff --git a/lib/libc/include/aarch64-freebsd-none/machine/machdep.h b/lib/libc/include/aarch64-freebsd-none/machine/machdep.h index c965e4c2a0fb005c00246ae4ebcd0034cbad4523..0718e65b2faa91de96352a1c0ab68e485e0e8243 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/machdep.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/machdep.h @@ -33,7 +33,6 @@ struct arm64_bootparams { vm_offset_t modulep; vm_offset_t kern_stack; vm_paddr_t kern_ttbr0; - uint64_t hcr_el2; int boot_el; /* EL the kernel booted from */ int pad; }; @@ -48,6 +47,7 @@ extern enum arm64_bus arm64_bus_method; void dbg_init(void); bool has_hyp(void); +bool in_vhe(void); void initarm(struct arm64_bootparams *); vm_offset_t parse_boot_param(struct arm64_bootparams *abp); #ifdef FDT diff --git a/lib/libc/include/aarch64-freebsd-none/machine/md_var.h b/lib/libc/include/aarch64-freebsd-none/machine/md_var.h index 8cb7e019467e521295330ce136c808ed820276f2..169160928adb6bd9aceace5de445d8c7c56393eb 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/md_var.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/md_var.h @@ -37,8 +37,12 @@ extern char sigcode[]; extern int szsigcode; extern u_long elf_hwcap; extern u_long elf_hwcap2; +extern u_long elf_hwcap3; +extern u_long elf_hwcap4; extern u_long linux_elf_hwcap; extern u_long linux_elf_hwcap2; +extern u_long linux_elf_hwcap3; +extern u_long linux_elf_hwcap4; #ifdef COMPAT_FREEBSD32 extern u_long elf32_hwcap; extern u_long elf32_hwcap2; diff --git a/lib/libc/include/aarch64-freebsd-none/machine/metadata.h b/lib/libc/include/aarch64-freebsd-none/machine/metadata.h index 51c438678781d833158f5dbba74e7aa0f37b994d..b0f7670be581e9a5db38f6a199e1fe11ed471fc6 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/metadata.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/metadata.h @@ -31,10 +31,15 @@ #define MODINFOMD_DTBP 0x1002 #define MODINFOMD_EFI_FB 0x1003 +/* + * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though + * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table + * starting at a 16-byte alignment. + */ struct efi_map_header { - size_t memory_size; - size_t descriptor_size; - uint32_t descriptor_version; + size_t memory_size; /* Numnber of bytes that follow */ + size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */ + uint32_t descriptor_version; /* Currently '1' */ }; struct efi_fb { diff --git a/lib/libc/include/aarch64-freebsd-none/machine/msan.h b/lib/libc/include/aarch64-freebsd-none/machine/msan.h new file mode 100644 index 0000000000000000000000000000000000000000..a114188b9084ada405ff19fd0d934be2703330f6 --- /dev/null +++ b/lib/libc/include/aarch64-freebsd-none/machine/msan.h @@ -0,0 +1,91 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2021 The FreeBSD Foundation + * Copyright (c) 2023 Juniper Networks, Inc. + * + * This software was developed by Mark Johnston under sponsorship from the + * FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_MSAN_H_ +#define _MACHINE_MSAN_H_ + +#ifdef KMSAN + +#include +#include +#include +#include + +typedef uint32_t msan_orig_t; + +/* + * Our 32-bit origin cells encode a 2-bit type and 30-bit pointer to a kernel + * instruction. The pointer is compressed by making it a positive offset + * relative to KERNBASE. + */ +#define KMSAN_ORIG_TYPE_SHIFT 30u +#define KMSAN_ORIG_PTR_MASK ((1ul << KMSAN_ORIG_TYPE_SHIFT) - 1) + +static inline msan_orig_t +kmsan_md_orig_encode(int type, uintptr_t ptr) +{ + return ((type << KMSAN_ORIG_TYPE_SHIFT) | + ((ptr & KMSAN_ORIG_PTR_MASK))); +} + +static inline void +kmsan_md_orig_decode(msan_orig_t orig, int *type, uintptr_t *ptr) +{ + *type = orig >> KMSAN_ORIG_TYPE_SHIFT; + *ptr = (orig & KMSAN_ORIG_PTR_MASK) | KERNBASE; +} + +static inline vm_offset_t +kmsan_md_addr_to_shad(vm_offset_t addr) +{ + return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_SHAD_MIN_ADDRESS); +} + +static inline vm_offset_t +kmsan_md_addr_to_orig(vm_offset_t addr) +{ + return (addr - VM_MIN_KERNEL_ADDRESS + KMSAN_ORIG_MIN_ADDRESS); +} + +static inline bool +kmsan_md_unsupported(vm_offset_t addr) +{ + /* + * It would be cheaper to use VM_MAX_KERNEL_ADDRESS as the upper bound, + * but we need to exclude device mappings above kernel_vm_end but within + * the kernel map. + */ + return (addr < VM_MIN_KERNEL_ADDRESS || addr >= kernel_vm_end); +} + +#endif /* KMSAN */ + +#endif /* !_MACHINE_MSAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/param.h b/lib/libc/include/aarch64-freebsd-none/machine/param.h index 17231651acca5bf3f2df2b4c746bd9509bf1c0c0..007c5d5c2e83d79071b55dd37922d614297c5b46 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/param.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/param.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifdef __arm__ @@ -45,8 +43,6 @@ #define STACKALIGNBYTES (16 - 1) #define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES) -#define __PCI_REROUTE_INTERRUPT - #ifndef MACHINE #define MACHINE "arm64" #endif @@ -99,7 +95,7 @@ #define PAGE_SIZE (1 << PAGE_SHIFT) #define PAGE_MASK (PAGE_SIZE - 1) -#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ +#define MAXPAGESIZES 4 /* maximum number of supported page sizes */ #ifndef KSTACK_PAGES #if defined(KASAN) || defined(KMSAN) @@ -121,17 +117,9 @@ /* * Mach derived conversion macros */ -#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK) -#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK) - -#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) - #define arm64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) #define arm64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) -#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) - #endif /* !_MACHINE_PARAM_H_ */ #endif /* !__arm__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h b/lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h index aa986363e56bd32a26dcfdf97dd710a9bd218124..4411dcb6655fec123cdb6795e9342a00d63e85e0 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/pci_cfgreg.h @@ -27,10 +27,7 @@ #define _MACHINE_PCI_CFGREG_H int pci_cfgregopen(void); -uint32_t pci_cfgregread_domain(int, int, int, int, int, int); -void pci_cfgregwrite_domain(int, int, int, int, int, uint32_t, int); - -#define pci_cfgregread pci_cfgregread_domain -#define pci_cfgregwrite pci_cfgregwrite_domain +uint32_t pci_cfgregread(int, int, int, int, int, int); +void pci_cfgregwrite(int, int, int, int, int, uint32_t, int); #endif /* !_MACHINE_PCI_CFGREG_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/pcpu.h b/lib/libc/include/aarch64-freebsd-none/machine/pcpu.h index db47829a86a0e6cc612756a7715bc5e00befacf8..3ef9e6e6ae079216110fbb94ef513aa4110785c5 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/pcpu.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/pcpu.h @@ -48,7 +48,6 @@ struct debug_monitor_state; pcpu_ssbd pc_ssbd; \ struct pmap *pc_curpmap; \ struct pmap *pc_curvmpmap; \ - /* Store as two u_int values to preserve KBI */ \ uint64_t pc_mpidr; \ u_int pc_bcast_tlbi_workaround; \ char __pad[197] diff --git a/lib/libc/include/aarch64-freebsd-none/machine/pmap.h b/lib/libc/include/aarch64-freebsd-none/machine/pmap.h index df4161fa9d8d180aa11cb132916ce394d7fc1772..80b03e3bf57df103cdf67d9ed3fac38d74f9c465 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/pmap.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/pmap.h @@ -63,10 +63,13 @@ void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); * Pmap stuff */ +struct rangeset; + struct md_page { TAILQ_HEAD(,pv_entry) pv_list; int pv_gen; vm_memattr_t pv_memattr; + uint8_t pv_reserve[3]; }; enum pmap_stage { @@ -87,7 +90,8 @@ struct pmap { struct asid_set *pm_asid_set; /* The ASID/VMID set to use */ enum pmap_stage pm_stage; int pm_levels; - uint64_t pm_reserved[4]; + struct rangeset *pm_bti; + uint64_t pm_reserved[3]; }; typedef struct pmap *pmap_t; @@ -98,6 +102,8 @@ extern struct pmap kernel_pmap_store; #define kernel_pmap (&kernel_pmap_store) #define pmap_kernel() kernel_pmap +extern bool pmap_lpa_enabled; + #define PMAP_ASSERT_LOCKED(pmap) \ mtx_assert(&(pmap)->pm_mtx, MA_OWNED) #define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) @@ -124,6 +130,8 @@ extern struct pmap kernel_pmap_store; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; +extern pt_entry_t pmap_sh_attr; + /* * Macros to test if a mapping is mappable with an L1 Section mapping * or an L2 Large Page mapping. @@ -134,7 +142,8 @@ extern vm_offset_t virtual_end; #define pmap_vm_page_alloc_check(m) void pmap_activate_vm(pmap_t); -void pmap_bootstrap(vm_size_t); +void pmap_bootstrap_dmap(vm_size_t); +void pmap_bootstrap(void); int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode); int pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot); void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode); @@ -166,18 +175,17 @@ int pmap_fault(pmap_t, uint64_t, uint64_t); struct pcb *pmap_switch(struct thread *); +void pmap_s1_invalidate_all_kernel(void); + extern void (*pmap_clean_stage2_tlbi)(void); -extern void (*pmap_invalidate_vpipt_icache)(void); extern void (*pmap_stage2_invalidate_range)(uint64_t, vm_offset_t, vm_offset_t, bool); extern void (*pmap_stage2_invalidate_all)(uint64_t); -static inline int -pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) -{ +int pmap_vmspace_copy(pmap_t, pmap_t); - return (0); -} +int pmap_bti_set(pmap_t, vm_offset_t, vm_offset_t); +int pmap_bti_clear(pmap_t, vm_offset_t, vm_offset_t); #if defined(KASAN) || defined(KMSAN) struct arm64_bootparams; diff --git a/lib/libc/include/aarch64-freebsd-none/machine/proc.h b/lib/libc/include/aarch64-freebsd-none/machine/proc.h index 9755856a8f082b1ef0796d57dde754ff81b61771..fb5f34e591726a5a9bf23aa46d4202567f9971b2 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/proc.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/proc.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 */ @@ -37,6 +35,7 @@ #ifndef _MACHINE_PROC_H_ #define _MACHINE_PROC_H_ +#ifndef LOCORE struct ptrauth_key { uint64_t pa_key_lo; uint64_t pa_key_hi; @@ -67,12 +66,21 @@ struct mdthread { struct ptrauth_key apia; } md_ptrauth_kern; - uint64_t md_reserved[4]; + uint64_t md_efirt_tmp; + int md_efirt_dis_pf; + + int md_reserved0; + uint64_t md_reserved[2]; }; struct mdproc { - long md_dummy; + uint64_t md_tcr; /* TCR_EL1 fields to update */ + uint64_t md_reserved[2]; }; +#endif /* !LOCORE */ + +/* Fields that can be set in md_tcr */ +#define MD_TCR_FIELDS TCR_TBI0 #define KINFO_PROC_SIZE 1088 #define KINFO_PROC32_SIZE 816 diff --git a/lib/libc/include/aarch64-freebsd-none/machine/pte.h b/lib/libc/include/aarch64-freebsd-none/machine/pte.h index 8c1eb573274541846e904c7db1e9cc7d88af74f9..4c7e288e40316d1fe5f4de60c56cfff2fa5eb0da 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/pte.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/pte.h @@ -54,13 +54,6 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define ATTR_MASK_L UINT64_C(0x0000000000000fff) #define ATTR_MASK (ATTR_MASK_H | ATTR_MASK_L) -#define BASE_MASK ~ATTR_MASK -#define BASE_ADDR(x) ((x) & BASE_MASK) - -#define PTE_TO_PHYS(pte) BASE_ADDR(pte) -/* Convert a phys addr to the output address field of a PTE */ -#define PHYS_TO_PTE(pa) (pa) - /* Bits 58:55 are reserved for software */ #define ATTR_SW_UNUSED1 (1UL << 58) #define ATTR_SW_NO_PROMOTE (1UL << 57) @@ -80,13 +73,37 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define ATTR_CONTIGUOUS (1UL << 52) #define ATTR_DBM (1UL << 51) +#define ATTR_S1_GP_SHIFT 50 +#define ATTR_S1_GP (1UL << ATTR_S1_GP_SHIFT) + +/* + * Largest possible output address field for a level 3 page. Block + * entries will use fewer low address bits, but these are res0 so + * should be safe to include. + * + * This is also safe to use for the next-level table address for + * table entries as they encode a physical address in the same way. + */ +#if PAGE_SIZE == PAGE_SIZE_4K +#define ATTR_ADDR UINT64_C(0x0003fffffffff000) +#elif PAGE_SIZE == PAGE_SIZE_16K +#define ATTR_ADDR UINT64_C(0x0003ffffffffc000) +#else +#error Unsupported page size +#endif + #define ATTR_S1_nG (1 << 11) #define ATTR_AF (1 << 10) +/* When TCR_EL1.DS == 0 */ #define ATTR_SH(x) ((x) << 8) #define ATTR_SH_MASK ATTR_SH(3) #define ATTR_SH_NS 0 /* Non-shareable */ #define ATTR_SH_OS 2 /* Outer-shareable */ #define ATTR_SH_IS 3 /* Inner-shareable */ +/* When TCR_EL1.DS == 1 */ +#define ATTR_OA_51_50_SHIFT 8 +#define ATTR_OA_51_50_MASK (3 << ATTR_OA_51_50_SHIFT) +#define ATTR_OA_51_50_DELTA (50 - 8) /* Delta from address to pte */ #define ATTR_S1_AP_RW_BIT (1 << 7) #define ATTR_S1_AP(x) ((x) << 6) @@ -110,8 +127,6 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define ATTR_S2_MEMATTR_WT 0xa #define ATTR_S2_MEMATTR_WB 0xf -#define ATTR_DEFAULT (ATTR_AF | ATTR_SH(ATTR_SH_IS)) - #define ATTR_DESCR_MASK 3 #define ATTR_DESCR_VALID 1 #define ATTR_DESCR_TYPE_MASK 2 @@ -119,6 +134,35 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define ATTR_DESCR_TYPE_PAGE 2 #define ATTR_DESCR_TYPE_BLOCK 0 +/* + * Superpage promotion requires that the bits specified by the following + * mask all be identical in the constituent PTEs. + */ +#define ATTR_PROMOTE (ATTR_MASK & ~(ATTR_CONTIGUOUS | ATTR_AF)) + +/* Read the output address or next-level table address from a PTE */ +#define PTE_TO_PHYS(x) ({ \ + pt_entry_t _pte = (x); \ + vm_paddr_t _pa; \ + _pa = _pte & ATTR_ADDR; \ + if (pmap_lpa_enabled) \ + _pa |= (_pte & ATTR_OA_51_50_MASK) << ATTR_OA_51_50_DELTA; \ + _pa; \ +}) + +/* + * Convert a physical address to an output address or next-level + * table address in a PTE + */ +#define PHYS_TO_PTE(x) ({ \ + vm_paddr_t _pa = (x); \ + pt_entry_t _pte; \ + _pte = _pa & ATTR_ADDR; \ + if (pmap_lpa_enabled) \ + _pte |= (_pa >> ATTR_OA_51_50_DELTA) & ATTR_OA_51_50_MASK; \ + _pte; \ +}) + #if PAGE_SIZE == PAGE_SIZE_4K #define L0_SHIFT 39 #define L1_SHIFT 30 @@ -186,6 +230,26 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define Ln_ADDR_MASK (Ln_ENTRIES - 1) #define Ln_TABLE_MASK ((1 << 12) - 1) +/* + * The number of contiguous Level 3 entries (with ATTR_CONTIGUOUS set) that + * can be coalesced into a single TLB entry + */ +#if PAGE_SIZE == PAGE_SIZE_4K +#define L2C_ENTRIES 16 +#define L3C_ENTRIES 16 +#elif PAGE_SIZE == PAGE_SIZE_16K +#define L2C_ENTRIES 32 +#define L3C_ENTRIES 128 +#else +#error Unsupported page size +#endif + +#define L2C_SIZE (L2C_ENTRIES * L2_SIZE) +#define L2C_OFFSET (L2C_SIZE - 1) + +#define L3C_SIZE (L3C_ENTRIES * L3_SIZE) +#define L3C_OFFSET (L3C_SIZE - 1) + #define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK) #define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK) #define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK) diff --git a/lib/libc/include/aarch64-freebsd-none/machine/resource.h b/lib/libc/include/aarch64-freebsd-none/machine/resource.h index 2529c90f28d2f7b9bc4cd65bcb9b950c1de74976..22815ed321cb27ef0b615fb38d057f6709f2e551 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/resource.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/resource.h @@ -44,9 +44,7 @@ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ #define SYS_RES_GPIO 5 /* general purpose i/o */ -#ifdef NEW_PCIB #define PCI_RES_BUS 6 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/runq.h b/lib/libc/include/aarch64-freebsd-none/machine/runq.h deleted file mode 100644 index 77ea2d30deded5cd1cc731cd582bffad3239f308..0000000000000000000000000000000000000000 --- a/lib/libc/include/aarch64-freebsd-none/machine/runq.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef __arm__ -#include -#else /* !__arm__ */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (1) /* Number of priority status words. */ -#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (ffsl(word) - 1) - -/* - * Type of run queue status word. - */ -typedef unsigned long rqb_word_t; - -#endif - -#endif /* !__arm__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/signal.h b/lib/libc/include/aarch64-freebsd-none/machine/signal.h index 3463dae3831663fdc12ce793295d43cb2b9581c5..59db752c5bc132dcc45b75de06b67a89483dddbf 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/signal.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/signal.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17 */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/sysarch.h b/lib/libc/include/aarch64-freebsd-none/machine/sysarch.h index 35fa7faa2e7789931036f4850d3b377532f67427..b82e8d908418f540745cb633e435dfed9df84fc0 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/sysarch.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/sysarch.h @@ -39,6 +39,15 @@ #ifndef _MACHINE_SYSARCH_H_ #define _MACHINE_SYSARCH_H_ +#include + +#define ARM64_GUARD_PAGE 0x100 + +struct arm64_guard_page_args { + __uintptr_t addr; + __size_t len; +}; + #define ARM64_GET_SVE_VL 0x200 /* Reserved ARM64_SET_SVE_VL 0x201 */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/undefined.h b/lib/libc/include/aarch64-freebsd-none/machine/undefined.h index f1e6c5a1a9ae3da28170fbbc805809f7efe8660a..1611769fd8d0cbd43d4120cb0f65fa735a55d581 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/undefined.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/undefined.h @@ -35,31 +35,17 @@ typedef int (*undef_handler_t)(vm_offset_t, uint32_t, struct trapframe *, uint32_t); - -static inline int -mrs_Op0(uint32_t insn) -{ - - /* op0 is encoded without the top bit in a mrs instruction */ - return (2 | ((insn & MRS_Op0_MASK) >> MRS_Op0_SHIFT)); -} - -#define MRS_GET(op) \ -static inline int \ -mrs_##op(uint32_t insn) \ -{ \ - \ - return ((insn & MRS_##op##_MASK) >> MRS_##op##_SHIFT); \ -} -MRS_GET(Op1) -MRS_GET(CRn) -MRS_GET(CRm) -MRS_GET(Op2) +typedef bool (*undef_sys_handler_t)(uint64_t, struct trapframe *); void undef_init(void); -void *install_undef_handler(bool, undef_handler_t); +void install_sys_handler(undef_sys_handler_t); +void *install_undef_handler(undef_handler_t); +#ifdef COMPAT_FREEBSD32 +void *install_undef32_handler(undef_handler_t); +#endif void remove_undef_handler(void *); -int undef_insn(u_int, struct trapframe *); +bool undef_sys(uint64_t, struct trapframe *); +int undef_insn(struct trapframe *); #endif /* _KERNEL */ diff --git a/lib/libc/include/aarch64-freebsd-none/machine/vmm.h b/lib/libc/include/aarch64-freebsd-none/machine/vmm.h new file mode 100644 index 0000000000000000000000000000000000000000..ffb4a9d2c2df30c50bc22144900899427b9bb160 --- /dev/null +++ b/lib/libc/include/aarch64-freebsd-none/machine/vmm.h @@ -0,0 +1,348 @@ +/* + * Copyright (C) 2015 Mihai Carabas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_H_ +#define _VMM_H_ + +#include +#include +#include +#include + +#include "pte.h" +#include "pmap.h" + +struct vcpu; + +enum vm_suspend_how { + VM_SUSPEND_NONE, + VM_SUSPEND_RESET, + VM_SUSPEND_POWEROFF, + VM_SUSPEND_HALT, + VM_SUSPEND_DESTROY, + VM_SUSPEND_LAST +}; + +/* + * Identifiers for architecturally defined registers. + */ +enum vm_reg_name { + VM_REG_GUEST_X0 = 0, + VM_REG_GUEST_X1, + VM_REG_GUEST_X2, + VM_REG_GUEST_X3, + VM_REG_GUEST_X4, + VM_REG_GUEST_X5, + VM_REG_GUEST_X6, + VM_REG_GUEST_X7, + VM_REG_GUEST_X8, + VM_REG_GUEST_X9, + VM_REG_GUEST_X10, + VM_REG_GUEST_X11, + VM_REG_GUEST_X12, + VM_REG_GUEST_X13, + VM_REG_GUEST_X14, + VM_REG_GUEST_X15, + VM_REG_GUEST_X16, + VM_REG_GUEST_X17, + VM_REG_GUEST_X18, + VM_REG_GUEST_X19, + VM_REG_GUEST_X20, + VM_REG_GUEST_X21, + VM_REG_GUEST_X22, + VM_REG_GUEST_X23, + VM_REG_GUEST_X24, + VM_REG_GUEST_X25, + VM_REG_GUEST_X26, + VM_REG_GUEST_X27, + VM_REG_GUEST_X28, + VM_REG_GUEST_X29, + VM_REG_GUEST_LR, + VM_REG_GUEST_SP, + VM_REG_GUEST_PC, + VM_REG_GUEST_CPSR, + + VM_REG_GUEST_SCTLR_EL1, + VM_REG_GUEST_TTBR0_EL1, + VM_REG_GUEST_TTBR1_EL1, + VM_REG_GUEST_TCR_EL1, + VM_REG_GUEST_TCR2_EL1, + VM_REG_GUEST_MPIDR_EL1, + VM_REG_LAST +}; + +#define VM_INTINFO_VECTOR(info) ((info) & 0xff) +#define VM_INTINFO_DEL_ERRCODE 0x800 +#define VM_INTINFO_RSVD 0x7ffff000 +#define VM_INTINFO_VALID 0x80000000 +#define VM_INTINFO_TYPE 0x700 +#define VM_INTINFO_HWINTR (0 << 8) +#define VM_INTINFO_NMI (2 << 8) +#define VM_INTINFO_HWEXCEPTION (3 << 8) +#define VM_INTINFO_SWINTR (4 << 8) + +#define VM_GUEST_BASE_IPA 0x80000000UL /* Guest kernel start ipa */ + +/* + * The VM name has to fit into the pathname length constraints of devfs, + * governed primarily by SPECNAMELEN. The length is the total number of + * characters in the full path, relative to the mount point and not + * including any leading '/' characters. + * A prefix and a suffix are added to the name specified by the user. + * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters + * longer for future use. + * The suffix is a string that identifies a bootrom image or some similar + * image that is attached to the VM. A separator character gets added to + * the suffix automatically when generating the full path, so it must be + * accounted for, reducing the effective length by 1. + * The effective length of a VM name is 229 bytes for FreeBSD 13 and 37 + * bytes for FreeBSD 12. A minimum length is set for safety and supports + * a SPECNAMELEN as small as 32 on old systems. + */ +#define VM_MAX_PREFIXLEN 10 +#define VM_MAX_SUFFIXLEN 15 +#define VM_MAX_NAMELEN \ + (SPECNAMELEN - VM_MAX_PREFIXLEN - VM_MAX_SUFFIXLEN - 1) + +#ifdef _KERNEL +struct vm; +struct vm_exception; +struct vm_exit; +struct vm_run; +struct vm_object; +struct vm_guest_paging; +struct vm_vgic_descr; +struct pmap; + +struct vm_eventinfo { + void *rptr; /* rendezvous cookie */ + int *sptr; /* suspend cookie */ + int *iptr; /* reqidle cookie */ +}; + +int vm_create(const char *name, struct vm **retvm); +struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid); +void vm_disable_vcpu_creation(struct vm *vm); +void vm_slock_vcpus(struct vm *vm); +void vm_unlock_vcpus(struct vm *vm); +void vm_destroy(struct vm *vm); +int vm_reinit(struct vm *vm); +const char *vm_name(struct vm *vm); + +uint16_t vm_get_maxcpus(struct vm *vm); +void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, + uint16_t *threads, uint16_t *maxcpus); +int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, + uint16_t threads, uint16_t maxcpus); +int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); +int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); +int vm_run(struct vcpu *vcpu); +int vm_suspend(struct vm *vm, enum vm_suspend_how how); +void* vm_get_cookie(struct vm *vm); +int vcpu_vcpuid(struct vcpu *vcpu); +void *vcpu_get_cookie(struct vcpu *vcpu); +struct vm *vcpu_vm(struct vcpu *vcpu); +struct vcpu *vm_vcpu(struct vm *vm, int cpu); +int vm_get_capability(struct vcpu *vcpu, int type, int *val); +int vm_set_capability(struct vcpu *vcpu, int type, int val); +int vm_activate_cpu(struct vcpu *vcpu); +int vm_suspend_cpu(struct vm *vm, struct vcpu *vcpu); +int vm_resume_cpu(struct vm *vm, struct vcpu *vcpu); +int vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far); +int vm_attach_vgic(struct vm *vm, struct vm_vgic_descr *descr); +int vm_assert_irq(struct vm *vm, uint32_t irq); +int vm_deassert_irq(struct vm *vm, uint32_t irq); +int vm_raise_msi(struct vm *vm, uint64_t msg, uint64_t addr, int bus, int slot, + int func); +struct vm_exit *vm_exitinfo(struct vcpu *vcpu); +void vm_exit_suspended(struct vcpu *vcpu, uint64_t pc); +void vm_exit_debug(struct vcpu *vcpu, uint64_t pc); +void vm_exit_rendezvous(struct vcpu *vcpu, uint64_t pc); +void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc); + +cpuset_t vm_active_cpus(struct vm *vm); +cpuset_t vm_debug_cpus(struct vm *vm); +cpuset_t vm_suspended_cpus(struct vm *vm); + +static __inline int +vcpu_rendezvous_pending(struct vm_eventinfo *info) +{ + + return (*((uintptr_t *)(info->rptr)) != 0); +} + +static __inline int +vcpu_suspended(struct vm_eventinfo *info) +{ + + return (*info->sptr); +} + +int vcpu_debugged(struct vcpu *vcpu); + +enum vcpu_state { + VCPU_IDLE, + VCPU_FROZEN, + VCPU_RUNNING, + VCPU_SLEEPING, +}; + +int vcpu_set_state(struct vcpu *vcpu, enum vcpu_state state, bool from_idle); +enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu); + +static int __inline +vcpu_is_running(struct vcpu *vcpu, int *hostcpu) +{ + return (vcpu_get_state(vcpu, hostcpu) == VCPU_RUNNING); +} + +#ifdef _SYS_PROC_H_ +static int __inline +vcpu_should_yield(struct vcpu *vcpu) +{ + struct thread *td; + + td = curthread; + return (td->td_ast != 0 || td->td_owepreempt != 0); +} +#endif + +void *vcpu_stats(struct vcpu *vcpu); +void vcpu_notify_event(struct vcpu *vcpu); +struct vmspace *vm_vmspace(struct vm *vm); +struct vm_mem *vm_mem(struct vm *vm); + +enum vm_reg_name vm_segment_name(int seg_encoding); + +struct vm_copyinfo { + uint64_t gpa; + size_t len; + void *hva; + void *cookie; +}; + +#endif /* _KERNEL */ + +#define VM_DIR_READ 0 +#define VM_DIR_WRITE 1 + +#define VM_GP_M_MASK 0x1f +#define VM_GP_MMU_ENABLED (1 << 5) + +struct vm_guest_paging { + uint64_t ttbr0_addr; + uint64_t ttbr1_addr; + uint64_t tcr_el1; + uint64_t tcr2_el1; + int flags; + int padding; +}; + +struct vie { + uint8_t access_size:4, sign_extend:1, dir:1, unused:2; + enum vm_reg_name reg; +}; + +struct vre { + uint32_t inst_syndrome; + uint8_t dir:1, unused:7; + enum vm_reg_name reg; +}; + +/* + * Identifiers for optional vmm capabilities + */ +enum vm_cap_type { + VM_CAP_HALT_EXIT, + VM_CAP_PAUSE_EXIT, + VM_CAP_UNRESTRICTED_GUEST, + VM_CAP_BRK_EXIT, + VM_CAP_SS_EXIT, + VM_CAP_MASK_HWINTR, + VM_CAP_MAX +}; + +enum vm_exitcode { + VM_EXITCODE_BOGUS, + VM_EXITCODE_INST_EMUL, + VM_EXITCODE_REG_EMUL, + VM_EXITCODE_HVC, + VM_EXITCODE_SUSPENDED, + VM_EXITCODE_HYP, + VM_EXITCODE_WFI, + VM_EXITCODE_PAGING, + VM_EXITCODE_SMCCC, + VM_EXITCODE_DEBUG, + VM_EXITCODE_BRK, + VM_EXITCODE_SS, + VM_EXITCODE_MAX +}; + +struct vm_exit { + enum vm_exitcode exitcode; + int inst_length; + uint64_t pc; + union { + /* + * ARM specific payload. + */ + struct { + uint32_t exception_nr; + uint32_t pad; + uint64_t esr_el2; /* Exception Syndrome Register */ + uint64_t far_el2; /* Fault Address Register */ + uint64_t hpfar_el2; /* Hypervisor IPA Fault Address Register */ + } hyp; + struct { + struct vre vre; + } reg_emul; + struct { + uint64_t gpa; + uint64_t esr; + } paging; + struct { + uint64_t gpa; + struct vm_guest_paging paging; + struct vie vie; + } inst_emul; + + /* + * A SMCCC call, e.g. starting a core via PSCI. + * Further arguments can be read by asking the kernel for + * all register values. + */ + struct { + uint64_t func_id; + uint64_t args[7]; + } smccc_call; + + struct { + enum vm_suspend_how how; + } suspended; + } u; +}; + +#endif /* _VMM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/vmm_dev.h b/lib/libc/include/aarch64-freebsd-none/machine/vmm_dev.h new file mode 100644 index 0000000000000000000000000000000000000000..b363b3d61a890e1f92a0b97db4c767d953e179a8 --- /dev/null +++ b/lib/libc/include/aarch64-freebsd-none/machine/vmm_dev.h @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2015 Mihai Carabas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_DEV_H_ +#define _VMM_DEV_H_ + +#include + +#include + +struct vm_memmap { + vm_paddr_t gpa; + int segid; /* memory segment */ + vm_ooffset_t segoff; /* offset into memory segment */ + size_t len; /* mmap length */ + int prot; /* RWX */ + int flags; +}; +#define VM_MEMMAP_F_WIRED 0x01 + +struct vm_munmap { + vm_paddr_t gpa; + size_t len; +}; + +#define VM_MEMSEG_NAME(m) ((m)->name[0] != '\0' ? (m)->name : NULL) +struct vm_memseg { + int segid; + size_t len; + char name[VM_MAX_SUFFIXLEN + 1]; + domainset_t *ds_mask; + size_t ds_mask_size; + int ds_policy; +}; + +struct vm_register { + int cpuid; + int regnum; /* enum vm_reg_name */ + uint64_t regval; +}; + +struct vm_register_set { + int cpuid; + unsigned int count; + const int *regnums; /* enum vm_reg_name */ + uint64_t *regvals; +}; + +struct vm_run { + int cpuid; + cpuset_t *cpuset; /* CPU set storage */ + size_t cpusetsize; + struct vm_exit *vm_exit; +}; + +struct vm_exception { + int cpuid; + uint64_t esr; + uint64_t far; +}; + +struct vm_msi { + uint64_t msg; + uint64_t addr; + int bus; + int slot; + int func; +}; + +struct vm_capability { + int cpuid; + enum vm_cap_type captype; + int capval; + int allcpus; +}; + +#define MAX_VM_STATS 64 +struct vm_stats { + int cpuid; /* in */ + int index; /* in */ + int num_entries; /* out */ + struct timeval tv; + uint64_t statbuf[MAX_VM_STATS]; +}; +struct vm_stat_desc { + int index; /* in */ + char desc[128]; /* out */ +}; + +struct vm_suspend { + enum vm_suspend_how how; +}; + +struct vm_gla2gpa { + int vcpuid; /* inputs */ + int prot; /* PROT_READ or PROT_WRITE */ + uint64_t gla; + struct vm_guest_paging paging; + int fault; /* outputs */ + uint64_t gpa; +}; + +struct vm_activate_cpu { + int vcpuid; +}; + +struct vm_cpuset { + int which; + int cpusetsize; + cpuset_t *cpus; +}; +#define VM_ACTIVE_CPUS 0 +#define VM_SUSPENDED_CPUS 1 +#define VM_DEBUG_CPUS 2 + +struct vm_vgic_version { + u_int version; + u_int flags; +}; + +struct vm_vgic_descr { + struct vm_vgic_version ver; + union { + struct { + uint64_t dist_start; + uint64_t dist_size; + uint64_t redist_start; + uint64_t redist_size; + } v3_regs; + }; +}; + +struct vm_irq { + uint32_t irq; +}; + +struct vm_cpu_topology { + uint16_t sockets; + uint16_t cores; + uint16_t threads; + uint16_t maxcpus; +}; + +enum { + /* general routines */ + IOCNUM_ABIVERS = 0, + IOCNUM_RUN = 1, + IOCNUM_SET_CAPABILITY = 2, + IOCNUM_GET_CAPABILITY = 3, + IOCNUM_SUSPEND = 4, + IOCNUM_REINIT = 5, + + /* memory apis */ + IOCNUM_GET_GPA_PMAP = 12, + IOCNUM_GLA2GPA_NOFAULT = 13, + IOCNUM_ALLOC_MEMSEG = 14, + IOCNUM_GET_MEMSEG = 15, + IOCNUM_MMAP_MEMSEG = 16, + IOCNUM_MMAP_GETNEXT = 17, + IOCNUM_MUNMAP_MEMSEG = 18, + + /* register/state accessors */ + IOCNUM_SET_REGISTER = 20, + IOCNUM_GET_REGISTER = 21, + IOCNUM_SET_REGISTER_SET = 24, + IOCNUM_GET_REGISTER_SET = 25, + + /* statistics */ + IOCNUM_VM_STATS = 50, + IOCNUM_VM_STAT_DESC = 51, + + /* CPU Topology */ + IOCNUM_SET_TOPOLOGY = 63, + IOCNUM_GET_TOPOLOGY = 64, + + /* interrupt injection */ + IOCNUM_ASSERT_IRQ = 80, + IOCNUM_DEASSERT_IRQ = 81, + IOCNUM_RAISE_MSI = 82, + IOCNUM_INJECT_EXCEPTION = 83, + + /* vm_cpuset */ + IOCNUM_ACTIVATE_CPU = 90, + IOCNUM_GET_CPUSET = 91, + IOCNUM_SUSPEND_CPU = 92, + IOCNUM_RESUME_CPU = 93, + + /* vm_attach_vgic */ + IOCNUM_GET_VGIC_VERSION = 110, + IOCNUM_ATTACH_VGIC = 111, +}; + +#define VM_RUN \ + _IOWR('v', IOCNUM_RUN, struct vm_run) +#define VM_SUSPEND \ + _IOW('v', IOCNUM_SUSPEND, struct vm_suspend) +#define VM_REINIT \ + _IO('v', IOCNUM_REINIT) +#define VM_ALLOC_MEMSEG \ + _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg) +#define VM_GET_MEMSEG \ + _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg) +#define VM_MMAP_MEMSEG \ + _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap) +#define VM_MMAP_GETNEXT \ + _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap) +#define VM_MUNMAP_MEMSEG \ + _IOW('v', IOCNUM_MUNMAP_MEMSEG, struct vm_munmap) +#define VM_SET_REGISTER \ + _IOW('v', IOCNUM_SET_REGISTER, struct vm_register) +#define VM_GET_REGISTER \ + _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register) +#define VM_SET_REGISTER_SET \ + _IOW('v', IOCNUM_SET_REGISTER_SET, struct vm_register_set) +#define VM_GET_REGISTER_SET \ + _IOWR('v', IOCNUM_GET_REGISTER_SET, struct vm_register_set) +#define VM_SET_CAPABILITY \ + _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability) +#define VM_GET_CAPABILITY \ + _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability) +#define VM_STATS \ + _IOWR('v', IOCNUM_VM_STATS, struct vm_stats) +#define VM_STAT_DESC \ + _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc) +#define VM_ASSERT_IRQ \ + _IOW('v', IOCNUM_ASSERT_IRQ, struct vm_irq) +#define VM_DEASSERT_IRQ \ + _IOW('v', IOCNUM_DEASSERT_IRQ, struct vm_irq) +#define VM_RAISE_MSI \ + _IOW('v', IOCNUM_RAISE_MSI, struct vm_msi) +#define VM_INJECT_EXCEPTION \ + _IOW('v', IOCNUM_INJECT_EXCEPTION, struct vm_exception) +#define VM_SET_TOPOLOGY \ + _IOW('v', IOCNUM_SET_TOPOLOGY, struct vm_cpu_topology) +#define VM_GET_TOPOLOGY \ + _IOR('v', IOCNUM_GET_TOPOLOGY, struct vm_cpu_topology) +#define VM_GLA2GPA_NOFAULT \ + _IOWR('v', IOCNUM_GLA2GPA_NOFAULT, struct vm_gla2gpa) +#define VM_ACTIVATE_CPU \ + _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu) +#define VM_GET_CPUS \ + _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset) +#define VM_SUSPEND_CPU \ + _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu) +#define VM_RESUME_CPU \ + _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu) +#define VM_GET_VGIC_VERSION \ + _IOR('v', IOCNUM_GET_VGIC_VERSION, struct vm_vgic_version) +#define VM_ATTACH_VGIC \ + _IOW('v', IOCNUM_ATTACH_VGIC, struct vm_vgic_descr) +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/vmm_instruction_emul.h b/lib/libc/include/aarch64-freebsd-none/machine/vmm_instruction_emul.h new file mode 100644 index 0000000000000000000000000000000000000000..96732c94f01d18e53dc0bd9bb21f53b14f858c18 --- /dev/null +++ b/lib/libc/include/aarch64-freebsd-none/machine/vmm_instruction_emul.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 Mihai Carabas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_INSTRUCTION_EMUL_H_ +#define _VMM_INSTRUCTION_EMUL_H_ + +/* + * Callback functions to read and write memory regions. + */ +typedef int (*mem_region_read_t)(struct vcpu *vcpu, uint64_t gpa, + uint64_t *rval, int rsize, void *arg); +typedef int (*mem_region_write_t)(struct vcpu *vcpu, uint64_t gpa, + uint64_t wval, int wsize, void *arg); + +/* + * Callback functions to read and write registers. + */ +typedef int (*reg_read_t)(struct vcpu *vcpu, uint64_t *rval, void *arg); +typedef int (*reg_write_t)(struct vcpu *vcpu, uint64_t wval, void *arg); + +/* + * Emulate the decoded 'vie' instruction when it contains a memory operation. + * + * The callbacks 'mrr' and 'mrw' emulate reads and writes to the memory region + * containing 'gpa'. 'mrarg' is an opaque argument that is passed into the + * callback functions. + * + * 'void *vm' should be 'struct vm *' when called from kernel context and + * 'struct vmctx *' when called from user context. + * + */ +int vmm_emulate_instruction(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, + struct vm_guest_paging *paging, mem_region_read_t mrr, + mem_region_write_t mrw, void *mrarg); + +/* + * Emulate the decoded 'vre' instruction when it contains a register access. + * + * The callbacks 'regread' and 'regwrite' emulate reads and writes to the + * register from 'vie'. 'regarg' is an opaque argument that is passed into the + * callback functions. + * + * 'void *vm' should be 'struct vm *' when called from kernel context and + * 'struct vmctx *' when called from user context. + * + */ +int vmm_emulate_register(struct vcpu *vcpu, struct vre *vre, reg_read_t regread, + reg_write_t regwrite, void *regarg); + +#ifdef _KERNEL +void vm_register_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask, + reg_read_t reg_read, reg_write_t reg_write, void *arg); +void vm_deregister_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask); + +void vm_register_inst_handler(struct vm *vm, uint64_t start, uint64_t size, + mem_region_read_t mmio_read, mem_region_write_t mmio_write); +void vm_deregister_inst_handler(struct vm *vm, uint64_t start, uint64_t size); +#endif + +#endif /* _VMM_INSTRUCTION_EMUL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-freebsd-none/machine/vmparam.h b/lib/libc/include/aarch64-freebsd-none/machine/vmparam.h index 43836cb537819720d20fb0038ef6a683ac86f5b1..cf8d0e7bee85cc039903c81bb5dfb8a75c1b4e1f 100644 --- a/lib/libc/include/aarch64-freebsd-none/machine/vmparam.h +++ b/lib/libc/include/aarch64-freebsd-none/machine/vmparam.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30 */ @@ -75,14 +73,16 @@ #define VM_PHYSSEG_MAX 64 /* - * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool - * from which physical pages are allocated and VM_FREEPOOL_DIRECT is - * the pool from which physical pages for small UMA objects are - * allocated. + * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from + * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from + * which physical pages for page tables and small UMA objects are allocated. + * VM_FREEPOOL_LAZYINIT is a special-purpose pool that is populated only during + * boot and is used to implement deferred initialization of page structures. */ -#define VM_NFREEPOOL 2 -#define VM_FREEPOOL_DEFAULT 0 -#define VM_FREEPOOL_DIRECT 1 +#define VM_NFREEPOOL 3 +#define VM_FREEPOOL_LAZYINIT 0 +#define VM_FREEPOOL_DEFAULT 1 +#define VM_FREEPOOL_DIRECT 2 /* * Create two free page lists: VM_FREELIST_DMA32 is for physical pages that have @@ -101,21 +101,46 @@ * are used by UMA, the physical memory allocator reduces the likelihood of * both 2MB page TLB misses and cache misses during the page table walk when * a 2MB page TLB miss does occur. + * + * When PAGE_SIZE is 16KB, an allocation size of 32MB is supported. This + * size is used by level 0 reservations and L2 BLOCK mappings. */ +#if PAGE_SIZE == PAGE_SIZE_4K #define VM_NFREEORDER 13 +#elif PAGE_SIZE == PAGE_SIZE_16K +#define VM_NFREEORDER 12 +#else +#error Unsupported page size +#endif /* - * Enable superpage reservations: 1 level. + * Enable superpage reservations: 2 levels. */ #ifndef VM_NRESERVLEVEL -#define VM_NRESERVLEVEL 1 +#define VM_NRESERVLEVEL 2 #endif /* - * Level 0 reservations consist of 512 pages. + * Level 0 reservations consist of 16 pages when PAGE_SIZE is 4KB, and 128 + * pages when PAGE_SIZE is 16KB. Level 1 reservations consist of 32 64KB + * pages when PAGE_SIZE is 4KB, and 16 2M pages when PAGE_SIZE is 16KB. */ +#if PAGE_SIZE == PAGE_SIZE_4K #ifndef VM_LEVEL_0_ORDER -#define VM_LEVEL_0_ORDER 9 +#define VM_LEVEL_0_ORDER 4 +#endif +#ifndef VM_LEVEL_1_ORDER +#define VM_LEVEL_1_ORDER 5 +#endif +#elif PAGE_SIZE == PAGE_SIZE_16K +#ifndef VM_LEVEL_0_ORDER +#define VM_LEVEL_0_ORDER 7 +#endif +#ifndef VM_LEVEL_1_ORDER +#define VM_LEVEL_1_ORDER 4 +#endif +#else +#error Unsupported page size #endif /** @@ -133,6 +158,12 @@ * 0xfffffeffffffffff End of DMAP * 0xffffa00000000000 Start of DMAP * + * 0xffff027fffffffff End of KMSAN origin map + * 0xffff020000000000 Start of KMSAN origin map + * + * 0xffff017fffffffff End of KMSAN shadow map + * 0xffff010000000000 Start of KMSAN shadow map + * * 0xffff009fffffffff End of KASAN shadow map * 0xffff008000000000 Start of KASAN shadow map * @@ -169,11 +200,25 @@ #define KASAN_MIN_ADDRESS (0xffff008000000000UL) #define KASAN_MAX_ADDRESS (0xffff00a000000000UL) +/* 512GiB KMSAN shadow map */ +#define KMSAN_SHAD_MIN_ADDRESS (0xffff010000000000UL) +#define KMSAN_SHAD_MAX_ADDRESS (0xffff018000000000UL) + +/* 512GiB KMSAN origin map */ +#define KMSAN_ORIG_MIN_ADDRESS (0xffff020000000000UL) +#define KMSAN_ORIG_MAX_ADDRESS (0xffff028000000000UL) + /* The address bits that hold a pointer authentication code */ -#define PAC_ADDR_MASK (0xff7f000000000000UL) +#define PAC_ADDR_MASK (0x007f000000000000UL) +#define PAC_ADDR_MASK_14 (0xff7f000000000000UL) + +/* The top-byte ignore address bits */ +#define TBI_ADDR_MASK 0xff00000000000000UL /* If true addr is in the kernel address space */ #define ADDR_IS_KERNEL(addr) (((addr) & (1ul << 55)) == (1ul << 55)) +/* If true addr is in the user address space */ +#define ADDR_IS_USER(addr) (((addr) & (1ul << 55)) == 0) /* If true addr is in its canonical form (i.e. no TBI, PAC, etc.) */ #define ADDR_IS_CANONICAL(addr) \ (((addr) & 0xffff000000000000UL) == 0 || \ @@ -265,7 +310,7 @@ #endif #if !defined(KASAN) && !defined(KMSAN) -#define UMA_MD_SMALL_ALLOC +#define UMA_USE_DMAP #endif #ifndef LOCORE @@ -289,6 +334,7 @@ extern vm_offset_t dmap_max_addr; * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 1 #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/lib/libc/include/arm-freebsd-eabihf/fenv.h b/lib/libc/include/arm-freebsd-eabihf/fenv.h index 4aa93a759c26ab4f0833e575ebeca5a096fd2500..ca9d01ef40f0ad138ac9dba0666d2d9c8195f4dd 100644 --- a/lib/libc/include/arm-freebsd-eabihf/fenv.h +++ b/lib/libc/include/arm-freebsd-eabihf/fenv.h @@ -29,6 +29,7 @@ #ifndef _FENV_H_ #define _FENV_H_ +#include #include #ifndef __fenv_static diff --git a/lib/libc/include/arm-freebsd-eabihf/float.h b/lib/libc/include/arm-freebsd-eabihf/float.h index 8f8a41e8562d266052d13b8758aaf49dbb3eab3a..b0ab1592b2ad5e4c455bd10be0937b8f0363afc3 100644 --- a/lib/libc/include/arm-freebsd-eabihf/float.h +++ b/lib/libc/include/arm-freebsd-eabihf/float.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/floatingpoint.h b/lib/libc/include/arm-freebsd-eabihf/floatingpoint.h index 428967247163bb8e075b97d4925f2b9bf107f097..bd3020282afc0ddd0e557c0364c1d86752572015 100644 --- a/lib/libc/include/arm-freebsd-eabihf/floatingpoint.h +++ b/lib/libc/include/arm-freebsd-eabihf/floatingpoint.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 */ #ifndef _FLOATINGPOINT_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/_align.h b/lib/libc/include/arm-freebsd-eabihf/machine/_align.h index 61c22df04881e6a07cef5ed3c045d59a9c33c01d..5a6acf9624fba3a59f1684adbc70196715bcd94e 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/_align.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/_align.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _ARM_INCLUDE__ALIGN_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/_bus.h b/lib/libc/include/arm-freebsd-eabihf/machine/_bus.h index ffa8addd0d954bb09dcbe90101015d37fb129bde..7b5f67bec68bcee78acf32cb87bd36d59d1571bf 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/_bus.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/_bus.h @@ -1,30 +1,13 @@ /*- + * Copyright (c) 2005 The FreeBSD Foundation. + * * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Derived in part from NetBSD's bus.h files by (alphabetically): + * Christopher G. Demetriou + * Charles M. Hannum + * Jason Thorpe + * The NetBSD Foundation. */ #ifndef ARM_INCLUDE__BUS_H diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/_limits.h b/lib/libc/include/arm-freebsd-eabihf/machine/_limits.h index bdcfd4d9797d382471b921fe9008193c1680c0d4..8dfdf8299b90c6053ac6733080d6c5805f80e4bf 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/_limits.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/_limits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE__LIMITS_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/_types.h b/lib/libc/include/arm-freebsd-eabihf/machine/_types.h index ad50fd62c74e4d6c818be3ff66621d2d01f1a42d..847aff8d2b898bbd7252020084929ac2002c59a7 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/_types.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/_types.h @@ -32,9 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifndef _MACHINE__TYPES_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h b/lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h index d63a1132e55da1e2aaa010ea8dfc02f58db9f87a..8791e469f8a83a4f3bf9edb98518b4a6e38decbc 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/acle-compat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 ARM Ltd + * Copyright (c) 2024 Arm Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,157 +27,5 @@ */ #ifndef __ARM_ARCH - -/* ACLE standardises a set of pre-defines that describe the ARM architecture. - These were mostly implemented in GCC around GCC-4.8; older versions - have no, or only partial support. To provide a level of backwards - compatibility we try to work out what the definitions should be, given - the older pre-defines that GCC did produce. This isn't complete, but - it should be enough for use by routines that depend on this header. */ - -/* No need to handle ARMv8, GCC had ACLE support before that. */ - -#define __ARM_ACLE 101 - -# ifdef __ARM_ARCH_7__ -/* The common subset of ARMv7 in all profiles. */ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# endif - -# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__) -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 15 -# define __ARM_FEATURE_UNALIGNED -# ifdef __ARM_ARCH_7A__ -# define __ARM_ARCH_PROFILE 'A' -# else -# define __ARM_ARCH_PROFILE 'R' -# endif -# endif - -# ifdef __ARM_ARCH_7EM__ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# define __ARM_ARCH_PROFILE 'M' -# endif - -# ifdef __ARM_ARCH_7M__ -# define __ARM_ARCH 7 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 7 -# define __ARM_FEATURE_UNALIGNED -# define __ARM_ARCH_PROFILE 'M' -# endif - -# ifdef __ARM_ARCH_6T2__ -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 2 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_LDREX 4 -# define __ARM_FEATURE_UNALIGNED -# endif - -# ifdef __ARM_ARCH_6M__ -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 1 -# define __ARM_ARCH_PROFILE 'M' -# endif - -# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \ - || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \ - || defined (__ARM_ARCH_6ZK__) -# define __ARM_ARCH 6 -# define __ARM_ARCH_ISA_THUMB 1 -# define __ARM_ARCH_ISA_ARM -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_SIMD32 -# define __ARM_FEATURE_DSP -# define __ARM_FEATURE_QBIT -# define __ARM_FEATURE_SAT -# define __ARM_FEATURE_UNALIGNED -# ifndef __thumb__ -# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__) -# define __ARM_FEATURE_LDREX 15 -# else -# define __ARM_FEATURE_LDREX 4 -# endif -# endif -# endif - -# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__) -# define __ARM_ARCH 5 -# define __ARM_ARCH_ISA_ARM -# ifdef __ARM_ARCH_5TE__ -# define __ARM_ARCH_ISA_THUMB 1 -# endif -# define __ARM_FEATURE_CLZ -# define __ARM_FEATURE_DSP -# endif - -# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__) -# define __ARM_ARCH 5 -# define __ARM_ARCH_ISA_ARM -# ifdef __ARM_ARCH_5TE__ -# define __ARM_ARCH_ISA_THUMB 1 -# endif -# define __ARM_FEATURE_CLZ -# endif - -# ifdef __ARM_ARCH_4T__ -# define __ARM_ARCH 4 -# define __ARM_ARCH_ISA_ARM -# define __ARM_ARCH_ISA_THUMB 1 -# endif - -# ifdef __ARM_ARCH_4__ -# define __ARM_ARCH 4 -# define __ARM_ARCH_ISA_ARM -# endif - -# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__) -# define __ARM_ARCH 3 -# define __ARM_ARCH_ISA_ARM -# endif - -# ifdef __ARM_ARCH_2__ -# define __ARM_ARCH 2 -# define __ARM_ARCH_ISA_ARM -# endif - -# ifdef __ARMEB__ -# define __ARM_BIG_ENDIAN -# endif - -/* If we still don't know what the target architecture is, then we're - probably not using GCC. */ -# ifndef __ARM_ARCH -# error Unable to determine architecture version. -# endif - -#endif /* __ARM_ARCH */ \ No newline at end of file +#error Your compiler is too old +#endif \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/asm.h b/lib/libc/include/arm-freebsd-eabihf/machine/asm.h index fa7cbd6694327a80af79f049c9419f165ac8509a..52acdd60dbe92c7d56b3f981920e0f49603e6270 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/asm.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/asm.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 */ #ifndef _MACHINE_ASM_H_ @@ -176,7 +174,6 @@ # define RETne bxne lr # define RETc(c) bx##c lr -#if __ARM_ARCH >= 7 #define ISB isb #define DSB dsb #define DMB dmb @@ -190,12 +187,5 @@ #define ERET .word 0xe160006e #endif -#elif __ARM_ARCH == 6 -#include -#define ISB mcr CP15_CP15ISB -#define DSB mcr CP15_CP15DSB -#define DMB mcr CP15_CP15DMB -#define WFI mcr CP15_CP15WFI -#endif #endif /* !_MACHINE_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/atomic.h b/lib/libc/include/arm-freebsd-eabihf/machine/atomic.h index f4e9fb5c1b294a638866678922b06896ba9eae09..9a8ae6bc124e57726e026638b30bf77c668cc0dc 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/atomic.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/atomic.h @@ -41,15 +41,9 @@ #include -#if __ARM_ARCH >= 7 #define isb() __asm __volatile("isb" : : : "memory") #define dsb() __asm __volatile("dsb" : : : "memory") #define dmb() __asm __volatile("dmb" : : : "memory") -#else -#define isb() __asm __volatile("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory") -#define dsb() __asm __volatile("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory") -#define dmb() __asm __volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory") -#endif #define mb() dmb() #define wmb() dmb() @@ -614,7 +608,7 @@ atomic_fetchadd_long(volatile u_long *p, u_long val) } static __inline uint32_t -atomic_load_acq_32(volatile uint32_t *p) +atomic_load_acq_32(const volatile uint32_t *p) { uint32_t v; @@ -624,7 +618,7 @@ atomic_load_acq_32(volatile uint32_t *p) } static __inline uint64_t -atomic_load_64(volatile uint64_t *p) +atomic_load_64(const volatile uint64_t *p) { uint64_t ret; @@ -643,7 +637,7 @@ atomic_load_64(volatile uint64_t *p) } static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) +atomic_load_acq_64(const volatile uint64_t *p) { uint64_t ret; @@ -653,7 +647,7 @@ atomic_load_acq_64(volatile uint64_t *p) } static __inline u_long -atomic_load_acq_long(volatile u_long *p) +atomic_load_acq_long(const volatile u_long *p) { u_long v; @@ -898,8 +892,6 @@ atomic_testandclear_long(volatile u_long *p, u_int v) return (atomic_testandclear_32((volatile uint32_t *)p, v)); } -#define atomic_testandclear_long atomic_testandclear_long - static __inline int atomic_testandclear_64(volatile uint64_t *p, u_int v) @@ -958,7 +950,16 @@ atomic_testandset_long(volatile u_long *p, u_int v) return (atomic_testandset_32((volatile uint32_t *)p, v)); } -#define atomic_testandset_long atomic_testandset_long + +static __inline int +atomic_testandset_acq_long(volatile u_long *p, u_int v) +{ + int ret; + + ret = atomic_testandset_32((volatile uint32_t *)p, v); + dmb(); + return (ret); +} static __inline int atomic_testandset_64(volatile uint64_t *p, u_int v) @@ -1052,6 +1053,12 @@ atomic_thread_fence_seq_cst(void) dmb(); } +#define atomic_add_ptr atomic_add_32 +#define atomic_add_acq_ptr atomic_add_acq_32 +#define atomic_add_rel_ptr atomic_add_rel_32 +#define atomic_subtract_ptr atomic_subtract_32 +#define atomic_subtract_acq_ptr atomic_subtract_acq_32 +#define atomic_subtract_rel_ptr atomic_subtract_rel_32 #define atomic_clear_ptr atomic_clear_32 #define atomic_clear_acq_ptr atomic_clear_acq_32 #define atomic_clear_rel_ptr atomic_clear_rel_32 @@ -1059,15 +1066,18 @@ atomic_thread_fence_seq_cst(void) #define atomic_set_acq_ptr atomic_set_acq_32 #define atomic_set_rel_ptr atomic_set_rel_32 #define atomic_fcmpset_ptr atomic_fcmpset_32 -#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32 #define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_32 +#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_32 #define atomic_cmpset_ptr atomic_cmpset_32 #define atomic_cmpset_acq_ptr atomic_cmpset_acq_32 #define atomic_cmpset_rel_ptr atomic_cmpset_rel_32 +#define atomic_fetchadd_ptr atomic_fetchadd_32 +#define atomic_readandclear_ptr atomic_readandclear_32 #define atomic_load_acq_ptr atomic_load_acq_32 #define atomic_store_rel_ptr atomic_store_rel_32 #define atomic_swap_ptr atomic_swap_32 -#define atomic_readandclear_ptr atomic_readandclear_32 +#define atomic_testandset_ptr atomic_testandset_32 +#define atomic_testandclear_ptr atomic_testandclear_32 #define atomic_add_int atomic_add_32 #define atomic_add_acq_int atomic_add_acq_32 @@ -1093,12 +1103,9 @@ atomic_thread_fence_seq_cst(void) #define atomic_store_rel_int atomic_store_rel_32 #define atomic_swap_int atomic_swap_32 -/* - * For: - * - atomic_load_acq_8 - * - atomic_load_acq_16 - * - atomic_testandset_acq_long - */ #include +#define atomic_set_short atomic_set_16 +#define atomic_clear_short atomic_clear_16 + #endif /* _MACHINE_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/cpu.h b/lib/libc/include/arm-freebsd-eabihf/machine/cpu.h index cc6c423703cfc57fe832e904227d4fbcc22886fe..edba80742197b00e68694d05177236c8f5c9dbfe 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/cpu.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/cpu.h @@ -45,13 +45,7 @@ void cpu_halt(void); * unconditionally with -DSMP. Although it looks like a bug, * handle this case here and in #elif condition in ARM_SMP_UP macro. */ -#if __ARM_ARCH <= 6 && defined(SMP) && !defined(KLD_MODULE) -#error SMP option is not supported on ARMv6 -#endif -#if __ARM_ARCH <= 6 && defined(SMP_ON_UP) -#error SMP_ON_UP option is only supported on ARMv7+ CPUs -#endif #if !defined(SMP) && defined(SMP_ON_UP) #error SMP option must be defined for SMP_ON_UP option @@ -68,7 +62,7 @@ do { \ up_code; \ } \ } while (0) -#elif defined(SMP) && __ARM_ARCH > 6 +#elif defined(SMP) #define ARM_SMP_UP(smp_code, up_code) \ do { \ smp_code; \ @@ -146,15 +140,15 @@ fname(uint64_t reg) \ /* TLB */ _WF0(_CP15_TLBIALL, CP15_TLBIALL) /* Invalidate entire unified TLB */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_TLBIALLIS, CP15_TLBIALLIS) /* Invalidate entire unified TLB IS */ #endif _WF1(_CP15_TLBIASID, CP15_TLBIASID(%0)) /* Invalidate unified TLB by ASID */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF1(_CP15_TLBIASIDIS, CP15_TLBIASIDIS(%0)) /* Invalidate unified TLB by ASID IS */ #endif _WF1(_CP15_TLBIMVAA, CP15_TLBIMVAA(%0)) /* Invalidate unified TLB by MVA, all ASID */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF1(_CP15_TLBIMVAAIS, CP15_TLBIMVAAIS(%0)) /* Invalidate unified TLB by MVA, all ASID IS */ #endif _WF1(_CP15_TLBIMVA, CP15_TLBIMVA(%0)) /* Invalidate unified TLB by MVA */ @@ -164,21 +158,19 @@ _WF1(_CP15_TTB_SET, CP15_TTBR0(%0)) /* Cache and Branch predictor */ _WF0(_CP15_BPIALL, CP15_BPIALL) /* Branch predictor invalidate all */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_BPIALLIS, CP15_BPIALLIS) /* Branch predictor invalidate all IS */ #endif _WF1(_CP15_BPIMVA, CP15_BPIMVA(%0)) /* Branch predictor invalidate by MVA */ _WF1(_CP15_DCCIMVAC, CP15_DCCIMVAC(%0)) /* Data cache clean and invalidate by MVA PoC */ _WF1(_CP15_DCCISW, CP15_DCCISW(%0)) /* Data cache clean and invalidate by set/way */ _WF1(_CP15_DCCMVAC, CP15_DCCMVAC(%0)) /* Data cache clean by MVA PoC */ -#if __ARM_ARCH >= 7 _WF1(_CP15_DCCMVAU, CP15_DCCMVAU(%0)) /* Data cache clean by MVA PoU */ -#endif _WF1(_CP15_DCCSW, CP15_DCCSW(%0)) /* Data cache clean by set/way */ _WF1(_CP15_DCIMVAC, CP15_DCIMVAC(%0)) /* Data cache invalidate by MVA PoC */ _WF1(_CP15_DCISW, CP15_DCISW(%0)) /* Data cache invalidate by set/way */ _WF0(_CP15_ICIALLU, CP15_ICIALLU) /* Instruction cache invalidate all PoU */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) _WF0(_CP15_ICIALLUIS, CP15_ICIALLUIS) /* Instruction cache invalidate all PoU IS */ #endif _WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */ @@ -209,10 +201,8 @@ _WF1(cp15_prrr_set, CP15_PRRR(%0)) _WF1(cp15_nmrr_set, CP15_NMRR(%0)) _RF0(cp15_ttbr_get, CP15_TTBR0(%0)) _RF0(cp15_dfar_get, CP15_DFAR(%0)) -#if __ARM_ARCH >= 7 _RF0(cp15_ifar_get, CP15_IFAR(%0)) _RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0)) -#endif _RF0(cp15_actlr_get, CP15_ACTLR(%0)) _WF1(cp15_actlr_set, CP15_ACTLR(%0)) _WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0)) @@ -251,14 +241,6 @@ _RF0(cp15_cbar_get, CP15_CBAR(%0)) /* Performance Monitor registers */ -#if __ARM_ARCH == 6 && defined(CPU_ARM1176) -_RF0(cp15_pmuserenr_get, CP15_PMUSERENR(%0)) -_WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0)) -_RF0(cp15_pmcr_get, CP15_PMCR(%0)) -_WF1(cp15_pmcr_set, CP15_PMCR(%0)) -_RF0(cp15_pmccntr_get, CP15_PMCCNTR(%0)) -_WF1(cp15_pmccntr_set, CP15_PMCCNTR(%0)) -#elif __ARM_ARCH > 6 _RF0(cp15_pmcr_get, CP15_PMCR(%0)) _WF1(cp15_pmcr_set, CP15_PMCR(%0)) _RF0(cp15_pmcnten_get, CP15_PMCNTENSET(%0)) @@ -280,7 +262,6 @@ _WF1(cp15_pmuserenr_set, CP15_PMUSERENR(%0)) _RF0(cp15_pminten_get, CP15_PMINTENSET(%0)) _WF1(cp15_pminten_set, CP15_PMINTENSET(%0)) _WF1(cp15_pminten_clr, CP15_PMINTENCLR(%0)) -#endif _RF0(cp15_tpidrurw_get, CP15_TPIDRURW(%0)) _WF1(cp15_tpidrurw_set, CP15_TPIDRURW(%0)) @@ -380,7 +361,7 @@ tlb_flush_range_local(vm_offset_t va, vm_size_t size) } /* Broadcasting operations. */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) static __inline void tlb_flush_all(void) @@ -442,14 +423,14 @@ tlb_flush_range(vm_offset_t va, vm_size_t size) ); dsb(); } -#else /* __ARM_ARCH < 7 */ +#else /* !SMP */ #define tlb_flush_all() tlb_flush_all_local() #define tlb_flush_all_ng() tlb_flush_all_ng_local() #define tlb_flush(va) tlb_flush_local(va) #define tlb_flush_range(va, size) tlb_flush_range_local(va, size) -#endif /* __ARM_ARCH < 7 */ +#endif /* !SMP */ /* * Cache maintenance operations. @@ -465,11 +446,7 @@ icache_sync(vm_offset_t va, vm_size_t size) va &= ~cpuinfo.dcache_line_mask; for ( ; va < eva; va += cpuinfo.dcache_line_size) { -#if __ARM_ARCH >= 7 _CP15_DCCMVAU(va); -#else - _CP15_DCCMVAC(va); -#endif } dsb(); ARM_SMP_UP( @@ -515,11 +492,7 @@ dcache_wb_pou(vm_offset_t va, vm_size_t size) dsb(); va &= ~cpuinfo.dcache_line_mask; for ( ; va < eva; va += cpuinfo.dcache_line_size) { -#if __ARM_ARCH >= 7 _CP15_DCCMVAU(va); -#else - _CP15_DCCMVAC(va); -#endif } dsb(); } @@ -686,8 +659,7 @@ cp15_ats1cuw_check(vm_offset_t addr) static __inline uint64_t get_cyclecount(void) { -#if __ARM_ARCH > 6 || (__ARM_ARCH == 6 && defined(CPU_ARM1176)) -#if (__ARM_ARCH > 6) && defined(DEV_PMU) +#if defined(DEV_PMU) if (pmu_attched) { u_int cpu; uint64_t h, h2; @@ -711,12 +683,6 @@ get_cyclecount(void) } else #endif return cp15_pmccntr_get(); -#else /* No performance counters, so use nanotime(9). */ - struct timespec tv; - - nanotime(&tv); - return (tv.tv_sec * (uint64_t)1000000000ull + tv.tv_nsec); -#endif } #endif @@ -729,7 +695,7 @@ get_cyclecount(void) #define cpu_spinwait() /* nothing */ #define cpu_lock_delay() DELAY(1) -#define ARM_NVEC 8 +#define ARM_NVEC 7 #define ARM_VEC_ALL 0xffffffff extern vm_offset_t vector_page; diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h b/lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h index 0f3b1a139be94c1c0082d4c9ac3acc7c02ef4bee..95bcd2b27b0da189e186bbd725ef5d84301c19a9 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/cpufunc.h @@ -97,9 +97,6 @@ void armv7_cpu_sleep (int); void pj4b_config (void); #endif -#if defined(CPU_ARM1176) -void arm11x6_sleep (int); /* no ref. for errata */ -#endif /* diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/endian.h b/lib/libc/include/arm-freebsd-eabihf/machine/endian.h index cbcfa2d885791438e961d1bf84257c71aee66a74..dac6e2b4c2c75b0e8460a089fbf5a21e4c0a6917 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/endian.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/endian.h @@ -26,8 +26,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)endian.h 8.1 (Berkeley) 6/10/93 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $ */ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/exec.h b/lib/libc/include/arm-freebsd-eabihf/machine/exec.h new file mode 100644 index 0000000000000000000000000000000000000000..8a2c6bd93612eab956558a8e7d56c3243c4edf7a --- /dev/null +++ b/lib/libc/include/arm-freebsd-eabihf/machine/exec.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2001 David E. O'Brien + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ + +#define __LDPGSZ 4096 + +#endif /* !_MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/fiq.h b/lib/libc/include/arm-freebsd-eabihf/machine/fiq.h deleted file mode 100644 index 13d84d5ba350799e085f37048e635d136f0544be..0000000000000000000000000000000000000000 --- a/lib/libc/include/arm-freebsd-eabihf/machine/fiq.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: fiq.h,v 1.1 2001/12/20 01:20:23 thorpej Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Jason R. Thorpe for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef _MACHINE_FIQ_H_ -#define _MACHINE_FIQ_H_ - -#include - -struct fiqregs { - u_int fr_r8; /* FIQ mode r8 */ - u_int fr_r9; /* FIQ mode r9 */ - u_int fr_r10; /* FIQ mode r10 */ - u_int fr_r11; /* FIQ mode r11 */ - u_int fr_r12; /* FIQ mode r12 */ - u_int fr_r13; /* FIQ mode r13 */ -}; - -struct fiqhandler { - TAILQ_ENTRY(fiqhandler) fh_list;/* link in the FIQ handler stack */ - void *fh_func; /* FIQ handler routine */ - size_t fh_size; /* size of FIQ handler */ - int fh_flags; /* flags; see below */ - struct fiqregs *fh_regs; /* pointer to regs structure */ -}; - -#define FH_CANPUSH 0x01 /* can push this handler out of the way */ - -int fiq_claim(struct fiqhandler *); -void fiq_release(struct fiqhandler *); - -void fiq_getregs(struct fiqregs *); -void fiq_setregs(struct fiqregs *); - -#endif /* _MACHINE_FIQ_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/float.h b/lib/libc/include/arm-freebsd-eabihf/machine/float.h index 8f8a41e8562d266052d13b8758aaf49dbb3eab3a..b0ab1592b2ad5e4c455bd10be0937b8f0363afc3 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/float.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/float.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h b/lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h index 428967247163bb8e075b97d4925f2b9bf107f097..bd3020282afc0ddd0e557c0364c1d86752572015 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/floatingpoint.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 */ #ifndef _FLOATINGPOINT_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/ieee.h b/lib/libc/include/arm-freebsd-eabihf/machine/ieee.h index 446908cdbe4d23dd698755c3205b669f37c63193..20658d1763967f2b8dd3ad9eddf40045a76d0bc3 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/ieee.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/ieee.h @@ -39,8 +39,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ieee.h 8.1 (Berkeley) 6/11/93 - * */ /* diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h b/lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h index f3ef2992bc3bb958ee3ce0893619b1ae7d6ba02d..417517432cf5ede516d892c610415fa71808332a 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/ieeefp.h @@ -49,4 +49,14 @@ typedef enum { #define fp_except_t int +/* Augment the userland declarations. */ +__BEGIN_DECLS +extern fp_rnd_t fpgetround(void); +extern fp_rnd_t fpsetround(fp_rnd_t); +extern fp_except_t fpgetmask(void); +extern fp_except_t fpsetmask(fp_except_t); +extern fp_except_t fpgetsticky(void); +extern fp_except_t fpsetsticky(fp_except_t); +__END_DECLS + #endif /* _MACHINE_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/in_cksum.h b/lib/libc/include/arm-freebsd-eabihf/machine/in_cksum.h index 7adfb5d1d6b92a75997fea805acd41e6d73c32cd..86ee82e582c5c47e41ab6cd033bd5aed372ca115 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/in_cksum.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/in_cksum.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp */ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/intr.h b/lib/libc/include/arm-freebsd-eabihf/machine/intr.h index bca24ce483f40722142f45c4e38fd352794199d3..65fca3b5e6e17b6ffe0ed587aba414e3cb2e50c1 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/intr.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/intr.h @@ -39,16 +39,19 @@ #ifndef _MACHINE_INTR_H_ #define _MACHINE_INTR_H_ +#ifndef LOCORE #ifdef FDT #include #endif +void arm_irq_memory_barrier(uintptr_t); +#endif /* !LOCORE */ + #ifndef NIRQ #define NIRQ 1024 /* XXX - It should be an option. */ #endif -#include - -void arm_irq_memory_barrier(uintptr_t); +#define INTR_ROOT_IRQ 0 +#define INTR_ROOT_COUNT 1 #endif /* _MACHINE_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/machdep.h b/lib/libc/include/arm-freebsd-eabihf/machine/machdep.h index d6260277bb3f7bc0198196487691a6f9d8de1e9e..3cab2935895e48837b3e5d50b490d15d184b5073 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/machdep.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/machdep.h @@ -51,6 +51,13 @@ void arm_add_efi_map_entries(struct efi_map_header *efihdr, struct mem_region *mr, int *mrcnt); #endif +#ifdef SOCDEV_PA +/* + * The virtual address SOCDEV_PA is mapped at. + */ +extern uintptr_t socdev_va; +#endif + /* * Symbols created by ldscript.arm which are accessible in the kernel as global * symbols. They have uint8 type because they mark the byte location where the diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/metadata.h b/lib/libc/include/arm-freebsd-eabihf/machine/metadata.h index 3708e09f6f666ed45021091420b60dcf5d2d02cc..722ef7c3fd41fb52b9136da3183da22e5daaf00c 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/metadata.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/metadata.h @@ -33,10 +33,15 @@ #define MODINFOMD_DTBP 0x1002 #define MODINFOMD_EFI_MAP 0x1003 +/* + * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though + * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table + * starting at a 16-byte alignment. + */ struct efi_map_header { - uint64_t memory_size; - uint64_t descriptor_size; - uint32_t descriptor_version; + uint64_t memory_size; /* Numnber of bytes that follow */ + uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */ + uint32_t descriptor_version; /* Currently '1' */ }; /* diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/param.h b/lib/libc/include/arm-freebsd-eabihf/machine/param.h index edab4a72b46fbcf10753ac01d44055ca62bef11a..6fab13f3955c2531bc990470d532b2484bad6516 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/param.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/param.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _ARM_INCLUDE_PARAM_H_ @@ -51,17 +49,11 @@ #define STACKALIGNBYTES (8 - 1) #define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES) -#define __PCI_REROUTE_INTERRUPT - #ifndef MACHINE #define MACHINE "arm" #endif #ifndef MACHINE_ARCH -#if __ARM_ARCH >= 7 #define MACHINE_ARCH "armv7" -#else -#define MACHINE_ARCH "armv6" -#endif #endif #ifdef SMP @@ -76,6 +68,8 @@ #define MAXMEMDOM 1 #endif +#define __HAVE_STATIC_DEVMAP + #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) /* @@ -129,17 +123,10 @@ /* * Mach derived conversion macros */ -#define trunc_page(x) ((x) & ~PAGE_MASK) -#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) #define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK) #define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) -#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) - #define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT) #define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT) -#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) - #endif /* !_ARM_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/pmap.h b/lib/libc/include/arm-freebsd-eabihf/machine/pmap.h index 78b6e5b2c14820fb55bba7abd7bd5e1927f0f100..3b18349d881383f7727d1c2800b43c7b6b0f5f15 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/pmap.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/pmap.h @@ -39,9 +39,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 */ @@ -138,9 +135,9 @@ extern ttb_entry_t pmap_kern_ttb; /* TTB for kernel pmap */ * vtopte2(). */ void pmap_bootstrap(vm_offset_t); -void pmap_kenter(vm_offset_t, vm_paddr_t); +void pmap_kenter(vm_offset_t, vm_size_t, vm_paddr_t, int); void pmap_kremove(vm_offset_t); -boolean_t pmap_page_is_mapped(vm_page_t); +bool pmap_page_is_mapped(vm_page_t); bool pmap_ps_enabled(pmap_t pmap); void pmap_tlb_flush(pmap_t, vm_offset_t); @@ -175,15 +172,9 @@ void pmap_page_set_memattr(vm_page_t, vm_memattr_t); #define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva) void *pmap_mapdev(vm_paddr_t, vm_size_t); +void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t); void pmap_unmapdev(void *, vm_size_t); -static inline void * -pmap_mapdev_attr(vm_paddr_t addr __unused, vm_size_t size __unused, - int attr __unused) -{ - panic("%s is not implemented yet!\n", __func__); -} - struct pcb; void pmap_set_pcb_pagedir(pmap_t, struct pcb *); diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/pmap_var.h b/lib/libc/include/arm-freebsd-eabihf/machine/pmap_var.h index ad0a787981a91020ff9ca74af0d95f50df44a356..1a213f868c278f62722560b80c2adf0b03f3077a 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/pmap_var.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/pmap_var.h @@ -161,7 +161,7 @@ pte1_clear_bit(pt1_entry_t *pte1p, uint32_t bit) pte1_sync(pte1p); } -static __inline boolean_t +static __inline bool pte1_is_link(pt1_entry_t pte1) { @@ -175,21 +175,21 @@ pte1_is_section(pt1_entry_t pte1) return ((pte1 & L1_TYPE_MASK) == L1_TYPE_S); } -static __inline boolean_t +static __inline bool pte1_is_dirty(pt1_entry_t pte1) { return ((pte1 & (PTE1_NM | PTE1_RO)) == 0); } -static __inline boolean_t +static __inline bool pte1_is_global(pt1_entry_t pte1) { return ((pte1 & PTE1_NG) == 0); } -static __inline boolean_t +static __inline bool pte1_is_valid(pt1_entry_t pte1) { int l1_type; @@ -198,7 +198,7 @@ pte1_is_valid(pt1_entry_t pte1) return ((l1_type == L1_TYPE_C) || (l1_type == L1_TYPE_S)); } -static __inline boolean_t +static __inline bool pte1_is_wired(pt1_entry_t pte1) { @@ -301,28 +301,28 @@ pte2_clear_bit(pt2_entry_t *pte2p, uint32_t bit) pte2_sync(pte2p); } -static __inline boolean_t +static __inline bool pte2_is_dirty(pt2_entry_t pte2) { return ((pte2 & (PTE2_NM | PTE2_RO)) == 0); } -static __inline boolean_t +static __inline bool pte2_is_global(pt2_entry_t pte2) { return ((pte2 & PTE2_NG) == 0); } -static __inline boolean_t +static __inline bool pte2_is_valid(pt2_entry_t pte2) { return (pte2 & PTE2_V); } -static __inline boolean_t +static __inline bool pte2_is_wired(pt2_entry_t pte2) { @@ -358,7 +358,7 @@ pte2_set_bit(pt2_entry_t *pte2p, uint32_t bit) } static __inline void -pte2_set_wired(pt2_entry_t *pte2p, boolean_t wired) +pte2_set_wired(pt2_entry_t *pte2p, bool wired) { /* diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/proc.h b/lib/libc/include/arm-freebsd-eabihf/machine/proc.h index b37f5a690ecdccf4ce08016d4a540443b6dc6532..a142642becf5b36fbb2ee8a0db6084c262db3699 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/proc.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/proc.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 */ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/profile.h b/lib/libc/include/arm-freebsd-eabihf/machine/profile.h index 6154b6b662863e09d51e30695d89ed821568f438..83f743ca16cfaf99f4f1b3e93d7a19a7a57cf723 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/profile.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/profile.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_PROFILE_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/reloc.h b/lib/libc/include/arm-freebsd-eabihf/machine/reloc.h index 9a7855cbeeda86d88bf011e9719fda225eb87101..f318d27664e39c84712f8ee23bbb601e405619f0 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/reloc.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/reloc.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)reloc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _MACHINE_RELOC_H_ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/resource.h b/lib/libc/include/arm-freebsd-eabihf/machine/resource.h index 8edfc1ab1ea31fb4f509c044e40b8fd29b4e9a6d..c22c873f6b011a3382b8a58020fe7e6c93c43788 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/resource.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/resource.h @@ -40,8 +40,6 @@ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ #define SYS_RES_GPIO 5 /* general purpose i/o */ -#ifdef NEW_PCIB #define PCI_RES_BUS 6 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/runq.h b/lib/libc/include/arm-freebsd-eabihf/machine/runq.h deleted file mode 100644 index 63b30d582a975d12398ac7d6df338e6f19996202..0000000000000000000000000000000000000000 --- a/lib/libc/include/arm-freebsd-eabihf/machine/runq.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (2) /* Number of priority status words. */ -#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (ffs(word) - 1) - -/* - * Type of run queue status word. - */ -typedef u_int32_t rqb_word_t; - -#endif \ No newline at end of file diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/signal.h b/lib/libc/include/arm-freebsd-eabihf/machine/signal.h index d81c04382e06b8ab59e503c98b4fde5cb99a259e..df41f25faac956746109b3dc9874d551cbb8797f 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/signal.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/signal.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17 */ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h b/lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h index 4a37651d15dd44134c800eb01c9ab477133559c1..4536de8ecb208eb4695f8f3e9aeb2383c3fc6eb8 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/sysarch.h @@ -38,6 +38,8 @@ #ifndef _ARM_SYSARCH_H_ #define _ARM_SYSARCH_H_ +#include + #include #ifndef LOCORE diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h b/lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h index d83305a478d43234d11847d2d4477775f0b424e1..ce88a0a4b92e9268bad84204a7e5c1ef7ddeaabe 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/sysreg.h @@ -127,11 +127,9 @@ /* From ARMv6: */ #define CP15_IFSR(rr) p15, 0, rr, c5, c0, 1 /* Instruction Fault Status Register */ -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_ADFSR(rr) p15, 0, rr, c5, c1, 0 /* Auxiliary Data Fault Status Register */ #define CP15_AIFSR(rr) p15, 0, rr, c5, c1, 1 /* Auxiliary Instruction Fault Status Register */ -#endif /* * CP15 C6 registers @@ -147,7 +145,7 @@ /* * CP15 C7 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) /* From ARMv7: */ #define CP15_ICIALLUIS p15, 0, r0, c7, c1, 0 /* Instruction cache invalidate all PoU, IS */ #define CP15_BPIALLIS p15, 0, r0, c7, c1, 6 /* Branch predictor invalidate all IS */ @@ -157,17 +155,9 @@ #define CP15_ICIALLU p15, 0, r0, c7, c5, 0 /* Instruction cache invalidate all PoU */ #define CP15_ICIMVAU(rr) p15, 0, rr, c7, c5, 1 /* Instruction cache invalidate */ -#if __ARM_ARCH == 6 -/* Deprecated in ARMv7 */ -#define CP15_CP15ISB p15, 0, r0, c7, c5, 4 /* ISB */ -#endif #define CP15_BPIALL p15, 0, r0, c7, c5, 6 /* Branch predictor invalidate all */ #define CP15_BPIMVA p15, 0, rr, c7, c5, 7 /* Branch predictor invalidate by MVA */ -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCIALL p15, 0, r0, c7, c6, 0 /* Data cache invalidate all */ -#endif #define CP15_DCIMVAC(rr) p15, 0, rr, c7, c6, 1 /* Data cache invalidate by MVA PoC */ #define CP15_DCISW(rr) p15, 0, rr, c7, c6, 2 /* Data cache invalidate by set/way */ @@ -176,43 +166,25 @@ #define CP15_ATS1CUR(rr) p15, 0, rr, c7, c8, 2 /* Stage 1 Current state unprivileged read */ #define CP15_ATS1CUW(rr) p15, 0, rr, c7, c8, 3 /* Stage 1 Current state unprivileged write */ -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_ATS12NSOPR(rr) p15, 0, rr, c7, c8, 4 /* Stages 1 and 2 Non-secure only PL1 read */ #define CP15_ATS12NSOPW(rr) p15, 0, rr, c7, c8, 5 /* Stages 1 and 2 Non-secure only PL1 write */ #define CP15_ATS12NSOUR(rr) p15, 0, rr, c7, c8, 6 /* Stages 1 and 2 Non-secure only unprivileged read */ #define CP15_ATS12NSOUW(rr) p15, 0, rr, c7, c8, 7 /* Stages 1 and 2 Non-secure only unprivileged write */ -#endif -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCCALL p15, 0, r0, c7, c10, 0 /* Data cache clean all */ -#endif #define CP15_DCCMVAC(rr) p15, 0, rr, c7, c10, 1 /* Data cache clean by MVA PoC */ #define CP15_DCCSW(rr) p15, 0, rr, c7, c10, 2 /* Data cache clean by set/way */ -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_CP15DSB p15, 0, r0, c7, c10, 4 /* DSB */ -#define CP15_CP15DMB p15, 0, r0, c7, c10, 5 /* DMB */ -#define CP15_CP15WFI p15, 0, r0, c7, c0, 4 /* WFI */ -#endif -#if __ARM_ARCH >= 7 /* From ARMv7: */ #define CP15_DCCMVAU(rr) p15, 0, rr, c7, c11, 1 /* Data cache clean by MVA PoU */ -#endif -#if __ARM_ARCH == 6 -/* Only ARMv6: */ -#define CP15_DCCIALL p15, 0, r0, c7, c14, 0 /* Data cache clean and invalidate all */ -#endif #define CP15_DCCIMVAC(rr) p15, 0, rr, c7, c14, 1 /* Data cache clean and invalidate by MVA PoC */ #define CP15_DCCISW(rr) p15, 0, rr, c7, c14, 2 /* Data cache clean and invalidate by set/way */ /* * CP15 C8 registers */ -#if __ARM_ARCH >= 7 && defined(SMP) +#if defined(SMP) /* From ARMv7: */ #define CP15_TLBIALLIS p15, 0, r0, c8, c3, 0 /* Invalidate entire unified TLB IS */ #define CP15_TLBIMVAIS(rr) p15, 0, rr, c8, c3, 1 /* Invalidate unified TLB by MVA IS */ @@ -232,11 +204,6 @@ /* * CP15 C9 registers */ -#if __ARM_ARCH == 6 && defined(CPU_ARM1176) -#define CP15_PMUSERENR(rr) p15, 0, rr, c15, c9, 0 /* Access Validation Control Register */ -#define CP15_PMCR(rr) p15, 0, rr, c15, c12, 0 /* Performance Monitor Control Register */ -#define CP15_PMCCNTR(rr) p15, 0, rr, c15, c12, 1 /* PM Cycle Count Register */ -#else #define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */ #define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */ #define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */ @@ -250,7 +217,6 @@ #define CP15_PMUSERENR(rr) p15, 0, rr, c9, c14, 0 /* PM User Enable Register */ #define CP15_PMINTENSET(rr) p15, 0, rr, c9, c14, 1 /* PM Interrupt Enable Set Register */ #define CP15_PMINTENCLR(rr) p15, 0, rr, c9, c14, 2 /* PM Interrupt Enable Clear Register */ -#endif /* * CP15 C10 registers diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/vm.h b/lib/libc/include/arm-freebsd-eabihf/machine/vm.h index df7052a08faa5a5bde4d73798dc5ca08798316e5..14c1200125211fbfebe5ac82d4636125254f249e 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/vm.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/vm.h @@ -36,7 +36,7 @@ #define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)4) #define VM_MEMATTR_DEFAULT VM_MEMATTR_WB_WA -#define VM_MEMATTR_UNCACHEABLE VM_MEMATTR_SO /* misused by DMA */ +#define VM_MEMATTR_UNCACHEABLE VM_MEMATTR_NOCACHE /* used by BUSDMA */ #ifdef _KERNEL /* Don't export aliased VM_MEMATTR to userland */ #define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH /* for DRM */ diff --git a/lib/libc/include/arm-freebsd-eabihf/machine/vmparam.h b/lib/libc/include/arm-freebsd-eabihf/machine/vmparam.h index e5b6b491f701a9dc9600d5d100b1a420b8a6c9e0..92285fcfdc2546a6bedbb107f46ac97b9bb0614a 100644 --- a/lib/libc/include/arm-freebsd-eabihf/machine/vmparam.h +++ b/lib/libc/include/arm-freebsd-eabihf/machine/vmparam.h @@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address; * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 0 #endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/_ctype.h b/lib/libc/include/generic-freebsd/_ctype.h index c7142800d85e39bf0eff6b346b8bcb416e96011e..478eebd89ae0c0d23d7453f28d27e21dcc9c2c3e 100644 --- a/lib/libc/include/generic-freebsd/_ctype.h +++ b/lib/libc/include/generic-freebsd/_ctype.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From @(#)ctype.h 8.4 (Berkeley) 1/21/94 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp */ diff --git a/lib/libc/include/generic-freebsd/_libsys.h b/lib/libc/include/generic-freebsd/_libsys.h new file mode 100644 index 0000000000000000000000000000000000000000..1183efab7f20b05f8180a2dca310af37b7394f18 --- /dev/null +++ b/lib/libc/include/generic-freebsd/_libsys.h @@ -0,0 +1,881 @@ +/* + * Public system call stubs provided by libsys. + * + * Do not use directly, include instead. + * + * DO NOT EDIT-- this file is automatically @generated. + */ + +#ifndef __LIBSYS_H_ +#define __LIBSYS_H_ + +#include +#include +#include +#include +#include +#include /* for mcontext_t */ +#include +#include + +struct __siginfo; +struct __ucontext; +struct __wrusage; +struct acl; +struct aiocb; +struct auditinfo; +struct auditinfo_addr; +struct ffclock_estimate; +struct fhandle; +struct iovec; +struct itimerspec; +struct itimerval; +struct jail; +struct kevent; +struct kld_file_stat; +struct mac; +struct module_stat; +struct mq_attr; +struct msghdr; +struct msqid_ds; +struct ntptimeval; +struct pollfd; +struct rlimit; +struct rtprio; +struct rusage; +struct sched_param; +struct sctp_sndrcvinfo; +struct sembuf; +struct setcred; +struct sf_hdtr; +struct shmid_ds; +struct sigaction; +struct sigaltstack; +struct sigevent; +struct sockaddr; +struct spacectl_range; +struct stat; +struct statfs; +struct thr_param; +struct timespec; +struct timeval; +struct timex; +struct timezone; +struct uuid; +union semun; + +__BEGIN_DECLS +typedef void (__sys__exit_t)(int); +typedef int (__sys_fork_t)(void); +typedef ssize_t (__sys_read_t)(int, void *, size_t); +typedef ssize_t (__sys_write_t)(int, const void *, size_t); +typedef int (__sys_open_t)(const char *, int, mode_t); +typedef int (__sys_close_t)(int); +typedef int (__sys_wait4_t)(int, int *, int, struct rusage *); +typedef int (__sys_link_t)(const char *, const char *); +typedef int (__sys_unlink_t)(const char *); +typedef int (__sys_chdir_t)(const char *); +typedef int (__sys_fchdir_t)(int); +typedef int (__sys_chmod_t)(const char *, mode_t); +typedef int (__sys_chown_t)(const char *, int, int); +typedef void * (__sys_break_t)(char *); +typedef pid_t (__sys_getpid_t)(void); +typedef int (__sys_mount_t)(const char *, const char *, int, void *); +typedef int (__sys_unmount_t)(const char *, int); +typedef int (__sys_setuid_t)(uid_t); +typedef uid_t (__sys_getuid_t)(void); +typedef uid_t (__sys_geteuid_t)(void); +typedef int (__sys_ptrace_t)(int, pid_t, caddr_t, int); +typedef ssize_t (__sys_recvmsg_t)(int, struct msghdr *, int); +typedef ssize_t (__sys_sendmsg_t)(int, const struct msghdr *, int); +typedef ssize_t (__sys_recvfrom_t)(int, void *, size_t, int, struct sockaddr *, __socklen_t *); +typedef int (__sys_accept_t)(int, struct sockaddr *, __socklen_t *); +typedef int (__sys_getpeername_t)(int, struct sockaddr *, __socklen_t *); +typedef int (__sys_getsockname_t)(int, struct sockaddr *, __socklen_t *); +typedef int (__sys_access_t)(const char *, int); +typedef int (__sys_chflags_t)(const char *, u_long); +typedef int (__sys_fchflags_t)(int, u_long); +typedef int (__sys_sync_t)(void); +typedef int (__sys_kill_t)(int, int); +typedef pid_t (__sys_getppid_t)(void); +typedef int (__sys_dup_t)(u_int); +typedef gid_t (__sys_getegid_t)(void); +typedef int (__sys_profil_t)(char *, size_t, size_t, u_int); +typedef int (__sys_ktrace_t)(const char *, int, int, int); +typedef gid_t (__sys_getgid_t)(void); +typedef int (__sys_getlogin_t)(char *, u_int); +typedef int (__sys_setlogin_t)(const char *); +typedef int (__sys_acct_t)(const char *); +typedef int (__sys_sigaltstack_t)(const struct sigaltstack *, struct sigaltstack *); +typedef int (__sys_ioctl_t)(int, u_long, char *); +typedef int (__sys_reboot_t)(int); +typedef int (__sys_revoke_t)(const char *); +typedef int (__sys_symlink_t)(const char *, const char *); +typedef ssize_t (__sys_readlink_t)(const char *, char *, size_t); +typedef int (__sys_execve_t)(const char *, char **, char **); +typedef mode_t (__sys_umask_t)(mode_t); +typedef int (__sys_chroot_t)(const char *); +typedef int (__sys_msync_t)(void *, size_t, int); +typedef int (__sys_vfork_t)(void); +typedef int (__sys_munmap_t)(void *, size_t); +typedef int (__sys_mprotect_t)(void *, size_t, int); +typedef int (__sys_madvise_t)(void *, size_t, int); +typedef int (__sys_mincore_t)(const void *, size_t, char *); +typedef int (__sys_getpgrp_t)(void); +typedef int (__sys_setpgid_t)(int, int); +typedef int (__sys_setitimer_t)(int, const struct itimerval *, struct itimerval *); +typedef int (__sys_swapon_t)(const char *); +typedef int (__sys_getitimer_t)(int, struct itimerval *); +typedef int (__sys_getdtablesize_t)(void); +typedef int (__sys_dup2_t)(u_int, u_int); +typedef int (__sys_fcntl_t)(int, int, intptr_t); +typedef int (__sys_select_t)(int, fd_set *, fd_set *, fd_set *, struct timeval *); +typedef int (__sys_fsync_t)(int); +typedef int (__sys_setpriority_t)(int, int, int); +typedef int (__sys_socket_t)(int, int, int); +typedef int (__sys_connect_t)(int, const struct sockaddr *, __socklen_t); +typedef int (__sys_getpriority_t)(int, int); +typedef int (__sys_bind_t)(int, const struct sockaddr *, __socklen_t); +typedef int (__sys_setsockopt_t)(int, int, int, const void *, __socklen_t); +typedef int (__sys_listen_t)(int, int); +typedef int (__sys_gettimeofday_t)(struct timeval *, struct timezone *); +typedef int (__sys_getrusage_t)(int, struct rusage *); +typedef int (__sys_getsockopt_t)(int, int, int, void *, __socklen_t *); +typedef ssize_t (__sys_readv_t)(int, const struct iovec *, u_int); +typedef ssize_t (__sys_writev_t)(int, const struct iovec *, u_int); +typedef int (__sys_settimeofday_t)(const struct timeval *, const struct timezone *); +typedef int (__sys_fchown_t)(int, int, int); +typedef int (__sys_fchmod_t)(int, mode_t); +typedef int (__sys_setreuid_t)(int, int); +typedef int (__sys_setregid_t)(int, int); +typedef int (__sys_rename_t)(const char *, const char *); +typedef int (__sys_flock_t)(int, int); +typedef int (__sys_mkfifo_t)(const char *, mode_t); +typedef ssize_t (__sys_sendto_t)(int, const void *, size_t, int, const struct sockaddr *, __socklen_t); +typedef int (__sys_shutdown_t)(int, int); +typedef int (__sys_socketpair_t)(int, int, int, int *); +typedef int (__sys_mkdir_t)(const char *, mode_t); +typedef int (__sys_rmdir_t)(const char *); +typedef int (__sys_utimes_t)(const char *, const struct timeval *); +typedef int (__sys_adjtime_t)(const struct timeval *, struct timeval *); +typedef int (__sys_setsid_t)(void); +typedef int (__sys_quotactl_t)(const char *, int, int, void *); +typedef int (__sys_nlm_syscall_t)(int, int, int, char **); +typedef int (__sys_nfssvc_t)(int, void *); +typedef int (__sys_lgetfh_t)(const char *, struct fhandle *); +typedef int (__sys_getfh_t)(const char *, struct fhandle *); +typedef int (__sys_sysarch_t)(int, char *); +typedef int (__sys_rtprio_t)(int, pid_t, struct rtprio *); +typedef int (__sys_semsys_t)(int, int, int, int, int); +typedef int (__sys_msgsys_t)(int, int, int, int, int, int); +typedef int (__sys_shmsys_t)(int, int, int, int); +typedef int (__sys_setfib_t)(int); +typedef int (__sys_ntp_adjtime_t)(struct timex *); +typedef int (__sys_setgid_t)(gid_t); +typedef int (__sys_setegid_t)(gid_t); +typedef int (__sys_seteuid_t)(uid_t); +typedef int (__sys_pathconf_t)(const char *, int); +typedef int (__sys_fpathconf_t)(int, int); +typedef int (__sys_getrlimit_t)(u_int, struct rlimit *); +typedef int (__sys_setrlimit_t)(u_int, struct rlimit *); +typedef int (__sys___sysctl_t)(const int *, u_int, void *, size_t *, const void *, size_t); +typedef int (__sys_mlock_t)(const void *, size_t); +typedef int (__sys_munlock_t)(const void *, size_t); +typedef int (__sys_undelete_t)(const char *); +typedef int (__sys_futimes_t)(int, const struct timeval *); +typedef int (__sys_getpgid_t)(pid_t); +typedef int (__sys_poll_t)(struct pollfd *, u_int, int); +typedef int (__sys_semget_t)(key_t, int, int); +typedef int (__sys_semop_t)(int, struct sembuf *, size_t); +typedef int (__sys_msgget_t)(key_t, int); +typedef int (__sys_msgsnd_t)(int, const void *, size_t, int); +typedef ssize_t (__sys_msgrcv_t)(int, void *, size_t, long, int); +typedef void * (__sys_shmat_t)(int, const void *, int); +typedef int (__sys_shmdt_t)(const void *); +typedef int (__sys_shmget_t)(key_t, size_t, int); +typedef int (__sys_clock_gettime_t)(clockid_t, struct timespec *); +typedef int (__sys_clock_settime_t)(clockid_t, const struct timespec *); +typedef int (__sys_clock_getres_t)(clockid_t, struct timespec *); +typedef int (__sys_ktimer_create_t)(clockid_t, struct sigevent *, int *); +typedef int (__sys_ktimer_delete_t)(int); +typedef int (__sys_ktimer_settime_t)(int, int, const struct itimerspec *, struct itimerspec *); +typedef int (__sys_ktimer_gettime_t)(int, struct itimerspec *); +typedef int (__sys_ktimer_getoverrun_t)(int); +typedef int (__sys_nanosleep_t)(const struct timespec *, struct timespec *); +typedef int (__sys_ffclock_getcounter_t)(ffcounter *); +typedef int (__sys_ffclock_setestimate_t)(struct ffclock_estimate *); +typedef int (__sys_ffclock_getestimate_t)(struct ffclock_estimate *); +typedef int (__sys_clock_nanosleep_t)(clockid_t, int, const struct timespec *, struct timespec *); +typedef int (__sys_clock_getcpuclockid2_t)(id_t, int, clockid_t *); +typedef int (__sys_ntp_gettime_t)(struct ntptimeval *); +typedef int (__sys_minherit_t)(void *, size_t, int); +typedef int (__sys_rfork_t)(int); +typedef int (__sys_issetugid_t)(void); +typedef int (__sys_lchown_t)(const char *, int, int); +typedef int (__sys_aio_read_t)(struct aiocb *); +typedef int (__sys_aio_write_t)(struct aiocb *); +typedef int (__sys_lio_listio_t)(int, struct aiocb * const *, int, struct sigevent *); +typedef int (__sys_lchmod_t)(const char *, mode_t); +typedef int (__sys_lutimes_t)(const char *, const struct timeval *); +typedef ssize_t (__sys_preadv_t)(int, struct iovec *, u_int, off_t); +typedef ssize_t (__sys_pwritev_t)(int, struct iovec *, u_int, off_t); +typedef int (__sys_fhopen_t)(const struct fhandle *, int); +typedef int (__sys_modnext_t)(int); +typedef int (__sys_modstat_t)(int, struct module_stat *); +typedef int (__sys_modfnext_t)(int); +typedef int (__sys_modfind_t)(const char *); +typedef int (__sys_kldload_t)(const char *); +typedef int (__sys_kldunload_t)(int); +typedef int (__sys_kldfind_t)(const char *); +typedef int (__sys_kldnext_t)(int); +typedef int (__sys_kldstat_t)(int, struct kld_file_stat *); +typedef int (__sys_kldfirstmod_t)(int); +typedef int (__sys_getsid_t)(pid_t); +typedef int (__sys_setresuid_t)(uid_t, uid_t, uid_t); +typedef int (__sys_setresgid_t)(gid_t, gid_t, gid_t); +typedef ssize_t (__sys_aio_return_t)(struct aiocb *); +typedef int (__sys_aio_suspend_t)(const struct aiocb * const *, int, const struct timespec *); +typedef int (__sys_aio_cancel_t)(int, struct aiocb *); +typedef int (__sys_aio_error_t)(struct aiocb *); +typedef int (__sys_mlockall_t)(int); +typedef int (__sys_munlockall_t)(void); +typedef int (__sys___getcwd_t)(char *, size_t); +typedef int (__sys_sched_setparam_t)(pid_t, const struct sched_param *); +typedef int (__sys_sched_getparam_t)(pid_t, struct sched_param *); +typedef int (__sys_sched_setscheduler_t)(pid_t, int, const struct sched_param *); +typedef int (__sys_sched_getscheduler_t)(pid_t); +typedef int (__sys_sched_yield_t)(void); +typedef int (__sys_sched_get_priority_max_t)(int); +typedef int (__sys_sched_get_priority_min_t)(int); +typedef int (__sys_sched_rr_get_interval_t)(pid_t, struct timespec *); +typedef int (__sys_utrace_t)(const void *, size_t); +typedef int (__sys_kldsym_t)(int, int, void *); +typedef int (__sys_jail_t)(struct jail *); +typedef int (__sys_nnpfs_syscall_t)(int, char *, int, void *, int); +typedef int (__sys_sigprocmask_t)(int, const sigset_t *, sigset_t *); +typedef int (__sys_sigsuspend_t)(const sigset_t *); +typedef int (__sys_sigpending_t)(sigset_t *); +typedef int (__sys_sigtimedwait_t)(const sigset_t *, struct __siginfo *, const struct timespec *); +typedef int (__sys_sigwaitinfo_t)(const sigset_t *, struct __siginfo *); +typedef int (__sys___acl_get_file_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys___acl_set_file_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys___acl_get_fd_t)(int, __acl_type_t, struct acl *); +typedef int (__sys___acl_set_fd_t)(int, __acl_type_t, struct acl *); +typedef int (__sys___acl_delete_file_t)(const char *, __acl_type_t); +typedef int (__sys___acl_delete_fd_t)(int, __acl_type_t); +typedef int (__sys___acl_aclcheck_file_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys___acl_aclcheck_fd_t)(int, __acl_type_t, struct acl *); +typedef int (__sys_extattrctl_t)(const char *, int, const char *, int, const char *); +typedef ssize_t (__sys_extattr_set_file_t)(const char *, int, const char *, void *, size_t); +typedef ssize_t (__sys_extattr_get_file_t)(const char *, int, const char *, void *, size_t); +typedef int (__sys_extattr_delete_file_t)(const char *, int, const char *); +typedef ssize_t (__sys_aio_waitcomplete_t)(struct aiocb **, struct timespec *); +typedef int (__sys_getresuid_t)(uid_t *, uid_t *, uid_t *); +typedef int (__sys_getresgid_t)(gid_t *, gid_t *, gid_t *); +typedef int (__sys_kqueue_t)(void); +typedef ssize_t (__sys_extattr_set_fd_t)(int, int, const char *, void *, size_t); +typedef ssize_t (__sys_extattr_get_fd_t)(int, int, const char *, void *, size_t); +typedef int (__sys_extattr_delete_fd_t)(int, int, const char *); +typedef int (__sys___setugid_t)(int); +typedef int (__sys_eaccess_t)(const char *, int); +typedef int (__sys_afs3_syscall_t)(long, long, long, long, long, long, long); +typedef int (__sys_nmount_t)(struct iovec *, unsigned int, int); +typedef int (__sys___mac_get_proc_t)(struct mac *); +typedef int (__sys___mac_set_proc_t)(struct mac *); +typedef int (__sys___mac_get_fd_t)(int, struct mac *); +typedef int (__sys___mac_get_file_t)(const char *, struct mac *); +typedef int (__sys___mac_set_fd_t)(int, struct mac *); +typedef int (__sys___mac_set_file_t)(const char *, struct mac *); +typedef int (__sys_kenv_t)(int, const char *, char *, int); +typedef int (__sys_lchflags_t)(const char *, u_long); +typedef int (__sys_uuidgen_t)(struct uuid *, int); +typedef int (__sys_sendfile_t)(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); +typedef int (__sys_mac_syscall_t)(const char *, int, void *); +typedef int (__sys_ksem_close_t)(semid_t); +typedef int (__sys_ksem_post_t)(semid_t); +typedef int (__sys_ksem_wait_t)(semid_t); +typedef int (__sys_ksem_trywait_t)(semid_t); +typedef int (__sys_ksem_init_t)(semid_t *, unsigned int); +typedef int (__sys_ksem_open_t)(semid_t *, const char *, int, mode_t, unsigned int); +typedef int (__sys_ksem_unlink_t)(const char *); +typedef int (__sys_ksem_getvalue_t)(semid_t, int *); +typedef int (__sys_ksem_destroy_t)(semid_t); +typedef int (__sys___mac_get_pid_t)(pid_t, struct mac *); +typedef int (__sys___mac_get_link_t)(const char *, struct mac *); +typedef int (__sys___mac_set_link_t)(const char *, struct mac *); +typedef ssize_t (__sys_extattr_set_link_t)(const char *, int, const char *, void *, size_t); +typedef ssize_t (__sys_extattr_get_link_t)(const char *, int, const char *, void *, size_t); +typedef int (__sys_extattr_delete_link_t)(const char *, int, const char *); +typedef int (__sys___mac_execve_t)(const char *, char **, char **, struct mac *); +typedef int (__sys_sigaction_t)(int, const struct sigaction *, struct sigaction *); +typedef int (__sys_sigreturn_t)(const struct __ucontext *); +typedef int (__sys_getcontext_t)(struct __ucontext *); +typedef int (__sys_setcontext_t)(const struct __ucontext *); +typedef int (__sys_swapcontext_t)(struct __ucontext *, const struct __ucontext *); +typedef int (__sys___acl_get_link_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys___acl_set_link_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys___acl_delete_link_t)(const char *, __acl_type_t); +typedef int (__sys___acl_aclcheck_link_t)(const char *, __acl_type_t, struct acl *); +typedef int (__sys_sigwait_t)(const sigset_t *, int *); +typedef int (__sys_thr_create_t)(ucontext_t *, long *, int); +typedef void (__sys_thr_exit_t)(long *); +typedef int (__sys_thr_self_t)(long *); +typedef int (__sys_thr_kill_t)(long, int); +typedef int (__sys_jail_attach_t)(int); +typedef ssize_t (__sys_extattr_list_fd_t)(int, int, void *, size_t); +typedef ssize_t (__sys_extattr_list_file_t)(const char *, int, void *, size_t); +typedef ssize_t (__sys_extattr_list_link_t)(const char *, int, void *, size_t); +typedef int (__sys_ksem_timedwait_t)(semid_t, const struct timespec *); +typedef int (__sys_thr_suspend_t)(const struct timespec *); +typedef int (__sys_thr_wake_t)(long); +typedef int (__sys_kldunloadf_t)(int, int); +typedef int (__sys_audit_t)(const void *, u_int); +typedef int (__sys_auditon_t)(int, void *, u_int); +typedef int (__sys_getauid_t)(uid_t *); +typedef int (__sys_setauid_t)(uid_t *); +typedef int (__sys_getaudit_t)(struct auditinfo *); +typedef int (__sys_setaudit_t)(struct auditinfo *); +typedef int (__sys_getaudit_addr_t)(struct auditinfo_addr *, u_int); +typedef int (__sys_setaudit_addr_t)(struct auditinfo_addr *, u_int); +typedef int (__sys_auditctl_t)(const char *); +typedef int (__sys__umtx_op_t)(void *, int, u_long, void *, void *); +typedef int (__sys_thr_new_t)(struct thr_param *, int); +typedef int (__sys_sigqueue_t)(pid_t, int, void *); +typedef int (__sys_kmq_open_t)(const char *, int, mode_t, const struct mq_attr *); +typedef int (__sys_kmq_setattr_t)(int, const struct mq_attr *, struct mq_attr *); +typedef int (__sys_kmq_timedreceive_t)(int, char *, size_t, unsigned *, const struct timespec *); +typedef int (__sys_kmq_timedsend_t)(int, const char *, size_t, unsigned, const struct timespec *); +typedef int (__sys_kmq_notify_t)(int, const struct sigevent *); +typedef int (__sys_kmq_unlink_t)(const char *); +typedef void (__sys_abort2_t)(const char *, int, void **); +typedef int (__sys_thr_set_name_t)(long, const char *); +typedef int (__sys_aio_fsync_t)(int, struct aiocb *); +typedef int (__sys_rtprio_thread_t)(int, lwpid_t, struct rtprio *); +typedef int (__sys_sctp_peeloff_t)(int, uint32_t); +typedef int (__sys_sctp_generic_sendmsg_t)(int, void *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int); +typedef int (__sys_sctp_generic_sendmsg_iov_t)(int, struct iovec *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int); +typedef int (__sys_sctp_generic_recvmsg_t)(int, struct iovec *, int, struct sockaddr *, __socklen_t *, struct sctp_sndrcvinfo *, int *); +typedef ssize_t (__sys_pread_t)(int, void *, size_t, off_t); +typedef ssize_t (__sys_pwrite_t)(int, const void *, size_t, off_t); +typedef void * (__sys_mmap_t)(void *, size_t, int, int, int, off_t); +typedef off_t (__sys_lseek_t)(int, off_t, int); +typedef int (__sys_truncate_t)(const char *, off_t); +typedef int (__sys_ftruncate_t)(int, off_t); +typedef int (__sys_thr_kill2_t)(pid_t, long, int); +typedef int (__sys_shm_unlink_t)(const char *); +typedef int (__sys_cpuset_t)(cpusetid_t *); +typedef int (__sys_cpuset_setid_t)(cpuwhich_t, id_t, cpusetid_t); +typedef int (__sys_cpuset_getid_t)(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *); +typedef int (__sys_cpuset_getaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *); +typedef int (__sys_cpuset_setaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *); +typedef int (__sys_faccessat_t)(int, const char *, int, int); +typedef int (__sys_fchmodat_t)(int, const char *, mode_t, int); +typedef int (__sys_fchownat_t)(int, const char *, uid_t, gid_t, int); +typedef int (__sys_fexecve_t)(int, char **, char **); +typedef int (__sys_futimesat_t)(int, const char *, const struct timeval *); +typedef int (__sys_linkat_t)(int, const char *, int, const char *, int); +typedef int (__sys_mkdirat_t)(int, const char *, mode_t); +typedef int (__sys_mkfifoat_t)(int, const char *, mode_t); +typedef int (__sys_openat_t)(int, const char *, int, mode_t); +typedef ssize_t (__sys_readlinkat_t)(int, const char *, char *, size_t); +typedef int (__sys_renameat_t)(int, const char *, int, const char *); +typedef int (__sys_symlinkat_t)(const char *, int, const char *); +typedef int (__sys_unlinkat_t)(int, const char *, int); +typedef int (__sys_posix_openpt_t)(int); +typedef int (__sys_jail_get_t)(struct iovec *, unsigned int, int); +typedef int (__sys_jail_set_t)(struct iovec *, unsigned int, int); +typedef int (__sys_jail_remove_t)(int); +typedef int (__sys___semctl_t)(int, int, int, union semun *); +typedef int (__sys_msgctl_t)(int, int, struct msqid_ds *); +typedef int (__sys_shmctl_t)(int, int, struct shmid_ds *); +typedef int (__sys_lpathconf_t)(const char *, int); +typedef int (__sys___cap_rights_get_t)(int, int, cap_rights_t *); +typedef int (__sys_cap_enter_t)(void); +typedef int (__sys_cap_getmode_t)(u_int *); +typedef int (__sys_pdfork_t)(int *, int); +typedef int (__sys_pdkill_t)(int, int); +typedef int (__sys_pdgetpid_t)(int, pid_t *); +typedef int (__sys_pselect_t)(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); +typedef int (__sys_getloginclass_t)(char *, size_t); +typedef int (__sys_setloginclass_t)(const char *); +typedef int (__sys_rctl_get_racct_t)(const void *, size_t, void *, size_t); +typedef int (__sys_rctl_get_rules_t)(const void *, size_t, void *, size_t); +typedef int (__sys_rctl_get_limits_t)(const void *, size_t, void *, size_t); +typedef int (__sys_rctl_add_rule_t)(const void *, size_t, void *, size_t); +typedef int (__sys_rctl_remove_rule_t)(const void *, size_t, void *, size_t); +typedef int (__sys_posix_fallocate_t)(int, off_t, off_t); +typedef int (__sys_posix_fadvise_t)(int, off_t, off_t, int); +typedef int (__sys_wait6_t)(idtype_t, id_t, int *, int, struct __wrusage *, struct __siginfo *); +typedef int (__sys_cap_rights_limit_t)(int, cap_rights_t *); +typedef int (__sys_cap_ioctls_limit_t)(int, const u_long *, size_t); +typedef ssize_t (__sys_cap_ioctls_get_t)(int, u_long *, size_t); +typedef int (__sys_cap_fcntls_limit_t)(int, uint32_t); +typedef int (__sys_cap_fcntls_get_t)(int, uint32_t *); +typedef int (__sys_bindat_t)(int, int, const struct sockaddr *, __socklen_t); +typedef int (__sys_connectat_t)(int, int, const struct sockaddr *, __socklen_t); +typedef int (__sys_chflagsat_t)(int, const char *, u_long, int); +typedef int (__sys_accept4_t)(int, struct sockaddr *, __socklen_t *, int); +typedef int (__sys_pipe2_t)(int *, int); +typedef int (__sys_aio_mlock_t)(struct aiocb *); +typedef int (__sys_procctl_t)(idtype_t, id_t, int, void *); +typedef int (__sys_ppoll_t)(struct pollfd *, u_int, const struct timespec *, const sigset_t *); +typedef int (__sys_futimens_t)(int, const struct timespec *); +typedef int (__sys_utimensat_t)(int, const char *, const struct timespec *, int); +typedef int (__sys_fdatasync_t)(int); +typedef int (__sys_fstat_t)(int, struct stat *); +typedef int (__sys_fstatat_t)(int, const char *, struct stat *, int); +typedef int (__sys_fhstat_t)(const struct fhandle *, struct stat *); +typedef ssize_t (__sys_getdirentries_t)(int, char *, size_t, off_t *); +typedef int (__sys_statfs_t)(const char *, struct statfs *); +typedef int (__sys_fstatfs_t)(int, struct statfs *); +typedef int (__sys_getfsstat_t)(struct statfs *, long, int); +typedef int (__sys_fhstatfs_t)(const struct fhandle *, struct statfs *); +typedef int (__sys_mknodat_t)(int, const char *, mode_t, dev_t); +typedef int (__sys_kevent_t)(int, const struct kevent *, int, struct kevent *, int, const struct timespec *); +typedef int (__sys_cpuset_getdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int *); +typedef int (__sys_cpuset_setdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int); +typedef int (__sys_getrandom_t)(void *, size_t, unsigned int); +typedef int (__sys_getfhat_t)(int, char *, struct fhandle *, int); +typedef int (__sys_fhlink_t)(struct fhandle *, const char *); +typedef int (__sys_fhlinkat_t)(struct fhandle *, int, const char *); +typedef int (__sys_fhreadlink_t)(struct fhandle *, char *, size_t); +typedef int (__sys_funlinkat_t)(int, const char *, int, int); +typedef ssize_t (__sys_copy_file_range_t)(int, off_t *, int, off_t *, size_t, unsigned int); +typedef int (__sys___sysctlbyname_t)(const char *, size_t, void *, size_t *, void *, size_t); +typedef int (__sys_shm_open2_t)(const char *, int, mode_t, int, const char *); +typedef int (__sys_shm_rename_t)(const char *, const char *, int); +typedef int (__sys_sigfastblock_t)(int, void *); +typedef int (__sys___realpathat_t)(int, const char *, char *, size_t, int); +typedef int (__sys_close_range_t)(u_int, u_int, int); +typedef int (__sys_rpctls_syscall_t)(uint64_t); +typedef int (__sys___specialfd_t)(int, const void *, size_t); +typedef int (__sys_aio_writev_t)(struct aiocb *); +typedef int (__sys_aio_readv_t)(struct aiocb *); +typedef int (__sys_fspacectl_t)(int, int, const struct spacectl_range *, int, struct spacectl_range *); +typedef int (__sys_sched_getcpu_t)(void); +typedef int (__sys_swapoff_t)(const char *, u_int); +typedef int (__sys_kqueuex_t)(u_int); +typedef int (__sys_membarrier_t)(int, unsigned, int); +typedef int (__sys_timerfd_create_t)(int, int); +typedef int (__sys_timerfd_gettime_t)(int, struct itimerspec *); +typedef int (__sys_timerfd_settime_t)(int, int, const struct itimerspec *, struct itimerspec *); +typedef int (__sys_kcmp_t)(pid_t, pid_t, int, uintptr_t, uintptr_t); +typedef int (__sys_getrlimitusage_t)(u_int, int, rlim_t *); +typedef int (__sys_fchroot_t)(int); +typedef int (__sys_setcred_t)(u_int, const struct setcred *, size_t); +typedef int (__sys_exterrctl_t)(u_int, u_int, void *); +typedef int (__sys_inotify_add_watch_at_t)(int, int, const char *, uint32_t); +typedef int (__sys_inotify_rm_watch_t)(int, int); +typedef int (__sys_getgroups_t)(int, gid_t *); +typedef int (__sys_setgroups_t)(int, const gid_t *); +typedef int (__sys_jail_attach_jd_t)(int); +typedef int (__sys_jail_remove_jd_t)(int); + +_Noreturn void __sys__exit(int rval); +int __sys_fork(void); +ssize_t __sys_read(int fd, void * buf, size_t nbyte); +ssize_t __sys_write(int fd, const void * buf, size_t nbyte); +int __sys_open(const char * path, int flags, mode_t mode); +int __sys_close(int fd); +int __sys_wait4(int pid, int * status, int options, struct rusage * rusage); +int __sys_link(const char * path, const char * link); +int __sys_unlink(const char * path); +int __sys_chdir(const char * path); +int __sys_fchdir(int fd); +int __sys_chmod(const char * path, mode_t mode); +int __sys_chown(const char * path, int uid, int gid); +void * __sys_break(char * nsize); +pid_t __sys_getpid(void); +int __sys_mount(const char * type, const char * path, int flags, void * data); +int __sys_unmount(const char * path, int flags); +int __sys_setuid(uid_t uid); +uid_t __sys_getuid(void); +uid_t __sys_geteuid(void); +int __sys_ptrace(int req, pid_t pid, caddr_t addr, int data); +ssize_t __sys_recvmsg(int s, struct msghdr * msg, int flags); +ssize_t __sys_sendmsg(int s, const struct msghdr * msg, int flags); +ssize_t __sys_recvfrom(int s, void * buf, size_t len, int flags, struct sockaddr * from, __socklen_t * fromlenaddr); +int __sys_accept(int s, struct sockaddr * name, __socklen_t * anamelen); +int __sys_getpeername(int fdes, struct sockaddr * asa, __socklen_t * alen); +int __sys_getsockname(int fdes, struct sockaddr * asa, __socklen_t * alen); +int __sys_access(const char * path, int amode); +int __sys_chflags(const char * path, u_long flags); +int __sys_fchflags(int fd, u_long flags); +int __sys_sync(void); +int __sys_kill(int pid, int signum); +pid_t __sys_getppid(void); +int __sys_dup(u_int fd); +gid_t __sys_getegid(void); +int __sys_profil(char * samples, size_t size, size_t offset, u_int scale); +int __sys_ktrace(const char * fname, int ops, int facs, int pid); +gid_t __sys_getgid(void); +int __sys_getlogin(char * namebuf, u_int namelen); +int __sys_setlogin(const char * namebuf); +int __sys_acct(const char * path); +int __sys_sigaltstack(const struct sigaltstack * ss, struct sigaltstack * oss); +int __sys_ioctl(int fd, u_long com, char * data); +int __sys_reboot(int opt); +int __sys_revoke(const char * path); +int __sys_symlink(const char * path, const char * link); +ssize_t __sys_readlink(const char * path, char * buf, size_t count); +int __sys_execve(const char * fname, char ** argv, char ** envv); +mode_t __sys_umask(mode_t newmask); +int __sys_chroot(const char * path); +int __sys_msync(void * addr, size_t len, int flags); +int __sys_vfork(void); +int __sys_munmap(void * addr, size_t len); +int __sys_mprotect(void * addr, size_t len, int prot); +int __sys_madvise(void * addr, size_t len, int behav); +int __sys_mincore(const void * addr, size_t len, char * vec); +int __sys_getpgrp(void); +int __sys_setpgid(int pid, int pgid); +int __sys_setitimer(int which, const struct itimerval * itv, struct itimerval * oitv); +int __sys_swapon(const char * name); +int __sys_getitimer(int which, struct itimerval * itv); +int __sys_getdtablesize(void); +int __sys_dup2(u_int from, u_int to); +int __sys_fcntl(int fd, int cmd, intptr_t arg); +int __sys_select(int nd, fd_set * in, fd_set * ou, fd_set * ex, struct timeval * tv); +int __sys_fsync(int fd); +int __sys_setpriority(int which, int who, int prio); +int __sys_socket(int domain, int type, int protocol); +int __sys_connect(int s, const struct sockaddr * name, __socklen_t namelen); +int __sys_getpriority(int which, int who); +int __sys_bind(int s, const struct sockaddr * name, __socklen_t namelen); +int __sys_setsockopt(int s, int level, int name, const void * val, __socklen_t valsize); +int __sys_listen(int s, int backlog); +int __sys_gettimeofday(struct timeval * tp, struct timezone * tzp); +int __sys_getrusage(int who, struct rusage * rusage); +int __sys_getsockopt(int s, int level, int name, void * val, __socklen_t * avalsize); +ssize_t __sys_readv(int fd, const struct iovec * iovp, u_int iovcnt); +ssize_t __sys_writev(int fd, const struct iovec * iovp, u_int iovcnt); +int __sys_settimeofday(const struct timeval * tv, const struct timezone * tzp); +int __sys_fchown(int fd, int uid, int gid); +int __sys_fchmod(int fd, mode_t mode); +int __sys_setreuid(int ruid, int euid); +int __sys_setregid(int rgid, int egid); +int __sys_rename(const char * from, const char * to); +int __sys_flock(int fd, int how); +int __sys_mkfifo(const char * path, mode_t mode); +ssize_t __sys_sendto(int s, const void * buf, size_t len, int flags, const struct sockaddr * to, __socklen_t tolen); +int __sys_shutdown(int s, int how); +int __sys_socketpair(int domain, int type, int protocol, int * rsv); +int __sys_mkdir(const char * path, mode_t mode); +int __sys_rmdir(const char * path); +int __sys_utimes(const char * path, const struct timeval * tptr); +int __sys_adjtime(const struct timeval * delta, struct timeval * olddelta); +int __sys_setsid(void); +int __sys_quotactl(const char * path, int cmd, int uid, void * arg); +int __sys_nlm_syscall(int debug_level, int grace_period, int addr_count, char ** addrs); +int __sys_nfssvc(int flag, void * argp); +int __sys_lgetfh(const char * fname, struct fhandle * fhp); +int __sys_getfh(const char * fname, struct fhandle * fhp); +int __sys_sysarch(int op, char * parms); +int __sys_rtprio(int function, pid_t pid, struct rtprio * rtp); +int __sys_semsys(int which, int a2, int a3, int a4, int a5); +int __sys_msgsys(int which, int a2, int a3, int a4, int a5, int a6); +int __sys_shmsys(int which, int a2, int a3, int a4); +int __sys_setfib(int fibnum); +int __sys_ntp_adjtime(struct timex * tp); +int __sys_setgid(gid_t gid); +int __sys_setegid(gid_t egid); +int __sys_seteuid(uid_t euid); +int __sys_pathconf(const char * path, int name); +int __sys_fpathconf(int fd, int name); +int __sys_getrlimit(u_int which, struct rlimit * rlp); +int __sys_setrlimit(u_int which, struct rlimit * rlp); +int __sys___sysctl(const int * name, u_int namelen, void * old, size_t * oldlenp, const void * new, size_t newlen); +int __sys_mlock(const void * addr, size_t len); +int __sys_munlock(const void * addr, size_t len); +int __sys_undelete(const char * path); +int __sys_futimes(int fd, const struct timeval * tptr); +int __sys_getpgid(pid_t pid); +int __sys_poll(struct pollfd * fds, u_int nfds, int timeout); +int __sys_semget(key_t key, int nsems, int semflg); +int __sys_semop(int semid, struct sembuf * sops, size_t nsops); +int __sys_msgget(key_t key, int msgflg); +int __sys_msgsnd(int msqid, const void * msgp, size_t msgsz, int msgflg); +ssize_t __sys_msgrcv(int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg); +void * __sys_shmat(int shmid, const void * shmaddr, int shmflg); +int __sys_shmdt(const void * shmaddr); +int __sys_shmget(key_t key, size_t size, int shmflg); +int __sys_clock_gettime(clockid_t clock_id, struct timespec * tp); +int __sys_clock_settime(clockid_t clock_id, const struct timespec * tp); +int __sys_clock_getres(clockid_t clock_id, struct timespec * tp); +int __sys_ktimer_create(clockid_t clock_id, struct sigevent * evp, int * timerid); +int __sys_ktimer_delete(int timerid); +int __sys_ktimer_settime(int timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue); +int __sys_ktimer_gettime(int timerid, struct itimerspec * value); +int __sys_ktimer_getoverrun(int timerid); +int __sys_nanosleep(const struct timespec * rqtp, struct timespec * rmtp); +int __sys_ffclock_getcounter(ffcounter * ffcount); +int __sys_ffclock_setestimate(struct ffclock_estimate * cest); +int __sys_ffclock_getestimate(struct ffclock_estimate * cest); +int __sys_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec * rqtp, struct timespec * rmtp); +int __sys_clock_getcpuclockid2(id_t id, int which, clockid_t * clock_id); +int __sys_ntp_gettime(struct ntptimeval * ntvp); +int __sys_minherit(void * addr, size_t len, int inherit); +int __sys_rfork(int flags); +int __sys_issetugid(void); +int __sys_lchown(const char * path, int uid, int gid); +int __sys_aio_read(struct aiocb * aiocbp); +int __sys_aio_write(struct aiocb * aiocbp); +int __sys_lio_listio(int mode, struct aiocb * const * acb_list, int nent, struct sigevent * sig); +int __sys_lchmod(const char * path, mode_t mode); +int __sys_lutimes(const char * path, const struct timeval * tptr); +ssize_t __sys_preadv(int fd, struct iovec * iovp, u_int iovcnt, off_t offset); +ssize_t __sys_pwritev(int fd, struct iovec * iovp, u_int iovcnt, off_t offset); +int __sys_fhopen(const struct fhandle * u_fhp, int flags); +int __sys_modnext(int modid); +int __sys_modstat(int modid, struct module_stat * stat); +int __sys_modfnext(int modid); +int __sys_modfind(const char * name); +int __sys_kldload(const char * file); +int __sys_kldunload(int fileid); +int __sys_kldfind(const char * file); +int __sys_kldnext(int fileid); +int __sys_kldstat(int fileid, struct kld_file_stat * stat); +int __sys_kldfirstmod(int fileid); +int __sys_getsid(pid_t pid); +int __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid); +int __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid); +ssize_t __sys_aio_return(struct aiocb * aiocbp); +int __sys_aio_suspend(const struct aiocb * const * aiocbp, int nent, const struct timespec * timeout); +int __sys_aio_cancel(int fd, struct aiocb * aiocbp); +int __sys_aio_error(struct aiocb * aiocbp); +int __sys_mlockall(int how); +int __sys_munlockall(void); +int __sys___getcwd(char * buf, size_t buflen); +int __sys_sched_setparam(pid_t pid, const struct sched_param * param); +int __sys_sched_getparam(pid_t pid, struct sched_param * param); +int __sys_sched_setscheduler(pid_t pid, int policy, const struct sched_param * param); +int __sys_sched_getscheduler(pid_t pid); +int __sys_sched_yield(void); +int __sys_sched_get_priority_max(int policy); +int __sys_sched_get_priority_min(int policy); +int __sys_sched_rr_get_interval(pid_t pid, struct timespec * interval); +int __sys_utrace(const void * addr, size_t len); +int __sys_kldsym(int fileid, int cmd, void * data); +int __sys_jail(struct jail * jail); +int __sys_nnpfs_syscall(int operation, char * a_pathP, int a_opcode, void * a_paramsP, int a_followSymlinks); +int __sys_sigprocmask(int how, const sigset_t * set, sigset_t * oset); +int __sys_sigsuspend(const sigset_t * sigmask); +int __sys_sigpending(sigset_t * set); +int __sys_sigtimedwait(const sigset_t * set, struct __siginfo * info, const struct timespec * timeout); +int __sys_sigwaitinfo(const sigset_t * set, struct __siginfo * info); +int __sys___acl_get_file(const char * path, __acl_type_t type, struct acl * aclp); +int __sys___acl_set_file(const char * path, __acl_type_t type, struct acl * aclp); +int __sys___acl_get_fd(int filedes, __acl_type_t type, struct acl * aclp); +int __sys___acl_set_fd(int filedes, __acl_type_t type, struct acl * aclp); +int __sys___acl_delete_file(const char * path, __acl_type_t type); +int __sys___acl_delete_fd(int filedes, __acl_type_t type); +int __sys___acl_aclcheck_file(const char * path, __acl_type_t type, struct acl * aclp); +int __sys___acl_aclcheck_fd(int filedes, __acl_type_t type, struct acl * aclp); +int __sys_extattrctl(const char * path, int cmd, const char * filename, int attrnamespace, const char * attrname); +ssize_t __sys_extattr_set_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes); +ssize_t __sys_extattr_get_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes); +int __sys_extattr_delete_file(const char * path, int attrnamespace, const char * attrname); +ssize_t __sys_aio_waitcomplete(struct aiocb ** aiocbp, struct timespec * timeout); +int __sys_getresuid(uid_t * ruid, uid_t * euid, uid_t * suid); +int __sys_getresgid(gid_t * rgid, gid_t * egid, gid_t * sgid); +int __sys_kqueue(void); +ssize_t __sys_extattr_set_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes); +ssize_t __sys_extattr_get_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes); +int __sys_extattr_delete_fd(int fd, int attrnamespace, const char * attrname); +int __sys___setugid(int flag); +int __sys_eaccess(const char * path, int amode); +int __sys_afs3_syscall(long syscall, long parm1, long parm2, long parm3, long parm4, long parm5, long parm6); +int __sys_nmount(struct iovec * iovp, unsigned int iovcnt, int flags); +int __sys___mac_get_proc(struct mac * mac_p); +int __sys___mac_set_proc(struct mac * mac_p); +int __sys___mac_get_fd(int fd, struct mac * mac_p); +int __sys___mac_get_file(const char * path_p, struct mac * mac_p); +int __sys___mac_set_fd(int fd, struct mac * mac_p); +int __sys___mac_set_file(const char * path_p, struct mac * mac_p); +int __sys_kenv(int what, const char * name, char * value, int len); +int __sys_lchflags(const char * path, u_long flags); +int __sys_uuidgen(struct uuid * store, int count); +int __sys_sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr * hdtr, off_t * sbytes, int flags); +int __sys_mac_syscall(const char * policy, int call, void * arg); +int __sys_ksem_close(semid_t id); +int __sys_ksem_post(semid_t id); +int __sys_ksem_wait(semid_t id); +int __sys_ksem_trywait(semid_t id); +int __sys_ksem_init(semid_t * idp, unsigned int value); +int __sys_ksem_open(semid_t * idp, const char * name, int oflag, mode_t mode, unsigned int value); +int __sys_ksem_unlink(const char * name); +int __sys_ksem_getvalue(semid_t id, int * val); +int __sys_ksem_destroy(semid_t id); +int __sys___mac_get_pid(pid_t pid, struct mac * mac_p); +int __sys___mac_get_link(const char * path_p, struct mac * mac_p); +int __sys___mac_set_link(const char * path_p, struct mac * mac_p); +ssize_t __sys_extattr_set_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes); +ssize_t __sys_extattr_get_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes); +int __sys_extattr_delete_link(const char * path, int attrnamespace, const char * attrname); +int __sys___mac_execve(const char * fname, char ** argv, char ** envv, struct mac * mac_p); +int __sys_sigaction(int sig, const struct sigaction * act, struct sigaction * oact); +int __sys_sigreturn(const struct __ucontext * sigcntxp); +int __sys_getcontext(struct __ucontext * ucp); +int __sys_setcontext(const struct __ucontext * ucp); +int __sys_swapcontext(struct __ucontext * oucp, const struct __ucontext * ucp); +int __sys___acl_get_link(const char * path, __acl_type_t type, struct acl * aclp); +int __sys___acl_set_link(const char * path, __acl_type_t type, struct acl * aclp); +int __sys___acl_delete_link(const char * path, __acl_type_t type); +int __sys___acl_aclcheck_link(const char * path, __acl_type_t type, struct acl * aclp); +int __sys_sigwait(const sigset_t * set, int * sig); +int __sys_thr_create(ucontext_t * ctx, long * id, int flags); +void __sys_thr_exit(long * state); +int __sys_thr_self(long * id); +int __sys_thr_kill(long id, int sig); +int __sys_jail_attach(int jid); +ssize_t __sys_extattr_list_fd(int fd, int attrnamespace, void * data, size_t nbytes); +ssize_t __sys_extattr_list_file(const char * path, int attrnamespace, void * data, size_t nbytes); +ssize_t __sys_extattr_list_link(const char * path, int attrnamespace, void * data, size_t nbytes); +int __sys_ksem_timedwait(semid_t id, const struct timespec * abstime); +int __sys_thr_suspend(const struct timespec * timeout); +int __sys_thr_wake(long id); +int __sys_kldunloadf(int fileid, int flags); +int __sys_audit(const void * record, u_int length); +int __sys_auditon(int cmd, void * data, u_int length); +int __sys_getauid(uid_t * auid); +int __sys_setauid(uid_t * auid); +int __sys_getaudit(struct auditinfo * auditinfo); +int __sys_setaudit(struct auditinfo * auditinfo); +int __sys_getaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length); +int __sys_setaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length); +int __sys_auditctl(const char * path); +int __sys__umtx_op(void * obj, int op, u_long val, void * uaddr1, void * uaddr2); +int __sys_thr_new(struct thr_param * param, int param_size); +int __sys_sigqueue(pid_t pid, int signum, void * value); +int __sys_kmq_open(const char * path, int flags, mode_t mode, const struct mq_attr * attr); +int __sys_kmq_setattr(int mqd, const struct mq_attr * attr, struct mq_attr * oattr); +int __sys_kmq_timedreceive(int mqd, char * msg_ptr, size_t msg_len, unsigned * msg_prio, const struct timespec * abs_timeout); +int __sys_kmq_timedsend(int mqd, const char * msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec * abs_timeout); +int __sys_kmq_notify(int mqd, const struct sigevent * sigev); +int __sys_kmq_unlink(const char * path); +void __sys_abort2(const char * why, int nargs, void ** args); +int __sys_thr_set_name(long id, const char * name); +int __sys_aio_fsync(int op, struct aiocb * aiocbp); +int __sys_rtprio_thread(int function, lwpid_t lwpid, struct rtprio * rtp); +int __sys_sctp_peeloff(int sd, uint32_t name); +int __sys_sctp_generic_sendmsg(int sd, void * msg, int mlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags); +int __sys_sctp_generic_sendmsg_iov(int sd, struct iovec * iov, int iovlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags); +int __sys_sctp_generic_recvmsg(int sd, struct iovec * iov, int iovlen, struct sockaddr * from, __socklen_t * fromlenaddr, struct sctp_sndrcvinfo * sinfo, int * msg_flags); +ssize_t __sys_pread(int fd, void * buf, size_t nbyte, off_t offset); +ssize_t __sys_pwrite(int fd, const void * buf, size_t nbyte, off_t offset); +void * __sys_mmap(void * addr, size_t len, int prot, int flags, int fd, off_t pos); +off_t __sys_lseek(int fd, off_t offset, int whence); +int __sys_truncate(const char * path, off_t length); +int __sys_ftruncate(int fd, off_t length); +int __sys_thr_kill2(pid_t pid, long id, int sig); +int __sys_shm_unlink(const char * path); +int __sys_cpuset(cpusetid_t * setid); +int __sys_cpuset_setid(cpuwhich_t which, id_t id, cpusetid_t setid); +int __sys_cpuset_getid(cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t * setid); +int __sys_cpuset_getaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t * mask); +int __sys_cpuset_setaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, const cpuset_t * mask); +int __sys_faccessat(int fd, const char * path, int amode, int flag); +int __sys_fchmodat(int fd, const char * path, mode_t mode, int flag); +int __sys_fchownat(int fd, const char * path, uid_t uid, gid_t gid, int flag); +int __sys_fexecve(int fd, char ** argv, char ** envv); +int __sys_futimesat(int fd, const char * path, const struct timeval * times); +int __sys_linkat(int fd1, const char * path1, int fd2, const char * path2, int flag); +int __sys_mkdirat(int fd, const char * path, mode_t mode); +int __sys_mkfifoat(int fd, const char * path, mode_t mode); +int __sys_openat(int fd, const char * path, int flag, mode_t mode); +ssize_t __sys_readlinkat(int fd, const char * path, char * buf, size_t bufsize); +int __sys_renameat(int oldfd, const char * old, int newfd, const char * new); +int __sys_symlinkat(const char * path1, int fd, const char * path2); +int __sys_unlinkat(int fd, const char * path, int flag); +int __sys_posix_openpt(int flags); +int __sys_jail_get(struct iovec * iovp, unsigned int iovcnt, int flags); +int __sys_jail_set(struct iovec * iovp, unsigned int iovcnt, int flags); +int __sys_jail_remove(int jid); +int __sys___semctl(int semid, int semnum, int cmd, union semun * arg); +int __sys_msgctl(int msqid, int cmd, struct msqid_ds * buf); +int __sys_shmctl(int shmid, int cmd, struct shmid_ds * buf); +int __sys_lpathconf(const char * path, int name); +int __sys___cap_rights_get(int version, int fd, cap_rights_t * rightsp); +int __sys_cap_enter(void); +int __sys_cap_getmode(u_int * modep); +int __sys_pdfork(int * fdp, int flags); +int __sys_pdkill(int fd, int signum); +int __sys_pdgetpid(int fd, pid_t * pidp); +int __sys_pselect(int nd, fd_set * in, fd_set * ou, fd_set * ex, const struct timespec * ts, const sigset_t * sm); +int __sys_getloginclass(char * namebuf, size_t namelen); +int __sys_setloginclass(const char * namebuf); +int __sys_rctl_get_racct(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen); +int __sys_rctl_get_rules(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen); +int __sys_rctl_get_limits(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen); +int __sys_rctl_add_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen); +int __sys_rctl_remove_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen); +int __sys_posix_fallocate(int fd, off_t offset, off_t len); +int __sys_posix_fadvise(int fd, off_t offset, off_t len, int advice); +int __sys_wait6(idtype_t idtype, id_t id, int * status, int options, struct __wrusage * wrusage, struct __siginfo * info); +int __sys_cap_rights_limit(int fd, cap_rights_t * rightsp); +int __sys_cap_ioctls_limit(int fd, const u_long * cmds, size_t ncmds); +ssize_t __sys_cap_ioctls_get(int fd, u_long * cmds, size_t maxcmds); +int __sys_cap_fcntls_limit(int fd, uint32_t fcntlrights); +int __sys_cap_fcntls_get(int fd, uint32_t * fcntlrightsp); +int __sys_bindat(int fd, int s, const struct sockaddr * name, __socklen_t namelen); +int __sys_connectat(int fd, int s, const struct sockaddr * name, __socklen_t namelen); +int __sys_chflagsat(int fd, const char * path, u_long flags, int atflag); +int __sys_accept4(int s, struct sockaddr * name, __socklen_t * anamelen, int flags); +int __sys_pipe2(int * fildes, int flags); +int __sys_aio_mlock(struct aiocb * aiocbp); +int __sys_procctl(idtype_t idtype, id_t id, int com, void * data); +int __sys_ppoll(struct pollfd * fds, u_int nfds, const struct timespec * ts, const sigset_t * set); +int __sys_futimens(int fd, const struct timespec * times); +int __sys_utimensat(int fd, const char * path, const struct timespec * times, int flag); +int __sys_fdatasync(int fd); +int __sys_fstat(int fd, struct stat * sb); +int __sys_fstatat(int fd, const char * path, struct stat * buf, int flag); +int __sys_fhstat(const struct fhandle * u_fhp, struct stat * sb); +ssize_t __sys_getdirentries(int fd, char * buf, size_t count, off_t * basep); +int __sys_statfs(const char * path, struct statfs * buf); +int __sys_fstatfs(int fd, struct statfs * buf); +int __sys_getfsstat(struct statfs * buf, long bufsize, int mode); +int __sys_fhstatfs(const struct fhandle * u_fhp, struct statfs * buf); +int __sys_mknodat(int fd, const char * path, mode_t mode, dev_t dev); +int __sys_kevent(int fd, const struct kevent * changelist, int nchanges, struct kevent * eventlist, int nevents, const struct timespec * timeout); +int __sys_cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int * policy); +int __sys_cpuset_setdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int policy); +int __sys_getrandom(void * buf, size_t buflen, unsigned int flags); +int __sys_getfhat(int fd, char * path, struct fhandle * fhp, int flags); +int __sys_fhlink(struct fhandle * fhp, const char * to); +int __sys_fhlinkat(struct fhandle * fhp, int tofd, const char * to); +int __sys_fhreadlink(struct fhandle * fhp, char * buf, size_t bufsize); +int __sys_funlinkat(int dfd, const char * path, int fd, int flag); +ssize_t __sys_copy_file_range(int infd, off_t * inoffp, int outfd, off_t * outoffp, size_t len, unsigned int flags); +int __sys___sysctlbyname(const char * name, size_t namelen, void * old, size_t * oldlenp, void * new, size_t newlen); +int __sys_shm_open2(const char * path, int flags, mode_t mode, int shmflags, const char * name); +int __sys_shm_rename(const char * path_from, const char * path_to, int flags); +int __sys_sigfastblock(int cmd, void * ptr); +int __sys___realpathat(int fd, const char * path, char * buf, size_t size, int flags); +int __sys_close_range(u_int lowfd, u_int highfd, int flags); +int __sys_rpctls_syscall(uint64_t socookie); +int __sys___specialfd(int type, const void * req, size_t len); +int __sys_aio_writev(struct aiocb * aiocbp); +int __sys_aio_readv(struct aiocb * aiocbp); +int __sys_fspacectl(int fd, int cmd, const struct spacectl_range * rqsr, int flags, struct spacectl_range * rmsr); +int __sys_sched_getcpu(void); +int __sys_swapoff(const char * name, u_int flags); +int __sys_kqueuex(u_int flags); +int __sys_membarrier(int cmd, unsigned flags, int cpu_id); +int __sys_timerfd_create(int clockid, int flags); +int __sys_timerfd_gettime(int fd, struct itimerspec * curr_value); +int __sys_timerfd_settime(int fd, int flags, const struct itimerspec * new_value, struct itimerspec * old_value); +int __sys_kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2); +int __sys_getrlimitusage(u_int which, int flags, rlim_t * res); +int __sys_fchroot(int fd); +int __sys_setcred(u_int flags, const struct setcred * wcred, size_t size); +int __sys_exterrctl(u_int op, u_int flags, void * ptr); +int __sys_inotify_add_watch_at(int fd, int dfd, const char * path, uint32_t mask); +int __sys_inotify_rm_watch(int fd, int wd); +int __sys_getgroups(int gidsetsize, gid_t * gidset); +int __sys_setgroups(int gidsetsize, const gid_t * gidset); +int __sys_jail_attach_jd(int fd); +int __sys_jail_remove_jd(int fd); +__END_DECLS + +#endif /* __LIBSYS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/a.out.h b/lib/libc/include/generic-freebsd/a.out.h index bd347bbe1ffd6d152d6d651a142110d969c42426..1830d83aac9263109ee682cc3f90c71cb986f1ec 100644 --- a/lib/libc/include/generic-freebsd/a.out.h +++ b/lib/libc/include/generic-freebsd/a.out.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)a.out.h 8.1 (Berkeley) 6/2/93 */ #ifndef _AOUT_H_ diff --git a/lib/libc/include/generic-freebsd/aio.h b/lib/libc/include/generic-freebsd/aio.h index c27e766737bf473a57df004112dd1eb2655fe4cd..6aa067394811343a98747b0c61b2a578f6b55406 100644 --- a/lib/libc/include/generic-freebsd/aio.h +++ b/lib/libc/include/generic-freebsd/aio.h @@ -97,7 +97,7 @@ struct __aiocb_private { long status; long error; - void *kernelinfo; + void *spare; }; /* diff --git a/lib/libc/include/generic-freebsd/ar.h b/lib/libc/include/generic-freebsd/ar.h index 2e6599536cdaece465beba590d85d2919c73dc68..da952d735f6c85e2445a991a5ab998def707ca08 100644 --- a/lib/libc/include/generic-freebsd/ar.h +++ b/lib/libc/include/generic-freebsd/ar.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ar.h 8.2 (Berkeley) 1/21/94 */ #ifndef _AR_H_ diff --git a/lib/libc/include/generic-freebsd/arpa/ftp.h b/lib/libc/include/generic-freebsd/arpa/ftp.h index 9384fd498333091b56722ee9ba1e944b56827aa4..3309c27381e1748435fe5f62ba96cb867bb21bc7 100644 --- a/lib/libc/include/generic-freebsd/arpa/ftp.h +++ b/lib/libc/include/generic-freebsd/arpa/ftp.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ftp.h 8.1 (Berkeley) 6/2/93 */ #ifndef _ARPA_FTP_H_ diff --git a/lib/libc/include/generic-freebsd/arpa/inet.h b/lib/libc/include/generic-freebsd/arpa/inet.h index fc96ba8b5076d13d65a185204215b146c9787e8b..31377feb838875a817a4aaf9ae3a4e7010ca8981 100644 --- a/lib/libc/include/generic-freebsd/arpa/inet.h +++ b/lib/libc/include/generic-freebsd/arpa/inet.h @@ -52,7 +52,6 @@ */ /*% - * @(#)inet.h 8.1 (Berkeley) 6/2/93 * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $ */ diff --git a/lib/libc/include/generic-freebsd/arpa/telnet.h b/lib/libc/include/generic-freebsd/arpa/telnet.h index 62817ade3d6ef4810f6799dd5986cfb53be42900..44cec222efbf9c7e11bf75d37acda5ef7ed07f54 100644 --- a/lib/libc/include/generic-freebsd/arpa/telnet.h +++ b/lib/libc/include/generic-freebsd/arpa/telnet.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)telnet.h 8.2 (Berkeley) 12/15/93 */ #ifndef _ARPA_TELNET_H_ diff --git a/lib/libc/include/generic-freebsd/arpa/tftp.h b/lib/libc/include/generic-freebsd/arpa/tftp.h index c186e16b8ab642523710a632f077cfa03e0ed440..69c0cb3ffa730e73b33985eb630e2e411e8eef93 100644 --- a/lib/libc/include/generic-freebsd/arpa/tftp.h +++ b/lib/libc/include/generic-freebsd/arpa/tftp.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tftp.h 8.1 (Berkeley) 6/2/93 */ #ifndef _ARPA_TFTP_H_ diff --git a/lib/libc/include/generic-freebsd/assert.h b/lib/libc/include/generic-freebsd/assert.h index 36080f57e29c7357bec6aff645ce5cb155e43f89..b7c7deb1206af23bcd79da6e4544743e5694defb 100644 --- a/lib/libc/include/generic-freebsd/assert.h +++ b/lib/libc/include/generic-freebsd/assert.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)assert.h 8.2 (Berkeley) 1/21/94 */ #include @@ -45,15 +43,22 @@ #undef assert #undef _assert +#undef __assert_unreachable #ifdef NDEBUG #define assert(e) ((void)0) #define _assert(e) ((void)0) +#if __BSD_VISIBLE +#define __assert_unreachable() __unreachable() +#endif /* __BSD_VISIBLE */ #else #define _assert(e) assert(e) #define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \ __LINE__, #e)) +#if __BSD_VISIBLE +#define __assert_unreachable() assert(0 && "unreachable segment reached") +#endif /* __BSD_VISIBLE */ #endif /* NDEBUG */ #ifndef _ASSERT_H_ diff --git a/lib/libc/include/generic-freebsd/bsm/audit.h b/lib/libc/include/generic-freebsd/bsm/audit.h deleted file mode 100644 index abdacf6b1754095d54e91aad0febe3aaa1d03e11..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit.h +++ /dev/null @@ -1,345 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2005-2009 Apple Inc. - * Copyright (c) 2016 Robert N. M. Watson - * All rights reserved. - * - * Portions of this software were developed by BAE Systems, the University of - * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL - * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent - * Computing (TC) research program. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_H -#define _BSM_AUDIT_H - -#include -#include - -#define AUDIT_RECORD_MAGIC 0x828a0f1b -#define MAX_AUDIT_RECORDS 20 -#define MAXAUDITDATA (0x8000 - 1) -#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA -#define MIN_AUDIT_FILE_SIZE (512 * 1024) - -/* - * Minimum noumber of free blocks on the filesystem containing the audit - * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0 - * as the kernel does an unsigned compare, plus we want to leave a few blocks - * free so userspace can terminate the log, etc. - */ -#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4 - -/* - * Triggers for the audit daemon. - */ -#define AUDIT_TRIGGER_MIN 1 -#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */ -#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */ -#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */ -#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */ -#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */ -#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */ -#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */ -#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */ -#define AUDIT_TRIGGER_MAX 8 - -/* - * The special device filename (FreeBSD). - */ -#define AUDITDEV_FILENAME "audit" -#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME) - -/* - * Pre-defined audit IDs - */ -#define AU_DEFAUDITID (uid_t)(-1) -#define AU_DEFAUDITSID 0 -#define AU_ASSIGN_ASID -1 - -/* - * IPC types. - */ -#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */ -#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */ -#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */ - -/* - * Audit conditions. - */ -#define AUC_UNSET 0 -#define AUC_AUDITING 1 -#define AUC_NOAUDIT 2 -#define AUC_DISABLED -1 - -/* - * auditon(2) commands. - */ -#define A_OLDGETPOLICY 2 -#define A_OLDSETPOLICY 3 -#define A_GETKMASK 4 -#define A_SETKMASK 5 -#define A_OLDGETQCTRL 6 -#define A_OLDSETQCTRL 7 -#define A_GETCWD 8 -#define A_GETCAR 9 -#define A_GETSTAT 12 -#define A_SETSTAT 13 -#define A_SETUMASK 14 -#define A_SETSMASK 15 -#define A_OLDGETCOND 20 -#define A_OLDSETCOND 21 -#define A_GETCLASS 22 -#define A_SETCLASS 23 -#define A_GETPINFO 24 -#define A_SETPMASK 25 -#define A_SETFSIZE 26 -#define A_GETFSIZE 27 -#define A_GETPINFO_ADDR 28 -#define A_GETKAUDIT 29 -#define A_SETKAUDIT 30 -#define A_SENDTRIGGER 31 -#define A_GETSINFO_ADDR 32 -#define A_GETPOLICY 33 -#define A_SETPOLICY 34 -#define A_GETQCTRL 35 -#define A_SETQCTRL 36 -#define A_GETCOND 37 -#define A_SETCOND 38 -#define A_GETEVENT 39 /* Get audit event-to-name mapping. */ -#define A_SETEVENT 40 /* Set audit event-to-name mapping. */ - -/* - * Audit policy controls. - */ -#define AUDIT_CNT 0x0001 -#define AUDIT_AHLT 0x0002 -#define AUDIT_ARGV 0x0004 -#define AUDIT_ARGE 0x0008 -#define AUDIT_SEQ 0x0010 -#define AUDIT_WINDATA 0x0020 -#define AUDIT_USER 0x0040 -#define AUDIT_GROUP 0x0080 -#define AUDIT_TRAIL 0x0100 -#define AUDIT_PATH 0x0200 -#define AUDIT_SCNT 0x0400 -#define AUDIT_PUBLIC 0x0800 -#define AUDIT_ZONENAME 0x1000 -#define AUDIT_PERZONE 0x2000 - -/* - * Default audit queue control parameters. - */ -#define AQ_HIWATER 100 -#define AQ_MAXHIGH 10000 -#define AQ_LOWATER 10 -#define AQ_BUFSZ MAXAUDITDATA -#define AQ_MAXBUFSZ 1048576 - -/* - * Default minimum percentage free space on file system. - */ -#define AU_FS_MINFREE 20 - -/* - * Type definitions used indicating the length of variable length addresses - * in tokens containing addresses, such as header fields. - */ -#define AU_IPv4 4 -#define AU_IPv6 16 - -__BEGIN_DECLS - -typedef uid_t au_id_t; -typedef pid_t au_asid_t; -typedef u_int16_t au_event_t; -typedef u_int16_t au_emod_t; -typedef u_int32_t au_class_t; -typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8))); - -struct au_tid { - u_int32_t port; /* XXX dev_t compatibility */ - u_int32_t machine; -}; -typedef struct au_tid au_tid_t; - -struct au_tid_addr { - u_int32_t at_port; /* XXX dev_t compatibility */ - u_int32_t at_type; - u_int32_t at_addr[4]; -}; -typedef struct au_tid_addr au_tid_addr_t; - -struct au_mask { - unsigned int am_success; /* Success bits. */ - unsigned int am_failure; /* Failure bits. */ -}; -typedef struct au_mask au_mask_t; - -struct auditinfo { - au_id_t ai_auid; /* Audit user ID. */ - au_mask_t ai_mask; /* Audit masks. */ - au_tid_t ai_termid; /* Terminal ID. */ - au_asid_t ai_asid; /* Audit session ID. */ -}; -typedef struct auditinfo auditinfo_t; - -struct auditinfo_addr { - au_id_t ai_auid; /* Audit user ID. */ - au_mask_t ai_mask; /* Audit masks. */ - au_tid_addr_t ai_termid; /* Terminal ID. */ - au_asid_t ai_asid; /* Audit session ID. */ - au_asflgs_t ai_flags; /* Audit session flags. */ -}; -typedef struct auditinfo_addr auditinfo_addr_t; - -struct auditpinfo { - pid_t ap_pid; /* ID of target process. */ - au_id_t ap_auid; /* Audit user ID. */ - au_mask_t ap_mask; /* Audit masks. */ - au_tid_t ap_termid; /* Terminal ID. */ - au_asid_t ap_asid; /* Audit session ID. */ -}; -typedef struct auditpinfo auditpinfo_t; - -struct auditpinfo_addr { - pid_t ap_pid; /* ID of target process. */ - au_id_t ap_auid; /* Audit user ID. */ - au_mask_t ap_mask; /* Audit masks. */ - au_tid_addr_t ap_termid; /* Terminal ID. */ - au_asid_t ap_asid; /* Audit session ID. */ - au_asflgs_t ap_flags; /* Audit session flags. */ -}; -typedef struct auditpinfo_addr auditpinfo_addr_t; - -struct au_session { - auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */ - au_mask_t as_mask; /* Process Audit Masks. */ -}; -typedef struct au_session au_session_t; - -/* - * Contents of token_t are opaque outside of libbsm. - */ -typedef struct au_token token_t; - -/* - * Kernel audit queue control parameters: - * Default: Maximum: - * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000) - * aq_lowater: AQ_LOWATER (10) -mach_port_name_t audit_session_self(void); -au_asid_t audit_session_join(mach_port_name_t port); -#endif /* __APPLE_API_PRIVATE */ - -#endif /* defined(_KERNEL) || defined(KERNEL) */ - -__END_DECLS - -#endif /* !_BSM_AUDIT_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_domain.h b/lib/libc/include/generic-freebsd/bsm/audit_domain.h deleted file mode 100644 index d2cbe5e48bff57880be7c8502cfec61d0135d60e..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_domain.h +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2008 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_DOMAIN_H_ -#define _BSM_AUDIT_DOMAIN_H_ - -/* - * BSM protocol domain constants - protocol domains defined in Solaris. - */ -#define BSM_PF_UNSPEC 0 -#define BSM_PF_LOCAL 1 -#define BSM_PF_INET 2 -#define BSM_PF_IMPLINK 3 -#define BSM_PF_PUP 4 -#define BSM_PF_CHAOS 5 -#define BSM_PF_NS 6 -#define BSM_PF_NBS 7 /* Solaris-specific. */ -#define BSM_PF_ECMA 8 -#define BSM_PF_DATAKIT 9 -#define BSM_PF_CCITT 10 -#define BSM_PF_SNA 11 -#define BSM_PF_DECnet 12 -#define BSM_PF_DLI 13 -#define BSM_PF_LAT 14 -#define BSM_PF_HYLINK 15 -#define BSM_PF_APPLETALK 16 -#define BSM_PF_NIT 17 /* Solaris-specific. */ -#define BSM_PF_802 18 /* Solaris-specific. */ -#define BSM_PF_OSI 19 -#define BSM_PF_X25 20 /* Solaris/Linux-specific. */ -#define BSM_PF_OSINET 21 /* Solaris-specific. */ -#define BSM_PF_GOSIP 22 /* Solaris-specific. */ -#define BSM_PF_IPX 23 -#define BSM_PF_ROUTE 24 -#define BSM_PF_LINK 25 -#define BSM_PF_INET6 26 -#define BSM_PF_KEY 27 -#define BSM_PF_NCA 28 /* Solaris-specific. */ -#define BSM_PF_POLICY 29 /* Solaris-specific. */ -#define BSM_PF_INET_OFFLOAD 30 /* Solaris-specific. */ - -/* - * BSM protocol domain constants - protocol domains not defined in Solaris. - */ -#define BSM_PF_NETBIOS 500 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_ISO 501 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_XTP 502 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_COIP 503 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_CNT 504 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_RTIP 505 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_SIP 506 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_PIP 507 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_ISDN 508 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_E164 509 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_NATM 510 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_ATM 511 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_NETGRAPH 512 /* FreeBSD/Darwin-specific. */ -#define BSM_PF_SLOW 513 /* FreeBSD-specific. */ -#define BSM_PF_SCLUSTER 514 /* FreeBSD-specific. */ -#define BSM_PF_ARP 515 /* FreeBSD-specific. */ -#define BSM_PF_BLUETOOTH 516 /* FreeBSD-specific. */ - /* 517: unallocated. */ -#define BSM_PF_AX25 518 /* Linux-specific. */ -#define BSM_PF_ROSE 519 /* Linux-specific. */ -#define BSM_PF_NETBEUI 520 /* Linux-specific. */ -#define BSM_PF_SECURITY 521 /* Linux-specific. */ -#define BSM_PF_PACKET 522 /* Linux-specific. */ -#define BSM_PF_ASH 523 /* Linux-specific. */ -#define BSM_PF_ECONET 524 /* Linux-specific. */ -#define BSM_PF_ATMSVC 525 /* Linux-specific. */ -#define BSM_PF_IRDA 526 /* Linux-specific. */ -#define BSM_PF_PPPOX 527 /* Linux-specific. */ -#define BSM_PF_WANPIPE 528 /* Linux-specific. */ -#define BSM_PF_LLC 529 /* Linux-specific. */ -#define BSM_PF_CAN 530 /* Linux-specific. */ -#define BSM_PF_TIPC 531 /* Linux-specific. */ -#define BSM_PF_IUCV 532 /* Linux-specific. */ -#define BSM_PF_RXRPC 533 /* Linux-specific. */ -#define BSM_PF_PHONET 534 /* Linux-specific. */ - -/* - * Used when there is no mapping from a local to BSM protocol domain. - */ -#define BSM_PF_UNKNOWN 700 /* OpenBSM-specific. */ - -#endif /* !_BSM_AUDIT_DOMAIN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_errno.h b/lib/libc/include/generic-freebsd/bsm/audit_errno.h deleted file mode 100644 index 99d6be05f196eb4802a7675a94da4034cd5f8ac3..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_errno.h +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2008 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_ERRNO_H_ -#define _BSM_AUDIT_ERRNO_H_ - -/* - * For the purposes of portable encoding, we convert between local error - * numbers and Solaris error numbers (as well as some extensions for error - * numbers that don't exist in Solaris). Although the first 35 or so - * constants are the same across all OS's, we don't handle that in any - * special way. - * - * When adding constants here, also add them to bsm_errno.c. - */ -#define BSM_ERRNO_ESUCCESS 0 -#define BSM_ERRNO_EPERM 1 -#define BSM_ERRNO_ENOENT 2 -#define BSM_ERRNO_ESRCH 3 -#define BSM_ERRNO_EINTR 4 -#define BSM_ERRNO_EIO 5 -#define BSM_ERRNO_ENXIO 6 -#define BSM_ERRNO_E2BIG 7 -#define BSM_ERRNO_ENOEXEC 8 -#define BSM_ERRNO_EBADF 9 -#define BSM_ERRNO_ECHILD 10 -#define BSM_ERRNO_EAGAIN 11 -#define BSM_ERRNO_ENOMEM 12 -#define BSM_ERRNO_EACCES 13 -#define BSM_ERRNO_EFAULT 14 -#define BSM_ERRNO_ENOTBLK 15 -#define BSM_ERRNO_EBUSY 16 -#define BSM_ERRNO_EEXIST 17 -#define BSM_ERRNO_EXDEV 18 -#define BSM_ERRNO_ENODEV 19 -#define BSM_ERRNO_ENOTDIR 20 -#define BSM_ERRNO_EISDIR 21 -#define BSM_ERRNO_EINVAL 22 -#define BSM_ERRNO_ENFILE 23 -#define BSM_ERRNO_EMFILE 24 -#define BSM_ERRNO_ENOTTY 25 -#define BSM_ERRNO_ETXTBSY 26 -#define BSM_ERRNO_EFBIG 27 -#define BSM_ERRNO_ENOSPC 28 -#define BSM_ERRNO_ESPIPE 29 -#define BSM_ERRNO_EROFS 30 -#define BSM_ERRNO_EMLINK 31 -#define BSM_ERRNO_EPIPE 32 -#define BSM_ERRNO_EDOM 33 -#define BSM_ERRNO_ERANGE 34 -#define BSM_ERRNO_ENOMSG 35 -#define BSM_ERRNO_EIDRM 36 -#define BSM_ERRNO_ECHRNG 37 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EL2NSYNC 38 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EL3HLT 39 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EL3RST 40 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELNRNG 41 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EUNATCH 42 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOCSI 43 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EL2HLT 44 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EDEADLK 45 -#define BSM_ERRNO_ENOLCK 46 -#define BSM_ERRNO_ECANCELED 47 -#define BSM_ERRNO_ENOTSUP 48 -#define BSM_ERRNO_EDQUOT 49 -#define BSM_ERRNO_EBADE 50 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EBADR 51 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EXFULL 52 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOANO 53 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EBADRQC 54 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EBADSLT 55 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EDEADLOCK 56 /* Solaris-specific. */ -#define BSM_ERRNO_EBFONT 57 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EOWNERDEAD 58 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOTRECOVERABLE 59 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOSTR 60 /* Solaris/Darwin/Linux-specific. */ -#define BSM_ERRNO_ENODATA 61 /* Solaris/Darwin/Linux-specific. */ -#define BSM_ERRNO_ETIME 62 /* Solaris/Darwin/Linux-specific. */ -#define BSM_ERRNO_ENOSR 63 /* Solaris/Darwin/Linux-specific. */ -#define BSM_ERRNO_ENONET 64 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOPKG 65 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EREMOTE 66 -#define BSM_ERRNO_ENOLINK 67 -#define BSM_ERRNO_EADV 68 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ESRMNT 69 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ECOMM 70 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EPROTO 71 -#define BSM_ERRNO_ELOCKUNMAPPED 72 /* Solaris-specific. */ -#define BSM_ERRNO_ENOTACTIVE 73 /* Solaris-specific. */ -#define BSM_ERRNO_EMULTIHOP 74 -#define BSM_ERRNO_EBADMSG 77 -#define BSM_ERRNO_ENAMETOOLONG 78 -#define BSM_ERRNO_EOVERFLOW 79 -#define BSM_ERRNO_ENOTUNIQ 80 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EBADFD 81 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EREMCHG 82 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELIBACC 83 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELIBBAD 84 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELIBSCN 85 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELIBMAX 86 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ELIBEXEC 87 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_EILSEQ 88 -#define BSM_ERRNO_ENOSYS 89 -#define BSM_ERRNO_ELOOP 90 -#define BSM_ERRNO_ERESTART 91 -#define BSM_ERRNO_ESTRPIPE 92 /* Solaris/Linux-specific. */ -#define BSM_ERRNO_ENOTEMPTY 93 -#define BSM_ERRNO_EUSERS 94 -#define BSM_ERRNO_ENOTSOCK 95 -#define BSM_ERRNO_EDESTADDRREQ 96 -#define BSM_ERRNO_EMSGSIZE 97 -#define BSM_ERRNO_EPROTOTYPE 98 -#define BSM_ERRNO_ENOPROTOOPT 99 -#define BSM_ERRNO_EPROTONOSUPPORT 120 -#define BSM_ERRNO_ESOCKTNOSUPPORT 121 -#define BSM_ERRNO_EOPNOTSUPP 122 -#define BSM_ERRNO_EPFNOSUPPORT 123 -#define BSM_ERRNO_EAFNOSUPPORT 124 -#define BSM_ERRNO_EADDRINUSE 125 -#define BSM_ERRNO_EADDRNOTAVAIL 126 -#define BSM_ERRNO_ENETDOWN 127 -#define BSM_ERRNO_ENETUNREACH 128 -#define BSM_ERRNO_ENETRESET 129 -#define BSM_ERRNO_ECONNABORTED 130 -#define BSM_ERRNO_ECONNRESET 131 -#define BSM_ERRNO_ENOBUFS 132 -#define BSM_ERRNO_EISCONN 133 -#define BSM_ERRNO_ENOTCONN 134 -#define BSM_ERRNO_ESHUTDOWN 143 -#define BSM_ERRNO_ETOOMANYREFS 144 -#define BSM_ERRNO_ETIMEDOUT 145 -#define BSM_ERRNO_ECONNREFUSED 146 -#define BSM_ERRNO_EHOSTDOWN 147 -#define BSM_ERRNO_EHOSTUNREACH 148 -#define BSM_ERRNO_EALREADY 149 -#define BSM_ERRNO_EINPROGRESS 150 -#define BSM_ERRNO_ESTALE 151 - -/* - * OpenBSM constants for error numbers not defined in Solaris. In the event - * that these errors are added to Solaris, we will deprecate the OpenBSM - * numbers in the same way we do for audit event constants. - * - * ELAST doesn't get a constant in the BSM space. - */ -#define BSM_ERRNO_EPROCLIM 190 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EBADRPC 191 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_ERPCMISMATCH 192 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EPROGUNAVAIL 193 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EPROGMISMATCH 194 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EPROCUNAVAIL 195 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EFTYPE 196 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EAUTH 197 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_ENEEDAUTH 198 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_ENOATTR 199 /* FreeBSD/Darwin-specific. */ -#define BSM_ERRNO_EDOOFUS 200 /* FreeBSD-specific. */ -#define BSM_ERRNO_EJUSTRETURN 201 /* FreeBSD-specific. */ -#define BSM_ERRNO_ENOIOCTL 202 /* FreeBSD-specific. */ -#define BSM_ERRNO_EDIRIOCTL 203 /* FreeBSD-specific. */ -#define BSM_ERRNO_EPWROFF 204 /* Darwin-specific. */ -#define BSM_ERRNO_EDEVERR 205 /* Darwin-specific. */ -#define BSM_ERRNO_EBADEXEC 206 /* Darwin-specific. */ -#define BSM_ERRNO_EBADARCH 207 /* Darwin-specific. */ -#define BSM_ERRNO_ESHLIBVERS 208 /* Darwin-specific. */ -#define BSM_ERRNO_EBADMACHO 209 /* Darwin-specific. */ -#define BSM_ERRNO_EPOLICY 210 /* Darwin-specific. */ -#define BSM_ERRNO_EDOTDOT 211 /* Linux-specific. */ -#define BSM_ERRNO_EUCLEAN 212 /* Linux-specific. */ -#define BSM_ERRNO_ENOTNAM 213 /* Linux(Xenix?)-specific. */ -#define BSM_ERRNO_ENAVAIL 214 /* Linux(Xenix?)-specific. */ -#define BSM_ERRNO_EISNAM 215 /* Linux(Xenix?)-specific. */ -#define BSM_ERRNO_EREMOTEIO 216 /* Linux-specific. */ -#define BSM_ERRNO_ENOMEDIUM 217 /* Linux-specific. */ -#define BSM_ERRNO_EMEDIUMTYPE 218 /* Linux-specific. */ -#define BSM_ERRNO_ENOKEY 219 /* Linux-specific. */ -#define BSM_ERRNO_EKEYEXPIRED 220 /* Linux-specific. */ -#define BSM_ERRNO_EKEYREVOKED 221 /* Linux-specific. */ -#define BSM_ERRNO_EKEYREJECTED 222 /* Linux-specific. */ -#define BSM_ERRNO_ENOTCAPABLE 223 /* FreeBSD-specific. */ -#define BSM_ERRNO_ECAPMODE 224 /* FreeBSD-specific. */ -#define BSM_ERRNO_EINTEGRITY 225 /* FreeBSD-specific. */ - -/* - * In the event that OpenBSM doesn't have a file representation of a local - * error number, use this. - */ -#define BSM_ERRNO_UNKNOWN 250 /* OpenBSM-specific. */ - -#endif /* !_BSM_AUDIT_ERRNO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_fcntl.h b/lib/libc/include/generic-freebsd/bsm/audit_fcntl.h deleted file mode 100644 index 49763107eca243073bd352193e62f90eb2da1b75..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_fcntl.h +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2009 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_FCNTL_H_ -#define _BSM_AUDIT_FCNTL_H_ - -/* - * Shared and Solaris-specific: (0-99). - */ -#define BSM_F_DUPFD 0 -#define BSM_F_GETFD 1 -#define BSM_F_SETFD 2 -#define BSM_F_GETFL 3 -#define BSM_F_SETFL 4 -#define BSM_F_O_GETLK 5 /* Solaris-specific. */ -#define BSM_F_SETLK 6 -#define BSM_F_SETLKW 7 -#define BSM_F_CHKFL 8 /* Solaris-specific. */ -#define BSM_F_DUP2FD 9 /* FreeBSD/Solaris-specific. */ -#define BSM_F_ALLOCSP 10 /* Solaris-specific. */ -#define BSM_F_FREESP 11 /* Solaris-specific. */ - -#define BSM_F_ISSTREAM 13 /* Solaris-specific. */ -#define BSM_F_GETLK 14 -#define BSM_F_PRIV 15 /* Solaris-specific. */ -#define BSM_F_NPRIV 16 /* Solaris-specific. */ -#define BSM_F_QUOTACTL 17 /* Solaris-specific. */ -#define BSM_F_BLOCKS 18 /* Solaris-specific. */ -#define BSM_F_BLKSIZE 19 /* Solaris-specific. */ - -#define BSM_F_GETOWN 23 -#define BSM_F_SETOWN 24 -#define BSM_F_REVOKE 25 /* Solaris-specific. */ -#define BSM_F_HASREMOTELOCKS 26 /* Solaris-specific. */ -#define BSM_F_FREESP64 27 /* Solaris-specific. */ -#define BSM_F_ALLOCSP64 28 /* Solaris-specific. */ - -#define BSM_F_GETLK64 33 /* Solaris-specific. */ -#define BSM_F_SETLK64 34 /* Solaris-specific. */ -#define BSM_F_SETLKW64 35 /* Solaris-specific. */ - -#define BSM_F_SHARE 40 /* Solaris-specific. */ -#define BSM_F_UNSHARE 41 /* Solaris-specific. */ -#define BSM_F_SETLK_NBMAND 42 /* Solaris-specific. */ -#define BSM_F_SHARE_NBMAND 43 /* Solaris-specific. */ -#define BSM_F_SETLK64_NBMAND 44 /* Solaris-specific. */ -#define BSM_F_GETXFL 45 /* Solaris-specific. */ -#define BSM_F_BADFD 46 /* Solaris-specific. */ - -/* - * FreeBSD-specific (100-199). - */ -#define BSM_F_OGETLK 107 /* FreeBSD-specific. */ -#define BSM_F_OSETLK 108 /* FreeBSD-specific. */ -#define BSM_F_OSETLKW 109 /* FreeBSD-specific. */ - -#define BSM_F_SETLK_REMOTE 114 /* FreeBSD-specific. */ - -/* - * Linux-specific (200-299). - */ -#define BSM_F_SETSIG 210 /* Linux-specific. */ -#define BSM_F_GETSIG 211 /* Linux-specific. */ - -/* - * Darwin-specific (300-399). - */ -#define BSM_F_CHKCLEAN 341 /* Darwin-specific. */ -#define BSM_F_PREALLOCATE 342 /* Darwin-specific. */ -#define BSM_F_SETSIZE 343 /* Darwin-specific. */ -#define BSM_F_RDADVISE 344 /* Darwin-specific. */ -#define BSM_F_RDAHEAD 345 /* Darwin-specific. */ -#define BSM_F_READBOOTSTRAP 346 /* Darwin-specific. */ -#define BSM_F_WRITEBOOTSTRAP 347 /* Darwin-specific. */ -#define BSM_F_NOCACHE 348 /* Darwin-specific. */ -#define BSM_F_LOG2PHYS 349 /* Darwin-specific. */ -#define BSM_F_GETPATH 350 /* Darwin-specific. */ -#define BSM_F_FULLFSYNC 351 /* Darwin-specific. */ -#define BSM_F_PATHPKG_CHECK 352 /* Darwin-specific. */ -#define BSM_F_FREEZE_FS 353 /* Darwin-specific. */ -#define BSM_F_THAW_FS 354 /* Darwin-specific. */ -#define BSM_F_GLOBAL_NOCACHE 355 /* Darwin-specific. */ -#define BSM_F_OPENFROM 356 /* Darwin-specific. */ -#define BSM_F_UNLINKFROM 357 /* Darwin-specific. */ -#define BSM_F_CHECK_OPENEVT 358 /* Darwin-specific. */ -#define BSM_F_ADDSIGS 359 /* Darwin-specific. */ -#define BSM_F_MARKDEPENDENCY 360 /* Darwin-specific. */ - -/* - * Darwin file system specific (400-499). - */ -#define BSM_F_FS_SPECIFIC_0 400 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_1 401 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_2 402 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_3 403 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_4 404 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_5 405 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_6 406 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_7 407 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_8 408 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_9 409 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_10 410 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_11 411 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_12 412 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_13 413 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_14 414 /* Darwin-fs-specific. */ -#define BSM_F_FS_SPECIFIC_15 415 /* Darwin-fs-specific. */ - - -#define BSM_F_UNKNOWN 0xFFFF - -#endif /* !_BSM_AUDIT_FCNTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_internal.h b/lib/libc/include/generic-freebsd/bsm/audit_internal.h deleted file mode 100644 index 1de62cf9d4e191e49815e823514a30b2c65912ea..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_internal.h +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2005-2008 Apple Inc. - * Copyright (c) 2005 SPARTA, Inc. - * All rights reserved. - * - * This code was developed in part by Robert N. M. Watson, Senior Principal - * Scientist, SPARTA, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _AUDIT_INTERNAL_H -#define _AUDIT_INTERNAL_H - -#if defined(__linux__) && !defined(__unused) -#define __unused -#endif - -/* - * audit_internal.h contains private interfaces that are shared by user space - * and the kernel for the purposes of assembling audit records. Applications - * should not include this file or use the APIs found within, or it may be - * broken with future releases of OpenBSM, which may delete, modify, or - * otherwise break these interfaces or the assumptions they rely on. - */ -struct au_token { - u_char *t_data; - size_t len; - TAILQ_ENTRY(au_token) tokens; -}; - -struct au_record { - char used; /* Record currently in use? */ - int desc; /* Descriptor for record. */ - TAILQ_HEAD(, au_token) token_q; /* Queue of BSM tokens. */ - u_char *data; - size_t len; - LIST_ENTRY(au_record) au_rec_q; -}; -typedef struct au_record au_record_t; - - -/* - * We could determined the header and trailer sizes by defining appropriate - * structures. We hold off that approach until we have a consistent way of - * using structures for all tokens. This is not straightforward since these - * token structures may contain pointers of whose contents we do not know the - * size (e.g text tokens). - */ -#define AUDIT_HEADER_EX_SIZE(a) ((a)->ai_termid.at_type+18+sizeof(u_int32_t)) -#define AUDIT_HEADER_SIZE 18 -#define MAX_AUDIT_HEADER_SIZE (5*sizeof(u_int32_t)+18) -#define AUDIT_TRAILER_SIZE 7 - -/* - * BSM token streams store fields in big endian byte order, so as to be - * portable; when encoding and decoding, we must convert byte orders for - * typed values. - */ -#define ADD_U_CHAR(loc, val) \ - do { \ - *(loc) = (val); \ - (loc) += sizeof(u_char); \ - } while(0) - - -#define ADD_U_INT16(loc, val) \ - do { \ - be16enc((loc), (val)); \ - (loc) += sizeof(u_int16_t); \ - } while(0) - -#define ADD_U_INT32(loc, val) \ - do { \ - be32enc((loc), (val)); \ - (loc) += sizeof(u_int32_t); \ - } while(0) - -#define ADD_U_INT64(loc, val) \ - do { \ - be64enc((loc), (val)); \ - (loc) += sizeof(u_int64_t); \ - } while(0) - -#define ADD_MEM(loc, data, size) \ - do { \ - memcpy((loc), (data), (size)); \ - (loc) += size; \ - } while(0) - -#define ADD_STRING(loc, data, size) ADD_MEM(loc, data, size) - -#endif /* !_AUDIT_INTERNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_kevents.h b/lib/libc/include/generic-freebsd/bsm/audit_kevents.h deleted file mode 100644 index e9c03cac0ef23bf0dd99097a56b37f657fbceefc..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_kevents.h +++ /dev/null @@ -1,851 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2005-2009 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_KEVENTS_H_ -#define _BSM_AUDIT_KEVENTS_H_ - -/* - * The reserved event numbers for kernel events are 1...2047 and 43001..44999. - */ -#define AUE_IS_A_KEVENT(e) (((e) > 0 && (e) < 2048) || \ - ((e) > 43000 && (e) < 45000)) - -/* - * Values marked as AUE_NULL are not required to be audited as per CAPP. - * - * Some conflicts exist in the assignment of name to event number mappings - * between BSM implementations. In general, we prefer the OpenSolaris - * definition as we consider Solaris BSM to be authoritative. _DARWIN_ has - * been inserted for the Darwin variants. If necessary, other tags will be - * added in the future. - */ -#define AUE_NULL 0 -#define AUE_EXIT 1 -#define AUE_FORK 2 -#define AUE_FORKALL AUE_FORK /* Solaris-specific. */ -#define AUE_OPEN 3 -#define AUE_CREAT 4 -#define AUE_LINK 5 -#define AUE_UNLINK 6 -#define AUE_DELETE AUE_UNLINK /* Darwin-specific. */ -#define AUE_EXEC 7 -#define AUE_CHDIR 8 -#define AUE_MKNOD 9 -#define AUE_CHMOD 10 -#define AUE_CHOWN 11 -#define AUE_UMOUNT 12 -#define AUE_JUNK 13 /* Solaris-specific. */ -#define AUE_ACCESS 14 -#define AUE_KILL 15 -#define AUE_STAT 16 -#define AUE_LSTAT 17 -#define AUE_ACCT 18 -#define AUE_MCTL 19 /* Solaris-specific. */ -#define AUE_REBOOT 20 /* XXX: Darwin conflict. */ -#define AUE_SYMLINK 21 -#define AUE_READLINK 22 -#define AUE_EXECVE 23 -#define AUE_CHROOT 24 -#define AUE_VFORK 25 -#define AUE_SETGROUPS 26 -#define AUE_SETPGRP 27 -#define AUE_SWAPON 28 -#define AUE_SETHOSTNAME 29 /* XXX: Darwin conflict. */ -#define AUE_FCNTL 30 -#define AUE_SETPRIORITY 31 /* XXX: Darwin conflict. */ -#define AUE_CONNECT 32 -#define AUE_ACCEPT 33 -#define AUE_BIND 34 -#define AUE_SETSOCKOPT 35 -#define AUE_VTRACE 36 /* Solaris-specific. */ -#define AUE_SETTIMEOFDAY 37 /* XXX: Darwin conflict. */ -#define AUE_FCHOWN 38 -#define AUE_FCHMOD 39 -#define AUE_SETREUID 40 -#define AUE_SETREGID 41 -#define AUE_RENAME 42 -#define AUE_TRUNCATE 43 /* XXX: Darwin conflict. */ -#define AUE_FTRUNCATE 44 /* XXX: Darwin conflict. */ -#define AUE_FLOCK 45 /* XXX: Darwin conflict. */ -#define AUE_SHUTDOWN 46 -#define AUE_MKDIR 47 -#define AUE_RMDIR 48 -#define AUE_UTIMES 49 -#define AUE_ADJTIME 50 -#define AUE_SETRLIMIT 51 -#define AUE_KILLPG 52 -#define AUE_NFS_SVC 53 /* XXX: Darwin conflict. */ -#define AUE_STATFS 54 -#define AUE_FSTATFS 55 -#define AUE_UNMOUNT 56 /* XXX: Darwin conflict. */ -#define AUE_ASYNC_DAEMON 57 -#define AUE_NFS_GETFH 58 /* XXX: Darwin conflict. */ -#define AUE_SETDOMAINNAME 59 -#define AUE_QUOTACTL 60 /* XXX: Darwin conflict. */ -#define AUE_EXPORTFS 61 -#define AUE_MOUNT 62 -#define AUE_SEMSYS 63 -#define AUE_MSGSYS 64 -#define AUE_SHMSYS 65 -#define AUE_BSMSYS 66 /* Solaris-specific. */ -#define AUE_RFSSYS 67 /* Solaris-specific. */ -#define AUE_FCHDIR 68 -#define AUE_FCHROOT 69 -#define AUE_VPIXSYS 70 /* Solaris-specific. */ -#define AUE_PATHCONF 71 -#define AUE_OPEN_R 72 -#define AUE_OPEN_RC 73 -#define AUE_OPEN_RT 74 -#define AUE_OPEN_RTC 75 -#define AUE_OPEN_W 76 -#define AUE_OPEN_WC 77 -#define AUE_OPEN_WT 78 -#define AUE_OPEN_WTC 79 -#define AUE_OPEN_RW 80 -#define AUE_OPEN_RWC 81 -#define AUE_OPEN_RWT 82 -#define AUE_OPEN_RWTC 83 -#define AUE_MSGCTL 84 -#define AUE_MSGCTL_RMID 85 -#define AUE_MSGCTL_SET 86 -#define AUE_MSGCTL_STAT 87 -#define AUE_MSGGET 88 -#define AUE_MSGRCV 89 -#define AUE_MSGSND 90 -#define AUE_SHMCTL 91 -#define AUE_SHMCTL_RMID 92 -#define AUE_SHMCTL_SET 93 -#define AUE_SHMCTL_STAT 94 -#define AUE_SHMGET 95 -#define AUE_SHMAT 96 -#define AUE_SHMDT 97 -#define AUE_SEMCTL 98 -#define AUE_SEMCTL_RMID 99 -#define AUE_SEMCTL_SET 100 -#define AUE_SEMCTL_STAT 101 -#define AUE_SEMCTL_GETNCNT 102 -#define AUE_SEMCTL_GETPID 103 -#define AUE_SEMCTL_GETVAL 104 -#define AUE_SEMCTL_GETALL 105 -#define AUE_SEMCTL_GETZCNT 106 -#define AUE_SEMCTL_SETVAL 107 -#define AUE_SEMCTL_SETALL 108 -#define AUE_SEMGET 109 -#define AUE_SEMOP 110 -#define AUE_CORE 111 /* Solaris-specific, currently. */ -#define AUE_CLOSE 112 -#define AUE_SYSTEMBOOT 113 /* Solaris-specific. */ -#define AUE_ASYNC_DAEMON_EXIT 114 /* Solaris-specific. */ -#define AUE_NFSSVC_EXIT 115 /* Solaris-specific. */ -#define AUE_WRITEL 128 /* Solaris-specific. */ -#define AUE_WRITEVL 129 /* Solaris-specific. */ -#define AUE_GETAUID 130 -#define AUE_SETAUID 131 -#define AUE_GETAUDIT 132 -#define AUE_SETAUDIT 133 -#define AUE_GETUSERAUDIT 134 /* Solaris-specific. */ -#define AUE_SETUSERAUDIT 135 /* Solaris-specific. */ -#define AUE_AUDITSVC 136 /* Solaris-specific. */ -#define AUE_AUDITUSER 137 /* Solaris-specific. */ -#define AUE_AUDITON 138 -#define AUE_AUDITON_GTERMID 139 /* Solaris-specific. */ -#define AUE_AUDITON_STERMID 140 /* Solaris-specific. */ -#define AUE_AUDITON_GPOLICY 141 -#define AUE_AUDITON_SPOLICY 142 -#define AUE_AUDITON_GQCTRL 145 -#define AUE_AUDITON_SQCTRL 146 -#define AUE_GETKERNSTATE 147 /* Solaris-specific. */ -#define AUE_SETKERNSTATE 148 /* Solaris-specific. */ -#define AUE_GETPORTAUDIT 149 /* Solaris-specific. */ -#define AUE_AUDITSTAT 150 /* Solaris-specific. */ -#define AUE_REVOKE 151 -#define AUE_MAC 152 /* Solaris-specific. */ -#define AUE_ENTERPROM 153 /* Solaris-specific. */ -#define AUE_EXITPROM 154 /* Solaris-specific. */ -#define AUE_IFLOAT 155 /* Solaris-specific. */ -#define AUE_PFLOAT 156 /* Solaris-specific. */ -#define AUE_UPRIV 157 /* Solaris-specific. */ -#define AUE_IOCTL 158 -#define AUE_SOCKET 183 -#define AUE_SENDTO 184 -#define AUE_PIPE 185 -#define AUE_SOCKETPAIR 186 /* XXX: Darwin conflict. */ -#define AUE_SEND 187 -#define AUE_SENDMSG 188 -#define AUE_RECV 189 -#define AUE_RECVMSG 190 -#define AUE_RECVFROM 191 -#define AUE_READ 192 -#define AUE_GETDENTS 193 -#define AUE_LSEEK 194 -#define AUE_WRITE 195 -#define AUE_WRITEV 196 -#define AUE_NFS 197 /* Solaris-specific. */ -#define AUE_READV 198 -#define AUE_OSTAT 199 /* Solaris-specific. */ -#define AUE_SETUID 200 /* XXXRW: Solaris old setuid? */ -#define AUE_STIME 201 /* XXXRW: Solaris old stime? */ -#define AUE_UTIME 202 /* XXXRW: Solaris old utime? */ -#define AUE_NICE 203 /* XXXRW: Solaris old nice? */ -#define AUE_OSETPGRP 204 /* Solaris-specific. */ -#define AUE_SETGID 205 -#define AUE_READL 206 /* Solaris-specific. */ -#define AUE_READVL 207 /* Solaris-specific. */ -#define AUE_FSTAT 208 -#define AUE_DUP2 209 -#define AUE_MMAP 210 -#define AUE_AUDIT 211 -#define AUE_PRIOCNTLSYS 212 /* Solaris-specific. */ -#define AUE_MUNMAP 213 -#define AUE_SETEGID 214 -#define AUE_SETEUID 215 -#define AUE_PUTMSG 216 /* Solaris-specific. */ -#define AUE_GETMSG 217 /* Solaris-specific. */ -#define AUE_PUTPMSG 218 /* Solaris-specific. */ -#define AUE_GETPMSG 219 /* Solaris-specific. */ -#define AUE_AUDITSYS 220 /* Solaris-specific. */ -#define AUE_AUDITON_GETKMASK 221 -#define AUE_AUDITON_SETKMASK 222 -#define AUE_AUDITON_GETCWD 223 -#define AUE_AUDITON_GETCAR 224 -#define AUE_AUDITON_GETSTAT 225 -#define AUE_AUDITON_SETSTAT 226 -#define AUE_AUDITON_SETUMASK 227 -#define AUE_AUDITON_SETSMASK 228 -#define AUE_AUDITON_GETCOND 229 -#define AUE_AUDITON_SETCOND 230 -#define AUE_AUDITON_GETCLASS 231 -#define AUE_AUDITON_SETCLASS 232 -#define AUE_FUSERS 233 /* Solaris-specific; also UTSSYS? */ -#define AUE_STATVFS 234 -#define AUE_XSTAT 235 /* Solaris-specific. */ -#define AUE_LXSTAT 236 /* Solaris-specific. */ -#define AUE_LCHOWN 237 -#define AUE_MEMCNTL 238 /* Solaris-specific. */ -#define AUE_SYSINFO 239 /* Solaris-specific. */ -#define AUE_XMKNOD 240 /* Solaris-specific. */ -#define AUE_FORK1 241 -#define AUE_MODCTL 242 /* Solaris-specific. */ -#define AUE_MODLOAD 243 -#define AUE_MODUNLOAD 244 -#define AUE_MODCONFIG 245 /* Solaris-specific. */ -#define AUE_MODADDMAJ 246 /* Solaris-specific. */ -#define AUE_SOCKACCEPT 247 /* Solaris-specific. */ -#define AUE_SOCKCONNECT 248 /* Solaris-specific. */ -#define AUE_SOCKSEND 249 /* Solaris-specific. */ -#define AUE_SOCKRECEIVE 250 /* Solaris-specific. */ -#define AUE_ACLSET 251 -#define AUE_FACLSET 252 -#define AUE_DOORFS 253 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_CALL 254 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_RETURN 255 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_CREATE 256 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_REVOKE 257 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_INFO 258 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_CRED 259 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_BIND 260 /* Solaris-specific. */ -#define AUE_DOORFS_DOOR_UNBIND 261 /* Solaris-specific. */ -#define AUE_P_ONLINE 262 /* Solaris-specific. */ -#define AUE_PROCESSOR_BIND 263 /* Solaris-specific. */ -#define AUE_INST_SYNC 264 /* Solaris-specific. */ -#define AUE_SOCKCONFIG 265 /* Solaris-specific. */ -#define AUE_SETAUDIT_ADDR 266 -#define AUE_GETAUDIT_ADDR 267 -#define AUE_UMOUNT2 268 /* Solaris-specific. */ -#define AUE_FSAT 269 /* Solaris-specific. */ -#define AUE_OPENAT_R 270 -#define AUE_OPENAT_RC 271 -#define AUE_OPENAT_RT 272 -#define AUE_OPENAT_RTC 273 -#define AUE_OPENAT_W 274 -#define AUE_OPENAT_WC 275 -#define AUE_OPENAT_WT 276 -#define AUE_OPENAT_WTC 277 -#define AUE_OPENAT_RW 278 -#define AUE_OPENAT_RWC 279 -#define AUE_OPENAT_RWT 280 -#define AUE_OPENAT_RWTC 281 -#define AUE_RENAMEAT 282 -#define AUE_FSTATAT 283 -#define AUE_FCHOWNAT 284 -#define AUE_FUTIMESAT 285 -#define AUE_UNLINKAT 286 -#define AUE_CLOCK_SETTIME 287 -#define AUE_NTP_ADJTIME 288 -#define AUE_SETPPRIV 289 /* Solaris-specific. */ -#define AUE_MODDEVPLCY 290 /* Solaris-specific. */ -#define AUE_MODADDPRIV 291 /* Solaris-specific. */ -#define AUE_CRYPTOADM 292 /* Solaris-specific. */ -#define AUE_CONFIGKSSL 293 /* Solaris-specific. */ -#define AUE_BRANDSYS 294 /* Solaris-specific. */ -#define AUE_PF_POLICY_ADDRULE 295 /* Solaris-specific. */ -#define AUE_PF_POLICY_DELRULE 296 /* Solaris-specific. */ -#define AUE_PF_POLICY_CLONE 297 /* Solaris-specific. */ -#define AUE_PF_POLICY_FLIP 298 /* Solaris-specific. */ -#define AUE_PF_POLICY_FLUSH 299 /* Solaris-specific. */ -#define AUE_PF_POLICY_ALGS 300 /* Solaris-specific. */ -#define AUE_PORTFS 301 /* Solaris-specific. */ - -/* - * Events added for Apple Darwin that potentially collide with future Solaris - * BSM events. These are assigned AUE_DARWIN prefixes, and are deprecated in - * new trails. Systems generating these events should switch to the new - * identifiers that avoid colliding with the Solaris identifier space. - */ -#define AUE_DARWIN_GETFSSTAT 301 -#define AUE_DARWIN_PTRACE 302 -#define AUE_DARWIN_CHFLAGS 303 -#define AUE_DARWIN_FCHFLAGS 304 -#define AUE_DARWIN_PROFILE 305 -#define AUE_DARWIN_KTRACE 306 -#define AUE_DARWIN_SETLOGIN 307 -#define AUE_DARWIN_REBOOT 308 -#define AUE_DARWIN_REVOKE 309 -#define AUE_DARWIN_UMASK 310 -#define AUE_DARWIN_MPROTECT 311 -#define AUE_DARWIN_SETPRIORITY 312 -#define AUE_DARWIN_SETTIMEOFDAY 313 -#define AUE_DARWIN_FLOCK 314 -#define AUE_DARWIN_MKFIFO 315 -#define AUE_DARWIN_POLL 316 -#define AUE_DARWIN_SOCKETPAIR 317 -#define AUE_DARWIN_FUTIMES 318 -#define AUE_DARWIN_SETSID 319 -#define AUE_DARWIN_SETPRIVEXEC 320 /* Darwin-specific. */ -#define AUE_DARWIN_NFSSVC 321 -#define AUE_DARWIN_GETFH 322 -#define AUE_DARWIN_QUOTACTL 323 -#define AUE_DARWIN_ADDPROFILE 324 /* Darwin-specific. */ -#define AUE_DARWIN_KDEBUGTRACE 325 /* Darwin-specific. */ -#define AUE_DARWIN_KDBUGTRACE AUE_KDEBUGTRACE -#define AUE_DARWIN_FSTAT 326 -#define AUE_DARWIN_FPATHCONF 327 -#define AUE_DARWIN_GETDIRENTRIES 328 -#define AUE_DARWIN_TRUNCATE 329 -#define AUE_DARWIN_FTRUNCATE 330 -#define AUE_DARWIN_SYSCTL 331 -#define AUE_DARWIN_MLOCK 332 -#define AUE_DARWIN_MUNLOCK 333 -#define AUE_DARWIN_UNDELETE 334 -#define AUE_DARWIN_GETATTRLIST 335 /* Darwin-specific. */ -#define AUE_DARWIN_SETATTRLIST 336 /* Darwin-specific. */ -#define AUE_DARWIN_GETDIRENTRIESATTR 337 /* Darwin-specific. */ -#define AUE_DARWIN_EXCHANGEDATA 338 /* Darwin-specific. */ -#define AUE_DARWIN_SEARCHFS 339 /* Darwin-specific. */ -#define AUE_DARWIN_MINHERIT 340 -#define AUE_DARWIN_SEMCONFIG 341 -#define AUE_DARWIN_SEMOPEN 342 -#define AUE_DARWIN_SEMCLOSE 343 -#define AUE_DARWIN_SEMUNLINK 344 -#define AUE_DARWIN_SHMOPEN 345 -#define AUE_DARWIN_SHMUNLINK 346 -#define AUE_DARWIN_LOADSHFILE 347 /* Darwin-specific. */ -#define AUE_DARWIN_RESETSHFILE 348 /* Darwin-specific. */ -#define AUE_DARWIN_NEWSYSTEMSHREG 349 /* Darwin-specific. */ -#define AUE_DARWIN_PTHREADKILL 350 /* Darwin-specific. */ -#define AUE_DARWIN_PTHREADSIGMASK 351 /* Darwin-specific. */ -#define AUE_DARWIN_AUDITCTL 352 -#define AUE_DARWIN_RFORK 353 -#define AUE_DARWIN_LCHMOD 354 -#define AUE_DARWIN_SWAPOFF 355 -#define AUE_DARWIN_INITPROCESS 356 /* Darwin-specific. */ -#define AUE_DARWIN_MAPFD 357 /* Darwin-specific. */ -#define AUE_DARWIN_TASKFORPID 358 /* Darwin-specific. */ -#define AUE_DARWIN_PIDFORTASK 359 /* Darwin-specific. */ -#define AUE_DARWIN_SYSCTL_NONADMIN 360 -#define AUE_DARWIN_COPYFILE 361 /* Darwin-specific. */ - -/* - * Audit event identifiers added as part of OpenBSM, generally corresponding - * to events in FreeBSD, Darwin, and Linux that were not present in Solaris. - * These often duplicate events added to the Solaris set by Darwin, but use - * event identifiers in a higher range in order to avoid colliding with - * future Solaris additions. - * - * If an event in this section is later added to Solaris, we prefer the - * Solaris event identifier, and add _OPENBSM_ to the OpenBSM-specific - * identifier so that old trails can still be processed, but new trails use - * the Solaris identifier. - */ -#define AUE_GETFSSTAT 43001 -#define AUE_PTRACE 43002 -#define AUE_CHFLAGS 43003 -#define AUE_FCHFLAGS 43004 -#define AUE_PROFILE 43005 -#define AUE_KTRACE 43006 -#define AUE_SETLOGIN 43007 -#define AUE_OPENBSM_REVOKE 43008 /* Solaris event now preferred. */ -#define AUE_UMASK 43009 -#define AUE_MPROTECT 43010 -#define AUE_MKFIFO 43011 -#define AUE_POLL 43012 -#define AUE_FUTIMES 43013 -#define AUE_SETSID 43014 -#define AUE_SETPRIVEXEC 43015 /* Darwin-specific. */ -#define AUE_ADDPROFILE 43016 /* Darwin-specific. */ -#define AUE_KDEBUGTRACE 43017 /* Darwin-specific. */ -#define AUE_KDBUGTRACE AUE_KDEBUGTRACE -#define AUE_OPENBSM_FSTAT 43018 /* Solaris event now preferred. */ -#define AUE_FPATHCONF 43019 -#define AUE_GETDIRENTRIES 43020 -#define AUE_SYSCTL 43021 -#define AUE_MLOCK 43022 -#define AUE_MUNLOCK 43023 -#define AUE_UNDELETE 43024 -#define AUE_GETATTRLIST 43025 /* Darwin-specific. */ -#define AUE_SETATTRLIST 43026 /* Darwin-specific. */ -#define AUE_GETDIRENTRIESATTR 43027 /* Darwin-specific. */ -#define AUE_EXCHANGEDATA 43028 /* Darwin-specific. */ -#define AUE_SEARCHFS 43029 /* Darwin-specific. */ -#define AUE_MINHERIT 43030 -#define AUE_SEMCONFIG 43031 -#define AUE_SEMOPEN 43032 -#define AUE_SEMCLOSE 43033 -#define AUE_SEMUNLINK 43034 -#define AUE_SHMOPEN 43035 -#define AUE_SHMUNLINK 43036 -#define AUE_LOADSHFILE 43037 /* Darwin-specific. */ -#define AUE_RESETSHFILE 43038 /* Darwin-specific. */ -#define AUE_NEWSYSTEMSHREG 43039 /* Darwin-specific. */ -#define AUE_PTHREADKILL 43040 /* Darwin-specific. */ -#define AUE_PTHREADSIGMASK 43041 /* Darwin-specific. */ -#define AUE_AUDITCTL 43042 -#define AUE_RFORK 43043 -#define AUE_LCHMOD 43044 -#define AUE_SWAPOFF 43045 -#define AUE_INITPROCESS 43046 /* Darwin-specific. */ -#define AUE_MAPFD 43047 /* Darwin-specific. */ -#define AUE_TASKFORPID 43048 /* Darwin-specific. */ -#define AUE_PIDFORTASK 43049 /* Darwin-specific. */ -#define AUE_SYSCTL_NONADMIN 43050 -#define AUE_COPYFILE 43051 /* Darwin-specific. */ - -/* - * Events added to OpenBSM for FreeBSD and Linux; may also be used by Darwin - * in the future. - */ -#define AUE_LUTIMES 43052 -#define AUE_LCHFLAGS 43053 /* FreeBSD-specific. */ -#define AUE_SENDFILE 43054 /* BSD/Linux-specific. */ -#define AUE_USELIB 43055 /* Linux-specific. */ -#define AUE_GETRESUID 43056 -#define AUE_SETRESUID 43057 -#define AUE_GETRESGID 43058 -#define AUE_SETRESGID 43059 -#define AUE_WAIT4 43060 /* FreeBSD-specific. */ -#define AUE_LGETFH 43061 /* FreeBSD-specific. */ -#define AUE_FHSTATFS 43062 /* FreeBSD-specific. */ -#define AUE_FHOPEN 43063 /* FreeBSD-specific. */ -#define AUE_FHSTAT 43064 /* FreeBSD-specific. */ -#define AUE_JAIL 43065 /* FreeBSD-specific. */ -#define AUE_EACCESS 43066 /* FreeBSD-specific. */ -#define AUE_KQUEUE 43067 /* FreeBSD-specific. */ -#define AUE_KEVENT 43068 /* FreeBSD-specific. */ -#define AUE_FSYNC 43069 -#define AUE_NMOUNT 43070 /* FreeBSD-specific. */ -#define AUE_BDFLUSH 43071 /* Linux-specific. */ -#define AUE_SETFSUID 43072 /* Linux-specific. */ -#define AUE_SETFSGID 43073 /* Linux-specific. */ -#define AUE_PERSONALITY 43074 /* Linux-specific. */ -#define AUE_SCHED_GETSCHEDULER 43075 /* POSIX.1b. */ -#define AUE_SCHED_SETSCHEDULER 43076 /* POSIX.1b. */ -#define AUE_PRCTL 43077 /* Linux-specific. */ -#define AUE_GETCWD 43078 /* FreeBSD/Linux-specific. */ -#define AUE_CAPGET 43079 /* Linux-specific. */ -#define AUE_CAPSET 43080 /* Linux-specific. */ -#define AUE_PIVOT_ROOT 43081 /* Linux-specific. */ -#define AUE_RTPRIO 43082 /* FreeBSD-specific. */ -#define AUE_SCHED_GETPARAM 43083 /* POSIX.1b. */ -#define AUE_SCHED_SETPARAM 43084 /* POSIX.1b. */ -#define AUE_SCHED_GET_PRIORITY_MAX 43085 /* POSIX.1b. */ -#define AUE_SCHED_GET_PRIORITY_MIN 43086 /* POSIX.1b. */ -#define AUE_SCHED_RR_GET_INTERVAL 43087 /* POSIX.1b. */ -#define AUE_ACL_GET_FILE 43088 /* FreeBSD. */ -#define AUE_ACL_SET_FILE 43089 /* FreeBSD. */ -#define AUE_ACL_GET_FD 43090 /* FreeBSD. */ -#define AUE_ACL_SET_FD 43091 /* FreeBSD. */ -#define AUE_ACL_DELETE_FILE 43092 /* FreeBSD. */ -#define AUE_ACL_DELETE_FD 43093 /* FreeBSD. */ -#define AUE_ACL_CHECK_FILE 43094 /* FreeBSD. */ -#define AUE_ACL_CHECK_FD 43095 /* FreeBSD. */ -#define AUE_ACL_GET_LINK 43096 /* FreeBSD. */ -#define AUE_ACL_SET_LINK 43097 /* FreeBSD. */ -#define AUE_ACL_DELETE_LINK 43098 /* FreeBSD. */ -#define AUE_ACL_CHECK_LINK 43099 /* FreeBSD. */ -#define AUE_SYSARCH 43100 /* FreeBSD. */ -#define AUE_EXTATTRCTL 43101 /* FreeBSD. */ -#define AUE_EXTATTR_GET_FILE 43102 /* FreeBSD. */ -#define AUE_EXTATTR_SET_FILE 43103 /* FreeBSD. */ -#define AUE_EXTATTR_LIST_FILE 43104 /* FreeBSD. */ -#define AUE_EXTATTR_DELETE_FILE 43105 /* FreeBSD. */ -#define AUE_EXTATTR_GET_FD 43106 /* FreeBSD. */ -#define AUE_EXTATTR_SET_FD 43107 /* FreeBSD. */ -#define AUE_EXTATTR_LIST_FD 43108 /* FreeBSD. */ -#define AUE_EXTATTR_DELETE_FD 43109 /* FreeBSD. */ -#define AUE_EXTATTR_GET_LINK 43110 /* FreeBSD. */ -#define AUE_EXTATTR_SET_LINK 43111 /* FreeBSD. */ -#define AUE_EXTATTR_LIST_LINK 43112 /* FreeBSD. */ -#define AUE_EXTATTR_DELETE_LINK 43113 /* FreeBSD. */ -#define AUE_KENV 43114 /* FreeBSD. */ -#define AUE_JAIL_ATTACH 43115 /* FreeBSD. */ -#define AUE_SYSCTL_WRITE 43116 /* FreeBSD. */ -#define AUE_IOPERM 43117 /* Linux. */ -#define AUE_READDIR 43118 /* Linux. */ -#define AUE_IOPL 43119 /* Linux. */ -#define AUE_VM86 43120 /* Linux. */ -#define AUE_MAC_GET_PROC 43121 /* FreeBSD/Darwin. */ -#define AUE_MAC_SET_PROC 43122 /* FreeBSD/Darwin. */ -#define AUE_MAC_GET_FD 43123 /* FreeBSD/Darwin. */ -#define AUE_MAC_GET_FILE 43124 /* FreeBSD/Darwin. */ -#define AUE_MAC_SET_FD 43125 /* FreeBSD/Darwin. */ -#define AUE_MAC_SET_FILE 43126 /* FreeBSD/Darwin. */ -#define AUE_MAC_SYSCALL 43127 /* FreeBSD. */ -#define AUE_MAC_GET_PID 43128 /* FreeBSD/Darwin. */ -#define AUE_MAC_GET_LINK 43129 /* FreeBSD/Darwin. */ -#define AUE_MAC_SET_LINK 43130 /* FreeBSD/Darwin. */ -#define AUE_MAC_EXECVE 43131 /* FreeBSD/Darwin. */ -#define AUE_GETPATH_FROMFD 43132 /* FreeBSD. */ -#define AUE_GETPATH_FROMADDR 43133 /* FreeBSD. */ -#define AUE_MQ_OPEN 43134 /* FreeBSD. */ -#define AUE_MQ_SETATTR 43135 /* FreeBSD. */ -#define AUE_MQ_TIMEDRECEIVE 43136 /* FreeBSD. */ -#define AUE_MQ_TIMEDSEND 43137 /* FreeBSD. */ -#define AUE_MQ_NOTIFY 43138 /* FreeBSD. */ -#define AUE_MQ_UNLINK 43139 /* FreeBSD. */ -#define AUE_LISTEN 43140 /* FreeBSD/Darwin/Linux. */ -#define AUE_MLOCKALL 43141 /* FreeBSD. */ -#define AUE_MUNLOCKALL 43142 /* FreeBSD. */ -#define AUE_CLOSEFROM 43143 /* FreeBSD. */ -#define AUE_FEXECVE 43144 /* FreeBSD. */ -#define AUE_FACCESSAT 43145 /* FreeBSD. */ -#define AUE_FCHMODAT 43146 /* FreeBSD. */ -#define AUE_LINKAT 43147 /* FreeBSD. */ -#define AUE_MKDIRAT 43148 /* FreeBSD. */ -#define AUE_MKFIFOAT 43149 /* FreeBSD. */ -#define AUE_MKNODAT 43150 /* FreeBSD. */ -#define AUE_READLINKAT 43151 /* FreeBSD. */ -#define AUE_SYMLINKAT 43152 /* FreeBSD. */ -#define AUE_MAC_GETFSSTAT 43153 /* Darwin. */ -#define AUE_MAC_GET_MOUNT 43154 /* Darwin. */ -#define AUE_MAC_GET_LCID 43155 /* Darwin. */ -#define AUE_MAC_GET_LCTX 43156 /* Darwin. */ -#define AUE_MAC_SET_LCTX 43157 /* Darwin. */ -#define AUE_MAC_MOUNT 43158 /* Darwin. */ -#define AUE_GETLCID 43159 /* Darwin. */ -#define AUE_SETLCID 43160 /* Darwin. */ -#define AUE_TASKNAMEFORPID 43161 /* Darwin. */ -#define AUE_ACCESS_EXTENDED 43162 /* Darwin. */ -#define AUE_CHMOD_EXTENDED 43163 /* Darwin. */ -#define AUE_FCHMOD_EXTENDED 43164 /* Darwin. */ -#define AUE_FSTAT_EXTENDED 43165 /* Darwin. */ -#define AUE_LSTAT_EXTENDED 43166 /* Darwin. */ -#define AUE_MKDIR_EXTENDED 43167 /* Darwin. */ -#define AUE_MKFIFO_EXTENDED 43168 /* Darwin. */ -#define AUE_OPEN_EXTENDED 43169 /* Darwin. */ -#define AUE_OPEN_EXTENDED_R 43170 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RC 43171 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RT 43172 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RTC 43173 /* Darwin. */ -#define AUE_OPEN_EXTENDED_W 43174 /* Darwin. */ -#define AUE_OPEN_EXTENDED_WC 43175 /* Darwin. */ -#define AUE_OPEN_EXTENDED_WT 43176 /* Darwin. */ -#define AUE_OPEN_EXTENDED_WTC 43177 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RW 43178 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RWC 43179 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RWT 43180 /* Darwin. */ -#define AUE_OPEN_EXTENDED_RWTC 43181 /* Darwin. */ -#define AUE_STAT_EXTENDED 43182 /* Darwin. */ -#define AUE_UMASK_EXTENDED 43183 /* Darwin. */ -#define AUE_OPENAT 43184 /* FreeBSD. */ -#define AUE_POSIX_OPENPT 43185 /* FreeBSD. */ -#define AUE_CAP_NEW 43186 /* TrustedBSD. */ -#define AUE_CAP_RIGHTS_GET 43187 /* TrustedBSD. */ -#define AUE_CAP_GETRIGHTS AUE_CAP_RIGHTS_GET -#define AUE_CAP_ENTER 43188 /* TrustedBSD. */ -#define AUE_CAP_GETMODE 43189 /* TrustedBSD. */ -#define AUE_POSIX_SPAWN 43190 /* Darwin. */ -#define AUE_FSGETPATH 43191 /* Darwin. */ -#define AUE_PREAD 43192 /* Darwin/FreeBSD. */ -#define AUE_PWRITE 43193 /* Darwin/FreeBSD. */ -#define AUE_FSCTL 43194 /* Darwin. */ -#define AUE_FFSCTL 43195 /* Darwin. */ -#define AUE_LPATHCONF 43196 /* FreeBSD. */ -#define AUE_PDFORK 43197 /* FreeBSD. */ -#define AUE_PDKILL 43198 /* FreeBSD. */ -#define AUE_PDGETPID 43199 /* FreeBSD. */ -#define AUE_PDWAIT 43200 /* FreeBSD. */ -#define AUE_WAIT6 43201 /* FreeBSD. */ -#define AUE_CAP_RIGHTS_LIMIT 43202 /* TrustedBSD. */ -#define AUE_CAP_IOCTLS_LIMIT 43203 /* TrustedBSD. */ -#define AUE_CAP_IOCTLS_GET 43204 /* TrustedBSD. */ -#define AUE_CAP_FCNTLS_LIMIT 43205 /* TrustedBSD. */ -#define AUE_CAP_FCNTLS_GET 43206 /* TrustedBSD. */ -#define AUE_BINDAT 43207 /* TrustedBSD. */ -#define AUE_CONNECTAT 43208 /* TrustedBSD. */ -#define AUE_CHFLAGSAT 43209 /* FreeBSD-specific. */ -#define AUE_PREADV 43210 /* FreeBSD-specific. */ -#define AUE_PWRITEV 43211 /* FreeBSD-specific. */ -#define AUE_POSIX_FALLOCATE 43212 /* FreeBSD-specific. */ -#define AUE_AIO_MLOCK 43213 /* FreeBSD-specific. */ -#define AUE_PROCCTL 43214 /* FreeBSD-specific. */ -#define AUE_AIO_READ 43215 /* FreeBSD-specific. */ -#define AUE_AIO_WRITE 43216 /* FreeBSD-specific. */ -#define AUE_AIO_RETURN 43217 /* FreeBSD-specific. */ -#define AUE_AIO_SUSPEND 43218 /* FreeBSD-specific. */ -#define AUE_AIO_CANCEL 43219 /* FreeBSD-specific. */ -#define AUE_AIO_ERROR 43220 /* FreeBSD-specific. */ -#define AUE_AIO_WAITCOMPLETE 43221 /* FreeBSD-specific. */ -#define AUE_AIO_FSYNC 43222 /* FreeBSD-specific. */ -#define AUE_THR_CREATE 43223 /* FreeBSD-specific. */ -#define AUE_THR_NEW 43224 /* FreeBSD-specific. */ -#define AUE_THR_EXIT 43225 /* FreeBSD-specific. */ -#define AUE_THR_KILL 43226 /* FreeBSD-specific. */ -#define AUE_THR_KILL2 43227 /* FreeBSD-specific. */ -#define AUE_SETFIB 43228 /* FreeBSD-specific. */ -#define AUE_LIO_LISTIO 43229 /* FreeBSD-specific. */ -#define AUE_SETUGID 43230 /* FreeBSD-specific. */ -#define AUE_SCTP_PEELOFF 43231 /* FreeBSD-specific. */ -#define AUE_SCTP_GENERIC_SENDMSG 43232 /* FreeBSD-specific. */ -#define AUE_SCTP_GENERIC_RECVMSG 43233 /* FreeBSD-specific. */ -#define AUE_JAIL_GET 43234 /* FreeBSD-specific. */ -#define AUE_JAIL_SET 43235 /* FreeBSD-specific. */ -#define AUE_JAIL_REMOVE 43236 /* FreeBSD-specific. */ -#define AUE_GETLOGINCLASS 43237 /* FreeBSD-specific. */ -#define AUE_SETLOGINCLASS 43238 /* FreeBSD-specific. */ -#define AUE_POSIX_FADVISE 43239 /* FreeBSD-specific. */ -#define AUE_SCTP_GENERIC_SENDMSG_IOV 43240 /* FreeBSD-specific. */ -#define AUE_ABORT2 43241 /* FreeBSD-specific. */ -#define AUE_SEMTIMEDWAIT 43242 /* FreeBSD-specific. */ -#define AUE_SEMDESTROY 43243 /* FreeBSD-specific. */ -#define AUE_SEMGETVALUE 43244 /* FreeBSD-specific. */ -#define AUE_SEMINIT 43245 /* FreeBSD-specific. */ -#define AUE_SEMPOST 43246 /* FreeBSD-specific. */ -#define AUE_SEMTRYWAIT 43247 /* FreeBSD-specific. */ -#define AUE_SEMWAIT 43258 /* FreeBSD-specific. */ -#define AUE_FGETUUID 43259 /* CADETS. */ -#define AUE_GETUUID 43260 /* CADETS. */ -#define AUE_LGETUUID 43261 /* CADETS. */ -#define AUE_EXECVEAT 43262 /* FreeBSD/Linux. */ -#define AUE_SHMRENAME 43263 /* FreeBSD-specific. */ -#define AUE_REALPATHAT 43264 /* FreeBSD-specific. */ -#define AUE_CLOSERANGE 43265 /* FreeBSD-specific. */ -#define AUE_SPECIALFD 43266 /* FreeBSD-specific. */ -#define AUE_AIO_WRITEV 43267 /* FreeBSD-specific. */ -#define AUE_AIO_READV 43268 /* FreeBSD-specific. */ -#define AUE_FSPACECTL 43269 /* FreeBSD-specific. */ -#define AUE_TIMERFD 43270 /* FreeBSD/Linux. */ - -/* - * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the - * normal Solaris BSM identifiers. _O_ refers to it being an old, or compat - * interface. In most cases, Darwin has never implemented these system calls - * but picked up the fields in their system call table from their FreeBSD - * import. Happily, these have different names than the AUE_O* definitions - * in Solaris BSM. - */ -#define AUE_O_CREAT AUE_OPEN_RWTC /* Darwin */ -#define AUE_O_EXECVE AUE_NULL /* Darwin */ -#define AUE_O_SBREAK AUE_NULL /* Darwin */ -#define AUE_O_LSEEK AUE_NULL /* Darwin */ -#define AUE_O_MOUNT AUE_NULL /* Darwin */ -#define AUE_O_UMOUNT AUE_NULL /* Darwin */ -#define AUE_O_STAT AUE_STAT /* Darwin */ -#define AUE_O_LSTAT AUE_LSTAT /* Darwin */ -#define AUE_O_FSTAT AUE_FSTAT /* Darwin */ -#define AUE_O_GETPAGESIZE AUE_NULL /* Darwin */ -#define AUE_O_VREAD AUE_NULL /* Darwin */ -#define AUE_O_VWRITE AUE_NULL /* Darwin */ -#define AUE_O_MMAP AUE_MMAP /* Darwin */ -#define AUE_O_VADVISE AUE_NULL /* Darwin */ -#define AUE_O_VHANGUP AUE_NULL /* Darwin */ -#define AUE_O_VLIMIT AUE_NULL /* Darwin */ -#define AUE_O_WAIT AUE_NULL /* Darwin */ -#define AUE_O_GETHOSTNAME AUE_NULL /* Darwin */ -#define AUE_O_SETHOSTNAME AUE_SYSCTL /* Darwin */ -#define AUE_O_GETDOPT AUE_NULL /* Darwin */ -#define AUE_O_SETDOPT AUE_NULL /* Darwin */ -#define AUE_O_ACCEPT AUE_NULL /* Darwin */ -#define AUE_O_SEND AUE_SENDMSG /* Darwin */ -#define AUE_O_RECV AUE_RECVMSG /* Darwin */ -#define AUE_O_VTIMES AUE_NULL /* Darwin */ -#define AUE_O_SIGVEC AUE_NULL /* Darwin */ -#define AUE_O_SIGBLOCK AUE_NULL /* Darwin */ -#define AUE_O_SIGSETMASK AUE_NULL /* Darwin */ -#define AUE_O_SIGSTACK AUE_NULL /* Darwin */ -#define AUE_O_RECVMSG AUE_RECVMSG /* Darwin */ -#define AUE_O_SENDMSG AUE_SENDMSG /* Darwin */ -#define AUE_O_VTRACE AUE_NULL /* Darwin */ -#define AUE_O_RESUBA AUE_NULL /* Darwin */ -#define AUE_O_RECVFROM AUE_RECVFROM /* Darwin */ -#define AUE_O_SETREUID AUE_SETREUID /* Darwin */ -#define AUE_O_SETREGID AUE_SETREGID /* Darwin */ -#define AUE_O_GETDIRENTRIES AUE_GETDIRENTRIES /* Darwin */ -#define AUE_O_TRUNCATE AUE_TRUNCATE /* Darwin */ -#define AUE_O_FTRUNCATE AUE_FTRUNCATE /* Darwin */ -#define AUE_O_GETPEERNAME AUE_NULL /* Darwin */ -#define AUE_O_GETHOSTID AUE_NULL /* Darwin */ -#define AUE_O_SETHOSTID AUE_NULL /* Darwin */ -#define AUE_O_GETRLIMIT AUE_NULL /* Darwin */ -#define AUE_O_SETRLIMIT AUE_SETRLIMIT /* Darwin */ -#define AUE_O_KILLPG AUE_KILL /* Darwin */ -#define AUE_O_SETQUOTA AUE_NULL /* Darwin */ -#define AUE_O_QUOTA AUE_NULL /* Darwin */ -#define AUE_O_GETSOCKNAME AUE_NULL /* Darwin */ -#define AUE_O_GETDIREENTRIES AUE_GETDIREENTRIES /* Darwin */ -#define AUE_O_ASYNCDAEMON AUE_NULL /* Darwin */ -#define AUE_O_GETDOMAINNAME AUE_NULL /* Darwin */ -#define AUE_O_SETDOMAINNAME AUE_SYSCTL /* Darwin */ -#define AUE_O_PCFS_MOUNT AUE_NULL /* Darwin */ -#define AUE_O_EXPORTFS AUE_NULL /* Darwin */ -#define AUE_O_USTATE AUE_NULL /* Darwin */ -#define AUE_O_WAIT3 AUE_NULL /* Darwin */ -#define AUE_O_RPAUSE AUE_NULL /* Darwin */ -#define AUE_O_GETDENTS AUE_NULL /* Darwin */ - -/* - * Possible desired future values based on review of BSD/Darwin system calls. - */ -#define AUE_ATGETMSG AUE_NULL -#define AUE_ATPUTMSG AUE_NULL -#define AUE_ATSOCKET AUE_NULL -#define AUE_ATPGETREQ AUE_NULL -#define AUE_ATPGETRSP AUE_NULL -#define AUE_ATPSNDREQ AUE_NULL -#define AUE_ATPSNDRSP AUE_NULL -#define AUE_BSDTHREADCREATE AUE_NULL -#define AUE_BSDTHREADTERMINATE AUE_NULL -#define AUE_BSDTHREADREGISTER AUE_NULL -#define AUE_CHUD AUE_NULL -#define AUE_CSOPS AUE_NULL -#define AUE_DUP AUE_NULL -#define AUE_FDATASYNC AUE_NULL -#define AUE_FGETATTRLIST AUE_NULL -#define AUE_FGETXATTR AUE_NULL -#define AUE_FLISTXATTR AUE_NULL -#define AUE_FREMOVEXATTR AUE_NULL -#define AUE_FSETATTRLIST AUE_NULL -#define AUE_FSETXATTR AUE_NULL -#define AUE_FSTATFS64 AUE_NULL -#define AUE_FSTATV AUE_NULL -#define AUE_FSTAT64 AUE_NULL -#define AUE_FSTAT64_EXTENDED AUE_NULL -#define AUE_GCCONTROL AUE_NULL -#define AUE_GETDIRENTRIES64 AUE_NULL -#define AUE_GETDTABLESIZE AUE_NULL -#define AUE_GETEGID AUE_NULL -#define AUE_GETEUID AUE_NULL -#define AUE_GETFSSTAT64 AUE_NULL -#define AUE_GETGID AUE_NULL -#define AUE_GETGROUPS AUE_NULL -#define AUE_GETITIMER AUE_NULL -#define AUE_GETLOGIN AUE_NULL -#define AUE_GETPEERNAME AUE_NULL -#define AUE_GETPGID AUE_NULL -#define AUE_GETPGRP AUE_NULL -#define AUE_GETPID AUE_NULL -#define AUE_GETPPID AUE_NULL -#define AUE_GETPRIORITY AUE_NULL -#define AUE_GETRLIMIT AUE_NULL -#define AUE_GETRUSAGE AUE_NULL -#define AUE_GETSGROUPS AUE_NULL -#define AUE_GETSID AUE_NULL -#define AUE_GETSOCKNAME AUE_NULL -#define AUE_GETTIMEOFDAY AUE_NULL -#define AUE_GETTID AUE_NULL -#define AUE_GETUID AUE_NULL -#define AUE_GETSOCKOPT AUE_NULL -#define AUE_GETWGROUPS AUE_NULL -#define AUE_GETXATTR AUE_NULL -#define AUE_IDENTITYSVC AUE_NULL -#define AUE_INITGROUPS AUE_NULL -#define AUE_IOPOLICYSYS AUE_NULL -#define AUE_ISSETUGID AUE_NULL -#define AUE_LIOLISTIO AUE_NULL -#define AUE_LISTXATTR AUE_NULL -#define AUE_LSTATV AUE_NULL -#define AUE_LSTAT64 AUE_NULL -#define AUE_LSTAT64_EXTENDED AUE_NULL -#define AUE_MADVISE AUE_NULL -#define AUE_MINCORE AUE_NULL -#define AUE_MKCOMPLEX AUE_NULL -#define AUE_MODWATCH AUE_NULL -#define AUE_MSGCL AUE_NULL -#define AUE_MSYNC AUE_NULL -#define AUE_PROCINFO AUE_NULL -#define AUE_PTHREADCANCELED AUE_NULL -#define AUE_PTHREADCHDIR AUE_NULL -#define AUE_PTHREADCONDBROADCAST AUE_NULL -#define AUE_PTHREADCONDDESTORY AUE_NULL -#define AUE_PTHREADCONDINIT AUE_NULL -#define AUE_PTHREADCONDSIGNAL AUE_NULL -#define AUE_PTHREADCONDWAIT AUE_NULL -#define AUE_PTHREADFCHDIR AUE_NULL -#define AUE_PTHREADMARK AUE_NULL -#define AUE_PTHREADMUTEXDESTROY AUE_NULL -#define AUE_PTHREADMUTEXINIT AUE_NULL -#define AUE_PTHREADMUTEXTRYLOCK AUE_NULL -#define AUE_PTHREADMUTEXUNLOCK AUE_NULL -#define AUE_REMOVEXATTR AUE_NULL -#define AUE_SBRK AUE_NULL -#define AUE_SELECT AUE_NULL -#define AUE_SEMWAITSIGNAL AUE_NULL -#define AUE_SETITIMER AUE_NULL -#define AUE_SETSGROUPS AUE_NULL -#define AUE_SETTID AUE_NULL -#define AUE_SETTIDWITHPID AUE_NULL -#define AUE_SETWGROUPS AUE_NULL -#define AUE_SETXATTR AUE_NULL -#define AUE_SHAREDREGIONCHECK AUE_NULL -#define AUE_SHAREDREGIONMAP AUE_NULL -#define AUE_SIGACTION AUE_NULL -#define AUE_SIGALTSTACK AUE_NULL -#define AUE_SIGPENDING AUE_NULL -#define AUE_SIGPROCMASK AUE_NULL -#define AUE_SIGRETURN AUE_NULL -#define AUE_SIGSUSPEND AUE_NULL -#define AUE_SIGWAIT AUE_NULL -#define AUE_SSTK AUE_NULL -#define AUE_STACKSNAPSHOT AUE_NULL -#define AUE_STATFS64 AUE_NULL -#define AUE_STATV AUE_NULL -#define AUE_STAT64 AUE_NULL -#define AUE_STAT64_EXTENDED AUE_NULL -#define AUE_SYNC AUE_NULL -#define AUE_SYSCALL AUE_NULL -#define AUE_TABLE AUE_NULL -#define AUE_VMPRESSUREMONITOR AUE_NULL -#define AUE_WAITEVENT AUE_NULL -#define AUE_WAITID AUE_NULL -#define AUE_WATCHEVENT AUE_NULL -#define AUE_WORKQOPEN AUE_NULL -#define AUE_WORKQOPS AUE_NULL - -#endif /* !_BSM_AUDIT_KEVENTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_record.h b/lib/libc/include/generic-freebsd/bsm/audit_record.h deleted file mode 100644 index b852b002edcbef6758fb249f8c863ae98146b014..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_record.h +++ /dev/null @@ -1,311 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2005-2009 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_RECORD_H_ -#define _BSM_AUDIT_RECORD_H_ - -#include -#include /* struct timeval */ - -/* - * Token type identifiers. - */ -#define AUT_INVALID 0x00 -#define AUT_OTHER_FILE32 0x11 -#define AUT_OHEADER 0x12 -#define AUT_TRAILER 0x13 -#define AUT_HEADER32 0x14 -#define AUT_HEADER32_EX 0x15 -#define AUT_DATA 0x21 -#define AUT_IPC 0x22 -#define AUT_PATH 0x23 -#define AUT_SUBJECT32 0x24 -#define AUT_XATPATH 0x25 -#define AUT_PROCESS32 0x26 -#define AUT_RETURN32 0x27 -#define AUT_TEXT 0x28 -#define AUT_OPAQUE 0x29 -#define AUT_IN_ADDR 0x2a -#define AUT_IP 0x2b -#define AUT_IPORT 0x2c -#define AUT_ARG32 0x2d -#define AUT_SOCKET 0x2e -#define AUT_SEQ 0x2f -#define AUT_ACL 0x30 -#define AUT_ATTR 0x31 -#define AUT_IPC_PERM 0x32 -#define AUT_LABEL 0x33 -#define AUT_GROUPS 0x34 -#define AUT_ACE 0x35 -#define AUT_PRIV 0x38 -#define AUT_UPRIV 0x39 -#define AUT_LIAISON 0x3a -#define AUT_NEWGROUPS 0x3b -#define AUT_EXEC_ARGS 0x3c -#define AUT_EXEC_ENV 0x3d -#define AUT_ATTR32 0x3e -#define AUT_UNAUTH 0x3f -#define AUT_XATOM 0x40 -#define AUT_XOBJ 0x41 -#define AUT_XPROTO 0x42 -#define AUT_XSELECT 0x43 -#define AUT_XCOLORMAP 0x44 -#define AUT_XCURSOR 0x45 -#define AUT_XFONT 0x46 -#define AUT_XGC 0x47 -#define AUT_XPIXMAP 0x48 -#define AUT_XPROPERTY 0x49 -#define AUT_XWINDOW 0x4a -#define AUT_XCLIENT 0x4b -#define AUT_CMD 0x51 -#define AUT_EXIT 0x52 -#define AUT_ZONENAME 0x60 -#define AUT_HOST 0x70 -#define AUT_ARG64 0x71 -#define AUT_RETURN64 0x72 -#define AUT_ATTR64 0x73 -#define AUT_HEADER64 0x74 -#define AUT_SUBJECT64 0x75 -#define AUT_PROCESS64 0x77 -#define AUT_OTHER_FILE64 0x78 -#define AUT_HEADER64_EX 0x79 -#define AUT_SUBJECT32_EX 0x7a -#define AUT_PROCESS32_EX 0x7b -#define AUT_SUBJECT64_EX 0x7c -#define AUT_PROCESS64_EX 0x7d -#define AUT_IN_ADDR_EX 0x7e -#define AUT_SOCKET_EX 0x7f - -/* - * Pre-64-bit BSM, 32-bit tokens weren't explicitly named as '32'. We have - * compatibility defines. - */ -#define AUT_HEADER AUT_HEADER32 -#define AUT_ARG AUT_ARG32 -#define AUT_RETURN AUT_RETURN32 -#define AUT_SUBJECT AUT_SUBJECT32 -#define AUT_PROCESS AUT_PROCESS32 -#define AUT_OTHER_FILE AUT_OTHER_FILE32 - -/* - * The values for the following token ids are not defined by BSM. - * - * XXXRW: Not sure how to handle these in OpenBSM yet, but I'll give them - * names more consistent with Sun's BSM. These originally came from Apple's - * BSM. - */ -#define AUT_SOCKINET32 0x80 /* XXX */ -#define AUT_SOCKINET128 0x81 /* XXX */ -#define AUT_SOCKUNIX 0x82 /* XXX */ - -#define AUT_RIGHTS 0x83 - -/* print values for the arbitrary token */ -#define AUP_BINARY 0 -#define AUP_OCTAL 1 -#define AUP_DECIMAL 2 -#define AUP_HEX 3 -#define AUP_STRING 4 - -/* data-types for the arbitrary token */ -#define AUR_BYTE 0 -#define AUR_CHAR AUR_BYTE -#define AUR_SHORT 1 -#define AUR_INT32 2 -#define AUR_INT AUR_INT32 -#define AUR_INT64 3 - -/* ... and their sizes */ -#define AUR_BYTE_SIZE sizeof(u_char) -#define AUR_CHAR_SIZE AUR_BYTE_SIZE -#define AUR_SHORT_SIZE sizeof(uint16_t) -#define AUR_INT32_SIZE sizeof(uint32_t) -#define AUR_INT_SIZE AUR_INT32_SIZE -#define AUR_INT64_SIZE sizeof(uint64_t) - -/* Modifiers for the header token */ -#define PAD_NOTATTR 0x4000 /* nonattributable event */ -#define PAD_FAILURE 0x8000 /* fail audit event */ - -#define AUDIT_MAX_GROUPS 16 - -/* - * A number of BSM versions are floating around and defined. Here are - * constants for them. OpenBSM uses the same token types, etc, used in the - * Solaris BSM version, but has a separate version number in order to - * identify a potentially different event identifier name space. - */ -#define AUDIT_HEADER_VERSION_OLDDARWIN 1 /* In retrospect, a mistake. */ -#define AUDIT_HEADER_VERSION_SOLARIS 2 -#define AUDIT_HEADER_VERSION_TSOL25 3 -#define AUDIT_HEADER_VERSION_TSOL 4 -#define AUDIT_HEADER_VERSION_OPENBSM10 10 -#define AUDIT_HEADER_VERSION_OPENBSM11 11 -#define AUDIT_HEADER_VERSION_OPENBSM AUDIT_HEADER_VERSION_OPENBSM11 - -#define AUT_TRAILER_MAGIC 0xb105 - -/* BSM library calls */ - -__BEGIN_DECLS - -struct in_addr; -struct in6_addr; -struct ip; -struct ipc_perm; -struct kevent; -struct sockaddr; -struct sockaddr_in; -struct sockaddr_in6; -struct sockaddr_un; -#if defined(_KERNEL) || defined(KERNEL) -struct vnode_au_info; -#endif - -#ifndef _CAP_RIGHTS_T_DECLARED -#define _CAP_RIGHTS_T_DECLARED -struct cap_rights; - -typedef struct cap_rights cap_rights_t; -#endif - -int au_open(void); -int au_write(int d, token_t *m); -int au_close(int d, int keep, short event); -int au_close_buffer(int d, short event, u_char *buffer, size_t *buflen); -int au_close_token(token_t *tok, u_char *buffer, size_t *buflen); - -token_t *au_to_file(const char *file, struct timeval tm); - -token_t *au_to_header32_tm(int rec_size, au_event_t e_type, au_emod_t e_mod, - struct timeval tm); -token_t *au_to_header32_ex_tm(int rec_size, au_event_t e_type, au_emod_t e_mod, - struct timeval tm, struct auditinfo_addr *aia); -token_t *au_to_header64_tm(int rec_size, au_event_t e_type, au_emod_t e_mod, - struct timeval tm); -#if !defined(KERNEL) && !defined(_KERNEL) -token_t *au_to_header(int rec_size, au_event_t e_type, au_emod_t e_mod); -token_t *au_to_header_ex(int rec_size, au_event_t e_type, au_emod_t e_mod); -token_t *au_to_header32(int rec_size, au_event_t e_type, au_emod_t e_mod); -token_t *au_to_header64(int rec_size, au_event_t e_type, au_emod_t e_mod); -token_t *au_to_header32_ex(int rec_size, au_event_t e_type, au_emod_t e_mod); -#endif - -token_t *au_to_me(void); -token_t *au_to_arg(char n, const char *text, uint32_t v); -token_t *au_to_arg32(char n, const char *text, uint32_t v); -token_t *au_to_arg64(char n, const char *text, uint64_t v); - -#if defined(_KERNEL) || defined(KERNEL) -token_t *au_to_attr(struct vnode_au_info *vni); -token_t *au_to_attr32(struct vnode_au_info *vni); -token_t *au_to_attr64(struct vnode_au_info *vni); -#endif - -token_t *au_to_data(char unit_print, char unit_type, char unit_count, - const char *p); -token_t *au_to_exit(int retval, int err); -token_t *au_to_groups(int *groups); -token_t *au_to_newgroups(uint16_t n, gid_t *groups); -token_t *au_to_in_addr(struct in_addr *internet_addr); -token_t *au_to_in_addr_ex(struct in6_addr *internet_addr); -token_t *au_to_ip(struct ip *ip); -token_t *au_to_ipc(char type, int id); -token_t *au_to_ipc_perm(struct ipc_perm *perm); -token_t *au_to_iport(uint16_t iport); -token_t *au_to_opaque(const char *data, uint16_t bytes); -token_t *au_to_path(const char *path); -token_t *au_to_privset(char *privtypestr, char *privstr); -token_t *au_to_process(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_process32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_process64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_process_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); -token_t *au_to_process32_ex(au_id_t auid, uid_t euid, gid_t egid, - uid_t ruid, gid_t rgid, pid_t pid, au_asid_t sid, - au_tid_addr_t *tid); -token_t *au_to_process64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); -token_t *au_to_rights(cap_rights_t *rightsp); -token_t *au_to_return(char status, uint32_t ret); -token_t *au_to_return32(char status, uint32_t ret); -token_t *au_to_return64(char status, uint64_t ret); -token_t *au_to_seq(long audit_count); -token_t *au_to_socket_ex(u_short so_domain, u_short so_type, - struct sockaddr *sa_local, struct sockaddr *sa_remote); -token_t *au_to_sock_inet(struct sockaddr_in *so); -token_t *au_to_sock_inet32(struct sockaddr_in *so); -token_t *au_to_sock_inet128(struct sockaddr_in6 *so); -token_t *au_to_sock_unix(struct sockaddr_un *so); -token_t *au_to_subject(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_subject32(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_subject64(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_t *tid); -token_t *au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); -token_t *au_to_subject32_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); -token_t *au_to_subject64_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, - gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid); -#if defined(_KERNEL) || defined(KERNEL) -token_t *au_to_exec_args(char *args, int argc); -token_t *au_to_exec_env(char *envs, int envc); -#else -token_t *au_to_exec_args(char **argv); -token_t *au_to_exec_env(char **envp); -#endif -token_t *au_to_text(const char *text); -token_t *au_to_kevent(struct kevent *kev); -token_t *au_to_trailer(int rec_size); -token_t *au_to_upriv(char sorf, char *priv); -token_t *au_to_zonename(const char *zonename); - -/* - * BSM library routines for converting between local and BSM constant spaces. - */ -int au_bsm_to_domain(u_short bsm_domain, int *local_domainp); -int au_bsm_to_errno(u_char bsm_error, int *errorp); -int au_bsm_to_fcntl_cmd(u_short bsm_fcntl_cmd, int *local_fcntl_cmdp); -int au_bsm_to_socket_type(u_short bsm_socket_type, - int *local_socket_typep); -u_short au_domain_to_bsm(int local_domain); -u_char au_errno_to_bsm(int local_errno); -u_short au_fcntl_cmd_to_bsm(int local_fcntl_command); -u_short au_socket_type_to_bsm(int local_socket_type); - -__END_DECLS - -#endif /* ! _BSM_AUDIT_RECORD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/bsm/audit_socket_type.h b/lib/libc/include/generic-freebsd/bsm/audit_socket_type.h deleted file mode 100644 index b64992a062af7abbfd255b5d62eb4559ce5619e6..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/bsm/audit_socket_type.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2008 Apple Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _BSM_AUDIT_SOCKET_TYPE_H_ -#define _BSM_AUDIT_SOCKET_TYPE_H_ - -/* - * BSM socket type constants. - */ -#define BSM_SOCK_DGRAM 1 -#define BSM_SOCK_STREAM 2 -#define BSM_SOCK_RAW 4 -#define BSM_SOCK_RDM 5 -#define BSM_SOCK_SEQPACKET 6 - -#define BSM_SOCK_UNKNOWN 500 - -#endif /* !_BSM_AUDIT_SOCKET_TYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/cam/cam.h b/lib/libc/include/generic-freebsd/cam/cam.h index c5167575593514d151bca5834dc6ba144e85c168..dac54a16ac63e73424b43722532fb7977976097f 100644 --- a/lib/libc/include/generic-freebsd/cam/cam.h +++ b/lib/libc/include/generic-freebsd/cam/cam.h @@ -35,9 +35,9 @@ #include "opt_cam.h" #endif -#include #ifndef _KERNEL #include +#include #endif typedef u_int path_id_t; @@ -350,6 +350,11 @@ typedef enum { CAM_EAF_PRINT_RESULT = 0x20 } cam_error_ata_flags; +typedef enum { + CAM_ENF_PRINT_NONE = 0x00, + CAM_ENF_PRINT_STATUS = 0x10, +} cam_error_nvme_flags; + typedef enum { CAM_STRVIS_FLAG_NONE = 0x00, CAM_STRVIS_FLAG_NONASCII_MASK = 0x03, diff --git a/lib/libc/include/generic-freebsd/cam/cam_ccb.h b/lib/libc/include/generic-freebsd/cam/cam_ccb.h index 9cfb694452bbb6b9d55e590ba76fac2d6dfbe9af..93d5d843d834cdaab12e329a4c9413c5a471b58c 100644 --- a/lib/libc/include/generic-freebsd/cam/cam_ccb.h +++ b/lib/libc/include/generic-freebsd/cam/cam_ccb.h @@ -32,7 +32,6 @@ #define _CAM_CAM_CCB_H 1 #include -#include #include #include #ifndef _KERNEL @@ -298,15 +297,18 @@ typedef enum { XPORT_SRP, /* SCSI RDMA Protocol */ XPORT_NVME, /* NVMe over PCIe */ XPORT_MMCSD, /* MMC, SD, SDIO card */ + XPORT_NVMF, /* NVMe over Fabrics */ + XPORT_UFSHCI, /* Universal Flash Storage Host Interface */ } cam_xport; -#define XPORT_IS_NVME(t) ((t) == XPORT_NVME) +#define XPORT_IS_NVME(t) ((t) == XPORT_NVME || (t) == XPORT_NVMF) #define XPORT_IS_ATA(t) ((t) == XPORT_ATA || (t) == XPORT_SATA) #define XPORT_IS_SCSI(t) ((t) != XPORT_UNKNOWN && \ (t) != XPORT_UNSPECIFIED && \ !XPORT_IS_ATA(t) && !XPORT_IS_NVME(t)) #define XPORT_DEVSTAT_TYPE(t) (XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \ XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \ + XPORT_IS_NVME(t) ? DEVSTAT_TYPE_IF_NVME : \ DEVSTAT_TYPE_IF_OTHER) #define PROTO_VERSION_UNKNOWN (UINT_MAX - 1) @@ -653,6 +655,12 @@ struct ccb_pathinq_settings_nvme { _Static_assert(sizeof(struct ccb_pathinq_settings_nvme) == 64, "ccb_pathinq_settings_nvme too big"); +struct ccb_pathinq_settings_nvmf { + uint32_t nsid; /* Namespace ID for this path */ + uint8_t trtype; + char dev_name[NVME_DEV_NAME_LEN]; /* nvme controller dev name for this device */ +}; + #define PATHINQ_SETTINGS_SIZE 128 struct ccb_pathinq { @@ -684,6 +692,7 @@ struct ccb_pathinq { struct ccb_pathinq_settings_fc fc; struct ccb_pathinq_settings_sas sas; struct ccb_pathinq_settings_nvme nvme; + struct ccb_pathinq_settings_nvmf nvmf; char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]; } xport_specific; u_int maxio; /* Max supported I/O size, in bytes. */ @@ -1050,6 +1059,31 @@ struct ccb_trans_settings_nvme uint8_t max_speed; /* PCIe generation for each lane */ }; +struct ccb_trans_settings_nvmf +{ + u_int valid; /* Which fields to honor */ +#define CTS_NVMF_VALID_TRTYPE 0x01 + uint8_t trtype; +}; + +struct ccb_trans_settings_ufshci +{ + u_int valid; /* Which fields to honor */ + /* + * Ensure the validity of the information for the Unipro link + * (GEAR, SPEED, LANE) + */ +#define CTS_UFSHCI_VALID_LINK 0x01 + uint32_t speed; + uint8_t hs_gear; /* High Speed Gear (G1, G2, G3...) */ + uint8_t tx_lanes; + uint8_t rx_lanes; + uint8_t max_hs_gear; /* Maximum HS Gear */ + uint8_t max_tx_lanes; + uint8_t max_rx_lanes; +}; + + #include struct ccb_trans_settings_mmc { struct mmc_ios ios; @@ -1122,6 +1156,8 @@ struct ccb_trans_settings { struct ccb_trans_settings_pata ata; struct ccb_trans_settings_sata sata; struct ccb_trans_settings_nvme nvme; + struct ccb_trans_settings_nvmf nvmf; + struct ccb_trans_settings_ufshci ufshci; } xport_specific; }; @@ -1488,6 +1524,7 @@ cam_fill_mmcio(struct ccb_mmcio *mmcio, uint32_t retries, mmcio->cmd.opcode = mmc_opcode; mmcio->cmd.arg = mmc_arg; mmcio->cmd.flags = mmc_flags; + mmcio->cmd.error = 0; mmcio->stop.opcode = 0; mmcio->stop.arg = 0; mmcio->stop.flags = 0; diff --git a/lib/libc/include/generic-freebsd/cam/cam_debug.h b/lib/libc/include/generic-freebsd/cam/cam_debug.h index 42694db2607a65756f7d9453bb1fb588fc668d4e..33c248cbd3d01fc3e7800cd253f94d6d159b6854 100644 --- a/lib/libc/include/generic-freebsd/cam/cam_debug.h +++ b/lib/libc/include/generic-freebsd/cam/cam_debug.h @@ -81,57 +81,46 @@ extern uint32_t cam_dflags; /* Printf delay value (to prevent scrolling) */ extern uint32_t cam_debug_delay; +/* Helper routines -- helps conserve stack */ +struct cam_ed; +void xpt_cam_path_debug(struct cam_path *path, const char *fmt, ...); +void xpt_cam_dev_debug(struct cam_ed *dev, const char *fmt, ...); +void xpt_cam_debug(const char *fmt, ...); + +/* Stupid macro to remove a layer of parens */ +#define _CAM_X(...) __VA_ARGS__ + /* Debugging macros. */ -#define CAM_DEBUGGED(path, flag) \ - (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \ - && (cam_dpath != NULL) \ - && (xpt_path_comp(cam_dpath, path) >= 0) \ - && (xpt_path_comp(cam_dpath, path) < 2)) +#define CAM_DEBUGGED(path, flag) \ + (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \ + && (cam_dpath != NULL) \ + && (xpt_path_comp(cam_dpath, (path)) >= 0) \ + && (xpt_path_comp(cam_dpath, (path)) < 2)) -#define CAM_DEBUG(path, flag, printfargs) \ - if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \ - && (cam_dpath != NULL) \ - && (xpt_path_comp(cam_dpath, path) >= 0) \ - && (xpt_path_comp(cam_dpath, path) < 2)) { \ - xpt_print_path(path); \ - printf printfargs; \ - if (cam_debug_delay != 0) \ - DELAY(cam_debug_delay); \ +#define CAM_DEBUG(path, flag, printfargs) \ + if (CAM_DEBUGGED(path, flag)) { \ + xpt_cam_path_debug(path, _CAM_X printfargs); \ } -#define CAM_DEBUG_DEV(dev, flag, printfargs) \ - if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \ - && (cam_dpath != NULL) \ - && (xpt_path_comp_dev(cam_dpath, dev) >= 0) \ - && (xpt_path_comp_dev(cam_dpath, dev) < 2)) { \ - xpt_print_device(dev); \ - printf printfargs; \ - if (cam_debug_delay != 0) \ - DELAY(cam_debug_delay); \ +#define CAM_DEBUG_DEV(dev, flag, printfargs) \ + if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \ + && (cam_dpath != NULL) \ + && (xpt_path_comp_dev(cam_dpath, (dev)) >= 0) \ + && (xpt_path_comp_dev(cam_dpath, (dev)) < 2)) { \ + xpt_cam_dev_debug(dev, _CAM_X printfargs); \ } -#define CAM_DEBUG_PRINT(flag, printfargs) \ - if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \ - printf("cam_debug: "); \ - printf printfargs; \ - if (cam_debug_delay != 0) \ - DELAY(cam_debug_delay); \ - } - -#define CAM_DEBUG_PATH_PRINT(flag, path, printfargs) \ - if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \ - xpt_print(path, "cam_debug: "); \ - printf printfargs; \ - if (cam_debug_delay != 0) \ - DELAY(cam_debug_delay); \ +#define CAM_DEBUG_PRINT(flag, printfargs) \ + if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \ + xpt_cam_debug(_CAM_X printfargs); \ } #else /* !_KERNEL */ #define CAM_DEBUGGED(A, B) 0 #define CAM_DEBUG(A, B, C) +#define CAM_DEBUG_DEV(A, B, C) #define CAM_DEBUG_PRINT(A, B) -#define CAM_DEBUG_PATH_PRINT(A, B, C) #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/cam/cam_iosched.h b/lib/libc/include/generic-freebsd/cam/cam_iosched.h index 332152858e518f9409a1312ebe5259b7a0a7f9e4..3c9e3cadc121d536f71fe333e6efd112e8aa9f86 100644 --- a/lib/libc/include/generic-freebsd/cam/cam_iosched.h +++ b/lib/libc/include/generic-freebsd/cam/cam_iosched.h @@ -79,8 +79,10 @@ cam_iosched_sbintime_t(uintptr_t delta) } typedef void (*cam_iosched_latfcn_t)(void *, sbintime_t, struct bio *); +typedef void (*cam_iosched_schedule_t)(struct cam_periph *periph); -int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph); +int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph, + const struct disk *dp, cam_iosched_schedule_t schedfnp); void cam_iosched_fini(struct cam_iosched_softc *); void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *); struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc); diff --git a/lib/libc/include/generic-freebsd/cam/cam_sim.h b/lib/libc/include/generic-freebsd/cam/cam_sim.h index 07db069f9f695e9b06b752a1dfb094ea45927618..3a19639a5c3d46aecd95f8027c3cdb3f0c1d1655 100644 --- a/lib/libc/include/generic-freebsd/cam/cam_sim.h +++ b/lib/libc/include/generic-freebsd/cam/cam_sim.h @@ -60,15 +60,6 @@ struct cam_sim * cam_sim_alloc(sim_action_func sim_action, int max_dev_transactions, int max_tagged_dev_transactions, struct cam_devq *queue); -struct cam_sim * cam_sim_alloc_dev(sim_action_func sim_action, - sim_poll_func sim_poll, - const char *sim_name, - void *softc, - device_t dev, - struct mtx *mtx, - int max_dev_transactions, - int max_tagged_dev_transactions, - struct cam_devq *queue); void cam_sim_free(struct cam_sim *sim, int free_devq); void cam_sim_hold(struct cam_sim *sim); void cam_sim_release(struct cam_sim *sim); diff --git a/lib/libc/include/generic-freebsd/cam/cam_xpt.h b/lib/libc/include/generic-freebsd/cam/cam_xpt.h index 3cfb6148c3b08ea717b1e09342e03a086b5f53c3..6d25ebd507c061c12889fa37b3bc01e7119aae40 100644 --- a/lib/libc/include/generic-freebsd/cam/cam_xpt.h +++ b/lib/libc/include/generic-freebsd/cam/cam_xpt.h @@ -33,16 +33,15 @@ #define _CAM_CAM_XPT_H 1 #ifdef _KERNEL -#include #include #endif +#include /* Forward Declarations */ union ccb; struct cam_periph; struct cam_ed; struct cam_sim; -struct sbuf; /* * Definition of a CAM path. Paths are created from bus, target, and lun ids @@ -113,7 +112,6 @@ struct cam_sim *xpt_path_sim(struct cam_path *path); struct cam_periph *xpt_path_periph(struct cam_path *path); device_t xpt_path_sim_device(const struct cam_path *path); void xpt_print_path(struct cam_path *path); -void xpt_print_device(struct cam_ed *device); void xpt_print(struct cam_path *path, const char *fmt, ...); void xpt_async(uint32_t async_code, struct cam_path *path, void *async_arg); @@ -147,19 +145,31 @@ uint32_t xpt_poll_setup(union ccb *start_ccb); void xpt_sim_poll(struct cam_sim *sim); /* - * Perform a path inquiry at the request priority. The bzero may be - * unnecessary. + * Perform a path inquiry. bzero may be redundant for allocated CCBs, but for + * the on-stack CCBs it's required. */ static inline void xpt_path_inq(struct ccb_pathinq *cpi, struct cam_path *path) { - bzero(cpi, sizeof(*cpi)); - xpt_setup_ccb(&cpi->ccb_h, path, CAM_PRIORITY_NORMAL); + xpt_setup_ccb(&cpi->ccb_h, path, CAM_PRIORITY_NONE); cpi->ccb_h.func_code = XPT_PATH_INQ; xpt_action((union ccb *)cpi); } +/* + * Perform get device type. bzero may be redundant for allocated CCBs, but for + * the on-stack CCBs it's required. + */ +static inline void +xpt_gdev_type(struct ccb_getdev *cgd, struct cam_path *path) +{ + bzero(cgd, sizeof(*cgd)); + xpt_setup_ccb(&cgd->ccb_h, path, CAM_PRIORITY_NONE); + cgd->ccb_h.func_code = XPT_GDEV_TYPE; + xpt_action((union ccb *)cgd); +} + #endif /* _KERNEL */ #endif /* _CAM_CAM_XPT_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/cam/nvme/nvme_all.h b/lib/libc/include/generic-freebsd/cam/nvme/nvme_all.h index 6ba15263c01a6784b915fb1200bf568e479a5c17..694439e4f50e215c72a22d723ff93f447678b71e 100644 --- a/lib/libc/include/generic-freebsd/cam/nvme/nvme_all.h +++ b/lib/libc/include/generic-freebsd/cam/nvme/nvme_all.h @@ -42,10 +42,10 @@ struct sbuf; void nvme_print_ident(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); void nvme_print_ident_short(const struct nvme_controller_data *, const struct nvme_namespace_data *, struct sbuf *); -const char *nvme_op_string(const struct nvme_command *, int admin); -const char *nvme_cmd_string(const struct nvme_command *, char *, size_t); void nvme_cmd_sbuf(const struct nvme_command *, struct sbuf *sb); int nvme_command_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb); +const char *nvme_command_string(struct ccb_nvmeio *nvmeio, char *, size_t); +int nvme_status_sbuf(struct ccb_nvmeio *nvmeio, struct sbuf *sb); const void *nvme_get_identify_cntrl(struct cam_periph *); const void *nvme_get_identify_ns(struct cam_periph *); diff --git a/lib/libc/include/generic-freebsd/cam/scsi/scsi_all.h b/lib/libc/include/generic-freebsd/cam/scsi/scsi_all.h index f09d991bce469ab9ab6c740aae2489a01a3a5be4..7a96a072e8313e2d69c7e5791aa02aac963126b7 100644 --- a/lib/libc/include/generic-freebsd/cam/scsi/scsi_all.h +++ b/lib/libc/include/generic-freebsd/cam/scsi/scsi_all.h @@ -1,18 +1,12 @@ -/*- - * Largely written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems. +/* + * Copyright (c) 1997-2017 Kenneth D. Merry + * Copyright (c) 2012-2020 Alexander Motin + * Copyright (c) 1997-2011 Justin T. Gibbs * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. + * SPDX-License-Identifier: BSD-2-Clause * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 + * Original scsi_all.h from 386BSD was by Julian Elischer at TRW Financial + * Services has been transformed into a new work by subsequent contributors. */ /* @@ -22,10 +16,9 @@ #ifndef _SCSI_SCSI_ALL_H #define _SCSI_SCSI_ALL_H 1 -#include #ifdef _KERNEL #include -#include +#include #else #include #endif diff --git a/lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h b/lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h index e268a926dd3313852ac5321b99b35eb06bf4ea51..6531075c831412e7438b68bf46d3bd4ac61b3bf9 100644 --- a/lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h +++ b/lib/libc/include/generic-freebsd/cam/scsi/scsi_ch.h @@ -64,7 +64,6 @@ #ifndef _SCSI_SCSI_CH_H #define _SCSI_SCSI_CH_H 1 -#include /* * SCSI command format diff --git a/lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h b/lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h index f53f4c6b44e06fa7319f0ef4846b03f0cfa96e42..05cccfcf3ff18203d460023d7415a00e00c8da36 100644 --- a/lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h +++ b/lib/libc/include/generic-freebsd/cam/scsi/scsi_da.h @@ -50,7 +50,6 @@ #ifndef _SCSI_SCSI_DA_H #define _SCSI_SCSI_DA_H 1 -#include struct scsi_rezero_unit { diff --git a/lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h b/lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h index 4b1e905001fef03b77ab1b56c278a2307314d8d0..be4bc6fe359300fc358e0b4b4658efda1affdf04 100644 --- a/lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h +++ b/lib/libc/include/generic-freebsd/cam/scsi/scsi_sa.h @@ -33,7 +33,6 @@ #ifndef _SCSI_SCSI_SA_H #define _SCSI_SCSI_SA_H 1 -#include struct scsi_read_block_limits { diff --git a/lib/libc/include/generic-freebsd/crypto/cryptodev.h b/lib/libc/include/generic-freebsd/crypto/cryptodev.h index d43dc925e80ab74bc3a75600b13137dbc80f771b..46716b60f8736762559e7c2d086e950a03d5b906 100644 --- a/lib/libc/include/generic-freebsd/crypto/cryptodev.h +++ b/lib/libc/include/generic-freebsd/crypto/cryptodev.h @@ -433,7 +433,7 @@ struct cryptop { int crp_flags; #define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ -#define CRYPTO_F_DONE 0x0020 /* Operation completed */ +#define CRYPTO_F_DONE 0x0020 /* Deprecated, do not use */ #define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ #define CRYPTO_F_ASYNC_ORDERED 0x0100 /* Completions must happen in order */ #define CRYPTO_F_IV_SEPARATE 0x0200 /* Use crp_iv[] as IV. */ diff --git a/lib/libc/include/generic-freebsd/ctype.h b/lib/libc/include/generic-freebsd/ctype.h index db8e17fbe4eda16259eaa9e5b392c062caa6aa80..9ba19981b78c3f2b85aa8be0a47b1f26aa3f2deb 100644 --- a/lib/libc/include/generic-freebsd/ctype.h +++ b/lib/libc/include/generic-freebsd/ctype.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ctype.h 8.4 (Berkeley) 1/21/94 */ #ifndef _CTYPE_H_ diff --git a/lib/libc/include/generic-freebsd/db.h b/lib/libc/include/generic-freebsd/db.h index 1447927ec334b1f9dd0a33ad1c045dffe4a9429b..dba042d910f1dab4a14758d44b66edc9e74cc041 100644 --- a/lib/libc/include/generic-freebsd/db.h +++ b/lib/libc/include/generic-freebsd/db.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)db.h 8.7 (Berkeley) 6/16/94 */ #ifndef _DB_H_ diff --git a/lib/libc/include/generic-freebsd/dev/ciss/cissreg.h b/lib/libc/include/generic-freebsd/dev/ciss/cissreg.h index 8939fd796fa3d7073d51e8d1d1626cfad348e7fa..e4d6adbe392e3048a34d5957bd8e87149ad1a908 100644 --- a/lib/libc/include/generic-freebsd/dev/ciss/cissreg.h +++ b/lib/libc/include/generic-freebsd/dev/ciss/cissreg.h @@ -684,7 +684,7 @@ struct ciss_bmic_id_table { u_int8_t percent_write_cache; /* Percent of memory allocated to write cache */ u_int16_t daughterboard_size_mb; /* Total size (MB) of cache board */ u_int8_t cache_batter_count; /* Number of cache batteries */ - u_int16_t total_controller_mem_mb; /* Total size (MB) of atttached memory */ + u_int16_t total_controller_mem_mb; /* Total size (MB) of attached memory */ u_int8_t more_controller_flags; /* Additional controller flags byte */ u_int8_t x_board_host_i2c_rev; /* 2nd byte of 3 byte autorev field */ u_int8_t battery_pic_rev; /* BBWC PIC revision */ diff --git a/lib/libc/include/generic-freebsd/dev/ciss/cissvar.h b/lib/libc/include/generic-freebsd/dev/ciss/cissvar.h index 10cb78629883dce3dd8ab13958d3e47db5db2065..eb96e442bf569fceb9c7bae2c1a489a9e13fc751 100644 --- a/lib/libc/include/generic-freebsd/dev/ciss/cissvar.h +++ b/lib/libc/include/generic-freebsd/dev/ciss/cissvar.h @@ -184,7 +184,7 @@ struct ciss_softc { /* bus connections */ device_t ciss_dev; /* bus attachment */ - struct cdev *ciss_dev_t; /* control device */ + struct cdev *ciss_dev_t; /* control device */ struct resource *ciss_regs_resource; /* register interface window */ int ciss_regs_rid; /* resource ID */ @@ -236,6 +236,7 @@ struct ciss_softc int ciss_max_bus_number; /* maximum bus number */ int ciss_max_logical_bus; int ciss_max_physical_bus; + int ciss_max_physical_target; /* highest physical target number */ struct cam_devq *ciss_cam_devq; struct cam_sim **ciss_cam_sim; diff --git a/lib/libc/include/generic-freebsd/dev/firewire/firewirereg.h b/lib/libc/include/generic-freebsd/dev/firewire/firewirereg.h index dfb973308a0d57d1fd729e214d184acfe901b346..01381dce637a7780f3209ea5a800c9a7c6c004cc 100644 --- a/lib/libc/include/generic-freebsd/dev/firewire/firewirereg.h +++ b/lib/libc/include/generic-freebsd/dev/firewire/firewirereg.h @@ -293,7 +293,7 @@ extern int firewire_debug; extern devclass_t firewire_devclass; extern int firewire_phydma_enable; -#define FWPRI ((PZERO + 8) | PCATCH) +#define FWPRI (PWAIT | PCATCH) #define CALLOUT_INIT(x) callout_init(x, 1 /* mpsafe */) diff --git a/lib/libc/include/generic-freebsd/dev/hid/hid.h b/lib/libc/include/generic-freebsd/dev/hid/hid.h index b3017cdab1c8f8ca00c8feda30bfa007c9ca2959..8e55116085e3026b851f68024091fb51ecb4eca7 100644 --- a/lib/libc/include/generic-freebsd/dev/hid/hid.h +++ b/lib/libc/include/generic-freebsd/dev/hid/hid.h @@ -57,6 +57,7 @@ #define HUP_SCALE 0x008c #define HUP_CAMERA_CONTROL 0x0090 #define HUP_ARCADE 0x0091 +#define HUP_FIDO 0xf1d0 #define HUP_MICROSOFT 0xff00 /* Usages, generic desktop */ @@ -161,6 +162,9 @@ #define HUC_HEADPHONE 0x0005 #define HUC_AC_PAN 0x0238 +/* Usages, FIDO */ +#define HUF_U2FHID 0x0001 + #define HID_USAGE2(p,u) (((p) << 16) | (u)) #define HID_GET_USAGE(u) ((u) & 0xffff) #define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff) @@ -233,31 +237,31 @@ struct hid_location { struct hid_item { /* Global */ - int32_t _usage_page; + uint32_t _usage_page; int32_t logical_minimum; int32_t logical_maximum; int32_t physical_minimum; int32_t physical_maximum; - int32_t unit_exponent; - int32_t unit; - int32_t report_ID; + uint32_t unit_exponent; + uint32_t unit; + uint32_t report_ID; /* Local */ int nusages; union { - int32_t usage; - int32_t usages[HID_ITEM_MAXUSAGE]; + uint32_t usage; + uint32_t usages[HID_ITEM_MAXUSAGE]; }; - int32_t usage_minimum; - int32_t usage_maximum; - int32_t designator_index; - int32_t designator_minimum; - int32_t designator_maximum; - int32_t string_index; - int32_t string_minimum; - int32_t string_maximum; - int32_t set_delimiter; + uint32_t usage_minimum; + uint32_t usage_maximum; + uint32_t designator_index; + uint32_t designator_minimum; + uint32_t designator_maximum; + uint32_t string_index; + uint32_t string_minimum; + uint32_t string_maximum; + uint32_t set_delimiter; /* Misc */ - int32_t collection; + uint32_t collection; int collevel; enum hid_kind kind; uint32_t flags; diff --git a/lib/libc/include/generic-freebsd/dev/hid/hidraw.h b/lib/libc/include/generic-freebsd/dev/hid/hidraw.h index c7df23a8e6225b8bd669093521a42cf9f0934147..f36e3d46a0ad611042f1bada5116c8f8478ac6d6 100644 --- a/lib/libc/include/generic-freebsd/dev/hid/hidraw.h +++ b/lib/libc/include/generic-freebsd/dev/hid/hidraw.h @@ -92,5 +92,9 @@ struct hidraw_devinfo { #define HIDIOCSFEATURE(len) _IOC(IOC_IN, 'U', 35, len) #define HIDIOCGFEATURE(len) _IOC(IOC_INOUT, 'U', 36, len) #define HIDIOCGRAWUNIQ(len) _IOC(IOC_OUT, 'U', 37, len) +#define HIDIOCSINPUT(len) _IOC(IOC_IN, 'U', 38, len) +#define HIDIOCGINPUT(len) _IOC(IOC_INOUT, 'U', 39, len) +#define HIDIOCSOUTPUT(len) _IOC(IOC_IN, 'U', 40, len) +#define HIDIOCGOUTPUT(len) _IOC(IOC_INOUT, 'U', 41, len) #endif /* _HID_HIDRAW_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_amd.h b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_amd.h index dcdd27061277228ddf82516e1787af86f7bd6453..e2bf15f734cff4741bf6b089d9e92ca5e0e306b1 100644 --- a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_amd.h +++ b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_amd.h @@ -31,7 +31,7 @@ #ifndef _DEV_HWPMC_AMD_H_ #define _DEV_HWPMC_AMD_H_ 1 -/* AMD K7 and K8 PMCs */ +/* AMD K8 PMCs */ #define AMD_PMC_EVSEL_0 0xC0010000 #define AMD_PMC_EVSEL_1 0xC0010001 diff --git a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h index 21127f2149c55c66b480ba3b03804f6f1992cf23..45ef8793c0424087b7f31137384279aec96ba0e7 100644 --- a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h +++ b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_arm64.h @@ -42,7 +42,7 @@ #ifdef _KERNEL /* MD extension for 'struct pmc' */ struct pmc_md_arm64_pmc { - uint32_t pm_arm64_evsel; + uint64_t pm_arm64_evsel; }; #endif /* _KERNEL */ #endif /* _DEV_HWPMC_ARMV8_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_core.h b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_core.h index 004fd428cec2fbc3689f0716d97efb36661d48a7..502ea650520550e2a56875d57ddcc3598c803130 100644 --- a/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_core.h +++ b/lib/libc/include/generic-freebsd/dev/hwpmc/hwpmc_core.h @@ -198,11 +198,9 @@ int pmc_core_initialize(struct pmc_mdep *_md, int _maxcpu, void pmc_core_finalize(struct pmc_mdep *_md); int pmc_iaf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width); -void pmc_iaf_finalize(struct pmc_mdep *_md); int pmc_iap_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width, int _flags); -void pmc_iap_finalize(struct pmc_mdep *_md); #endif /* _KERNEL */ #endif /* _DEV_HWPMC_CORE_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/hwpmc/pmc_events.h b/lib/libc/include/generic-freebsd/dev/hwpmc/pmc_events.h index c8d57c685fb8c00047e86cd63260402fdcf3680d..84b16e150ccd6dbd07e61882097a9ab38a4b7fa7 100644 --- a/lib/libc/include/generic-freebsd/dev/hwpmc/pmc_events.h +++ b/lib/libc/include/generic-freebsd/dev/hwpmc/pmc_events.h @@ -62,39 +62,6 @@ __PMC_EV_ALIAS("cycles", TSC_TSC) #define PMC_EV_SOFT_FIRST 0x20000 #define PMC_EV_SOFT_LAST (PMC_EV_SOFT_FIRST + PMC_EV_DYN_COUNT - 1) -/* - * AMD K7 Events, from "The AMD Athlon(tm) Processor x86 Code - * Optimization Guide" [Doc#22007K, Feb 2002] - */ - -#define __PMC_EV_K7() \ -__PMC_EV(K7, DC_ACCESSES) \ -__PMC_EV(K7, DC_MISSES) \ -__PMC_EV(K7, DC_REFILLS_FROM_L2) \ -__PMC_EV(K7, DC_REFILLS_FROM_SYSTEM) \ -__PMC_EV(K7, DC_WRITEBACKS) \ -__PMC_EV(K7, L1_DTLB_MISS_AND_L2_DTLB_HITS) \ -__PMC_EV(K7, L1_AND_L2_DTLB_MISSES) \ -__PMC_EV(K7, MISALIGNED_REFERENCES) \ -__PMC_EV(K7, IC_FETCHES) \ -__PMC_EV(K7, IC_MISSES) \ -__PMC_EV(K7, L1_ITLB_MISSES) \ -__PMC_EV(K7, L1_L2_ITLB_MISSES) \ -__PMC_EV(K7, RETIRED_INSTRUCTIONS) \ -__PMC_EV(K7, RETIRED_OPS) \ -__PMC_EV(K7, RETIRED_BRANCHES) \ -__PMC_EV(K7, RETIRED_BRANCHES_MISPREDICTED) \ -__PMC_EV(K7, RETIRED_TAKEN_BRANCHES) \ -__PMC_EV(K7, RETIRED_TAKEN_BRANCHES_MISPREDICTED) \ -__PMC_EV(K7, RETIRED_FAR_CONTROL_TRANSFERS) \ -__PMC_EV(K7, RETIRED_RESYNC_BRANCHES) \ -__PMC_EV(K7, INTERRUPTS_MASKED_CYCLES) \ -__PMC_EV(K7, INTERRUPTS_MASKED_WHILE_PENDING_CYCLES) \ -__PMC_EV(K7, HARDWARE_INTERRUPTS) - -#define PMC_EV_K7_FIRST PMC_EV_K7_DC_ACCESSES -#define PMC_EV_K7_LAST PMC_EV_K7_HARDWARE_INTERRUPTS - /* AMD K8 PMCs */ #define __PMC_EV_K8() \ @@ -2431,7 +2398,7 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF) * START #EVENTS DESCRIPTION * 0 0x1000 Reserved * 0x1000 0x0001 TSC - * 0x2000 0x0080 AMD K7 events + * 0x2000 0x0080 free (was AMD K7 events) * 0x2080 0x0100 AMD K8 events * 0x10000 0x0080 INTEL architectural fixed-function events * 0x10080 0x0F80 free (was INTEL architectural programmable events) @@ -2457,8 +2424,6 @@ __PMC_EV_ALIAS("unhalted-reference-cycles", IAF_CPU_CLK_UNHALTED_REF) #define __PMC_EVENTS() \ __PMC_EV_BLOCK(TSC, 0x01000) \ __PMC_EV_TSC() \ - __PMC_EV_BLOCK(K7, 0x02000) \ - __PMC_EV_K7() \ __PMC_EV_BLOCK(K8, 0x02080) \ __PMC_EV_K8() \ __PMC_EV_BLOCK(IAF, 0x10000) \ diff --git a/lib/libc/include/generic-freebsd/dev/ic/nec765.h b/lib/libc/include/generic-freebsd/dev/ic/nec765.h index 383c40e881ff54220d4605be2472a36788edb467..40077ceed4a9563c6c22a988998d1b7bcca14a82 100644 --- a/lib/libc/include/generic-freebsd/dev/ic/nec765.h +++ b/lib/libc/include/generic-freebsd/dev/ic/nec765.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)nec765.h 7.1 (Berkeley) 5/9/91 */ /* diff --git a/lib/libc/include/generic-freebsd/dev/ic/ns16550.h b/lib/libc/include/generic-freebsd/dev/ic/ns16550.h index 24201f7319b752dbab7fc2b82660ac2188699cd9..6214db16d4852a79338f55c0af7c03ada5d80a32 100644 --- a/lib/libc/include/generic-freebsd/dev/ic/ns16550.h +++ b/lib/libc/include/generic-freebsd/dev/ic/ns16550.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)ns16550.h 7.1 (Berkeley) 5/9/91 */ /* @@ -162,9 +160,6 @@ #define FIFO_XMT_RST FCR_XMT_RST #define FCR_DMA 0x08 #define FIFO_DMA_MODE FCR_DMA -#ifdef CPU_XBURST -#define FCR_UART_ON 0x10 -#endif #define FCR_RX_LOW 0x00 #define FIFO_RX_LOW FCR_RX_LOW #define FCR_RX_MEDL 0x40 diff --git a/lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h b/lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h index a14aa381f9c01c6bb9135a176e9dd80cc093f40e..447375857314c03bd2440ea5c1a03c5b37ba8043 100644 --- a/lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h +++ b/lib/libc/include/generic-freebsd/dev/iicbus/iiconf.h @@ -32,7 +32,7 @@ #include -#define IICPRI (PZERO+8) /* XXX sleep/wakeup queue priority */ +#define IICPRI (PWAIT) /* XXX sleep/wakeup queue priority */ #define LSB 0x1 diff --git a/lib/libc/include/generic-freebsd/dev/mfi/mfireg.h b/lib/libc/include/generic-freebsd/dev/mfi/mfireg.h index a43f2e346b948dbaadf69d1d58cf031f3c34ea2e..f5d9922b5bb321dce446a957b82eeffde4e33bae 100644 --- a/lib/libc/include/generic-freebsd/dev/mfi/mfireg.h +++ b/lib/libc/include/generic-freebsd/dev/mfi/mfireg.h @@ -1028,7 +1028,7 @@ struct mfi_evt_detail { } pd_prog; struct { - struct mfi_evt_pd ld; + struct mfi_evt_pd pd; uint32_t prev_state; uint32_t new_state; } pd_state; diff --git a/lib/libc/include/generic-freebsd/dev/mmc/bridge.h b/lib/libc/include/generic-freebsd/dev/mmc/bridge.h index e0f21c2ae9d03c8da4d0e4c07194519454fd533f..22468466a6d347cf43df8ef67841f74d7a22c133 100644 --- a/lib/libc/include/generic-freebsd/dev/mmc/bridge.h +++ b/lib/libc/include/generic-freebsd/dev/mmc/bridge.h @@ -103,6 +103,10 @@ enum mmc_chip_select { cs_dontcare = 0, cs_high, cs_low }; +enum mmc_bus_type { + bus_type_default = 0, bus_type_spi +}; + enum mmc_bus_width { bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3 }; @@ -123,6 +127,7 @@ struct mmc_ios { uint32_t clock; /* Speed of the clock in Hz to move data */ enum mmc_vdd vdd; /* Voltage to apply to the power pins */ enum mmc_vccq vccq; /* Voltage to use for signaling */ + enum mmc_bus_type bus_type; enum mmc_bus_mode bus_mode; enum mmc_chip_select chip_select; enum mmc_bus_width bus_width; diff --git a/lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h b/lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h index 1630aee3d3a26556c38ba856a79799e8165a9b6a..9e3cf06fdfae8d8c4b643de45ac5c3a11bf81e78 100644 --- a/lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h +++ b/lib/libc/include/generic-freebsd/dev/mmc/mmc_fdt_helpers.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include diff --git a/lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h b/lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h index c94727dee7063c48cd9817423cca3d408a71cd03..03fded905d4dd8040fa76377f37ecd8b25ae03cf 100644 --- a/lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h +++ b/lib/libc/include/generic-freebsd/dev/mmc/mmc_helpers.h @@ -30,7 +30,7 @@ #include -#include +#include struct mmc_helper { device_t dev; diff --git a/lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h b/lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h index 1c6b08223a3e17bd5999e21bee0764e3eea83644..34988b6c93af19502ef8fe405b27f68d5a22d2ec 100644 --- a/lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h +++ b/lib/libc/include/generic-freebsd/dev/mmc/mmcbrvar.h @@ -60,6 +60,7 @@ #include "mmcbr_if.h" enum mmcbr_device_ivars { + MMCBR_IVAR_BUS_TYPE, MMCBR_IVAR_BUS_MODE, MMCBR_IVAR_BUS_WIDTH, MMCBR_IVAR_CHIP_SELECT, @@ -113,6 +114,17 @@ mmcbr_get_retune_req(device_t dev) return ((int)v); } +static int __inline +mmcbr_get_bus_type(device_t dev) +{ + uintptr_t v; + + if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev, + MMCBR_IVAR_BUS_TYPE, &v) != 0)) + return (bus_type_default); + return ((int)v); +} + /* * Convenience wrappers for the mmcbr interface */ diff --git a/lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h b/lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h index 497a126999b0bff779f2ad33f2c4453ccc32aa69..6be01d45350bca3e995eec2116a708b224bd0d05 100644 --- a/lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h +++ b/lib/libc/include/generic-freebsd/dev/mmc/mmcreg.h @@ -80,6 +80,7 @@ struct mmc_command { #define MMC_CMD_BC (2ul << 5) /* Broadcast command, no response */ #define MMC_CMD_BCR (3ul << 5) /* Broadcast command with response */ #define MMC_CMD_MASK (3ul << 5) +#define MMC_CMD_IS_APP (1ul << 7) /* Next cmd after MMC_APP_CMD */ /* Possible response types defined in the standard: */ #define MMC_RSP_NONE (0) diff --git a/lib/libc/include/generic-freebsd/dev/nvme/nvme.h b/lib/libc/include/generic-freebsd/dev/nvme/nvme.h index 09c46d4c5de718efebc4b05c74c33e93d1e30454..803797e61178c3afdabcd6933dbc07685d0fbe74 100644 --- a/lib/libc/include/generic-freebsd/dev/nvme/nvme.h +++ b/lib/libc/include/generic-freebsd/dev/nvme/nvme.h @@ -35,15 +35,23 @@ #include #include +#ifndef _KERNEL +#include +#endif + +struct sbuf; #define NVME_PASSTHROUGH_CMD _IOWR('n', 0, struct nvme_pt_command) #define NVME_RESET_CONTROLLER _IO('n', 1) #define NVME_GET_NSID _IOR('n', 2, struct nvme_get_nsid) #define NVME_GET_MAX_XFER_SIZE _IOR('n', 3, uint64_t) +#define NVME_GET_CONTROLLER_DATA _IOR('n', 4, struct nvme_controller_data) #define NVME_IO_TEST _IOWR('n', 100, struct nvme_io_test) #define NVME_BIO_TEST _IOWR('n', 101, struct nvme_io_test) +/* NB: Fabrics-specific ioctls defined in nvmf.h start at 200. */ + /* * Macros to deal with NVME revisions, as defined VS register */ @@ -211,6 +219,11 @@ /* Command field definitions */ +enum nvme_fuse { + NVME_FUSE_NORMAL = 0x0, + NVME_FUSE_FIRST = 0x1, + NVME_FUSE_SECOND = 0x2 +}; #define NVME_CMD_FUSE_SHIFT (0) #define NVME_CMD_FUSE_MASK (0x3) @@ -390,9 +403,24 @@ enum nvme_psdt { /* per namespace smart/health log page */ #define NVME_CTRLR_DATA_LPA_NS_SMART_SHIFT (0) #define NVME_CTRLR_DATA_LPA_NS_SMART_MASK (0x1) +/* Commands Supported and Effects log page */ +#define NVME_CTRLR_DATA_LPA_CMD_EFFECTS_SHIFT (1) +#define NVME_CTRLR_DATA_LPA_CMD_EFFECTS_MASK (0x1) /* extended data for Get Log Page command */ #define NVME_CTRLR_DATA_LPA_EXT_DATA_SHIFT (2) #define NVME_CTRLR_DATA_LPA_EXT_DATA_MASK (0x1) +/* telemetry */ +#define NVME_CTRLR_DATA_LPA_TELEMETRY_SHIFT (3) +#define NVME_CTRLR_DATA_LPA_TELEMETRY_MASK (0x1) +/* persistent event */ +#define NVME_CTRLR_DATA_LPA_PERSISTENT_EVENT_SHIFT (4) +#define NVME_CTRLR_DATA_LPA_PERSISTENT_EVENT_MASK (0x1) +/* Supported log pages, etc */ +#define NVME_CTRLR_DATA_LPA_LOG_PAGES_PAGE_SHIFT (5) +#define NVME_CTRLR_DATA_LPA_LOG_PAGES_PAGE_MASK (0x1) +/* Data Area 4 for Telemetry */ +#define NVME_CTRLR_DATA_LPA_DA4_TELEMETRY_SHIFT (6) +#define NVME_CTRLR_DATA_LPA_DA4_TELEMETRY_MASK (0x1) /** AVSCC - admin vendor specific command configuration */ /* admin vendor specific commands use spec format */ @@ -623,10 +651,19 @@ enum nvme_critical_warning_state { NVME_CRIT_WARN_ST_DEVICE_RELIABILITY = 0x4, NVME_CRIT_WARN_ST_READ_ONLY = 0x8, NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP = 0x10, + NVME_CRIT_WARN_ST_PERSISTENT_MEMORY_REGION = 0x20, }; -#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xE0) -#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (0x100) -#define NVME_ASYNC_EVENT_FW_ACTIVATE (0x200) +#define NVME_CRIT_WARN_ST_RESERVED_MASK (0xC0) +#define NVME_ASYNC_EVENT_NS_ATTRIBUTE (1U << 8) +#define NVME_ASYNC_EVENT_FW_ACTIVATE (1U << 9) +#define NVME_ASYNC_EVENT_TELEMETRY_LOG (1U << 10) +#define NVME_ASYNC_EVENT_ASYM_NS_ACC (1U << 11) +#define NVME_ASYNC_EVENT_PRED_LAT_DELTA (1U << 12) +#define NVME_ASYNC_EVENT_LBA_STATUS (1U << 13) +#define NVME_ASYNC_EVENT_ENDURANCE_DELTA (1U << 14) +#define NVME_ASYNC_EVENT_NVM_SHUTDOWN (1U << 15) +#define NVME_ASYNC_EVENT_ZONE_DELTA (1U << 27) +#define NVME_ASYNC_EVENT_DISCOVERY_DELTA (1U << 31) /* slot for current FW */ #define NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT (0) @@ -809,7 +846,7 @@ struct nvme_command { uint32_t cdw13; /* command-specific */ uint32_t cdw14; /* command-specific */ uint32_t cdw15; /* command-specific */ -}; +} __aligned(8); _Static_assert(sizeof(struct nvme_command) == 16 * 4, "bad size for nvme_command"); @@ -1578,7 +1615,7 @@ struct nvme_health_information_page { uint32_t ttftmt2; uint8_t reserved2[280]; -} __packed __aligned(4); +} __packed __aligned(8); _Static_assert(sizeof(struct nvme_health_information_page) == 512, "bad size for nvme_health_information_page"); @@ -1629,6 +1666,30 @@ struct nvme_device_self_test_page { _Static_assert(sizeof(struct nvme_device_self_test_page) == 564, "bad size for nvme_device_self_test_page"); +/* + * Header structure for both host initiated telemetry (page 7) and controller + * initiated telemetry (page 8). + */ +struct nvme_telemetry_log_page { + uint8_t identifier; + uint8_t rsvd[4]; + uint8_t oui[3]; + uint16_t da1_last; + uint16_t da2_last; + uint16_t da3_last; + uint8_t rsvd2[2]; + uint32_t da4_last; + uint8_t rsvd3[361]; + uint8_t hi_gen; + uint8_t ci_avail; + uint8_t ci_gen; + uint8_t reason[128]; + /* Blocks of telemetry data follow */ +} __packed __aligned(4); + +_Static_assert(sizeof(struct nvme_telemetry_log_page) == 512, + "bad size for nvme_telemetry_log"); + struct nvme_discovery_log_entry { uint8_t trtype; uint8_t adrfam; @@ -1845,6 +1906,9 @@ struct nvme_hmb_desc { #define nvme_completion_is_error(cpl) \ (NVME_STATUS_GET_SC((cpl)->status) != 0 || NVME_STATUS_GET_SCT((cpl)->status) != 0) +void nvme_cpl_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); +void nvme_opcode_sbuf(bool admin, uint8_t opc, struct sbuf *sb); +void nvme_sc_sbuf(const struct nvme_completion *cpl, struct sbuf *sbuf); void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen); #ifdef _KERNEL @@ -1855,6 +1919,7 @@ struct thread; struct nvme_namespace; struct nvme_controller; struct nvme_consumer; +struct nvme_passthru_cmd; typedef void (*nvme_cb_fn_t)(void *, const struct nvme_completion *); @@ -1865,8 +1930,11 @@ typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *, typedef void (*nvme_cons_fail_fn_t)(void *); enum nvme_namespace_flags { - NVME_NS_DEALLOCATE_SUPPORTED = 0x1, - NVME_NS_FLUSH_SUPPORTED = 0x2, + NVME_NS_DEALLOCATE_SUPPORTED = 0x01, + NVME_NS_FLUSH_SUPPORTED = 0x02, + NVME_NS_ADDED = 0x04, + NVME_NS_CHANGED = 0x08, + NVME_NS_GONE = 0x10, }; int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr, @@ -1874,6 +1942,11 @@ int nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr, uint32_t nsid, int is_user_buffer, int is_admin_cmd); +int nvme_ctrlr_linux_passthru_cmd(struct nvme_controller *ctrlr, + struct nvme_passthru_cmd *npc, + uint32_t nsid, bool is_user, + bool is_admin); + /* Admin functions */ void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, uint8_t feature, uint32_t cdw11, diff --git a/lib/libc/include/generic-freebsd/dev/nvmf/nvmf.h b/lib/libc/include/generic-freebsd/dev/nvmf/nvmf.h new file mode 100644 index 0000000000000000000000000000000000000000..229f8659280ce59f98feb4b95743cd963cd9b9b8 --- /dev/null +++ b/lib/libc/include/generic-freebsd/dev/nvmf/nvmf.h @@ -0,0 +1,132 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2022-2024 Chelsio Communications, Inc. + * Written by: John Baldwin + */ + +#ifndef __NVMF_H__ +#define __NVMF_H__ + +#include +#ifndef _KERNEL +#include +#endif + +/* + * Default settings in Fabrics controllers. These match values used by the + * Linux target. + */ +#define NVMF_MAX_IO_ENTRIES (1024) +#define NVMF_CC_EN_TIMEOUT (15) /* In 500ms units */ + +/* Allows for a 16k data buffer + SQE */ +#define NVMF_IOCCSZ (sizeof(struct nvme_command) + 16 * 1024) +#define NVMF_IORCSZ (sizeof(struct nvme_completion)) + +#define NVMF_NN (1024) + +/* + * Default timeouts for Fabrics hosts. These match values used by + * Linux. + */ +#define NVMF_DEFAULT_RECONNECT_DELAY 10 +#define NVMF_DEFAULT_CONTROLLER_LOSS 600 + +/* + * (data, size) is the userspace buffer for a packed nvlist. + * + * For requests that copyout an nvlist, len is the amount of data + * copied out to *data. If size is zero, no data is copied and len is + * set to the required buffer size. + */ +struct nvmf_ioc_nv { + void *data; + size_t len; + size_t size; +}; + +/* + * The fields in a qpair handoff nvlist are: + * + * Transport independent: + * + * bool admin + * bool sq_flow_control + * number qsize + * number sqhd + * number sqtail host only + * + * TCP transport: + * + * number fd + * number rxpda + * number txpda + * bool header_digests + * bool data_digests + * number maxr2t + * number maxh2cdata + * number max_icd + */ + +/* + * The fields in the nvlist for NVMF_HANDOFF_HOST and + * NVMF_RECONNECT_HOST are: + * + * number trtype + * number kato (optional) + * number reconnect_delay (optional) + * number controller_loss_timeout (optional) + * qpair handoff nvlist admin + * qpair handoff nvlist array io + * binary cdata struct nvme_controller_data + * NVMF_RECONNECT_PARAMS nvlist rparams + */ + +/* + * The fields in the nvlist for NVMF_RECONNECT_PARAMS are: + * + * binary dle struct nvme_discovery_log_entry + * string hostnqn + * number num_io_queues + * number kato (optional) + * number reconnect_delay (optional) + * number controller_loss_timeout (optional) + * number io_qsize + * bool sq_flow_control + * + * TCP transport: + * + * bool header_digests + * bool data_digests + */ + +/* + * The fields in the nvlist for NVMF_CONNECTION_STATUS are: + * + * bool connected + * timespec nvlist last_disconnect + * number tv_sec + * number tv_nsec + */ + +/* + * The fields in the nvlist for handing off a controller qpair are: + * + * number trtype + * qpair handoff nvlist params + * binary cmd struct nvmf_fabric_connect_cmd + * binary data struct nvmf_fabric_connect_data + */ + +/* Operations on /dev/nvmf */ +#define NVMF_HANDOFF_HOST _IOW('n', 200, struct nvmf_ioc_nv) +#define NVMF_DISCONNECT_HOST _IOW('n', 201, const char *) +#define NVMF_DISCONNECT_ALL _IO('n', 202) + +/* Operations on /dev/nvmeX */ +#define NVMF_RECONNECT_PARAMS _IOWR('n', 203, struct nvmf_ioc_nv) +#define NVMF_RECONNECT_HOST _IOW('n', 204, struct nvmf_ioc_nv) +#define NVMF_CONNECTION_STATUS _IOWR('n', 205, struct nvmf_ioc_nv) + +#endif /* !__NVMF_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/nvmf/nvmf_proto.h b/lib/libc/include/generic-freebsd/dev/nvmf/nvmf_proto.h new file mode 100644 index 0000000000000000000000000000000000000000..cd42db2cfd47a370130adcc14b9666a7e13622e9 --- /dev/null +++ b/lib/libc/include/generic-freebsd/dev/nvmf/nvmf_proto.h @@ -0,0 +1,765 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) 2016 Intel Corporation. + * All rights reserved. + */ + +/* Derived from include/spdk/nvmf_spec.h from Intel's SPDK. */ + +#ifndef __NVMF_PROTO_H__ +#define __NVMF_PROTO_H__ + +#include +#include +#ifdef _KERNEL +#include +#else +#include +#endif +#include + +/** + * \file + * NVMe over Fabrics specification definitions + */ + +#define NVME_NQN_FIELD_SIZE 256 + +struct nvmf_capsule_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; + uint8_t reserved2[35]; + uint8_t fabric_specific[24]; +}; +_Static_assert(sizeof(struct nvmf_capsule_cmd) == 64, "Incorrect size"); + +/* Fabric Command Set */ +enum nvmf_fabric_cmd_types { + NVMF_FABRIC_COMMAND_PROPERTY_SET = 0x00, + NVMF_FABRIC_COMMAND_CONNECT = 0x01, + NVMF_FABRIC_COMMAND_PROPERTY_GET = 0x04, + NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND = 0x05, + NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV = 0x06, + NVMF_FABRIC_COMMAND_DISCONNECT = 0x08, + NVMF_FABRIC_COMMAND_START_VENDOR_SPECIFIC = 0xC0, +}; + +enum nvmf_fabric_cmd_status_code { + NVMF_FABRIC_SC_INCOMPATIBLE_FORMAT = 0x80, + NVMF_FABRIC_SC_CONTROLLER_BUSY = 0x81, + NVMF_FABRIC_SC_INVALID_PARAM = 0x82, + NVMF_FABRIC_SC_RESTART_DISCOVERY = 0x83, + NVMF_FABRIC_SC_INVALID_HOST = 0x84, + NVMF_FABRIC_SC_INVALID_QUEUE_TYPE = 0x85, + NVMF_FABRIC_SC_LOG_RESTART_DISCOVERY = 0x90, + NVMF_FABRIC_SC_AUTH_REQUIRED = 0x91, +}; + +/** + * RDMA Queue Pair service types + */ +enum nvmf_rdma_qptype { + /** Reliable connected */ + NVMF_RDMA_QPTYPE_RELIABLE_CONNECTED = 0x1, + + /** Reliable datagram */ + NVMF_RDMA_QPTYPE_RELIABLE_DATAGRAM = 0x2, +}; + +/** + * RDMA provider types + */ +enum nvmf_rdma_prtype { + /** No provider specified */ + NVMF_RDMA_PRTYPE_NONE = 0x1, + + /** InfiniBand */ + NVMF_RDMA_PRTYPE_IB = 0x2, + + /** RoCE v1 */ + NVMF_RDMA_PRTYPE_ROCE = 0x3, + + /** RoCE v2 */ + NVMF_RDMA_PRTYPE_ROCE2 = 0x4, + + /** iWARP */ + NVMF_RDMA_PRTYPE_IWARP = 0x5, +}; + +/** + * RDMA connection management service types + */ +enum nvmf_rdma_cms { + /** Sockets based endpoint addressing */ + NVMF_RDMA_CMS_RDMA_CM = 0x1, +}; + +/** + * NVMe over Fabrics transport types + */ +enum nvmf_trtype { + /** RDMA */ + NVMF_TRTYPE_RDMA = 0x1, + + /** Fibre Channel */ + NVMF_TRTYPE_FC = 0x2, + + /** TCP */ + NVMF_TRTYPE_TCP = 0x3, + + /** Intra-host transport (loopback) */ + NVMF_TRTYPE_INTRA_HOST = 0xfe, +}; + +/** + * Address family types + */ +enum nvmf_adrfam { + /** IPv4 (AF_INET) */ + NVMF_ADRFAM_IPV4 = 0x1, + + /** IPv6 (AF_INET6) */ + NVMF_ADRFAM_IPV6 = 0x2, + + /** InfiniBand (AF_IB) */ + NVMF_ADRFAM_IB = 0x3, + + /** Fibre Channel address family */ + NVMF_ADRFAM_FC = 0x4, + + /** Intra-host transport (loopback) */ + NVMF_ADRFAM_INTRA_HOST = 0xfe, +}; + +/** + * NVM subsystem types + */ +enum nvmf_subtype { + /** Referral to a discovery service */ + NVMF_SUBTYPE_DISCOVERY = 0x1, + + /** NVM Subsystem */ + NVMF_SUBTYPE_NVME = 0x2, + + /** Current Discovery Subsystem */ + NVMF_SUBTYPE_DISCOVERY_CURRENT = 0x3 +}; + +/* Discovery Log Entry Flags - Duplicate Returned Information */ +#define NVMF_DISCOVERY_LOG_EFLAGS_DUPRETINFO (1u << 0u) + +/* Discovery Log Entry Flags - Explicit Persistent Connection Support for Discovery */ +#define NVMF_DISCOVERY_LOG_EFLAGS_EPCSD (1u << 1u) + +/** + * Connections shall be made over a fabric secure channel + */ +enum nvmf_treq_secure_channel { + /** Not specified */ + NVMF_TREQ_SECURE_CHANNEL_NOT_SPECIFIED = 0x0, + + /** Required */ + NVMF_TREQ_SECURE_CHANNEL_REQUIRED = 0x1, + + /** Not required */ + NVMF_TREQ_SECURE_CHANNEL_NOT_REQUIRED = 0x2, +}; + +struct nvmf_fabric_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; + uint8_t reserved2[59]; +} __aligned(8); + +struct nvmf_fabric_auth_recv_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_RECV (0x06) */ + uint8_t reserved2[19]; + struct nvme_sgl_descriptor sgl1; + uint8_t reserved3; + uint8_t spsp0; + uint8_t spsp1; + uint8_t secp; + uint32_t al; + uint8_t reserved4[16]; +}; +_Static_assert(sizeof(struct nvmf_fabric_auth_recv_cmd) == 64, "Incorrect size"); + +struct nvmf_fabric_auth_send_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; /* NVMF_FABRIC_COMMAND_AUTHENTICATION_SEND (0x05) */ + uint8_t reserved2[19]; + struct nvme_sgl_descriptor sgl1; + uint8_t reserved3; + uint8_t spsp0; + uint8_t spsp1; + uint8_t secp; + uint32_t tl; + uint8_t reserved4[16]; +}; +_Static_assert(sizeof(struct nvmf_fabric_auth_send_cmd) == 64, "Incorrect size"); + +struct nvmf_fabric_connect_data { + uint8_t hostid[16]; + uint16_t cntlid; + uint8_t reserved5[238]; + uint8_t subnqn[NVME_NQN_FIELD_SIZE]; + uint8_t hostnqn[NVME_NQN_FIELD_SIZE]; + uint8_t reserved6[256]; +}; +_Static_assert(sizeof(struct nvmf_fabric_connect_data) == 1024, "Incorrect size"); + +struct nvmf_fabric_connect_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; + uint8_t reserved2[19]; + struct nvme_sgl_descriptor sgl1; + uint16_t recfmt; /* Connect Record Format */ + uint16_t qid; /* Queue Identifier */ + uint16_t sqsize; /* Submission Queue Size */ + uint8_t cattr; /* queue attributes */ + uint8_t reserved3; + uint32_t kato; /* keep alive timeout */ + uint8_t reserved4[12]; +}; +_Static_assert(sizeof(struct nvmf_fabric_connect_cmd) == 64, "Incorrect size"); + +#define NVMF_CNTLID_DYNAMIC 0xFFFF +#define NVMF_CNTLID_STATIC_ANY 0xFFFE + +/* + * XXX: 5.3 in NVMe-over-Fabrics 1.1 gives this as an upper bound in + * the Discovery Log Entry. + */ +#define NVMF_CNTLID_STATIC_MAX 0xFFEF + +/* 5.21.1.15 in NVMe 1.4b */ +#define NVMF_KATO_DEFAULT (120000) + +#define NVMF_CONNECT_ATTR_PRIORITY_CLASS (0x3) +#define NVMF_CONNECT_ATTR_DISABLE_SQ_FC (1u << 2) +#define NVMF_CONNECT_ATTR_IO_QUEUE_DELETION (1u << 3) + +struct nvmf_fabric_connect_rsp { + union { + struct { + uint16_t cntlid; + uint16_t authreq; + } success; + + struct { + uint16_t ipo; + uint8_t iattr; + uint8_t reserved; + } invalid; + + uint32_t raw; + } status_code_specific; + + uint32_t reserved0; + uint16_t sqhd; + uint16_t reserved1; + uint16_t cid; + uint16_t status; +}; +_Static_assert(sizeof(struct nvmf_fabric_connect_rsp) == 16, "Incorrect size"); + +struct nvmf_fabric_disconnect_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; + uint8_t reserved2[19]; + struct nvme_sgl_descriptor sgl1; + uint16_t recfmt; /* Disconnect Record Format */ + uint8_t reserved3[22]; +}; +_Static_assert(sizeof(struct nvmf_fabric_disconnect_cmd) == 64, "Incorrect size"); + +#define NVMF_PROP_SIZE_4 0 +#define NVMF_PROP_SIZE_8 1 + +#define NVMF_PROP_CAP 0x00 /* Controller Capabilities */ +#define NVMF_PROP_VS 0x08 /* Version */ +#define NVMF_PROP_CC 0x14 /* Controller Configuration */ +#define NVMF_PROP_CSTS 0x1C /* Controller Status */ +#define NVMF_PROP_NSSR 0x20 /* NVM Subsystem Reset */ + +struct nvmf_fabric_prop_get_cmd { + uint8_t opcode; + uint8_t reserved1; + uint16_t cid; + uint8_t fctype; + uint8_t reserved2[35]; + struct { + uint8_t size : 3; + uint8_t reserved : 5; + } attrib; + uint8_t reserved3[3]; + uint32_t ofst; + uint8_t reserved4[16]; +}; +_Static_assert(sizeof(struct nvmf_fabric_prop_get_cmd) == 64, "Incorrect size"); + +struct nvmf_fabric_prop_get_rsp { + union { + uint64_t u64; + struct { + uint32_t low; + uint32_t high; + } u32; + } value; + + uint16_t sqhd; + uint16_t reserved0; + uint16_t cid; + uint16_t status; +}; +_Static_assert(sizeof(struct nvmf_fabric_prop_get_rsp) == 16, "Incorrect size"); + +struct nvmf_fabric_prop_set_cmd { + uint8_t opcode; + uint8_t reserved0; + uint16_t cid; + uint8_t fctype; + uint8_t reserved1[35]; + struct { + uint8_t size : 3; + uint8_t reserved : 5; + } attrib; + uint8_t reserved2[3]; + uint32_t ofst; + + union { + uint64_t u64; + struct { + uint32_t low; + uint32_t high; + } u32; + } value; + + uint8_t reserved4[8]; +}; +_Static_assert(sizeof(struct nvmf_fabric_prop_set_cmd) == 64, "Incorrect size"); + +#define NVMF_NQN_MIN_LEN 11 /* The prefix in the spec is 11 characters */ +#define NVMF_NQN_MAX_LEN 223 +#define NVMF_NQN_UUID_PRE_LEN 32 +#define NVMF_UUID_STRING_LEN 36 +#define NVMF_NQN_UUID_PRE "nqn.2014-08.org.nvmexpress:uuid:" +#define NVMF_DISCOVERY_NQN "nqn.2014-08.org.nvmexpress.discovery" + +#define NVMF_TRSTRING_MAX_LEN 32 +#define NVMF_TRADDR_MAX_LEN 256 +#define NVMF_TRSVCID_MAX_LEN 32 + +/** RDMA transport-specific address subtype */ +struct nvmf_rdma_transport_specific_address_subtype { + /** RDMA QP service type (\ref nvmf_rdma_qptype) */ + uint8_t rdma_qptype; + + /** RDMA provider type (\ref nvmf_rdma_prtype) */ + uint8_t rdma_prtype; + + /** RDMA connection management service (\ref nvmf_rdma_cms) */ + uint8_t rdma_cms; + + uint8_t reserved0[5]; + + /** RDMA partition key for AF_IB */ + uint16_t rdma_pkey; + + uint8_t reserved2[246]; +}; +_Static_assert(sizeof(struct nvmf_rdma_transport_specific_address_subtype) == 256, + "Incorrect size"); + +/** TCP Secure Socket Type */ +enum nvme_tcp_secure_socket_type { + /** No security */ + NVME_TCP_SECURITY_NONE = 0, + + /** TLS (Secure Sockets) version 1.2 */ + NVME_TCP_SECURITY_TLS_1_2 = 1, + + /** TLS (Secure Sockets) version 1.3 */ + NVME_TCP_SECURITY_TLS_1_3 = 2, +}; + +/** TCP transport-specific address subtype */ +struct nvme_tcp_transport_specific_address_subtype { + /** Security type (\ref nvme_tcp_secure_socket_type) */ + uint8_t sectype; + + uint8_t reserved0[255]; +}; +_Static_assert(sizeof(struct nvme_tcp_transport_specific_address_subtype) == 256, + "Incorrect size"); + +/** Transport-specific address subtype */ +union nvmf_transport_specific_address_subtype { + uint8_t raw[256]; + + /** RDMA */ + struct nvmf_rdma_transport_specific_address_subtype rdma; + + /** TCP */ + struct nvme_tcp_transport_specific_address_subtype tcp; +}; +_Static_assert(sizeof(union nvmf_transport_specific_address_subtype) == 256, + "Incorrect size"); + +#define NVMF_MIN_ADMIN_MAX_SQ_SIZE 32 + +/** + * Discovery Log Page entry + */ +struct nvmf_discovery_log_page_entry { + /** Transport type (\ref nvmf_trtype) */ + uint8_t trtype; + + /** Address family (\ref nvmf_adrfam) */ + uint8_t adrfam; + + /** Subsystem type (\ref nvmf_subtype) */ + uint8_t subtype; + + /** Transport requirements */ + struct { + /** Secure channel requirements (\ref nvmf_treq_secure_channel) */ + uint8_t secure_channel : 2; + + uint8_t reserved : 6; + } treq; + + /** NVM subsystem port ID */ + uint16_t portid; + + /** Controller ID */ + uint16_t cntlid; + + /** Admin max SQ size */ + uint16_t asqsz; + + /** Entry Flags */ + uint16_t eflags; + + uint8_t reserved0[20]; + + /** Transport service identifier */ + uint8_t trsvcid[NVMF_TRSVCID_MAX_LEN]; + + uint8_t reserved1[192]; + + /** NVM subsystem qualified name */ + uint8_t subnqn[256]; + + /** Transport address */ + uint8_t traddr[NVMF_TRADDR_MAX_LEN]; + + /** Transport-specific address subtype */ + union nvmf_transport_specific_address_subtype tsas; +}; +_Static_assert(sizeof(struct nvmf_discovery_log_page_entry) == 1024, "Incorrect size"); + +struct nvmf_discovery_log_page { + uint64_t genctr; + uint64_t numrec; + uint16_t recfmt; + uint8_t reserved0[1006]; + struct nvmf_discovery_log_page_entry entries[0]; +}; +_Static_assert(sizeof(struct nvmf_discovery_log_page) == 1024, "Incorrect size"); + +/* RDMA Fabric specific definitions below */ + +#define NVME_SGL_SUBTYPE_INVALIDATE_KEY 0xF + +struct nvmf_rdma_request_private_data { + uint16_t recfmt; /* record format */ + uint16_t qid; /* queue id */ + uint16_t hrqsize; /* host receive queue size */ + uint16_t hsqsize; /* host send queue size */ + uint16_t cntlid; /* controller id */ + uint8_t reserved[22]; +}; +_Static_assert(sizeof(struct nvmf_rdma_request_private_data) == 32, "Incorrect size"); + +struct nvmf_rdma_accept_private_data { + uint16_t recfmt; /* record format */ + uint16_t crqsize; /* controller receive queue size */ + uint8_t reserved[28]; +}; +_Static_assert(sizeof(struct nvmf_rdma_accept_private_data) == 32, "Incorrect size"); + +struct nvmf_rdma_reject_private_data { + uint16_t recfmt; /* record format */ + uint16_t sts; /* status */ +}; +_Static_assert(sizeof(struct nvmf_rdma_reject_private_data) == 4, "Incorrect size"); + +union nvmf_rdma_private_data { + struct nvmf_rdma_request_private_data pd_request; + struct nvmf_rdma_accept_private_data pd_accept; + struct nvmf_rdma_reject_private_data pd_reject; +}; +_Static_assert(sizeof(union nvmf_rdma_private_data) == 32, "Incorrect size"); + +enum nvmf_rdma_transport_error { + NVMF_RDMA_ERROR_INVALID_PRIVATE_DATA_LENGTH = 0x1, + NVMF_RDMA_ERROR_INVALID_RECFMT = 0x2, + NVMF_RDMA_ERROR_INVALID_QID = 0x3, + NVMF_RDMA_ERROR_INVALID_HSQSIZE = 0x4, + NVMF_RDMA_ERROR_INVALID_HRQSIZE = 0x5, + NVMF_RDMA_ERROR_NO_RESOURCES = 0x6, + NVMF_RDMA_ERROR_INVALID_IRD = 0x7, + NVMF_RDMA_ERROR_INVALID_ORD = 0x8, +}; + +/* TCP transport specific definitions below */ + +/** NVMe/TCP PDU type */ +enum nvme_tcp_pdu_type { + /** Initialize Connection Request (ICReq) */ + NVME_TCP_PDU_TYPE_IC_REQ = 0x00, + + /** Initialize Connection Response (ICResp) */ + NVME_TCP_PDU_TYPE_IC_RESP = 0x01, + + /** Terminate Connection Request (TermReq) */ + NVME_TCP_PDU_TYPE_H2C_TERM_REQ = 0x02, + + /** Terminate Connection Response (TermResp) */ + NVME_TCP_PDU_TYPE_C2H_TERM_REQ = 0x03, + + /** Command Capsule (CapsuleCmd) */ + NVME_TCP_PDU_TYPE_CAPSULE_CMD = 0x04, + + /** Response Capsule (CapsuleRsp) */ + NVME_TCP_PDU_TYPE_CAPSULE_RESP = 0x05, + + /** Host To Controller Data (H2CData) */ + NVME_TCP_PDU_TYPE_H2C_DATA = 0x06, + + /** Controller To Host Data (C2HData) */ + NVME_TCP_PDU_TYPE_C2H_DATA = 0x07, + + /** Ready to Transfer (R2T) */ + NVME_TCP_PDU_TYPE_R2T = 0x09, +}; + +/** Common NVMe/TCP PDU header */ +struct nvme_tcp_common_pdu_hdr { + /** PDU type (\ref nvme_tcp_pdu_type) */ + uint8_t pdu_type; + + /** pdu_type-specific flags */ + uint8_t flags; + + /** Length of PDU header (not including the Header Digest) */ + uint8_t hlen; + + /** PDU Data Offset from the start of the PDU */ + uint8_t pdo; + + /** Total number of bytes in PDU, including pdu_hdr */ + uint32_t plen; +}; +_Static_assert(sizeof(struct nvme_tcp_common_pdu_hdr) == 8, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, pdu_type) == 0, + "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, flags) == 1, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, hlen) == 2, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, pdo) == 3, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_common_pdu_hdr, plen) == 4, "Incorrect offset"); + +#define NVME_TCP_CH_FLAGS_HDGSTF (1u << 0) +#define NVME_TCP_CH_FLAGS_DDGSTF (1u << 1) + +/** + * ICReq + * + * common.pdu_type == NVME_TCP_PDU_TYPE_IC_REQ + */ +struct nvme_tcp_ic_req { + struct nvme_tcp_common_pdu_hdr common; + uint16_t pfv; + /** Specifies the data alignment for all PDUs transferred from the controller to the host that contain data */ + uint8_t hpda; + union { + uint8_t raw; + struct { + uint8_t hdgst_enable : 1; + uint8_t ddgst_enable : 1; + uint8_t reserved : 6; + } bits; + } dgst; + uint32_t maxr2t; + uint8_t reserved16[112]; +}; +_Static_assert(sizeof(struct nvme_tcp_ic_req) == 128, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_ic_req, pfv) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_ic_req, hpda) == 10, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_ic_req, maxr2t) == 12, "Incorrect offset"); + +#define NVME_TCP_HPDA_MAX 31 +#define NVME_TCP_CPDA_MAX 31 +#define NVME_TCP_PDU_PDO_MAX_OFFSET ((NVME_TCP_CPDA_MAX + 1) << 2) + +/** + * ICResp + * + * common.pdu_type == NVME_TCP_PDU_TYPE_IC_RESP + */ +struct nvme_tcp_ic_resp { + struct nvme_tcp_common_pdu_hdr common; + uint16_t pfv; + /** Specifies the data alignment for all PDUs transferred from the host to the controller that contain data */ + uint8_t cpda; + union { + uint8_t raw; + struct { + uint8_t hdgst_enable : 1; + uint8_t ddgst_enable : 1; + uint8_t reserved : 6; + } bits; + } dgst; + /** Specifies the maximum number of PDU-Data bytes per H2C Data Transfer PDU */ + uint32_t maxh2cdata; + uint8_t reserved16[112]; +}; +_Static_assert(sizeof(struct nvme_tcp_ic_resp) == 128, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_ic_resp, pfv) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_ic_resp, cpda) == 10, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_ic_resp, maxh2cdata) == 12, "Incorrect offset"); + +/** + * TermReq + * + * common.pdu_type == NVME_TCP_PDU_TYPE_TERM_REQ + */ +struct nvme_tcp_term_req_hdr { + struct nvme_tcp_common_pdu_hdr common; + uint16_t fes; + uint8_t fei[4]; + uint8_t reserved14[10]; +}; + +_Static_assert(sizeof(struct nvme_tcp_term_req_hdr) == 24, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_term_req_hdr, fes) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_term_req_hdr, fei) == 10, "Incorrect offset"); + +enum nvme_tcp_term_req_fes { + NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD = 0x01, + NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR = 0x02, + NVME_TCP_TERM_REQ_FES_HDGST_ERROR = 0x03, + NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_OUT_OF_RANGE = 0x04, + NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_LIMIT_EXCEEDED = 0x05, + NVME_TCP_TERM_REQ_FES_R2T_LIMIT_EXCEEDED = 0x05, + NVME_TCP_TERM_REQ_FES_INVALID_DATA_UNSUPPORTED_PARAMETER = 0x06, +}; + +/* Total length of term req PDU (including PDU header and DATA) in bytes shall not exceed a limit of 152 bytes. */ +#define NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE 128 +#define NVME_TCP_TERM_REQ_PDU_MAX_SIZE (NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE + sizeof(struct nvme_tcp_term_req_hdr)) + +/** + * CapsuleCmd + * + * common.pdu_type == NVME_TCP_PDU_TYPE_CAPSULE_CMD + */ +struct nvme_tcp_cmd { + struct nvme_tcp_common_pdu_hdr common; + struct nvme_command ccsqe; + /**< icdoff hdgst padding + in-capsule data + ddgst (if enabled) */ +}; +_Static_assert(sizeof(struct nvme_tcp_cmd) == 72, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_cmd, ccsqe) == 8, "Incorrect offset"); + +/** + * CapsuleResp + * + * common.pdu_type == NVME_TCP_PDU_TYPE_CAPSULE_RESP + */ +struct nvme_tcp_rsp { + struct nvme_tcp_common_pdu_hdr common; + struct nvme_completion rccqe; +}; +_Static_assert(sizeof(struct nvme_tcp_rsp) == 24, "incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_rsp, rccqe) == 8, "Incorrect offset"); + + +/** + * H2CData + * + * hdr.pdu_type == NVME_TCP_PDU_TYPE_H2C_DATA + */ +struct nvme_tcp_h2c_data_hdr { + struct nvme_tcp_common_pdu_hdr common; + uint16_t cccid; + uint16_t ttag; + uint32_t datao; + uint32_t datal; + uint8_t reserved20[4]; +}; +_Static_assert(sizeof(struct nvme_tcp_h2c_data_hdr) == 24, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, cccid) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, ttag) == 10, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, datao) == 12, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_h2c_data_hdr, datal) == 16, "Incorrect offset"); + +#define NVME_TCP_H2C_DATA_FLAGS_LAST_PDU (1u << 2) +#define NVME_TCP_H2C_DATA_FLAGS_SUCCESS (1u << 3) +#define NVME_TCP_H2C_DATA_PDO_MULT 8u + +/** + * C2HData + * + * hdr.pdu_type == NVME_TCP_PDU_TYPE_C2H_DATA + */ +struct nvme_tcp_c2h_data_hdr { + struct nvme_tcp_common_pdu_hdr common; + uint16_t cccid; + uint8_t reserved10[2]; + uint32_t datao; + uint32_t datal; + uint8_t reserved20[4]; +}; +_Static_assert(sizeof(struct nvme_tcp_c2h_data_hdr) == 24, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, cccid) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, datao) == 12, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_c2h_data_hdr, datal) == 16, "Incorrect offset"); + +#define NVME_TCP_C2H_DATA_FLAGS_SUCCESS (1u << 3) +#define NVME_TCP_C2H_DATA_FLAGS_LAST_PDU (1u << 2) +#define NVME_TCP_C2H_DATA_PDO_MULT 8u + +/** + * R2T + * + * common.pdu_type == NVME_TCP_PDU_TYPE_R2T + */ +struct nvme_tcp_r2t_hdr { + struct nvme_tcp_common_pdu_hdr common; + uint16_t cccid; + uint16_t ttag; + uint32_t r2to; + uint32_t r2tl; + uint8_t reserved20[4]; +}; +_Static_assert(sizeof(struct nvme_tcp_r2t_hdr) == 24, "Incorrect size"); +_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, cccid) == 8, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, ttag) == 10, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, r2to) == 12, "Incorrect offset"); +_Static_assert(offsetof(struct nvme_tcp_r2t_hdr, r2tl) == 16, "Incorrect offset"); + +#endif /* __NVMF_PROTO_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/ofw/ofw_cpu.h b/lib/libc/include/generic-freebsd/dev/ofw/ofw_cpu.h index 4dd7f5556791d3137096cfb49ad1346fce087fac..bde462cc62ad0054a71aee0e699c657ba9c83712 100644 --- a/lib/libc/include/generic-freebsd/dev/ofw/ofw_cpu.h +++ b/lib/libc/include/generic-freebsd/dev/ofw/ofw_cpu.h @@ -30,6 +30,6 @@ #define _DEV_OFW_OFW_CPU_H_ typedef bool (*ofw_cpu_foreach_cb)(u_int, phandle_t, u_int, pcell_t *); -int ofw_cpu_early_foreach(ofw_cpu_foreach_cb, boolean_t); +int ofw_cpu_early_foreach(ofw_cpu_foreach_cb, bool); #endif /* _DEV_OFW_OFW_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/ofw/openfirm.h b/lib/libc/include/generic-freebsd/dev/ofw/openfirm.h index 87bfbcd3c2d74804d6213db25c0efed11a09426e..1bb249a2957d9d3095980778b0b69da5ffe33ed4 100644 --- a/lib/libc/include/generic-freebsd/dev/ofw/openfirm.h +++ b/lib/libc/include/generic-freebsd/dev/ofw/openfirm.h @@ -83,8 +83,8 @@ MALLOC_DECLARE(M_OFWPROP); * interface as the Open Firmware access mechanism, OF_init initializes it. */ -boolean_t OF_install(char *name, int prio); -int OF_init(void *cookie); +bool OF_install(char *name, int prio); +int OF_init(void *cookie); /* * Known Open Firmware interface names @@ -149,6 +149,7 @@ phandle_t OF_xref_from_node(phandle_t node); device_t OF_device_from_xref(phandle_t xref); phandle_t OF_xref_from_device(device_t dev); int OF_device_register_xref(phandle_t xref, device_t dev); +void OF_device_unregister_xref(phandle_t xref, device_t dev); /* Device I/O functions */ ihandle_t OF_open(const char *path); diff --git a/lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h b/lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h index 003300d21b26d0c8481f249e190f878dc3d8cd21..d49696f274e853d1b1e4a9c0c88b96a3b80b2f1c 100644 --- a/lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h +++ b/lib/libc/include/generic-freebsd/dev/ofw/openfirmio.h @@ -33,8 +33,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)openpromio.h 8.1 (Berkeley) 6/11/93 */ #ifndef _DEV_OFW_OPENFIRMIO_H_ diff --git a/lib/libc/include/generic-freebsd/dev/pci/pcireg.h b/lib/libc/include/generic-freebsd/dev/pci/pcireg.h index cc2e06f966ecb43a03e0f1a83c5459b33b171645..c934264a84cf003473b1bcb57abb8f1e25110489 100644 --- a/lib/libc/include/generic-freebsd/dev/pci/pcireg.h +++ b/lib/libc/include/generic-freebsd/dev/pci/pcireg.h @@ -616,6 +616,8 @@ #define PCIM_MSICTRL_MMC_16 0x0008 #define PCIM_MSICTRL_MMC_32 0x000A #define PCIM_MSICTRL_MSI_ENABLE 0x0001 +#define PCI_MSI_MSGNUM(ctrl) \ + (1 << (((ctrl) & PCIM_MSICTRL_MMC_MASK) >> 1)) #define PCIR_MSI_ADDR 0x4 #define PCIR_MSI_ADDR_HIGH 0x8 #define PCIR_MSI_DATA 0x8 @@ -965,6 +967,7 @@ #define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000 #define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000 #define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF +#define PCI_MSIX_MSGNUM(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1) #define PCIR_MSIX_TABLE 0x4 #define PCIR_MSIX_PBA 0x8 #define PCIM_MSIX_BIR_MASK 0x7 diff --git a/lib/libc/include/generic-freebsd/dev/powermac_nvram/powermac_nvramvar.h b/lib/libc/include/generic-freebsd/dev/powermac_nvram/powermac_nvramvar.h deleted file mode 100644 index 48172b858b4f2647c81d028bafbb9e9e228427d8..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/dev/powermac_nvram/powermac_nvramvar.h +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2006 Maxim Sobolev - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ -#define _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ - -#define NVRAM_SIZE 0x2000 - -#define CORE99_SIGNATURE 0x5a - -#define SM_FLASH_CMD_ERASE_CONFIRM 0xd0 -#define SM_FLASH_CMD_ERASE_SETUP 0x20 -#define SM_FLASH_CMD_RESET 0xff -#define SM_FLASH_CMD_WRITE_SETUP 0x40 -#define SM_FLASH_CMD_CLEAR_STATUS 0x50 -#define SM_FLASH_CMD_READ_STATUS 0x70 - -#define SM_FLASH_STATUS_DONE 0x80 -#define SM_FLASH_STATUS_ERR 0x38 - -#ifdef _KERNEL - -struct powermac_nvram_softc { - device_t sc_dev; - struct sx sc_lock; - phandle_t sc_node; - void * sc_bank; - void * sc_bank0; - void * sc_bank1; - uint8_t sc_data[NVRAM_SIZE]; - - struct cdev * sc_cdev; - int sc_type; -#define FLASH_TYPE_SM 0 -#define FLASH_TYPE_AMD 1 - int sc_isopen; - int sc_rpos; - int sc_wpos; -}; - -#endif /* _KERNEL */ - -struct chrp_header { - uint8_t signature; - uint8_t chrp_checksum; - uint16_t length; - char name[12]; -}; - -struct core99_header { - struct chrp_header chrp_header; - uint32_t adler_checksum; - uint32_t generation; - uint32_t reserved[2]; -}; - -#endif /* _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dev/ppbus/lpt.h b/lib/libc/include/generic-freebsd/dev/ppbus/lpt.h index 16bdfa2329ae1becb715f57dcef4f2229dfbe4bd..7c181a2f5bf76650f4bc196e61d74f46bc6071b7 100644 --- a/lib/libc/include/generic-freebsd/dev/ppbus/lpt.h +++ b/lib/libc/include/generic-freebsd/dev/ppbus/lpt.h @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * Distantly from : - * @(#)lptreg.h 1.1 (Berkeley) 12/19/90 * Id: lptreg.h,v 1.6 1997/02/22 09:36:52 peter Exp * From Id: nlpt.h,v 1.3 1999/01/10 12:04:54 nsouch Exp */ diff --git a/lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h b/lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h index 7df8714eee6459d816f792178a0047bb30b57bdd..704b074faa850c7dc3e637ae210097c52c103e1c 100644 --- a/lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h +++ b/lib/libc/include/generic-freebsd/dev/ppbus/ppbconf.h @@ -63,7 +63,7 @@ /* * Parallel Port Bus sleep/wakeup queue. */ -#define PPBPRI (PZERO+8) +#define PPBPRI (PWAIT) /* * Parallel Port Chipset mode masks. diff --git a/lib/libc/include/generic-freebsd/dev/smbus/smbconf.h b/lib/libc/include/generic-freebsd/dev/smbus/smbconf.h index 3c86cde0fa7c97fc38d8dbd9f826866b3a16b58d..c5e107b9e63a586fb60ad5920ba1dca73500aa3d 100644 --- a/lib/libc/include/generic-freebsd/dev/smbus/smbconf.h +++ b/lib/libc/include/generic-freebsd/dev/smbus/smbconf.h @@ -30,7 +30,7 @@ #include -#define SMBPRI (PZERO+8) /* XXX sleep/wakeup queue priority */ +#define SMBPRI (PWAIT) /* XXX sleep/wakeup queue priority */ #define n(flags) (~(flags) & (flags)) diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb.h b/lib/libc/include/generic-freebsd/dev/usb/usb.h index cd33ae06c9a8bc210bb308ee01b43ec1bcf81d4c..f2e0dc0a3731261ae52758d4d7c721f9a0ba28a5 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb.h @@ -114,7 +114,7 @@ MALLOC_DECLARE(M_USBDEV); /* Allow for marginal and non-conforming devices. */ #define USB_PORT_RESET_DELAY 50 /* ms */ #define USB_PORT_ROOT_RESET_DELAY 200 /* ms */ -#define USB_PORT_RESET_RECOVERY 10 /* ms */ +#define USB_PORT_RESET_RECOVERY 20 /* ms */ #define USB_PORT_POWERUP_DELAY 300 /* ms */ #define USB_PORT_RESUME_DELAY (20*2) /* ms */ #define USB_SET_ADDRESS_SETTLE 10 /* ms */ diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_bus.h b/lib/libc/include/generic-freebsd/dev/usb/usb_bus.h index 216aa1763a9148bddb06fa1a43fd1099f232b4c3..9bdc9995b2b61f9bfcb7028e9d34fa7df5df3fca 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_bus.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_bus.h @@ -86,7 +86,7 @@ struct usb_bus { struct usb_bus_msg shutdown_msg[2]; #if USB_HAVE_UGEN struct usb_bus_msg cleanup_msg[2]; - LIST_HEAD(,usb_fs_privdata) pd_cleanup_list; + SLIST_HEAD(,usb_fs_privdata) pd_cleanup_list; #endif /* * This mutex protects the USB hardware: diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_dev.h b/lib/libc/include/generic-freebsd/dev/usb/usb_dev.h index a59b404be70213a2e7fed39ac0e485a0dc4b5cd7..119f99d56fed826129671898091c8a7a4b6e6bd2 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_dev.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_dev.h @@ -96,7 +96,7 @@ struct usb_fs_privdata { int fifo_index; struct cdev *cdev; - LIST_ENTRY(usb_fs_privdata) pd_next; + SLIST_ENTRY(usb_fs_privdata) pd_next; }; /* diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_device.h b/lib/libc/include/generic-freebsd/dev/usb/usb_device.h index 3443d4df5129f3cf5a1f85e1e438ebed0317a4bc..83e455a73fe947f918a7660080b3857cfbbca797 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_device.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_device.h @@ -225,7 +225,7 @@ struct usb_device { struct usb_fifo *fifo[USB_FIFO_MAX]; struct usb_symlink *ugen_symlink; /* our generic symlink */ struct usb_fs_privdata *ctrl_dev; /* Control Endpoint 0 device node */ - LIST_HEAD(,usb_fs_privdata) pd_list; + SLIST_HEAD(,usb_fs_privdata) pd_list; char ugen_name[20]; /* name of ugenX.X device */ #endif usb_ticks_t plugtime; /* copy of "ticks" */ diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h b/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h index 937835a08c9c42a27d0000323d253482936634a6..551df441b3fc0c378bbeb6fb9316c2dc20ca2fb2 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd.h @@ -42,6 +42,7 @@ #define USB_HAVE_TT_SUPPORT 1 #define USB_HAVE_POWERD 1 #define USB_HAVE_MSCTEST 1 +#define USB_HAVE_MSCTEST_AUTOQUIRK 0 #define USB_HAVE_MSCTEST_DETACH 1 #define USB_HAVE_PF 1 #define USB_HAVE_ROOT_MOUNT_HOLD 1 diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h b/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h index 2548d9deb4f710e88193b357a9a3807a587aeed8..526ea167cc483ad407261070eb45b402ec8402cf 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_freebsd_loader.h @@ -42,6 +42,7 @@ #define USB_HAVE_TT_SUPPORT 1 #define USB_HAVE_POWERD 1 #define USB_HAVE_MSCTEST 1 +#define USB_HAVE_MSCTEST_AUTOQUIRK 0 #define USB_HAVE_MSCTEST_DETACH 0 #define USB_HAVE_PF 0 #define USB_HAVE_ROOT_MOUNT_HOLD 0 diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_ioctl.h b/lib/libc/include/generic-freebsd/dev/usb/usb_ioctl.h index 51f09c1c19ec74537b911fd5ca7851b019f33122..4d1771aaf15a616ec97d6fb6b75ed51e0e36799d 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_ioctl.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_ioctl.h @@ -239,7 +239,7 @@ struct usb_gen_quirk { #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) #define USB_DEVICEENUMERATE _IOW ('U', 6, int) -/* Generic HID device. Numbers 26 and 30-39 are occupied by hidraw. */ +/* Generic HID device. Numbers 26 and 30-49 are occupied by hidraw. */ #define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor) #define USB_SET_IMMED _IOW ('U', 22, int) #define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor) diff --git a/lib/libc/include/generic-freebsd/dev/usb/usb_process.h b/lib/libc/include/generic-freebsd/dev/usb/usb_process.h index f79aaf1cf2ef8547ab0d37bbc098cda30250e800..bb377a9852c272227aa7a29f1e711679a05fe60d 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usb_process.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usb_process.h @@ -31,7 +31,6 @@ #ifndef USB_GLOBAL_INCLUDE_FILE #include #include -#include #endif /* defines */ @@ -76,6 +75,7 @@ int usb_proc_create(struct usb_process *up, struct mtx *p_mtx, const char *pmesg, uint8_t prio); void usb_proc_drain(struct usb_process *up); void usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1); +int usb_proc_mwait_sig(struct usb_process *up, void *pm0, void *pm1); void usb_proc_free(struct usb_process *up); void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1); void usb_proc_rewakeup(struct usb_process *up); diff --git a/lib/libc/include/generic-freebsd/dev/usb/usbdi.h b/lib/libc/include/generic-freebsd/dev/usb/usbdi.h index db954753a55f81c459ed6b1d22eec12fec44c076..afaf4872a54ffac20d7b62b6a49508d6875c53c0 100644 --- a/lib/libc/include/generic-freebsd/dev/usb/usbdi.h +++ b/lib/libc/include/generic-freebsd/dev/usb/usbdi.h @@ -38,6 +38,7 @@ struct usb_process; struct usb_proc_msg; struct usb_mbuf; struct usb_fs_privdata; +struct usb_device_info; struct mbuf; typedef enum { /* keep in sync with usb_errstr_table */ @@ -525,6 +526,8 @@ struct usb_proc_msg { usb_size_t pm_num; }; +#define USB_PROC_MSG_ENQUEUED(msg) ((msg)->pm_qentry.tqe_prev != NULL) + #define USB_FIFO_TX 0 #define USB_FIFO_RX 1 @@ -585,6 +588,8 @@ usb_error_t usbd_set_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep, uint8_t ep_mode); uint8_t usbd_get_endpoint_mode(struct usb_device *udev, struct usb_endpoint *ep); +int usbd_fill_deviceinfo(struct usb_device *udev, + struct usb_device_info *di); const struct usb_device_id *usbd_lookup_id_by_info( const struct usb_device_id *id, usb_size_t sizeof_id, diff --git a/lib/libc/include/generic-freebsd/dev/veriexec/veriexec_ioctl.h b/lib/libc/include/generic-freebsd/dev/veriexec/veriexec_ioctl.h index 1eeaa77ed1d13f6e5735f7590aec2d7247414e3c..e20cd80a25c77f4f926c68db6fc1f45ebaa0a58e 100644 --- a/lib/libc/include/generic-freebsd/dev/veriexec/veriexec_ioctl.h +++ b/lib/libc/include/generic-freebsd/dev/veriexec/veriexec_ioctl.h @@ -63,7 +63,7 @@ struct verified_exec_label_params { #define VERIEXEC_DEBUG_OFF _IO('S', 0x6) /* reset debug */ #define VERIEXEC_GETSTATE _IOR('S', 0x7, int) /* get state */ #define VERIEXEC_SIGNED_LOAD32 _IOW('S', 0x8, struct verified_exec_params32) -#define VERIEXEC_VERIFIED_FILD _IOW('S', 0x9, int) /* fd */ +#define VERIEXEC_VERIFIED_FILE _IOW('S', 0x9, int) /* fd */ #define VERIEXEC_GETVERSION _IOR('S', 0xa, int) /* get version */ #define VERIEXEC_LABEL_LOAD _IOW('S', 0xb, struct verified_exec_label_params) #define VERIEXEC_SIGNED_LOAD _IOW('S', 0xc, struct verified_exec_params) diff --git a/lib/libc/include/generic-freebsd/dev/wg/if_wg.h b/lib/libc/include/generic-freebsd/dev/wg/if_wg.h index b6750892c8cb55c0297be1aae67fcfaaa10e2613..d73516e769a314c8d18bd73a4010847a03f4b682 100644 --- a/lib/libc/include/generic-freebsd/dev/wg/if_wg.h +++ b/lib/libc/include/generic-freebsd/dev/wg/if_wg.h @@ -32,4 +32,10 @@ struct wg_data_io { #define SIOCSWG _IOWR('i', 210, struct wg_data_io) #define SIOCGWG _IOWR('i', 211, struct wg_data_io) + +/* Keep these in sync with wireguard-tools:containers.h */ +#define WGALLOWEDIP_REMOVE_ME 0x0001 + +#define WGALLOWEDIP_VALID_FLAGS WGALLOWEDIP_REMOVE_ME + #endif /* __IF_WG_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/dirent.h b/lib/libc/include/generic-freebsd/dirent.h index 597a4d517154a2bed73b28a9f740d111b3f5abb4..e29b29805e7eecebe5a44763adf39be81a6bbe64 100644 --- a/lib/libc/include/generic-freebsd/dirent.h +++ b/lib/libc/include/generic-freebsd/dirent.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dirent.h 8.2 (Berkeley) 7/28/94 */ #ifndef _DIRENT_H_ @@ -118,7 +116,8 @@ DIR *fdopendir(int); struct dirent * readdir(DIR *); #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 -int readdir_r(DIR *, struct dirent *, struct dirent **); +int readdir_r(DIR *, struct dirent *, struct dirent **) + __deprecated1("Does not take variable {NAME_MAX} into account"); #endif void rewinddir(DIR *); #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 @@ -132,9 +131,22 @@ int scandir_b(const char *, struct dirent ***, #endif #endif #if __BSD_VISIBLE +int fdscandir(int, struct dirent ***, + int (*)(const struct dirent *), int (*)(const struct dirent **, + const struct dirent **)); +#ifdef __BLOCKS__ +int fdscandir_b(int, struct dirent ***, + int (^)(const struct dirent *), + int (^)(const struct dirent **, const struct dirent **)); +#endif int scandirat(int, const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); +#ifdef __BLOCKS__ +int scandirat_b(int, const char *, struct dirent ***, + int (^)(const struct dirent *), + int (^)(const struct dirent **, const struct dirent **)); +#endif #endif #if __XSI_VISIBLE void seekdir(DIR *, long); diff --git a/lib/libc/include/generic-freebsd/dlfcn.h b/lib/libc/include/generic-freebsd/dlfcn.h index 0d4f1902d4ceefb7d3baa69505844dc9c775cb09..c608aefe67ad921fda45ba5c209a9a042ee3ec54 100644 --- a/lib/libc/include/generic-freebsd/dlfcn.h +++ b/lib/libc/include/generic-freebsd/dlfcn.h @@ -32,6 +32,7 @@ #ifndef _DLFCN_H_ #define _DLFCN_H_ +#include #include /* diff --git a/lib/libc/include/generic-freebsd/endian.h b/lib/libc/include/generic-freebsd/endian.h index c73f87b1e90b27b0008c7a436ab8513e14b1569d..b30db5816fc00680c6db00e578973ba656f598ca 100644 --- a/lib/libc/include/generic-freebsd/endian.h +++ b/lib/libc/include/generic-freebsd/endian.h @@ -11,9 +11,34 @@ #ifndef _ENDIAN_H_ #define _ENDIAN_H_ +/* + * POSIX.1-2024 requires that endian.h define uint{16,32,64}_t. Although POSIX + * allows stdint.h symbols here, be conservative and only define there required + * ones. FreeBSD's sys/_endian.h doesn't need to expose those types since it + * implements all the [bl]eXtoh hto[bl]eX interfaces as macros calling builtin + * functions. POSIX.1-2024 allows functions, macros or both. We opt for macros + * only. + */ +#include + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + /* * FreeBSD's sys/_endian.h is very close to the interface provided on Linux by - * glibc's endian.h. + * glibc's endian.h as well as POSIX.1-2024's endian.h. */ #include diff --git a/lib/libc/include/generic-freebsd/err.h b/lib/libc/include/generic-freebsd/err.h index b68463a94b4e336057c8b4430745fa82d8f61e60..111b6d2015c4f5c53aa98b9a9c98caca697f2750 100644 --- a/lib/libc/include/generic-freebsd/err.h +++ b/lib/libc/include/generic-freebsd/err.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)err.h 8.1 (Berkeley) 6/2/93 */ #ifndef _ERR_H_ diff --git a/lib/libc/include/generic-freebsd/errno.h b/lib/libc/include/generic-freebsd/errno.h index cdeb8fbcadc4bd52a0a94df763f9abdff88e51a7..6238ec73d92dec43090a299febee944658eea60d 100644 --- a/lib/libc/include/generic-freebsd/errno.h +++ b/lib/libc/include/generic-freebsd/errno.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)errno.h 8.5 (Berkeley) 1/21/94 */ #ifndef _SYS_ERRNO_H_ diff --git a/lib/libc/include/generic-freebsd/execinfo.h b/lib/libc/include/generic-freebsd/execinfo.h index 99eafc35ffd525b83a10b81049367caf0e6de446..903f4530d9482b3c4d0822d7cf4df9f5835f5286 100644 --- a/lib/libc/include/generic-freebsd/execinfo.h +++ b/lib/libc/include/generic-freebsd/execinfo.h @@ -32,6 +32,8 @@ #ifndef _EXECINFO_H_ #define _EXECINFO_H_ +#include + #include __BEGIN_DECLS diff --git a/lib/libc/include/generic-freebsd/exterr.h b/lib/libc/include/generic-freebsd/exterr.h new file mode 100644 index 0000000000000000000000000000000000000000..052913a7edbc652ac35e781494256c572b3674c8 --- /dev/null +++ b/lib/libc/include/generic-freebsd/exterr.h @@ -0,0 +1,21 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * All rights reserved. + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#ifndef _EXTERR_H_ +#define _EXTERR_H_ + +#include +#include + +__BEGIN_DECLS +int uexterr_gettext(char *buf, size_t bufsz); +__END_DECLS + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fcntl.h b/lib/libc/include/generic-freebsd/fcntl.h index d0d93108b5e9d7794f314221deac746d5b85f774..0120afe643a11b791a17396bf157888545fb32df 100644 --- a/lib/libc/include/generic-freebsd/fcntl.h +++ b/lib/libc/include/generic-freebsd/fcntl.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 */ #ifndef _SYS_FCNTL_H_ @@ -142,8 +140,24 @@ typedef __pid_t pid_t; #define O_DSYNC 0x01000000 /* POSIX data sync */ #if __BSD_VISIBLE #define O_EMPTY_PATH 0x02000000 +#define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */ +#define O_XATTR O_NAMEDATTR /* Solaris compatibility */ #endif +#if __POSIX_VISIBLE >= 202405 +#define O_CLOFORK 0x08000000 +#endif + +/* + * !!! DANGER !!! + * + * There are very few bits left for O_* flags. Every bit we consume for + * local features is one bit we can't use for future source compatibility + * with other operating systems. + * + * All additions should be coordinated with srcmgr@. + */ + /* * XXX missing O_RSYNC. */ @@ -270,6 +284,16 @@ typedef __pid_t pid_t; #define F_GET_SEALS 20 #define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */ #define F_KINFO 22 /* Return kinfo_file for this fd */ +#endif /* __BSD_VISIBLE */ + +#if __POSIX_VISIBLE >= 202405 +#define F_DUPFD_CLOFORK 23 /* Like F_DUPFD, but FD_CLOFORK is set */ +#endif + +#if __BSD_VISIBLE +#define F_DUP3FD 24 /* Used with dup3() */ + +#define F_DUP3FD_SHIFT 16 /* Shift used for F_DUP3FD */ /* Seals (F_ADD_SEALS, F_GET_SEALS). */ #define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */ @@ -280,6 +304,11 @@ typedef __pid_t pid_t; /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ +#define FD_RESOLVE_BENEATH 2 /* all lookups relative to fd have + O_RESOLVE_BENEATH semantics */ +#if __POSIX_VISIBLE >= 202405 +#define FD_CLOFORK 4 /* close-on-fork flag */ +#endif /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ #define F_RDLCK 1 /* shared or read lock */ diff --git a/lib/libc/include/generic-freebsd/fenv.h b/lib/libc/include/generic-freebsd/fenv.h index 1838590a9950fd2ddfeb88d71094a6525f1b117d..3f511b649c27bce6386552d238177be428320ddd 100644 --- a/lib/libc/include/generic-freebsd/fenv.h +++ b/lib/libc/include/generic-freebsd/fenv.h @@ -29,277 +29,320 @@ #ifndef _FENV_H_ #define _FENV_H_ +#include #include -#include +#include #ifndef __fenv_static #define __fenv_static static #endif -typedef __uint32_t fenv_t; -typedef __uint32_t fexcept_t; +typedef __uint16_t fexcept_t; /* Exception flags */ -#ifdef __SPE__ -#define FE_OVERFLOW 0x00000100 -#define FE_UNDERFLOW 0x00000200 -#define FE_DIVBYZERO 0x00000400 -#define FE_INVALID 0x00000800 -#define FE_INEXACT 0x00001000 - -#define FE_ALL_INVALID FE_INVALID - -#define _FPUSW_SHIFT 6 -#else -#define FE_INEXACT 0x02000000 -#define FE_DIVBYZERO 0x04000000 -#define FE_UNDERFLOW 0x08000000 -#define FE_OVERFLOW 0x10000000 -#define FE_INVALID 0x20000000 /* all types of invalid FP ops */ - -/* - * The PowerPC architecture has extra invalid flags that indicate the - * specific type of invalid operation occurred. These flags may be - * tested, set, and cleared---but not masked---separately. All of - * these bits are cleared when FE_INVALID is cleared, but only - * FE_VXSOFT is set when FE_INVALID is explicitly set in software. - */ -#define FE_VXCVI 0x00000100 /* invalid integer convert */ -#define FE_VXSQRT 0x00000200 /* square root of a negative */ -#define FE_VXSOFT 0x00000400 /* software-requested exception */ -#define FE_VXVC 0x00080000 /* ordered comparison involving NaN */ -#define FE_VXIMZ 0x00100000 /* inf * 0 */ -#define FE_VXZDZ 0x00200000 /* 0 / 0 */ -#define FE_VXIDI 0x00400000 /* inf / inf */ -#define FE_VXISI 0x00800000 /* inf - inf */ -#define FE_VXSNAN 0x01000000 /* operation on a signalling NaN */ -#define FE_ALL_INVALID (FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \ - FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \ - FE_VXSNAN | FE_INVALID) - -#define _FPUSW_SHIFT 22 -#endif -#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ - FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW) +#define FE_INVALID 0x01 +#define FE_DENORMAL 0x02 +#define FE_DIVBYZERO 0x04 +#define FE_OVERFLOW 0x08 +#define FE_UNDERFLOW 0x10 +#define FE_INEXACT 0x20 +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \ + FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) /* Rounding modes */ #define FE_TONEAREST 0x0000 -#define FE_TOWARDZERO 0x0001 -#define FE_UPWARD 0x0002 -#define FE_DOWNWARD 0x0003 +#define FE_DOWNWARD 0x0400 +#define FE_UPWARD 0x0800 +#define FE_TOWARDZERO 0x0c00 #define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ FE_UPWARD | FE_TOWARDZERO) +/* + * As compared to the x87 control word, the SSE unit's control word + * has the rounding control bits offset by 3 and the exception mask + * bits offset by 7. + */ +#define _SSE_ROUND_SHIFT 3 +#define _SSE_EMASK_SHIFT 7 + +#ifdef __i386__ +/* + * To preserve binary compatibility with FreeBSD 5.3, we pack the + * mxcsr into some reserved fields, rather than changing sizeof(fenv_t). + */ +typedef struct { + __uint16_t __control; + __uint16_t __mxcsr_hi; + __uint16_t __status; + __uint16_t __mxcsr_lo; + __uint32_t __tag; + char __other[16]; +} fenv_t; +#else /* __amd64__ */ +typedef struct { + struct { + __uint32_t __control; + __uint32_t __status; + __uint32_t __tag; + char __other[16]; + } __x87; + __uint32_t __mxcsr; +} fenv_t; +#endif /* __i386__ */ + __BEGIN_DECLS /* Default floating-point environment */ extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) -/* We need to be able to map status flag positions to mask flag positions */ -#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \ - FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT) - -#ifndef _SOFT_FLOAT -#ifdef __SPE__ -#define __mffs(__env) \ - __asm __volatile("mfspr %0, 512" : "=r" ((__env)->__bits.__reg)) -#define __mtfsf(__env) \ - __asm __volatile("mtspr 512,%0;isync" :: "r" ((__env).__bits.__reg)) -#else -#define __mffs(__env) \ - __asm __volatile("mffs %0" : "=f" ((__env)->__d)) -#define __mtfsf(__env) \ - __asm __volatile("mtfsf 255,%0" :: "f" ((__env).__d)) -#endif -#else -#define __mffs(__env) -#define __mtfsf(__env) -#endif - -union __fpscr { - double __d; - struct { -#if _BYTE_ORDER == _LITTLE_ENDIAN - fenv_t __reg; - __uint32_t __junk; -#else - __uint32_t __junk; - fenv_t __reg; -#endif - } __bits; -}; - -__fenv_static inline int -feclearexcept(int __excepts) -{ - union __fpscr __r; - - if (__excepts & FE_INVALID) - __excepts |= FE_ALL_INVALID; - __mffs(&__r); - __r.__bits.__reg &= ~__excepts; - __mtfsf(__r); - return (0); -} - -__fenv_static inline int -fegetexceptflag(fexcept_t *__flagp, int __excepts) -{ - union __fpscr __r; - - __mffs(&__r); - *__flagp = __r.__bits.__reg & __excepts; - return (0); -} - -__fenv_static inline int -fesetexceptflag(const fexcept_t *__flagp, int __excepts) -{ - union __fpscr __r; - - if (__excepts & FE_INVALID) - __excepts |= FE_ALL_INVALID; - __mffs(&__r); - __r.__bits.__reg &= ~__excepts; - __r.__bits.__reg |= *__flagp & __excepts; - __mtfsf(__r); - return (0); -} - -#ifdef __SPE__ -extern int feraiseexcept(int __excepts); -#else -__fenv_static inline int -feraiseexcept(int __excepts) -{ - union __fpscr __r; - - if (__excepts & FE_INVALID) - __excepts |= FE_VXSOFT; - __mffs(&__r); - __r.__bits.__reg |= __excepts; - __mtfsf(__r); - return (0); -} -#endif - -__fenv_static inline int -fetestexcept(int __excepts) -{ - union __fpscr __r; - - __mffs(&__r); - return (__r.__bits.__reg & __excepts); -} +#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \ + : "st", "st(1)", "st(2)", "st(3)", "st(4)", \ + "st(5)", "st(6)", "st(7)") +#define __fwait() __asm __volatile("fwait") + +int fegetenv(fenv_t *__envp); +int feholdexcept(fenv_t *__envp); +int fesetexceptflag(const fexcept_t *__flagp, int __excepts); +int feraiseexcept(int __excepts); +int feupdateenv(const fenv_t *__envp); __fenv_static inline int fegetround(void) { - union __fpscr __r; - - __mffs(&__r); - return (__r.__bits.__reg & _ROUND_MASK); -} - -__fenv_static inline int -fesetround(int __round) -{ - union __fpscr __r; - - if (__round & ~_ROUND_MASK) - return (-1); - __mffs(&__r); - __r.__bits.__reg &= ~_ROUND_MASK; - __r.__bits.__reg |= __round; - __mtfsf(__r); - return (0); -} - -__fenv_static inline int -fegetenv(fenv_t *__envp) -{ - union __fpscr __r; - - __mffs(&__r); - *__envp = __r.__bits.__reg; - return (0); -} - -__fenv_static inline int -feholdexcept(fenv_t *__envp) -{ - union __fpscr __r; - - __mffs(&__r); - *__envp = __r.__bits.__reg; - __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); - __mtfsf(__r); - return (0); -} - -__fenv_static inline int -fesetenv(const fenv_t *__envp) -{ - union __fpscr __r; - - __r.__bits.__reg = *__envp; - __mtfsf(__r); - return (0); -} - -__fenv_static inline int -feupdateenv(const fenv_t *__envp) -{ - union __fpscr __r; - - __mffs(&__r); - __r.__bits.__reg &= FE_ALL_EXCEPT; - __r.__bits.__reg |= *__envp; - __mtfsf(__r); - return (0); + __uint16_t __control; + + /* + * We assume that the x87 and the SSE unit agree on the + * rounding mode. Reading the control word on the x87 turns + * out to be about 5 times faster than reading it on the SSE + * unit on an Opteron 244. + */ + __fnstcw(&__control); + return (__control & _ROUND_MASK); } #if __BSD_VISIBLE -__fenv_static inline int -feenableexcept(int __mask) -{ - union __fpscr __r; - fenv_t __oldmask; - - __mffs(&__r); - __oldmask = __r.__bits.__reg; - __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT; - __mtfsf(__r); - return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); -} - -__fenv_static inline int -fedisableexcept(int __mask) -{ - union __fpscr __r; - fenv_t __oldmask; - - __mffs(&__r); - __oldmask = __r.__bits.__reg; - __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT); - __mtfsf(__r); - return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); -} +int feenableexcept(int __mask); +int fedisableexcept(int __mask); /* We currently provide no external definition of fegetexcept(). */ static inline int fegetexcept(void) { - union __fpscr __r; + __uint16_t __control; - __mffs(&__r); - return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT); + /* + * We assume that the masks for the x87 and the SSE unit are + * the same. + */ + __fnstcw(&__control); + return (~__control & FE_ALL_EXCEPT); } #endif /* __BSD_VISIBLE */ +#ifdef __i386__ + +/* After testing for SSE support once, we cache the result in __has_sse. */ +enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK }; +extern enum __sse_support __has_sse; +int __test_sse(void); +#ifdef __SSE__ +#define __HAS_SSE() 1 +#else +#define __HAS_SSE() (__has_sse == __SSE_YES || \ + (__has_sse == __SSE_UNK && __test_sse())) +#endif + +#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \ + ((env).__mxcsr_lo)) +#define __set_mxcsr(env, x) do { \ + (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \ + (env).__mxcsr_lo = (__uint16_t)(x); \ +} while (0) + +__fenv_static inline int +feclearexcept(int __excepts) +{ + fenv_t __env; + __uint32_t __mxcsr; + + if (__excepts == FE_ALL_EXCEPT) { + __fnclex(); + } else { + __fnstenv(&__env); + __env.__status &= ~__excepts; + __fldenv(&__env); + } + if (__HAS_SSE()) { + __stmxcsr(&__mxcsr); + __mxcsr &= ~__excepts; + __ldmxcsr(&__mxcsr); + } + return (0); +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + __uint32_t __mxcsr; + __uint16_t __status; + + __fnstsw(&__status); + if (__HAS_SSE()) + __stmxcsr(&__mxcsr); + else + __mxcsr = 0; + *__flagp = (__mxcsr | __status) & __excepts; + return (0); +} + +__fenv_static inline int +fetestexcept(int __excepts) +{ + __uint32_t __mxcsr; + __uint16_t __status; + + __fnstsw(&__status); + if (__HAS_SSE()) + __stmxcsr(&__mxcsr); + else + __mxcsr = 0; + return ((__status | __mxcsr) & __excepts); +} + +__fenv_static inline int +fesetround(int __round) +{ + __uint32_t __mxcsr; + __uint16_t __control; + + if (__round & ~_ROUND_MASK) + return (-1); + + __fnstcw(&__control); + __control &= ~_ROUND_MASK; + __control |= __round; + __fldcw(&__control); + + if (__HAS_SSE()) { + __stmxcsr(&__mxcsr); + __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); + __mxcsr |= __round << _SSE_ROUND_SHIFT; + __ldmxcsr(&__mxcsr); + } + + return (0); +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + fenv_t __env = *__envp; + __uint32_t __mxcsr; + + __mxcsr = __get_mxcsr(__env); + __set_mxcsr(__env, 0xffffffff); + /* + * XXX Using fldenvx() instead of fldenv() tells the compiler that this + * instruction clobbers the i387 register stack. This happens because + * we restore the tag word from the saved environment. Normally, this + * would happen anyway and we wouldn't care, because the ABI allows + * function calls to clobber the i387 regs. However, fesetenv() is + * inlined, so we need to be more careful. + */ + __fldenvx(__env); + if (__HAS_SSE()) + __ldmxcsr(&__mxcsr); + return (0); +} + +#else /* __amd64__ */ + +__fenv_static inline int +feclearexcept(int __excepts) +{ + fenv_t __env; + + if (__excepts == FE_ALL_EXCEPT) { + __fnclex(); + } else { + __fnstenv(&__env.__x87); + __env.__x87.__status &= ~__excepts; + __fldenv(&__env.__x87); + } + __stmxcsr(&__env.__mxcsr); + __env.__mxcsr &= ~__excepts; + __ldmxcsr(&__env.__mxcsr); + return (0); +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + __uint32_t __mxcsr; + __uint16_t __status; + + __stmxcsr(&__mxcsr); + __fnstsw(&__status); + *__flagp = (__mxcsr | __status) & __excepts; + return (0); +} + +__fenv_static inline int +fetestexcept(int __excepts) +{ + __uint32_t __mxcsr; + __uint16_t __status; + + __stmxcsr(&__mxcsr); + __fnstsw(&__status); + return ((__status | __mxcsr) & __excepts); +} + +__fenv_static inline int +fesetround(int __round) +{ + __uint32_t __mxcsr; + __uint16_t __control; + + if (__round & ~_ROUND_MASK) + return (-1); + + __fnstcw(&__control); + __control &= ~_ROUND_MASK; + __control |= __round; + __fldcw(&__control); + + __stmxcsr(&__mxcsr); + __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); + __mxcsr |= __round << _SSE_ROUND_SHIFT; + __ldmxcsr(&__mxcsr); + + return (0); +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + + /* + * XXX Using fldenvx() instead of fldenv() tells the compiler that this + * instruction clobbers the i387 register stack. This happens because + * we restore the tag word from the saved environment. Normally, this + * would happen anyway and we wouldn't care, because the ABI allows + * function calls to clobber the i387 regs. However, fesetenv() is + * inlined, so we need to be more careful. + */ + __fldenvx(__envp->__x87); + __ldmxcsr(&__envp->__mxcsr); + return (0); +} + +#endif /* __i386__ */ + __END_DECLS #endif /* !_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/float.h b/lib/libc/include/generic-freebsd/float.h index a39a98229f7704483df10d942ca04f9610fc5660..0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff 100644 --- a/lib/libc/include/generic-freebsd/float.h +++ b/lib/libc/include/generic-freebsd/float.h @@ -1,100 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 - * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 + * This file is in the public domain. */ -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ 1 - -#include - -#ifndef _SOFT_FLOAT -__BEGIN_DECLS -extern int __flt_rounds(void); -__END_DECLS -#define FLT_ROUNDS __flt_rounds() -#else -#define FLT_ROUNDS (-1) -#endif - -#define FLT_RADIX 2 /* b */ -#if __ISO_C_VISIBLE >= 1999 -#define FLT_EVAL_METHOD 0 -#define DECIMAL_DIG 17 /* max precision in decimal digits */ -#endif - -#define FLT_MANT_DIG 24 /* p */ -#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ -#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ -#define FLT_MIN_EXP (-125) /* emin */ -#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ -#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ -#define FLT_MAX_EXP 128 /* emax */ -#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ -#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ -#if __ISO_C_VISIBLE >= 2011 -#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */ -#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */ -#define FLT_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define DBL_MANT_DIG 53 -#define DBL_EPSILON 2.2204460492503131E-16 -#define DBL_DIG 15 -#define DBL_MIN_EXP (-1021) -#define DBL_MIN 2.2250738585072014E-308 -#define DBL_MIN_10_EXP (-307) -#define DBL_MAX_EXP 1024 -#define DBL_MAX 1.7976931348623157E+308 -#define DBL_MAX_10_EXP 308 -#if __ISO_C_VISIBLE >= 2011 -#define DBL_TRUE_MIN 4.9406564584124654E-324 -#define DBL_DECIMAL_DIG 17 -#define DBL_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define LDBL_MANT_DIG DBL_MANT_DIG -#define LDBL_EPSILON ((long double)DBL_EPSILON) -#define LDBL_DIG DBL_DIG -#define LDBL_MIN_EXP DBL_MIN_EXP -#define LDBL_MIN ((long double)DBL_MIN) -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP -#define LDBL_MAX_EXP DBL_MAX_EXP -#define LDBL_MAX ((long double)DBL_MAX) -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP -#if __ISO_C_VISIBLE >= 2011 -#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN) -#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG -#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#endif /* _MACHINE_FLOAT_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/floatingpoint.h b/lib/libc/include/generic-freebsd/floatingpoint.h index d2c7e15ad2e8ae4c8fff302ee2365f352fd05c79..e05bc6f49c01b58a31ef2055a4e9103338a3b56d 100644 --- a/lib/libc/include/generic-freebsd/floatingpoint.h +++ b/lib/libc/include/generic-freebsd/floatingpoint.h @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause + * SPDX-License-Identifier: BSD-4-Clause * - * Copyright (c) 2004 Suleiman Souhlal + * Copyright (c) 1993 Andrew Moore, Talke Studio * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,11 +12,15 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of any co-contributors + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE @@ -32,6 +36,7 @@ #ifndef _FLOATINGPOINT_H_ #define _FLOATINGPOINT_H_ +#include #include #endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fnmatch.h b/lib/libc/include/generic-freebsd/fnmatch.h index 79253d2c574e4c87486a3e26a80b03f771431657..d19d301091ffe9c431b413132ac54ba3a5a495d9 100644 --- a/lib/libc/include/generic-freebsd/fnmatch.h +++ b/lib/libc/include/generic-freebsd/fnmatch.h @@ -27,7 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 */ #ifndef _FNMATCH_H_ diff --git a/lib/libc/include/generic-freebsd/fs/devfs/devfs.h b/lib/libc/include/generic-freebsd/fs/devfs/devfs.h index 29227b28984450138a89b6dd3a57b438ee422c6f..78473fbef7eeca577351a39b1c9ec31976ab326d 100644 --- a/lib/libc/include/generic-freebsd/fs/devfs/devfs.h +++ b/lib/libc/include/generic-freebsd/fs/devfs/devfs.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)kernfs.h 8.6 (Berkeley) 3/29/95 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14 */ diff --git a/lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h b/lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h index f7dca514557b38d4ef9578df6ed31755cdd4328c..4a95b37fa02adf7976482ec56595dd3583040379 100644 --- a/lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h +++ b/lib/libc/include/generic-freebsd/fs/fdescfs/fdesc.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fdesc.h 8.5 (Berkeley) 1/21/94 */ #ifndef _FS_FDESC_H_ diff --git a/lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h b/lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h index e12afc7a3a47ee737fb5f6f18f12e5a7c1f7371f..d5d922697cf31f7bd9241fc041bf28d2efb5d578 100644 --- a/lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h +++ b/lib/libc/include/generic-freebsd/fs/msdosfs/bootsect.h @@ -20,7 +20,7 @@ /* * Format of a boot sector. This is the first sector on a DOS floppy disk - * or the fist sector of a partition on a hard disk. But, it is not the + * or the first sector of a partition on a hard disk. But, it is not the * first sector of a partitioned hard disk. */ struct bootsector33 { diff --git a/lib/libc/include/generic-freebsd/fs/msdosfs/denode.h b/lib/libc/include/generic-freebsd/fs/msdosfs/denode.h index 6eedf0eeca0003a178201388277d0f3b5829af13..c437075c4ec2bb9a763221f9e7d7a31922dea320 100644 --- a/lib/libc/include/generic-freebsd/fs/msdosfs/denode.h +++ b/lib/libc/include/generic-freebsd/fs/msdosfs/denode.h @@ -212,7 +212,7 @@ struct denode { ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \ putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16)) -#if defined(_KERNEL) || defined(MAKEFS) +#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS) #define VTODE(vp) ((struct denode *)(vp)->v_data) #define DETOV(de) ((de)->de_vnode) @@ -294,5 +294,5 @@ int removede(struct denode *pdep, struct denode *dep); int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred); int doscheckpath( struct denode *source, struct denode *target, daddr_t *wait_scn); -#endif /* _KERNEL || MAKEFS */ +#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */ #endif /* !_FS_MSDOSFS_DENODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fs/msdosfs/fat.h b/lib/libc/include/generic-freebsd/fs/msdosfs/fat.h index 014ff14a4ec35a48829bd13b85d4a7df06a6b92d..df3865028840feea70abbe43c2a9a20db479f487 100644 --- a/lib/libc/include/generic-freebsd/fs/msdosfs/fat.h +++ b/lib/libc/include/generic-freebsd/fs/msdosfs/fat.h @@ -81,7 +81,7 @@ #define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS) -#if defined (_KERNEL) || defined(MAKEFS) +#if defined (_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS) /* * These are the values for the function argument to the function * fatentry(). @@ -110,5 +110,5 @@ markvoldirty(struct msdosfsmount *pmp, bool dirty) return (markvoldirty_upgrade(pmp, dirty, false)); } -#endif /* _KERNEL || MAKEFS */ +#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */ #endif /* !_FS_MSDOSFS_FAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fs/msdosfs/msdosfsmount.h b/lib/libc/include/generic-freebsd/fs/msdosfs/msdosfsmount.h index 9a4fc568dde9ef11f67114baa4c4336c3a777c25..45a72cdd48a976ed095b546307a29588b1c10c4d 100644 --- a/lib/libc/include/generic-freebsd/fs/msdosfs/msdosfsmount.h +++ b/lib/libc/include/generic-freebsd/fs/msdosfs/msdosfsmount.h @@ -52,14 +52,17 @@ #ifndef _MSDOSFS_MSDOSFSMOUNT_H_ #define _MSDOSFS_MSDOSFSMOUNT_H_ -#if defined (_KERNEL) || defined(MAKEFS) +#if defined(_KERNEL) || defined(_WANT_MSDOSFS_INTERNALS) #include -#ifndef MAKEFS +#ifdef _KERNEL #include #include +#else +#include +#include +#endif #include -#endif #include #ifdef MALLOC_DECLARE @@ -114,11 +117,8 @@ struct msdosfsmount { void *pm_w2u; /* Unicode->Local iconv handle */ void *pm_u2d; /* Unicode->DOS iconv handle */ void *pm_d2u; /* DOS->Local iconv handle */ -#ifndef MAKEFS struct lock pm_fatlock; /* lockmgr protecting allocations */ - struct lock pm_checkpath_lock; /* protects doscheckpath result */ struct task pm_rw2ro_task; /* context for emergency remount ro */ -#endif }; /* @@ -245,9 +245,9 @@ struct msdosfs_fileno { #define MSDOSFS_ASSERT_MP_LOCKED(pmp) \ lockmgr_assert(&(pmp)->pm_fatlock, KA_XLOCKED) -#endif /* _KERNEL || MAKEFS */ +#endif /* _KERNEL || _WANT_MSDOSFS_INTERNALS */ -#ifndef MAKEFS +#ifdef _KERNEL /* * Arguments to mount MSDOS filesystems. */ @@ -265,7 +265,7 @@ struct msdosfs_args { char *cs_local; /* Local Charset */ mode_t dirmask; /* dir mask to be applied for msdosfs perms */ }; -#endif /* MAKEFS */ +#endif /* _KERNEL */ /* * Msdosfs mount options: diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfs.h b/lib/libc/include/generic-freebsd/fs/nfs/nfs.h index f3ec45352b7dbcc6b2d710fa7bae60c22198a7a3..72c52134d457e4cd85c31932470a8605555035bf 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfs.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfs.h @@ -865,6 +865,8 @@ struct nfsslot { /* Enumerated type for nfsuserd state. */ typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state; +typedef enum { UNKNOWN=0, DELETED=1, NLINK_ZERO=2, VALID=3 } nfsremove_status; + #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfs_var.h b/lib/libc/include/generic-freebsd/fs/nfs/nfs_var.h index 0a4d70898b24b13079450a529e1901cd0c9a86c9..42e71e33ec9ca125d13abb881b1aa64e419923ea 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfs_var.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfs_var.h @@ -169,6 +169,7 @@ int nfsrv_mdscopymr(char *, char *, char *, char *, int *, char *, NFSPROC_T *, struct vnode **, struct vnode **, struct pnfsdsfile **, struct nfsdevice **, struct nfsdevice **); void nfsrv_marknospc(char *, bool); +void nfsrv_removedeleg(fhandle_t *, struct nfsrv_descript *, NFSPROC_T *); /* nfs_nfsdserv.c */ int nfsrvd_access(struct nfsrv_descript *, int, @@ -285,6 +286,8 @@ int nfsrvd_deallocate(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); int nfsrvd_copy_file_range(struct nfsrv_descript *, int, vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *); +int nfsrvd_clone(struct nfsrv_descript *, int, + vnode_t, vnode_t, struct nfsexstuff *, struct nfsexstuff *); int nfsrvd_seek(struct nfsrv_descript *, int, vnode_t, struct nfsexstuff *); int nfsrvd_getxattr(struct nfsrv_descript *, int, @@ -340,7 +343,8 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, struct nfsfh **, fhandle_t *, int, struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *, struct nfsfsinfo *, NFSACL_T *, - int, int *, u_int32_t *, u_int32_t *, NFSPROC_T *, struct ucred *); + int, int *, u_int32_t *, u_int32_t *, bool *, uint32_t *, NFSPROC_T *, + struct ucred *); int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *); void nfsv4_unlock(struct nfsv4lock *, int); void nfsv4_relref(struct nfsv4lock *); @@ -394,8 +398,9 @@ int nfsrv_putopbit(struct nfsrv_descript *, nfsopbit_t *); void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int, struct nfsvattr *); int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *, - struct vattr *, fhandle_t *, int, nfsattrbit_t *, - struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *); + struct vattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *, + NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *, bool, bool, + bool, uint32_t); void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *); struct mbuf *nfsrv_adj(struct mbuf *, int, int); void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *); @@ -438,6 +443,7 @@ int nfs_supportsnfsv4acls(vnode_t); /* nfs_commonacl.c */ int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *, bool, int *, int *, NFSPROC_T *); +uint32_t nfs_aceperm(acl_perm_t); int nfsrv_buildacl(struct nfsrv_descript *, NFSACL_T *, __enum_uint8(vtype), NFSPROC_T *); int nfsrv_compareacl(NFSACL_T *, NFSACL_T *); @@ -481,11 +487,13 @@ int nfsrpc_mknod(vnode_t, char *, int, struct vattr *, u_int32_t, int nfsrpc_create(vnode_t, char *, int, struct vattr *, nfsquad_t, int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, struct nfsfh **, int *, int *); -int nfsrpc_remove(vnode_t, char *, int, vnode_t, struct ucred *, NFSPROC_T *, - struct nfsvattr *, int *); -int nfsrpc_rename(vnode_t, vnode_t, char *, int, vnode_t, vnode_t, char *, int, - struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, - int *, int *); +int nfsrpc_remove(struct vnode *, char *, int, struct vnode *, + struct nfsvattr *, int *, nfsremove_status *, struct nfsvattr *, int *, + struct ucred *, NFSPROC_T *); +int nfsrpc_rename(struct vnode *, struct vnode *, char *, int, struct vnode *, + struct vnode *, char *, int, nfsremove_status *, struct nfsvattr *, + struct nfsvattr *, int *, int *, struct nfsvattr *, int *, struct ucred *, + NFSPROC_T *); int nfsrpc_link(vnode_t, vnode_t, char *, int, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsvattr *, int *, int *); @@ -512,10 +520,10 @@ int nfsrpc_lock(struct nfsrv_descript *, struct nfsmount *, vnode_t, u_int8_t *, int, struct nfscllockowner *, int, int, u_int64_t, u_int64_t, short, struct ucred *, NFSPROC_T *, int); int nfsrpc_statfs(vnode_t, struct nfsstatfs *, struct nfsfsinfo *, uint32_t *, - struct ucred *, NFSPROC_T *, struct nfsvattr *, int *); + uint32_t *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *); int nfsrpc_fsinfo(vnode_t, struct nfsfsinfo *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *); -int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *, +int nfsrpc_pathconf(vnode_t, struct nfsv3_pathconf *, bool *, uint32_t *, struct ucred *, NFSPROC_T *, struct nfsvattr *, int *); int nfsrpc_renew(struct nfsclclient *, struct nfsclds *, struct ucred *, NFSPROC_T *); @@ -557,6 +565,8 @@ int nfsrpc_deallocate(vnode_t, off_t, off_t, struct nfsvattr *, int *, int nfsrpc_copy_file_range(vnode_t, off_t *, vnode_t, off_t *, size_t *, unsigned int, int *, struct nfsvattr *, int *, struct nfsvattr *, struct ucred *, bool, bool *); +int nfsrpc_clone(vnode_t, off_t *, vnode_t, off_t *, size_t *, bool, + int *, struct nfsvattr *, int *, struct nfsvattr *, struct ucred *); int nfsrpc_seek(vnode_t, off_t *, bool *, int, struct ucred *, struct nfsvattr *, int *); int nfsrpc_getextattr(vnode_t, const char *, struct uio *, ssize_t *, @@ -568,6 +578,9 @@ int nfsrpc_listextattr(vnode_t, uint64_t *, struct uio *, size_t *, bool *, int nfsrpc_rmextattr(vnode_t, const char *, struct nfsvattr *, int *, struct ucred *, NFSPROC_T *); void nfsrpc_bindconnsess(CLIENT *, void *, struct ucred *); +int nfsrpc_openattr(struct nfsmount *, struct vnode *, uint8_t *, int, + bool, struct ucred *, NFSPROC_T *, struct nfsvattr *, struct nfsfh **, + int *); /* nfs_clstate.c */ int nfscl_open(vnode_t, u_int8_t *, int, u_int32_t, int, @@ -606,12 +619,12 @@ int nfscl_doclose(vnode_t, struct nfsclclient **, NFSPROC_T *); int nfsrpc_doclose(struct nfsmount *, struct nfsclopen *, NFSPROC_T *, bool, bool); int nfscl_deleg(mount_t, struct nfsclclient *, u_int8_t *, int, - struct ucred *, NFSPROC_T *, struct nfscldeleg **); + struct ucred *, NFSPROC_T *, struct nfscldeleg *); void nfscl_lockinit(struct nfsv4lock *); void nfscl_lockexcl(struct nfsv4lock *, void *); void nfscl_lockunlock(struct nfsv4lock *); void nfscl_lockderef(struct nfsv4lock *); -void nfscl_delegreturnvp(vnode_t, NFSPROC_T *); +void nfscl_delegreturnvp(struct vnode *, bool, NFSPROC_T *); void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *); void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *, int); @@ -626,7 +639,7 @@ int nfscl_renamedeleg(vnode_t, nfsv4stateid_t *, int *, vnode_t, nfsv4stateid_t *, int *, NFSPROC_T *); void nfscl_reclaimnode(vnode_t); void nfscl_newnode(vnode_t); -void nfscl_delegmodtime(vnode_t); +void nfscl_delegmodtime(struct vnode *, struct timespec *); void nfscl_deleggetmodtime(vnode_t, struct timespec *); int nfscl_trydelegreturn(struct nfscldeleg *, struct ucred *, struct nfsmount *, NFSPROC_T *); @@ -651,6 +664,8 @@ void nfscl_freelayout(struct nfscllayout *); void nfscl_freeflayout(struct nfsclflayout *); void nfscl_freedevinfo(struct nfscldevinfo *); int nfscl_layoutcommit(vnode_t, NFSPROC_T *); +int nfscl_delegacecheck(struct vnode *, accmode_t, struct ucred *); +void nfscl_startdelegrecall(struct nfsclclient *, struct nfsfh *); /* nfs_clport.c */ int nfscl_nget(mount_t, vnode_t, struct nfsfh *, @@ -658,7 +673,7 @@ int nfscl_nget(mount_t, vnode_t, struct nfsfh *, NFSPROC_T *nfscl_getparent(NFSPROC_T *); void nfscl_start_renewthread(struct nfsclclient *); void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *); -void nfscl_loadfsinfo (struct nfsmount *, struct nfsfsinfo *); +void nfscl_loadfsinfo(struct nfsmount *, struct nfsfsinfo *, uint32_t); void nfscl_delegreturn(struct nfscldeleg *, int, struct nfsmount *, struct ucred *, NFSPROC_T *); void nfsrvd_cbinit(int); @@ -707,12 +722,12 @@ int nfsvno_symlink(struct nameidata *, struct nfsvattr *, char *, int, int, uid_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *); int nfsvno_getsymlink(struct nfsrv_descript *, struct nfsvattr *, NFSPROC_T *, char **, int *); -int nfsvno_removesub(struct nameidata *, int, struct ucred *, NFSPROC_T *, - struct nfsexstuff *); +int nfsvno_removesub(struct nameidata *, bool, struct nfsrv_descript *, + NFSPROC_T *, struct nfsexstuff *); int nfsvno_rmdirsub(struct nameidata *, int, struct ucred *, NFSPROC_T *, struct nfsexstuff *); -int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t, - u_int32_t, struct ucred *, NFSPROC_T *); +int nfsvno_rename(struct nameidata *, struct nameidata *, + struct nfsrv_descript *, NFSPROC_T *); int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *, NFSPROC_T *, struct nfsexstuff *); int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *); @@ -726,7 +741,8 @@ int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct nfsrv_descript *, NFSPROC_T *); int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *, - struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t); + struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, bool, bool, + bool, uint32_t); int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *, NFSACL_T *, NFSPROC_T *); int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *, @@ -780,6 +796,7 @@ int newnfs_request(struct nfsrv_descript *, struct nfsmount *, struct nfsclient *, struct nfssockreq *, vnode_t, NFSPROC_T *, struct ucred *, u_int32_t, u_int32_t, u_char *, int, u_int64_t *, struct nfsclsession *); +void nfs_resetslots(struct nfsclsession *); int newnfs_connect(struct nfsmount *, struct nfssockreq *, struct ucred *, NFSPROC_T *, int, bool, struct __rpc_client **); void newnfs_disconnect(struct nfsmount *, struct nfssockreq *); diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfscl.h b/lib/libc/include/generic-freebsd/fs/nfs/nfscl.h index 702e36387beb3b0b23d7dea8834c70ba136ca10c..c64b25a7df7cb3d012f6d720724eae9bee03890a 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfscl.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfscl.h @@ -68,10 +68,11 @@ struct nfsv4node { * These flag bits are used for the argument to nfscl_fillsattr() to * indicate special handling of the attributes. */ -#define NFSSATTR_FULL 0x1 -#define NFSSATTR_SIZE0 0x2 -#define NFSSATTR_SIZENEG1 0x4 -#define NFSSATTR_SIZERDEV 0x8 +#define NFSSATTR_FULL 0x01 +#define NFSSATTR_SIZE0 0x02 +#define NFSSATTR_SIZENEG1 0x04 +#define NFSSATTR_SIZERDEV 0x08 +#define NFSSATTR_NEWFILE 0x10 /* Use this macro for debug printfs. */ #define NFSCL_DEBUG(level, ...) do { \ diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h b/lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h index a54339e07224c70e0d0d550444529cf87bf15d13..7147929594aa0d30f1b9d426d6b22632fd26b9d3 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfsclstate.h @@ -116,6 +116,10 @@ struct nfsclclient { struct proc *nfsc_renewthread; struct nfsmount *nfsc_nmp; time_t nfsc_expire; + int nfsc_delegcnt; + int nfsc_deleghighwater; + int nfsc_layoutcnt; + int nfsc_layouthighwater; u_int32_t nfsc_clientidrev; u_int32_t nfsc_rev; u_int32_t nfsc_renew; diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfsport.h b/lib/libc/include/generic-freebsd/fs/nfs/nfsport.h index a40aba5cf5e97911d877bcc792e8dabe089b2db1..94ad3c1be990116f609d41f8d4d69a6be9c173f0 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfsport.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfsport.h @@ -439,10 +439,16 @@ /* Do an NFSv4 Verify+Write. */ #define NFSPROC_APPENDWRITE 69 +/* Do a NFSv4 Openattr. */ +#define NFSPROC_OPENATTR 70 + +/* Do a NFSv4.2 Clone. */ +#define NFSPROC_CLONE 71 + /* * Must be defined as one higher than the last NFSv4.2 Proc# above. */ -#define NFSV42_NPROCS 70 +#define NFSV42_NPROCS 72 /* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */ #define NFSV42_OLDNPROCS 69 @@ -474,7 +480,7 @@ struct nfsstatsv1 { uint64_t readlink_bios; uint64_t biocache_readdirs; uint64_t readdir_bios; - uint64_t rpccnt[NFSV42_NPROCS + 10]; + uint64_t rpccnt[NFSV42_NPROCS + 8]; uint64_t rpcretries; uint64_t srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15]; uint64_t srvlayouts; @@ -690,6 +696,7 @@ struct nfsvattr { #define na_bytes na_vattr.va_bytes #define na_filerev na_vattr.va_filerev #define na_vaflags na_vattr.va_vaflags +#define na_bsdflags na_vattr.va_bsdflags #include @@ -901,15 +908,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *); #define NFSBCMP(s, d, l) bcmp((s), (d), (l)) #define NFSBZERO(s, l) bzero((s), (l)) -/* - * Some queue.h files don't have these dfined in them. - */ -#ifndef LIST_END -#define LIST_END(head) NULL -#define SLIST_END(head) NULL -#define TAILQ_END(head) NULL -#endif - /* * This must be defined to be a global variable that increments once * per second, but never stops or goes backwards, even when a "date" @@ -1019,7 +1017,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION); int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, int, int); int newnfs_realign(struct mbuf **, int); bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep); -void ncl_copy_vattr(struct vattr *dst, struct vattr *src); +void ncl_copy_vattr(struct vnode *vp, struct vattr *dst, struct vattr *src); /* * If the port runs on an SMP box that can enforce Atomic ops with low @@ -1030,9 +1028,6 @@ void ncl_copy_vattr(struct vattr *dst, struct vattr *src); #define NFSINCRGLOBAL(a) ((a)++) #define NFSDECRGLOBAL(a) ((a)--) -/* - * Assorted funky stuff to make things work under Darwin8. - */ /* * These macros checks for a field in vattr being set. */ @@ -1180,9 +1175,11 @@ struct nfsreq { */ #ifdef VV_DISABLEDELEG #define NFSVNO_DELEGOK(v) \ - ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0) + ((v) == NULL || ((v)->v_vflag & VV_DISABLEDELEG) == 0 || \ + (vn_irflag_read(v) & VIRF_NAMEDATTR) == 0) #else -#define NFSVNO_DELEGOK(v) (1) +#define NFSVNO_DELEGOK(v) \ + ((v) == NULL || (vn_irflag_read(v) & VIRF_NAMEDATTR) == 0) #endif /* diff --git a/lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h b/lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h index 4791ceaf022994e036ba64b20bc95821bc449df1..cfc0b6f898ceada809ff54aeb7481082cf168c4b 100644 --- a/lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h +++ b/lib/libc/include/generic-freebsd/fs/nfs/nfsproto.h @@ -275,6 +275,8 @@ #define NFSX_V4SESSIONID 16 #define NFSX_V4DEVICEID 16 #define NFSX_V4PNFSFH (sizeof(fhandle_t) + 1) +#define NFSX_V4NAMEDDIRFH 2 +#define NFSX_V4NAMEDATTRFH 3 #define NFSX_V4FILELAYOUT (4 * NFSX_UNSIGNED + NFSX_V4DEVICEID + \ NFSX_HYPER + NFSM_RNDUP(NFSX_V4PNFSFH)) #define NFSX_V4FLEXLAYOUT(m) (NFSX_HYPER + 3 * NFSX_UNSIGNED + \ @@ -406,10 +408,16 @@ /* Do an NFSv4 Verify+Write. */ #define NFSPROC_APPENDWRITE 69 +/* Do a NFSv4 Openattr. */ +#define NFSPROC_OPENATTR 70 + +/* Do a NFSv4.2 Clone. */ +#define NFSPROC_CLONE 71 + /* * Must be defined as one higher than the last NFSv4.2 Proc# above. */ -#define NFSV42_NPROCS 70 +#define NFSV42_NPROCS 72 /* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */ #define NFSV42_OLDNPROCS 69 @@ -744,6 +752,17 @@ #define NFSSECINFONONAME_CURFH 0 #define NFSSECINFONONAME_PARENT 1 +/* Bits for CB_RECALL_ANY. */ +#define NFSRCA4_RDATA_DLG 0x00000001 +#define NFSRCA4_WDATA_DLG 0x00000002 +#define NFSRCA4_DIR_DLG 0x00000004 +#define NFSRCA4_FILE_LAYOUT 0x00000008 +#define NFSRCA4_BLK_LAYOUT 0x00000010 +#define NFSRCA4_OBJ_LAYOUT_MIN 0x00000100 +#define NFSRCA4_OBJ_LAYOUT_MAX 0x00000200 +#define NFSRCA4_FF_LAYOUT_READ 0x00010000 +#define NFSRCA4_FF_LAYOUT_RW 0x00020000 + #if defined(_KERNEL) || defined(KERNEL) /* Conversion macros */ #define vtonfsv2_mode(t,m) \ @@ -1126,6 +1145,7 @@ struct nfsv3_sattr { NFSATTRBM_FILESFREE | \ NFSATTRBM_FILESTOTAL | \ NFSATTRBM_FSLOCATIONS | \ + NFSATTRBM_HIDDEN | \ NFSATTRBM_HOMOGENEOUS | \ NFSATTRBM_MAXFILESIZE | \ NFSATTRBM_MAXLINK | \ @@ -1147,6 +1167,7 @@ struct nfsv3_sattr { NFSATTRBM_SPACEFREE | \ NFSATTRBM_SPACETOTAL | \ NFSATTRBM_SPACEUSED | \ + NFSATTRBM_SYSTEM | \ NFSATTRBM_TIMEACCESS | \ NFSATTRBM_TIMECREATE | \ NFSATTRBM_TIMEDELTA | \ @@ -1176,6 +1197,8 @@ struct nfsv3_sattr { NFSATTRBM_LAYOUTBLKSIZE | \ NFSATTRBM_LAYOUTALIGNMENT | \ NFSATTRBM_SUPPATTREXCLCREAT | \ + NFSATTRBM_CLONEBLKSIZE | \ + NFSATTRBM_CHANGEATTRTYPE | \ NFSATTRBM_XATTRSUPPORT) /* @@ -1183,7 +1206,8 @@ struct nfsv3_sattr { */ #define NFSATTRBIT_SUPPSETONLY1 (NFSATTRBM_TIMEACCESSSET | \ NFSATTRBM_TIMEMODIFYSET) -#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED) +#define NFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED | \ + NFSATTRBM_MODEUMASK) /* * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31 @@ -1192,16 +1216,19 @@ struct nfsv3_sattr { */ #define NFSATTRBIT_SETABLE0 \ (NFSATTRBM_SIZE | \ + NFSATTRBM_HIDDEN | \ NFSATTRBM_ACL) #define NFSATTRBIT_SETABLE1 \ (NFSATTRBM_MODE | \ NFSATTRBM_OWNER | \ NFSATTRBM_OWNERGROUP | \ - NFSATTRBM_TIMECREATE | \ + NFSATTRBM_SYSTEM | \ + NFSATTRBM_TIMECREATE | \ NFSATTRBM_TIMEACCESSSET | \ NFSATTRBM_TIMEMODIFYSET) #define NFSATTRBIT_SETABLE2 \ - (NFSATTRBM_MODESETMASKED) + (NFSATTRBM_MODESETMASKED | \ + NFSATTRBM_MODEUMASK) /* * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1. @@ -1218,7 +1245,11 @@ struct nfsv3_sattr { /* * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2. */ -#define NFSATTRBIT_NFSV42_2 NFSATTRBM_XATTRSUPPORT +#define NFSATTRBIT_NFSV42_2 \ + (NFSATTRBM_CLONEBLKSIZE | \ + NFSATTRBM_CHANGEATTRTYPE | \ + NFSATTRBM_XATTRSUPPORT | \ + NFSATTRBM_MODEUMASK) /* * Set of attributes that the getattr vnode op needs. @@ -1232,6 +1263,7 @@ struct nfsv3_sattr { NFSATTRBM_SIZE | \ NFSATTRBM_FSID | \ NFSATTRBM_FILEID | \ + NFSATTRBM_HIDDEN | \ NFSATTRBM_MAXREAD) /* @@ -1244,6 +1276,7 @@ struct nfsv3_sattr { NFSATTRBM_OWNERGROUP | \ NFSATTRBM_RAWDEV | \ NFSATTRBM_SPACEUSED | \ + NFSATTRBM_SYSTEM | \ NFSATTRBM_TIMEACCESS | \ NFSATTRBM_TIMECREATE | \ NFSATTRBM_TIMEMETADATA | \ @@ -1266,6 +1299,7 @@ struct nfsv3_sattr { NFSATTRBM_SIZE | \ NFSATTRBM_FSID | \ NFSATTRBM_FILEID | \ + NFSATTRBM_HIDDEN | \ NFSATTRBM_MAXREAD) /* @@ -1276,6 +1310,7 @@ struct nfsv3_sattr { NFSATTRBM_NUMLINKS | \ NFSATTRBM_RAWDEV | \ NFSATTRBM_SPACEUSED | \ + NFSATTRBM_SYSTEM | \ NFSATTRBM_TIMEACCESS | \ NFSATTRBM_TIMECREATE | \ NFSATTRBM_TIMEMETADATA | \ @@ -1385,13 +1420,14 @@ struct nfsv3_sattr { /* * NFSGETATTRBIT_STATFS2 - bits 64<->95 */ -#define NFSGETATTRBIT_STATFS2 0 +#define NFSGETATTRBIT_STATFS2 (NFSATTRBM_CLONEBLKSIZE) /* * Set of attributes for the equivalent of an nfsv3 pathconf rpc. * NFSGETATTRBIT_PATHCONF0 - bits 0<->31 */ #define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 | \ + NFSATTRBM_NAMEDATTR | \ NFSATTRBM_CASEINSENSITIVE | \ NFSATTRBM_CASEPRESERVING | \ NFSATTRBM_CHOWNRESTRICTED | \ @@ -1407,7 +1443,7 @@ struct nfsv3_sattr { /* * NFSGETATTRBIT_PATHCONF2 - bits 64<->95 */ -#define NFSGETATTRBIT_PATHCONF2 0 +#define NFSGETATTRBIT_PATHCONF2 (NFSATTRBM_CLONEBLKSIZE) /* * Sets of attributes required by readdir and readdirplus. @@ -1653,4 +1689,11 @@ typedef struct nfsv4stateid nfsv4stateid_t; #define NFSV4SXATTR_CREATE 1 #define NFSV4SXATTR_REPLACE 2 +/* Values for ChangeAttrType (RFC-7862). */ +#define NFSV4CHANGETYPE_MONOTONIC_INCR 0 +#define NFSV4CHANGETYPE_VERS_COUNTER 1 +#define NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS 2 +#define NFSV4CHANGETYPE_TIME_METADATA 3 +#define NFSV4CHANGETYPE_UNDEFINED 4 + #endif /* _NFS_NFSPROTO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/fs/nullfs/null.h b/lib/libc/include/generic-freebsd/fs/nullfs/null.h index 8e2c2c8b573a2fb5edd8c4e873b190577552110d..ba64f8ce71dd73e1c90fb2215e45c61a3e6e9226 100644 --- a/lib/libc/include/generic-freebsd/fs/nullfs/null.h +++ b/lib/libc/include/generic-freebsd/fs/nullfs/null.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)null.h 8.3 (Berkeley) 8/20/94 */ #ifndef FS_NULL_H diff --git a/lib/libc/include/generic-freebsd/fs/procfs/procfs.h b/lib/libc/include/generic-freebsd/fs/procfs/procfs.h index 47c9b2a761d3c2c3a0a93e52890b9fb8bba2237f..daee89f6c79a5cb4b74febc8b3ac1f65d0b293ed 100644 --- a/lib/libc/include/generic-freebsd/fs/procfs/procfs.h +++ b/lib/libc/include/generic-freebsd/fs/procfs/procfs.h @@ -32,8 +32,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)procfs.h 8.9 (Berkeley) 5/14/95 - * * From: */ diff --git a/lib/libc/include/generic-freebsd/fs/smbfs/smbfs_node.h b/lib/libc/include/generic-freebsd/fs/smbfs/smbfs_node.h index 1e53fce8a6a0c1b1f535f499a1c0bda520b4fe57..3b480074089faa9b02c9584cfaaa8bccec8960e8 100644 --- a/lib/libc/include/generic-freebsd/fs/smbfs/smbfs_node.h +++ b/lib/libc/include/generic-freebsd/fs/smbfs/smbfs_node.h @@ -93,7 +93,7 @@ u_int32_t smbfs_hash(const u_char *name, int nmlen); int smbfs_getpages(struct vop_getpages_args *); int smbfs_putpages(struct vop_putpages_args *); -int smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred); +int smbfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int *eofp); int smbfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag); void smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap); int smbfs_attr_cachelookup(struct vnode *vp ,struct vattr *va); diff --git a/lib/libc/include/generic-freebsd/fs/udf/ecma167-udf.h b/lib/libc/include/generic-freebsd/fs/udf/ecma167-udf.h index 335bf5212fda9a331182e981a8064ef4fd7ee0a7..dec14812c62538f2bce2b0e41a87a0f01f9e5b9e 100644 --- a/lib/libc/include/generic-freebsd/fs/udf/ecma167-udf.h +++ b/lib/libc/include/generic-freebsd/fs/udf/ecma167-udf.h @@ -243,7 +243,7 @@ struct part_map_spare { uint8_t n_st; /* Number of Sparing Tables */ uint8_t reserved1; uint32_t st_size; - uint32_t st_loc[1]; + uint32_t st_loc[]; } __packed; union udf_pmap { @@ -266,7 +266,7 @@ struct udf_sparing_table { uint16_t rt_l; /* Relocation Table len */ uint8_t reserved[2]; uint32_t seq_num; - struct spare_map_entry entries[1]; + struct spare_map_entry entries[]; } __packed; /* Partition Descriptor [3/10.5] */ diff --git a/lib/libc/include/generic-freebsd/fs/unionfs/union.h b/lib/libc/include/generic-freebsd/fs/unionfs/union.h index 4fe3ccda005d607b0261281caab3b1f17d97daa7..426918b467726530de8dddc196834dace1c54f9a 100644 --- a/lib/libc/include/generic-freebsd/fs/unionfs/union.h +++ b/lib/libc/include/generic-freebsd/fs/unionfs/union.h @@ -33,8 +33,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)union.h 8.9 (Berkeley) 12/10/94 */ #ifdef _KERNEL @@ -99,15 +97,17 @@ struct unionfs_node { char *un_path; /* path */ int un_pathlen; /* strlen of path */ - int un_flag; /* unionfs node flag */ -}; -/* - * unionfs node flags - * It needs the vnode with exclusive lock, when changing the un_flag variable. - */ -#define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */ -#define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */ + /* + * unionfs node flags + * Changing these flags requires the vnode to be locked exclusive. + */ + #define UNIONFS_OPENEXTL 0x01 /* openextattr (lower) */ + #define UNIONFS_OPENEXTU 0x02 /* openextattr (upper) */ + #define UNIONFS_COPY_IN_PROGRESS 0x04 /* copy/dir shadow in progres */ + #define UNIONFS_LOOKUP_IN_PROGRESS 0x08 + unsigned int un_flag; /* unionfs node flag */ +}; extern struct vop_vector unionfs_vnodeops; @@ -133,34 +133,32 @@ int unionfs_uninit(struct vfsconf *); int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *, struct vnode *, struct vnode **, struct componentname *); void unionfs_noderem(struct vnode *); +struct unionfs_node_status * unionfs_find_node_status(struct unionfs_node *, + struct thread *td); void unionfs_get_node_status(struct unionfs_node *, struct thread *, struct unionfs_node_status **); void unionfs_tryrem_node_status(struct unionfs_node *, struct unionfs_node_status *); int unionfs_check_rmdir(struct vnode *, struct ucred *, struct thread *td); -int unionfs_copyfile(struct unionfs_node *, int, struct ucred *, +int unionfs_copyfile(struct vnode *, int, struct ucred *, struct thread *); void unionfs_create_uppervattr_core(struct unionfs_mount *, struct vattr *, struct vattr *, struct thread *); int unionfs_create_uppervattr(struct unionfs_mount *, struct vnode *, struct vattr *, struct ucred *, struct thread *); -int unionfs_mkshadowdir(struct unionfs_mount *, struct vnode *, - struct unionfs_node *, struct componentname *, struct thread *); +int unionfs_mkshadowdir(struct vnode *, struct vnode *, + struct componentname *, struct thread *); int unionfs_mkwhiteout(struct vnode *, struct vnode *, struct componentname *, struct thread *, char *, int); int unionfs_relookup(struct vnode *, struct vnode **, struct componentname *, struct componentname *, struct thread *, char *, int, u_long); -int unionfs_relookup_for_create(struct vnode *, struct componentname *, - struct thread *); -int unionfs_relookup_for_delete(struct vnode *, struct componentname *, - struct thread *); -int unionfs_relookup_for_rename(struct vnode *, struct componentname *, - struct thread *); void unionfs_forward_vop_start_pair(struct vnode *, int *, struct vnode *, int *); bool unionfs_forward_vop_finish_pair(struct vnode *, struct vnode *, int, struct vnode *, struct vnode *, int); +int unionfs_set_in_progress_flag(struct vnode *, unsigned int); +void unionfs_clear_in_progress_flag(struct vnode *, unsigned int); static inline void unionfs_forward_vop_start(struct vnode *basevp, int *lkflags) diff --git a/lib/libc/include/generic-freebsd/fstab.h b/lib/libc/include/generic-freebsd/fstab.h index d43df2530ced211fc7997d7c3299995bda50f469..ab39157500a4c9bc50c4673eb71542f025e65818 100644 --- a/lib/libc/include/generic-freebsd/fstab.h +++ b/lib/libc/include/generic-freebsd/fstab.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fstab.h 8.1 (Berkeley) 6/2/93 */ #ifndef _FSTAB_H_ diff --git a/lib/libc/include/generic-freebsd/fts.h b/lib/libc/include/generic-freebsd/fts.h index ad16892a4cd744d4b9fd1b0173efff28cde212ad..69b271ac2b6855360cee70698dedb55968c05277 100644 --- a/lib/libc/include/generic-freebsd/fts.h +++ b/lib/libc/include/generic-freebsd/fts.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 */ #ifndef _FTS_H_ @@ -36,35 +34,54 @@ #include +typedef struct _ftsent FTSENT; + typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ + FTSENT *fts_cur; /* current node */ + FTSENT *fts_child; /* linked list of children */ + FTSENT **fts_array; /* sort array */ __dev_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ __size_t fts_pathlen; /* sizeof(path) */ __size_t fts_nitems; /* elements in the sort array */ - int (*fts_compar) /* compare function */ - (const struct _ftsent * const *, const struct _ftsent * const *); + union { + int (*fts_compar) /* compare function */ + (const FTSENT * const *, const FTSENT * const *); +#ifdef __BLOCKS__ + int (^fts_compar_b) + (const FTSENT * const *, const FTSENT * const *); +#else + void *fts_compar_b; +#endif /* __BLOCKS__ */ + }; -#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ -#define FTS_LOGICAL 0x002 /* logical walk */ -#define FTS_NOCHDIR 0x004 /* don't change directories */ -#define FTS_NOSTAT 0x008 /* don't get stat info */ -#define FTS_PHYSICAL 0x010 /* physical walk */ -#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ -#define FTS_XDEV 0x040 /* don't cross devices */ -#define FTS_WHITEOUT 0x080 /* return whiteout information */ -#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ +/* valid for fts_open() */ +#define FTS_COMFOLLOW 0x000001 /* follow command line symlinks */ +#define FTS_LOGICAL 0x000002 /* logical walk */ +#define FTS_NOCHDIR 0x000004 /* don't change directories */ +#define FTS_NOSTAT 0x000008 /* don't get stat info */ +#define FTS_PHYSICAL 0x000010 /* physical walk */ +#define FTS_SEEDOT 0x000020 /* return dot and dot-dot */ +#define FTS_XDEV 0x000040 /* don't cross devices */ +#define FTS_WHITEOUT 0x000080 /* return whiteout information */ + /* 0x0100 is FTS_NAMEONLY below */ + /* 0x0200 was previously FTS_STOP */ +#define FTS_COMFOLLOWDIR 0x00400 /* like COMFOLLOW but directories only */ +#define FTS_NOSTAT_TYPE 0x000800 /* like NOSTAT but use d_type */ +#define FTS_OPTIONMASK 0x000cff /* valid user option mask */ -#define FTS_NAMEONLY 0x100 /* (private) child names only */ -#define FTS_STOP 0x200 /* (private) unrecoverable error */ +/* valid only for fts_children() */ +#define FTS_NAMEONLY 0x000100 /* child names only */ + +/* internal use only */ +#define FTS_STOP 0x010000 /* unrecoverable error */ +#define FTS_COMPAR_B 0x020000 /* compare function is a block */ int fts_options; /* fts_open options, global flags */ void *fts_clientptr; /* thunk for sort function */ } FTS; -typedef struct _ftsent { +struct _ftsent { struct _ftsent *fts_cycle; /* cycle node */ struct _ftsent *fts_parent; /* parent directory */ struct _ftsent *fts_link; /* next file in directory */ @@ -116,7 +133,7 @@ typedef struct _ftsent { struct stat *fts_statp; /* stat(2) information */ char *fts_name; /* file name */ FTS *fts_fts; /* back pointer to main FTS */ -} FTSENT; +}; #include @@ -129,6 +146,10 @@ FTS *fts_get_stream(FTSENT *); #define fts_get_stream(ftsent) ((ftsent)->fts_fts) FTS *fts_open(char * const *, int, int (*)(const FTSENT * const *, const FTSENT * const *)); +#ifdef __BLOCKS__ +FTS *fts_open_b(char * const *, int, + int (^)(const FTSENT * const *, const FTSENT * const *)); +#endif /* __BLOCKS__ */ FTSENT *fts_read(FTS *); int fts_set(FTS *, FTSENT *, int); void fts_set_clientptr(FTS *, void *); diff --git a/lib/libc/include/generic-freebsd/geom/geom.h b/lib/libc/include/generic-freebsd/geom/geom.h index 88a50bfa792bc9bff7371a22cdb4254d470c800a..7c69b60d5386b3bfcbdf3d3de7d37f5e6095a431 100644 --- a/lib/libc/include/generic-freebsd/geom/geom.h +++ b/lib/libc/include/generic-freebsd/geom/geom.h @@ -282,7 +282,7 @@ void g_detach(struct g_consumer *cp); void g_error_provider(struct g_provider *pp, int error); struct g_provider *g_provider_by_name(char const *arg); int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); -#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) +#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof(*(v))) int g_handleattr(struct bio *bp, const char *attribute, const void *val, int len); int g_handleattr_int(struct bio *bp, const char *attribute, int val); @@ -417,7 +417,7 @@ g_free(void *ptr) static moduledata_t name##_mod = { \ #name, g_modevent, &class \ }; \ - DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); + DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); int g_is_geom_thread(struct thread *td); diff --git a/lib/libc/include/generic-freebsd/geom/label/g_label.h b/lib/libc/include/generic-freebsd/geom/label/g_label.h index 0ca929a1a81f950c25e8f245e7ebe5904d3730d0..fb4755ced428a254ba065cd344153c2527ec7774 100644 --- a/lib/libc/include/generic-freebsd/geom/label/g_label.h +++ b/lib/libc/include/generic-freebsd/geom/label/g_label.h @@ -73,12 +73,12 @@ extern struct g_label_desc g_label_ufs_volume; extern struct g_label_desc g_label_iso9660; extern struct g_label_desc g_label_msdosfs; extern struct g_label_desc g_label_ext2fs; -extern struct g_label_desc g_label_reiserfs; extern struct g_label_desc g_label_ntfs; extern struct g_label_desc g_label_gpt; extern struct g_label_desc g_label_gpt_uuid; extern struct g_label_desc g_label_disk_ident; extern struct g_label_desc g_label_flashmap; +extern struct g_label_desc g_label_swaplinux; extern void g_label_rtrim(char *label, size_t size); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/glob.h b/lib/libc/include/generic-freebsd/glob.h index d8c3f9017a6aa06246c19cde5de7f6f77edb9bec..bfc40a0341087415955788dd84057a138d9f3fce 100644 --- a/lib/libc/include/generic-freebsd/glob.h +++ b/lib/libc/include/generic-freebsd/glob.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)glob.h 8.1 (Berkeley) 6/2/93 */ #ifndef _GLOB_H_ @@ -52,8 +50,15 @@ typedef struct { size_t gl_offs; /* Reserved at beginning of gl_pathv. */ int gl_flags; /* Copy of flags parameter to glob. */ char **gl_pathv; /* List of paths matching pattern. */ - /* Copy of errfunc parameter to glob. */ - int (*gl_errfunc)(const char *, int); + /* Copy of error callback parameter to glob. */ + union { + int (*gl_errfunc)(const char *, int); +#ifdef __BLOCKS__ + int (^gl_errblk)(const char *, int); +#else + void *gl_errblk; +#endif + }; /* * Alternate filesystem access methods for glob; replacement @@ -92,6 +97,7 @@ typedef struct { #define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ #define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ #define GLOB_LIMIT 0x1000 /* limit number of returned paths */ +#define _GLOB_ERR_BLOCK 0x08000000 /* (internal) error callback is a block */ /* source compatibility, these are the old names */ #define GLOB_MAXPATH GLOB_LIMIT @@ -101,6 +107,10 @@ typedef struct { __BEGIN_DECLS int glob(const char * __restrict, int, int (*)(const char *, int), glob_t * __restrict); +#if defined(__BLOCKS__) && __BSD_VISIBLE +int glob_b(const char * __restrict, int, + int (^)(const char *, int), glob_t * __restrict); +#endif void globfree(glob_t *); __END_DECLS diff --git a/lib/libc/include/generic-freebsd/grp.h b/lib/libc/include/generic-freebsd/grp.h index 95de6bebef2d9d10d67360780541a7c82123d1d1..1aa52223cf9de1a0a668f8a2ee9066fe78ce7a7f 100644 --- a/lib/libc/include/generic-freebsd/grp.h +++ b/lib/libc/include/generic-freebsd/grp.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)grp.h 8.2 (Berkeley) 1/21/94 */ #ifndef _GRP_H_ diff --git a/lib/libc/include/generic-freebsd/iconv.h b/lib/libc/include/generic-freebsd/iconv.h index 4a22166a1d1545287b8f7f8e8185b4e2cd6ab526..39ca3f108a07ce0fc3c1a867ac2902cbf25d7284 100644 --- a/lib/libc/include/generic-freebsd/iconv.h +++ b/lib/libc/include/generic-freebsd/iconv.h @@ -33,12 +33,10 @@ #ifndef _ICONV_H_ #define _ICONV_H_ -#include #include #include -#include #include #ifdef __cplusplus diff --git a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h index 0af01c536ea632a25f888b43f98680f2c57416a4..b0e6f51a9f2e4a727f775503dd866937ff5c8f7a 100644 --- a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h +++ b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_mount.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95 */ /* diff --git a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h index 64fc930d89f23f890c43638f0739e64658bd6d31..d76640fdae9b41be72eea228675467fc2bdad42b 100644 --- a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h +++ b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_node.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95 */ /* @@ -58,7 +56,7 @@ typedef struct { struct iso_node { struct vnode *i_vnode; /* vnode associated with this inode */ - cd_ino_t i_number; /* the identity of the inode */ + ino_t i_number; /* the identity of the inode */ /* we use the actual starting block of the file */ struct iso_mnt *i_mnt; /* filesystem associated with this inode */ struct lockf *i_lockf; /* head of byte-level lock list */ diff --git a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_rrip.h b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_rrip.h index d120dd0147429c2799ef4a5cd35302786cfebff3..d9d3c474362c6a2c1170376160beb7d84252691f 100644 --- a/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_rrip.h +++ b/lib/libc/include/generic-freebsd/isofs/cd9660/cd9660_rrip.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94 */ #ifndef _ISOFS_CD9660_CD9660_RRIP_H_ diff --git a/lib/libc/include/generic-freebsd/isofs/cd9660/iso.h b/lib/libc/include/generic-freebsd/isofs/cd9660/iso.h index 332c0c5d831171d79971f27843018d3e5daf0349..ba65e04d7f93b39d8cbfbced13d1d2312adb08ac 100644 --- a/lib/libc/include/generic-freebsd/isofs/cd9660/iso.h +++ b/lib/libc/include/generic-freebsd/isofs/cd9660/iso.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)iso.h 8.6 (Berkeley) 5/10/95 */ #ifndef _ISOFS_CD9660_ISO_H_ @@ -214,21 +212,12 @@ struct iso_extended_attributes { u_char len_au [ISODCL (247, 250)]; /* 723 */ }; -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_WANT_ISO_MNT) /* CD-ROM Format type */ enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_JOLIET, ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA }; -#ifndef ISOFSMNT_ROOT -#define ISOFSMNT_ROOT 0 -#endif - -/* - * When ino_t becomes 64-bit, we can remove this definition in favor of ino_t. - */ -typedef __uint64_t cd_ino_t; - struct iso_mnt { uint64_t im_flags; @@ -264,12 +253,16 @@ struct iso_mnt { void *im_l2d; }; +#endif /* defined(_KERNEL) || defined(_WANT_ISO_MNT) */ + +#ifdef _KERNEL + struct ifid { u_short ifid_len; u_short ifid_pad; - cd_ino_t ifid_ino; + ino_t ifid_ino; long ifid_start; -}; +} __packed; #define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) @@ -278,7 +271,7 @@ struct ifid { #define lblkno(imp, loc) ((loc) >> (imp)->im_bshift) #define blksize(imp, ip, lbn) ((imp)->logical_block_size) -int cd9660_vget_internal(struct mount *, cd_ino_t, int, struct vnode **, int, +int cd9660_vget_internal(struct mount *, ino_t , int, struct vnode **, int, struct iso_directory_record *); #define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \ size_t, struct proc *))eopnotsupp) @@ -289,7 +282,7 @@ extern struct vop_vector cd9660_fifoops; int isochar(u_char *, u_char *, int, u_short *, int *, int, void *); int isofncmp(u_char *, int, u_char *, int, int, int, void *, void *); void isofntrans(u_char *, int, u_char *, u_short *, int, int, int, int, void *); -cd_ino_t isodirino(struct iso_directory_record *, struct iso_mnt *); +ino_t isodirino(struct iso_directory_record *, struct iso_mnt *); u_short sgetrune(const char *, size_t, char const **, int, void *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h b/lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h index c899ca42f726d595f2da6eec5167b98bd40a9500..d4b6d59dd47d686ebb62a8511c4760dbd37320d5 100644 --- a/lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h +++ b/lib/libc/include/generic-freebsd/isofs/cd9660/iso_rrip.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)iso_rrip.h 8.2 (Berkeley) 1/23/94 */ #ifndef _ISOFS_CD9660_ISO_RRIP_H_ @@ -65,7 +63,7 @@ typedef struct { off_t iso_ce_off; /* offset of continuation area */ int iso_ce_len; /* length of continuation area */ struct iso_mnt *imp; /* mount structure */ - cd_ino_t *inump; /* inode number pointer */ + ino_t *inump; /* inode number pointer */ char *outbuf; /* name/symbolic link output area */ u_short *outlen; /* length of above */ u_short maxlen; /* maximum length of above */ @@ -78,7 +76,7 @@ int cd9660_rrip_analyze(struct iso_directory_record *isodir, struct iso_node *inop, struct iso_mnt *imp); int cd9660_rrip_getname(struct iso_directory_record *isodir, char *outbuf, u_short *outlen, - cd_ino_t *inump, struct iso_mnt *imp); + ino_t *inump, struct iso_mnt *imp); int cd9660_rrip_getsymname(struct iso_directory_record *isodir, char *outbuf, u_short *outlen, struct iso_mnt *imp); diff --git a/lib/libc/include/generic-freebsd/libsys.h b/lib/libc/include/generic-freebsd/libsys.h new file mode 100644 index 0000000000000000000000000000000000000000..6e24496c46885baf58a6ca350ad8bd8e7149054d --- /dev/null +++ b/lib/libc/include/generic-freebsd/libsys.h @@ -0,0 +1,25 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 SRI International + * + * This software was developed by SRI International, the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology), and Capabilities Limited under Defense Advanced Research + * Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC"). + */ + +#ifndef _LIBSYS_H_ +#define _LIBSYS_H_ + +#include + +#include <_libsys.h> + +typedef int (__sys_syscall_t)(int number, ...); +typedef int (__sys___syscall_t)(int64_t number, ...); + +int __sys_syscall(int number, ...); +off_t __sys___syscall(int64_t number, ...); + +#endif /* _LIBSYS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/libutil.h b/lib/libc/include/generic-freebsd/libutil.h index 10cff683f737d6bc3bd80de8f165f288ca1694fe..877f02103464d92540192f63cc36ae06459785f4 100644 --- a/lib/libc/include/generic-freebsd/libutil.h +++ b/lib/libc/include/generic-freebsd/libutil.h @@ -86,10 +86,17 @@ struct termios; struct winsize; __BEGIN_DECLS -char *auth_getval(const char *_name); void clean_environment(const char * const *_white, const char * const *_more_white); -int expand_number(const char *_buf, uint64_t *_num); +int expand_number(const char *_buf, int64_t *_num); +int expand_unsigned(const char *_buf, uint64_t *_num); +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + __has_extension(c_generic_selections) +#define expand_number(_buf, _num) \ + _Generic((_num), \ + uint64_t *: expand_unsigned, \ + default: expand_number)((_buf), (_num)) +#endif int extattr_namespace_to_string(int _attrnamespace, char **_string); int extattr_string_to_namespace(const char *_string, int *_attrnamespace); int flopen(const char *_path, int _flags, ...); @@ -213,7 +220,13 @@ int cpuset_parselist(const char *list, cpuset_t *mask); #define CPUSET_PARSE_OK 0 #define CPUSET_PARSE_GETAFFINITY -1 #define CPUSET_PARSE_ERROR -2 -#define CPUSET_PARSE_INVALID_CPU -3 +#define CPUSET_PARSE_OUT_OF_RANGE -3 +#define CPUSET_PARSE_GETDOMAIN -4 +#define CPUSET_PARSE_INVALID_CPU CPUSET_PARSE_OUT_OF_RANGE /* backwards compat */ +#endif + +#ifdef _SYS_DOMAINSET_H_ +int domainset_parselist(const char *list, domainset_t *mask, int *policyp); #endif __END_DECLS diff --git a/lib/libc/include/generic-freebsd/limits.h b/lib/libc/include/generic-freebsd/limits.h index e711c34db2e9960a0e92743bddaaa4bb68678b70..21fcd0e682fd8f20990ecb4cd47efddc197589c1 100644 --- a/lib/libc/include/generic-freebsd/limits.h +++ b/lib/libc/include/generic-freebsd/limits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.2 (Berkeley) 1/4/94 */ #ifndef _LIMITS_H_ @@ -139,6 +137,11 @@ #define MB_LEN_MAX 6 /* 31-bit UTF-8 */ +#if __POSIX_VISIBLE >= 202405 +#define GETENTROPY_MAX 256 +#define NSIG_MAX 128 /* _SIG_MAXSIG from */ +#endif + #include #if __POSIX_VISIBLE diff --git a/lib/libc/include/generic-freebsd/locale.h b/lib/libc/include/generic-freebsd/locale.h index d780f93db618be6d0e199f65e86ab989b1f3fbd9..82b4c6423a3592ede279bed455d501546fd453aa 100644 --- a/lib/libc/include/generic-freebsd/locale.h +++ b/lib/libc/include/generic-freebsd/locale.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)locale.h 8.1 (Berkeley) 6/2/93 */ #ifndef _LOCALE_H_ diff --git a/lib/libc/include/generic-freebsd/machine/_align.h b/lib/libc/include/generic-freebsd/machine/_align.h index d7a186a2eb09eeb41b19a4fc5def844196c78e8e..4af6dd67a7aa6c4b62acf80c30081e1bf4906702 100644 --- a/lib/libc/include/generic-freebsd/machine/_align.h +++ b/lib/libc/include/generic-freebsd/machine/_align.h @@ -1,53 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2001 David E. O'Brien - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 + * This file is in the public domain. */ -#ifndef _POWERPC_INCLUDE__ALIGN_H_ -#define _POWERPC_INCLUDE__ALIGN_H_ - -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#define _ALIGNBYTES (sizeof(register_t) - 1) -#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) - -#endif /* !_POWERPC_INCLUDE__ALIGN_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/_bus.h b/lib/libc/include/generic-freebsd/machine/_bus.h index 409470a3657c81fa0ec4ed4980f37ba7afdbe7b4..684d5496d9f3c9d27b838addc1c07c1eda1228f6 100644 --- a/lib/libc/include/generic-freebsd/machine/_bus.h +++ b/lib/libc/include/generic-freebsd/machine/_bus.h @@ -1,47 +1,28 @@ /*- + * Copyright (c) 2005 The FreeBSD Foundation. + * * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Derived in part from NetBSD's bus.h files by (alphabetically): + * Christopher G. Demetriou + * Charles M. Hannum + * Jason Thorpe + * The NetBSD Foundation. */ -#ifndef POWERPC_INCLUDE__BUS_H -#define POWERPC_INCLUDE__BUS_H - -#include +#ifndef _MACHINE__BUS_H_ +#define _MACHINE__BUS_H_ /* - * Bus address and size types + * Addresses (in bus space). */ -typedef vm_paddr_t bus_addr_t; -typedef vm_size_t bus_size_t; +typedef u_long bus_addr_t; +typedef u_long bus_size_t; /* - * Access methods for bus resources and address space. + * Access methods for bus space. */ +typedef u_long bus_space_handle_t; typedef struct bus_space *bus_space_tag_t; -typedef vm_offset_t bus_space_handle_t; -#endif /* POWERPC_INCLUDE__BUS_H */ \ No newline at end of file +#endif /* !_MACHINE__BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/_inttypes.h b/lib/libc/include/generic-freebsd/machine/_inttypes.h index 770c91e434159779f77b1c0b3510f82aa98d9bd7..218f00871b1659c2232d879ebfe3581c925689dc 100644 --- a/lib/libc/include/generic-freebsd/machine/_inttypes.h +++ b/lib/libc/include/generic-freebsd/machine/_inttypes.h @@ -1,222 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $ + * This file is in the public domain. */ -#ifndef _MACHINE_INTTYPES_H_ -#define _MACHINE_INTTYPES_H_ - -/* - * Macros for format specifiers. - */ - -#ifdef __LP64__ -#define __PRI64 "l" -#define __PRIptr "l" -#else -#define __PRI64 "ll" -#define __PRIptr -#endif - -/* fprintf(3) macros for signed integers. */ - -#define PRId8 "d" /* int8_t */ -#define PRId16 "d" /* int16_t */ -#define PRId32 "d" /* int32_t */ -#define PRId64 __PRI64"d" /* int64_t */ -#define PRIdLEAST8 "d" /* int_least8_t */ -#define PRIdLEAST16 "d" /* int_least16_t */ -#define PRIdLEAST32 "d" /* int_least32_t */ -#define PRIdLEAST64 __PRI64"d" /* int_least64_t */ -#define PRIdFAST8 "d" /* int_fast8_t */ -#define PRIdFAST16 "d" /* int_fast16_t */ -#define PRIdFAST32 "d" /* int_fast32_t */ -#define PRIdFAST64 __PRI64"d" /* int_fast64_t */ -#define PRIdMAX "jd" /* intmax_t */ -#define PRIdPTR __PRIptr"d" /* intptr_t */ - -#define PRIi8 "i" /* int8_t */ -#define PRIi16 "i" /* int16_t */ -#define PRIi32 "i" /* int32_t */ -#define PRIi64 __PRI64"i" /* int64_t */ -#define PRIiLEAST8 "i" /* int_least8_t */ -#define PRIiLEAST16 "i" /* int_least16_t */ -#define PRIiLEAST32 "i" /* int_least32_t */ -#define PRIiLEAST64 __PRI64"i" /* int_least64_t */ -#define PRIiFAST8 "i" /* int_fast8_t */ -#define PRIiFAST16 "i" /* int_fast16_t */ -#define PRIiFAST32 "i" /* int_fast32_t */ -#define PRIiFAST64 __PRI64"i" /* int_fast64_t */ -#define PRIiMAX "ji" /* intmax_t */ -#define PRIiPTR __PRIptr"i" /* intptr_t */ - -/* fprintf(3) macros for unsigned integers. */ - -#define PRIo8 "o" /* uint8_t */ -#define PRIo16 "o" /* uint16_t */ -#define PRIo32 "o" /* uint32_t */ -#define PRIo64 __PRI64"o" /* uint64_t */ -#define PRIoLEAST8 "o" /* uint_least8_t */ -#define PRIoLEAST16 "o" /* uint_least16_t */ -#define PRIoLEAST32 "o" /* uint_least32_t */ -#define PRIoLEAST64 __PRI64"o" /* uint_least64_t */ -#define PRIoFAST8 "o" /* uint_fast8_t */ -#define PRIoFAST16 "o" /* uint_fast16_t */ -#define PRIoFAST32 "o" /* uint_fast32_t */ -#define PRIoFAST64 __PRI64"o" /* uint_fast64_t */ -#define PRIoMAX "jo" /* uintmax_t */ -#define PRIoPTR __PRIptr"o" /* uintptr_t */ - -#define PRIu8 "u" /* uint8_t */ -#define PRIu16 "u" /* uint16_t */ -#define PRIu32 "u" /* uint32_t */ -#define PRIu64 __PRI64"u" /* uint64_t */ -#define PRIuLEAST8 "u" /* uint_least8_t */ -#define PRIuLEAST16 "u" /* uint_least16_t */ -#define PRIuLEAST32 "u" /* uint_least32_t */ -#define PRIuLEAST64 __PRI64"u" /* uint_least64_t */ -#define PRIuFAST8 "u" /* uint_fast8_t */ -#define PRIuFAST16 "u" /* uint_fast16_t */ -#define PRIuFAST32 "u" /* uint_fast32_t */ -#define PRIuFAST64 __PRI64"u" /* uint_fast64_t */ -#define PRIuMAX "ju" /* uintmax_t */ -#define PRIuPTR __PRIptr"u" /* uintptr_t */ - -#define PRIx8 "x" /* uint8_t */ -#define PRIx16 "x" /* uint16_t */ -#define PRIx32 "x" /* uint32_t */ -#define PRIx64 __PRI64"x" /* uint64_t */ -#define PRIxLEAST8 "x" /* uint_least8_t */ -#define PRIxLEAST16 "x" /* uint_least16_t */ -#define PRIxLEAST32 "x" /* uint_least32_t */ -#define PRIxLEAST64 __PRI64"x" /* uint_least64_t */ -#define PRIxFAST8 "x" /* uint_fast8_t */ -#define PRIxFAST16 "x" /* uint_fast16_t */ -#define PRIxFAST32 "x" /* uint_fast32_t */ -#define PRIxFAST64 __PRI64"x" /* uint_fast64_t */ -#define PRIxMAX "jx" /* uintmax_t */ -#define PRIxPTR __PRIptr"x" /* uintptr_t */ - -#define PRIX8 "X" /* uint8_t */ -#define PRIX16 "X" /* uint16_t */ -#define PRIX32 "X" /* uint32_t */ -#define PRIX64 __PRI64"X" /* uint64_t */ -#define PRIXLEAST8 "X" /* uint_least8_t */ -#define PRIXLEAST16 "X" /* uint_least16_t */ -#define PRIXLEAST32 "X" /* uint_least32_t */ -#define PRIXLEAST64 __PRI64"X" /* uint_least64_t */ -#define PRIXFAST8 "X" /* uint_fast8_t */ -#define PRIXFAST16 "X" /* uint_fast16_t */ -#define PRIXFAST32 "X" /* uint_fast32_t */ -#define PRIXFAST64 __PRI64"X" /* uint_fast64_t */ -#define PRIXMAX "jX" /* uintmax_t */ -#define PRIXPTR __PRIptr"X" /* uintptr_t */ - -/* fscanf(3) macros for signed integers. */ - -#define SCNd8 "hhd" /* int8_t */ -#define SCNd16 "hd" /* int16_t */ -#define SCNd32 "d" /* int32_t */ -#define SCNd64 __PRI64"d" /* int64_t */ -#define SCNdLEAST8 "hhd" /* int_least8_t */ -#define SCNdLEAST16 "hd" /* int_least16_t */ -#define SCNdLEAST32 "d" /* int_least32_t */ -#define SCNdLEAST64 __PRI64"d" /* int_least64_t */ -#define SCNdFAST8 "d" /* int_fast8_t */ -#define SCNdFAST16 "d" /* int_fast16_t */ -#define SCNdFAST32 "d" /* int_fast32_t */ -#define SCNdFAST64 __PRI64"d" /* int_fast64_t */ -#define SCNdMAX "jd" /* intmax_t */ -#define SCNdPTR __PRIptr"d" /* intptr_t */ - -#define SCNi8 "hhi" /* int8_t */ -#define SCNi16 "hi" /* int16_t */ -#define SCNi32 "i" /* int32_t */ -#define SCNi64 __PRI64"i" /* int64_t */ -#define SCNiLEAST8 "hhi" /* int_least8_t */ -#define SCNiLEAST16 "hi" /* int_least16_t */ -#define SCNiLEAST32 "i" /* int_least32_t */ -#define SCNiLEAST64 __PRI64"i" /* int_least64_t */ -#define SCNiFAST8 "i" /* int_fast8_t */ -#define SCNiFAST16 "i" /* int_fast16_t */ -#define SCNiFAST32 "i" /* int_fast32_t */ -#define SCNiFAST64 __PRI64"i" /* int_fast64_t */ -#define SCNiMAX "ji" /* intmax_t */ -#define SCNiPTR __PRIptr"i" /* intptr_t */ - -/* fscanf(3) macros for unsigned integers. */ - -#define SCNo8 "hho" /* uint8_t */ -#define SCNo16 "ho" /* uint16_t */ -#define SCNo32 "o" /* uint32_t */ -#define SCNo64 __PRI64"o" /* uint64_t */ -#define SCNoLEAST8 "hho" /* uint_least8_t */ -#define SCNoLEAST16 "ho" /* uint_least16_t */ -#define SCNoLEAST32 "o" /* uint_least32_t */ -#define SCNoLEAST64 __PRI64"o" /* uint_least64_t */ -#define SCNoFAST8 "o" /* uint_fast8_t */ -#define SCNoFAST16 "o" /* uint_fast16_t */ -#define SCNoFAST32 "o" /* uint_fast32_t */ -#define SCNoFAST64 __PRI64"o" /* uint_fast64_t */ -#define SCNoMAX "jo" /* uintmax_t */ -#define SCNoPTR __PRIptr"o" /* uintptr_t */ - -#define SCNu8 "hhu" /* uint8_t */ -#define SCNu16 "hu" /* uint16_t */ -#define SCNu32 "u" /* uint32_t */ -#define SCNu64 __PRI64"u" /* uint64_t */ -#define SCNuLEAST8 "hhu" /* uint_least8_t */ -#define SCNuLEAST16 "hu" /* uint_least16_t */ -#define SCNuLEAST32 "u" /* uint_least32_t */ -#define SCNuLEAST64 __PRI64"u" /* uint_least64_t */ -#define SCNuFAST8 "u" /* uint_fast8_t */ -#define SCNuFAST16 "u" /* uint_fast16_t */ -#define SCNuFAST32 "u" /* uint_fast32_t */ -#define SCNuFAST64 __PRI64"u" /* uint_fast64_t */ -#define SCNuMAX "ju" /* uintmax_t */ -#define SCNuPTR __PRIptr"u" /* uintptr_t */ - -#define SCNx8 "hhx" /* uint8_t */ -#define SCNx16 "hx" /* uint16_t */ -#define SCNx32 "x" /* uint32_t */ -#define SCNx64 __PRI64"x" /* uint64_t */ -#define SCNxLEAST8 "hhx" /* uint_least8_t */ -#define SCNxLEAST16 "hx" /* uint_least16_t */ -#define SCNxLEAST32 "x" /* uint_least32_t */ -#define SCNxLEAST64 __PRI64"x" /* uint_least64_t */ -#define SCNxFAST8 "x" /* uint_fast8_t */ -#define SCNxFAST16 "x" /* uint_fast16_t */ -#define SCNxFAST32 "x" /* uint_fast32_t */ -#define SCNxFAST64 __PRI64"x" /* uint_fast64_t */ -#define SCNxMAX "jx" /* uintmax_t */ -#define SCNxPTR __PRIptr"x" /* uintptr_t */ - -#endif /* !_MACHINE_INTTYPES_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/_limits.h b/lib/libc/include/generic-freebsd/machine/_limits.h index fd8ab8e08a93ae85d5d4eca86be624fdd3bd7be5..71d8b62434e11012148499c26cc5d41499c4c7c7 100644 --- a/lib/libc/include/generic-freebsd/machine/_limits.h +++ b/lib/libc/include/generic-freebsd/machine/_limits.h @@ -1,98 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 + * This file is in the public domain. */ -#ifndef _MACHINE__LIMITS_H_ -#define _MACHINE__LIMITS_H_ - -/* - * According to ANSI (section 2.2.4.2), the values below must be usable by - * #if preprocessing directives. Additionally, the expression must have the - * same type as would an expression that is an object of the corresponding - * type converted according to the integral promotions. The subtraction for - * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an - * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). - */ - -#define __CHAR_BIT 8 /* number of bits in a char */ - -#define __SCHAR_MAX 0x7f /* max value for a signed char */ -#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ - -#define __UCHAR_MAX 0xff /* max value for an unsigned char */ - -#define __USHRT_MAX 0xffff /* max value for an unsigned short */ -#define __SHRT_MAX 0x7fff /* max value for a short */ -#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */ - -#define __UINT_MAX 0xffffffff /* max value for an unsigned int */ -#define __INT_MAX 0x7fffffff /* max value for an int */ -#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */ - -#ifdef __LP64__ -#define __ULONG_MAX 0xffffffffffffffff -#define __LONG_MAX 0x7fffffffffffffff -#define __LONG_MIN (-0x7fffffffffffffff - 1) -#define __LONG_BIT 64 -#else -#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ -#define __LONG_MAX 0x7fffffffL /* max value for a long */ -#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */ -#define __LONG_BIT 32 -#endif - -#define __ULLONG_MAX 0xffffffffffffffffULL -#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ -#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ - -#ifdef __LP64__ -#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ -#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ -#else -#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */ -#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */ -#endif - -#define __OFF_MAX __LLONG_MAX /* max value for an off_t */ -#define __OFF_MIN __LLONG_MIN /* min value for an off_t */ - -/* Quads and long longs are the same size. Ensure they stay in sync. */ -#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */ -#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */ -#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */ - -#define __WORD_BIT 32 - -/* Minimum signal stack size. */ -#define __MINSIGSTKSZ (512 * 4) - -#endif /* !_MACHINE__LIMITS_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/_stdint.h b/lib/libc/include/generic-freebsd/machine/_stdint.h index 6111b8467c09c33f2dafc78839b5035a1d68a2f1..4fb2b3fb4ada6fdd4e1741429ba79b866b6475d4 100644 --- a/lib/libc/include/generic-freebsd/machine/_stdint.h +++ b/lib/libc/include/generic-freebsd/machine/_stdint.h @@ -1,200 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2001, 2002 Mike Barcroft - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE__STDINT_H_ -#define _MACHINE__STDINT_H_ - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -#define INT8_C(c) (c) -#define INT16_C(c) (c) -#define INT32_C(c) (c) - -#define UINT8_C(c) (c) -#define UINT16_C(c) (c) -#define UINT32_C(c) (c ## U) - -#ifdef __LP64__ -#define INT64_C(c) (c ## L) -#define UINT64_C(c) (c ## UL) -#else -#define INT64_C(c) (c ## LL) -#define UINT64_C(c) (c ## ULL) -#endif - -#define INTMAX_C(c) INT64_C(c) -#define UINTMAX_C(c) UINT64_C(c) - -#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -#ifndef __INT64_C -#ifdef __LP64__ -#define __INT64_C(c) (c ## L) -#define __UINT64_C(c) (c ## UL) -#else -#define __INT64_C(c) (c ## LL) -#define __UINT64_C(c) (c ## ULL) -#endif -#endif - -/* - * ISO/IEC 9899:1999 - * 7.18.2.1 Limits of exact-width integer types - */ -/* Minimum values of exact-width signed integer types. */ -#define INT8_MIN (-0x7f-1) -#define INT16_MIN (-0x7fff-1) -#define INT32_MIN (-0x7fffffff-1) -#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1) - -/* Maximum values of exact-width signed integer types. */ -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff -#define INT64_MAX __INT64_C(0x7fffffffffffffff) - -/* Maximum values of exact-width unsigned integer types. */ -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffff -#define UINT64_MAX __UINT64_C(0xffffffffffffffff) - -/* - * ISO/IEC 9899:1999 - * 7.18.2.2 Limits of minimum-width integer types - */ -/* Minimum values of minimum-width signed integer types. */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -/* Maximum values of minimum-width signed integer types. */ -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -/* Maximum values of minimum-width unsigned integer types. */ -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.3 Limits of fastest minimum-width integer types - */ -/* Minimum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MIN INT32_MIN -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -/* Maximum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MAX INT32_MAX -#define INT_FAST16_MAX INT32_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -/* Maximum values of fastest minimum-width unsigned integer types. */ -#define UINT_FAST8_MAX UINT32_MAX -#define UINT_FAST16_MAX UINT32_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.4 Limits of integer types capable of holding object pointers - */ -#ifdef __LP64__ -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX -#else -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX -#endif - -/* - * ISO/IEC 9899:1999 - * 7.18.2.5 Limits of greatest-width integer types - */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.3 Limits of other integer types - */ -#ifdef __LP64__ -/* Limits of ptrdiff_t. */ -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX - -/* Limits of sig_atomic_t. */ -#define SIG_ATOMIC_MIN INT64_MIN -#define SIG_ATOMIC_MAX INT64_MAX - -/* Limit of size_t. */ -#define SIZE_MAX UINT64_MAX -#else -/* Limits of ptrdiff_t. */ -#define PTRDIFF_MIN INT32_MIN -#define PTRDIFF_MAX INT32_MAX - -/* Limits of sig_atomic_t. */ -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -/* Limit of size_t. */ -#define SIZE_MAX UINT32_MAX -#endif - -/* Limits of wint_t. */ -#define WINT_MIN INT32_MIN -#define WINT_MAX INT32_MAX - -#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - -#endif /* !_MACHINE__STDINT_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/_types.h b/lib/libc/include/generic-freebsd/machine/_types.h index 889fdffe74d1f1dcb0bd6a3d6e0af73e7284eea0..da8cb16909c45a62b2bcd0064c37989424176da7 100644 --- a/lib/libc/include/generic-freebsd/machine/_types.h +++ b/lib/libc/include/generic-freebsd/machine/_types.h @@ -1,92 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2002 Mike Barcroft - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 + * This file is in the public domain. */ -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -#ifndef _SYS__TYPES_H_ -#error do not include this header, use sys/_types.h -#endif - -/* - * Standard type definitions. - */ -typedef __uint32_t __clock_t; /* clock()... */ -#ifndef _STANDALONE -typedef double __double_t; -typedef float __float_t; -#endif -#ifdef __LP64__ -typedef __int64_t __critical_t; -#else -typedef __int32_t __critical_t; -#endif -typedef __int32_t __int_fast8_t; -typedef __int32_t __int_fast16_t; -typedef __int32_t __int_fast32_t; -typedef __int64_t __int_fast64_t; -#ifdef __LP64__ -typedef __int64_t __register_t; -typedef __int64_t __segsz_t; /* segment size (in pages) */ -#else -typedef __int32_t __register_t; -typedef __int32_t __segsz_t; /* segment size (in pages) */ -#endif -typedef __int64_t __time_t; /* time()... */ -typedef __uint32_t __uint_fast8_t; -typedef __uint32_t __uint_fast16_t; -typedef __uint32_t __uint_fast32_t; -typedef __uint64_t __uint_fast64_t; -#ifdef __LP64__ -typedef __uint64_t __u_register_t; -typedef __uint64_t __vm_paddr_t; -#else -typedef __uint32_t __u_register_t; -#ifdef BOOKE -typedef __uint64_t __vm_paddr_t; -#else -typedef __uint32_t __vm_paddr_t; -#endif -#endif -typedef int ___wchar_t; - -#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */ -#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */ - -#endif /* !_MACHINE__TYPES_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/altivec.h b/lib/libc/include/generic-freebsd/machine/altivec.h deleted file mode 100644 index 87f795c6ee43606f2c85f2a9e3ce6c581b59045b..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/altivec.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2008 Nathan Whitehorn - * All rights reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_ALTIVEC_H_ -#define _MACHINE_ALTIVEC_H_ - -#define ALTIVEC_VSCR_NJ 0x00010000 /* Enable non-Java mode */ -#define ALTIVEC_VSCR_SAT 0x00000001 /* Saturation status bit */ - -void enable_vec(struct thread *); -void save_vec(struct thread *); -void save_vec_nodrop(struct thread *); -void enable_vec_kern(void); -void disable_vec(struct thread *td); - -#endif /* _MACHINE_ALTIVEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/asm.h b/lib/libc/include/generic-freebsd/machine/asm.h deleted file mode 100644 index 5f886582518e86fd6ce4171cbba318088dc8eb4c..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/asm.h +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $ - */ - -#ifndef _MACHINE_ASM_H_ -#define _MACHINE_ASM_H_ - -#include - -#if defined(PIC) && !defined(__powerpc64__) -#define PIC_PROLOGUE XXX -#define PIC_EPILOGUE XXX -#define PIC_PLT(x) x@plt -#ifdef __STDC__ -#define PIC_GOT(x) XXX -#else /* not __STDC__ */ -#define PIC_GOT(x) XXX -#endif /* __STDC__ */ -#else -#define PIC_PROLOGUE -#define PIC_EPILOGUE -#define PIC_PLT(x) x -#define PIC_GOT(x) x -#endif - -#define CNAME(csym) csym -#define ASMNAME(asmsym) asmsym -#ifdef __powerpc64__ -#define HIDENAME(asmsym) __CONCAT(_,asmsym) -#else -#define HIDENAME(asmsym) __CONCAT(.,asmsym) -#endif - -#if !defined(_CALL_ELF) || _CALL_ELF == 1 -#ifdef _KERNEL -/* ELFv1 kernel uses global dot symbols */ -#define DOT_LABEL(name) __CONCAT(.,name) -#define TYPE_ENTRY(name) .size name,24; \ - .type DOT_LABEL(name),@function; \ - .globl DOT_LABEL(name); -#define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name); -#else /* !_KERNEL */ -/* ELFv1 user code uses local function entry points */ -#define DOT_LABEL(name) __CONCAT(.L.,name) -#define TYPE_ENTRY(name) .type name,@function; -#define END_SIZE(name) .size name,.-DOT_LABEL(name); -#endif /* _KERNEL */ -#else -/* ELFv2 doesn't have any of this complication */ -#define DOT_LABEL(name) name -#define TYPE_ENTRY(name) .type name,@function; -#define END_SIZE(name) .size name,.-DOT_LABEL(name); -#endif - -#define _GLOBAL(name) \ - .data; \ - .p2align 2; \ - .globl name; \ - name: - -#ifdef __powerpc64__ -#define TOC_NAME_FOR_REF(name) __CONCAT(.L,name) -#define TOC_REF(name) TOC_NAME_FOR_REF(name)@toc -#define TOC_ENTRY(name) \ - .section ".toc","aw"; \ - TOC_NAME_FOR_REF(name): \ - .tc name[TC],name -#endif - -#ifdef __powerpc64__ - -#if !defined(_CALL_ELF) || _CALL_ELF == 1 -#define _ENTRY(name) \ - .section ".text"; \ - .p2align 2; \ - .globl name; \ - .section ".opd","aw"; \ - .p2align 3; \ -name: \ - .quad DOT_LABEL(name),.TOC.@tocbase,0; \ - .previous; \ - .p2align 4; \ - TYPE_ENTRY(name) \ -DOT_LABEL(name): \ - .cfi_startproc -#define _NAKED_ENTRY(name) _ENTRY(name) -#else -#define _ENTRY(name) \ - .text; \ - .p2align 4; \ - .globl name; \ - .type name,@function; \ -name: \ - .cfi_startproc; \ - addis %r2, %r12, (.TOC.-name)@ha; \ - addi %r2, %r2, (.TOC.-name)@l; \ - .localentry name, .-name; - -/* "Naked" function entry. No TOC prologue for ELFv2. */ -#define _NAKED_ENTRY(name) \ - .text; \ - .p2align 4; \ - .globl name; \ - .type name,@function; \ -name: \ - .cfi_startproc; \ - .localentry name, .-name; -#endif - -#define _END(name) \ - .cfi_endproc; \ - .long 0; \ - .byte 0,0,0,0,0,0,0,0; \ - END_SIZE(name) - -#define LOAD_ADDR(reg, var) \ - lis reg, var@highest; \ - ori reg, reg, var@higher; \ - rldicr reg, reg, 32, 31; \ - oris reg, reg, var@h; \ - ori reg, reg, var@l; -#else /* !__powerpc64__ */ -#define _ENTRY(name) \ - .text; \ - .p2align 4; \ - .globl name; \ - .type name,@function; \ -name: \ - .cfi_startproc -#define _END(name) \ - .cfi_endproc; \ - .size name, . - name - -#define _NAKED_ENTRY(name) _ENTRY(name) - -#define LOAD_ADDR(reg, var) \ - lis reg, var@ha; \ - ori reg, reg, var@l; -#endif /* __powerpc64__ */ - -#if defined(PROF) || (defined(_KERNEL) && defined(GPROF)) -# ifdef __powerpc64__ -# define _PROF_PROLOGUE mflr 0; \ - std 3,48(1); \ - std 4,56(1); \ - std 5,64(1); \ - std 0,16(1); \ - stdu 1,-112(1); \ - bl _mcount; \ - nop; \ - ld 0,112+16(1); \ - ld 3,112+48(1); \ - ld 4,112+56(1); \ - ld 5,112+64(1); \ - mtlr 0; \ - addi 1,1,112 -# else -# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount -# endif -#else -# define _PROF_PROLOGUE -#endif - -#define ASEND(y) _END(ASMNAME(y)) -#define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE -#define END(y) _END(CNAME(y)) -#define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE -#define GLOBAL(y) _GLOBAL(CNAME(y)) - -#define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y)) -#define ENTRY_NOPROF(y) _ENTRY(CNAME(y)) - -/* Load NIA without affecting branch prediction */ -#define LOAD_LR_NIA bcl 20, 31, .+4 - -/* - * Magic sequence to return to native endian. - * Overwrites r0 and r11. - * - * The encoding of the instruction "tdi 0, %r0, 0x48" in opposite endian - * happens to be "b . + 8". This is useful because we can write a sequence - * of instructions that can execute in either endian. - * - * Use a sequence of handcoded instructions that switches contexts to the - * instruction following the sequence, but with the correct PSL_LE bit. - * - * The same sequence works for both BE and LE because the xori will flip - * the bit to the other state, and the code only runs when running in the - * wrong endian. - * - * This sequence is NMI-reentrant. - * - * Do not change the length of this sequence without looking at the users, - * this is used in size-constrained places like the reset vector! - */ -#define RETURN_TO_NATIVE_ENDIAN \ - tdi 0, %r0, 0x48; /* Endian swapped: b . + 8 */\ - b 1f; /* Will fall through to here if correct */\ - .long 0xa600607d; /* mfmsr %r11 */\ - .long 0x00000038; /* li %r0, 0 */\ - .long 0x6401617d; /* mtmsrd %r0, 1 (L=1 EE,RI bits only) */\ - .long 0x01006b69; /* xori %r11, %r11, 0x1 (PSL_LE) */\ - .long 0xa602087c; /* mflr %r0 */\ - .long 0x05009f42; /* LOAD_LR_NIA */\ - .long 0xa6037b7d; /* 0: mtsrr1 %r11 */\ - .long 0xa602687d; /* mflr %r11 */\ - .long 0x18006b39; /* addi %r11, %r11, (1f - 0b) */\ - .long 0xa6037a7d; /* mtsrr0 %r11 */\ - .long 0xa603087c; /* mtlr %r0 */\ - .long 0x2400004c; /* rfid */\ -1: /* RETURN_TO_NATIVE_ENDIAN */ - -#define ASMSTR .asciz - -#define RCSID(x) .text; .asciz x - -#undef __FBSDID -#if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s -#else -#define __FBSDID(s) /* nothing */ -#endif /* not lint and not STRIP_FBSDID */ - -#define WEAK_REFERENCE(sym, alias) \ - .weak alias; \ - .equ alias,sym - -#ifdef __STDC__ -#define WARN_REFERENCES(_sym,_msg) \ - .section .gnu.warning. ## _sym ; .ascii _msg ; .text -#else -#define WARN_REFERENCES(_sym,_msg) \ - .section .gnu.warning./**/_sym ; .ascii _msg ; .text -#endif /* __STDC__ */ - -#endif /* !_MACHINE_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/atomic.h b/lib/libc/include/generic-freebsd/machine/atomic.h deleted file mode 100644 index eb9ab520c9af64d23ab04d8ee39ee18c0ff9e039..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/atomic.h +++ /dev/null @@ -1,1148 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2008 Marcel Moolenaar - * Copyright (c) 2001 Benno Rice - * Copyright (c) 2001 David E. O'Brien - * Copyright (c) 1998 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ - -#include - -#ifndef __powerpc64__ -#include -#endif - -/* - * The __ATOMIC_REL/ACQ() macros provide memory barriers only in conjunction - * with the atomic lXarx/stXcx. sequences below. They are not exposed outside - * of this file. See also Appendix B.2 of Book II of the architecture manual. - * - * Note that not all Book-E processors accept the light-weight sync variant. - * In particular, early models of E500 cores are known to wedge. Bank on all - * 64-bit capable CPUs to accept lwsync properly and pressimize 32-bit CPUs - * to use the heavier-weight sync. - */ - -#ifdef __powerpc64__ -#define mb() __asm __volatile("sync" : : : "memory") -#define rmb() __asm __volatile("lwsync" : : : "memory") -#define wmb() __asm __volatile("lwsync" : : : "memory") -#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") -#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") -#else -#define mb() __asm __volatile("sync" : : : "memory") -#define rmb() __asm __volatile("sync" : : : "memory") -#define wmb() __asm __volatile("sync" : : : "memory") -#define __ATOMIC_REL() __asm __volatile("sync" : : : "memory") -#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") -#endif - -static __inline void -powerpc_lwsync(void) -{ - -#ifdef __powerpc64__ - __asm __volatile("lwsync" : : : "memory"); -#else - __asm __volatile("sync" : : : "memory"); -#endif -} - -/* - * atomic_add(p, v) - * { *p += v; } - */ - -#define __atomic_add_int(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " add %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_add_int */ - -#ifdef __powerpc64__ -#define __atomic_add_long(p, v, t) \ - __asm __volatile( \ - "1: ldarx %0, 0, %2\n" \ - " add %0, %3, %0\n" \ - " stdcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_add_long */ -#else -#define __atomic_add_long(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " add %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_add_long */ -#endif - -#define _ATOMIC_ADD(type) \ - static __inline void \ - atomic_add_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_add_##type(p, v, t); \ - } \ - \ - static __inline void \ - atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_add_##type(p, v, t); \ - __ATOMIC_ACQ(); \ - } \ - \ - static __inline void \ - atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __ATOMIC_REL(); \ - __atomic_add_##type(p, v, t); \ - } \ - /* _ATOMIC_ADD */ - -_ATOMIC_ADD(int) -_ATOMIC_ADD(long) - -#define atomic_add_32 atomic_add_int -#define atomic_add_acq_32 atomic_add_acq_int -#define atomic_add_rel_32 atomic_add_rel_int - -#ifdef __powerpc64__ -#define atomic_add_64 atomic_add_long -#define atomic_add_acq_64 atomic_add_acq_long -#define atomic_add_rel_64 atomic_add_rel_long - -#define atomic_add_ptr atomic_add_long -#define atomic_add_acq_ptr atomic_add_acq_long -#define atomic_add_rel_ptr atomic_add_rel_long -#else -#define atomic_add_ptr atomic_add_int -#define atomic_add_acq_ptr atomic_add_acq_int -#define atomic_add_rel_ptr atomic_add_rel_int -#endif -#undef _ATOMIC_ADD -#undef __atomic_add_long -#undef __atomic_add_int - -/* - * atomic_clear(p, v) - * { *p &= ~v; } - */ - -#define __atomic_clear_int(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " andc %0, %0, %3\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_clear_int */ - -#ifdef __powerpc64__ -#define __atomic_clear_long(p, v, t) \ - __asm __volatile( \ - "1: ldarx %0, 0, %2\n" \ - " andc %0, %0, %3\n" \ - " stdcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_clear_long */ -#else -#define __atomic_clear_long(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " andc %0, %0, %3\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_clear_long */ -#endif - -#define _ATOMIC_CLEAR(type) \ - static __inline void \ - atomic_clear_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_clear_##type(p, v, t); \ - } \ - \ - static __inline void \ - atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_clear_##type(p, v, t); \ - __ATOMIC_ACQ(); \ - } \ - \ - static __inline void \ - atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __ATOMIC_REL(); \ - __atomic_clear_##type(p, v, t); \ - } \ - /* _ATOMIC_CLEAR */ - -_ATOMIC_CLEAR(int) -_ATOMIC_CLEAR(long) - -#define atomic_clear_32 atomic_clear_int -#define atomic_clear_acq_32 atomic_clear_acq_int -#define atomic_clear_rel_32 atomic_clear_rel_int - -#ifdef __powerpc64__ -#define atomic_clear_64 atomic_clear_long -#define atomic_clear_acq_64 atomic_clear_acq_long -#define atomic_clear_rel_64 atomic_clear_rel_long - -#define atomic_clear_ptr atomic_clear_long -#define atomic_clear_acq_ptr atomic_clear_acq_long -#define atomic_clear_rel_ptr atomic_clear_rel_long -#else -#define atomic_clear_ptr atomic_clear_int -#define atomic_clear_acq_ptr atomic_clear_acq_int -#define atomic_clear_rel_ptr atomic_clear_rel_int -#endif -#undef _ATOMIC_CLEAR -#undef __atomic_clear_long -#undef __atomic_clear_int - -/* - * atomic_cmpset(p, o, n) - */ -/* TODO -- see below */ - -/* - * atomic_load_acq(p) - */ -/* TODO -- see below */ - -/* - * atomic_readandclear(p) - */ -/* TODO -- see below */ - -/* - * atomic_set(p, v) - * { *p |= v; } - */ - -#define __atomic_set_int(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " or %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_set_int */ - -#ifdef __powerpc64__ -#define __atomic_set_long(p, v, t) \ - __asm __volatile( \ - "1: ldarx %0, 0, %2\n" \ - " or %0, %3, %0\n" \ - " stdcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_set_long */ -#else -#define __atomic_set_long(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " or %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_set_long */ -#endif - -#define _ATOMIC_SET(type) \ - static __inline void \ - atomic_set_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_set_##type(p, v, t); \ - } \ - \ - static __inline void \ - atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_set_##type(p, v, t); \ - __ATOMIC_ACQ(); \ - } \ - \ - static __inline void \ - atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __ATOMIC_REL(); \ - __atomic_set_##type(p, v, t); \ - } \ - /* _ATOMIC_SET */ - -_ATOMIC_SET(int) -_ATOMIC_SET(long) - -#define atomic_set_32 atomic_set_int -#define atomic_set_acq_32 atomic_set_acq_int -#define atomic_set_rel_32 atomic_set_rel_int - -#ifdef __powerpc64__ -#define atomic_set_64 atomic_set_long -#define atomic_set_acq_64 atomic_set_acq_long -#define atomic_set_rel_64 atomic_set_rel_long - -#define atomic_set_ptr atomic_set_long -#define atomic_set_acq_ptr atomic_set_acq_long -#define atomic_set_rel_ptr atomic_set_rel_long -#else -#define atomic_set_ptr atomic_set_int -#define atomic_set_acq_ptr atomic_set_acq_int -#define atomic_set_rel_ptr atomic_set_rel_int -#endif -#undef _ATOMIC_SET -#undef __atomic_set_long -#undef __atomic_set_int - -/* - * atomic_subtract(p, v) - * { *p -= v; } - */ - -#define __atomic_subtract_int(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " subf %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_subtract_int */ - -#ifdef __powerpc64__ -#define __atomic_subtract_long(p, v, t) \ - __asm __volatile( \ - "1: ldarx %0, 0, %2\n" \ - " subf %0, %3, %0\n" \ - " stdcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_subtract_long */ -#else -#define __atomic_subtract_long(p, v, t) \ - __asm __volatile( \ - "1: lwarx %0, 0, %2\n" \ - " subf %0, %3, %0\n" \ - " stwcx. %0, 0, %2\n" \ - " bne- 1b\n" \ - : "=&r" (t), "=m" (*p) \ - : "r" (p), "r" (v), "m" (*p) \ - : "cr0", "memory") \ - /* __atomic_subtract_long */ -#endif - -#define _ATOMIC_SUBTRACT(type) \ - static __inline void \ - atomic_subtract_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_subtract_##type(p, v, t); \ - } \ - \ - static __inline void \ - atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __atomic_subtract_##type(p, v, t); \ - __ATOMIC_ACQ(); \ - } \ - \ - static __inline void \ - atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \ - u_##type t; \ - __ATOMIC_REL(); \ - __atomic_subtract_##type(p, v, t); \ - } \ - /* _ATOMIC_SUBTRACT */ - -_ATOMIC_SUBTRACT(int) -_ATOMIC_SUBTRACT(long) - -#define atomic_subtract_32 atomic_subtract_int -#define atomic_subtract_acq_32 atomic_subtract_acq_int -#define atomic_subtract_rel_32 atomic_subtract_rel_int - -#ifdef __powerpc64__ -#define atomic_subtract_64 atomic_subtract_long -#define atomic_subtract_acq_64 atomic_subract_acq_long -#define atomic_subtract_rel_64 atomic_subtract_rel_long - -#define atomic_subtract_ptr atomic_subtract_long -#define atomic_subtract_acq_ptr atomic_subtract_acq_long -#define atomic_subtract_rel_ptr atomic_subtract_rel_long -#else -#define atomic_subtract_ptr atomic_subtract_int -#define atomic_subtract_acq_ptr atomic_subtract_acq_int -#define atomic_subtract_rel_ptr atomic_subtract_rel_int -#endif -#undef _ATOMIC_SUBTRACT -#undef __atomic_subtract_long -#undef __atomic_subtract_int - -/* - * atomic_store_rel(p, v) - */ -/* TODO -- see below */ - -/* - * Old/original implementations that still need revisiting. - */ - -static __inline u_int -atomic_readandclear_int(volatile u_int *addr) -{ - u_int result,temp; - - __asm __volatile ( - "\tsync\n" /* drain writes */ - "1:\tlwarx %0, 0, %3\n\t" /* load old value */ - "li %1, 0\n\t" /* load new value */ - "stwcx. %1, 0, %3\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - : "=&r"(result), "=&r"(temp), "=m" (*addr) - : "r" (addr), "m" (*addr) - : "cr0", "memory"); - - return (result); -} - -#ifdef __powerpc64__ -static __inline u_long -atomic_readandclear_long(volatile u_long *addr) -{ - u_long result,temp; - - __asm __volatile ( - "\tsync\n" /* drain writes */ - "1:\tldarx %0, 0, %3\n\t" /* load old value */ - "li %1, 0\n\t" /* load new value */ - "stdcx. %1, 0, %3\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - : "=&r"(result), "=&r"(temp), "=m" (*addr) - : "r" (addr), "m" (*addr) - : "cr0", "memory"); - - return (result); -} -#endif - -#define atomic_readandclear_32 atomic_readandclear_int - -#ifdef __powerpc64__ -#define atomic_readandclear_64 atomic_readandclear_long - -#define atomic_readandclear_ptr atomic_readandclear_long -#else -static __inline u_long -atomic_readandclear_long(volatile u_long *addr) -{ - - return ((u_long)atomic_readandclear_int((volatile u_int *)addr)); -} - -#define atomic_readandclear_ptr atomic_readandclear_int -#endif - -/* - * We assume that a = b will do atomic loads and stores. - */ -#define ATOMIC_STORE_LOAD(TYPE) \ -static __inline u_##TYPE \ -atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ -{ \ - u_##TYPE v; \ - \ - v = *p; \ - powerpc_lwsync(); \ - return (v); \ -} \ - \ -static __inline void \ -atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \ -{ \ - \ - powerpc_lwsync(); \ - *p = v; \ -} - -ATOMIC_STORE_LOAD(int) - -#define atomic_load_acq_32 atomic_load_acq_int -#define atomic_store_rel_32 atomic_store_rel_int - -#ifdef __powerpc64__ -ATOMIC_STORE_LOAD(long) - -#define atomic_load_acq_64 atomic_load_acq_long -#define atomic_store_rel_64 atomic_store_rel_long - -#define atomic_load_acq_ptr atomic_load_acq_long -#define atomic_store_rel_ptr atomic_store_rel_long -#else -static __inline u_long -atomic_load_acq_long(volatile u_long *addr) -{ - - return ((u_long)atomic_load_acq_int((volatile u_int *)addr)); -} - -static __inline void -atomic_store_rel_long(volatile u_long *addr, u_long val) -{ - - atomic_store_rel_int((volatile u_int *)addr, (u_int)val); -} - -#define atomic_load_acq_ptr atomic_load_acq_int -#define atomic_store_rel_ptr atomic_store_rel_int -#endif -#undef ATOMIC_STORE_LOAD - -/* - * Atomically compare the value stored at *p with cmpval and if the - * two values are equal, update the value of *p with newval. Returns - * zero if the compare failed, nonzero otherwise. - */ -#ifdef ISA_206_ATOMICS -static __inline int -atomic_cmpset_char(volatile u_char *p, u_char cmpval, u_char newval) -{ - int ret; - - __asm __volatile ( - "1:\tlbarx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "stbcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stbcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) - : "cr0", "memory"); - - return (ret); -} - -static __inline int -atomic_cmpset_short(volatile u_short *p, u_short cmpval, u_short newval) -{ - int ret; - - __asm __volatile ( - "1:\tlharx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "sthcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "sthcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) - : "cr0", "memory"); - - return (ret); -} -#else -static __inline int -atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval, - uint32_t mask) -{ - int ret; - uint32_t tmp; - - __asm __volatile ( - "1:\tlwarx %2, 0, %3\n\t" /* load old value */ - "and %0, %2, %7\n\t" - "cmplw %4, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "andc %2, %2, %7\n\t" - "or %2, %2, %5\n\t" - "stwcx. %2, 0, %3\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stwcx. %2, 0, %3\n\t" /* clear reservation (74xx) */ - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p), "+&r" (tmp) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p), - "r" (mask) - : "cr0", "memory"); - - return (ret); -} - -#define _atomic_cmpset_masked_word(a,o,v,m) atomic_cmpset_masked(a, o, v, m) -#endif - -static __inline int -atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) -{ - int ret; - - __asm __volatile ( - "1:\tlwarx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "stwcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) - : "cr0", "memory"); - - return (ret); -} -static __inline int -atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) -{ - int ret; - - __asm __volatile ( - #ifdef __powerpc64__ - "1:\tldarx %0, 0, %2\n\t" /* load old value */ - "cmpld %3, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "stdcx. %4, 0, %2\n\t" /* attempt to store */ - #else - "1:\tlwarx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne- 2f\n\t" /* exit if not equal */ - "stwcx. %4, 0, %2\n\t" /* attempt to store */ - #endif - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - #ifdef __powerpc64__ - "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - #else - "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - #endif - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) - : "cr0", "memory"); - - return (ret); -} - -#define ATOMIC_CMPSET_ACQ_REL(type) \ - static __inline int \ - atomic_cmpset_acq_##type(volatile u_##type *p, \ - u_##type cmpval, u_##type newval)\ - {\ - u_##type retval; \ - retval = atomic_cmpset_##type(p, cmpval, newval);\ - __ATOMIC_ACQ();\ - return (retval);\ - }\ - static __inline int \ - atomic_cmpset_rel_##type(volatile u_##type *p, \ - u_##type cmpval, u_##type newval)\ - {\ - __ATOMIC_REL();\ - return (atomic_cmpset_##type(p, cmpval, newval));\ - }\ - struct hack - -ATOMIC_CMPSET_ACQ_REL(int); -ATOMIC_CMPSET_ACQ_REL(long); - -#ifdef ISA_206_ATOMICS -#define atomic_cmpset_8 atomic_cmpset_char -#endif -#define atomic_cmpset_acq_8 atomic_cmpset_acq_char -#define atomic_cmpset_rel_8 atomic_cmpset_rel_char - -#ifdef ISA_206_ATOMICS -#define atomic_cmpset_16 atomic_cmpset_short -#endif -#define atomic_cmpset_acq_16 atomic_cmpset_acq_short -#define atomic_cmpset_rel_16 atomic_cmpset_rel_short - -#define atomic_cmpset_32 atomic_cmpset_int -#define atomic_cmpset_acq_32 atomic_cmpset_acq_int -#define atomic_cmpset_rel_32 atomic_cmpset_rel_int - -#ifdef __powerpc64__ -#define atomic_cmpset_64 atomic_cmpset_long -#define atomic_cmpset_acq_64 atomic_cmpset_acq_long -#define atomic_cmpset_rel_64 atomic_cmpset_rel_long - -#define atomic_cmpset_ptr atomic_cmpset_long -#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long -#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long -#else -#define atomic_cmpset_ptr atomic_cmpset_int -#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int -#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int -#endif - -/* - * Atomically compare the value stored at *p with *cmpval and if the - * two values are equal, update the value of *p with newval. Returns - * zero if the compare failed and sets *cmpval to the read value from *p, - * nonzero otherwise. - */ -#ifdef ISA_206_ATOMICS -static __inline int -atomic_fcmpset_char(volatile u_char *p, u_char *cmpval, u_char newval) -{ - int ret; - - __asm __volatile ( - "lbarx %0, 0, %3\n\t" /* load old value */ - "cmplw %4, %0\n\t" /* compare */ - "bne- 1f\n\t" /* exit if not equal */ - "stbcx. %5, 0, %3\n\t" /* attempt to store */ - "bne- 1f\n\t" /* exit if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 2f\n\t" /* we've succeeded */ - "1:\n\t" - "stbcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ - "stbx %0, 0, %7\n\t" - "li %0, 0\n\t" /* failure - retval = 0 */ - "2:\n\t" - : "=&r" (ret), "=m" (*p), "=m" (*cmpval) - : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) - : "cr0", "memory"); - - return (ret); -} - -static __inline int -atomic_fcmpset_short(volatile u_short *p, u_short *cmpval, u_short newval) -{ - int ret; - - __asm __volatile ( - "lharx %0, 0, %3\n\t" /* load old value */ - "cmplw %4, %0\n\t" /* compare */ - "bne- 1f\n\t" /* exit if not equal */ - "sthcx. %5, 0, %3\n\t" /* attempt to store */ - "bne- 1f\n\t" /* exit if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 2f\n\t" /* we've succeeded */ - "1:\n\t" - "sthcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ - "sthx %0, 0, %7\n\t" - "li %0, 0\n\t" /* failure - retval = 0 */ - "2:\n\t" - : "=&r" (ret), "=m" (*p), "=m" (*cmpval) - : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) - : "cr0", "memory"); - - return (ret); -} -#endif /* ISA_206_ATOMICS */ - -static __inline int -atomic_fcmpset_int(volatile u_int *p, u_int *cmpval, u_int newval) -{ - int ret; - - __asm __volatile ( - "lwarx %0, 0, %3\n\t" /* load old value */ - "cmplw %4, %0\n\t" /* compare */ - "bne- 1f\n\t" /* exit if not equal */ - "stwcx. %5, 0, %3\n\t" /* attempt to store */ - "bne- 1f\n\t" /* exit if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 2f\n\t" /* we've succeeded */ - "1:\n\t" - "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ - "stwx %0, 0, %7\n\t" - "li %0, 0\n\t" /* failure - retval = 0 */ - "2:\n\t" - : "=&r" (ret), "=m" (*p), "=m" (*cmpval) - : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) - : "cr0", "memory"); - - return (ret); -} -static __inline int -atomic_fcmpset_long(volatile u_long *p, u_long *cmpval, u_long newval) -{ - int ret; - - __asm __volatile ( - #ifdef __powerpc64__ - "ldarx %0, 0, %3\n\t" /* load old value */ - "cmpld %4, %0\n\t" /* compare */ - "bne- 1f\n\t" /* exit if not equal */ - "stdcx. %5, 0, %3\n\t" /* attempt to store */ - #else - "lwarx %0, 0, %3\n\t" /* load old value */ - "cmplw %4, %0\n\t" /* compare */ - "bne- 1f\n\t" /* exit if not equal */ - "stwcx. %5, 0, %3\n\t" /* attempt to store */ - #endif - "bne- 1f\n\t" /* exit if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 2f\n\t" /* we've succeeded */ - "1:\n\t" - #ifdef __powerpc64__ - "stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ - "stdx %0, 0, %7\n\t" - #else - "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ - "stwx %0, 0, %7\n\t" - #endif - "li %0, 0\n\t" /* failure - retval = 0 */ - "2:\n\t" - : "=&r" (ret), "=m" (*p), "=m" (*cmpval) - : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) - : "cr0", "memory"); - - return (ret); -} - -#define ATOMIC_FCMPSET_ACQ_REL(type) \ - static __inline int \ - atomic_fcmpset_acq_##type(volatile u_##type *p, \ - u_##type *cmpval, u_##type newval)\ - {\ - u_##type retval; \ - retval = atomic_fcmpset_##type(p, cmpval, newval);\ - __ATOMIC_ACQ();\ - return (retval);\ - }\ - static __inline int \ - atomic_fcmpset_rel_##type(volatile u_##type *p, \ - u_##type *cmpval, u_##type newval)\ - {\ - __ATOMIC_REL();\ - return (atomic_fcmpset_##type(p, cmpval, newval));\ - }\ - struct hack - -ATOMIC_FCMPSET_ACQ_REL(int); -ATOMIC_FCMPSET_ACQ_REL(long); - -#ifdef ISA_206_ATOMICS -#define atomic_fcmpset_8 atomic_fcmpset_char -#endif -#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char -#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char - -#ifdef ISA_206_ATOMICS -#define atomic_fcmpset_16 atomic_fcmpset_short -#endif -#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short -#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short - -#define atomic_fcmpset_32 atomic_fcmpset_int -#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int -#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int - -#ifdef __powerpc64__ -#define atomic_fcmpset_64 atomic_fcmpset_long -#define atomic_fcmpset_acq_64 atomic_fcmpset_acq_long -#define atomic_fcmpset_rel_64 atomic_fcmpset_rel_long - -#define atomic_fcmpset_ptr atomic_fcmpset_long -#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long -#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long -#else -#define atomic_fcmpset_ptr atomic_fcmpset_int -#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_int -#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_int -#endif - -static __inline u_int -atomic_fetchadd_int(volatile u_int *p, u_int v) -{ - u_int value; - - do { - value = *p; - } while (!atomic_cmpset_int(p, value, value + v)); - return (value); -} - -static __inline u_long -atomic_fetchadd_long(volatile u_long *p, u_long v) -{ - u_long value; - - do { - value = *p; - } while (!atomic_cmpset_long(p, value, value + v)); - return (value); -} - -static __inline u_int -atomic_swap_32(volatile u_int *p, u_int v) -{ - u_int prev; - - __asm __volatile( - "1: lwarx %0,0,%2\n" - " stwcx. %3,0,%2\n" - " bne- 1b\n" - : "=&r" (prev), "+m" (*(volatile u_int *)p) - : "r" (p), "r" (v) - : "cr0", "memory"); - - return (prev); -} - -#ifdef __powerpc64__ -static __inline u_long -atomic_swap_64(volatile u_long *p, u_long v) -{ - u_long prev; - - __asm __volatile( - "1: ldarx %0,0,%2\n" - " stdcx. %3,0,%2\n" - " bne- 1b\n" - : "=&r" (prev), "+m" (*(volatile u_long *)p) - : "r" (p), "r" (v) - : "cr0", "memory"); - - return (prev); -} -#endif - -#define atomic_fetchadd_32 atomic_fetchadd_int -#define atomic_swap_int atomic_swap_32 - -#ifdef __powerpc64__ -#define atomic_fetchadd_64 atomic_fetchadd_long -#define atomic_swap_long atomic_swap_64 -#define atomic_swap_ptr atomic_swap_64 -#else -#define atomic_swap_long(p,v) atomic_swap_32((volatile u_int *)(p), v) -#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v) -#endif - -static __inline int -atomic_testandset_int(volatile u_int *p, u_int v) -{ - u_int m = (1u << (v & 0x1f)); - u_int res; - u_int tmp; - - __asm __volatile( - "1: lwarx %0,0,%3\n" - " and %1,%0,%4\n" - " or %0,%0,%4\n" - " stwcx. %0,0,%3\n" - " bne- 1b\n" - : "=&r"(tmp), "=&r"(res), "+m"(*p) - : "r"(p), "r"(m) - : "cr0", "memory"); - - return (res != 0); -} - -static __inline int -atomic_testandclear_int(volatile u_int *p, u_int v) -{ - u_int m = (1u << (v & 0x1f)); - u_int res; - u_int tmp; - - __asm __volatile( - "1: lwarx %0,0,%3\n" - " and %1,%0,%4\n" - " andc %0,%0,%4\n" - " stwcx. %0,0,%3\n" - " bne- 1b\n" - : "=&r"(tmp), "=&r"(res), "+m"(*p) - : "r"(p), "r"(m) - : "cr0", "memory"); - - return (res != 0); -} - -#ifdef __powerpc64__ -static __inline int -atomic_testandset_long(volatile u_long *p, u_int v) -{ - u_long m = (1ul << (v & 0x3f)); - u_long res; - u_long tmp; - - __asm __volatile( - "1: ldarx %0,0,%3\n" - " and %1,%0,%4\n" - " or %0,%0,%4\n" - " stdcx. %0,0,%3\n" - " bne- 1b\n" - : "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p) - : "r"(p), "r"(m) - : "cr0", "memory"); - - return (res != 0); -} - -static __inline int -atomic_testandclear_long(volatile u_long *p, u_int v) -{ - u_long m = (1ul << (v & 0x3f)); - u_long res; - u_long tmp; - - __asm __volatile( - "1: ldarx %0,0,%3\n" - " and %1,%0,%4\n" - " andc %0,%0,%4\n" - " stdcx. %0,0,%3\n" - " bne- 1b\n" - : "=&r"(tmp), "=&r"(res), "+m"(*p) - : "r"(p), "r"(m) - : "cr0", "memory"); - - return (res != 0); -} -#else -static __inline int -atomic_testandset_long(volatile u_long *p, u_int v) -{ - return (atomic_testandset_int((volatile u_int *)p, v)); -} - -static __inline int -atomic_testandclear_long(volatile u_long *p, u_int v) -{ - return (atomic_testandclear_int((volatile u_int *)p, v)); -} -#endif - -#define atomic_testandclear_32 atomic_testandclear_int -#define atomic_testandset_32 atomic_testandset_int - -static __inline int -atomic_testandset_acq_long(volatile u_long *p, u_int v) -{ - u_int a = atomic_testandset_long(p, v); - __ATOMIC_ACQ(); - return (a); -} - -#define atomic_testandclear_int atomic_testandclear_int -#define atomic_testandset_int atomic_testandset_int -#define atomic_testandclear_long atomic_testandclear_long -#define atomic_testandset_long atomic_testandset_long -#define atomic_testandset_acq_long atomic_testandset_acq_long - -static __inline void -atomic_thread_fence_acq(void) -{ - - powerpc_lwsync(); -} - -static __inline void -atomic_thread_fence_rel(void) -{ - - powerpc_lwsync(); -} - -static __inline void -atomic_thread_fence_acq_rel(void) -{ - - powerpc_lwsync(); -} - -static __inline void -atomic_thread_fence_seq_cst(void) -{ - - __asm __volatile("sync" : : : "memory"); -} - -#ifndef ISA_206_ATOMICS -#include -#define atomic_cmpset_char atomic_cmpset_8 -#define atomic_cmpset_short atomic_cmpset_16 -#define atomic_fcmpset_char atomic_fcmpset_8 -#define atomic_fcmpset_short atomic_fcmpset_16 -#endif - -/* These need sys/_atomic_subword.h on non-ISA-2.06-atomic platforms. */ -ATOMIC_CMPSET_ACQ_REL(char); -ATOMIC_CMPSET_ACQ_REL(short); - -ATOMIC_FCMPSET_ACQ_REL(char); -ATOMIC_FCMPSET_ACQ_REL(short); - -#undef __ATOMIC_REL -#undef __ATOMIC_ACQ - -#endif /* ! _MACHINE_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/bat.h b/lib/libc/include/generic-freebsd/machine/bat.h deleted file mode 100644 index 69f74286c2f40d8fd7bd2a604240fa4b3bbb64e1..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/bat.h +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause - * - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: bat.h,v 1.2 1999/12/18 01:36:06 thorpej Exp $ - */ - -#ifndef _MACHINE_BAT_H_ -#define _MACHINE_BAT_H_ - -#ifndef LOCORE -struct bat { - u_int32_t batu; - u_int32_t batl; -}; -#endif - -/* Lower BAT bits (all but PowerPC 601): */ -#define BAT_PBS 0xfffe0000 /* physical block start */ -#define BAT_W 0x00000040 /* 1 = write-through, 0 = write-back */ -#define BAT_I 0x00000020 /* cache inhibit */ -#define BAT_M 0x00000010 /* memory coherency enable */ -#define BAT_G 0x00000008 /* guarded region */ - -#define BAT_PP_NONE 0x00000000 /* no access permission */ -#define BAT_PP_RO_S 0x00000001 /* read-only (soft) */ -#define BAT_PP_RW 0x00000002 /* read/write */ -#define BAT_PP_RO 0x00000003 /* read-only */ - -/* Upper BAT bits (all but PowerPC 601): */ -#define BAT_EBS 0xfffe0000 /* effective block start */ -#define BAT_BL 0x00001ffc /* block length */ -#define BAT_Vs 0x00000002 /* valid in supervisor mode */ -#define BAT_Vu 0x00000001 /* valid in user mode */ - -#define BAT_V (BAT_Vs|BAT_Vu) - -/* Block Length encoding (all but PowerPC 601): */ -#define BAT_BL_128K 0x00000000 -#define BAT_BL_256K 0x00000004 -#define BAT_BL_512K 0x0000000c -#define BAT_BL_1M 0x0000001c -#define BAT_BL_2M 0x0000003c -#define BAT_BL_4M 0x0000007c -#define BAT_BL_8M 0x000000fc -#define BAT_BL_16M 0x000001fc -#define BAT_BL_32M 0x000003fc -#define BAT_BL_64M 0x000007fc -#define BAT_BL_128M 0x00000ffc -#define BAT_BL_256M 0x00001ffc - -#define BATU(va, len, v) \ - (((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V)) - -#define BATL(pa, wimg, pp) \ - (((pa) & BAT_PBS) | (wimg) | (pp)) - -/* Lower BAT bits (PowerPC 601): */ -#define BAT601_PBN 0xfffe0000 /* physical block number */ -#define BAT601_V 0x00000040 /* valid */ -#define BAT601_BSM 0x0000003f /* block size mask */ - -/* Upper BAT bits (PowerPC 601): */ -#define BAT601_BLPI 0xfffe0000 /* block logical page index */ -#define BAT601_W 0x00000040 /* 1 = write-through, 0 = write-back */ -#define BAT601_I 0x00000020 /* cache inhibit */ -#define BAT601_M 0x00000010 /* memory coherency enable */ -#define BAT601_Ks 0x00000008 /* key-supervisor */ -#define BAT601_Ku 0x00000004 /* key-user */ - -/* - * Permission bits on the PowerPC 601 are modified by the appropriate - * Key bit: - * - * Key PP Access - * 0 NONE read/write - * 0 RO_S read/write - * 0 RW read/write - * 0 RO read-only - * - * 1 NONE none - * 1 RO_S read-only - * 1 RW read/write - * 1 RO read-only - */ -#define BAT601_PP_NONE 0x00000000 /* no access permission */ -#define BAT601_PP_RO_S 0x00000001 /* read-only (soft) */ -#define BAT601_PP_RW 0x00000002 /* read/write */ -#define BAT601_PP_RO 0x00000003 /* read-only */ - -/* Block Size Mask encoding (PowerPC 601): */ -#define BAT601_BSM_128K 0x00000000 -#define BAT601_BSM_256K 0x00000001 -#define BAT601_BSM_512K 0x00000003 -#define BAT601_BSM_1M 0x00000007 -#define BAT601_BSM_2M 0x0000000f -#define BAT601_BSM_4M 0x0000001f -#define BAT601_BSM_8M 0x0000003f - -#define BATU601(va, wim, key, pp) \ - (((va) & BAT601_BLPI) | (wim) | (key) | (pp)) - -#define BATL601(pa, size, v) \ - (((pa) & BAT601_PBN) | (v) | (size)) - -#if defined(_KERNEL) && !defined(LOCORE) -extern struct bat battable[16]; -#endif - -#endif /* _MACHINE_BAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/bus.h b/lib/libc/include/generic-freebsd/machine/bus.h index 9955a93d75eebf2088e39480f6ffc19e7c4b52ac..025c59ba2f2fba0441deaf254e60b905a59101bc 100644 --- a/lib/libc/include/generic-freebsd/machine/bus.h +++ b/lib/libc/include/generic-freebsd/machine/bus.h @@ -1,493 +1,5 @@ -/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ - /*- - * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause - * - * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * This file is in the public domain. */ -/*- - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_BUS_H_ -#define _MACHINE_BUS_H_ - -#include - -#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) - -#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL -#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL -#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL -#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL - -#ifdef __powerpc64__ -#define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL -#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL -#else -#ifdef BOOKE -#define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL -#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL -#else -#define BUS_SPACE_MAXADDR 0xFFFFFFFFUL -#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL -#endif -#endif - -#define BUS_SPACE_MAP_CACHEABLE 0x01 -#define BUS_SPACE_MAP_LINEAR 0x02 -#define BUS_SPACE_MAP_PREFETCHABLE 0x04 - -#define BUS_SPACE_UNRESTRICTED (~0) - -#define BUS_SPACE_BARRIER_READ 0x01 -#define BUS_SPACE_BARRIER_WRITE 0x02 - -struct bus_space_access; - -struct bus_space { - /* mapping/unmapping */ - int (*bs_map)(bus_addr_t, bus_size_t, int, - bus_space_handle_t *); - void (*bs_unmap)(bus_size_t); - int (*bs_subregion)(bus_space_handle_t, bus_size_t, - bus_size_t, bus_space_handle_t *); - - /* allocation/deallocation */ - int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t, - bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *); - void (*bs_free)(bus_space_handle_t, bus_size_t); - - void (*bs_barrier)(bus_space_handle_t, bus_size_t, - bus_size_t, int); - - /* Read single. */ - uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t); - uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t); - uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t); - uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t); - - uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t); - uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t); - uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t); - - /* read multiple */ - void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *, - bus_size_t); - void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *, - bus_size_t); - void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *, - bus_size_t); - void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *, - bus_size_t); - - void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, - bus_size_t); - void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, - bus_size_t); - void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, - bus_size_t); - - /* read region */ - void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *, - bus_size_t); - void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *, - bus_size_t); - void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *, - bus_size_t); - void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *, - bus_size_t); - - void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, - bus_size_t); - void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, - bus_size_t); - void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, - bus_size_t); - - /* write */ - void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t); - void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t); - void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t); - void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t); - - void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t); - void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t); - void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t); - - /* write multiple */ - void (*bs_wm_1)(bus_space_handle_t, bus_size_t, - const uint8_t *, bus_size_t); - void (*bs_wm_2)(bus_space_handle_t, bus_size_t, - const uint16_t *, bus_size_t); - void (*bs_wm_4)(bus_space_handle_t, bus_size_t, - const uint32_t *, bus_size_t); - void (*bs_wm_8)(bus_space_handle_t, bus_size_t, - const uint64_t *, bus_size_t); - - void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t, - const uint16_t *, bus_size_t); - void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t, - const uint32_t *, bus_size_t); - void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t, - const uint64_t *, bus_size_t); - - /* write region */ - void (*bs_wr_1)(bus_space_handle_t, bus_size_t, - const uint8_t *, bus_size_t); - void (*bs_wr_2)(bus_space_handle_t, bus_size_t, - const uint16_t *, bus_size_t); - void (*bs_wr_4)(bus_space_handle_t, bus_size_t, - const uint32_t *, bus_size_t); - void (*bs_wr_8)(bus_space_handle_t, bus_size_t, - const uint64_t *, bus_size_t); - - void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t, - const uint16_t *, bus_size_t); - void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t, - const uint32_t *, bus_size_t); - void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t, - const uint64_t *, bus_size_t); - - /* set multiple */ - void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t, - bus_size_t); - void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t, - bus_size_t); - void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t, - bus_size_t); - void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t, - bus_size_t); - - void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t, - bus_size_t); - void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t, - bus_size_t); - void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t, - bus_size_t); - - /* set region */ - void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t, - bus_size_t); - void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t, - bus_size_t); - void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t, - bus_size_t); - void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t, - bus_size_t); - - void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t, - bus_size_t); - void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t, - bus_size_t); - void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t, - bus_size_t); - - /* copy region */ - void (*bs_cr_1)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - void (*bs_cr_2)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - void (*bs_cr_4)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - void (*bs_cr_8)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - - void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); - void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t, - bus_space_handle_t, bus_size_t, bus_size_t); -}; - -extern struct bus_space bs_be_tag; -extern struct bus_space bs_le_tag; - -#define __bs_c(a,b) __CONCAT(a,b) -#define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) - -#define __bs_rs(sz, t, h, o) \ - (*(t)->__bs_opname(r,sz))(h, o) -#define __bs_ws(sz, t, h, o, v) \ - (*(t)->__bs_opname(w,sz))(h, o, v) -#define __bs_nonsingle(type, sz, t, h, o, a, c) \ - (*(t)->__bs_opname(type,sz))(h, o, a, c) -#define __bs_set(type, sz, t, h, o, v, c) \ - (*(t)->__bs_opname(type,sz))(h, o, v, c) -#define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ - (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt) - -/* - * Mapping and unmapping operations. - */ -#define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp) -#define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s) -#define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp) - -/* - * Allocation and deallocation operations. - */ -#define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ - (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp) -#define bus_space_free(t, h, s) \ - (*(t)->bs_free)(h, s) - -/* - * Bus barrier operations. - */ -#define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f) - -/* - * Bus read (single) operations. - */ -#define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o) -#define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o) -#define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o) -#define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o) - -#define bus_space_read_stream_1 bus_space_read_1 -#define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o) -#define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o) -#define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o) - -/* - * Bus read multiple operations. - */ -#define bus_space_read_multi_1(t, h, o, a, c) \ - __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) -#define bus_space_read_multi_2(t, h, o, a, c) \ - __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) -#define bus_space_read_multi_4(t, h, o, a, c) \ - __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) -#define bus_space_read_multi_8(t, h, o, a, c) \ - __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) - -#define bus_space_read_multi_stream_1 bus_space_read_multi_1 -#define bus_space_read_multi_stream_2(t, h, o, a, c) \ - __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c)) -#define bus_space_read_multi_stream_4(t, h, o, a, c) \ - __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c)) -#define bus_space_read_multi_stream_8(t, h, o, a, c) \ - __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c)) - -/* - * Bus read region operations. - */ -#define bus_space_read_region_1(t, h, o, a, c) \ - __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) -#define bus_space_read_region_2(t, h, o, a, c) \ - __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) -#define bus_space_read_region_4(t, h, o, a, c) \ - __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) -#define bus_space_read_region_8(t, h, o, a, c) \ - __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) - -#define bus_space_read_region_stream_1 bus_space_read_region_1 -#define bus_space_read_region_stream_2(t, h, o, a, c) \ - __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c)) -#define bus_space_read_region_stream_4(t, h, o, a, c) \ - __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c)) -#define bus_space_read_region_stream_8(t, h, o, a, c) \ - __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c)) - -/* - * Bus write (single) operations. - */ -#define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) -#define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) -#define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) -#define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) - -#define bus_space_write_stream_1 bus_space_write_1 -#define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v)) -#define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v)) -#define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v)) - -/* - * Bus write multiple operations. - */ -#define bus_space_write_multi_1(t, h, o, a, c) \ - __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) -#define bus_space_write_multi_2(t, h, o, a, c) \ - __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) -#define bus_space_write_multi_4(t, h, o, a, c) \ - __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) -#define bus_space_write_multi_8(t, h, o, a, c) \ - __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) - -#define bus_space_write_multi_stream_1 bus_space_write_multi_1 -#define bus_space_write_multi_stream_2(t, h, o, a, c) \ - __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c)) -#define bus_space_write_multi_stream_4(t, h, o, a, c) \ - __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c)) -#define bus_space_write_multi_stream_8(t, h, o, a, c) \ - __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c)) - -/* - * Bus write region operations. - */ -#define bus_space_write_region_1(t, h, o, a, c) \ - __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) -#define bus_space_write_region_2(t, h, o, a, c) \ - __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) -#define bus_space_write_region_4(t, h, o, a, c) \ - __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) -#define bus_space_write_region_8(t, h, o, a, c) \ - __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) - -#define bus_space_write_region_stream_1 bus_space_write_region_1 -#define bus_space_write_region_stream_2(t, h, o, a, c) \ - __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c)) -#define bus_space_write_region_stream_4(t, h, o, a, c) \ - __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c)) -#define bus_space_write_region_stream_8(t, h, o, a, c) \ - __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c)) - -/* - * Set multiple operations. - */ -#define bus_space_set_multi_1(t, h, o, v, c) \ - __bs_set(sm,1,(t),(h),(o),(v),(c)) -#define bus_space_set_multi_2(t, h, o, v, c) \ - __bs_set(sm,2,(t),(h),(o),(v),(c)) -#define bus_space_set_multi_4(t, h, o, v, c) \ - __bs_set(sm,4,(t),(h),(o),(v),(c)) -#define bus_space_set_multi_8(t, h, o, v, c) \ - __bs_set(sm,8,(t),(h),(o),(v),(c)) - -#define bus_space_set_multi_stream_1 bus_space_set_multi_1 -#define bus_space_set_multi_stream_2(t, h, o, v, c) \ - __bs_set(sm,s_2,(t),(h),(o),(v),(c)) -#define bus_space_set_multi_stream_4(t, h, o, v, c) \ - __bs_set(sm,s_4,(t),(h),(o),(v),(c)) -#define bus_space_set_multi_stream_8(t, h, o, v, c) \ - __bs_set(sm,s_8,(t),(h),(o),(v),(c)) - -/* - * Set region operations. - */ -#define bus_space_set_region_1(t, h, o, v, c) \ - __bs_set(sr,1,(t),(h),(o),(v),(c)) -#define bus_space_set_region_2(t, h, o, v, c) \ - __bs_set(sr,2,(t),(h),(o),(v),(c)) -#define bus_space_set_region_4(t, h, o, v, c) \ - __bs_set(sr,4,(t),(h),(o),(v),(c)) -#define bus_space_set_region_8(t, h, o, v, c) \ - __bs_set(sr,8,(t),(h),(o),(v),(c)) - -#define bus_space_set_region_stream_1 bus_space_set_region_1 -#define bus_space_set_region_stream_2(t, h, o, v, c) \ - __bs_set(sr,s_2,(t),(h),(o),(v),(c)) -#define bus_space_set_region_stream_4(t, h, o, v, c) \ - __bs_set(sr,s_4,(t),(h),(o),(v),(c)) -#define bus_space_set_region_stream_8(t, h, o, v, c) \ - __bs_set(sr,s_8,(t),(h),(o),(v),(c)) - -#if 0 -/* - * Copy operations. - */ -#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ - __bs_copy(1, t, h1, o1, h2, o2, c) -#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ - __bs_copy(2, t, h1, o1, h2, o2, c) -#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ - __bs_copy(4, t, h1, o1, h2, o2, c) -#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ - __bs_copy(8, t, h1, o1, h2, o2, c) - -#define bus_space_copy_region_stream_1 bus_space_copy_region_1 -#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \ - __bs_copy(s_2, t, h1, o1, h2, o2, c) -#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \ - __bs_copy(s_4, t, h1, o1, h2, o2, c) -#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \ - __bs_copy(s_8, t, h1, o1, h2, o2, c) -#endif - -#define BUS_PEEK_FUNC(width, type) \ - static inline int \ - bus_space_peek_##width(bus_space_tag_t tag, \ - bus_space_handle_t hnd, bus_size_t offset, type *value) \ - { \ - type tmp; \ - tmp = bus_space_read_##width(tag, hnd, offset); \ - *value = (type)tmp; \ - return (0); \ - } -BUS_PEEK_FUNC(1, uint8_t) -BUS_PEEK_FUNC(2, uint16_t) -BUS_PEEK_FUNC(4, uint32_t) -BUS_PEEK_FUNC(8, uint64_t) - -#define BUS_POKE_FUNC(width, type) \ - static inline int \ - bus_space_poke_##width(bus_space_tag_t tag, \ - bus_space_handle_t hnd, bus_size_t offset, type value) \ - { \ - bus_space_write_##width(tag, hnd, offset, value); \ - return (0); \ - } -BUS_POKE_FUNC(1, uint8_t) -BUS_POKE_FUNC(2, uint16_t) -BUS_POKE_FUNC(4, uint32_t) -BUS_POKE_FUNC(8, uint64_t) - -#include - -#endif /* _MACHINE_BUS_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/bus_dma.h b/lib/libc/include/generic-freebsd/machine/bus_dma.h deleted file mode 100644 index 0f66234aeb045ddc37e15ed76b32b7e3d453ad3d..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/bus_dma.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2005 Scott Long - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _POWERPC_BUS_DMA_H_ -#define _POWERPC_BUS_DMA_H_ - -#include -#include - -int bus_dma_tag_set_iommu(bus_dma_tag_t, device_t iommu, void *cookie); - -#endif /* _POWERPC_BUS_DMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/clock.h b/lib/libc/include/generic-freebsd/machine/clock.h index 9998037028b5bdf81d77188d6ac564acf81c3c80..838e4abd59164efa7f0ef931839aed473eace111 100644 --- a/lib/libc/include/generic-freebsd/machine/clock.h +++ b/lib/libc/include/generic-freebsd/machine/clock.h @@ -1,18 +1,5 @@ -/*- - * Kernel interface to machine-dependent clock driver. - * Garrett Wollman, September 1994. +/* * This file is in the public domain. */ -#ifndef _MACHINE_CLOCK_H_ -#define _MACHINE_CLOCK_H_ - -#ifdef _KERNEL - -struct trapframe; - -void decr_intr(struct trapframe *); - -#endif - -#endif /* !_MACHINE_CLOCK_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/counter.h b/lib/libc/include/generic-freebsd/machine/counter.h deleted file mode 100644 index 18618faf6cd4f1a50d62fa09c1b2bcc04e02ec29..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/counter.h +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2012, 2013 Konstantin Belousov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __MACHINE_COUNTER_H__ -#define __MACHINE_COUNTER_H__ - -#include -#ifdef INVARIANTS -#include -#endif - -#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter - -#ifdef __powerpc64__ - -#define counter_enter() do {} while (0) -#define counter_exit() do {} while (0) - -#ifdef IN_SUBR_COUNTER_C -static inline uint64_t -counter_u64_read_one(uint64_t *p, int cpu) -{ - - return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); -} - -static inline uint64_t -counter_u64_fetch_inline(uint64_t *p) -{ - uint64_t r; - int i; - - r = 0; - CPU_FOREACH(i) - r += counter_u64_read_one((uint64_t *)p, i); - - return (r); -} - -static void -counter_u64_zero_one_cpu(void *arg) -{ - - *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * - PCPU_GET(cpuid))) = 0; -} - -static inline void -counter_u64_zero_inline(counter_u64_t c) -{ - - smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu, - smp_no_rendezvous_barrier, c); -} -#endif - -#define counter_u64_add_protected(c, i) counter_u64_add(c, i) - -static inline void -counter_u64_add(counter_u64_t c, int64_t inc) -{ - uint64_t ccpu, old; - - __asm __volatile("\n" - "1:\n\t" - "mfsprg %0, 0\n\t" - "ldarx %1, %0, %2\n\t" - "add %1, %1, %3\n\t" - "stdcx. %1, %0, %2\n\t" - "bne- 1b" - : "=&b" (ccpu), "=&r" (old) - : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc) - : "cr0", "memory"); -} - -#else /* !64bit */ - -#define counter_enter() critical_enter() -#define counter_exit() critical_exit() - -#ifdef IN_SUBR_COUNTER_C -/* XXXKIB non-atomic 64bit read */ -static inline uint64_t -counter_u64_read_one(uint64_t *p, int cpu) -{ - - return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); -} - -static inline uint64_t -counter_u64_fetch_inline(uint64_t *p) -{ - uint64_t r; - int i; - - r = 0; - for (i = 0; i < mp_ncpus; i++) - r += counter_u64_read_one((uint64_t *)p, i); - - return (r); -} - -/* XXXKIB non-atomic 64bit store, might interrupt increment */ -static void -counter_u64_zero_one_cpu(void *arg) -{ - - *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * - PCPU_GET(cpuid))) = 0; -} - -static inline void -counter_u64_zero_inline(counter_u64_t c) -{ - - smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu, - smp_no_rendezvous_barrier, c); -} -#endif - -#define counter_u64_add_protected(c, inc) do { \ - CRITICAL_ASSERT(curthread); \ - *(uint64_t *)zpcpu_get(c) += (inc); \ -} while (0) - -static inline void -counter_u64_add(counter_u64_t c, int64_t inc) -{ - - counter_enter(); - counter_u64_add_protected(c, inc); - counter_exit(); -} - -#endif /* 64bit */ - -#endif /* ! __MACHINE_COUNTER_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/cpu.h b/lib/libc/include/generic-freebsd/machine/cpu.h deleted file mode 100644 index 2442a9207380ec69adbd3a8f0d6581c7ea9039dd..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/cpu.h +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995-1997 Wolfgang Solfrank. - * Copyright (C) 1995-1997 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ - */ - -#ifndef _MACHINE_CPU_H_ -#define _MACHINE_CPU_H_ - -#include -#include -#include - -/* - * CPU Feature Attributes - * - * These are defined in the PowerPC ELF ABI for the AT_HWCAP vector, - * and are exported to userland via the machdep.cpu_features - * sysctl. - */ - -extern u_long cpu_features; -extern u_long cpu_features2; - -#define PPC_FEATURE_32 0x80000000 /* Always true */ -#define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */ -#define PPC_FEATURE_601_INSTR 0x20000000 /* Defined on a 64-bit CPU */ -#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 -#define PPC_FEATURE_HAS_FPU 0x08000000 -#define PPC_FEATURE_HAS_MMU 0x04000000 -#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 -#define PPC_FEATURE_HAS_SPE 0x00800000 -#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 -#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 -#define PPC_FEATURE_NO_TB 0x00100000 -#define PPC_FEATURE_POWER4 0x00080000 -#define PPC_FEATURE_POWER5 0x00040000 -#define PPC_FEATURE_POWER5_PLUS 0x00020000 -#define PPC_FEATURE_CELL 0x00010000 -#define PPC_FEATURE_BOOKE 0x00008000 -#define PPC_FEATURE_SMT 0x00004000 -#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 -#define PPC_FEATURE_ARCH_2_05 0x00001000 -#define PPC_FEATURE_HAS_DFP 0x00000400 -#define PPC_FEATURE_POWER6_EXT 0x00000200 -#define PPC_FEATURE_ARCH_2_06 0x00000100 -#define PPC_FEATURE_HAS_VSX 0x00000080 -#define PPC_FEATURE_TRUE_LE 0x00000002 -#define PPC_FEATURE_PPC_LE 0x00000001 - -#define PPC_FEATURE2_ARCH_2_07 0x80000000 -#define PPC_FEATURE2_HTM 0x40000000 -#define PPC_FEATURE2_DSCR 0x20000000 -#define PPC_FEATURE2_EBB 0x10000000 -#define PPC_FEATURE2_ISEL 0x08000000 -#define PPC_FEATURE2_TAR 0x04000000 -#define PPC_FEATURE2_HAS_VEC_CRYPTO 0x02000000 -#define PPC_FEATURE2_HTM_NOSC 0x01000000 -#define PPC_FEATURE2_ARCH_3_00 0x00800000 -#define PPC_FEATURE2_HAS_IEEE128 0x00400000 -#define PPC_FEATURE2_DARN 0x00200000 -#define PPC_FEATURE2_SCV 0x00100000 -#define PPC_FEATURE2_HTM_NOSUSPEND 0x00080000 -#define PPC_FEATURE2_ARCH_3_1 0x00040000 -#define PPC_FEATURE2_MMA 0x00020000 - -#define PPC_FEATURE_BITMASK \ - "\20" \ - "\040PPC32\037PPC64\036PPC601\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" \ - "\030SPE\027SPESFP\026DPESFP\025NOTB\024POWER4\023POWER5\022P5PLUS\021CELL"\ - "\020BOOKE\017SMT\016ISNOOP\015ARCH205\013DFP\011ARCH206\010VSX"\ - "\002TRUELE\001PPCLE" -#define PPC_FEATURE2_BITMASK \ - "\20" \ - "\040ARCH207\037HTM\036DSCR\034ISEL\033TAR\032VCRYPTO\031HTMNOSC" \ - "\030ARCH300\027IEEE128\026DARN\025SCV\024HTMNOSUSP" - -#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) -#define TRAPF_PC(frame) ((frame)->srr0) - -/* - * CTL_MACHDEP definitions. - */ -#define CPU_CACHELINE 1 - -static __inline u_int64_t -get_cyclecount(void) -{ - u_int32_t _upper, _lower; - u_int64_t _time; - - __asm __volatile( - "mftb %0\n" - "mftbu %1" - : "=r" (_lower), "=r" (_upper)); - - _time = (u_int64_t)_upper; - _time = (_time << 32) + _lower; - return (_time); -} - -#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) -#define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */ -#define cpu_lock_delay() DELAY(1) - -extern char btext[]; -extern char etext[]; - -struct thread; - -#ifdef __powerpc64__ -extern void enter_idle_powerx(void); -extern uint64_t can_wakeup; -extern register_t lpcr; -#endif - -void cpu_halt(void); -void cpu_reset(void); -void flush_disable_caches(void); -void fork_trampoline(void); -int cpu_machine_check(struct thread *, struct trapframe *, int *); - - -#ifndef __powerpc64__ -void mpc745x_sleep(void); -#endif - -#endif /* _MACHINE_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/cpufunc.h b/lib/libc/include/generic-freebsd/machine/cpufunc.h deleted file mode 100644 index 633899d5546d7e49da785eb843e3b1ad6c05f6e6..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/cpufunc.h +++ /dev/null @@ -1,298 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_CPUFUNC_H_ -#define _MACHINE_CPUFUNC_H_ - -#ifdef _KERNEL - -#include - -#include -#include - -struct thread; - -#ifdef KDB -void breakpoint(void); -#else -static __inline void -breakpoint(void) -{ - - return; -} -#endif - -/* CPU register mangling inlines */ - -static __inline void -mtmsr(register_t value) -{ - - __asm __volatile ("mtmsr %0; isync" :: "r"(value)); -} - -#ifdef __powerpc64__ -static __inline void -mtmsrd(register_t value) -{ - - __asm __volatile ("mtmsrd %0; isync" :: "r"(value)); -} -#endif - -static __inline register_t -mfmsr(void) -{ - register_t value; - - __asm __volatile ("mfmsr %0" : "=r"(value)); - - return (value); -} - -#ifndef __powerpc64__ -static __inline void -mtsrin(vm_offset_t va, register_t value) -{ - - __asm __volatile ("mtsrin %0,%1; isync" :: "r"(value), "r"(va)); -} - -static __inline register_t -mfsrin(vm_offset_t va) -{ - register_t value; - - __asm __volatile ("mfsrin %0,%1" : "=r"(value) : "r"(va)); - - return (value); -} -#endif - -static __inline register_t -mfctrl(void) -{ - register_t value; - - __asm __volatile ("mfspr %0,136" : "=r"(value)); - - return (value); -} - -static __inline void -mtdec(register_t value) -{ - - __asm __volatile ("mtdec %0" :: "r"(value)); -} - -static __inline register_t -mfdec(void) -{ - register_t value; - - __asm __volatile ("mfdec %0" : "=r"(value)); - - return (value); -} - -static __inline uint32_t -mfpvr(void) -{ - uint32_t value; - - __asm __volatile ("mfpvr %0" : "=r"(value)); - - return (value); -} - -static __inline u_quad_t -mftb(void) -{ - u_quad_t tb; - #ifdef __powerpc64__ - __asm __volatile ("mftb %0" : "=r"(tb)); - #else - uint32_t *tbup = (uint32_t *)&tb; - uint32_t *tblp = tbup + 1; - - do { - *tbup = mfspr(TBR_TBU); - *tblp = mfspr(TBR_TBL); - } while (*tbup != mfspr(TBR_TBU)); - #endif - - return (tb); -} - -static __inline void -mttb(u_quad_t time) -{ - - mtspr(TBR_TBWL, 0); - mtspr(TBR_TBWU, (uint32_t)(time >> 32)); - mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff)); -} - -static __inline register_t -mffs(void) -{ - uint64_t value; - - __asm __volatile ("mffs 0; stfd 0,0(%0)" - :: "b"(&value)); - - return ((register_t)value); -} - -static __inline void -mtfsf(uint64_t value) -{ - - __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0" - :: "b"(&value)); -} - -static __inline void -eieio(void) -{ - - __asm __volatile ("eieio" : : : "memory"); -} - -static __inline void -isync(void) -{ - - __asm __volatile ("isync" : : : "memory"); -} - -static __inline void -powerpc_sync(void) -{ - - __asm __volatile ("sync" : : : "memory"); -} - -static __inline int -cntlzd(uint64_t word) -{ - uint64_t result; - /* cntlzd %0, %1 */ - __asm __volatile(".long 0x7c000074 | (%1 << 21) | (%0 << 16)" : - "=r"(result) : "r"(word)); - - return (int)result; -} - -static __inline int -cnttzd(uint64_t word) -{ - uint64_t result; - /* cnttzd %0, %1 */ - __asm __volatile(".long 0x7c000474 | (%1 << 21) | (%0 << 16)" : - "=r"(result) : "r"(word)); - - return (int)result; -} - -static __inline void -ptesync(void) -{ - __asm __volatile("ptesync"); -} - -static __inline register_t -intr_disable(void) -{ - register_t msr; - - msr = mfmsr(); - mtmsr(msr & ~PSL_EE); - return (msr); -} - -static __inline void -intr_restore(register_t msr) -{ - - mtmsr(msr); -} - -static __inline struct pcpu * -get_pcpu(void) -{ - struct pcpu *ret; - - __asm __volatile("mfsprg %0, 0" : "=r"(ret)); - - return (ret); -} - -/* "NOP" operations to signify priorities to the kernel. */ -static __inline void -nop_prio_vlow(void) -{ - __asm __volatile("or 31,31,31"); -} - -static __inline void -nop_prio_low(void) -{ - __asm __volatile("or 1,1,1"); -} - -static __inline void -nop_prio_mlow(void) -{ - __asm __volatile("or 6,6,6"); -} - -static __inline void -nop_prio_medium(void) -{ - __asm __volatile("or 2,2,2"); -} - -static __inline void -nop_prio_mhigh(void) -{ - __asm __volatile("or 5,5,5"); -} - -static __inline void -nop_prio_high(void) -{ - __asm __volatile("or 3,3,3"); -} - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_CPUFUNC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/db_machdep.h b/lib/libc/include/generic-freebsd/machine/db_machdep.h deleted file mode 100644 index 6707b3bb7420ab80439818ce5f229bdbce436996..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/db_machdep.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ - * $NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $ - */ - -/* - * Machine-dependent defines for new kernel debugger. - */ -#ifndef _POWERPC_DB_MACHDEP_H_ -#define _POWERPC_DB_MACHDEP_H_ - -#include -#include - -#define DB_ELF_SYMBOLS -#define DB_ELFSIZE __ELF_WORD_SIZE - -typedef vm_offset_t db_addr_t; /* address - unsigned */ -typedef intptr_t db_expr_t; /* expression - signed */ - -#define PC_REGS(regs) ((db_addr_t)kdb_thrctx->pcb_lr) - -#define BKPT_INST 0x7C810808 /* breakpoint instruction */ - -#define BKPT_SIZE (4) /* size of breakpoint inst */ -#define BKPT_SET(inst) (BKPT_INST) - -#define db_clear_single_step kdb_cpu_clear_singlestep -#define db_set_single_step kdb_cpu_set_singlestep - -#if 0 -#define SR_SINGLESTEP 0x400 -#define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP) -#define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP) -#endif - -#define T_BREAKPOINT 0xffff -#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) - -#define T_WATCHPOINT 0xeeee -#ifdef T_WATCHPOINT -#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) -#else -#define IS_WATCHPOINT_TRAP(type, code) 0 -#endif - -#define M_RTS 0xfc0007fe -#define I_RTS 0x4c000020 -#define M_BC 0xfc000000 -#define I_BC 0x40000000 -#define M_B 0xfc000000 -#define I_B 0x50000000 -#define M_RFI 0xfc0007fe -#define I_RFI 0x4c000064 - -#define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI) -#define inst_return(ins) (((ins)&M_RTS) == I_RTS) -#define inst_call(ins) (((ins)&M_BC ) == I_BC || \ - ((ins)&M_B ) == I_B ) -#define inst_load(ins) 0 -#define inst_store(ins) 0 - -#endif /* _POWERPC_DB_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/dbdma.h b/lib/libc/include/generic-freebsd/machine/dbdma.h deleted file mode 100644 index c04ae1ba80e89e545635906aa658079ccddf953e..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/dbdma.h +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2008 Nathan Whitehorn - * All rights reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_DBDMA_H_ -#define _MACHINE_DBDMA_H_ - -#include -#include - -/* - * Apple's DBDMA (Descriptor-based DMA) interface is a common DMA engine - * used by a variety of custom Apple ASICs. It is described in the CHRP - * specification and in the book Macintosh Technology in the Common - * Hardware Reference Platform, copyright 1995 Apple Computer. - */ - -/* DBDMA Command Values */ - -enum { - DBDMA_OUTPUT_MORE = 0, - DBDMA_OUTPUT_LAST = 1, - DBDMA_INPUT_MORE = 2, - DBDMA_INPUT_LAST = 3, - - DBDMA_STORE_QUAD = 4, - DBDMA_LOAD_QUAD = 5, - DBDMA_NOP = 6, - DBDMA_STOP = 7 -}; - -/* These codes are for the interrupt, branch, and wait flags */ - -enum { - DBDMA_NEVER = 0, - DBDMA_COND_TRUE = 1, - DBDMA_COND_FALSE = 2, - DBDMA_ALWAYS = 3 -}; - -/* Channel status bits */ -#define DBDMA_STATUS_RUN (0x01 << 15) -#define DBDMA_STATUS_PAUSE (0x01 << 14) -#define DBDMA_STATUS_FLUSH (0x01 << 13) -#define DBDMA_STATUS_WAKE (0x01 << 12) -#define DBDMA_STATUS_DEAD (0x01 << 11) -#define DBDMA_STATUS_ACTIVE (0x01 << 10) - -/* Set by hardware if a branch was taken */ -#define DBDMA_STATUS_BRANCH 8 - -struct dbdma_command; -typedef struct dbdma_command dbdma_command_t; -struct dbdma_channel; -typedef struct dbdma_channel dbdma_channel_t; - -int dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset, - bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan); - -int dbdma_resize_channel(dbdma_channel_t *chan, int newslots); -int dbdma_free_channel(dbdma_channel_t *chan); - -void dbdma_run(dbdma_channel_t *chan); -void dbdma_stop(dbdma_channel_t *chan); -void dbdma_reset(dbdma_channel_t *chan); -void dbdma_set_current_cmd(dbdma_channel_t *chan, int slot); - -void dbdma_pause(dbdma_channel_t *chan); -void dbdma_wake(dbdma_channel_t *chan); - -/* - * DBDMA uses a 16 bit channel control register to describe the current - * state of DMA on the channel. The high-order bits (8-15) contain information - * on the run state and are listed in the DBDMA_STATUS_* constants above. These - * are manipulated with the dbdma_run/stop/reset() routines above. - * - * The low order bits (0-7) are device dependent status bits. These can be set - * and read by both hardware and software. The mask is the set of bits to - * modify; if mask is 0x03 and value is 0, the lowest order 2 bits will be - * zeroed. - */ - -uint16_t dbdma_get_chan_status(dbdma_channel_t *chan); - -uint8_t dbdma_get_device_status(dbdma_channel_t *chan); -void dbdma_set_device_status(dbdma_channel_t *chan, uint8_t mask, - uint8_t value); - -/* - * Each DBDMA command word has the current channel status register and the - * number of residual bytes (requested - actually transferred) written to it - * at time of command completion. - */ - -uint16_t dbdma_get_cmd_status(dbdma_channel_t *chan, int slot); -uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot); - -void dbdma_clear_cmd_status(dbdma_channel_t *chan, int slot); - -/* - * The interrupt/branch/wait selector let you specify a set of values - * of the device dependent status bits that will cause intterupt/branch/wait - * conditions to be taken if the flags for these are set to one of the - * DBDMA_COND_* values. - * - * The condition is considered true if (status & mask) == value. - */ - -void dbdma_set_interrupt_selector(dbdma_channel_t *chan, uint8_t mask, - uint8_t value); -void dbdma_set_branch_selector(dbdma_channel_t *chan, uint8_t mask, - uint8_t value); -void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask, - uint8_t value); - -void dbdma_insert_command(dbdma_channel_t *chan, int slot, int command, - int stream, bus_addr_t data, size_t count, uint8_t interrupt, - uint8_t branch, uint8_t wait, uint32_t branch_slot); - -void dbdma_insert_stop(dbdma_channel_t *chan, int slot); -void dbdma_insert_nop(dbdma_channel_t *chan, int slot); -void dbdma_insert_branch(dbdma_channel_t *chan, int slot, int to_slot); - -void dbdma_sync_commands(dbdma_channel_t *chan, bus_dmasync_op_t op); - -void dbdma_save_state(dbdma_channel_t *chan); -void dbdma_restore_state(dbdma_channel_t *chan); - -#endif /* _MACHINE_DBDMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/dump.h b/lib/libc/include/generic-freebsd/machine/dump.h index 68051ae782c057dd79bfaf99b8daa41c71828144..cf91d4b47952976f754ec6c400c30433a5ed7207 100644 --- a/lib/libc/include/generic-freebsd/machine/dump.h +++ b/lib/libc/include/generic-freebsd/machine/dump.h @@ -1,73 +1,5 @@ /*- - * Copyright (c) 2014 EMC Corp. - * Author: Conrad Meyer - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_DUMP_H_ -#define _MACHINE_DUMP_H_ - -#define KERNELDUMP_ARCH_VERSION KERNELDUMP_POWERPC_VERSION -#define EM_VALUE ELF_ARCH /* Defined in powerpc/include/elf.h */ -#define DUMPSYS_MD_PA_NPAIRS (PHYS_AVAIL_SZ + 1) -#define DUMPSYS_NUM_AUX_HDRS 0 - -/* How often to check the dump progress bar? */ -#define DUMPSYS_PB_CHECK_BITS 20 /* Every 1MB */ - -void dumpsys_pa_init(void); -void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *); -size_t dumpsys_scan_pmap(struct bitset *); -void *dumpsys_dump_pmap_init(unsigned blkpgs); -void *dumpsys_dump_pmap(void *ctx, void *buf, u_long *nbytes); - -static inline struct dump_pa * -dumpsys_pa_next(struct dump_pa *p) -{ - - return (dumpsys_gen_pa_next(p)); -} - -static inline void -dumpsys_wbinv_all(void) -{ - - dumpsys_gen_wbinv_all(); -} - -static inline int -dumpsys_write_aux_headers(struct dumperinfo *di) -{ - - return (dumpsys_gen_write_aux_headers(di)); -} - -static inline int -dumpsys(struct dumperinfo *di) -{ - - return (dumpsys_generic(di)); -} - -#endif /* !_MACHINE_DUMP_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/efi.h b/lib/libc/include/generic-freebsd/machine/efi.h deleted file mode 100644 index 13f09c46613f07898a6266d2cfdde5bfef0f3ef3..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/efi.h +++ /dev/null @@ -1,12 +0,0 @@ -/*- - * This file is in the public domain since it's just boilerplate. - */ - -#ifndef __POWERPC_INCLUDE_EFI_H_ -#define __POWERPC_INCLUDE_EFI_H_ - -#define EFIABI_ATTR - -/* Note: we don't actually support this on powerpc */ - -#endif /* __POWERPC_INCLUDE_EFI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/elf.h b/lib/libc/include/generic-freebsd/machine/elf.h index b643c6592160dc9a5c21a62788a16a93a41d358b..36a7ae1abaaddc874cebe8843e66d7d68e6d97ee 100644 --- a/lib/libc/include/generic-freebsd/machine/elf.h +++ b/lib/libc/include/generic-freebsd/machine/elf.h @@ -1,146 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 David E. O'Brien - * Copyright (c) 1996-1997 John D. Polstra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_ELF_H_ -#define _MACHINE_ELF_H_ 1 - -/* - * EABI ELF definitions for the PowerPC architecture. - * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation" - * [ppc-eabi-1995-01.pdf] for details. - */ - -#ifndef __ELF_WORD_SIZE -#ifdef __powerpc64__ -#define __ELF_WORD_SIZE 64 /* Used by */ -#else -#define __ELF_WORD_SIZE 32 /* Used by */ -#endif -#endif - -#include /* Definitions common to all 32 bit architectures. */ -#include /* Definitions common to all 64 bit architectures. */ -#include - -#if __ELF_WORD_SIZE == 64 -#define ELF_ARCH EM_PPC64 -#define ELF_MACHINE_OK(x) ((x) == EM_PPC64) -#else -#define ELF_ARCH EM_PPC -#define ELF_ARCH32 EM_PPC -#define ELF_MACHINE_OK(x) ((x) == EM_PPC) -#endif - -/* - * Auxiliary vector entries for passing information to the interpreter. - * - * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t", - * but POSIX lays claim to all symbols ending with "_t". - */ - -typedef struct { /* Auxiliary vector entry on initial stack */ - int a_type; /* Entry type. */ - union { -#ifdef __powerpc64__ - int a_val; /* Integer value */ -#else - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ -#endif - } a_un; -} Elf32_Auxinfo; - -typedef struct { /* Auxiliary vector entry on initial stack */ - long a_type; /* Entry type. */ - union { - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ - } a_un; -} Elf64_Auxinfo; - -__ElfType(Auxinfo); - -/* - * Relocation types. - */ - -#define R_PPC_COUNT 37 /* Count of defined relocation types. */ - - /* Count of defined relocation types. */ -#define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1) - -/* Define "machine" characteristics */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define ELF_TARG_DATA ELFDATA2LSB -#else -#define ELF_TARG_DATA ELFDATA2MSB -#endif -#if __ELF_WORD_SIZE == 64 -#define ELF_TARG_CLASS ELFCLASS64 -#define ELF_TARG_MACH EM_PPC64 -#define ELF_TARG_VER 1 -#else -#define ELF_TARG_CLASS ELFCLASS32 -#define ELF_TARG_MACH EM_PPC -#define ELF_TARG_VER 1 -#endif - -#define ET_DYN_LOAD_ADDR 0x01010000 - -#define AT_OLD_NULL AT_NULL -#define AT_OLD_IGNORE AT_IGNORE -#define AT_OLD_EXECFD AT_EXECFD -#define AT_OLD_PHDR AT_PHDR -#define AT_OLD_PHENT AT_PHENT -#define AT_OLD_PHNUM AT_PHNUM -#define AT_OLD_PAGESZ AT_PAGESZ -#define AT_OLD_BASE AT_BASE -#define AT_OLD_FLAGS AT_FLAGS -#define AT_OLD_ENTRY AT_ENTRY -#define AT_OLD_NOTELF AT_NOTELF -#define AT_OLD_UID AT_UID -#define AT_OLD_EUID AT_EUID -#define AT_OLD_EXECPATH 13 -#define AT_OLD_CANARY 14 -#define AT_OLD_CANARYLEN 15 -#define AT_OLD_OSRELDATE 16 -#define AT_OLD_NCPUS 17 -#define AT_OLD_PAGESIZES 18 -#define AT_OLD_PAGESIZESLEN 19 -#define AT_OLD_STACKPROT 21 -#define AT_OLD_TIMEKEEP AT_TIMEKEEP -#define AT_OLD_EHDRFLAGS AT_EHDRFLAGS -#define AT_OLD_HWCAP AT_HWCAP -#define AT_OLD_HWCAP2 AT_HWCAP2 - -#define AT_OLD_COUNT 27 /* Count of defined aux entry types. */ - -#endif /* !_MACHINE_ELF_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/endian.h b/lib/libc/include/generic-freebsd/machine/endian.h index cee6814d10bf61f6fcd6016ae9f1eba66fb39d00..02be261a3b8025118a48fffd3c5b56be6f2aa0f3 100644 --- a/lib/libc/include/generic-freebsd/machine/endian.h +++ b/lib/libc/include/generic-freebsd/machine/endian.h @@ -1,40 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1987, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)endian.h 8.1 (Berkeley) 6/10/93 + * This file is in the public domain. */ -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#include -#include - -#endif /* !_MACHINE_ENDIAN_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/exec.h b/lib/libc/include/generic-freebsd/machine/exec.h index 8a2c6bd93612eab956558a8e7d56c3243c4edf7a..22a48bd0f8eda9ddbdbad816a83e58dbcbb8c77c 100644 --- a/lib/libc/include/generic-freebsd/machine/exec.h +++ b/lib/libc/include/generic-freebsd/machine/exec.h @@ -1,8 +1,8 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2001 David E. O'Brien - * All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,11 +12,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of any co-contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE diff --git a/lib/libc/include/generic-freebsd/machine/float.h b/lib/libc/include/generic-freebsd/machine/float.h index a39a98229f7704483df10d942ca04f9610fc5660..0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff 100644 --- a/lib/libc/include/generic-freebsd/machine/float.h +++ b/lib/libc/include/generic-freebsd/machine/float.h @@ -1,100 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 - * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 + * This file is in the public domain. */ -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ 1 - -#include - -#ifndef _SOFT_FLOAT -__BEGIN_DECLS -extern int __flt_rounds(void); -__END_DECLS -#define FLT_ROUNDS __flt_rounds() -#else -#define FLT_ROUNDS (-1) -#endif - -#define FLT_RADIX 2 /* b */ -#if __ISO_C_VISIBLE >= 1999 -#define FLT_EVAL_METHOD 0 -#define DECIMAL_DIG 17 /* max precision in decimal digits */ -#endif - -#define FLT_MANT_DIG 24 /* p */ -#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ -#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ -#define FLT_MIN_EXP (-125) /* emin */ -#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ -#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ -#define FLT_MAX_EXP 128 /* emax */ -#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ -#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ -#if __ISO_C_VISIBLE >= 2011 -#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */ -#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */ -#define FLT_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define DBL_MANT_DIG 53 -#define DBL_EPSILON 2.2204460492503131E-16 -#define DBL_DIG 15 -#define DBL_MIN_EXP (-1021) -#define DBL_MIN 2.2250738585072014E-308 -#define DBL_MIN_10_EXP (-307) -#define DBL_MAX_EXP 1024 -#define DBL_MAX 1.7976931348623157E+308 -#define DBL_MAX_10_EXP 308 -#if __ISO_C_VISIBLE >= 2011 -#define DBL_TRUE_MIN 4.9406564584124654E-324 -#define DBL_DECIMAL_DIG 17 -#define DBL_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define LDBL_MANT_DIG DBL_MANT_DIG -#define LDBL_EPSILON ((long double)DBL_EPSILON) -#define LDBL_DIG DBL_DIG -#define LDBL_MIN_EXP DBL_MIN_EXP -#define LDBL_MIN ((long double)DBL_MIN) -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP -#define LDBL_MAX_EXP DBL_MAX_EXP -#define LDBL_MAX ((long double)DBL_MAX) -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP -#if __ISO_C_VISIBLE >= 2011 -#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN) -#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG -#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#endif /* _MACHINE_FLOAT_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/floatingpoint.h b/lib/libc/include/generic-freebsd/machine/floatingpoint.h index d2c7e15ad2e8ae4c8fff302ee2365f352fd05c79..e05bc6f49c01b58a31ef2055a4e9103338a3b56d 100644 --- a/lib/libc/include/generic-freebsd/machine/floatingpoint.h +++ b/lib/libc/include/generic-freebsd/machine/floatingpoint.h @@ -1,7 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause + * SPDX-License-Identifier: BSD-4-Clause * - * Copyright (c) 2004 Suleiman Souhlal + * Copyright (c) 1993 Andrew Moore, Talke Studio * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,11 +12,15 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of any co-contributors + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE @@ -32,6 +36,7 @@ #ifndef _FLOATINGPOINT_H_ #define _FLOATINGPOINT_H_ +#include #include #endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/fpu.h b/lib/libc/include/generic-freebsd/machine/fpu.h deleted file mode 100644 index a291b1817afe567d1db46d1196d95a51c549250f..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/fpu.h +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1996 Wolfgang Solfrank. - * Copyright (C) 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: fpu.h,v 1.2 1999/12/07 15:14:56 danw Exp $ - */ - -#ifndef _MACHINE_FPU_H_ -#define _MACHINE_FPU_H_ - -#define FPSCR_FX 0x80000000 -#define FPSCR_FEX 0x40000000 -#define FPSCR_VX 0x20000000 -#define FPSCR_OX 0x10000000 -#define FPSCR_UX 0x08000000 -#define FPSCR_ZX 0x04000000 -#define FPSCR_XX 0x02000000 -#define FPSCR_VXSNAN 0x01000000 -#define FPSCR_VXISI 0x00800000 -#define FPSCR_VXIDI 0x00400000 -#define FPSCR_VXZDZ 0x00200000 -#define FPSCR_VXIMZ 0x00100000 -#define FPSCR_VXVC 0x00080000 -#define FPSCR_FR 0x00040000 -#define FPSCR_FI 0x00020000 -#define FPSCR_FPRF 0x0001f000 -#define FPSCR_C 0x00010000 -#define FPSCR_FPCC 0x0000f000 -#define FPSCR_FL 0x00008000 -#define FPSCR_FG 0x00004000 -#define FPSCR_FE 0x00002000 -#define FPSCR_FU 0x00001000 -#define FPSCR_VXSOFT 0x00000400 -#define FPSCR_VXSQRT 0x00000200 -#define FPSCR_VXCVI 0x00000100 -#define FPSCR_VE 0x00000080 -#define FPSCR_OE 0x00000040 -#define FPSCR_UE 0x00000020 -#define FPSCR_ZE 0x00000010 -#define FPSCR_XE 0x00000008 -#define FPSCR_NI 0x00000004 -#define FPSCR_RN 0x00000003 - -#ifdef _KERNEL - -void enable_fpu(struct thread *); -void save_fpu(struct thread *); -void save_fpu_nodrop(struct thread *); -void cleanup_fpscr(void); -u_int get_fpu_exception(struct thread *); -void enable_fpu_kern(void); -void disable_fpu(struct thread *td); - -/* - * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). - */ -#define FPU_KERN_NORMAL 0x0000 -#define FPU_KERN_NOWAIT 0x0001 -#define FPU_KERN_KTHR 0x0002 -#define FPU_KERN_NOCTX 0x0004 - -struct fpu_kern_ctx; - -struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); -void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); -void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, - u_int flags); -int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); -int fpu_kern_thread(u_int flags); -int is_fpu_kern_thread(u_int flags); - -#endif /* _KERNEL */ - -#endif /* _MACHINE_FPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/frame.h b/lib/libc/include/generic-freebsd/machine/frame.h deleted file mode 100644 index 01008712c3ce395601cac770bc777461afc6dc3f..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/frame.h +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $ - */ - -#ifndef _MACHINE_FRAME_H_ -#define _MACHINE_FRAME_H_ - -#include - -/* - * We have to save all registers on every trap, because - * 1. user could attach this process every time - * 2. we must be able to restore all user registers in case of fork - * Actually, we do not save the fp registers on trap, since - * these are not used by the kernel. They are saved only when switching - * between processes using the FPU. - * - * Change ordering to cluster together these register_t's. XXX - */ -struct trapframe { - register_t fixreg[32]; - register_t lr; - register_t cr; - register_t xer; - register_t ctr; - register_t srr0; - register_t srr1; - register_t exc; - register_t dar; /* DAR/DEAR filled in on DSI traps */ - union { - struct { - /* dsisr only filled on a DSI trap */ - register_t dsisr; - } aim; - struct { - register_t esr; - register_t dbcr0; - } booke; - } cpu; -}; - -/* - * FRAMELEN is the size of the stack region used by the low-level trap - * handler. It is the size of its data (trapframe) plus the callframe - * header (sizeof(struct callframe) - 3 register widths). It must also - * be 16-byte aligned. - */ -#define FRAMELEN roundup(sizeof(struct trapframe) + \ - sizeof(struct callframe) - 3*sizeof(register_t), 16) -#define trapframe(td) ((td)->td_frame) - -/* - * Call frame for PowerPC used during fork. - */ -#ifdef __powerpc64__ -struct callframe { - register_t cf_dummy_fp; /* dummy frame pointer */ - register_t cf_cr; - register_t cf_lr; - register_t cf_compiler; - register_t cf_linkeditor; - register_t cf_toc; - register_t cf_func; - register_t cf_arg0; - register_t cf_arg1; - register_t _padding; /* Maintain 16-byte alignment */ -}; -#else -struct callframe { - register_t cf_dummy_fp; /* dummy frame pointer */ - register_t cf_lr; /* space for link register save */ - register_t cf_func; - register_t cf_arg0; - register_t cf_arg1; - register_t _padding; /* Maintain 16-byte alignment */ -}; -#endif - -/* Definitions for syscalls */ -#define FIRSTARG 3 /* first arg in reg 3 */ -#define NARGREG 8 /* 8 args in regs */ - -#endif /* _MACHINE_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/gdb_machdep.h b/lib/libc/include/generic-freebsd/machine/gdb_machdep.h deleted file mode 100644 index 443aa6f27feb4942988bcf6240e29cc642dc3995..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/gdb_machdep.h +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2006 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_GDB_MACHDEP_H_ -#define _MACHINE_GDB_MACHDEP_H_ - -#ifdef BOOKE -#define PPC_GDB_NREGS0 1 -#define PPC_GDB_NREGS4 (70 + 1) -#define PPC_GDB_NREGS8 (1 + 32) -#define PPC_GDB_NREGS16 0 - -#else -/* - * 0 - 32*GPR(4/8) - * 32 - 32*FPR(8) - * 64 - PC, PS (4/8) - * 66 - CR (4) - * 67 - LR, CTR (4/8) - * 69 - XER, FPSCR (4) - * 71 - 32*VR(16) - * 103 - VSCR, VRSAVE (4) - */ - -#define PPC_REGNUM_R0 0 -#define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31) -#define PPC_REGNUM_FR0 32 -#define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31) -#define PPC_REGNUM_PC 64 -#define PPC_REGNUM_PS 65 -#define PPC_REGNUM_CR 66 -#define PPC_REGNUM_LR 67 -#define PPC_REGNUM_CTR 68 -#define PPC_REGNUM_XER 69 -#define PPC_REGNUM_FPSCR 70 -#define PPC_REGNUM_VR0 71 -#define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31) - -#define PPC_GDB_NREGS0 0 - -#ifdef __powerpc64__ -#define PPC_GDB_NREGS4 5 -#define PPC_GDB_NREGS8 (64 + 4) -#else -#define PPC_GDB_NREGS4 (32 + 7 + 2) -#define PPC_GDB_NREGS8 32 -#endif - -#define PPC_GDB_NREGS16 32 -#endif - -#define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \ - PPC_GDB_NREGS8 + PPC_GDB_NREGS16) -#define GDB_REG_PC 64 - -#define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \ - PPC_GDB_NREGS8 * 16 + \ - PPC_GDB_NREGS16 * 32) - -static __inline size_t -gdb_cpu_regsz(int regnum) -{ - -#ifdef BOOKE - if (regnum == 70) - return (0); - if (regnum == 71 || regnum >= 73) - return (8); -#else -#ifdef __powerpc64__ - if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) || - regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR) - return (8); -#else - if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31) - return (8); -#endif - if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31) - return (16); -#endif - return (4); -} - -static __inline int -gdb_cpu_query(void) -{ - - return (0); -} - -static __inline void * -gdb_begin_write(void) -{ - - return (NULL); -} - -static __inline void -gdb_end_write(void *arg __unused) -{ - -} - -static __inline void -gdb_cpu_stop_reason(int type __unused, int code __unused) -{ - -} - -void *gdb_cpu_getreg(int, size_t *); -void gdb_cpu_setreg(int, void *); -int gdb_cpu_signal(int, int); -void gdb_cpu_do_offsets(void); - -#endif /* !_MACHINE_GDB_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/hid.h b/lib/libc/include/generic-freebsd/machine/hid.h deleted file mode 100644 index 97267189216f277239812a5e3e00dcee2beeaf84..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/hid.h +++ /dev/null @@ -1,223 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2000 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: hid.h,v 1.2 2001/08/22 21:05:25 matt Exp $ - */ - -#ifndef _POWERPC_HID_H_ -#define _POWERPC_HID_H_ - -/* Hardware Implementation Dependent registers for the PowerPC */ -#define HID0_RADIX 0x0080000000000000 /* Enable Radix page tables (POWER9) */ - -#define HID0_EMCP 0x80000000 /* Enable machine check pin */ -#define HID0_DBP 0x40000000 /* Disable 60x bus parity generation */ -#define HID0_EBA 0x20000000 /* Enable 60x bus address parity checking */ -#define HID0_EBD 0x10000000 /* Enable 60x bus data parity checking */ -#define HID0_BCLK 0x08000000 /* CLK_OUT clock type selection */ -#define HID0_EICE 0x04000000 /* Enable ICE output */ -#define HID0_ECLK 0x02000000 /* CLK_OUT clock type selection */ -#define HID0_PAR 0x01000000 /* Disable precharge of ARTRY */ -#define HID0_STEN 0x01000000 /* Software table search enable (7450) */ -#define HID0_DEEPNAP 0x01000000 /* Enable deep nap mode (970) */ -#define HID0_HBATEN 0x00800000 /* High BAT enable (74[45][578]) */ -#define HID0_DOZE 0x00800000 /* Enable doze mode */ -#define HID0_NAP 0x00400000 /* Enable nap mode */ -#define HID0_SLEEP 0x00200000 /* Enable sleep mode */ -#define HID0_DPM 0x00100000 /* Enable Dynamic power management */ -#define HID0_RISEG 0x00080000 /* Read I-SEG */ -#define HID0_TG 0x00040000 /* Timebase Granularity (OEA64) */ -#define HID0_BHTCLR 0x00040000 /* Clear branch history table (7450) */ -#define HID0_EIEC 0x00040000 /* Enable internal error checking */ -#define HID0_XAEN 0x00020000 /* Enable eXtended Addressing (7450) */ -#define HID0_NHR 0x00010000 /* Not hard reset */ -#define HID0_ICE 0x00008000 /* Enable i-cache */ -#define HID0_DCE 0x00004000 /* Enable d-cache */ -#define HID0_ILOCK 0x00002000 /* i-cache lock */ -#define HID0_DLOCK 0x00001000 /* d-cache lock */ -#define HID0_ICFI 0x00000800 /* i-cache flush invalidate */ -#define HID0_DCFI 0x00000400 /* d-cache flush invalidate */ -#define HID0_SPD 0x00000200 /* Disable speculative cache access */ -#define HID0_XBSEN 0x00000100 /* Extended BAT block-size enable (7457) */ -#define HID0_IFEM 0x00000100 /* Enable M-bit for I-fetch */ -#define HID0_XBSEN 0x00000100 /* Extended BAT block size enable (7455+)*/ -#define HID0_SGE 0x00000080 /* Enable store gathering */ -#define HID0_DCFA 0x00000040 /* Data cache flush assist */ -#define HID0_BTIC 0x00000020 /* Enable BTIC */ -#define HID0_LRSTK 0x00000010 /* Link register stack enable (7450) */ -#define HID0_ABE 0x00000008 /* Enable address broadcast */ -#define HID0_FOLD 0x00000008 /* Branch folding enable (7450) */ -#define HID0_BHT 0x00000004 /* Enable branch history table */ -#define HID0_NOPTI 0x00000001 /* No-op the dcbt(st) */ - -#define HID0_AIM_TBEN 0x04000000 /* Time base enable (7450) */ - -#define HID0_E500_TBEN 0x00004000 /* Time Base and decr. enable */ -#define HID0_E500_SEL_TBCLK 0x00002000 /* Select Time Base clock */ -#define HID0_E500_MAS7UPDEN 0x00000080 /* Enable MAS7 update (e500v2) */ - -#define HID0_E500MC_L2MMU_MHD 0x40000000 /* L2MMU Multiple Hit Detection */ - -#define HID0_BITMASK \ - "\20" \ - "\040EMCP\037DBP\036EBA\035EBD\034BCLK\033EICE\032ECLK\031PAR" \ - "\030DOZE\027NAP\026SLEEP\025DPM\024RISEG\023EIEC\022res\021NHR" \ - "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011IFEM" \ - "\010SGE\007DCFA\006BTIC\005FBIOB\004ABE\003BHT\002NOPDST\001NOPTI" - -#define HID0_7450_BITMASK \ - "\20" \ - "\040EMCP\037b1\036b2\035b3\034b4\033TBEN\032b6\031STEN" \ - "\030HBATEN\027NAP\026SLEEP\025DPM\024b12\023BHTCLR\022XAEN\021NHR" \ - "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011XBSEN" \ - "\010SGE\007b25\006BTIC\005LRSTK\004FOLD\003BHT\002NOPDST\001NOPTI" - -#define HID0_E500_BITMASK \ - "\20" \ - "\040EMCP\037b1\036b2\035b3\034b4\033b5\032b6\031b7" \ - "\030DOZE\027NAP\026SLEEP\025b11\024b12\023b13\022b14\021b15" \ - "\020b16\017TBEN\016SEL_TBCLK\015b19\014b20\013b21\012b22\011b23" \ - "\010EN_MAS7_UPDATE\007DCFA\006b26\005b27\004b28\003b29\002b30\001NOPTI" - -#define HID0_970_BITMASK \ - "\20" \ - "\040ONEPPC\037SINGLE\036ISYNCSC\035SERGP\031DEEPNAP\030DOZE" \ - "\027NAP\025DPM\023TG\022HANGDETECT\021NHR\020INORDER" \ - "\016TBCTRL\015TBEN\012CIABREN\011HDICEEN\001ENATTN" - -#define HID0_E500MC_BITMASK \ - "\20" \ - "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \ - "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \ - "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \ - "\010EN_MAS7_UPDATE\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI" - -#define HID0_E5500_BITMASK \ - "\20" \ - "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \ - "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \ - "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \ - "\010b24\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI" - -/* - * HID0 bit definitions per cpu model - * - * bit 603 604 750 7400 7410 7450 7457 e500 - * 0 EMCP EMCP EMCP EMCP EMCP - - EMCP - * 1 - ECP DBP - - - - - - * 2 EBA EBA EBA EBA EDA - - - - * 3 EBD EBD EBD EBD EBD - - - - * 4 SBCLK - BCLK BCKL BCLK - - - - * 5 EICE - - - - TBEN TBEN - - * 6 ECLK - ECLK ECLK ECLK - - - - * 7 PAR PAR PAR PAR PAR STEN STEN - - * 8 DOZE - DOZE DOZE DOZE - HBATEN DOZE - * 9 NAP - NAP NAP NAP NAP NAP NAP - * 10 SLEEP - SLEEP SLEEP SLEEP SLEEP SLEEP SLEEP - * 11 DPM - DPM DPM DPM DPM DPM - - * 12 RISEG - - RISEG - - - - - * 13 - - - EIEC EIEC BHTCLR BHTCLR - - * 14 - - - - - XAEN XAEN - - * 15 - NHR NHR NHR NHR NHR NHR - - * 16 ICE ICE ICE ICE ICE ICE ICE - - * 17 DCE DCE DCE DCE DCE DCE DCE TBEN - * 18 ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK SEL_TBCLK - * 19 DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK - - * 20 ICFI ICFI ICFI ICFI ICFI ICFI ICFI - - * 21 DCFI DCFI DCFI DCFI DCFI DCFI DCFI - - * 22 - - SPD SPD SPG SPD SPD - - * 23 - - IFEM IFTT IFTT - XBSEN - - * 24 - SIE SGE SGE SGE SGE SGE EN_MAS7_UPDATE - * 25 - - DCFA DCFA DCFA - - DCFA - * 26 - - BTIC BTIC BTIC BTIC BTIC - - * 27 FBIOB - - - - LRSTK LRSTK - - * 28 - - ABE - - FOLD FOLD - - * 29 - BHT BHT BHT BHT BHT BHT - - * 30 - - - NOPDST NOPDST NOPDST NOPDST - - * 31 NOOPTI - NOOPTI NOPTI NOPTI NOPTI NOPTI NOPTI - * - * bit e500mc e5500 - * 0 EMCP EMCP - * 1 EN_L2MMU_MHD EN_L2MMU_MHD - * 2 - - - * 3 - - - * 4 - - - * 5 - - - * 6 - - - * 7 - - - * 8 - - - * 9 - - - * 10 - - - * 11 - - - * 12 - - - * 13 - - - * 14 - - - * 15 - - - * 16 - - - * 17 - - - * 18 - - - * 19 - - - * 20 - - - * 21 - - - * 22 - - - * 23 - - - * 24 EN_MAS7_UPDATE - - * 25 DCFA DCFA - * 26 - - - * 27 CIGLSO CIGLSO - * 28 - - - * 29 - - - * 30 - - - * 31 NOPTI NOPTI - * - * 604: ECP = Enable cache parity checking - * 604: SIE = Serial instruction execution disable - * 7450: TBEN = Time Base Enable - * 7450: STEN = Software table lookup enable - * 7450: BHTCLR = Branch history clear - * 7450: XAEN = Extended Addressing Enabled - * 7450: LRSTK = Link Register Stack Enable - * 7450: FOLD = Branch folding enable - * 7457: HBATEN = High BAT Enable - * 7457: XBSEN = Extended BAT Block Size Enable - */ - -#define HID1_E500_ABE 0x00001000 /* Address broadcast enable */ -#define HID1_E500_ASTME 0x00002000 /* Address bus streaming mode enable */ -#define HID1_E500_RFXE 0x00020000 /* Read fault exception enable */ - -#define HID0_E500_DEFAULT_SET (HID0_EMCP | HID0_E500_TBEN | \ - HID0_E500_MAS7UPDEN) -#define HID1_E500_DEFAULT_SET (HID1_E500_ABE | HID1_E500_ASTME) -#define HID0_E500MC_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD | \ - HID0_E500_MAS7UPDEN) -#define HID0_E5500_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD) - -#define HID5_970_DCBZ_SIZE_HI 0x00000080UL /* dcbz does a 32-byte store */ -#define HID4_970_DISABLE_LG_PG 0x00000004ULL /* disables large pages */ - -#endif /* _POWERPC_HID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ieee.h b/lib/libc/include/generic-freebsd/machine/ieee.h deleted file mode 100644 index 73f04cb16043bd9c9ce46ce59115b0109d7514c1..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/ieee.h +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ieee.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp - */ - -#ifndef _MACHINE_IEEE_H_ -#define _MACHINE_IEEE_H_ - -/* - * ieee.h defines the machine-dependent layout of the machine's IEEE - * floating point. It does *not* define (yet?) any of the rounding - * mode bits, exceptions, and so forth. - */ - -/* - * Define the number of bits in each fraction and exponent. - * - * k k+1 - * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented - * - * (-exp_bias+1) - * as fractions that look like 0.fffff x 2 . This means that - * - * -126 - * the number 0.10000 x 2 , for instance, is the same as the normalized - * - * -127 -128 - * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero - * - * -129 - * in the fraction; to represent 2 , we need two, and so on. This - * - * (-exp_bias-fracbits+1) - * implies that the smallest denormalized number is 2 - * - * for whichever format we are talking about: for single precision, for - * - * -126 -149 - * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and - * - * -149 == -127 - 23 + 1. - */ -#define SNG_EXPBITS 8 -#define SNG_FRACBITS 23 - -#define DBL_EXPBITS 11 -#define DBL_FRACBITS 52 - -#ifdef notyet -#define E80_EXPBITS 15 -#define E80_FRACBITS 64 -#endif - -#define EXT_EXPBITS 15 -#define EXT_FRACBITS 112 - -struct ieee_single { - u_int sng_sign:1; - u_int sng_exp:8; - u_int sng_frac:23; -}; - -struct ieee_double { - u_int dbl_sign:1; - u_int dbl_exp:11; - u_int dbl_frach:20; - u_int dbl_fracl; -}; - -struct ieee_ext { - u_int ext_sign:1; - u_int ext_exp:15; - u_int ext_frach:16; - u_int ext_frachm; - u_int ext_fraclm; - u_int ext_fracl; -}; - -/* - * Floats whose exponent is in [1..INFNAN) (of whatever type) are - * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. - * Floats whose exponent is zero are either zero (iff all fraction - * bits are zero) or subnormal values. - * - * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its - * high fraction; if the bit is set, it is a `quiet NaN'. - */ -#define SNG_EXP_INFNAN 255 -#define DBL_EXP_INFNAN 2047 -#define EXT_EXP_INFNAN 32767 - -#if 0 -#define SNG_QUIETNAN (1 << 22) -#define DBL_QUIETNAN (1 << 19) -#define EXT_QUIETNAN (1 << 15) -#endif - -/* - * Exponent biases. - */ -#define SNG_EXP_BIAS 127 -#define DBL_EXP_BIAS 1023 -#define EXT_EXP_BIAS 16383 - -#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ieeefp.h b/lib/libc/include/generic-freebsd/machine/ieeefp.h deleted file mode 100644 index 37cb89cd5f805582e5fb3a619b159b62867b7d49..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/ieeefp.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - - * Written by J.T. Conklin, Apr 6, 1995 - * Public domain. - * $NetBSD: ieeefp.h,v 1.2 1999/07/07 01:52:26 danw Exp $ - */ - -#ifndef _MACHINE_IEEEFP_H_ -#define _MACHINE_IEEEFP_H_ - -/* Deprecated historical FPU control interface */ - -typedef int fp_except_t; -#ifdef __SPE__ -#define FP_X_OFL 0x01 /* overflow exception */ -#define FP_X_UFL 0x02 /* underflow exception */ -#define FP_X_DZ 0x04 /* divide-by-zero exception */ -#define FP_X_INV 0x08 /* invalid operation exception */ -#define FP_X_IMP 0x10 /* imprecise (loss of precision) */ -#else -#define FP_X_IMP 0x01 /* imprecise (loss of precision) */ -#define FP_X_DZ 0x02 /* divide-by-zero exception */ -#define FP_X_UFL 0x04 /* underflow exception */ -#define FP_X_OFL 0x08 /* overflow exception */ -#define FP_X_INV 0x10 /* invalid operation exception */ -#endif - -typedef enum { - FP_RN=0, /* round to nearest representable number */ - FP_RZ=1, /* round to zero (truncate) */ - FP_RP=2, /* round toward positive infinity */ - FP_RM=3 /* round toward negative infinity */ -} fp_rnd_t; - -__BEGIN_DECLS -extern fp_rnd_t fpgetround(void); -extern fp_rnd_t fpsetround(fp_rnd_t); -extern fp_except_t fpgetmask(void); -extern fp_except_t fpsetmask(fp_except_t); -extern fp_except_t fpgetsticky(void); -__END_DECLS - -#endif /* _MACHINE_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ifunc.h b/lib/libc/include/generic-freebsd/machine/ifunc.h deleted file mode 100644 index 7c82fe0af8c2d5591d6c29570a3590d90e00c1a6..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/ifunc.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2019 Brandon Bergren - * Copyright (c) 2015-2018 The FreeBSD Foundation. All rights reserved. - * - * Part of this software was developed by - * Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __POWERPC_IFUNC_H -#define __POWERPC_IFUNC_H - -#include - -#define DEFINE_IFUNC(qual, ret_type, name, args) \ - static ret_type (*name##_resolver(void))args __used; \ - qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ - static ret_type (*name##_resolver(void))args - -#define DEFINE_UIFUNC(qual, ret_type, name, args) \ - static ret_type (*name##_resolver(register_t, register_t, \ - register_t, register_t, register_t, register_t, register_t, \ - register_t))args __used; \ - qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ - static ret_type (*name##_resolver( \ - register_t cpu_features, \ - register_t cpu_features2, \ - register_t arg3 __unused, \ - register_t arg4 __unused, \ - register_t arg5 __unused, \ - register_t arg6 __unused, \ - register_t arg7 __unused, \ - register_t arg8 __unused))args - -#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/in_cksum.h b/lib/libc/include/generic-freebsd/machine/in_cksum.h index 6d9dad8fbb773520e84ee402bc36f6c8fa386400..0a931caffe96cc15ebe6f17c7d956ac99a99762a 100644 --- a/lib/libc/include/generic-freebsd/machine/in_cksum.h +++ b/lib/libc/include/generic-freebsd/machine/in_cksum.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp */ diff --git a/lib/libc/include/generic-freebsd/machine/intr_machdep.h b/lib/libc/include/generic-freebsd/machine/intr_machdep.h deleted file mode 100644 index 1a5dce02f23463db86843c9c7ee79659d3626ab3..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/intr_machdep.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (C) 2002 Benno Rice. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_INTR_MACHDEP_H_ -#define _MACHINE_INTR_MACHDEP_H_ - -#define INTR_VECTORS 256 - -#define MAX_PICS 32 -#define MAP_IRQ(node, pin) powerpc_get_irq(node, pin) - -/* - * Default base address for MSI messages on PowerPC - */ -#define MSI_INTEL_ADDR_BASE 0xfee00000 - -extern device_t root_pic; - -struct trapframe; - -driver_filter_t powerpc_ipi_handler; - -void intrcnt_add(const char *name, u_long **countp); - -u_int powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int); -u_int powerpc_get_irq(uint32_t, u_int); - -void powerpc_dispatch_intr(u_int, struct trapframe *); -int powerpc_enable_intr(void); -int powerpc_setup_intr(const char *, u_int, driver_filter_t, driver_intr_t, - void *, enum intr_type, void **, int); -int powerpc_teardown_intr(void *); -int powerpc_bind_intr(u_int irq, u_char cpu); -int powerpc_config_intr(int, enum intr_trigger, enum intr_polarity); -int powerpc_fw_config_intr(int irq, int sense_code); - -void powerpc_intr_mask(u_int irq); -void powerpc_intr_unmask(u_int irq); - -#endif /* _MACHINE_INTR_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/kdb.h b/lib/libc/include/generic-freebsd/machine/kdb.h deleted file mode 100644 index 14c555233a789d75504d5d4b113fbf4dad842137..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/kdb.h +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2004 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_KDB_H_ -#define _MACHINE_KDB_H_ - -#include -#include -#include -#include -#include - -void kdb_cpu_clear_singlestep(void); -void kdb_cpu_set_singlestep(void); - -static __inline void -kdb_cpu_sync_icache(unsigned char *addr, size_t size) -{ - - __syncicache(addr, size); -} - -static __inline void -kdb_cpu_trap(int vector, int _) -{ -} - -static __inline int -kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access) -{ - - return (ENXIO); -} - -static __inline int -kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size) -{ - - return (0); -} - -#endif /* _MACHINE_KDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/limits.h b/lib/libc/include/generic-freebsd/machine/limits.h index 8dd7900a374cf45f8a91b773a464a9e83326d3c9..4c4e5c0bb04bf838c6133a43f399128e4d00c3b5 100644 --- a/lib/libc/include/generic-freebsd/machine/limits.h +++ b/lib/libc/include/generic-freebsd/machine/limits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE_LIMITS_H_ diff --git a/lib/libc/include/generic-freebsd/machine/machdep.h b/lib/libc/include/generic-freebsd/machine/machdep.h deleted file mode 100644 index dcd54c9b570019eba683db3010b872a8cf4b265d..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/machdep.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2011-2012 Semihalf - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _POWERPC_MACHDEP_H_ -#define _POWERPC_MACHDEP_H_ - -void booke_disable_l2_cache(void); -void booke_enable_l1_cache(void); -void booke_enable_l2_cache(void); -void booke_enable_bpred(void); - -#endif /* _POWERPC_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/md_var.h b/lib/libc/include/generic-freebsd/machine/md_var.h deleted file mode 100644 index 6d49ce2eda8feeaa82c52fd54c6e7ebd2158ee5a..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/md_var.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1998 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_MD_VAR_H_ -#define _MACHINE_MD_VAR_H_ - -/* - * Miscellaneous machine-dependent declarations. - */ - -extern char sigcode32[]; -extern int szsigcode32; - -#ifdef __powerpc64__ -extern char sigcode64[], sigcode64_elfv2[]; -extern int szsigcode64, szsigcode64_elfv2; - -struct dumperinfo; -struct minidumpstate; -int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); -#endif - -extern long Maxmem; - -extern vm_offset_t kstack0; -extern vm_offset_t kstack0_phys; - -extern int powerpc_pow_enabled; -extern int cacheline_size; -extern int hw_direct_map; - -void __syncicache(void *, int); - -int mem_valid(vm_offset_t addr, int len); - -void decr_init(void); -void decr_ap_init(void); -void decr_tc_init(void); - -void cpu_feature_setup(void); -void cpu_setup(u_int); - -struct trapframe; -void powerpc_interrupt(struct trapframe *); - -#endif /* !_MACHINE_MD_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/metadata.h b/lib/libc/include/generic-freebsd/machine/metadata.h index e82eb2790b10d76b5e0b466198be53260f86f0f9..2b194e06d14b745d26826928625e63311dd55ef2 100644 --- a/lib/libc/include/generic-freebsd/machine/metadata.h +++ b/lib/libc/include/generic-freebsd/machine/metadata.h @@ -1,38 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_METADATA_H_ -#define _MACHINE_METADATA_H_ - -#define MODINFOMD_ENVP 0x1001 -#define MODINFOMD_HOWTO 0x1002 -#define MODINFOMD_KERNEND 0x1003 -#define MODINFOMD_BOOTINFO 0x1004 -#define MODINFOMD_DTBP 0x1005 - -#endif /* !_MACHINE_METADATA_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/minidump.h b/lib/libc/include/generic-freebsd/machine/minidump.h deleted file mode 100644 index d55bb4dfa3e5d22c718c260b72c8aae63fc4c5c0..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/minidump.h +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2006 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * From i386: FreeBSD: 157909 2006-04-21 04:28:43Z peter - */ - -#ifndef _MACHINE_MINIDUMP_H_ -#define _MACHINE_MINIDUMP_H_ 1 - -#define MINIDUMP_MAGIC "minidump FreeBSD/powerpc64" -#define MINIDUMP_VERSION 2 - -struct minidumphdr { - char magic[32]; - char mmu_name[32]; - uint32_t version; - uint32_t msgbufsize; - uint32_t bitmapsize; - uint32_t pmapsize; - uint64_t kernbase; - uint64_t kernend; - uint64_t dmapbase; - uint64_t dmapend; - int hw_direct_map; - uint64_t startkernel; - uint64_t endkernel; - uint32_t dumpavailsize; -}; - -#endif /* _MACHINE_MINIDUMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/mmuvar.h b/lib/libc/include/generic-freebsd/machine/mmuvar.h deleted file mode 100644 index ee8265eec2043eac2ab4f4a4245b9186c594b995..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/mmuvar.h +++ /dev/null @@ -1,224 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2005 Peter Grehan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_MMUVAR_H_ -#define _MACHINE_MMUVAR_H_ - -typedef void (*pmap_bootstrap_t)(vm_offset_t, vm_offset_t); -typedef void (*pmap_cpu_bootstrap_t)(int); -typedef void (*pmap_kenter_t)(vm_offset_t, vm_paddr_t pa); -typedef void (*pmap_kenter_attr_t)(vm_offset_t, vm_paddr_t, vm_memattr_t); -typedef void (*pmap_kremove_t)(vm_offset_t); -typedef void *(*pmap_mapdev_t)(vm_paddr_t, vm_size_t); -typedef void *(*pmap_mapdev_attr_t)(vm_paddr_t, vm_size_t, vm_memattr_t); -typedef void (*pmap_unmapdev_t)(void *, vm_size_t); -typedef void (*pmap_page_set_memattr_t)(vm_page_t, vm_memattr_t); -typedef int (*pmap_change_attr_t)(vm_offset_t, vm_size_t, vm_memattr_t); -typedef int (*pmap_map_user_ptr_t)(pmap_t, volatile const void *, - void **, size_t, size_t *); -typedef int (*pmap_decode_kernel_ptr_t)(vm_offset_t, int *, vm_offset_t *); -typedef vm_paddr_t (*pmap_kextract_t)(vm_offset_t); -typedef int (*pmap_dev_direct_mapped_t)(vm_paddr_t, vm_size_t); - -typedef void (*pmap_page_array_startup_t)(long); -typedef void (*pmap_advise_t)(pmap_t, vm_offset_t, vm_offset_t, int); -typedef void (*pmap_clear_modify_t)(vm_page_t); -typedef void (*pmap_remove_write_t)(vm_page_t); -typedef void (*pmap_copy_t)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t); -typedef void (*pmap_copy_page_t)(vm_page_t, vm_page_t); -typedef void (*pmap_copy_pages_t)(vm_page_t *, vm_offset_t, - vm_page_t *, vm_offset_t, int); -typedef int (*pmap_enter_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, - u_int, int8_t); -typedef void (*pmap_enter_object_t)(pmap_t, vm_offset_t, vm_offset_t, - vm_page_t, vm_prot_t); -typedef void (*pmap_enter_quick_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t); -typedef vm_paddr_t (*pmap_extract_t)(pmap_t, vm_offset_t); -typedef vm_page_t (*pmap_extract_and_hold_t)(pmap_t, vm_offset_t, vm_prot_t); -typedef void (*pmap_growkernel_t)(vm_offset_t); -typedef void (*pmap_init_t)(void); -typedef boolean_t (*pmap_is_modified_t)(vm_page_t); -typedef boolean_t (*pmap_is_prefaultable_t)(pmap_t, vm_offset_t); -typedef boolean_t (*pmap_is_referenced_t)(vm_page_t); -typedef int (*pmap_ts_referenced_t)(vm_page_t); -typedef vm_offset_t (*pmap_map_t)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int); -typedef void (*pmap_object_init_pt_t)(pmap_t, vm_offset_t, vm_object_t, - vm_pindex_t, vm_size_t); -typedef boolean_t (*pmap_page_exists_quick_t)(pmap_t, vm_page_t); -typedef boolean_t (*pmap_page_is_mapped_t)(vm_page_t); -typedef void (*pmap_page_init_t)(vm_page_t); -typedef int (*pmap_page_wired_mappings_t)(vm_page_t); -typedef void (*pmap_pinit0_t)(pmap_t); -typedef void (*pmap_protect_t)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t); -typedef void (*pmap_qenter_t)(vm_offset_t, vm_page_t *, int); -typedef void (*pmap_qremove_t)(vm_offset_t, int); -typedef void (*pmap_release_t)(pmap_t); -typedef void (*pmap_remove_t)(pmap_t, vm_offset_t, vm_offset_t); -typedef void (*pmap_remove_all_t)(vm_page_t); -typedef void (*pmap_remove_pages_t)(pmap_t); -typedef void (*pmap_unwire_t)(pmap_t, vm_offset_t, vm_offset_t); -typedef void (*pmap_zero_page_t)(vm_page_t); -typedef void (*pmap_zero_page_area_t)(vm_page_t, int, int); -typedef int (*pmap_mincore_t)(pmap_t, vm_offset_t, vm_paddr_t *); -typedef void (*pmap_activate_t)(struct thread *); -typedef void (*pmap_deactivate_t)(struct thread *); -typedef void (*pmap_align_superpage_t)(vm_object_t, vm_ooffset_t, - vm_offset_t *, vm_size_t); - -typedef void (*pmap_sync_icache_t)(pmap_t, vm_offset_t, vm_size_t); -typedef void (*pmap_dumpsys_map_chunk_t)(vm_paddr_t, size_t, void **); -typedef void (*pmap_dumpsys_unmap_chunk_t)(vm_paddr_t, size_t, void *); -typedef void (*pmap_dumpsys_pa_init_t)(void); -typedef size_t (*pmap_dumpsys_scan_pmap_t)(struct bitset *dump_bitset); -typedef void *(*pmap_dumpsys_dump_pmap_init_t)(unsigned); -typedef void *(*pmap_dumpsys_dump_pmap_t)(void *, void *, u_long *); -typedef vm_offset_t (*pmap_quick_enter_page_t)(vm_page_t); -typedef void (*pmap_quick_remove_page_t)(vm_offset_t); -typedef bool (*pmap_ps_enabled_t)(pmap_t); -typedef void (*pmap_tlbie_all_t)(void); -typedef void (*pmap_installer_t)(void); - -struct pmap_funcs { - pmap_installer_t install; - pmap_bootstrap_t bootstrap; - pmap_cpu_bootstrap_t cpu_bootstrap; - pmap_kenter_t kenter; - pmap_kenter_attr_t kenter_attr; - pmap_kremove_t kremove; - pmap_mapdev_t mapdev; - pmap_mapdev_attr_t mapdev_attr; - pmap_unmapdev_t unmapdev; - pmap_page_set_memattr_t page_set_memattr; - pmap_change_attr_t change_attr; - pmap_map_user_ptr_t map_user_ptr; - pmap_decode_kernel_ptr_t decode_kernel_ptr; - pmap_kextract_t kextract; - pmap_dev_direct_mapped_t dev_direct_mapped; - pmap_advise_t advise; - pmap_clear_modify_t clear_modify; - pmap_remove_write_t remove_write; - pmap_copy_t copy; - pmap_copy_page_t copy_page; - pmap_copy_pages_t copy_pages; - pmap_enter_t enter; - pmap_enter_object_t enter_object; - pmap_enter_quick_t enter_quick; - pmap_extract_t extract; - pmap_extract_and_hold_t extract_and_hold; - pmap_growkernel_t growkernel; - pmap_init_t init; - pmap_is_modified_t is_modified; - pmap_is_prefaultable_t is_prefaultable; - pmap_is_referenced_t is_referenced; - pmap_ts_referenced_t ts_referenced; - pmap_page_is_mapped_t page_is_mapped; - pmap_ps_enabled_t ps_enabled; - pmap_map_t map; - pmap_object_init_pt_t object_init_pt; - pmap_page_exists_quick_t page_exists_quick; - pmap_page_init_t page_init; - pmap_page_wired_mappings_t page_wired_mappings; - pmap_pinit_t pinit; - pmap_pinit0_t pinit0; - pmap_protect_t protect; - pmap_qenter_t qenter; - pmap_qremove_t qremove; - pmap_release_t release; - pmap_remove_t remove; - pmap_remove_all_t remove_all; - pmap_remove_pages_t remove_pages; - pmap_unwire_t unwire; - pmap_zero_page_t zero_page; - pmap_zero_page_area_t zero_page_area; - pmap_mincore_t mincore; - pmap_activate_t activate; - pmap_deactivate_t deactivate; - pmap_align_superpage_t align_superpage; - pmap_sync_icache_t sync_icache; - pmap_quick_enter_page_t quick_enter_page; - pmap_quick_remove_page_t quick_remove_page; - pmap_page_array_startup_t page_array_startup; - pmap_dumpsys_map_chunk_t dumpsys_map_chunk; - pmap_dumpsys_unmap_chunk_t dumpsys_unmap_chunk; - pmap_dumpsys_pa_init_t dumpsys_pa_init; - pmap_dumpsys_scan_pmap_t dumpsys_scan_pmap; - pmap_dumpsys_dump_pmap_init_t dumpsys_dump_pmap_init; - pmap_dumpsys_dump_pmap_t dumpsys_dump_pmap; - pmap_tlbie_all_t tlbie_all; - -}; -struct mmu_kobj { - const char *name; - const struct mmu_kobj *base; - const struct pmap_funcs *funcs; -}; - -typedef struct mmu_kobj *mmu_t; - -/* The currently installed pmap object. */ -extern mmu_t mmu_obj; - -/* - * Resolve a given pmap function. - * 'func' is the function name less the 'pmap_' * prefix. - */ -#define PMAP_RESOLVE_FUNC(func) \ - ({ \ - pmap_##func##_t f; \ - const struct mmu_kobj *mmu = mmu_obj; \ - do { \ - f = mmu->funcs->func; \ - if (f != NULL) break; \ - mmu = mmu->base; \ - } while (mmu != NULL); \ - f;}) - -#define MMU_DEF(name, ident, methods) \ - \ -const struct mmu_kobj name = { \ - ident, NULL, &methods \ -}; \ -DATA_SET(mmu_set, name) - -#define MMU_DEF_INHERIT(name, ident, methods, base1) \ - \ -const struct mmu_kobj name = { \ - ident, &base1, &methods, \ -}; \ -DATA_SET(mmu_set, name) - -/* - * Known MMU names - */ -#define MMU_TYPE_BOOKE "mmu_booke" /* Book-E MMU specification */ -#define MMU_TYPE_OEA "mmu_oea" /* 32-bit OEA */ -#define MMU_TYPE_G5 "mmu_g5" /* 64-bit bridge (ibm 970) */ -#define MMU_TYPE_RADIX "mmu_radix" /* 64-bit native ISA 3.0 (POWER9) radix */ -#define MMU_TYPE_8xx "mmu_8xx" /* 8xx quicc TLB */ - -#endif /* _MACHINE_MMUVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ofw_machdep.h b/lib/libc/include/generic-freebsd/machine/ofw_machdep.h index 78fe8dd7e44b0c628ec2e50b3a92ac2c3f620438..21d28906f0dda8d9607400b9a6f5c6890cacbbca 100644 --- a/lib/libc/include/generic-freebsd/machine/ofw_machdep.h +++ b/lib/libc/include/generic-freebsd/machine/ofw_machdep.h @@ -1,58 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 by Thomas Moestl . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_OFW_MACHDEP_H_ -#define _MACHINE_OFW_MACHDEP_H_ - -#include -#include -#include -#include -#include -#include - -struct mem_region; -struct numa_mem_region; - -typedef uint32_t cell_t; - -void OF_getetheraddr(device_t dev, u_char *addr); - -void OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *)); -boolean_t OF_bootstrap(void); - -void OF_reboot(void); - -void ofw_mem_regions(struct mem_region *, int *, struct mem_region *, int *); -void ofw_numa_mem_regions(struct numa_mem_region *, int *); -void ofw_quiesce(void); /* Must be called before VM is up! */ -void ofw_save_trap_vec(char *); -int ofw_pcibus_get_domain(device_t dev, device_t child, int *domain); -int ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op, - size_t setsize, cpuset_t *cpuset); - -#endif /* _MACHINE_OFW_MACHDEP_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/openpicreg.h b/lib/libc/include/generic-freebsd/machine/openpicreg.h deleted file mode 100644 index f3f3e602de33e67431b7937bd78e1ee62778de86..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/openpicreg.h +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2000 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp - */ - -/* - * Size of OpenPIC register space - */ -#define OPENPIC_SIZE 0x40000 - -/* - * Per Processor Registers [private access] (0x00000 - 0x00fff) - */ - -/* IPI dispatch command reg */ -#define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10) - -/* current task priority reg */ -#define OPENPIC_TPR 0x80 -#define OPENPIC_TPR_MASK 0x0000000f - -#define OPENPIC_WHOAMI 0x90 - -/* interrupt acknowledge reg */ -#define OPENPIC_IACK 0xa0 - -/* end of interrupt reg */ -#define OPENPIC_EOI 0xb0 - -/* - * Global registers (0x01000-0x0ffff) - */ - -/* feature reporting reg 0 */ -#define OPENPIC_FEATURE 0x1000 -#define OPENPIC_FEATURE_VERSION_MASK 0x000000ff -#define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00 -#define OPENPIC_FEATURE_LAST_CPU_SHIFT 8 -#define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000 -#define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16 - -/* global config reg 0 */ -#define OPENPIC_CONFIG 0x1020 -#define OPENPIC_CONFIG_RESET 0x80000000 -#define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000 - -/* interrupt configuration mode (direct or serial) */ -#define OPENPIC_ICR 0x1030 -#define OPENPIC_ICR_SERIAL_MODE (1 << 27) -#define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28) -#define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28 - -/* vendor ID */ -#define OPENPIC_VENDOR_ID 0x1080 - -/* processor initialization reg */ -#define OPENPIC_PROC_INIT 0x1090 - -/* IPI vector/priority reg */ -#define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10) - -/* spurious intr. vector */ -#define OPENPIC_SPURIOUS_VECTOR 0x10e0 - -/* Timer registers */ -#define OPENPIC_TIMERS 4 -#define OPENPIC_TFREQ 0x10f0 -#define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40) -#define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40) -#define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40) -#define OPENPIC_TDST(t) (0x1130 + (t) * 0x40) - -/* - * Interrupt Source Configuration Registers (0x10000 - 0x1ffff) - */ - -/* interrupt vector/priority reg */ -#define OPENPIC_SRC_VECTOR_COUNT 64 -#ifndef OPENPIC_SRC_VECTOR -#define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20) -#endif -#define OPENPIC_SENSE_LEVEL 0x00400000 -#define OPENPIC_SENSE_EDGE 0x00000000 -#define OPENPIC_POLARITY_POSITIVE 0x00800000 -#define OPENPIC_POLARITY_NEGATIVE 0x00000000 -#define OPENPIC_IMASK 0x80000000 -#define OPENPIC_ACTIVITY 0x40000000 -#define OPENPIC_PRIORITY_MASK 0x000f0000 -#define OPENPIC_PRIORITY_SHIFT 16 -#define OPENPIC_VECTOR_MASK 0x000000ff - -/* interrupt destination cpu */ -#ifndef OPENPIC_IDEST -#define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20) -#endif - -/* - * Per Processor Registers [global access] (0x20000 - 0x3ffff) - */ - -#define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000) - -#define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \ - (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi)) - -#define OPENPIC_PCPU_TPR(cpu) \ - (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR) - -#define OPENPIC_PCPU_WHOAMI(cpu) \ - (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI) - -#define OPENPIC_PCPU_IACK(cpu) \ - (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK) - -#define OPENPIC_PCPU_EOI(cpu) \ - (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI) \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/openpicvar.h b/lib/libc/include/generic-freebsd/machine/openpicvar.h deleted file mode 100644 index 5077b8a82390c123286a998b65f634ec6c7f6804..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/openpicvar.h +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (C) 2002 Benno Rice. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _POWERPC_OPENPICVAR_H_ -#define _POWERPC_OPENPICVAR_H_ - -#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller" - -#define OPENPIC_IRQMAX 256 /* h/w allows more */ - -#define OPENPIC_QUIRK_SINGLE_BIND 1 /* Bind interrupts to only 1 CPU */ -#define OPENPIC_QUIRK_HIDDEN_IRQS 2 /* May have IRQs beyond FRR[NIRQ] */ - -/* Names match the macros in openpicreg.h. */ -struct openpic_timer { - uint32_t tcnt; - uint32_t tbase; - uint32_t tvec; - uint32_t tdst; -}; - -struct openpic_softc { - device_t sc_dev; - struct resource *sc_memr; - struct resource *sc_intr; - bus_space_tag_t sc_bt; - bus_space_handle_t sc_bh; - char *sc_version; - int sc_rid; - int sc_irq; - void *sc_icookie; - u_int sc_ncpu; - u_int sc_nirq; - int sc_psim; - u_int sc_quirks; - - /* Saved states. */ - uint32_t sc_saved_config; - uint32_t sc_saved_ipis[4]; - uint32_t sc_saved_prios[4]; - struct openpic_timer sc_saved_timers[OPENPIC_TIMERS]; - uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT]; - -}; - -/* - * Bus-independent attach i/f - */ -int openpic_common_attach(device_t, uint32_t); - -/* - * PIC interface. - */ -void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **); -void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); -void openpic_dispatch(device_t, struct trapframe *); -void openpic_enable(device_t, u_int, u_int, void **); -void openpic_eoi(device_t, u_int, void *); -void openpic_ipi(device_t, u_int); -void openpic_mask(device_t, u_int, void *); -void openpic_unmask(device_t, u_int, void *); - -int openpic_suspend(device_t dev); -int openpic_resume(device_t dev); - -#endif /* _POWERPC_OPENPICVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/param.h b/lib/libc/include/generic-freebsd/machine/param.h deleted file mode 100644 index bc157c464e411670f1db105b745524a3cd7d04c2..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/param.h +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2001 David E. O'Brien - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - */ - -#ifndef _POWERPC_INCLUDE_PARAM_H_ -#define _POWERPC_INCLUDE_PARAM_H_ - -/* - * Machine dependent constants for PowerPC - */ - -#include - -/* Needed to display interrupts on OFW PCI */ -#define __PCI_REROUTE_INTERRUPT - -#ifndef MACHINE -#define MACHINE "powerpc" -#endif -#ifndef MACHINE_ARCH -#ifdef __powerpc64__ -#if defined(__LITTLE_ENDIAN__) -#define MACHINE_ARCH "powerpc64le" -#else -#define MACHINE_ARCH "powerpc64" -#endif -#else -#ifdef __SPE__ -#define MACHINE_ARCH "powerpcspe" -#else -#define MACHINE_ARCH "powerpc" -#endif -#endif -#endif -#define MID_MACHINE MID_POWERPC -#ifdef __powerpc64__ -#ifndef MACHINE_ARCH32 -#define MACHINE_ARCH32 "powerpc" -#endif -#endif - -#ifdef SMP -#ifndef MAXCPU -#define MAXCPU 256 -#endif -#else -#define MAXCPU 1 -#endif - -#ifndef MAXMEMDOM -#define MAXMEMDOM 8 -#endif - -#define ALIGNBYTES _ALIGNBYTES -#define ALIGN(p) _ALIGN(p) -/* - * ALIGNED_POINTER is a boolean macro that checks whether an address - * is valid to fetch data elements of type t from on this architecture. - * This does not reflect the optimal alignment, just the possibility - * (within reasonable limits). - */ -#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0) - -/* - * CACHE_LINE_SIZE is the compile-time maximum cache line size for an - * architecture. It should be used with appropriate caution. - */ -#define CACHE_LINE_SHIFT 7 -#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) - -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ -#define PAGE_MASK (PAGE_SIZE - 1) -#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) -#define NPDEPG (PAGE_SIZE/(sizeof (pt_entry_t))) - -#define L1_PAGE_SIZE_SHIFT 39 -#define L1_PAGE_SIZE (1UL<> PAGE_SHIFT) -#define ptoa(x) ((x) << PAGE_SHIFT) - -#define powerpc_btop(x) ((x) >> PAGE_SHIFT) -#define powerpc_ptob(x) ((x) << PAGE_SHIFT) - -#define pgtok(x) ((x) * (PAGE_SIZE / 1024UL)) - -#define btoc(x) ((vm_offset_t)(((x)+PAGE_MASK)>>PAGE_SHIFT)) - -#endif /* !_POWERPC_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pcb.h b/lib/libc/include/generic-freebsd/machine/pcb.h deleted file mode 100644 index 0ad791d624aacb220590d75980a675918466e602..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pcb.h +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: pcb.h,v 1.4 2000/06/04 11:57:17 tsubai Exp $ - */ - -#ifndef _MACHINE_PCB_H_ -#define _MACHINE_PCB_H_ - -#include - -#include - -#ifndef _STANDALONE -struct pcb { - register_t pcb_context[20]; /* non-volatile r12-r31 */ - register_t pcb_cr; /* Condition register */ - register_t pcb_sp; /* stack pointer */ - register_t pcb_toc; /* toc pointer */ - register_t pcb_lr; /* link register */ - register_t pcb_dscr; /* dscr value */ - register_t pcb_fscr; - register_t pcb_tar; - struct pmap *pcb_pm; /* pmap of our vmspace */ - jmp_buf *pcb_onfault; /* For use during - copyin/copyout */ - int pcb_flags; -#define PCB_FPU 0x1 /* Process uses FPU */ -#define PCB_FPREGS 0x2 /* Process had FPU registers initialized */ -#define PCB_VEC 0x4 /* Process uses Altivec */ -#define PCB_VSX 0x8 /* Process had VSX initialized */ -#define PCB_CDSCR 0x10 /* Process had Custom DSCR initialized */ -#define PCB_HTM 0x20 /* Process had HTM initialized */ -#define PCB_CFSCR 0x40 /* Process had FSCR updated */ -#define PCB_KERN_FPU 0x80 /* Kernel is using FPU/Vector unit */ -#define PCB_KERN_FPU_NOSAVE 0x100 /* FPU/Vec state not saved for kernel use */ -#define PCB_VECREGS 0x200 /* Process had Altivec registers initialized */ - struct fpu { - union { -#if _BYTE_ORDER == _BIG_ENDIAN - double fpr; - uint32_t vsr[4]; -#else - uint32_t vsr[4]; - struct { - double padding; - double fpr; - }; -#endif - } fpr[32]; - double fpscr; /* FPSCR stored as double for easier access */ - } pcb_fpu; /* Floating point processor */ - unsigned int pcb_fpcpu; /* which CPU had our FPU - stuff. */ - struct vec { - uint32_t vr[32][4]; - uint32_t spare[2]; - uint32_t vrsave; - uint32_t vscr; /* aligned at vector element 3 */ - } pcb_vec __aligned(16); /* Vector processor */ - unsigned int pcb_veccpu; /* which CPU had our vector - stuff. */ - struct htm { - uint64_t tfhar; - uint64_t texasr; - uint64_t tfiar; - } pcb_htm; - - struct ebb { - uint64_t ebbhr; - uint64_t ebbrr; - uint64_t bescr; - } pcb_ebb; - - struct lmon { - uint64_t lmrr; - uint64_t lmser; - } pcb_lm; - - union { - struct { - vm_offset_t usr_segm; /* Base address */ - register_t usr_vsid; /* USER_SR segment */ - } aim; - struct { - register_t dbcr0; - } booke; - } pcb_cpu; - vm_offset_t pcb_lastill; /* Last illegal instruction */ -}; -#endif - -#ifdef _KERNEL - -struct trapframe; - -#ifndef curpcb -extern struct pcb *curpcb; -#endif - -extern struct pmap *curpm; -extern struct proc *fpuproc; - -void makectx(struct trapframe *, struct pcb *); -void savectx(struct pcb *) __returns_twice; - -#endif -#endif /* _MACHINE_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pcpu.h b/lib/libc/include/generic-freebsd/machine/pcpu.h deleted file mode 100644 index 630ddf6499bea6a42004ec353854bff3d321ba79..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pcpu.h +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 1999 Luoqi Chen - * Copyright (c) Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_PCPU_H_ -#define _MACHINE_PCPU_H_ - -#include -#include -#include - -struct pmap; -struct pvo_entry; -#define CPUSAVE_LEN 9 - -#define PCPU_MD_COMMON_FIELDS \ - int pc_inside_intr; \ - struct pmap *pc_curpmap; /* current pmap */ \ - struct thread *pc_fputhread; /* current fpu user */ \ - struct thread *pc_vecthread; /* current vec user */ \ - struct thread *pc_htmthread; /* current htm user */ \ - uintptr_t pc_hwref; \ - int pc_bsp; \ - volatile int pc_awake; \ - uint32_t pc_ipimask; \ - uint32_t pc_flags; /* cpu feature flags */ \ - register_t pc_tempsave[CPUSAVE_LEN]; \ - register_t pc_disisave[CPUSAVE_LEN]; \ - register_t pc_dbsave[CPUSAVE_LEN]; \ - void *pc_restore; \ - vm_offset_t pc_qmap_addr; - -#define PCPU_MD_AIM32_FIELDS \ - struct pvo_entry *qmap_pvo; \ - struct mtx qmap_lock; \ - char __pad[128]; - -#define PCPU_MD_AIM64_FIELDS \ - struct slb slb[64]; \ - struct slb **userslb; \ - register_t slbsave[18]; \ - uint8_t slbstack[1024]; \ - struct pvo_entry *qmap_pvo; \ - struct mtx qmap_lock; \ - uint64_t opal_hmi_flags; \ - char __pad[1337]; - -#ifdef __powerpc64__ -#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM64_FIELDS -#else -#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM32_FIELDS -#endif - -/* CPU feature flags, can be used for cached flow control. */ -#define PC_FLAG_NOSRS 0x80000000 - -#define BOOKE_CRITSAVE_LEN (CPUSAVE_LEN + 2) -#define BOOKE_TLB_MAXNEST 4 -#define BOOKE_TLB_SAVELEN 16 -#define BOOKE_TLBSAVE_LEN (BOOKE_TLB_SAVELEN * BOOKE_TLB_MAXNEST) - -#ifdef __powerpc64__ -#define BOOKE_PCPU_PAD 901 -#else -#define BOOKE_PCPU_PAD 365 -#endif -#define PCPU_MD_BOOKE_FIELDS \ - register_t critsave[BOOKE_CRITSAVE_LEN]; \ - register_t mchksave[CPUSAVE_LEN]; \ - register_t tlbsave[BOOKE_TLBSAVE_LEN]; \ - register_t tlb_level; \ - uintptr_t *tlb_lock; \ - int tid_next; \ - char __pad[BOOKE_PCPU_PAD]; - -/* Definitions for register offsets within the exception tmp save areas */ -#define CPUSAVE_R27 0 /* where r27 gets saved */ -#define CPUSAVE_R28 1 /* where r28 gets saved */ -#define CPUSAVE_R29 2 /* where r29 gets saved */ -#define CPUSAVE_R30 3 /* where r30 gets saved */ -#define CPUSAVE_R31 4 /* where r31 gets saved */ -#define CPUSAVE_AIM_DAR 5 /* where SPR_DAR gets saved */ -#define CPUSAVE_AIM_DSISR 6 /* where SPR_DSISR gets saved */ -#define CPUSAVE_BOOKE_DEAR 5 /* where SPR_DEAR gets saved */ -#define CPUSAVE_BOOKE_ESR 6 /* where SPR_ESR gets saved */ -#define CPUSAVE_SRR0 7 /* where SRR0 gets saved */ -#define CPUSAVE_SRR1 8 /* where SRR1 gets saved */ -#define BOOKE_CRITSAVE_SRR0 9 /* where real SRR0 gets saved (critical) */ -#define BOOKE_CRITSAVE_SRR1 10 /* where real SRR0 gets saved (critical) */ - -/* Book-E TLBSAVE is more elaborate */ -#define TLBSAVE_BOOKE_LR 0 -#define TLBSAVE_BOOKE_CR 1 -#define TLBSAVE_BOOKE_SRR0 2 -#define TLBSAVE_BOOKE_SRR1 3 -#define TLBSAVE_BOOKE_R20 4 -#define TLBSAVE_BOOKE_R21 5 -#define TLBSAVE_BOOKE_R22 6 -#define TLBSAVE_BOOKE_R23 7 -#define TLBSAVE_BOOKE_R24 8 -#define TLBSAVE_BOOKE_R25 9 -#define TLBSAVE_BOOKE_R26 10 -#define TLBSAVE_BOOKE_R27 11 -#define TLBSAVE_BOOKE_R28 12 -#define TLBSAVE_BOOKE_R29 13 -#define TLBSAVE_BOOKE_R30 14 -#define TLBSAVE_BOOKE_R31 15 - -#define PCPU_MD_FIELDS \ - PCPU_MD_COMMON_FIELDS \ - union { \ - struct { \ - PCPU_MD_AIM_FIELDS \ - } pc_aim; \ - struct { \ - PCPU_MD_BOOKE_FIELDS \ - } pc_booke; \ - } - -#ifdef _KERNEL - -#define pcpup (get_pcpu()) - -static __inline __pure2 struct thread * -__curthread(void) -{ - struct thread *td; -#ifdef __powerpc64__ - __asm __volatile("mr %0,13" : "=r"(td)); -#else - __asm __volatile("mr %0,2" : "=r"(td)); -#endif - return (td); -} -#define curthread (__curthread()) - -#define PCPU_GET(member) (pcpup->pc_ ## member) - -/* - * XXX The implementation of this operation should be made atomic - * with respect to preemption. - */ -#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) -#define PCPU_PTR(member) (&pcpup->pc_ ## member) -#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PCPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pio.h b/lib/libc/include/generic-freebsd/machine/pio.h deleted file mode 100644 index fd63a44b0ab4b60ce6cf78cd49057c6255ecafed..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pio.h +++ /dev/null @@ -1,304 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed under OpenBSD by - * Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $NetBSD: pio.h,v 1.1 1998/05/15 10:15:54 tsubai Exp $ - * $OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $ - */ - -#ifndef _MACHINE_PIO_H_ -#define _MACHINE_PIO_H_ -/* - * I/O macros. - */ - -/* - * Use sync so that bus space operations cannot sneak out the bottom of - * mutex-protected sections (mutex release does not guarantee completion of - * accesses to caching-inhibited memory on some systems) - */ -#define powerpc_iomb() __asm __volatile("sync" : : : "memory") - -static __inline void -__outb(volatile u_int8_t *a, u_int8_t v) -{ - *a = v; - powerpc_iomb(); -} - -static __inline void -__outw(volatile u_int16_t *a, u_int16_t v) -{ - *a = v; - powerpc_iomb(); -} - -static __inline void -__outl(volatile u_int32_t *a, u_int32_t v) -{ - *a = v; - powerpc_iomb(); -} - -static __inline void -__outll(volatile u_int64_t *a, u_int64_t v) -{ - *a = v; - powerpc_iomb(); -} - -static __inline void -__outwrb(volatile u_int16_t *a, u_int16_t v) -{ - __asm__ volatile("sthbrx %0, 0, %1" :: "r"(v), "r"(a)); - powerpc_iomb(); -} - -static __inline void -__outlrb(volatile u_int32_t *a, u_int32_t v) -{ - __asm__ volatile("stwbrx %0, 0, %1" :: "r"(v), "r"(a)); - powerpc_iomb(); -} - -static __inline u_int8_t -__inb(volatile u_int8_t *a) -{ - u_int8_t _v_; - - _v_ = *a; - powerpc_iomb(); - return _v_; -} - -static __inline u_int16_t -__inw(volatile u_int16_t *a) -{ - u_int16_t _v_; - - _v_ = *a; - powerpc_iomb(); - return _v_; -} - -static __inline u_int32_t -__inl(volatile u_int32_t *a) -{ - u_int32_t _v_; - - _v_ = *a; - powerpc_iomb(); - return _v_; -} - -static __inline u_int64_t -__inll(volatile u_int64_t *a) -{ - u_int64_t _v_; - - _v_ = *a; - powerpc_iomb(); - return _v_; -} - -static __inline u_int16_t -__inwrb(volatile u_int16_t *a) -{ - u_int16_t _v_; - - __asm__ volatile("lhbrx %0, 0, %1" : "=r"(_v_) : "r"(a)); - powerpc_iomb(); - return _v_; -} - -static __inline u_int32_t -__inlrb(volatile u_int32_t *a) -{ - u_int32_t _v_; - - __asm__ volatile("lwbrx %0, 0, %1" : "=r"(_v_) : "r"(a)); - powerpc_iomb(); - return _v_; -} - -#define outb(a,v) (__outb((volatile u_int8_t *)(a), v)) -#define out8(a,v) outb(a,v) -#define outw(a,v) (__outw((volatile u_int16_t *)(a), v)) -#define out16(a,v) outw(a,v) -#define outl(a,v) (__outl((volatile u_int32_t *)(a), v)) -#define out32(a,v) outl(a,v) -#define outll(a,v) (__outll((volatile u_int64_t *)(a), v)) -#define out64(a,v) outll(a,v) -#define inb(a) (__inb((volatile u_int8_t *)(a))) -#define in8(a) inb(a) -#define inw(a) (__inw((volatile u_int16_t *)(a))) -#define in16(a) inw(a) -#define inl(a) (__inl((volatile u_int32_t *)(a))) -#define in32(a) inl(a) -#define inll(a) (__inll((volatile u_int64_t *)(a))) -#define in64(a) inll(a) - -#define out8rb(a,v) outb(a,v) -#define outwrb(a,v) (__outwrb((volatile u_int16_t *)(a), v)) -#define out16rb(a,v) outwrb(a,v) -#define outlrb(a,v) (__outlrb((volatile u_int32_t *)(a), v)) -#define out32rb(a,v) outlrb(a,v) -#define in8rb(a) inb(a) -#define inwrb(a) (__inwrb((volatile u_int16_t *)(a))) -#define in16rb(a) inwrb(a) -#define inlrb(a) (__inlrb((volatile u_int32_t *)(a))) -#define in32rb(a) inlrb(a) - -static __inline void -__outsb(volatile u_int8_t *a, const u_int8_t *s, size_t c) -{ - while (c--) - *a = *s++; - powerpc_iomb(); -} - -static __inline void -__outsw(volatile u_int16_t *a, const u_int16_t *s, size_t c) -{ - while (c--) - *a = *s++; - powerpc_iomb(); -} - -static __inline void -__outsl(volatile u_int32_t *a, const u_int32_t *s, size_t c) -{ - while (c--) - *a = *s++; - powerpc_iomb(); -} - -static __inline void -__outsll(volatile u_int64_t *a, const u_int64_t *s, size_t c) -{ - while (c--) - *a = *s++; - powerpc_iomb(); -} - -static __inline void -__outswrb(volatile u_int16_t *a, const u_int16_t *s, size_t c) -{ - while (c--) - __asm__ volatile("sthbrx %0, 0, %1" :: "r"(*s++), "r"(a)); - powerpc_iomb(); -} - -static __inline void -__outslrb(volatile u_int32_t *a, const u_int32_t *s, size_t c) -{ - while (c--) - __asm__ volatile("stwbrx %0, 0, %1" :: "r"(*s++), "r"(a)); - powerpc_iomb(); -} - -static __inline void -__insb(volatile u_int8_t *a, u_int8_t *d, size_t c) -{ - while (c--) - *d++ = *a; - powerpc_iomb(); -} - -static __inline void -__insw(volatile u_int16_t *a, u_int16_t *d, size_t c) -{ - while (c--) - *d++ = *a; - powerpc_iomb(); -} - -static __inline void -__insl(volatile u_int32_t *a, u_int32_t *d, size_t c) -{ - while (c--) - *d++ = *a; - powerpc_iomb(); -} - -static __inline void -__insll(volatile u_int64_t *a, u_int64_t *d, size_t c) -{ - while (c--) - *d++ = *a; - powerpc_iomb(); -} - -static __inline void -__inswrb(volatile u_int16_t *a, u_int16_t *d, size_t c) -{ - while (c--) - __asm__ volatile("lhbrx %0, 0, %1" : "=r"(*d++) : "r"(a)); - powerpc_iomb(); -} - -static __inline void -__inslrb(volatile u_int32_t *a, u_int32_t *d, size_t c) -{ - while (c--) - __asm__ volatile("lwbrx %0, 0, %1" : "=r"(*d++) : "r"(a)); - powerpc_iomb(); -} - -#define outsb(a,s,c) (__outsb((volatile u_int8_t *)(a), s, c)) -#define outs8(a,s,c) outsb(a,s,c) -#define outsw(a,s,c) (__outsw((volatile u_int16_t *)(a), s, c)) -#define outs16(a,s,c) outsw(a,s,c) -#define outsl(a,s,c) (__outsl((volatile u_int32_t *)(a), s, c)) -#define outs32(a,s,c) outsl(a,s,c) -#define outsll(a,s,c) (__outsll((volatile u_int64_t *)(a), s, c)) -#define outs64(a,s,c) outsll(a,s,c) -#define insb(a,d,c) (__insb((volatile u_int8_t *)(a), d, c)) -#define ins8(a,d,c) insb(a,d,c) -#define insw(a,d,c) (__insw((volatile u_int16_t *)(a), d, c)) -#define ins16(a,d,c) insw(a,d,c) -#define insl(a,d,c) (__insl((volatile u_int32_t *)(a), d, c)) -#define ins32(a,d,c) insl(a,d,c) -#define insll(a,d,c) (__insll((volatile u_int64_t *)(a), d, c)) -#define ins64(a,d,c) insll(a,d,c) - -#define outs8rb(a,s,c) outsb(a,s,c) -#define outswrb(a,s,c) (__outswrb((volatile u_int16_t *)(a), s, c)) -#define outs16rb(a,s,c) outswrb(a,s,c) -#define outslrb(a,s,c) (__outslrb((volatile u_int32_t *)(a), s, c)) -#define outs32rb(a,s,c) outslrb(a,s,c) -#define ins8rb(a,d,c) insb(a,d,c) -#define inswrb(a,d,c) (__inswrb((volatile u_int16_t *)(a), d, c)) -#define ins16rb(a,d,c) inswrb(a,d,c) -#define inslrb(a,d,c) (__inslrb((volatile u_int32_t *)(a), d, c)) -#define ins32rb(a,d,c) inslrb(a,d,c) - -#endif /*_MACHINE_PIO_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/platform.h b/lib/libc/include/generic-freebsd/machine/platform.h deleted file mode 100644 index 51104cae74a455cc61e1ac0e929930b9a9bde11c..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/platform.h +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1996 Wolfgang Solfrank. - * Copyright (C) 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: powerpc.h,v 1.3 2000/06/01 00:49:59 matt Exp $ - */ - -#ifndef _MACHINE_PLATFORM_H_ -#define _MACHINE_PLATFORM_H_ - -#include -#include -#include - -struct mem_region { - uint64_t mr_start; - uint64_t mr_size; -}; - -struct numa_mem_region { - uint64_t mr_start; - uint64_t mr_size; - uint64_t mr_domain; -}; - -/* Documentation for these functions is in platform_if.m */ - -void mem_regions(struct mem_region **, int *, struct mem_region **, int *); -void numa_mem_regions(struct numa_mem_region **, int *); -vm_offset_t platform_real_maxaddr(void); - -u_long platform_timebase_freq(struct cpuref *); - -int platform_smp_first_cpu(struct cpuref *); -int platform_smp_next_cpu(struct cpuref *); -int platform_smp_get_bsp(struct cpuref *); -int platform_smp_start_cpu(struct pcpu *); -void platform_smp_timebase_sync(u_long tb, int ap); -void platform_smp_ap_init(void); -void platform_smp_probe_threads(void); -int platform_node_numa_domain(phandle_t); - -const char *installed_platform(void); -void platform_probe_and_attach(void); - -void platform_sleep(void); - -#endif /* _MACHINE_PLATFORM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/platformvar.h b/lib/libc/include/generic-freebsd/machine/platformvar.h deleted file mode 100644 index dff641944a7fb4c82a0e2a2c9bfb1817ff633a10..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/platformvar.h +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2005 Peter Grehan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_PLATFORMVAR_H_ -#define _MACHINE_PLATFORMVAR_H_ - -/* - * A PowerPC platform implementation is declared with a kernel object and - * an associated method table, similar to a device driver. - * - * e.g. - * - * static platform_method_t chrp_methods[] = { - * PLATFORMMETHOD(platform_probe, chrp_probe), - * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions), - * ... - * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu), - * { 0, 0 } - * }; - * - * static platform_def_t chrp_platform = { - * "chrp", - * chrp_methods, - * sizeof(chrp_platform_softc), // or 0 if no softc - * }; - * - * PLATFORM_DEF(chrp_platform); - */ - -#include - -struct platform_kobj { - /* - * A platform instance is a kernel object - */ - KOBJ_FIELDS; - - /* - * Utility elements that an instance may use - */ - struct mtx platform_mtx; /* available for instance use */ - void *platform_iptr; /* instance data pointer */ - - /* - * Opaque data that can be overlaid with an instance-private - * structure. Platform code can test that this is large enough at - * compile time with a sizeof() test againt it's softc. There - * is also a run-time test when the platform kernel object is - * registered. - */ -#define PLATFORM_OPAQUESZ 64 - u_int platform_opaque[PLATFORM_OPAQUESZ]; -}; - -typedef struct platform_kobj *platform_t; -typedef struct kobj_class platform_def_t; -#define platform_method_t kobj_method_t - -#define PLATFORMMETHOD KOBJMETHOD -#define PLATFORMMETHOD_END KOBJMETHOD_END - -#define PLATFORM_DEF(name) DATA_SET(platform_set, name) - -#endif /* _MACHINE_PLATFORMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pmap.h b/lib/libc/include/generic-freebsd/machine/pmap.h deleted file mode 100644 index 4342dd9e4c211a343b4a40b2e8b69760c104dba0..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pmap.h +++ /dev/null @@ -1,361 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause AND BSD-4-Clause - * - * Copyright (C) 2006 Semihalf, Marian Balakowicz - * All rights reserved. - * - * Adapted for Freescale's e500 core CPUs. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*- - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from: $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $ - */ - -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __powerpc64__ -#include -#endif - -/* - * The radix page table structure is described by levels 1-4. - * See Fig 33. on p. 1002 of Power ISA v3.0B - * - * Page directories and tables must be size aligned. - */ - -/* Root page directory - 64k -- each entry covers 512GB */ -typedef uint64_t pml1_entry_t; -/* l2 page directory - 4k -- each entry covers 1GB */ -typedef uint64_t pml2_entry_t; -/* l3 page directory - 4k -- each entry covers 2MB */ -typedef uint64_t pml3_entry_t; -/* l4 page directory - 256B/4k -- each entry covers 64k/4k */ -typedef uint64_t pml4_entry_t; - -typedef uint64_t pt_entry_t; - -struct pmap; -typedef struct pmap *pmap_t; - -#define PMAP_ENTER_QUICK_LOCKED 0x10000000 - -#if !defined(NPMAPS) -#define NPMAPS 32768 -#endif /* !defined(NPMAPS) */ - -struct slbtnode; - -struct pvo_entry { - LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */ -#ifndef __powerpc64__ - LIST_ENTRY(pvo_entry) pvo_olink; /* Link to overflow entry */ -#endif - union { - RB_ENTRY(pvo_entry) pvo_plink; /* Link to pmap entries */ - SLIST_ENTRY(pvo_entry) pvo_dlink; /* Link to delete enty */ - }; - struct { -#ifndef __powerpc64__ - /* 32-bit fields */ - pte_t pte; -#endif - /* 64-bit fields */ - uintptr_t slot; - vm_paddr_t pa; - vm_prot_t prot; - } pvo_pte; - pmap_t pvo_pmap; /* Owning pmap */ - vm_offset_t pvo_vaddr; /* VA of entry */ - uint64_t pvo_vpn; /* Virtual page number */ -}; -LIST_HEAD(pvo_head, pvo_entry); -SLIST_HEAD(pvo_dlist, pvo_entry); -RB_HEAD(pvo_tree, pvo_entry); -int pvo_vaddr_compare(struct pvo_entry *, struct pvo_entry *); -RB_PROTOTYPE(pvo_tree, pvo_entry, pvo_plink, pvo_vaddr_compare); - -/* Used by 32-bit PMAP */ -#define PVO_PTEGIDX_MASK 0x007UL /* which PTEG slot */ -#define PVO_PTEGIDX_VALID 0x008UL /* slot is valid */ -/* Used by 64-bit PMAP */ -#define PVO_HID 0x008UL /* PVO entry in alternate hash*/ -/* Used by both */ -#define PVO_WIRED 0x010UL /* PVO entry is wired */ -#define PVO_MANAGED 0x020UL /* PVO entry is managed */ -#define PVO_BOOTSTRAP 0x080UL /* PVO entry allocated during - bootstrap */ -#define PVO_DEAD 0x100UL /* waiting to be deleted */ -#define PVO_LARGE 0x200UL /* large page */ -#define PVO_VADDR(pvo) ((pvo)->pvo_vaddr & ~ADDR_POFF) -#define PVO_PTEGIDX_GET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK) -#define PVO_PTEGIDX_ISSET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_VALID) -#define PVO_PTEGIDX_CLR(pvo) \ - ((void)((pvo)->pvo_vaddr &= ~(PVO_PTEGIDX_VALID|PVO_PTEGIDX_MASK))) -#define PVO_PTEGIDX_SET(pvo, i) \ - ((void)((pvo)->pvo_vaddr |= (i)|PVO_PTEGIDX_VALID)) -#define PVO_VSID(pvo) ((pvo)->pvo_vpn >> 16) - -struct pmap { - struct pmap_statistics pm_stats; - struct mtx pm_mtx; - cpuset_t pm_active; - union { - struct { - #ifdef __powerpc64__ - struct slbtnode *pm_slb_tree_root; - struct slb **pm_slb; - int pm_slb_len; - #else - register_t pm_sr[16]; - #endif - - struct pmap *pmap_phys; - struct pvo_tree pmap_pvo; - }; -#ifdef __powerpc64__ - /* Radix support */ - struct { - pml1_entry_t *pm_pml1; /* KVA of root page directory */ - struct vm_radix pm_radix; /* spare page table pages */ - TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ - uint64_t pm_pid; /* PIDR value */ - int pm_flags; - }; -#endif - struct { - /* TID to identify this pmap entries in TLB */ - tlbtid_t pm_tid[MAXCPU]; - -#ifdef __powerpc64__ - /* - * Page table directory, - * array of pointers to page directories. - */ - pte_t ****pm_root; -#else - /* - * Page table directory, - * array of pointers to page tables. - */ - pte_t **pm_pdir; - - /* List of allocated ptbl bufs (ptbl kva regions). */ - TAILQ_HEAD(, ptbl_buf) pm_ptbl_list; -#endif - }; - } __aligned(CACHE_LINE_SIZE); -}; - -/* - * pv_entries are allocated in chunks per-process. This avoids the - * need to track per-pmap assignments. - */ -#define _NPCPV 126 -#define _NPCM howmany(_NPCPV, 64) - -#define PV_CHUNK_HEADER \ - pmap_t pc_pmap; \ - TAILQ_ENTRY(pv_chunk) pc_list; \ - uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \ - TAILQ_ENTRY(pv_chunk) pc_lru; - -struct pv_entry { - pmap_t pv_pmap; - vm_offset_t pv_va; - TAILQ_ENTRY(pv_entry) pv_link; -}; -typedef struct pv_entry *pv_entry_t; - -struct pv_chunk_header { - PV_CHUNK_HEADER -}; -struct pv_chunk { - PV_CHUNK_HEADER - uint64_t reserved; - struct pv_entry pc_pventry[_NPCPV]; -}; - -struct md_page { - union { - struct { - volatile int32_t mdpg_attrs; - vm_memattr_t mdpg_cache_attrs; - struct pvo_head mdpg_pvoh; - int pv_gen; /* (p) */ - }; - struct { - int pv_tracked; - }; - }; - TAILQ_HEAD(, pv_entry) pv_list; /* (p) */ -}; - -#ifdef AIM -#define pmap_page_get_memattr(m) ((m)->md.mdpg_cache_attrs) -#else -#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT -#endif /* AIM */ - -/* - * Return the VSID corresponding to a given virtual address. - * If no VSID is currently defined, it will allocate one, and add - * it to a free slot if available. - * - * NB: The PMAP MUST be locked already. - */ -uint64_t va_to_vsid(pmap_t pm, vm_offset_t va); - -/* Lock-free, non-allocating lookup routines */ -uint64_t kernel_va_to_slbv(vm_offset_t va); -struct slb *user_va_to_slb_entry(pmap_t pm, vm_offset_t va); - -uint64_t allocate_user_vsid(pmap_t pm, uint64_t esid, int large); -void free_vsid(pmap_t pm, uint64_t esid, int large); -void slb_insert_user(pmap_t pm, struct slb *slb); -void slb_insert_kernel(uint64_t slbe, uint64_t slbv); - -struct slbtnode *slb_alloc_tree(void); -void slb_free_tree(pmap_t pm); -struct slb **slb_alloc_user_cache(void); -void slb_free_user_cache(struct slb **); - -extern struct pmap kernel_pmap_store; -#define kernel_pmap (&kernel_pmap_store) - -#ifdef _KERNEL - -#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) -#define PMAP_LOCK_ASSERT(pmap, type) \ - mtx_assert(&(pmap)->pm_mtx, (type)) -#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) -#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, \ - (pmap == kernel_pmap) ? "kernelpmap" : \ - "pmap", NULL, MTX_DEF | MTX_DUPOK) -#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) -#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) -#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) -#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) - -#define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) - -#define pmap_vm_page_alloc_check(m) - -void pmap_bootstrap(vm_offset_t, vm_offset_t); -void pmap_kenter(vm_offset_t va, vm_paddr_t pa); -void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t); -void pmap_kremove(vm_offset_t); -void *pmap_mapdev(vm_paddr_t, vm_size_t); -void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t); -void pmap_unmapdev(void *, vm_size_t); -void pmap_page_set_memattr(vm_page_t, vm_memattr_t); -int pmap_change_attr(vm_offset_t, vm_size_t, vm_memattr_t); -int pmap_map_user_ptr(pmap_t pm, volatile const void *uaddr, - void **kaddr, size_t ulen, size_t *klen); -int pmap_decode_kernel_ptr(vm_offset_t addr, int *is_user, - vm_offset_t *decoded_addr); -void pmap_deactivate(struct thread *); -vm_paddr_t pmap_kextract(vm_offset_t); -int pmap_dev_direct_mapped(vm_paddr_t, vm_size_t); -boolean_t pmap_mmu_install(char *name, int prio); -void pmap_mmu_init(void); -const char *pmap_mmu_name(void); -bool pmap_ps_enabled(pmap_t pmap); -int pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t flags); -boolean_t pmap_page_is_mapped(vm_page_t m); -#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva) - -void pmap_page_array_startup(long count); - -#define vtophys(va) pmap_kextract((vm_offset_t)(va)) - -extern vm_offset_t virtual_avail; -extern vm_offset_t virtual_end; -extern caddr_t crashdumpmap; - -extern vm_offset_t msgbuf_phys; - -extern int pmap_bootstrapped; -extern int radix_mmu; -extern int superpages_enabled; - -#ifdef AIM -void pmap_early_io_map_init(void); -#endif -vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size); -void pmap_early_io_unmap(vm_offset_t va, vm_size_t size); -void pmap_track_page(pmap_t pmap, vm_offset_t va); -void pmap_page_print_mappings(vm_page_t m); -void pmap_tlbie_all(void); - -static inline int -pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) -{ - - return (0); -} - -#endif - -#endif /* !_MACHINE_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pmc_mdep.h b/lib/libc/include/generic-freebsd/machine/pmc_mdep.h deleted file mode 100644 index 3e772d63864fca9b5dec3388a3775dddad33221a..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pmc_mdep.h +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#ifndef _MACHINE_PMC_MDEP_H_ -#define _MACHINE_PMC_MDEP_H_ - -#define PMC_MDEP_CLASS_INDEX_POWERPC 1 - -union pmc_md_op_pmcallocate { - uint32_t pm_event; - uint64_t __pad[4]; -}; - -/* Logging */ -#ifdef __powerpc64__ -#define PMCLOG_READADDR PMCLOG_READ64 -#define PMCLOG_EMITADDR PMCLOG_EMIT64 -#else -#define PMCLOG_READADDR PMCLOG_READ32 -#define PMCLOG_EMITADDR PMCLOG_EMIT32 -#endif - -#define mtpmr(reg, val) \ - __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val)) -#define mfpmr(reg) \ - ( { register_t val; \ - __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg)); \ - val; } ) - -#define PMR_PMC0 16 -#define PMR_PMC1 17 -#define PMR_PMC2 18 -#define PMR_PMC3 19 -#define PMR_PMLCa0 144 -#define PMLCax_FC 0x80000000 -#define PMLCax_FCS 0x40000000 -#define PMLCax_FCU 0x20000000 -#define PMLCax_FCM1 0x10000000 -#define PMLCax_FCM0 0x08000000 -#define PMLCax_CE 0x04000000 -#define PMLCax_EVENT(x) ((x) << 16) -#define PMLCax_FCGS1 0x00000002 -#define PMLCax_FCGS0 0x00000001 -#define PMR_PMLCa1 145 -#define PMR_PMLCa2 146 -#define PMR_PMLCa3 147 -#define PMR_PMLCb0 272 -#define PMLCbx_TRIGONCTL(x) ((x) << 28) -#define PMLCbx_TRIGOFFCTL(x) ((x) << 24) -#define PMLCbx_PMCC 0x00800000 -#define PMLCbx_PMP(x) ((x) << 13) -#define PMLCbx_TREHMUL(x) ((x) << 8) -#define PMLCbx_TRESHOLD(x) ((x) << 0) -#define PMR_PMLCb1 273 -#define PMR_PMLCb2 274 -#define PMR_PMLCb3 275 -#define PMR_PMGC0 400 -#define PMGC_FAC 0x80000000 -#define PMGC_PMIE 0x40000000 -#define PMGC_FCECE 0x20000000 -#define PMGC_TBSEL(x) ((x) << 11) -#define PMGC_TBEE 0x00000100 -#define PMR_UPMC0 0 -#define PMR_UPMC1 1 -#define PMR_UPMC2 2 -#define PMR_UPMC3 3 -#define PMR_UPMLCa0 128 -#define PMR_UPMLCa1 129 -#define PMR_UPMLCa2 130 -#define PMR_UPMLCa3 131 -#define PMR_UPMLCb0 256 -#define PMR_UPMLCb1 257 -#define PMR_UPMLCb2 258 -#define PMR_UPMLCb3 259 -#define PMR_UPMGC0 384 - -#if _KERNEL - -struct pmc_md_powerpc_pmc { - uint64_t pm_powerpc_overflowcnt; - uint32_t pm_powerpc_evsel; -}; - -union pmc_md_pmc { - struct pmc_md_powerpc_pmc pm_powerpc; -}; - -#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0) -#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1]) -#define PMC_TRAPFRAME_TO_SP(TF) (0) - -#endif - -#endif /* !_MACHINE_PMC_MDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/proc.h b/lib/libc/include/generic-freebsd/machine/proc.h deleted file mode 100644 index a5eeb66941386aa528815a4fa37637fbc69178d5..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/proc.h +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: proc.h,v 1.2 1997/04/16 22:57:48 thorpej Exp $ - */ - -#ifndef _MACHINE_PROC_H_ -#define _MACHINE_PROC_H_ - -/* - * Machine-dependent part of the proc structure - */ -struct mdthread { - int md_spinlock_count; /* (k) */ - register_t md_saved_msr; /* (k) */ -}; - -struct mdproc { - /* - * Avoid empty structs because they are undefined behavior. - */ - long md_spare; -}; - -#ifdef __powerpc64__ -#define KINFO_PROC_SIZE 1088 -#define KINFO_PROC32_SIZE 816 -#else -#define KINFO_PROC_SIZE 816 -#endif - -#endif /* !_MACHINE_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/profile.h b/lib/libc/include/generic-freebsd/machine/profile.h deleted file mode 100644 index 054386a5aa625eb20f065a2ecb7729c6cc7fa521..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/profile.h +++ /dev/null @@ -1,234 +0,0 @@ -/*- - * SPDX-License-Identifier: MIT-CMU - * - * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp - * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 - */ - -#ifndef _MACHINE_PROFILE_H_ -#define _MACHINE_PROFILE_H_ - -#define _MCOUNT_DECL void __mcount - -#define FUNCTION_ALIGNMENT 4 - -typedef __ptrdiff_t fptrdiff_t; - -/* - * The mcount trampoline macro, expanded in libc/gmon/mcount.c - * - * For PowerPC SVR4 ABI profiling, the compiler will insert - * a data declaration and code sequence at the start of a routine of the form - * - * .function_mc: .data - * .align 2 - * .long 0 - * .text - * - * function: mflr %r0 - * addis %r11,%r0, .function_mc@ha - * stw %r0,4(%r1) - * addi %r0,%r11, .function_mc@l - * bl _mcount - * - * The link register is saved in the LR save word in the caller's - * stack frame, r0 is set up to point to the allocated longword, - * and control is transferred to _mcount. - * - * On return from _mcount, the routine should function as it would - * with no profiling so _mcount must restore register state to that upon - * entry. Any routine called by the _mcount trampoline will save - * callee-save registers, so _mcount must make sure it saves volatile - * registers that may have state after it returns i.e. parameter registers. - * - * The FreeBSD libc mcount routine ignores the r0 longword pointer, but - * instead requires as parameters the current PC and called PC. The current - * PC is obtained from the link register, as a result of "bl _mcount" in - * the stub, while the caller's PC is obtained from the LR save word. - * - * On return from libc mcount, the return is done indirectly with the - * ctr register rather than the link register, to allow the link register - * to be restored to what it was on entry to the profiled routine. - */ - -#if defined(__powerpc64__) - -#if !defined(_CALL_ELF) || _CALL_ELF == 1 -#define MCOUNT_PREAMBLE \ - " .align 2 \n" \ - " .globl _mcount \n" \ - " .section \".opd\",\"aw\" \n" \ - " .align 3 \n" \ - "_mcount: \n" \ - " .quad .L._mcount,.TOC.@tocbase,0\n" \ - " .previous \n" \ - " .size _mcount,24 \n" \ - " .type _mcount,@function \n" \ - " .align 4 \n" \ - ".L._mcount: \n" -#else -#define MCOUNT_PREAMBLE \ - " .globl _mcount \n" \ - " .type _mcount,@function \n" \ - " .align 4 \n" \ - "_mcount: \n" -#endif - -#define MCOUNT \ -__asm( MCOUNT_PREAMBLE \ - " stdu %r1,-(288+128)(%r1) \n" \ - " std %r3,48(%r1) \n" \ - " std %r4,56(%r1) \n" \ - " std %r5,64(%r1) \n" \ - " std %r6,72(%r1) \n" \ - " std %r7,80(%r1) \n" \ - " std %r8,88(%r1) \n" \ - " std %r9,96(%r1) \n" \ - " std %r10,104(%r1) \n" \ - " mflr %r4 \n" \ - " std %r4,112(%r1) \n" \ - " ld %r3,0(%r1) \n" \ - " ld %r3,0(%r3) \n" \ - " ld %r3,16(%r3) \n" \ - " bl __mcount \n" \ - " nop \n" \ - " ld %r4,112(%r1) \n" \ - " mtlr %r4 \n" \ - " ld %r3,48(%r1) \n" \ - " ld %r4,56(%r1) \n" \ - " ld %r5,64(%r1) \n" \ - " ld %r6,72(%r1) \n" \ - " ld %r7,80(%r1) \n" \ - " ld %r8,88(%r1) \n" \ - " ld %r9,96(%r1) \n" \ - " ld %r10,104(%r1) \n" \ - " addi %r1,%r1,(288+128) \n" \ - " blr \n"); -#else - -#ifdef PIC -#define _PLT "@plt" -#else -#define _PLT -#endif - -#define MCOUNT \ -__asm( " .globl _mcount \n" \ - " .type _mcount,@function \n" \ - " .align 4 \n" \ - "_mcount: \n" \ - " stwu %r1,-64(%r1) \n" \ - " stw %r3,16(%r1) \n" \ - " stw %r4,20(%r1) \n" \ - " stw %r5,24(%r1) \n" \ - " stw %r6,28(%r1) \n" \ - " stw %r7,32(%r1) \n" \ - " stw %r8,36(%r1) \n" \ - " stw %r9,40(%r1) \n" \ - " stw %r10,44(%r1) \n" \ - " mflr %r4 \n" \ - " stw %r4,48(%r1) \n" \ - " lwz %r3,68(%r1) \n" \ - " bl __mcount" _PLT " \n" \ - " lwz %r3,68(%r1) \n" \ - " mtlr %r3 \n" \ - " lwz %r4,48(%r1) \n" \ - " mtctr %r4 \n" \ - " lwz %r3,16(%r1) \n" \ - " lwz %r4,20(%r1) \n" \ - " lwz %r5,24(%r1) \n" \ - " lwz %r6,28(%r1) \n" \ - " lwz %r7,32(%r1) \n" \ - " lwz %r8,36(%r1) \n" \ - " lwz %r9,40(%r1) \n" \ - " lwz %r10,44(%r1) \n" \ - " addi %r1,%r1,64 \n" \ - " bctr \n" \ - "_mcount_end: \n" \ - " .size _mcount,_mcount_end-_mcount"); -#endif - -#ifdef _KERNEL -#define MCOUNT_ENTER(s) s = intr_disable() -#define MCOUNT_EXIT(s) intr_restore(s) -#define MCOUNT_DECL(s) register_t s; - -#ifndef COMPILING_LINT -#ifdef AIM -#include -#define __PROFILE_VECTOR_BASE EXC_RST -#define __PROFILE_VECTOR_TOP (EXC_LAST + 0x100) -#endif /* AIM */ -#if defined(BOOKE) -extern char interrupt_vector_base[]; -extern char interrupt_vector_top[]; -#define __PROFILE_VECTOR_BASE (uintfptr_t)interrupt_vector_base -#define __PROFILE_VECTOR_TOP (uintfptr_t)interrupt_vector_top -#endif /* BOOKE_E500 */ - -#endif /* !COMPILING_LINT */ - -#ifndef __PROFILE_VECTOR_BASE -#define __PROFILE_VECTOR_BASE 0 -#endif -#ifndef __PROFILE_VECTOR_TOP -#define __PROFILE_VECTOR_TOP 1 -#endif - -static __inline void -powerpc_profile_interrupt(void) -{ -} - -static __inline void -powerpc_profile_userspace(void) -{ -} - -#define MCOUNT_FROMPC_USER(pc) \ - ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? \ - (uintfptr_t)powerpc_profile_userspace : pc) - -#define MCOUNT_FROMPC_INTR(pc) \ - ((pc >= __PROFILE_VECTOR_BASE && \ - pc < __PROFILE_VECTOR_TOP) ? \ - (uintfptr_t)powerpc_profile_interrupt : ~0U) - -void __mcount(uintfptr_t frompc, uintfptr_t selfpc); - -#else /* !_KERNEL */ - -#ifdef __powerpc64__ -typedef u_long uintfptr_t; -#else -typedef u_int uintfptr_t; -#endif - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/psl.h b/lib/libc/include/generic-freebsd/machine/psl.h index b8aed73f27df3fb8fb09300da0993f360c789f25..59536384fca5d786df3ad89e0d9cee9d9005d8ec 100644 --- a/lib/libc/include/generic-freebsd/machine/psl.h +++ b/lib/libc/include/generic-freebsd/machine/psl.h @@ -1,101 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: psl.h,v 1.5 2000/11/19 19:52:37 matt Exp $ + * This file is in the public domain. */ -#ifndef _MACHINE_PSL_H_ -#define _MACHINE_PSL_H_ - -/* - * Machine State Register (MSR) - All cores - */ -#define PSL_VEC 0x02000000UL /* AltiVec/SPE vector unit available */ -#define PSL_VSX 0x00800000UL /* Vector-Scalar unit available */ -#define PSL_EE 0x00008000UL /* external interrupt enable */ -#define PSL_PR 0x00004000UL /* privilege mode (1 == user) */ -#define PSL_FP 0x00002000UL /* floating point enable */ -#define PSL_ME 0x00001000UL /* machine check enable */ -#define PSL_FE0 0x00000800UL /* floating point interrupt mode 0 */ -#define PSL_FE1 0x00000100UL /* floating point interrupt mode 1 */ -#define PSL_PMM 0x00000004UL /* performance monitor mark */ -#define PSL_RI 0x00000002UL /* recoverable interrupt */ - -/* Machine State Register - Book-E cores */ -#ifdef __powerpc64__ -#define PSL_CM 0x80000000UL /* Computation Mode (64-bit) */ -#endif - -#define PSL_GS 0x10000000UL /* Guest state */ -#define PSL_UCLE 0x04000000UL /* User mode cache lock enable */ -#define PSL_WE 0x00040000UL /* Wait state enable */ -#define PSL_CE 0x00020000UL /* Critical interrupt enable */ -#define PSL_UBLE 0x00000400UL /* BTB lock enable - e500 only */ -#define PSL_DWE 0x00000400UL /* Debug Wait Enable - 440 only*/ -#define PSL_DE 0x00000200UL /* Debug interrupt enable */ -#define PSL_IS 0x00000020UL /* Instruction address space */ -#define PSL_DS 0x00000010UL /* Data address space */ - -/* Machine State Register (MSR) - AIM cores */ -#ifdef __powerpc64__ -#define PSL_SF 0x8000000000000000UL /* 64-bit addressing */ -#define PSL_HV 0x1000000000000000UL /* hyper-privileged mode */ -#endif - -#define PSL_POW 0x00040000UL /* power management */ -#define PSL_ILE 0x00010000UL /* interrupt endian mode (1 == le) */ -#define PSL_SE 0x00000400UL /* single-step trace enable */ -#define PSL_BE 0x00000200UL /* branch trace enable */ -#define PSL_IP 0x00000040UL /* interrupt prefix - 601 only */ -#define PSL_IR 0x00000020UL /* instruction address relocation */ -#define PSL_DR 0x00000010UL /* data address relocation */ -#define PSL_LE 0x00000001UL /* endian mode (1 == le) */ - -/* - * Floating-point exception modes: - */ -#define PSL_FE_DIS 0 /* none */ -#define PSL_FE_NONREC PSL_FE1 /* imprecise non-recoverable */ -#define PSL_FE_REC PSL_FE0 /* imprecise recoverable */ -#define PSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */ -#define PSL_FE_DFLT PSL_FE_PREC /* default == precise */ - -#ifndef LOCORE -extern register_t psl_kernset; /* Default MSR values for kernel */ -extern register_t psl_userset; /* Default MSR values for userland */ -#ifdef __powerpc64__ -extern register_t psl_userset32; /* Default user MSR values for 32-bit */ -#endif -extern register_t psl_userstatic; /* Bits of SRR1 userland may not set */ -#endif - -#endif /* _MACHINE_PSL_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/pte.h b/lib/libc/include/generic-freebsd/machine/pte.h deleted file mode 100644 index 24ef8d98694299428304ea0daa303bebf3464f7e..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/pte.h +++ /dev/null @@ -1,432 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: pte.h,v 1.2 1998/08/31 14:43:40 tsubai Exp $ - */ - -#ifndef _MACHINE_PTE_H_ -#define _MACHINE_PTE_H_ - -#if defined(AIM) - -/* - * Page Table Entries - */ -#ifndef LOCORE - -/* 32-bit PTE */ -struct pte { - u_int32_t pte_hi; - u_int32_t pte_lo; -}; - -struct pteg { - struct pte pt[8]; -}; - -/* 64-bit (long) PTE */ -struct lpte { - u_int64_t pte_hi; - u_int64_t pte_lo; -}; - -struct lpteg { - struct lpte pt[8]; -}; - -/* Partition table entry */ -struct pate { - u_int64_t pagetab; - u_int64_t proctab; -}; - -/* Process table entry */ -struct prte { - u_int64_t proctab0; - u_int64_t proctab1; -}; - -typedef struct pte pte_t; -typedef struct lpte lpte_t; -#endif /* LOCORE */ - -/* 32-bit PTE definitions */ - -/* High word: */ -#define PTE_VALID 0x80000000 -#define PTE_VSID_SHFT 7 -#define PTE_HID 0x00000040 -#define PTE_API 0x0000003f -/* Low word: */ -#define PTE_RPGN 0xfffff000 -#define PTE_REF 0x00000100 -#define PTE_CHG 0x00000080 -#define PTE_WIMG 0x00000078 -#define PTE_W 0x00000040 -#define PTE_I 0x00000020 -#define PTE_M 0x00000010 -#define PTE_G 0x00000008 -#define PTE_PP 0x00000003 -#define PTE_SO 0x00000000 /* Super. Only (U: XX, S: RW) */ -#define PTE_SW 0x00000001 /* Super. Write-Only (U: RO, S: RW) */ -#define PTE_BW 0x00000002 /* Supervisor (U: RW, S: RW) */ -#define PTE_BR 0x00000003 /* Both Read Only (U: RO, S: RO) */ -#define PTE_RW PTE_BW -#define PTE_RO PTE_BR - -#define PTE_EXEC 0x00000200 /* pseudo bit in attrs; page is exec */ - -/* 64-bit PTE definitions */ - -/* High quadword: */ -#define LPTE_VSID_SHIFT 12 -#define LPTE_AVPN_MASK 0xFFFFFFFFFFFFFF80ULL -#define LPTE_AVA_MASK 0x3FFFFFFFFFFFFF80ULL -#define LPTE_API 0x0000000000000F80ULL -#define LPTE_SWBITS 0x0000000000000078ULL -#define LPTE_WIRED 0x0000000000000010ULL -#define LPTE_LOCKED 0x0000000000000008ULL -#define LPTE_BIG 0x0000000000000004ULL /* 4kb/16Mb page */ -#define LPTE_HID 0x0000000000000002ULL -#define LPTE_VALID 0x0000000000000001ULL - -/* Low quadword: */ -#define LP_4K_16M 0x38 /* 4KB base, 16MB actual page size */ - -#define EXTEND_PTE(x) UINT64_C(x) /* make constants 64-bit */ -#define LPTE_RPGN 0xfffffffffffff000ULL -#define LPTE_LP_MASK 0x00000000000ff000ULL -#define LPTE_LP_SHIFT 12 -#define LPTE_LP_4K_16M ((unsigned long long)(LP_4K_16M) << LPTE_LP_SHIFT) -#define LPTE_REF EXTEND_PTE( PTE_REF ) -#define LPTE_CHG EXTEND_PTE( PTE_CHG ) -#define LPTE_WIMG EXTEND_PTE( PTE_WIMG ) -#define LPTE_W EXTEND_PTE( PTE_W ) -#define LPTE_I EXTEND_PTE( PTE_I ) -#define LPTE_M EXTEND_PTE( PTE_M ) -#define LPTE_G EXTEND_PTE( PTE_G ) -#define LPTE_NOEXEC 0x0000000000000004ULL -#define LPTE_PP EXTEND_PTE( PTE_PP ) - -#define LPTE_SO EXTEND_PTE( PTE_SO ) /* Super. Only */ -#define LPTE_SW EXTEND_PTE( PTE_SW ) /* Super. Write-Only */ -#define LPTE_BW EXTEND_PTE( PTE_BW ) /* Supervisor */ -#define LPTE_BR EXTEND_PTE( PTE_BR ) /* Both Read Only */ -#define LPTE_RW LPTE_BW -#define LPTE_RO LPTE_BR - -/* HPT superpage definitions */ -#define HPT_SP_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT) -#define HPT_SP_SIZE (1 << HPT_SP_SHIFT) -#define HPT_SP_MASK (HPT_SP_SIZE - 1) -#define HPT_SP_PAGES (1 << VM_LEVEL_0_ORDER) - -/* POWER ISA 3.0 Radix Table Definitions */ -#define RPTE_VALID 0x8000000000000000ULL -#define RPTE_LEAF 0x4000000000000000ULL /* is a PTE: always 1 */ -#define RPTE_SW0 0x2000000000000000ULL -#define RPTE_RPN_MASK 0x00FFFFFFFFFFF000ULL -#define RPTE_RPN_SHIFT 12 -#define RPTE_SW1 0x0000000000000800ULL -#define RPTE_SW2 0x0000000000000400ULL -#define RPTE_SW3 0x0000000000000200ULL -#define RPTE_R 0x0000000000000100ULL -#define RPTE_C 0x0000000000000080ULL - -#define RPTE_MANAGED RPTE_SW1 -#define RPTE_WIRED RPTE_SW2 -#define RPTE_PROMOTED RPTE_SW3 - -#define RPTE_ATTR_MASK 0x0000000000000030ULL -#define RPTE_ATTR_MEM 0x0000000000000000ULL /* PTE M */ -#define RPTE_ATTR_SAO 0x0000000000000010ULL /* PTE WIM */ -#define RPTE_ATTR_GUARDEDIO 0x0000000000000020ULL /* PTE IMG */ -#define RPTE_ATTR_UNGUARDEDIO 0x0000000000000030ULL /* PTE IM */ - -#define RPTE_EAA_MASK 0x000000000000000FULL -#define RPTE_EAA_P 0x0000000000000008ULL /* Supervisor only */ -#define RPTE_EAA_R 0x0000000000000004ULL /* Read allowed */ -#define RPTE_EAA_W 0x0000000000000002ULL /* Write (+read) */ -#define RPTE_EAA_X 0x0000000000000001ULL /* Execute allowed */ - -#define RPDE_VALID RPTE_VALID -#define RPDE_LEAF RPTE_LEAF /* is a PTE: always 0 */ -#define RPDE_NLB_MASK 0x00FFFFFFFFFFFF00ULL -#define RPDE_NLB_SHIFT 8 -#define RPDE_NLS_MASK 0x000000000000001FULL - -#define PG_FRAME (0x000ffffffffff000ul) -#define PG_PS_FRAME (0x000fffffffe00000ul) -/* - * Extract bits from address - */ -#define ADDR_SR_SHFT 28 -#define ADDR_PIDX 0x0ffff000UL -#define ADDR_PIDX_SHFT 12 -#define ADDR_API_SHFT 22 -#define ADDR_API_SHFT64 16 -#define ADDR_POFF 0x00000fffUL - -/* - * Bits in DSISR: - */ -#define DSISR_DIRECT 0x80000000 -#define DSISR_NOTFOUND 0x40000000 -#define DSISR_PROTECT 0x08000000 -#define DSISR_INVRX 0x04000000 -#define DSISR_STORE 0x02000000 -#define DSISR_DABR 0x00400000 -#define DSISR_SEGMENT 0x00200000 -#define DSISR_EAR 0x00100000 - -/* - * Bits in SRR1 on ISI: - */ -#define ISSRR1_NOTFOUND 0x40000000 -#define ISSRR1_DIRECT 0x10000000 -#define ISSRR1_PROTECT 0x08000000 -#define ISSRR1_SEGMENT 0x00200000 - -#else /* BOOKE */ - -#include - -/* - * Flags for pte_remove() routine. - */ -#define PTBL_HOLD 0x00000001 /* do not unhold ptbl pages */ -#define PTBL_UNHOLD 0x00000002 /* unhold and attempt to free ptbl pages */ - -#define PTBL_HOLD_FLAG(pmap) (((pmap) == kernel_pmap) ? PTBL_HOLD : PTBL_UNHOLD) - -/* - * Page Table Entry definitions and macros. - * - * RPN need only be 32-bit because Book-E has 36-bit addresses, and the smallest - * page size is 4k (12-bit mask), so RPN can really fit into 24 bits. - */ -#ifndef LOCORE -typedef uint64_t pte_t; -#endif - -/* RPN mask, TLB0 4K pages */ -#define PTE_PA_MASK PAGE_MASK - -#if defined(BOOKE_E500) - -/* PTE bits assigned to MAS2, MAS3 flags */ -#define PTE_MAS2_SHIFT 19 -#define PTE_W (MAS2_W << PTE_MAS2_SHIFT) -#define PTE_I (MAS2_I << PTE_MAS2_SHIFT) -#define PTE_M (MAS2_M << PTE_MAS2_SHIFT) -#define PTE_G (MAS2_G << PTE_MAS2_SHIFT) -#define PTE_MAS2_MASK (MAS2_G | MAS2_M | MAS2_I | MAS2_W) - -#define PTE_MAS3_SHIFT 2 -#define PTE_UX (MAS3_UX << PTE_MAS3_SHIFT) -#define PTE_SX (MAS3_SX << PTE_MAS3_SHIFT) -#define PTE_UW (MAS3_UW << PTE_MAS3_SHIFT) -#define PTE_SW (MAS3_SW << PTE_MAS3_SHIFT) -#define PTE_UR (MAS3_UR << PTE_MAS3_SHIFT) -#define PTE_SR (MAS3_SR << PTE_MAS3_SHIFT) -#define PTE_MAS3_MASK ((MAS3_UX | MAS3_SX | MAS3_UW \ - | MAS3_SW | MAS3_UR | MAS3_SR) << PTE_MAS3_SHIFT) - -#define PTE_PS_SHIFT 8 -#define PTE_PS_4KB (2 << PTE_PS_SHIFT) - -#endif - -/* Other PTE flags */ -#define PTE_VALID 0x00000001 /* Valid */ -#define PTE_MODIFIED 0x00001000 /* Modified */ -#define PTE_WIRED 0x00002000 /* Wired */ -#define PTE_MANAGED 0x00000002 /* Managed */ -#define PTE_REFERENCED 0x00040000 /* Referenced */ - -/* - * Page Table Entry definitions and macros. - * - * We use the hardware page table entry format: - * - * 63 24 23 19 18 17 14 13 12 11 8 7 6 5 4 3 2 1 0 - * --------------------------------------------------------------- - * ARPN(12:51) WIMGE R U0:U3 SW0 C PSIZE UX SX UW SW UR SR SW1 V - * --------------------------------------------------------------- - */ - -/* PTE fields. */ -#define PTE_TSIZE_SHIFT (63-54) -#define PTE_TSIZE_MASK 0x7 -#define PTE_TSIZE_SHIFT_DIRECT (63-55) -#define PTE_TSIZE_MASK_DIRECT 0xf -#define PTE_PS_DIRECT(ps) (ps<> PTE_TSIZE_SHIFT) & PTE_TSIZE_MASK) -#define PTE_TSIZE_DIRECT(pte) (int)((*pte >> PTE_TSIZE_SHIFT_DIRECT) & PTE_TSIZE_MASK_DIRECT) - -/* Macro argument must of pte_t type. */ -#define PTE_ARPN_SHIFT 12 -#define PTE_FLAGS_MASK 0x00ffffff -#define PTE_RPN_FROM_PA(pa) (((pa) & ~PAGE_MASK) << PTE_ARPN_SHIFT) -#define PTE_PA(pte) ((vm_paddr_t)(*pte >> PTE_ARPN_SHIFT) & ~PAGE_MASK) -#define PTE_ISVALID(pte) ((*pte) & PTE_VALID) -#define PTE_ISWIRED(pte) ((*pte) & PTE_WIRED) -#define PTE_ISMANAGED(pte) ((*pte) & PTE_MANAGED) -#define PTE_ISMODIFIED(pte) ((*pte) & PTE_MODIFIED) -#define PTE_ISREFERENCED(pte) ((*pte) & PTE_REFERENCED) - -#endif /* BOOKE */ - -/* Book-E page table format, broken out for the generic pmap.h. */ -#ifdef __powerpc64__ - -#include - -/* - * The virtual address is: - * - * 4K page size - * +-----+-----------+-------+-------------+-------------+----------------+ - * | - | pg_root |pdir_l1| dir# | pte# | off in 4K page | - * +-----+-----------+-------+-------------+-------------+----------------+ - * 63 52 51 39 38 30 29 ^ 21 20 ^ 12 11 0 - * | | - * index in 1 page of pointers - * - * 1st level - Root page table - * - * pp2d consists of PG_ROOT_NENTRIES entries, each being a pointer to - * second level entity, i.e. the page table directory (pdir). - */ -#define PG_ROOT_H 51 -#define PG_ROOT_L 39 -#define PG_ROOT_SIZE (1UL << PG_ROOT_L) /* va range mapped by pp2d */ -#define PG_ROOT_SHIFT PG_ROOT_L -#define PG_ROOT_NUM (PG_ROOT_H - PG_ROOT_L + 1) -#define PG_ROOT_MASK ((1 << PG_ROOT_NUM) - 1) -#define PG_ROOT_IDX(va) ((va >> PG_ROOT_SHIFT) & PG_ROOT_MASK) -#define PG_ROOT_NENTRIES (1 << PG_ROOT_NUM) -#define PG_ROOT_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry **)) */ - -/* - * 2nd level - page directory directory (pdir l1) - * - * pdir consists of PDIR_NENTRIES entries, each being a pointer to - * second level entity, i.e. the actual page table (ptbl). - */ -#define PDIR_L1_H (PG_ROOT_L-1) -#define PDIR_L1_L 30 -#define PDIR_L1_NUM (PDIR_L1_H-PDIR_L1_L+1) -#define PDIR_L1_SIZE (1 << PDIR_L1_L) /* va range mapped by pdir */ -#define PDIR_L1_MASK ((1<> PDIR_L1_SHIFT) & PDIR_L1_MASK) -#define PDIR_L1_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */ -#define PDIR_L1_PAGES ((PDIR_L1_NENTRIES * (1<> PDIR_SHIFT) & PDIR_MASK) -#define PDIR_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */ -#define PDIR_PAGES ((PDIR_NENTRIES * (1<> PTBL_SHIFT) & PTBL_MASK) -#define PTBL_ENTRY_SHIFT 3 /* log2 (sizeof (struct pte_entry)) */ -#define PTBL_PAGES ((PTBL_NENTRIES * (1<> PDIR_SHIFT) - -#define PDIR_ENTRY_SHIFT 2 /* entry size is 2^2 = 4 bytes */ - -/* - * 2nd level - page table (ptbl) - * - * Page table covers 1024 page table entries. Page - * table entry (pte) is 32 bit wide and defines mapping - * for a single page. - */ -#define PTBL_SHIFT PAGE_SHIFT -#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */ -#define PTBL_MASK ((PDIR_SIZE - 1) & ~((1 << PAGE_SHIFT) - 1)) -#define PTBL_NENTRIES 1024 /* number of pages mapped by ptbl */ - -/* Returns ptbl entry number for given va */ -#define PTBL_IDX(va) (((va) & PTBL_MASK) >> PTBL_SHIFT) - -/* Size of ptbl in pages, 1024 entries, each sizeof(struct pte_entry). */ -#define PTBL_PAGES 2 -#define PTBL_ENTRY_SHIFT 3 /* entry size is 2^3 = 8 bytes */ - -#endif -#endif /* _MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ptrace.h b/lib/libc/include/generic-freebsd/machine/ptrace.h index 2e1f48e840a2f74b96697899288853dc388106f2..0a426e24fabda625bb4750562767d4bb248dfe76 100644 --- a/lib/libc/include/generic-freebsd/machine/ptrace.h +++ b/lib/libc/include/generic-freebsd/machine/ptrace.h @@ -1,44 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2014 Justin Hibbits - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 + * This file is in the public domain. */ -#ifndef _MACHINE_PTRACE_H_ -#define _MACHINE_PTRACE_H_ - -#define __HAVE_PTRACE_MACHDEP - -#define PT_GETVRREGS (PT_FIRSTMACH + 0) -#define PT_SETVRREGS (PT_FIRSTMACH + 1) -#define PT_GETVSRREGS (PT_FIRSTMACH + 2) -#define PT_SETVSRREGS (PT_FIRSTMACH + 3) - -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/reg.h b/lib/libc/include/generic-freebsd/machine/reg.h index 743dad6839bc7f77bc8bd00f66c3e338d7d52607..419b2756cc0d2ee86d493fb6ab9a01f6efad94d1 100644 --- a/lib/libc/include/generic-freebsd/machine/reg.h +++ b/lib/libc/include/generic-freebsd/machine/reg.h @@ -1,92 +1,5 @@ -/* $NetBSD: reg.h,v 1.4 2000/06/04 09:30:44 tsubai Exp $ */ - -#ifndef _POWERPC_REG_H_ -#define _POWERPC_REG_H_ - -#include - -/* Must match struct trapframe */ -struct reg { - __register_t fixreg[32]; - __register_t lr; - __register_t cr; - __register_t xer; - __register_t ctr; - __register_t pc; -}; - -struct fpreg { - double fpreg[32]; - double fpscr; -}; - -/* Must match pcb.pcb_vec */ -struct vmxreg { - __uint32_t vr[32][4]; - __uint32_t pad[2]; - __uint32_t vrsave; - __uint32_t vscr; -}; - -struct dbreg { - unsigned int junk; -}; - -#ifdef __LP64__ -/* Must match struct trapframe */ -struct reg32 { - __int32_t fixreg[32]; - __int32_t lr; - __int32_t cr; - __int32_t xer; - __int32_t ctr; - __int32_t pc; -}; - -struct fpreg32 { - struct fpreg data; -}; - -struct vmxreg32 { - struct vmxreg data; -}; - -struct dbreg32 { - struct dbreg data; -}; - -#define __HAVE_REG32 -#endif - -#ifdef _KERNEL -/* - * XXX these interfaces are MI, so they should be declared in a MI place. - */ -int fill_regs(struct thread *, struct reg *); -int set_regs(struct thread *, struct reg *); -int fill_fpregs(struct thread *, struct fpreg *); -int set_fpregs(struct thread *, struct fpreg *); -int fill_dbregs(struct thread *, struct dbreg *); -int set_dbregs(struct thread *, struct dbreg *); - -/* - * MD interfaces. +/*- + * This file is in the public domain. */ -void cpu_save_thread_regs(struct thread *); - -#ifdef COMPAT_FREEBSD32 -struct image_params; - -int fill_regs32(struct thread *, struct reg32 *); -int set_regs32(struct thread *, struct reg32 *); -void ppc32_setregs(struct thread *, struct image_params *, uintptr_t); - -#define fill_fpregs32(td, reg) fill_fpregs(td,(struct fpreg *)reg) -#define set_fpregs32(td, reg) set_fpregs(td,(struct fpreg *)reg) -#define fill_dbregs32(td, reg) fill_dbregs(td,(struct dbreg *)reg) -#define set_dbregs32(td, reg) set_dbregs(td,(struct dbreg *)reg) -#endif - -#endif -#endif /* _POWERPC_REG_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/reloc.h b/lib/libc/include/generic-freebsd/machine/reloc.h index 592510637e39dc3c968c945e19fe35c21e13cedc..497e91c8e25bcd4d83ef61084a7eb8465ebacebb 100644 --- a/lib/libc/include/generic-freebsd/machine/reloc.h +++ b/lib/libc/include/generic-freebsd/machine/reloc.h @@ -1,8 +1,8 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 1998 John Birrell . - * All rights reserved. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,11 +12,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the names of any co-contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE @@ -27,4 +27,22 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - */ \ No newline at end of file + */ + +#ifndef _I386_MACHINE_RELOC_H_ +#define _I386_MACHINE_RELOC_H_ + +/* Relocation format. */ +struct relocation_info { + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ + r_pcrel : 1, /* 1 if value should be pc-relative */ + r_length : 2, /* log base 2 of value's width */ + r_extern : 1, /* 1 if need to add symbol to value */ + r_baserel : 1, /* linkage table relative */ + r_jmptable : 1, /* relocate to jump table */ + r_relative : 1, /* load address relative */ + r_copy : 1; /* run time copy */ +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/resource.h b/lib/libc/include/generic-freebsd/machine/resource.h deleted file mode 100644 index 4c356f38308e156c31327dfeaa387b50d2463795..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/resource.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RESOURCE_H_ -#define _MACHINE_RESOURCE_H_ 1 - -/* - * Definitions of resource types for Intel Architecture machines - * with support for legacy ISA devices and drivers. - */ - -#define SYS_RES_IRQ 1 /* interrupt lines */ -#define SYS_RES_DRQ 2 /* isa dma lines */ -#define SYS_RES_MEMORY 3 /* i/o memory */ -#define SYS_RES_IOPORT 4 /* i/o ports */ -#define PCI_RES_BUS 5 /* PCI bus numbers */ - -#endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/rtas.h b/lib/libc/include/generic-freebsd/machine/rtas.h deleted file mode 100644 index 0c27e31fb6b902002dc0808a0d2df5df5ba33b20..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/rtas.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2011 Nathan Whitehorn - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RTAS_H_ -#define _MACHINE_RTAS_H_ - -#include -#include -#include - -/* - * RTAS functions are defined by 32-bit integer tokens. These vary from - * system to system, and can be looked up from their standardized names - * using rtas_token_lookup(). If RTAS is not available, rtas_token_lookup() - * and rtas_call_method() return -1; this can be checked in advance using - * rtas_exists(). Otherwise, rtas_call_method() returns one of the RTAS - * status codes from the bottom of this file. - */ - -int rtas_exists(void); -int rtas_call_method(cell_t token, int nargs, int nreturns, ...); -cell_t rtas_token_lookup(const char *method); - -/* RTAS Status Codes: see CHRP or PAPR specification */ -#define RTAS_OK 0 -#define RTAS_HW_ERROR -1 -#define RTAS_BUSY -2 -#define RTAS_PARAM_ERROR -3 -#define RTAS_STATE_CHANGE -7 -#define RTAS_VENDOR_BEGIN 9000 -#define RTAS_EXTENDED_DELAY 9900 -#define RTAS_ISOLATION_ERROR -9000 -#define RTAS_VENDOR_ERROR_BEGIN -9004 - -#endif /* _MACHINE_RTAS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/runq.h b/lib/libc/include/generic-freebsd/machine/runq.h deleted file mode 100644 index e321547c218f9128d6fd1be9a8713e8b5e0c4405..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/runq.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#ifdef __powerpc64__ -#define RQB_LEN (1UL) /* Number of priority status words. */ -#define RQB_L2BPW (6UL) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#else -#define RQB_LEN (2) /* Number of priority status words. */ -#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#endif -#define RQB_BPW (1UL<> RQB_L2BPW) - -#define RQB_FFS(word) (ffsl(word) - 1) - -/* - * Type of run queue status word. - */ -#ifdef __powerpc64__ -typedef u_int64_t rqb_word_t; -#else -typedef u_int32_t rqb_word_t; -#endif - -#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/sdt_machdep.h b/lib/libc/include/generic-freebsd/machine/sdt_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..1b4d9152d2ec29b021b74991296dc604add90842 --- /dev/null +++ b/lib/libc/include/generic-freebsd/machine/sdt_machdep.h @@ -0,0 +1,12 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Mark Johnston + */ + +#ifndef _SYS_SDT_MACHDEP_H_ +#define _SYS_SDT_MACHDEP_H_ + +#define _SDT_ASM_PATCH_INSTR "nop" + +#endif /* _SYS_SDT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/setjmp.h b/lib/libc/include/generic-freebsd/machine/setjmp.h index fcc287508602b69bbd7b622f8a3c985023a1e710..41ef6217a78d6c901bb819cbf79f593f5a4effff 100644 --- a/lib/libc/include/generic-freebsd/machine/setjmp.h +++ b/lib/libc/include/generic-freebsd/machine/setjmp.h @@ -1,27 +1,5 @@ /*- - * $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $ + * This file is in the public domain. */ -#ifndef _MACHINE_SETJMP_H_ -#define _MACHINE_SETJMP_H_ - -#include - -#ifdef _KERNEL -#define _JBLEN 25 /* Kernel doesn't save FP and Altivec regs */ -#else -#define _JBLEN 100 -#endif - -/* - * jmp_buf and sigjmp_buf are encapsulated in different structs to force - * compile-time diagnostics for mismatches. The structs are the same - * internally to avoid some run-time errors for mismatches. - */ -#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE -typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1]; -#endif - -typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1]; - -#endif /* !_MACHINE_SETJMP_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/signal.h b/lib/libc/include/generic-freebsd/machine/signal.h deleted file mode 100644 index 59df51d1fa51404dcf28cac3475f0d896732313d..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/signal.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $ - */ - -#ifndef _MACHINE_SIGNAL_H_ -#define _MACHINE_SIGNAL_H_ - -#include - -typedef int sig_atomic_t; - -#if __BSD_VISIBLE -#include - -struct sigcontext { - int sc_onstack; /* saved onstack flag */ - int __sc_mask13; /* saved signal mask (old style) */ - struct trapframe sc_frame; /* saved registers */ - struct __sigset sc_mask; /* saved signal mask (new style) */ -}; -#endif - -#endif /* !_MACHINE_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/slb.h b/lib/libc/include/generic-freebsd/machine/slb.h deleted file mode 100644 index 38bee5fbc00fe158c44b9b656a9f4a600f6e0763..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/slb.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (C) 2009 Nathan Whitehorn - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_SLB_H_ -#define _MACHINE_SLB_H_ - -/* - * Bit definitions for segment lookaside buffer entries. - * - * PowerPC Microprocessor Family: The Programming Environments for 64-bit - * Microprocessors, section 7.4.2.1 - * - * Note that these bitmasks are relative to the values for one of the two - * values for slbmte, slbmfee, and slbmfev, not the internal SLB - * representation. - */ - -#define SLBV_KS 0x0000000000000800UL /* Supervisor-state prot key */ -#define SLBV_KP 0x0000000000000400UL /* User-state prot key */ -#define SLBV_N 0x0000000000000200UL /* No-execute protection */ -#define SLBV_L 0x0000000000000100UL /* Large page selector */ -#define SLBV_CLASS 0x0000000000000080UL /* Class selector */ -#define SLBV_VSID_MASK 0xfffffffffffff000UL /* Virtual segment ID mask */ -#define SLBV_VSID_SHIFT 12 - -/* - * Make a predictable 1:1 map from ESIDs to VSIDs for the kernel. Hash table - * coverage is increased by swizzling the ESID and multiplying by a prime - * number (0x13bb). - */ -#define KERNEL_VSID_BIT 0x0000001000000000UL /* Bit set in all kernel VSIDs */ -#define KERNEL_VSID(esid) ((((((uint64_t)esid << 8) | ((uint64_t)esid >> 28)) \ - * 0x13bbUL) & (KERNEL_VSID_BIT - 1)) | \ - KERNEL_VSID_BIT) - -#define SLBE_VALID 0x0000000008000000UL /* SLB entry valid */ -#define SLBE_INDEX_MASK 0x0000000000000fffUL /* SLB index mask*/ -#define SLBE_ESID_MASK 0xfffffffff0000000UL /* Effective segment ID mask */ -#define SLBE_ESID_SHIFT 28 - -/* - * SLB page sizes encoding, as present in property ibm,segment-page-sizes - * of CPU device tree node. - * - * See LoPAPR: CPU Node Properties, section C.6.1.4. - */ -#define SLB_PGSZ_4K_4K 0 - -/* Virtual real-mode VSID in LPARs */ -#define VSID_VRMA 0x1ffffff - -/* - * User segment for copyin/out - */ -#define USER_SLB_SLOT 0 -#define USER_SLB_SLBE (((USER_ADDR >> ADDR_SR_SHFT) << SLBE_ESID_SHIFT) | \ - SLBE_VALID | USER_SLB_SLOT) - -struct slb { - uint64_t slbv; - uint64_t slbe; -}; - -struct pmap; -void handle_kernel_slb_spill(int, register_t, register_t); -int handle_user_slb_spill(struct pmap *pm, vm_offset_t addr); - -#endif /* !_MACHINE_SLB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/smp.h b/lib/libc/include/generic-freebsd/machine/smp.h deleted file mode 100644 index 5af3459aff21f93ea0e000730d46ba9d24ea9456..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/smp.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2008 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_SMP_H_ -#define _MACHINE_SMP_H_ - -#ifdef _KERNEL - -#define IPI_AST 0 -#define IPI_PREEMPT 1 -#define IPI_RENDEZVOUS 2 -#define IPI_STOP 3 -#define IPI_STOP_HARD 3 -#define IPI_HARDCLOCK 4 - -#ifndef LOCORE - -#include -#include - -void ipi_all_but_self(int ipi); -void ipi_cpu(int cpu, u_int ipi); -void ipi_selected(cpuset_t cpus, int ipi); - -struct cpuref { - uintptr_t cr_hwref; - u_int cr_cpuid; - u_int cr_domain; -}; - -void pmap_cpu_bootstrap(int); -void cpudep_ap_early_bootstrap(void); -uintptr_t cpudep_ap_bootstrap(void); -void cpudep_ap_setup(void); -void machdep_ap_bootstrap(void); - -#endif /* !LOCORE */ -#endif /* _KERNEL */ -#endif /* !_MACHINE_SMP_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/spr.h b/lib/libc/include/generic-freebsd/machine/spr.h deleted file mode 100644 index 8e3c4fc936fe4b21c1d1683d5ecbfef5b4ef3414..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/spr.h +++ /dev/null @@ -1,863 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: spr.h,v 1.25 2002/08/14 15:38:40 matt Exp $ - */ -#ifndef _POWERPC_SPR_H_ -#define _POWERPC_SPR_H_ - -#ifndef _LOCORE -#define mtspr(reg, val) \ - __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val)) -#define mfspr(reg) \ - ( { register_t val; \ - __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \ - val; } ) - -#ifndef __powerpc64__ - -/* The following routines allow manipulation of the full 64-bit width - * of SPRs on 64 bit CPUs in bridge mode */ - -#define mtspr64(reg,valhi,vallo,scratch) \ - __asm __volatile(" \ - mfmsr %0; \ - insrdi %0,%5,1,0; \ - mtmsrd %0; \ - isync; \ - \ - sld %1,%1,%4; \ - or %1,%1,%2; \ - mtspr %3,%1; \ - srd %1,%1,%4; \ - \ - clrldi %0,%0,1; \ - mtmsrd %0; \ - isync;" \ - : "=r"(scratch), "=r"(valhi) : "r"(vallo), "K"(reg), "r"(32), "r"(1)) - -#define mfspr64upper(reg,scratch) \ - ( { register_t val; \ - __asm __volatile(" \ - mfmsr %0; \ - insrdi %0,%4,1,0; \ - mtmsrd %0; \ - isync; \ - \ - mfspr %1,%2; \ - srd %1,%1,%3; \ - \ - clrldi %0,%0,1; \ - mtmsrd %0; \ - isync;" \ - : "=r"(scratch), "=r"(val) : "K"(reg), "r"(32), "r"(1)); \ - val; } ) - -#endif - -#endif /* _LOCORE */ - -/* - * Special Purpose Register declarations. - * - * The first column in the comments indicates which PowerPC - * architectures the SPR is valid on - 4 for 4xx series, - * 6 for 6xx/7xx series and 8 for 8xx and 8xxx series. - */ - -#define SPR_MQ 0x000 /* .6. 601 MQ register */ -#define SPR_XER 0x001 /* 468 Fixed Point Exception Register */ -#define SPR_DSCR 0x003 /* .6. Data Stream Control Register (Unprivileged) */ -#define SPR_RTCU_R 0x004 /* .6. 601 RTC Upper - Read */ -#define SPR_RTCL_R 0x005 /* .6. 601 RTC Lower - Read */ -#define SPR_LR 0x008 /* 468 Link Register */ -#define SPR_CTR 0x009 /* 468 Count Register */ -#define SPR_DSCRP 0x011 /* Data Stream Control Register (Privileged) */ -#define SPR_DSISR 0x012 /* .68 DSI exception source */ -#define DSISR_DIRECT 0x80000000 /* Direct-store error exception */ -#define DSISR_NOTFOUND 0x40000000 /* Translation not found */ -#define DSISR_PROTECT 0x08000000 /* Memory access not permitted */ -#define DSISR_INVRX 0x04000000 /* Reserve-indexed insn direct-store access */ -#define DSISR_STORE 0x02000000 /* Store operation */ -#define DSISR_DABR 0x00400000 /* DABR match */ -#define DSISR_SEGMENT 0x00200000 /* XXX; not in 6xx PEM */ -#define DSISR_EAR 0x00100000 /* eciwx/ecowx && EAR[E] == 0 */ -#define DSISR_MC_UE_DEFERRED 0x00008000 /* UE deferred error */ -#define DSISR_MC_UE_TABLEWALK 0x00004000 /* UE deferred error during tablewalk */ -#define DSISR_MC_DERAT_MULTIHIT 0x00000800 /* D-ERAT multi-hit */ -#define DSISR_MC_TLB_MULTIHIT 0x00000400 /* TLB multi-hit */ -#define DSISR_MC_TLBIE_ERR 0x00000200 /* TLBIE or TLBIEL programming error */ -#define DSISR_MC_SLB_PARITY 0x00000100 /* SLB parity error */ -#define DSISR_MC_SLB_MULTIHIT 0x00000080 /* SLB Multi-hit detected (D-side) */ -#define DSISR_MC_BAD_REAL_LD 0x00000040 /* Bad real address for load. */ -#define DSISR_MC_BAD_ADDR 0x00000020 /* Bad address for load or store tablewalk */ -#define SPR_DAR 0x013 /* .68 Data Address Register */ -#define SPR_RTCU_W 0x014 /* .6. 601 RTC Upper - Write */ -#define SPR_RTCL_W 0x015 /* .6. 601 RTC Lower - Write */ -#define SPR_DEC 0x016 /* .68 DECrementer register */ -#define SPR_SDR1 0x019 /* .68 Page table base address register */ -#define SPR_SRR0 0x01a /* 468 Save/Restore Register 0 */ -#define SPR_SRR1 0x01b /* 468 Save/Restore Register 1 */ -#define SRR1_ISI_PFAULT 0x40000000 /* ISI page not found */ -#define SRR1_ISI_NOEXECUTE 0x10000000 /* Memory marked no-execute */ -#define SRR1_ISI_PP 0x08000000 /* PP bits forbid access */ -#define SRR1_MCHK_DATA 0x00200000 /* Machine check data in DSISR */ -#define SRR1_MCHK_IFETCH_M 0x081c0000 /* Machine check instr fetch mask */ -#define SRR1_MCHK_IFETCH_SLBMH 0x000c0000 /* SLB multihit */ -#define SPR_CFAR 0x01c /* Come From Address Register */ -#define SPR_AMR 0x01d /* Authority Mask Register */ - -#define SPR_PID 0x030 /* 4.. Process ID */ - -#define SPR_DECAR 0x036 /* ..8 Decrementer auto reload */ -#define SPR_IAMR 0x03d /* Instr. Authority Mask Reg */ - -#define SPR_EIE 0x050 /* ..8 Exception Interrupt ??? */ -#define SPR_EID 0x051 /* ..8 Exception Interrupt ??? */ -#define SPR_NRI 0x052 /* ..8 Exception Interrupt ??? */ -#define SPR_FSCR 0x099 /* Facility Status and Control Register */ -#define FSCR_IC_MASK 0xFF00000000000000ULL /* FSCR[0:7] is Interrupt Cause */ -#define FSCR_IC_FP 0x0000000000000000ULL /* FP unavailable */ -#define FSCR_IC_VSX 0x0100000000000000ULL /* VSX unavailable */ -#define FSCR_IC_DSCR 0x0200000000000000ULL /* Access to the DSCR at SPRs 3 or 17 */ -#define FSCR_IC_PM 0x0300000000000000ULL /* Read or write access of a Performance Monitor SPR in group A */ -#define FSCR_IC_BHRB 0x0400000000000000ULL /* Execution of a BHRB Instruction */ -#define FSCR_IC_HTM 0x0500000000000000ULL /* Access to a Transactional Memory */ -/* Reserved 0x0600000000000000ULL */ -#define FSCR_IC_EBB 0x0700000000000000ULL /* Access to Event-Based Branch */ -#define FSCR_IC_TAR 0x0800000000000000ULL /* Access to Target Address Register */ -#define FSCR_IC_STOP 0x0900000000000000ULL /* Access to the 'stop' instruction in privileged non-hypervisor state */ -#define FSCR_IC_MSG 0x0A00000000000000ULL /* Access to 'msgsndp' or 'msgclrp' instructions */ -#define FSCR_IC_LM 0x0A00000000000000ULL /* Access to load monitored facility */ -#define FSCR_IC_SCV 0x0C00000000000000ULL /* Execution of a 'scv' instruction */ -#define FSCR_SCV 0x0000000000001000 /* scv instruction available */ -#define FSCR_LM 0x0000000000000800 /* Load monitored facilities available */ -#define FSCR_MSGP 0x0000000000000400 /* msgsndp and SPRs available */ -#define FSCR_TAR 0x0000000000000100 /* TAR register available */ -#define FSCR_EBB 0x0000000000000080 /* Event-based branch available */ -#define FSCR_DSCR 0x0000000000000004 /* DSCR available in PR state */ -#define SPR_UAMOR 0x09d /* User Authority Mask Override Register */ -#define SPR_DPDES 0x0b0 /* .6. Directed Privileged Doorbell Exception State Register */ -#define SPR_USPRG0 0x100 /* 4.8 User SPR General 0 */ -#define SPR_VRSAVE 0x100 /* .6. AltiVec VRSAVE */ -#define SPR_SPRG0 0x110 /* 468 SPR General 0 */ -#define SPR_SPRG1 0x111 /* 468 SPR General 1 */ -#define SPR_SPRG2 0x112 /* 468 SPR General 2 */ -#define SPR_SPRG3 0x113 /* 468 SPR General 3 */ -#define SPR_SPRG4 0x114 /* 4.8 SPR General 4 */ -#define SPR_SPRG5 0x115 /* 4.8 SPR General 5 */ -#define SPR_SPRG6 0x116 /* 4.8 SPR General 6 */ -#define SPR_SPRG7 0x117 /* 4.8 SPR General 7 */ -#define SPR_SCOMC 0x114 /* ... SCOM Address Register (970) */ -#define SPR_SCOMD 0x115 /* ... SCOM Data Register (970) */ -#define SPR_ASR 0x118 /* ... Address Space Register (PPC64) */ -#define SPR_EAR 0x11a /* .68 External Access Register */ -#define SPR_PVR 0x11f /* 468 Processor Version Register */ -#define MPC601 0x0001 -#define MPC603 0x0003 -#define MPC604 0x0004 -#define MPC602 0x0005 -#define MPC603e 0x0006 -#define MPC603ev 0x0007 -#define MPC750 0x0008 -#define MPC750CL 0x7000 /* Nintendo Wii's Broadway */ -#define MPC604ev 0x0009 -#define MPC7400 0x000c -#define MPC620 0x0014 -#define IBM403 0x0020 -#define IBM401A1 0x0021 -#define IBM401B2 0x0022 -#define IBM401C2 0x0023 -#define IBM401D2 0x0024 -#define IBM401E2 0x0025 -#define IBM401F2 0x0026 -#define IBM401G2 0x0027 -#define IBMRS64II 0x0033 -#define IBMRS64III 0x0034 -#define IBMPOWER4 0x0035 -#define IBMRS64III_2 0x0036 -#define IBMRS64IV 0x0037 -#define IBMPOWER4PLUS 0x0038 -#define IBM970 0x0039 -#define IBMPOWER5 0x003a -#define IBMPOWER5PLUS 0x003b -#define IBM970FX 0x003c -#define IBMPOWER6 0x003e -#define IBMPOWER7 0x003f -#define IBMPOWER3 0x0040 -#define IBMPOWER3PLUS 0x0041 -#define IBM970MP 0x0044 -#define IBM970GX 0x0045 -#define IBMPOWERPCA2 0x0049 -#define IBMPOWER7PLUS 0x004a -#define IBMPOWER8E 0x004b -#define IBMPOWER8NVL 0x004c -#define IBMPOWER8 0x004d -#define IBMPOWER9 0x004e -#define MPC860 0x0050 -#define IBMCELLBE 0x0070 -#define IBMPOWER10 0x0080 -#define MPC8240 0x0081 -#define IBMPOWER11 0x0082 -#define PA6T 0x0090 -#define IBM405GP 0x4011 -#define IBM405L 0x4161 -#define IBM750FX 0x7000 -#define MPC745X_P(v) ((v & 0xFFF8) == 0x8000) -#define MPC7450 0x8000 -#define MPC7455 0x8001 -#define MPC7457 0x8002 -#define MPC7447A 0x8003 -#define MPC7448 0x8004 -#define MPC7410 0x800c -#define MPC8245 0x8081 -#define FSL_E500v1 0x8020 -#define FSL_E500v2 0x8021 -#define FSL_E500mc 0x8023 -#define FSL_E5500 0x8024 -#define FSL_E6500 0x8040 -#define FSL_E300C1 0x8083 -#define FSL_E300C2 0x8084 -#define FSL_E300C3 0x8085 -#define FSL_E300C4 0x8086 - -#define LPCR_PECE_WAKESET (LPCR_PECE_EXT | LPCR_PECE_DECR | LPCR_PECE_ME) - -#define SPR_DBSR 0x130 /* ..8 Debug Status Register */ -#define DBSR_IDE 0x80000000 /* Imprecise debug event. */ -#define DBSR_UDE 0x40000000 /* Unconditional debug event. */ -#define DBSR_MRR 0x30000000 /* Most recent Reset (mask). */ -#define DBSR_ICMP 0x08000000 /* Instr. complete debug event. */ -#define DBSR_BRT 0x04000000 /* Branch taken debug event. */ -#define DBSR_IRPT 0x02000000 /* Interrupt taken debug event. */ -#define DBSR_TRAP 0x01000000 /* Trap instr. debug event. */ -#define DBSR_IAC1 0x00800000 /* Instr. address compare #1. */ -#define DBSR_IAC2 0x00400000 /* Instr. address compare #2. */ -#define DBSR_IAC3 0x00200000 /* Instr. address compare #3. */ -#define DBSR_IAC4 0x00100000 /* Instr. address compare #4. */ -#define DBSR_DAC1R 0x00080000 /* Data addr. read compare #1. */ -#define DBSR_DAC1W 0x00040000 /* Data addr. write compare #1. */ -#define DBSR_DAC2R 0x00020000 /* Data addr. read compare #2. */ -#define DBSR_DAC2W 0x00010000 /* Data addr. write compare #2. */ -#define DBSR_RET 0x00008000 /* Return debug event. */ -#define SPR_EPCR 0x133 -#define EPCR_EXTGS 0x80000000 -#define EPCR_DTLBGS 0x40000000 -#define EPCR_ITLBGS 0x20000000 -#define EPCR_DSIGS 0x10000000 -#define EPCR_ISIGS 0x08000000 -#define EPCR_DUVGS 0x04000000 -#define EPCR_ICM 0x02000000 -#define EPCR_GICMGS 0x01000000 -#define EPCR_DGTMI 0x00800000 -#define EPCR_DMIUH 0x00400000 -#define EPCR_PMGS 0x00200000 -#define SPR_DBCR0 0x134 /* ..8 Debug Control Register 0 */ -#define SPR_DBCR1 0x135 /* ..8 Debug Control Register 1 */ -#define SPR_DBCR2 0x136 /* ..8 Debug Control Register 2 */ -#define SPR_IAC1 0x138 /* ..8 Instruction Address Compare 1 */ -#define SPR_IAC2 0x139 /* ..8 Instruction Address Compare 2 */ -#define SPR_IAC3 0x13a /* ..8 Instruction Address Compare 3 */ -#define SPR_IAC4 0x13b /* ..8 Instruction Address Compare 4 */ - -#define SPR_HSRR0 0x13a -#define SPR_HSRR1 0x13b -#define SPR_DAC1 0x13c /* ..8 Data Address Compare 1 */ -#define SPR_DAC2 0x13d /* ..8 Data Address Compare 2 */ -#define SPR_DVC1 0x13e /* ..8 Data Value Compare 1 */ -#define SPR_DVC2 0x13f /* ..8 Data Value Compare 2 */ - -#define SPR_LPCR 0x13e /* .6. Logical Partitioning Control */ -#define LPCR_LPES 0x008 /* Bit 60 */ -#define LPCR_HVICE 0x002 /* Hypervisor Virtualization Interrupt (Arch 3.0) */ -#define LPCR_ILE (1ULL << 25) /* Interrupt Little-Endian (ISA 2.07) */ -#define LPCR_UPRT (1ULL << 22) /* Use Process Table (ISA 3) */ -#define LPCR_HR (1ULL << 20) /* Host Radix mode */ -#define LPCR_PECE_DRBL (1ULL << 16) /* Directed Privileged Doorbell */ -#define LPCR_PECE_HDRBL (1ULL << 15) /* Directed Hypervisor Doorbell */ -#define LPCR_PECE_EXT (1ULL << 14) /* External exceptions */ -#define LPCR_PECE_DECR (1ULL << 13) /* Decrementer exceptions */ -#define LPCR_PECE_ME (1ULL << 12) /* Machine Check and Hypervisor */ - /* Maintenance exceptions */ -#define SPR_LPID 0x13f /* .6. Logical Partitioning Control */ -#define SPR_HMER 0x150 /* Hypervisor Maintenance Exception Register */ -#define SPR_HMEER 0x151 /* Hypervisor Maintenance Exception Enable Register */ -#define SPR_AMOR 0x15d /* Authority Mask Override Register */ - -#define SPR_TIR 0x1be /* .6. Thread Identification Register */ -#define SPR_PTCR 0x1d0 /* Partition Table Control Register */ -#define SPR_SPEFSCR 0x200 /* ..8 Signal Processing Engine FSCR. */ -#define SPEFSCR_SOVH 0x80000000 -#define SPEFSCR_OVH 0x40000000 -#define SPEFSCR_FGH 0x20000000 -#define SPEFSCR_FXH 0x10000000 -#define SPEFSCR_FINVH 0x08000000 -#define SPEFSCR_FDBZH 0x04000000 -#define SPEFSCR_FUNFH 0x02000000 -#define SPEFSCR_FOVFH 0x01000000 -#define SPEFSCR_FINXS 0x00200000 -#define SPEFSCR_FINVS 0x00100000 -#define SPEFSCR_FDBZS 0x00080000 -#define SPEFSCR_FUNFS 0x00040000 -#define SPEFSCR_FOVFS 0x00020000 -#define SPEFSCR_SOV 0x00008000 -#define SPEFSCR_OV 0x00004000 -#define SPEFSCR_FG 0x00002000 -#define SPEFSCR_FX 0x00001000 -#define SPEFSCR_FINV 0x00000800 -#define SPEFSCR_FDBZ 0x00000400 -#define SPEFSCR_FUNF 0x00000200 -#define SPEFSCR_FOVF 0x00000100 -#define SPEFSCR_FINXE 0x00000040 -#define SPEFSCR_FINVE 0x00000020 -#define SPEFSCR_FDBZE 0x00000010 -#define SPEFSCR_FUNFE 0x00000008 -#define SPEFSCR_FOVFE 0x00000004 -#define SPEFSCR_FRMC_M 0x00000003 -#define SPEFSCR_DFLT (SPEFSCR_FINVE | SPEFSCR_FDBZE | \ - SPEFSCR_FUNFE | SPEFSCR_FOVFE) -#define SPR_IBAT0U 0x210 /* .6. Instruction BAT Reg 0 Upper */ -#define SPR_IBAT0L 0x211 /* .6. Instruction BAT Reg 0 Lower */ -#define SPR_IBAT1U 0x212 /* .6. Instruction BAT Reg 1 Upper */ -#define SPR_IBAT1L 0x213 /* .6. Instruction BAT Reg 1 Lower */ -#define SPR_IBAT2U 0x214 /* .6. Instruction BAT Reg 2 Upper */ -#define SPR_IBAT2L 0x215 /* .6. Instruction BAT Reg 2 Lower */ -#define SPR_IBAT3U 0x216 /* .6. Instruction BAT Reg 3 Upper */ -#define SPR_IBAT3L 0x217 /* .6. Instruction BAT Reg 3 Lower */ -#define SPR_DBAT0U 0x218 /* .6. Data BAT Reg 0 Upper */ -#define SPR_DBAT0L 0x219 /* .6. Data BAT Reg 0 Lower */ -#define SPR_DBAT1U 0x21a /* .6. Data BAT Reg 1 Upper */ -#define SPR_DBAT1L 0x21b /* .6. Data BAT Reg 1 Lower */ -#define SPR_DBAT2U 0x21c /* .6. Data BAT Reg 2 Upper */ -#define SPR_DBAT2L 0x21d /* .6. Data BAT Reg 2 Lower */ -#define SPR_DBAT3U 0x21e /* .6. Data BAT Reg 3 Upper */ -#define SPR_DBAT3L 0x21f /* .6. Data BAT Reg 3 Lower */ -#define SPR_IBAT4U 0x230 /* .6. Instruction BAT Reg 4 Upper */ -#define SPR_DBCR3 0x231 /* ..8 Debug Control Register 3 */ -#define SPR_IBAT4L 0x231 /* .6. Instruction BAT Reg 4 Lower */ -#define SPR_IBAT5U 0x232 /* .6. Instruction BAT Reg 5 Upper */ -#define SPR_IBAT5L 0x233 /* .6. Instruction BAT Reg 5 Lower */ -#define SPR_DBCR4 0x233 /* ..8 Debug Control Register 4 */ -#define SPR_IBAT6U 0x234 /* .6. Instruction BAT Reg 6 Upper */ -#define SPR_DBCR5 0x234 /* ..8 Debug Control Register 5 */ -#define SPR_IBAT6L 0x235 /* .6. Instruction BAT Reg 6 Lower */ -#define SPR_IAC5 0x235 /* ..8 Instruction Address Compare 5 */ -#define SPR_IBAT7U 0x236 /* .6. Instruction BAT Reg 7 Upper */ -#define SPR_IAC6 0x236 /* ..8 Instruction Address Compare 6 */ -#define SPR_IBAT7L 0x237 /* .6. Instruction BAT Reg 7 Lower */ -#define SPR_IAC7 0x237 /* ..8 Instruction Address Compare 7 */ -#define SPR_DBAT4U 0x238 /* .6. Data BAT Reg 4 Upper */ -#define SPR_IAC8 0x238 /* ..8 Instruction Address Compare 8 */ -#define SPR_DBAT4L 0x239 /* .6. Data BAT Reg 4 Lower */ -#define SPR_DBAT5U 0x23a /* .6. Data BAT Reg 5 Upper */ -#define SPR_DBAT5L 0x23b /* .6. Data BAT Reg 5 Lower */ -#define SPR_DBAT6U 0x23c /* .6. Data BAT Reg 6 Upper */ -#define SPR_DBAT6L 0x23d /* .6. Data BAT Reg 6 Lower */ -#define SPR_DBAT7U 0x23e /* .6. Data BAT Reg 7 Upper */ -#define SPR_DBAT7L 0x23f /* .6. Data BAT Reg 7 Lower */ -#define SPR_DBCR6 0x25b /* ..8 Debug Control Register 6 */ -#define SPR_SPRG8 0x25c /* ..8 SPR General 8 */ - -#define SPR_MMCRA 0x312 /* ... Monitor Mode Control Register A */ -#define SPR_PMC1 0x313 /* ... PMC 1 */ -#define SPR_PMC2 0x314 /* ... PMC 2 */ -#define SPR_PMC3 0x315 /* ... PMC 3 */ -#define SPR_PMC4 0x316 /* ... PMC 4 */ -#define SPR_PMC5 0x317 /* ... PMC 5 */ -#define SPR_PMC6 0x318 /* ... PMC 6 */ -#define SPR_PMC7 0x319 /* ... PMC 7 */ -#define SPR_PMC8 0x31a /* ... PMC 8 */ - -#define SPR_MMCR0 0x31b /* ... Monitor Mode Control Register 0 */ -#define SPR_MMCR0_FC 0x80000000 /* Freeze counters */ -#define SPR_MMCR0_FCS 0x40000000 /* Freeze counters in supervisor mode */ -#define SPR_MMCR0_FCP 0x20000000 /* Freeze counters in user mode */ -#define SPR_MMCR0_FCM1 0x10000000 /* Freeze counters when mark=1 */ -#define SPR_MMCR0_FCM0 0x08000000 /* Freeze counters when mark=0 */ -#define SPR_MMCR0_PMXE 0x04000000 /* Enable PM interrupt */ -#define SPR_MMCR0_PMAE 0x04000000 /* PM Alert Enable */ -#define SPR_MMCR0_FCECE 0x02000000 /* Freeze counters after event */ -#define SPR_MMCR0_TBSEL_15 0x01800000 /* Count bit 15 of TBL */ -#define SPR_MMCR0_TBSEL_19 0x01000000 /* Count bit 19 of TBL */ -#define SPR_MMCR0_TBSEL_23 0x00800000 /* Count bit 23 of TBL */ -#define SPR_MMCR0_TBSEL_31 0x00000000 /* Count bit 31 of TBL */ -#define SPR_MMCR0_TBEE 0x00400000 /* Time-base event enable */ -#define SPR_MMCR0_THRESHOLD(x) ((x) << 16) /* Threshold value */ -#define SPR_MMCR0_PMC1CE 0x00008000 /* PMC1 condition enable */ -#define SPR_MMCR0_PMCNCE 0x00004000 /* PMCn condition enable */ -#define SPR_MMCR0_TRIGGER 0x00002000 /* Trigger */ -#define SPR_MMCR0_PMAO 0x00000080 /* PM Alert Occurred */ -#define SPR_MMCR0_FCPC 0x00001000 /* Freeze Counters in Problem State Cond. */ -#define SPR_MMCR0_FC56 0x00000010 /* Freeze Counters 5-6 */ -#define SPR_MMCR0_PMC1SEL(x) ((x) << 8) /* PMC1 selector (970) */ -#define SPR_MMCR0_PMC2SEL(x) ((x) << 1) /* PMC2 selector (970) */ -#define SPR_MMCR0_74XX_PMC1SEL(x) (((x) & 0x3f) << 6) /* PMC1 selector */ -#define SPR_MMCR0_74XX_PMC2SEL(x) (((x) & 0x3f) << 0) /* PMC2 selector */ - -#define SPR_MMCR1 0x31e /* ... Monitor Mode Control Register 1 */ -#define SPR_MMCR1_PMC3SEL(x) (((x) & 0x1f) << 27) /* PMC 3 selector */ -#define SPR_MMCR1_PMC4SEL(x) (((x) & 0x1f) << 22) /* PMC 4 selector */ -#define SPR_MMCR1_PMC5SEL(x) (((x) & 0x1f) << 17) /* PMC 5 selector */ -#define SPR_MMCR1_PMC6SEL(x) (((x) & 0x1f) << 12) /* PMC 6 selector */ -#define SPR_MMCR1_74XX_PMC6SEL(x) (((x) & 0x3f) << 11) /* PMC 6 selector */ -#define SPR_MMCR1_PMC7SEL(x) (((x) & 0x1f) << 7) /* PMC 7 selector */ -#define SPR_MMCR1_PMC8SEL(x) (((x) & 0x1f) << 2) /* PMC 8 selector */ -#define SPR_MMCR1_P8_PMCSEL_ALL 0xffffffff -#define SPR_MMCR1_P8_PMCNSEL_MASK(n) (0xffUL << ((3-(n))*8)) -#define SPR_MMCR1_P8_PMCNSEL(n, v) ((unsigned long)(v) << ((3-(n))*8)) - -#define SPR_MMCR2 0x311 -#define SPR_MMCR2_CNBIT(n, bit) ((bit) << (((5 - (n)) * 9) + 10)) -#define SPR_MMCR2_FCNS(n) SPR_MMCR2_CNBIT(n, 0x100ULL) -#define SPR_MMCR2_FCNP0(n) SPR_MMCR2_CNBIT(n, 0x080ULL) -#define SPR_MMCR2_FCNP1(n) SPR_MMCR2_CNBIT(n, 0x040ULL) -#define SPR_MMCR2_FCNM1(n) SPR_MMCR2_CNBIT(n, 0x020ULL) -#define SPR_MMCR2_FCNM0(n) SPR_MMCR2_CNBIT(n, 0x010ULL) -#define SPR_MMCR2_FCNWAIT(n) SPR_MMCR2_CNBIT(n, 0x008ULL) -#define SPR_MMCR2_FCNH(n) SPR_MMCR2_CNBIT(n, 0x004ULL) -/* Freeze Counter N in Hypervisor/Supervisor/Problem states */ -#define SPR_MMCR2_FCNHSP(n) \ - (SPR_MMCR2_FCNS(n) | SPR_MMCR2_FCNP0(n) | \ - SPR_MMCR2_FCNP1(n) | SPR_MMCR2_FCNH(n)) - -#define SPR_M_TWB 0x31c /* ..8 MMU tablewalk base */ -#define M_TWB_L1TB 0xfffff000 /* level-1 translation base */ -#define M_TWB_L1INDX 0x00000ffc /* level-1 index */ -#define SPR_MD_TWC 0x31d /* ..8 DMMU tablewalk control */ -#define SPR_MD_RPN 0x31e /* ..8 DMMU real (phys) page number */ -#define SPR_MD_TW 0x31f /* ..8 MMU tablewalk scratch */ -#define SPR_BESCRS 0x320 /* .6. Branch Event Status and Control Set Register */ -#define SPR_BESCRSU 0x321 /* .6. Branch Event Status and Control Set Register (upper 32-bit) */ -#define SPR_BESCRR 0x322 /* .6. Branch Event Status and Control Reset Register */ -#define SPR_BESCRRU 0x323 /* .6. Branch Event Status and Control Register (upper 32-bit) */ -#define SPR_EBBHR 0x324 /* .6. Event-based Branch Handler Register */ -#define SPR_EBBRR 0x325 /* .6. Event-based Branch Return Register */ -#define SPR_BESCR 0x326 /* .6. Branch Event Status and Control Register */ -#define SPR_LMRR 0x32d /* .6. Load Monitored Region Register */ -#define SPR_LMSER 0x32e /* .6. Load Monitored Section Enable Register */ -#define SPR_TAR 0x32f /* .6. Branch Target Address Register */ -#define SPR_MI_CAM 0x330 /* ..8 IMMU CAM entry read */ -#define SPR_MI_RAM0 0x331 /* ..8 IMMU RAM entry read reg 0 */ -#define SPR_MI_RAM1 0x332 /* ..8 IMMU RAM entry read reg 1 */ -#define SPR_MD_CAM 0x338 /* ..8 IMMU CAM entry read */ -#define SPR_MD_RAM0 0x339 /* ..8 IMMU RAM entry read reg 0 */ -#define SPR_MD_RAM1 0x33a /* ..8 IMMU RAM entry read reg 1 */ -#define SPR_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */ -#define PSSCR_PLS_S 60 -#define PSSCR_PLS_M (0xf << PSSCR_PLS_S) -#define PSSCR_SD (1 << 22) -#define PSSCR_ESL (1 << 21) -#define PSSCR_EC (1 << 20) -#define PSSCR_PSLL_S 16 -#define PSSCR_PSLL_M (0xf << PSSCR_PSLL_S) -#define PSSCR_TR_S 8 -#define PSSCR_TR_M (0x3 << PSSCR_TR_S) -#define PSSCR_MTL_S 4 -#define PSSCR_MTL_M (0xf << PSSCR_MTL_S) -#define PSSCR_RL_S 0 -#define PSSCR_RL_M (0xf << PSSCR_RL_S) -#define SPR_PMCR 0x374 /* Processor Management Control Register */ -#define SPR_UMMCR2 0x3a0 /* .6. User Monitor Mode Control Register 2 */ -#define SPR_UMMCR0 0x3a8 /* .6. User Monitor Mode Control Register 0 */ -#define SPR_USIA 0x3ab /* .6. User Sampled Instruction Address */ -#define SPR_UMMCR1 0x3ac /* .6. User Monitor Mode Control Register 1 */ -#define SPR_MMCR2_74XX 0x3b0 /* .6. Monitor Mode Control Register 2 */ -#define SPR_MMCR2_74XX_THRESHMULT_32 0x80000000 /* Multiply MMCR0 threshold by 32 */ -#define SPR_MMCR2_74XX_THRESHMULT_2 0x00000000 /* Multiply MMCR0 threshold by 2 */ -#define SPR_PMC5_74XX 0x3b1 /* .6. Performance Counter Register 5 */ -#define SPR_PMC6_74XX 0x3b2 /* .6. Performance Counter Register 6 */ -#define SPR_MMCR0_74XX 0x3b8 /* .6. Monitor Mode Control Register 0 */ -#define SPR_PMC1_74XX 0x3b9 /* .6. Performance Counter Register 1 */ -#define SPR_PMC2_74XX 0x3ba /* .6. Performance Counter Register 2 */ -#define SPR_SIA 0x3bb /* .6. Sampled Instruction Address */ -#define SPR_MMCR1_74XX 0x3bc /* .6. Monitor Mode Control Register 2 */ - -#define SPR_PMC3_74XX 0x3bd /* .6. Performance Counter Register 3 */ -#define SPR_PMC4_74XX 0x3be /* .6. Performance Counter Register 4 */ -#define SPR_DMISS 0x3d0 /* .68 Data TLB Miss Address Register */ -#define SPR_DCMP 0x3d1 /* .68 Data TLB Compare Register */ -#define SPR_HASH1 0x3d2 /* .68 Primary Hash Address Register */ -#define SPR_HASH2 0x3d3 /* .68 Secondary Hash Address Register */ -#define SPR_IMISS 0x3d4 /* .68 Instruction TLB Miss Address Register */ -#define SPR_TLBMISS 0x3d4 /* .6. TLB Miss Address Register */ -#define SPR_DEAR 0x03d /* ..8 Data Exception Address Register */ -#define SPR_ICMP 0x3d5 /* .68 Instruction TLB Compare Register */ -#define SPR_PTEHI 0x3d5 /* .6. Instruction TLB Compare Register */ -#define SPR_RPA 0x3d6 /* .68 Required Physical Address Register */ -#define SPR_PTELO 0x3d6 /* .6. Required Physical Address Register */ - -#define SPR_TSR 0x150 /* ..8 Timer Status Register */ -#define SPR_TCR 0x154 /* ..8 Timer Control Register */ - -#define TSR_ENW 0x80000000 /* Enable Next Watchdog */ -#define TSR_WIS 0x40000000 /* Watchdog Interrupt Status */ -#define TSR_WRS_MASK 0x30000000 /* Watchdog Reset Status */ -#define TSR_WRS_NONE 0x00000000 /* No watchdog reset has occurred */ -#define TSR_WRS_CORE 0x10000000 /* Core reset was forced by the watchdog */ -#define TSR_WRS_CHIP 0x20000000 /* Chip reset was forced by the watchdog */ -#define TSR_WRS_SYSTEM 0x30000000 /* System reset was forced by the watchdog */ -#define TSR_PIS 0x08000000 /* PIT Interrupt Status */ -#define TSR_DIS 0x08000000 /* Decrementer Interrupt Status */ -#define TSR_FIS 0x04000000 /* FIT Interrupt Status */ - -#define TCR_WP_MASK 0xc0000000 /* Watchdog Period mask */ -#define TCR_WP_2_17 0x00000000 /* 2**17 clocks */ -#define TCR_WP_2_21 0x40000000 /* 2**21 clocks */ -#define TCR_WP_2_25 0x80000000 /* 2**25 clocks */ -#define TCR_WP_2_29 0xc0000000 /* 2**29 clocks */ -#define TCR_WRC_MASK 0x30000000 /* Watchdog Reset Control mask */ -#define TCR_WRC_NONE 0x00000000 /* No watchdog reset */ -#define TCR_WRC_CORE 0x10000000 /* Core reset */ -#define TCR_WRC_CHIP 0x20000000 /* Chip reset */ -#define TCR_WRC_SYSTEM 0x30000000 /* System reset */ -#define TCR_WIE 0x08000000 /* Watchdog Interrupt Enable */ -#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ -#define TCR_DIE 0x04000000 /* Pecrementer Interrupt Enable */ -#define TCR_FP_MASK 0x03000000 /* FIT Period */ -#define TCR_FP_2_9 0x00000000 /* 2**9 clocks */ -#define TCR_FP_2_13 0x01000000 /* 2**13 clocks */ -#define TCR_FP_2_17 0x02000000 /* 2**17 clocks */ -#define TCR_FP_2_21 0x03000000 /* 2**21 clocks */ -#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ -#define TCR_ARE 0x00400000 /* Auto Reload Enable */ - -#define SPR_HID0 0x3f0 /* ..8 Hardware Implementation Register 0 */ -#define SPR_HID1 0x3f1 /* ..8 Hardware Implementation Register 1 */ -#define SPR_HID2 0x3f3 /* ..8 Hardware Implementation Register 2 */ -#define SPR_HID4 0x3f4 /* ..8 Hardware Implementation Register 4 */ -#define SPR_HID5 0x3f6 /* ..8 Hardware Implementation Register 5 */ -#define SPR_HID6 0x3f9 /* ..8 Hardware Implementation Register 6 */ - -#define SPR_CELL_TSRL 0x380 /* ... Cell BE Thread Status Register */ -#define SPR_CELL_TSCR 0x399 /* ... Cell BE Thread Switch Register */ - -#if defined(AIM) -#define SPR_PIR 0x3ff /* .6. Processor Identification Register */ -#elif defined(BOOKE) -#define SPR_PIR 0x11e /* ..8 Processor Identification Register */ -#endif - -#define DBCR0_EDM 0x80000000 /* External Debug Mode */ -#define DBCR0_IDM 0x40000000 /* Internal Debug Mode */ -#define DBCR0_RST_MASK 0x30000000 /* ReSeT */ -#define DBCR0_RST_NONE 0x00000000 /* No action */ -#define DBCR0_RST_CORE 0x10000000 /* Core reset */ -#define DBCR0_RST_CHIP 0x20000000 /* Chip reset */ -#define DBCR0_RST_SYSTEM 0x30000000 /* System reset */ -#define DBCR0_IC 0x08000000 /* Instruction Completion debug event */ -#define DBCR0_BT 0x04000000 /* Branch Taken debug event */ -#define DBCR0_EDE 0x02000000 /* Exception Debug Event */ -#define DBCR0_TDE 0x01000000 /* Trap Debug Event */ -#define DBCR0_IA1 0x00800000 /* IAC (Instruction Address Compare) 1 debug event */ -#define DBCR0_IA2 0x00400000 /* IAC 2 debug event */ -#define DBCR0_IA12 0x00200000 /* Instruction Address Range Compare 1-2 */ -#define DBCR0_IA12X 0x00100000 /* IA12 eXclusive */ -#define DBCR0_IA3 0x00080000 /* IAC 3 debug event */ -#define DBCR0_IA4 0x00040000 /* IAC 4 debug event */ -#define DBCR0_IA34 0x00020000 /* Instruction Address Range Compare 3-4 */ -#define DBCR0_IA34X 0x00010000 /* IA34 eXclusive */ -#define DBCR0_IA12T 0x00008000 /* Instruction Address Range Compare 1-2 range Toggle */ -#define DBCR0_IA34T 0x00004000 /* Instruction Address Range Compare 3-4 range Toggle */ -#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */ - -#define SPR_IABR 0x3f2 /* ..8 Instruction Address Breakpoint Register 0 */ -#define SPR_DABR 0x3f5 /* .6. Data Address Breakpoint Register */ -#define SPR_MSSCR0 0x3f6 /* .6. Memory SubSystem Control Register */ -#define MSSCR0_SHDEN 0x80000000 /* 0: Shared-state enable */ -#define MSSCR0_SHDPEN3 0x40000000 /* 1: ~SHD[01] signal enable in MEI mode */ -#define MSSCR0_L1INTVEN 0x38000000 /* 2-4: L1 data cache ~HIT intervention enable */ -#define MSSCR0_L2INTVEN 0x07000000 /* 5-7: L2 data cache ~HIT intervention enable*/ -#define MSSCR0_DL1HWF 0x00800000 /* 8: L1 data cache hardware flush */ -#define MSSCR0_MBO 0x00400000 /* 9: must be one */ -#define MSSCR0_EMODE 0x00200000 /* 10: MPX bus mode (read-only) */ -#define MSSCR0_ABD 0x00100000 /* 11: address bus driven (read-only) */ -#define MSSCR0_MBZ 0x000fffff /* 12-31: must be zero */ -#define MSSCR0_L2PFE 0x00000003 /* 30-31: L2 prefetch enable */ -#define SPR_MSSSR0 0x3f7 /* .6. Memory Subsystem Status Register (MPC745x) */ -#define MSSSR0_L2TAG 0x00040000 /* 13: L2 tag parity error */ -#define MSSSR0_L2DAT 0x00020000 /* 14: L2 data parity error */ -#define MSSSR0_L3TAG 0x00010000 /* 15: L3 tag parity error */ -#define MSSSR0_L3DAT 0x00008000 /* 16: L3 data parity error */ -#define MSSSR0_APE 0x00004000 /* 17: Address parity error */ -#define MSSSR0_DPE 0x00002000 /* 18: Data parity error */ -#define MSSSR0_TEA 0x00001000 /* 19: Bus transfer error acknowledge */ -#define SPR_LDSTCR 0x3f8 /* .6. Load/Store Control Register */ -#define SPR_L2PM 0x3f8 /* .6. L2 Private Memory Control Register */ -#define SPR_L2CR 0x3f9 /* .6. L2 Control Register */ -#define L2CR_L2E 0x80000000 /* 0: L2 enable */ -#define L2CR_L2PE 0x40000000 /* 1: L2 data parity enable */ -#define L2CR_L2SIZ 0x30000000 /* 2-3: L2 size */ -#define L2SIZ_2M 0x00000000 -#define L2SIZ_256K 0x10000000 -#define L2SIZ_512K 0x20000000 -#define L2SIZ_1M 0x30000000 -#define L2CR_L2CLK 0x0e000000 /* 4-6: L2 clock ratio */ -#define L2CLK_DIS 0x00000000 /* disable L2 clock */ -#define L2CLK_10 0x02000000 /* core clock / 1 */ -#define L2CLK_15 0x04000000 /* / 1.5 */ -#define L2CLK_20 0x08000000 /* / 2 */ -#define L2CLK_25 0x0a000000 /* / 2.5 */ -#define L2CLK_30 0x0c000000 /* / 3 */ -#define L2CR_L2RAM 0x01800000 /* 7-8: L2 RAM type */ -#define L2RAM_FLOWTHRU_BURST 0x00000000 -#define L2RAM_PIPELINE_BURST 0x01000000 -#define L2RAM_PIPELINE_LATE 0x01800000 -#define L2CR_L2DO 0x00400000 /* 9: L2 data-only. - Setting this bit disables instruction - caching. */ -#define L2CR_L2I 0x00200000 /* 10: L2 global invalidate. */ -#define L2CR_L2IO_7450 0x00010000 /* 11: L2 instruction-only (MPC745x). */ -#define L2CR_L2CTL 0x00100000 /* 11: L2 RAM control (ZZ enable). - Enables automatic operation of the - L2ZZ (low-power mode) signal. */ -#define L2CR_L2WT 0x00080000 /* 12: L2 write-through. */ -#define L2CR_L2TS 0x00040000 /* 13: L2 test support. */ -#define L2CR_L2OH 0x00030000 /* 14-15: L2 output hold. */ -#define L2CR_L2DO_7450 0x00010000 /* 15: L2 data-only (MPC745x). */ -#define L2CR_L2SL 0x00008000 /* 16: L2 DLL slow. */ -#define L2CR_L2DF 0x00004000 /* 17: L2 differential clock. */ -#define L2CR_L2BYP 0x00002000 /* 18: L2 DLL bypass. */ -#define L2CR_L2FA 0x00001000 /* 19: L2 flush assist (for software flush). */ -#define L2CR_L2HWF 0x00000800 /* 20: L2 hardware flush. */ -#define L2CR_L2IO 0x00000400 /* 21: L2 instruction-only. */ -#define L2CR_L2CLKSTP 0x00000200 /* 22: L2 clock stop. */ -#define L2CR_L2DRO 0x00000100 /* 23: L2DLL rollover checkstop enable. */ -#define L2CR_L2IP 0x00000001 /* 31: L2 global invalidate in */ - /* progress (read only). */ -#define SPR_L3CR 0x3fa /* .6. L3 Control Register */ -#define L3CR_L3E 0x80000000 /* 0: L3 enable */ -#define L3CR_L3PE 0x40000000 /* 1: L3 data parity enable */ -#define L3CR_L3APE 0x20000000 -#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */ -#define L3CR_L3CLKEN 0x08000000 /* 4: Enables L3_CLK[0:1] */ -#define L3CR_L3CLK 0x03800000 -#define L3CR_L3IO 0x00400000 -#define L3CR_L3CLKEXT 0x00200000 -#define L3CR_L3CKSPEXT 0x00100000 -#define L3CR_L3OH1 0x00080000 -#define L3CR_L3SPO 0x00040000 -#define L3CR_L3CKSP 0x00030000 -#define L3CR_L3PSP 0x0000e000 -#define L3CR_L3REP 0x00001000 -#define L3CR_L3HWF 0x00000800 -#define L3CR_L3I 0x00000400 /* 21: L3 global invalidate */ -#define L3CR_L3RT 0x00000300 -#define L3CR_L3NIRCA 0x00000080 -#define L3CR_L3DO 0x00000040 -#define L3CR_PMEN 0x00000004 -#define L3CR_PMSIZ 0x00000003 - -#define SPR_THRM1 0x3fc /* .6. Thermal Management Register */ -#define SPR_THRM2 0x3fd /* .6. Thermal Management Register */ -#define SPR_THRM_TIN 0x80000000 /* Thermal interrupt bit (RO) */ -#define SPR_THRM_TIV 0x40000000 /* Thermal interrupt valid (RO) */ -#define SPR_THRM_THRESHOLD(x) ((x) << 23) /* Thermal sensor threshold */ -#define SPR_THRM_TID 0x00000004 /* Thermal interrupt direction */ -#define SPR_THRM_TIE 0x00000002 /* Thermal interrupt enable */ -#define SPR_THRM_VALID 0x00000001 /* Valid bit */ -#define SPR_THRM3 0x3fe /* .6. Thermal Management Register */ -#define SPR_THRM_TIMER(x) ((x) << 1) /* Sampling interval timer */ -#define SPR_THRM_ENABLE 0x00000001 /* TAU Enable */ -#define SPR_FPECR 0x3fe /* .6. Floating-Point Exception Cause Register */ - -/* Time Base Register declarations */ -#define TBR_TBL 0x10c /* 468 Time Base Lower - read */ -#define TBR_TBU 0x10d /* 468 Time Base Upper - read */ -#define TBR_TBWL 0x11c /* 468 Time Base Lower - supervisor, write */ -#define TBR_TBWU 0x11d /* 468 Time Base Upper - supervisor, write */ - -/* Performance counter declarations */ -#define PMC_OVERFLOW 0x80000000 /* Counter has overflowed */ - -/* The first five countable [non-]events are common to many PMC's */ -#define PMCN_NONE 0 /* Count nothing */ -#define PMCN_CYCLES 1 /* Processor cycles */ -#define PMCN_ICOMP 2 /* Instructions completed */ -#define PMCN_TBLTRANS 3 /* TBL bit transitions */ -#define PCMN_IDISPATCH 4 /* Instructions dispatched */ - -/* Similar things for the 970 PMC direct counters */ -#define PMC970N_NONE 0x8 /* Count nothing */ -#define PMC970N_CYCLES 0xf /* Processor cycles */ -#define PMC970N_ICOMP 0x9 /* Instructions completed */ - -#if defined(BOOKE) - -#define SPR_MCARU 0x239 /* ..8 Machine Check Address register upper bits */ -#define SPR_MCSR 0x23c /* ..8 Machine Check Syndrome register */ -#define MCSR_MCP 0x80000000 /* Machine check input signal to core */ -#define MCSR_L2MMU_MHIT 0x08000000 /* L2 MMU simultaneous hit */ -#define MCSR_NMI 0x00100000 /* Non-maskable interrupt */ -#define MCSR_MAV 0x00080000 /* MCAR address valid */ -#define MCSR_MEA 0x00040000 /* MCAR effective address */ -#define MCSR_IF 0x00010000 /* Instruction fetch error report */ -#define MCSR_LD 0x00008000 /* Load instruction error report */ -#define MCSR_ST 0x00004000 /* Store instruction error report */ -#define MCSR_LDG 0x00002000 /* Guarded load instruction error report */ -#define MCSR_TLBSYNC 0x00000002 /* Simultaneous TLBSYNC detected */ -#define SPR_MCAR 0x23d /* ..8 Machine Check Address register */ - -#define SPR_ESR 0x003e /* ..8 Exception Syndrome Register */ -#define ESR_PIL 0x08000000 /* Program interrupt - illegal */ -#define ESR_PPR 0x04000000 /* Program interrupt - privileged */ -#define ESR_PTR 0x02000000 /* Program interrupt - trap */ -#define ESR_ST 0x00800000 /* Store operation */ -#define ESR_DLK 0x00200000 /* Data storage, D cache locking */ -#define ESR_ILK 0x00100000 /* Data storage, I cache locking */ -#define ESR_BO 0x00020000 /* Data/instruction storage, byte ordering */ -#define ESR_SPE 0x00000080 /* SPE exception bit */ - -#define SPR_CSRR0 0x03a /* ..8 58 Critical SRR0 */ -#define SPR_CSRR1 0x03b /* ..8 59 Critical SRR1 */ -#define SPR_MCSRR0 0x23a /* ..8 570 Machine check SRR0 */ -#define SPR_MCSRR1 0x23b /* ..8 571 Machine check SRR1 */ -#define SPR_DSRR0 0x23e /* ..8 574 Debug SRR0 */ -#define SPR_DSRR1 0x23f /* ..8 575 Debug SRR1 */ - -#define SPR_MMUCSR0 0x3f4 /* ..8 1012 MMU Control and Status Register 0 */ -#define MMUCSR0_L2TLB0_FI 0x04 /* TLB0 flash invalidate */ -#define MMUCSR0_L2TLB1_FI 0x02 /* TLB1 flash invalidate */ - -#define SPR_SVR 0x3ff /* ..8 1023 System Version Register */ -#define SVR_MPC8533 0x8034 -#define SVR_MPC8533E 0x803c -#define SVR_MPC8541 0x8072 -#define SVR_MPC8541E 0x807a -#define SVR_MPC8548 0x8031 -#define SVR_MPC8548E 0x8039 -#define SVR_MPC8555 0x8071 -#define SVR_MPC8555E 0x8079 -#define SVR_MPC8572 0x80e0 -#define SVR_MPC8572E 0x80e8 -#define SVR_P1011 0x80e5 -#define SVR_P1011E 0x80ed -#define SVR_P1013 0x80e7 -#define SVR_P1013E 0x80ef -#define SVR_P1020 0x80e4 -#define SVR_P1020E 0x80ec -#define SVR_P1022 0x80e6 -#define SVR_P1022E 0x80ee -#define SVR_P2010 0x80e3 -#define SVR_P2010E 0x80eb -#define SVR_P2020 0x80e2 -#define SVR_P2020E 0x80ea -#define SVR_P2041 0x8210 -#define SVR_P2041E 0x8218 -#define SVR_P3041 0x8211 -#define SVR_P3041E 0x8219 -#define SVR_P4040 0x8200 -#define SVR_P4040E 0x8208 -#define SVR_P4080 0x8201 -#define SVR_P4080E 0x8209 -#define SVR_P5010 0x8221 -#define SVR_P5010E 0x8229 -#define SVR_P5020 0x8220 -#define SVR_P5020E 0x8228 -#define SVR_P5021 0x8205 -#define SVR_P5021E 0x820d -#define SVR_P5040 0x8204 -#define SVR_P5040E 0x820c -#define SVR_VER(svr) (((svr) >> 16) & 0xffff) - -#define SPR_PID0 0x030 /* ..8 Process ID Register 0 */ -#define SPR_PID1 0x279 /* ..8 Process ID Register 1 */ -#define SPR_PID2 0x27a /* ..8 Process ID Register 2 */ - -#define SPR_TLB0CFG 0x2B0 /* ..8 TLB 0 Config Register */ -#define SPR_TLB1CFG 0x2B1 /* ..8 TLB 1 Config Register */ -#define TLBCFG_ASSOC_MASK 0xff000000 /* Associativity of TLB */ -#define TLBCFG_ASSOC_SHIFT 24 -#define TLBCFG_NENTRY_MASK 0x00000fff /* Number of entries in TLB */ - -#define SPR_IVPR 0x03f /* ..8 Interrupt Vector Prefix Register */ -#define SPR_IVOR0 0x190 /* ..8 Critical input */ -#define SPR_IVOR1 0x191 /* ..8 Machine check */ -#define SPR_IVOR2 0x192 -#define SPR_IVOR3 0x193 -#define SPR_IVOR4 0x194 -#define SPR_IVOR5 0x195 -#define SPR_IVOR6 0x196 -#define SPR_IVOR7 0x197 -#define SPR_IVOR8 0x198 -#define SPR_IVOR9 0x199 -#define SPR_IVOR10 0x19a -#define SPR_IVOR11 0x19b -#define SPR_IVOR12 0x19c -#define SPR_IVOR13 0x19d -#define SPR_IVOR14 0x19e -#define SPR_IVOR15 0x19f -#define SPR_IVOR32 0x210 -#define SPR_IVOR33 0x211 -#define SPR_IVOR34 0x212 -#define SPR_IVOR35 0x213 - -#define SPR_MAS0 0x270 /* ..8 MMU Assist Register 0 Book-E/e500 */ -#define SPR_MAS1 0x271 /* ..8 MMU Assist Register 1 Book-E/e500 */ -#define SPR_MAS2 0x272 /* ..8 MMU Assist Register 2 Book-E/e500 */ -#define SPR_MAS3 0x273 /* ..8 MMU Assist Register 3 Book-E/e500 */ -#define SPR_MAS4 0x274 /* ..8 MMU Assist Register 4 Book-E/e500 */ -#define SPR_MAS5 0x275 /* ..8 MMU Assist Register 5 Book-E */ -#define SPR_MAS6 0x276 /* ..8 MMU Assist Register 6 Book-E/e500 */ -#define SPR_MAS7 0x3B0 /* ..8 MMU Assist Register 7 Book-E/e500 */ -#define SPR_MAS8 0x155 /* ..8 MMU Assist Register 8 Book-E/e500 */ - -#define SPR_L1CFG0 0x203 /* ..8 L1 cache configuration register 0 */ -#define SPR_L1CFG1 0x204 /* ..8 L1 cache configuration register 1 */ - -#define SPR_CCR1 0x378 -#define CCR1_L2COBE 0x00000040 - -#define DCR_L2DCDCRAI 0x0000 /* L2 D-Cache DCR Address Pointer */ -#define DCR_L2DCDCRDI 0x0001 /* L2 D-Cache DCR Data Indirect */ -#define DCR_L2CR0 0x00 /* L2 Cache Configuration Register 0 */ -#define L2CR0_AS 0x30000000 - -#define SPR_L1CSR0 0x3F2 /* ..8 L1 Cache Control and Status Register 0 */ -#define L1CSR0_DCPE 0x00010000 /* Data Cache Parity Enable */ -#define L1CSR0_DCLFR 0x00000100 /* Data Cache Lock Bits Flash Reset */ -#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */ -#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */ -#define SPR_L1CSR1 0x3F3 /* ..8 L1 Cache Control and Status Register 1 */ -#define L1CSR1_ICPE 0x00010000 /* Instruction Cache Parity Enable */ -#define L1CSR1_ICUL 0x00000400 /* Instr Cache Unable to Lock */ -#define L1CSR1_ICLFR 0x00000100 /* Instruction Cache Lock Bits Flash Reset */ -#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */ -#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */ - -#define SPR_L2CFG0 0x207 /* ..8 L2 Configuration Register 0 */ -#define SPR_L2CSR0 0x3F9 /* ..8 L2 Cache Control and Status Register 0 */ -#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */ -#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity Enable */ -#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */ -#define L2CSR0_L2LFC 0x00000400 /* L2 Cache Lock Flags Clear */ - -#define SPR_BUCSR 0x3F5 /* ..8 Branch Unit Control and Status Register */ -#define BUCSR_BPEN 0x00000001 /* Branch Prediction Enable */ -#define BUCSR_BBFI 0x00000200 /* Branch Buffer Flash Invalidate */ - -#endif /* BOOKE */ -#endif /* !_POWERPC_SPR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/sr.h b/lib/libc/include/generic-freebsd/machine/sr.h deleted file mode 100644 index e0c8a3bc56fefc46e95cbe681bc7c26101b0a6c3..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/sr.h +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (C) 2002 Benno Rice. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_SR_H_ -#define _MACHINE_SR_H_ - -/* - * Bit definitions for segment registers. - * - * PowerPC Microprocessor Family: The Programming Environments for 32-bit - * Microprocessors, section 2.3.5 - */ - -#define SR_TYPE 0x80000000 /* Type selector */ -#define SR_KS 0x40000000 /* Supervisor-state protection key */ -#define SR_KP 0x20000000 /* User-state protection key */ -#define SR_N 0x10000000 /* No-execute protection */ -#define SR_VSID_MASK 0x00ffffff /* Virtual Segment ID mask */ - -/* Kernel segment register usage */ -#define USER_SR 12 -#define KERNEL_SR 13 -#define KERNEL2_SR 14 -#define KERNEL3_SR 15 -#define KERNEL_VSIDBITS 0xfffffUL -#define KERNEL_SEGMENT (0xfffff0 + KERNEL_SR) -#define KERNEL2_SEGMENT (0xfffff0 + KERNEL2_SR) -#define EMPTY_SEGMENT 0xfffff0 -#ifdef __powerpc64__ -#define USER_ADDR 0xc00ffffff0000000UL -#else -#define USER_ADDR ((uintptr_t)USER_SR << ADDR_SR_SHFT) -#endif -#define SEGMENT_LENGTH 0x10000000UL -#define SEGMENT_INVMASK 0x0fffffffUL -#define SEGMENT_MASK ~SEGMENT_INVMASK - -#endif /* !_MACHINE_SR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/stack.h b/lib/libc/include/generic-freebsd/machine/stack.h deleted file mode 100644 index 34a6caee56a2762e17ee6a14f8a6be203e4221df..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/stack.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#ifndef _MACHINE_STACK_H_ -#define _MACHINE_STACK_H_ - -extern int trapexit[]; -extern int asttrapexit[]; -extern int end[]; - -#ifdef _SYS_PROC_H_ - -#include - -/* Get the current kernel thread stack usage. */ -#define GET_STACK_USAGE(total, used) do { \ - struct thread *td = curthread; \ - (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \ - (used) = td->td_kstack + (total) - (vm_offset_t)&td; \ -} while (0) - -static __inline bool -kstack_contains(struct thread *td, vm_offset_t va, size_t len) -{ - return (va >= td->td_kstack && va + len >= va && - va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE - - sizeof(struct pcb)); -} -#endif /* _SYS_PROC_H_ */ - -#endif /* !_MACHINE_STACK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/sysarch.h b/lib/libc/include/generic-freebsd/machine/sysarch.h index e1911def3572a541f6f05d9bc401f8f984ef9499..7a878970793205ac7033c38ab745ae9a93a4dfbb 100644 --- a/lib/libc/include/generic-freebsd/machine/sysarch.h +++ b/lib/libc/include/generic-freebsd/machine/sysarch.h @@ -1,43 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_SYSARCH_H_ -#define _MACHINE_SYSARCH_H_ - -#ifndef _KERNEL -#include - -__BEGIN_DECLS -int sysarch(int, void *); -__END_DECLS -#endif - -#endif /* !_MACHINE_SYSARCH_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/tlb.h b/lib/libc/include/generic-freebsd/machine/tlb.h deleted file mode 100644 index 2064827437f063366857666019dc3e100316a40b..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/tlb.h +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (C) 2006-2012 Semihalf. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_TLB_H_ -#define _MACHINE_TLB_H_ - -#if defined(BOOKE_E500) - -/* PowerPC E500 MAS registers */ -#define MAS0_TLBSEL(x) ((x << 28) & 0x10000000) -#define MAS0_ESEL(x) ((x << 16) & 0x003F0000) - -#define MAS0_TLBSEL1 0x10000000 -#define MAS0_TLBSEL0 0x00000000 -#define MAS0_ESEL_TLB1MASK 0x000F0000 -#define MAS0_ESEL_TLB0MASK 0x00030000 -#define MAS0_ESEL_SHIFT 16 -#define MAS0_NV_MASK 0x00000003 -#define MAS0_NV_SHIFT 0 - -#define MAS1_VALID 0x80000000 -#define MAS1_IPROT 0x40000000 -#define MAS1_TID_MASK 0x00FF0000 -#define MAS1_TID_SHIFT 16 -#define MAS1_TS_MASK 0x00001000 -#define MAS1_TS_SHIFT 12 -#define MAS1_TSIZE_MASK 0x00000F00 -#define MAS1_TSIZE_SHIFT 8 - -#define TLB_SIZE_4K 1 -#define TLB_SIZE_16K 2 -#define TLB_SIZE_64K 3 -#define TLB_SIZE_256K 4 -#define TLB_SIZE_1M 5 -#define TLB_SIZE_4M 6 -#define TLB_SIZE_16M 7 -#define TLB_SIZE_64M 8 -#define TLB_SIZE_256M 9 -#define TLB_SIZE_1G 10 -#define TLB_SIZE_4G 11 - -#ifdef __powerpc64__ -#define MAS2_EPN_MASK 0xFFFFFFFFFFFFF000UL -#else -#define MAS2_EPN_MASK 0xFFFFF000 -#endif -#define MAS2_EPN_SHIFT 12 -#define MAS2_X0 0x00000040 -#define MAS2_X1 0x00000020 -#define MAS2_W 0x00000010 -#define MAS2_I 0x00000008 -#define MAS2_M 0x00000004 -#define MAS2_G 0x00000002 -#define MAS2_E 0x00000001 -#define MAS2_WIMGE_MASK 0x0000007F - -#define MAS3_RPN 0xFFFFF000 -#define MAS3_RPN_SHIFT 12 -#define MAS3_U0 0x00000200 -#define MAS3_U1 0x00000100 -#define MAS3_U2 0x00000080 -#define MAS3_U3 0x00000040 -#define MAS3_UX 0x00000020 -#define MAS3_SX 0x00000010 -#define MAS3_UW 0x00000008 -#define MAS3_SW 0x00000004 -#define MAS3_UR 0x00000002 -#define MAS3_SR 0x00000001 - -#define MAS4_TLBSELD1 0x10000000 -#define MAS4_TLBSELD0 0x00000000 -#define MAS4_TIDSELD_MASK 0x00030000 -#define MAS4_TIDSELD_SHIFT 16 -#define MAS4_TSIZED_MASK 0x00000F00 -#define MAS4_TSIZED_SHIFT 8 -#define MAS4_X0D 0x00000040 -#define MAS4_X1D 0x00000020 -#define MAS4_WD 0x00000010 -#define MAS4_ID 0x00000008 -#define MAS4_MD 0x00000004 -#define MAS4_GD 0x00000002 -#define MAS4_ED 0x00000001 - -#define MAS6_SPID0_MASK 0x00FF0000 -#define MAS6_SPID0_SHIFT 16 -#define MAS6_SAS 0x00000001 - -#define MAS7_RPN 0x0000000F - -#define MAS1_GETTID(mas1) (((mas1) & MAS1_TID_MASK) >> MAS1_TID_SHIFT) - -#define MAS2_TLB0_ENTRY_IDX_MASK 0x0007f000 -#define MAS2_TLB0_ENTRY_IDX_SHIFT 12 - -/* - * Maximum number of TLB1 entries used for a permanent mapping of kernel - * region (kernel image plus statically allocated data). - */ -#define KERNEL_REGION_MAX_TLB_ENTRIES 4 - -/* - * Use MAS2_X0 to mark entries which will be copied - * to AP CPUs during SMP bootstrap. As result entries - * marked with _TLB_ENTRY_SHARED will be shared by all CPUs. - */ -#define _TLB_ENTRY_SHARED (MAS2_X0) /* XXX under SMP? */ -#define _TLB_ENTRY_IO (MAS2_I | MAS2_G) -#define _TLB_ENTRY_MEM (MAS2_M) - -#define TLB1_MAX_ENTRIES 64 - -#if !defined(LOCORE) -typedef struct tlb_entry { - vm_paddr_t phys; - vm_offset_t virt; - vm_size_t size; - uint32_t mas1; -#ifdef __powerpc64__ - uint64_t mas2; -#else - uint32_t mas2; -#endif - uint32_t mas3; - uint32_t mas7; -} tlb_entry_t; - -void tlb1_inval_entry(unsigned int); -void tlb1_init(void); -#endif /* !LOCORE */ - -#endif /* BOOKE_E500 */ - -#define TID_KERNEL 0 /* TLB TID to use for kernel (shared) translations */ -#define TID_KRESERVED 1 /* Number of TIDs reserved for kernel */ -#define TID_URESERVED 0 /* Number of TIDs reserved for user */ -#define TID_MIN (TID_KRESERVED + TID_URESERVED) -#define TID_MAX 255 -#define TID_NONE -1 - -#define TLB_UNLOCKED 0 - -#if !defined(LOCORE) - -typedef int tlbtid_t; - -struct pmap; - -void tlb_lock(uintptr_t *); -void tlb_unlock(uintptr_t *); -void tlb1_ap_prep(void); -int tlb1_set_entry(vm_offset_t, vm_paddr_t, vm_size_t, uint32_t); - -#endif /* !LOCORE */ - -#endif /* _MACHINE_TLB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/tls.h b/lib/libc/include/generic-freebsd/machine/tls.h index 6dea3eb3a99ffb89592ce27b9ea3e78c5fb0a7ff..9a386029151eaf9da9c7e5747f8992d4d1c2e721 100644 --- a/lib/libc/include/generic-freebsd/machine/tls.h +++ b/lib/libc/include/generic-freebsd/machine/tls.h @@ -1,66 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright 2004 by Peter Grehan. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _MACHINE_TLS_H_ -#define _MACHINE_TLS_H_ - -#include - -#define TLS_DTV_OFFSET 0x8000 -#define TLS_TCB_ALIGN TLS_TCB_SIZE -#define TLS_TP_OFFSET 0x7000 - -static __inline void -_tcb_set(struct tcb *tcb) -{ -#ifdef __powerpc64__ - __asm __volatile("mr 13,%0" :: - "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE)); -#else - __asm __volatile("mr 2,%0" :: - "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE)); -#endif -} - -static __inline struct tcb * -_tcb_get(void) -{ - struct tcb *tcb; - -#ifdef __powerpc64__ - __asm __volatile("addi %0,13,%1" : "=r" (tcb) : - "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE))); -#else - __asm __volatile("addi %0,2,%1" : "=r" (tcb) : - "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE))); -#endif - return (tcb); -} - -#endif /* !_MACHINE_TLS_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/trap.h b/lib/libc/include/generic-freebsd/machine/trap.h index 7326ba17c5cdefd361a944051cf1555a2924107f..d8320b7b3503429b2fcffd38825a130c4bb26faf 100644 --- a/lib/libc/include/generic-freebsd/machine/trap.h +++ b/lib/libc/include/generic-freebsd/machine/trap.h @@ -1,160 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: trap.h,v 1.7 2002/02/22 13:51:40 kleink Exp $ + * This file is in the public domain. */ -#ifndef _POWERPC_TRAP_H_ -#define _POWERPC_TRAP_H_ - -#define EXC_RSVD 0x0000 /* Reserved */ -#define EXC_RST 0x0100 /* Reset; all but IBM4xx */ -#define EXC_MCHK 0x0200 /* Machine Check */ -#define EXC_DSI 0x0300 /* Data Storage Interrupt */ -#define EXC_DSE 0x0380 /* Data Segment Interrupt */ -#define EXC_ISI 0x0400 /* Instruction Storage Interrupt */ -#define EXC_ISE 0x0480 /* Instruction Segment Interrupt */ -#define EXC_EXI 0x0500 /* External Interrupt */ -#define EXC_ALI 0x0600 /* Alignment Interrupt */ -#define EXC_PGM 0x0700 /* Program Interrupt */ -#define EXC_FPU 0x0800 /* Floating-point Unavailable */ -#define EXC_DECR 0x0900 /* Decrementer Interrupt */ -#define EXC_SC 0x0c00 /* System Call */ -#define EXC_TRC 0x0d00 /* Trace */ -#define EXC_FPA 0x0e00 /* Floating-point Assist */ - -/* The following is only available on the 601: */ -#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */ - -/* The following are only available on 970(G5): */ -#define EXC_VECAST_G5 0x1700 /* AltiVec Assist */ - -/* The following are only available on 7400(G4): */ -#define EXC_VEC 0x0f20 /* AltiVec Unavailable */ -#define EXC_VECAST_G4 0x1600 /* AltiVec Assist */ - -/* The following are only available on 604/750/7400: */ -#define EXC_PERF 0x0f00 /* Performance Monitoring */ -#define EXC_BPT 0x1300 /* Instruction Breakpoint */ -#define EXC_SMI 0x1400 /* System Managment Interrupt */ - -/* The following are only available on 750/7400: */ -#define EXC_THRM 0x1700 /* Thermal Management Interrupt */ - -/* And these are only on the 603: */ -#define EXC_IMISS 0x1000 /* Instruction translation miss */ -#define EXC_DLMISS 0x1100 /* Data load translation miss */ -#define EXC_DSMISS 0x1200 /* Data store translation miss */ - -/* Power ISA 2.06+: */ -#define EXC_HDSI 0x0e00 /* Hypervisor Data Storage */ -#define EXC_HISI 0x0e20 /* Hypervisor Instruction Storage */ -#define EXC_HEA 0x0e40 /* Hypervisor Emulation Assistance */ -#define EXC_HMI 0x0e60 /* Hypervisor Maintenance */ -#define EXC_VSX 0x0f40 /* VSX Unavailable */ - -/* Power ISA 2.07+: */ -#define EXC_FAC 0x0f60 /* Facility Unavailable */ -#define EXC_HFAC 0x0f80 /* Hypervisor Facility Unavailable */ - -/* Power ISA 3.0+: */ -#define EXC_HVI 0x0ea0 /* Hypervisor Virtualization */ - -/* The following are available on 4xx and 85xx */ -#define EXC_CRIT 0x0100 /* Critical Input Interrupt */ -#define EXC_PIT 0x1000 /* Programmable Interval Timer */ -#define EXC_FIT 0x1010 /* Fixed Interval Timer */ -#define EXC_WDOG 0x1020 /* Watchdog Timer */ -#define EXC_DTMISS 0x1100 /* Data TLB Miss */ -#define EXC_ITMISS 0x1200 /* Instruction TLB Miss */ -#define EXC_APU 0x1300 /* Auxiliary Processing Unit */ -#define EXC_DEBUG 0x2f10 /* Debug trap */ -#define EXC_VECAST_E 0x2f20 /* Altivec Assist (Book-E) */ -#define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */ -#define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */ - -/* POWER8 */ -#define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */ - -#define EXC_LAST 0x2f00 /* Last possible exception vector */ - -#define EXC_AST 0x3000 /* Fake AST vector */ - -/* Trap was in user mode */ -#define EXC_USER 0x10000 - -/* - * EXC_ALI sets bits in the DSISR and DAR to provide enough - * information to recover from the unaligned access without needing to - * parse the offending instruction. This includes certain bits of the - * opcode, and information about what registers are used. The opcode - * indicator values below come from Appendix F of Book III of "The - * PowerPC Architecture". - */ - -#define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f) -#define EXC_ALI_LFD 0x09 -#define EXC_ALI_STFD 0x0b - -/* Macros to extract register information */ -#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */ -#define EXC_ALI_RA(dsisr) (dsisr & 0x1f) -#define EXC_ALI_INST_RST(instr) ((instr >> 21) & 0x1f) - -/* - * SRR1 bits for program exception traps. These identify what caused - * the program exception. See section 6.5.9 of the Power ISA Version - * 2.05. - */ - -#define EXC_PGM_FPENABLED (1UL << 20) -#define EXC_PGM_ILLEGAL (1UL << 19) -#define EXC_PGM_PRIV (1UL << 18) -#define EXC_PGM_TRAP (1UL << 17) - -/* DTrace trap opcode. */ -#define EXC_DTRACE 0x7ffff808 - -/* Magic pointer to store TOC base and other info for trap handlers on ppc64 */ -#define TRAP_ENTRY 0x1e8 -#define TRAP_GENTRAP 0x1f0 -#define TRAP_TOCBASE 0x1f8 - -#ifndef LOCORE -struct trapframe; -struct thread; -extern int (*hmi_handler)(struct trapframe *); -void trap(struct trapframe *); -int ppc_instr_emulate(struct trapframe *, struct thread *); -#endif - -#endif /* _POWERPC_TRAP_H_ */ \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/ucontext.h b/lib/libc/include/generic-freebsd/machine/ucontext.h deleted file mode 100644 index 01a14ce3a6b8c85f86f07e3e52cfac1eda763e85..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/ucontext.h +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $ - */ - -#ifndef _MACHINE_UCONTEXT_H_ -#define _MACHINE_UCONTEXT_H_ - -typedef struct __mcontext { - int mc_vers; - int mc_flags; -#define _MC_FP_VALID 0x01 -#define _MC_AV_VALID 0x02 - int mc_onstack; /* saved onstack flag */ - int mc_len; /* sizeof(__mcontext) */ - __uint64_t mc_avec[32*2]; /* vector register file */ - __uint32_t mc_av[2]; - __register_t mc_frame[42]; - __uint64_t mc_fpreg[33]; - __uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ -} mcontext_t __aligned(16); - -#if defined(_KERNEL) && defined(__powerpc64__) -typedef struct __mcontext32 { - int mc_vers; - int mc_flags; -#define _MC_FP_VALID 0x01 -#define _MC_AV_VALID 0x02 - int mc_onstack; /* saved onstack flag */ - int mc_len; /* sizeof(__mcontext) */ - uint64_t mc_avec[32*2]; /* vector register file */ - uint32_t mc_av[2]; - uint32_t mc_frame[42]; - uint64_t mc_fpreg[33]; - uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ -} mcontext32_t __aligned(16); -#endif - -/* GPRs and supervisor-level regs */ -#define mc_gpr mc_frame -#define mc_lr mc_frame[32] -#define mc_cr mc_frame[33] -#define mc_xer mc_frame[34] -#define mc_ctr mc_frame[35] -#define mc_srr0 mc_frame[36] -#define mc_srr1 mc_frame[37] -#define mc_exc mc_frame[38] -#define mc_dar mc_frame[39] -#define mc_dsisr mc_frame[40] - -/* floating-point state */ -#define mc_fpscr mc_fpreg[32] - -/* altivec state */ -#define mc_vscr mc_av[0] -#define mc_vrsave mc_av[1] - -#define _MC_VERSION 0x1 -#define _MC_VERSION_KSE 0xee /* partial ucontext for libpthread */ - -#endif /* !_MACHINE_UCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/vdso.h b/lib/libc/include/generic-freebsd/machine/vdso.h index 2a3e6f6dfd8f9ef396902c6fda487f619485e786..57db69e06a7c2c84ff7cbc3a9913d6470271923d 100644 --- a/lib/libc/include/generic-freebsd/machine/vdso.h +++ b/lib/libc/include/generic-freebsd/machine/vdso.h @@ -1,43 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright 2012 Konstantin Belousov . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This file is in the public domain. */ -#ifndef _POWERPC_VDSO_H -#define _POWERPC_VDSO_H - -#define VDSO_TIMEHANDS_MD \ - uint32_t th_res[8]; - -#define VDSO_TH_ALGO_PPC_TB VDSO_TH_ALGO_1 - -#ifdef _KERNEL -#ifdef COMPAT_FREEBSD32 - -#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD - -#endif -#endif -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/vm.h b/lib/libc/include/generic-freebsd/machine/vm.h index fa397b398c8d1a027f88add570a9d7f0b6dc5343..fdd08a2e4de48f9f2449ec87870fab54d16cbae5 100644 --- a/lib/libc/include/generic-freebsd/machine/vm.h +++ b/lib/libc/include/generic-freebsd/machine/vm.h @@ -1,7 +1,8 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2009 Alan L. Cox + * Copyright (c) 2009 Hudson River Trading LLC + * Written by: John H. Baldwin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,17 +30,17 @@ #ifndef _MACHINE_VM_H_ #define _MACHINE_VM_H_ -#include +#include /* Memory attributes. */ -#define VM_MEMATTR_DEFAULT 0 -#define VM_MEMATTR_UNCACHEABLE 0x01 -#define VM_MEMATTR_CACHEABLE 0x02 -#define VM_MEMATTR_WRITE_COMBINING 0x04 -#define VM_MEMATTR_WRITE_BACK 0x08 -#define VM_MEMATTR_WRITE_THROUGH 0x10 -#define VM_MEMATTR_PREFETCHABLE 0x20 +#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) +#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) +#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) +#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) +#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) +#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED) -#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT +#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK +#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE #endif /* !_MACHINE_VM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/vmm_snapshot.h b/lib/libc/include/generic-freebsd/machine/vmm_snapshot.h new file mode 100644 index 0000000000000000000000000000000000000000..7a41612f9ec15c82aed5d15b4b7e1e69e43e2441 --- /dev/null +++ b/lib/libc/include/generic-freebsd/machine/vmm_snapshot.h @@ -0,0 +1 @@ +/* $FreeBSD$ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/machine/vmparam.h b/lib/libc/include/generic-freebsd/machine/vmparam.h deleted file mode 100644 index be779d31e0bf047846dbfe0598093af3a36fc85a..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/machine/vmparam.h +++ /dev/null @@ -1,329 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1995, 1996 Wolfgang Solfrank. - * Copyright (C) 1995, 1996 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $ - */ - -#ifndef _MACHINE_VMPARAM_H_ -#define _MACHINE_VMPARAM_H_ - -#ifndef LOCORE -#include -#endif - -#define USRSTACK SHAREDPAGE - -#ifndef MAXTSIZ -#define MAXTSIZ (1*1024*1024*1024) /* max text size */ -#endif - -#ifndef DFLDSIZ -#define DFLDSIZ (128*1024*1024) /* default data size */ -#endif - -#ifndef MAXDSIZ -#ifdef __powerpc64__ -#define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ -#else -#define MAXDSIZ (1*1024*1024*1024) /* max data size */ -#endif -#endif - -#ifndef DFLSSIZ -#define DFLSSIZ (8*1024*1024) /* default stack size */ -#endif - -#ifndef MAXSSIZ -#ifdef __powerpc64__ -#define MAXSSIZ (512*1024*1024) /* max stack size */ -#else -#define MAXSSIZ (64*1024*1024) /* max stack size */ -#endif -#endif - -#ifdef AIM -#define VM_MAXUSER_ADDRESS32 0xfffff000 -#else -#define VM_MAXUSER_ADDRESS32 0x7ffff000 -#endif - -/* - * Would like to have MAX addresses = 0, but this doesn't (currently) work - */ -#ifdef __powerpc64__ -/* - * Virtual addresses of things. Derived from the page directory and - * page table indexes from pmap.h for precision. - * - * kernel map should be able to start at 0xc008000000000000 - - * but at least the functional simulator doesn't like it - * - * 0x0000000000000000 - 0x000fffffffffffff user map - * 0xc000000000000000 - 0xc007ffffffffffff direct map - * 0xc008000000000000 - 0xc00fffffffffffff kernel map - * - */ -#define VM_MIN_ADDRESS 0x0000000000000000 -#define VM_MAXUSER_ADDRESS 0x000fffffc0000000 -#define VM_MAX_ADDRESS 0xc00fffffffffffff -#define VM_MIN_KERNEL_ADDRESS 0xc008000000000000 -#define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff -#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS -#else -#define VM_MIN_ADDRESS 0 -#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 -#define VM_MAX_ADDRESS 0xffffffff -#endif - -#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) - -#define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) -#define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE - -#define KERNBASE 0x00100100 /* start of kernel virtual */ - -#ifdef AIM -#ifndef __powerpc64__ -#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) -#define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) -#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) -#endif - -/* - * Use the direct-mapped BAT registers for UMA small allocs. This - * takes pressure off the small amount of available KVA. - */ -#define UMA_MD_SMALL_ALLOC - -#else /* Book-E */ - -/* Use the direct map for UMA small allocs on powerpc64. */ -#ifdef __powerpc64__ -#define UMA_MD_SMALL_ALLOC -#else -#define VM_MIN_KERNEL_ADDRESS 0xc0000000 -#define VM_MAX_KERNEL_ADDRESS 0xffffefff -#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS -#endif - -#endif /* AIM/E500 */ - -#if !defined(LOCORE) -struct pmap_physseg { - struct pv_entry *pvent; - char *attrs; -}; -#endif - -#ifdef __powerpc64__ -#define VM_PHYSSEG_MAX 63 /* 1? */ -#else -#define VM_PHYSSEG_MAX 16 /* 1? */ -#endif - -#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with - * logical memory block size of 64MB. - * For more Ram increase the lmb or this value. - */ - -/* XXX This is non-sensical. Phys avail should hold contiguous regions. */ -#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ - -/* - * The physical address space is densely populated on 32-bit systems, - * but may not be on 64-bit ones. - */ -#ifdef __powerpc64__ -#define VM_PHYSSEG_SPARSE -#else -#define VM_PHYSSEG_DENSE -#endif - -/* - * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool - * from which physical pages are allocated and VM_FREEPOOL_DIRECT is - * the pool from which physical pages for small UMA objects are - * allocated. - */ -#define VM_NFREEPOOL 2 -#define VM_FREEPOOL_DEFAULT 0 -#define VM_FREEPOOL_DIRECT 1 - -/* - * Create one free page list. - */ -#define VM_NFREELIST 1 -#define VM_FREELIST_DEFAULT 0 - -#ifdef __powerpc64__ -/* The largest allocation size is 16MB. */ -#define VM_NFREEORDER 13 -#else -/* The largest allocation size is 4MB. */ -#define VM_NFREEORDER 11 -#endif - -#ifndef VM_NRESERVLEVEL -#ifdef __powerpc64__ -/* Enable superpage reservations: 1 level. */ -#define VM_NRESERVLEVEL 1 -#else -/* Disable superpage reservations. */ -#define VM_NRESERVLEVEL 0 -#endif -#endif - -#ifndef VM_LEVEL_0_ORDER -/* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */ -#define VM_LEVEL_0_ORDER vm_level_0_order -#ifndef __ASSEMBLER__ -extern int vm_level_0_order; -#endif -#endif - -#ifndef VM_LEVEL_0_ORDER_MAX -#define VM_LEVEL_0_ORDER_MAX 12 -#endif - -#ifdef __powerpc64__ -#ifdef SMP -#define PA_LOCK_COUNT 256 -#endif -#endif - -#ifndef VM_INITIAL_PAGEIN -#define VM_INITIAL_PAGEIN 16 -#endif - -#ifndef SGROWSIZ -#define SGROWSIZ (128UL*1024) /* amount to grow stack */ -#endif - -/* - * How many physical pages per kmem arena virtual page. - */ -#ifndef VM_KMEM_SIZE_SCALE -#define VM_KMEM_SIZE_SCALE (3) -#endif - -/* - * Optional floor (in bytes) on the size of the kmem arena. - */ -#ifndef VM_KMEM_SIZE_MIN -#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) -#endif - -/* - * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the - * usable KVA space. - */ -#ifndef VM_KMEM_SIZE_MAX -#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ - VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) -#endif - -#ifdef __powerpc64__ -#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ -#else -#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ -#endif - -/* - * On 32-bit OEA, the only purpose for which sf_buf is used is to implement - * an opaque pointer required by the machine-independent parts of the kernel. - * That pointer references the vm_page that is "mapped" by the sf_buf. The - * actual mapping is provided by the direct virtual-to-physical mapping. - * - * On OEA64 and Book-E, we need to do something a little more complicated. Use - * the runtime-detected hw_direct_map to pick between the two cases. Our - * friends in vm_machdep.c will do the same to ensure nothing gets confused. - */ -#define SFBUF -#define SFBUF_NOMD - -/* - * We (usually) have a direct map of all physical memory, so provide - * a macro to use to get the kernel VA address for a given PA. Check the - * value of PMAP_HAS_PMAP before using. - */ -#ifndef LOCORE -#ifdef __powerpc64__ -#define DMAP_BASE_ADDRESS 0xc000000000000000UL -#define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS -#define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL -#else -#define DMAP_BASE_ADDRESS 0x00000000UL -#define DMAP_MAX_ADDRESS 0xbfffffffUL -#endif -#endif - -#if defined(__powerpc64__) || defined(BOOKE) -/* - * powerpc64 and Book-E will provide their own page array allocators. - * - * On AIM, this will allocate a single virtual array, with pages from the - * correct memory domains. - * On Book-E this will let us put the array in TLB1, removing the need for TLB - * thrashing. - * - * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. - */ -#define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS -#define PMAP_HAS_PAGE_ARRAY 1 -#endif - -#if defined(__powerpc64__) -/* - * Need a page dump array for minidump. - */ -#define MINIDUMP_PAGE_TRACKING 1 -#else -/* - * No minidump with 32-bit powerpc. - */ -#define MINIDUMP_PAGE_TRACKING 0 -#endif - -#define PMAP_HAS_DMAP (hw_direct_map) -#define PHYS_TO_DMAP(x) ({ \ - KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ - (x) | DMAP_BASE_ADDRESS; }) -#define DMAP_TO_PHYS(x) ({ \ - KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ - (x) &~ DMAP_BASE_ADDRESS; }) - -/* - * No non-transparent large page support in the pmap. - */ -#define PMAP_HAS_LARGEPAGES 0 - -#endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/math.h b/lib/libc/include/generic-freebsd/math.h index 1f049ec5a02fa8011534223dad23a454933a0cfd..3a9e3fa119dafbf626f12b67a4ea0e9eeb8e2eec 100644 --- a/lib/libc/include/generic-freebsd/math.h +++ b/lib/libc/include/generic-freebsd/math.h @@ -10,12 +10,12 @@ */ /* - * from: @(#)fdlibm.h 5.1 93/09/24 */ #ifndef _MATH_H_ #define _MATH_H_ +#include #include #include @@ -32,13 +32,8 @@ extern const union __nan_un { float __uf; } __nan; -#if __GNUC_PREREQ__(3, 3) #define __MATH_BUILTIN_CONSTANTS -#endif - -#if __GNUC_PREREQ__(3, 0) #define __MATH_BUILTIN_RELOPS -#endif #ifdef __MATH_BUILTIN_CONSTANTS #define HUGE_VAL __builtin_huge_val() @@ -77,10 +72,10 @@ extern const union __nan_un { #if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections) #define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \ - float: f(x), \ - double: d(x), \ - long double: ld(x)) -#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) + float: f, \ + double: d, \ + long double: ld)(x) +#elif !defined(__cplusplus) #define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof(x), long double), ld(x), \ __builtin_choose_expr( \ @@ -143,6 +138,22 @@ typedef __float_t float_t; #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#if __BSD_VISIBLE || __XSI_VISIBLE >= 800 +#define M_El 2.718281828459045235360287471352662498L /* e */ +#define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */ +#define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */ +#define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */ +#define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */ +#define M_PIl 3.141592653589793238462643383279502884L /* pi */ +#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */ +#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */ +#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */ +#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */ +#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */ +#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */ +#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ +#endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 800 */ + #define MAXFLOAT ((float)3.40282346638528860e+38) extern int signgam; #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ @@ -182,21 +193,21 @@ int __signbitf(float) __pure2; int __signbitl(long double) __pure2; static __inline int -__inline_isnan(__const double __x) +__inline_isnan(const double __x) { return (__x != __x); } static __inline int -__inline_isnanf(__const float __x) +__inline_isnanf(const float __x) { return (__x != __x); } static __inline int -__inline_isnanl(__const long double __x) +__inline_isnanl(const long double __x) { return (__x != __x); diff --git a/lib/libc/include/generic-freebsd/memory.h b/lib/libc/include/generic-freebsd/memory.h index 09031b50abb1d27c3d89bfd2d6c8880644a17497..56fbbe6aed28a8aee47753a5d266add972ea5cc1 100644 --- a/lib/libc/include/generic-freebsd/memory.h +++ b/lib/libc/include/generic-freebsd/memory.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)memory.h 8.1 (Berkeley) 6/2/93 */ #include \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/mntopts.h b/lib/libc/include/generic-freebsd/mntopts.h new file mode 100644 index 0000000000000000000000000000000000000000..36082194193ffc5b951c896dac0aac73d2dc305c --- /dev/null +++ b/lib/libc/include/generic-freebsd/mntopts.h @@ -0,0 +1,114 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MNTOPTS_H_ +#define _MNTOPTS_H_ + +struct mntopt { + const char *m_option; /* option name */ + int m_inverse; /* if a negative option, e.g. "atime" */ + long long m_flag; /* bit to set, e.g. MNT_RDONLY */ + int m_altloc; /* 1 => set bit in altflags */ +}; + +/* User-visible MNT_ flags. */ +#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } +#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } +#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } +#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } +#define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 } +#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } +#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } +#define MOPT_UNION { "union", 0, MNT_UNION, 0 } +#define MOPT_USERQUOTA { "userquota", 0, 0, 0 } +#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 } +#define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } +#define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } +#define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } +#define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 } +#define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 } +#define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } +#define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 } +#define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 } +#define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 } + +/* Control flags. */ +#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } +#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } +#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } +#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } +#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 } +#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 } +/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ +#define MOPT_AUTO { "auto", 0, 0, 0 } + +/* A handy macro as terminator of MNT_ array. */ +#define MOPT_END { NULL, 0, 0, 0 } + +#define MOPT_FSTAB_COMPAT \ + MOPT_RO, \ + MOPT_RW, \ + MOPT_AUTO + +/* Standard options which all mounts can understand. */ +#define MOPT_STDOPTS \ + MOPT_USERQUOTA, \ + MOPT_GROUPQUOTA, \ + MOPT_FSTAB_COMPAT, \ + MOPT_NOATIME, \ + MOPT_NOEXEC, \ + MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ + MOPT_NOSUID, \ + MOPT_NOSYMFOLLOW, \ + MOPT_RDONLY, \ + MOPT_UNION, \ + MOPT_NOCLUSTERR, \ + MOPT_NOCLUSTERW, \ + MOPT_MULTILABEL, \ + MOPT_ACLS, \ + MOPT_NFS4ACLS, \ + MOPT_AUTOMOUNTED, \ + MOPT_UNTRUSTED, \ + MOPT_NOCOVER, \ + MOPT_EMPTYDIR + +void getmntopts(const char *, const struct mntopt *, int *, int *); +void rmslashes(char *, char *); +int checkpath(const char *, char resolved_path[]); +int checkpath_allow_file(const char *, char resolved_path[]); +struct statfs *getmntpoint(const char *); +int chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2)); +extern int getmnt_silent; +void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); +void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); +void free_iovec(struct iovec **iovec, int *iovlen); + +#endif /* !_MNTOPTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/mpool.h b/lib/libc/include/generic-freebsd/mpool.h index 64bfd8a7cd52b9163e1039ff316631096596de75..fdabbf606f487eeffd269010c04a435e69286804 100644 --- a/lib/libc/include/generic-freebsd/mpool.h +++ b/lib/libc/include/generic-freebsd/mpool.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mpool.h 8.4 (Berkeley) 11/2/95 */ #ifndef _MPOOL_H_ diff --git a/lib/libc/include/generic-freebsd/mqueue.h b/lib/libc/include/generic-freebsd/mqueue.h index e76a659daaeaaadca1ce6ee972f1aaa6e154737e..366b4e84f4746bd0ec2faf25871bc7aa3b0a6003 100644 --- a/lib/libc/include/generic-freebsd/mqueue.h +++ b/lib/libc/include/generic-freebsd/mqueue.h @@ -29,7 +29,6 @@ #ifndef _MQUEUE_H_ #define _MQUEUE_H_ -#include #include #include #include diff --git a/lib/libc/include/generic-freebsd/ndbm.h b/lib/libc/include/generic-freebsd/ndbm.h index a647d2a89fdef93efb8eec8d28c82f98f80b506a..827654f64d8ce2976894b43337a06e7244500e6c 100644 --- a/lib/libc/include/generic-freebsd/ndbm.h +++ b/lib/libc/include/generic-freebsd/ndbm.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 */ #ifndef _NDBM_H_ diff --git a/lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h b/lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h index 82aa9a980d0c3bb7c9e1e65f822b58f840d689ef..9572784f5951518690c167f5075b909f3f569c3d 100644 --- a/lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h +++ b/lib/libc/include/generic-freebsd/net/altq/altq_rmclass.h @@ -38,8 +38,6 @@ #include -/* #pragma ident "@(#)rm_class.h 1.20 97/10/23 SMI" */ - #ifdef __cplusplus extern "C" { #endif diff --git a/lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h b/lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h index 32e7ee3e45fea6ee070d9b3fc0f6656411d8b33c..07f3aed89152b84ce641bf27161cc0e5fb083912 100644 --- a/lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h +++ b/lib/libc/include/generic-freebsd/net/altq/altq_rmclass_debug.h @@ -33,8 +33,6 @@ #ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_ #define _ALTQ_ALTQ_RMCLASS_DEBUG_H_ -/* #pragma ident "@(#)rm_class_debug.h 1.7 98/05/04 SMI" */ - /* * Cbq debugging macros */ diff --git a/lib/libc/include/generic-freebsd/net/bpf.h b/lib/libc/include/generic-freebsd/net/bpf.h index cac440dfbfea5a3c9fe9bffdbd557104400e8fd9..b80675ff20709eb05b7b154435c9607e02ee2cbe 100644 --- a/lib/libc/include/generic-freebsd/net/bpf.h +++ b/lib/libc/include/generic-freebsd/net/bpf.h @@ -32,14 +32,12 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)bpf.h 8.1 (Berkeley) 6/10/93 - * @(#)bpf.h 1.34 (LBL) 6/16/96 */ #ifndef _NET_BPF_H_ #define _NET_BPF_H_ +#include #include #include #include @@ -431,6 +429,7 @@ void bpfdetach(struct ifnet *); bool bpf_peers_present_if(struct ifnet *); #ifdef VIMAGE int bpf_get_bp_params(struct bpf_if *, u_int *, u_int *); +void bpf_ifdetach(struct ifnet *); #endif void bpfilterattach(int); diff --git a/lib/libc/include/generic-freebsd/net/bpfdesc.h b/lib/libc/include/generic-freebsd/net/bpfdesc.h index 6ddb9b06308050dcda3492306f4fd529960363ee..d2a512ee02bd5c1c5100e81574ac35116ffcaf6c 100644 --- a/lib/libc/include/generic-freebsd/net/bpfdesc.h +++ b/lib/libc/include/generic-freebsd/net/bpfdesc.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_BPFDESC_H_ diff --git a/lib/libc/include/generic-freebsd/net/dlt.h b/lib/libc/include/generic-freebsd/net/dlt.h index 41ed713449bd75c54fbae73f882b1588899fbb16..76be93efe7362931cd79500506686ee6893dc8e1 100644 --- a/lib/libc/include/generic-freebsd/net/dlt.h +++ b/lib/libc/include/generic-freebsd/net/dlt.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)bpf.h 7.1 (Berkeley) 5/7/91 */ #ifndef _NET_DLT_H_ diff --git a/lib/libc/include/generic-freebsd/net/ethernet.h b/lib/libc/include/generic-freebsd/net/ethernet.h index f9ba1ceb7b29961c8143450be4c7fd1537bbdc40..b78c080d72d4d076c60789c10f51aba1f1b594e8 100644 --- a/lib/libc/include/generic-freebsd/net/ethernet.h +++ b/lib/libc/include/generic-freebsd/net/ethernet.h @@ -40,7 +40,6 @@ /* * Ethernet-specific mbuf flags. */ -#define M_HASFCS M_PROTO5 /* FCS included at end of frame */ #define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */ /* @@ -63,6 +62,8 @@ struct ether_header { u_char ether_shost[ETHER_ADDR_LEN]; u_short ether_type; } __packed; +_Static_assert(sizeof(struct ether_header) == ETHER_HDR_LEN, + "size of struct ether_header is wrong"); /* * Structure of a 48-bit Ethernet address. @@ -70,6 +71,8 @@ struct ether_header { struct ether_addr { u_char octet[ETHER_ADDR_LEN]; } __packed; +_Static_assert(sizeof(struct ether_addr) == ETHER_ADDR_LEN, + "size of struct ether_addr is wrong"); #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ #define ETHER_IS_IPV6_MULTICAST(addr) \ @@ -81,6 +84,28 @@ struct ether_addr { (((addr)[0] | (addr)[1] | (addr)[2] | \ (addr)[3] | (addr)[4] | (addr)[5]) == 0x00) +/* + * 802.1q VID constants from IEEE 802.1Q-2014, table 9-2. + */ + +/* Null VID: The tag contains only PCP (priority) and DEI information. */ +#define DOT1Q_VID_NULL 0x0 +/* The default PVID for a bridge port. NB: bridge(4) does not honor this. */ +#define DOT1Q_VID_DEF_PVID 0x1 +/* The default SR_PVID for SRP Stream related traffic. */ +#define DOT1Q_VID_DEF_SR_PVID 0x2 +/* A VID reserved for implementation use, not permitted on the wire. */ +#define DOT1Q_VID_RSVD_IMPL 0xfff +/* The lowest valid VID. */ +#define DOT1Q_VID_MIN 0x1 +/* The highest valid VID. */ +#define DOT1Q_VID_MAX 0xffe + +/* + * This is the type of the VLAN ID inside the tag, not the tag itself. + */ +typedef uint16_t ether_vlanid_t; + /* * 802.1q Virtual LAN header. */ @@ -91,6 +116,8 @@ struct ether_vlan_header { uint16_t evl_tag; uint16_t evl_proto; } __packed; +_Static_assert(sizeof(struct ether_vlan_header) == ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN, + "size of struct ether_vlan_header is wrong"); #define EVL_VLID_MASK 0x0FFF #define EVL_PRI_MASK 0xE000 diff --git a/lib/libc/include/generic-freebsd/net/if.h b/lib/libc/include/generic-freebsd/net/if.h index a35a56388c7e1a7635644132e33e99485c910271..06d63a2df8ad3b1a313bccc79bf52fdedb3b9ba4 100644 --- a/lib/libc/include/generic-freebsd/net/if.h +++ b/lib/libc/include/generic-freebsd/net/if.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_H_ @@ -257,7 +255,8 @@ struct if_data { #define IFCAP_B_TXTLS_RTLMT 31 /* can do TLS with rate limiting */ #define IFCAP_B_RXTLS4 32 /* can to TLS receive for TCP */ #define IFCAP_B_RXTLS6 33 /* can to TLS receive for TCP6 */ -#define __IFCAP_B_SIZE 34 +#define IFCAP_B_IPSEC_OFFLOAD 34 /* inline IPSEC offload */ +#define __IFCAP_B_SIZE 35 #define IFCAP_B_MAX (__IFCAP_B_MAX - 1) #define IFCAP_B_SIZE (__IFCAP_B_SIZE) @@ -300,6 +299,7 @@ struct if_data { /* IFCAP2_* are integers, not bits. */ #define IFCAP2_RXTLS4 (IFCAP_B_RXTLS4 - 32) #define IFCAP2_RXTLS6 (IFCAP_B_RXTLS6 - 32) +#define IFCAP2_IPSEC_OFFLOAD (IFCAP_B_IPSEC_OFFLOAD - 32) #define IFCAP2_BIT(x) (1UL << (x)) diff --git a/lib/libc/include/generic-freebsd/net/if_arp.h b/lib/libc/include/generic-freebsd/net/if_arp.h index 5379ca79e5b5a00e76e018efb8fd2133a3d8104b..4a55d5fd686f3b6c5b58b78d8fd579373dcc29bd 100644 --- a/lib/libc/include/generic-freebsd/net/if_arp.h +++ b/lib/libc/include/generic-freebsd/net/if_arp.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_ARP_H_ diff --git a/lib/libc/include/generic-freebsd/net/if_bridgevar.h b/lib/libc/include/generic-freebsd/net/if_bridgevar.h index 6be40a8ec10f9c1ef3a479ac4cf9fc954940fa5a..09679bff72f637d1ea784c96e5e7c307107039af 100644 --- a/lib/libc/include/generic-freebsd/net/if_bridgevar.h +++ b/lib/libc/include/generic-freebsd/net/if_bridgevar.h @@ -74,7 +74,12 @@ * Data structure and control definitions for bridge interfaces. */ +#ifndef _NET_IF_BRIDGEVAR_H_ +#define _NET_IF_BRIDGEVAR_H_ + #include +#include +#include #include #include #include @@ -119,6 +124,22 @@ #define BRDGSPROTO 28 /* set protocol (ifbrparam) */ #define BRDGSTXHC 29 /* set tx hold count (ifbrparam) */ #define BRDGSIFAMAX 30 /* set max interface addrs (ifbreq) */ +#define BRDGSIFPVID 31 /* set if PVID */ +#define BRDGSIFVLANSET 32 /* set if vlan set */ +#define BRDGGIFVLANSET 33 /* get if vlan set */ +#define BRDGGFLAGS 34 /* get bridge flags (ifbrparam) */ +#define BRDGSFLAGS 35 /* set bridge flags (ifbrparam) */ +#define BRDGGDEFPVID 36 /* get default pvid (ifbrparam) */ +#define BRDGSDEFPVID 37 /* set default pvid (ifbrparam) */ +#define BRDGSIFVLANPROTO 38 /* set if vlan protocol (ifbreq) */ + +/* BRDGSFLAGS, Bridge flags (non-interface-specific) */ +typedef uint32_t ifbr_flags_t; + +#define IFBRF_VLANFILTER (1U<<0) /* VLAN filtering enabled */ +#define IFBRF_DEFQINQ (1U<<1) /* 802.1ad Q-in-Q allowed by default */ + +#define IFBRFBITS "\020\01VLANFILTER\02DEFQINQ" /* * Generic bridge control request. @@ -136,7 +157,9 @@ struct ifbreq { uint32_t ifbr_addrcnt; /* member if addr number */ uint32_t ifbr_addrmax; /* member if addr max */ uint32_t ifbr_addrexceeded; /* member if addr violations */ - uint8_t pad[32]; + ether_vlanid_t ifbr_pvid; /* member if PVID */ + uint16_t ifbr_vlanproto; /* member if VLAN protocol */ + uint8_t pad[28]; }; /* BRDGGIFFLAGS, BRDGSIFFLAGS */ @@ -152,10 +175,11 @@ struct ifbreq { #define IFBIF_BSTP_ADMEDGE 0x0200 /* member stp admin edge enabled */ #define IFBIF_BSTP_ADMCOST 0x0400 /* member stp admin path cost */ #define IFBIF_PRIVATE 0x0800 /* if is a private segment */ +#define IFBIF_QINQ 0x1000 /* if allows 802.1ad Q-in-Q */ #define IFBIFBITS "\020\001LEARNING\002DISCOVER\003STP\004SPAN" \ "\005STICKY\014PRIVATE\006EDGE\007AUTOEDGE\010PTP" \ - "\011AUTOPTP" + "\011AUTOPTP\015QINQ" #define IFBIFMASK ~(IFBIF_BSTP_EDGE|IFBIF_BSTP_AUTOEDGE|IFBIF_BSTP_PTP| \ IFBIF_BSTP_AUTOPTP|IFBIF_BSTP_ADMEDGE| \ IFBIF_BSTP_ADMCOST) /* not saved */ @@ -185,7 +209,7 @@ struct ifbareq { unsigned long ifba_expire; /* address expire time */ uint8_t ifba_flags; /* address flags */ uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */ - uint16_t ifba_vlan; /* vlan id */ + ether_vlanid_t ifba_vlan; /* vlan id */ }; #define IFBAF_TYPEMASK 0x03 /* address type mask */ @@ -227,7 +251,11 @@ struct ifbrparam { #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */ #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */ #define ifbrp_cexceeded ifbrp_ifbrpu.ifbrpu_int32 /* # of cache dropped - * adresses */ + * addresses */ +#define ifbrp_flags ifbrp_ifbrpu.ifbrpu_int32 /* bridge flags */ +#define ifbrp_defpvid ifbrp_ifbrpu.ifbrpu_int16 /* default pvid */ +#define ifbrp_vlanproto ifbrp_ifbrpu.ifbrpu_int8 /* vlan protocol */ + /* * Bridge current operational parameters structure. */ @@ -301,6 +329,26 @@ struct ifbpstpconf { eaddr[5] = pv >> 0; \ } while (0) +/* + * Bridge VLAN access request. + */ +#define BRVLAN_SETSIZE 4096 +typedef __BITSET_DEFINE(ifbvlan_set, BRVLAN_SETSIZE) ifbvlan_set_t; + +#define BRVLAN_SET(set, bit) __BIT_SET(BRVLAN_SETSIZE, (bit), set) +#define BRVLAN_CLR(set, bit) __BIT_CLR(BRVLAN_SETSIZE, (bit), set) +#define BRVLAN_TEST(set, bit) __BIT_ISSET(BRVLAN_SETSIZE, (bit), set) + +#define BRDG_VLAN_OP_SET 1 /* replace current vlan set */ +#define BRDG_VLAN_OP_ADD 2 /* add vlans to current set */ +#define BRDG_VLAN_OP_DEL 3 /* remove vlans from current set */ + +struct ifbif_vlan_req { + char bv_ifname[IFNAMSIZ]; + uint8_t bv_op; + ifbvlan_set_t bv_set; +}; + #ifdef _KERNEL #define BRIDGE_INPUT(_ifp, _m) do { \ @@ -320,5 +368,10 @@ struct ifbpstpconf { } while (0) extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *); +extern bool (*bridge_same_p)(const void *, const void *); +extern void *(*bridge_get_softc_p)(struct ifnet *); +extern bool (*bridge_member_ifaddrs_p)(void); -#endif /* _KERNEL */ \ No newline at end of file +#endif /* _KERNEL */ + +#endif /* _NET_IF_BRIDGEVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_clone.h b/lib/libc/include/generic-freebsd/net/if_clone.h index e9a25bffc1d878dae1230ee8dfaf5ced0b4a7195..84a7d91176b2b1c9da58fbdf3e77d8d1c5f07976 100644 --- a/lib/libc/include/generic-freebsd/net/if_clone.h +++ b/lib/libc/include/generic-freebsd/net/if_clone.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)if.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_CLONE_H_ @@ -150,13 +148,12 @@ typedef void (*if_clone_event_handler_t)(void *, struct if_clone *); EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t); /* The below interfaces used only by net/if.c. */ -void vnet_if_clone_init(void); int if_clone_create(char *, size_t, caddr_t); int if_clone_destroy(const char *); int if_clone_list(struct if_clonereq *); void if_clone_restoregroup(struct ifnet *); -/* The below interfaces are used only by epair(4). */ +/* The below interfaces are used only by epair(4) and tun(4)/tap(4). */ void if_clone_addif(struct if_clone *, struct ifnet *); int if_clone_destroyif(struct if_clone *, struct ifnet *); diff --git a/lib/libc/include/generic-freebsd/net/if_dl.h b/lib/libc/include/generic-freebsd/net/if_dl.h index 282d4b5fab7309da548431c64aa32355438dfa05..a88e404a535683557b15d558c9d06a8e8f3becd2 100644 --- a/lib/libc/include/generic-freebsd/net/if_dl.h +++ b/lib/libc/include/generic-freebsd/net/if_dl.h @@ -27,13 +27,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if_dl.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_DL_H_ #define _NET_IF_DL_H_ +#include + /* * A Link-Level Sockaddr may specify the interface in one of two * ways: either by means of a system-provided index number (computed @@ -67,22 +67,25 @@ struct sockaddr_dl { contains both if name and ll address */ }; -#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) -#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen)) +#define LLADDR(s) (&(s)->sdl_data[(s)->sdl_nlen]) #define LLINDEX(s) ((s)->sdl_index) +#ifdef _KERNEL + struct ifnet; -struct sockaddr_dl *link_alloc_sdl(size_t, int); +struct sockaddr_dl *link_alloc_sdl(size_t size, int flags); void link_free_sdl(struct sockaddr *sa); -struct sockaddr_dl *link_init_sdl(struct ifnet *, struct sockaddr *, u_char); +struct sockaddr_dl *link_init_sdl(struct ifnet *ifp, struct sockaddr *paddr, + u_char iftypes); -#ifndef _KERNEL +#else /* !_KERNEL */ #include __BEGIN_DECLS -void link_addr(const char *, struct sockaddr_dl *); +int link_addr(const char *, struct sockaddr_dl *); char *link_ntoa(const struct sockaddr_dl *); +int link_ntoa_r(const struct sockaddr_dl *, char *, size_t *); __END_DECLS #endif /* !_KERNEL */ diff --git a/lib/libc/include/generic-freebsd/net/if_gif.h b/lib/libc/include/generic-freebsd/net/if_gif.h index 76bc55ce9726d97763680d5d726bbee5c0cc99a0..7476c04d333c846c9976b9fbb8d31e409fe3524b 100644 --- a/lib/libc/include/generic-freebsd/net/if_gif.h +++ b/lib/libc/include/generic-freebsd/net/if_gif.h @@ -120,7 +120,8 @@ int in6_gif_setopts(struct gif_softc *, u_int); #define GIFGOPTS _IOWR('i', 150, struct ifreq) #define GIFSOPTS _IOW('i', 151, struct ifreq) +#define GIF_NOCLAMP 0x0001 #define GIF_IGNORE_SOURCE 0x0002 -#define GIF_OPTMASK (GIF_IGNORE_SOURCE) +#define GIF_OPTMASK (GIF_NOCLAMP|GIF_IGNORE_SOURCE) #endif /* _NET_IF_GIF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_llc.h b/lib/libc/include/generic-freebsd/net/if_llc.h index 555e2cd0641e3b42a0a381e3d45d6fcecaed9acd..fc5a6bd167e30bb4af3dc45f6c4e3b1372428374 100644 --- a/lib/libc/include/generic-freebsd/net/if_llc.h +++ b/lib/libc/include/generic-freebsd/net/if_llc.h @@ -29,8 +29,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_LLC_H_ diff --git a/lib/libc/include/generic-freebsd/net/if_media.h b/lib/libc/include/generic-freebsd/net/if_media.h index 5f35ef1a5dbcd502e107dc3fb2bdafb58e725158..8dae3a001497acacf98684fd502e1c0d976b6856 100644 --- a/lib/libc/include/generic-freebsd/net/if_media.h +++ b/lib/libc/include/generic-freebsd/net/if_media.h @@ -258,6 +258,8 @@ uint64_t ifmedia_baudrate(int); #define IFM_400G_AUI8 IFM_X(117) /* 400G-AUI8 */ #define IFM_50G_KR4 IFM_X(118) /* 50GBase-KR4 */ #define IFM_40G_LM4 IFM_X(119) /* 40GBase-LM4 */ +#define IFM_100_BX IFM_X(120) /* 100Base-BX */ +#define IFM_1000_BX IFM_X(121) /* 1000Base-BX */ /* * Please update ieee8023ad_lacp.c:lacp_compose_key() @@ -437,11 +439,13 @@ struct ifmedia_description { { IFM_100_T4, "100baseT4" }, \ { IFM_100_VG, "100baseVG" }, \ { IFM_100_T2, "100baseT2" }, \ + { IFM_100_BX, "100baseBX" }, \ { IFM_10_STP, "10baseSTP" }, \ { IFM_10_FL, "10baseFL" }, \ { IFM_1000_SX, "1000baseSX" }, \ { IFM_1000_LX, "1000baseLX" }, \ { IFM_1000_CX, "1000baseCX" }, \ + { IFM_1000_BX, "1000baseBX" }, \ { IFM_1000_T, "1000baseT" }, \ { IFM_HPNA_1, "homePNA" }, \ { IFM_10G_LR, "10Gbase-LR" }, \ @@ -784,11 +788,13 @@ struct ifmedia_baudrate { { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \ { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \ { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \ + { IFM_ETHER | IFM_100_BX, IF_Mbps(100) }, \ { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \ { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \ { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \ { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \ { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \ + { IFM_ETHER | IFM_1000_BX, IF_Mbps(1000) }, \ { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \ { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \ { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \ diff --git a/lib/libc/include/generic-freebsd/net/if_ovpn.h b/lib/libc/include/generic-freebsd/net/if_ovpn.h index d982717d87bb63769d9e6acc921654e281dbe712..6754b810fc765e02a5bcb43e0d20ad9c563f430a 100644 --- a/lib/libc/include/generic-freebsd/net/if_ovpn.h +++ b/lib/libc/include/generic-freebsd/net/if_ovpn.h @@ -37,6 +37,7 @@ enum ovpn_notif_type { OVPN_NOTIF_DEL_PEER, OVPN_NOTIF_ROTATE_KEY, + OVPN_NOTIF_FLOAT, }; enum ovpn_del_reason { diff --git a/lib/libc/include/generic-freebsd/net/if_pflog.h b/lib/libc/include/generic-freebsd/net/if_pflog.h index 327abfd631ea8941fa9874682370bfca55caa82c..18d333456befc85efaed67792cb5cef1784f00d4 100644 --- a/lib/libc/include/generic-freebsd/net/if_pflog.h +++ b/lib/libc/include/generic-freebsd/net/if_pflog.h @@ -33,8 +33,6 @@ #include -#define PFLOGIFS_MAX 16 - #define PFLOG_RULESET_NAME_SIZE 16 struct pfloghdr { @@ -51,7 +49,9 @@ struct pfloghdr { uid_t rule_uid; pid_t rule_pid; u_int8_t dir; - u_int8_t pad[3]; + u_int8_t pad1; /* rewritten, on OpenBSD */ + sa_family_t naf; + u_int8_t pad[1]; u_int32_t ridentifier; u_int8_t reserve; /* Appease broken software like Wireshark. */ u_int8_t pad2[3]; @@ -69,9 +69,9 @@ struct pf_ruleset; struct pfi_kif; struct pf_pdesc; -#define PFLOG_PACKET(i,a,b,c,d,e,f,g,di) do { \ +#define PFLOG_PACKET(b,t,c,d,e,f,g,h) do { \ if (pflog_packet_ptr != NULL) \ - pflog_packet_ptr(i,a,b,c,d,e,f,g,di); \ + pflog_packet_ptr(b,t,c,d,e,f,g,h); \ } while (0) #endif /* _KERNEL */ #endif /* _NET_IF_PFLOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_pfsync.h b/lib/libc/include/generic-freebsd/net/if_pfsync.h index fcbb52e2ef1323ea7a738bf332f7f13245802a77..a07c0d880f167926de2bcdcab1e112a779efb626 100644 --- a/lib/libc/include/generic-freebsd/net/if_pfsync.h +++ b/lib/libc/include/generic-freebsd/net/if_pfsync.h @@ -62,9 +62,10 @@ enum pfsync_msg_versions { PFSYNC_MSG_VERSION_UNSPECIFIED = 0, PFSYNC_MSG_VERSION_1301 = 1301, PFSYNC_MSG_VERSION_1400 = 1400, + PFSYNC_MSG_VERSION_1500 = 1500, }; -#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_1400 +#define PFSYNC_MSG_VERSION_DEFAULT PFSYNC_MSG_VERSION_1500 #define PFSYNC_ACT_CLR 0 /* clear all states */ #define PFSYNC_ACT_INS_1301 1 /* insert state */ @@ -81,7 +82,9 @@ enum pfsync_msg_versions { #define PFSYNC_ACT_EOF 12 /* end of frame */ #define PFSYNC_ACT_INS_1400 13 /* insert state */ #define PFSYNC_ACT_UPD_1400 14 /* update state */ -#define PFSYNC_ACT_MAX 15 +#define PFSYNC_ACT_INS_1500 15 /* insert state */ +#define PFSYNC_ACT_UPD_1500 16 /* update state */ +#define PFSYNC_ACT_MAX 17 /* * A pfsync frame is built from a header followed by several sections which @@ -160,8 +163,8 @@ struct pfsync_ins_ack { struct pfsync_upd_c { u_int64_t id; - struct pfsync_state_peer src; - struct pfsync_state_peer dst; + struct pf_state_peer_export src; + struct pf_state_peer_export dst; u_int32_t creatorid; u_int32_t expire; u_int8_t timeout; diff --git a/lib/libc/include/generic-freebsd/net/if_private.h b/lib/libc/include/generic-freebsd/net/if_private.h index f779490c3f09171d478999057a55182d83629430..22444e666053e8ed3dc6d3bb28af4be9c8cafcb9 100644 --- a/lib/libc/include/generic-freebsd/net/if_private.h +++ b/lib/libc/include/generic-freebsd/net/if_private.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)if.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_PRIVATE_H_ @@ -140,6 +138,8 @@ struct ifnet { int (*if_requestencap) /* make link header from request */ (struct ifnet *, struct if_encap_req *); + const struct if_ipsec_accel_methods *if_ipsec_accel_m; + /* Statistics. */ counter_u64_t if_counters[IFCOUNTERS]; diff --git a/lib/libc/include/generic-freebsd/net/if_strings.h b/lib/libc/include/generic-freebsd/net/if_strings.h index b58825cdce5b4521c36f40cc765ee85979ff3748..1427475b2fde1fc4b4e33db3ab75fee6489ea4a4 100644 --- a/lib/libc/include/generic-freebsd/net/if_strings.h +++ b/lib/libc/include/generic-freebsd/net/if_strings.h @@ -60,10 +60,13 @@ #define IFCAP_TXTLS_RTLMT_NAME "TXTLS_RTLMT" #define IFCAP_RXTLS4_NAME "RXTLS4" #define IFCAP_RXTLS6_NAME "RXTLS6" +#define IFCAP_IPSEC_OFFLOAD_NAME "IPSEC" #define IFCAP2_RXTLS4_NAME IFCAP_RXTLS4_NAME #define IFCAP2_RXTLS6_NAME IFCAP_RXTLS6_NAME +#define IFCAP2_IPSEC_OFFLOAD_NAME IFCAP_IPSEC_OFFLOAD_NAME +#ifdef _WANT_IFCAP_BIT_NAMES static const char *ifcap_bit_names[] = { IFCAP_RXCSUM_NAME, IFCAP_TXCSUM_NAME, @@ -99,11 +102,13 @@ static const char *ifcap_bit_names[] = { IFCAP_TXTLS_RTLMT_NAME, IFCAP_RXTLS4_NAME, IFCAP_RXTLS6_NAME, + IFCAP_IPSEC_OFFLOAD_NAME, }; #ifdef IFCAP_B_SIZE _Static_assert(sizeof(ifcap_bit_names) >= IFCAP_B_SIZE * sizeof(char *), "ifcap bit names missing from ifcap_bit_names"); #endif +#endif #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_tap.h b/lib/libc/include/generic-freebsd/net/if_tap.h index 7c06de555fa83584b4a05ddb1a1e08011be84696..4c9e86ef847e443289ebdaa6d6ea797d1d325297 100644 --- a/lib/libc/include/generic-freebsd/net/if_tap.h +++ b/lib/libc/include/generic-freebsd/net/if_tap.h @@ -57,6 +57,8 @@ #define TAPGIFNAME TUNGIFNAME #define TAPSVNETHDR _IOW('t', 91, int) #define TAPGVNETHDR _IOR('t', 94, int) +#define TAPSTRANSIENT TUNSTRANSIENT +#define TAPGTRANSIENT TUNGTRANSIENT /* VMware ioctl's */ #define VMIO_SIOCSIFFLAGS _IOWINT('V', 0) diff --git a/lib/libc/include/generic-freebsd/net/if_tun.h b/lib/libc/include/generic-freebsd/net/if_tun.h index 7c6e2e7361f32e9d0a5aecb7d79104c65e901401..ca80dd32b2e933340e40ce3a2fb7168fdc4730ac 100644 --- a/lib/libc/include/generic-freebsd/net/if_tun.h +++ b/lib/libc/include/generic-freebsd/net/if_tun.h @@ -43,5 +43,7 @@ struct tuninfo { #define TUNSIFPID _IO('t', 95) #define TUNSIFHEAD _IOW('t', 96, int) #define TUNGIFHEAD _IOR('t', 97, int) +#define TUNSTRANSIENT _IOW('t', 98, int) +#define TUNGTRANSIENT _IOR('t', 99, int) #endif /* !_NET_IF_TUN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_types.h b/lib/libc/include/generic-freebsd/net/if_types.h index e4869b3b6d744e6baed959a3952cdc09338e7cf8..918e3f7e465b23dec518879367835e79fe1f1ac6 100644 --- a/lib/libc/include/generic-freebsd/net/if_types.h +++ b/lib/libc/include/generic-freebsd/net/if_types.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if_types.h 8.3 (Berkeley) 4/28/95 * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $ */ @@ -256,6 +254,7 @@ typedef enum { IFT_PFLOG = 0xf6, /* PF packet filter logging */ IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */ IFT_WIREGUARD = 0xf8, /* WireGuard tunnel */ + IFT_MBIM = 0xf9, /* Mobile Broadband Interface Model */ } ifType; /* diff --git a/lib/libc/include/generic-freebsd/net/if_var.h b/lib/libc/include/generic-freebsd/net/if_var.h index 57d135eacfe233eb8e16666f3626b3bae4b98501..f4e12ce9ec97f3ae4fd06f155fdda009a7933c4b 100644 --- a/lib/libc/include/generic-freebsd/net/if_var.h +++ b/lib/libc/include/generic-freebsd/net/if_var.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)if.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_VAR_H_ @@ -133,6 +131,25 @@ typedef void (*if_qflush_fn_t)(if_t); typedef int (*if_transmit_fn_t)(if_t, struct mbuf *); typedef uint64_t (*if_get_counter_t)(if_t, ift_counter); typedef void (*if_reassign_fn_t)(if_t, struct vnet *, char *); +typedef int (*if_spdadd_fn_t)(if_t ifp, void *sp, void *inp, void **priv); +typedef int (*if_spddel_fn_t)(if_t ifp, void *sp, void *priv); +typedef int (*if_sa_newkey_fn_t)(if_t ifp, void *sav, u_int drv_spi, + void **privp); +typedef int (*if_sa_deinstall_fn_t)(if_t ifp, u_int drv_spi, void *priv); +struct seclifetime; +#define IF_SA_CNT_UPD 0x80000000 +enum IF_SA_CNT_WHICH { + IF_SA_CNT_IFP_HW_VAL = 1, + IF_SA_CNT_TOTAL_SW_VAL, + IF_SA_CNT_TOTAL_HW_VAL, + IF_SA_CNT_IFP_HW_UPD = IF_SA_CNT_IFP_HW_VAL | IF_SA_CNT_UPD, + IF_SA_CNT_TOTAL_SW_UPD = IF_SA_CNT_TOTAL_SW_VAL | IF_SA_CNT_UPD, + IF_SA_CNT_TOTAL_HW_UPD = IF_SA_CNT_TOTAL_HW_VAL | IF_SA_CNT_UPD, +}; +typedef int (*if_sa_cnt_fn_t)(if_t ifp, void *sa, + uint32_t drv_spi, void *priv, struct seclifetime *lt); +typedef int (*if_ipsec_hwassist_fn_t)(if_t ifp, void *sav, + u_int drv_spi,void *priv); struct ifnet_hw_tsomax { u_int tsomaxbytes; /* TSO total burst length limit in bytes */ @@ -280,12 +297,14 @@ typedef int (if_snd_tag_modify_t)(struct m_snd_tag *, union if_snd_tag_modify_pa typedef int (if_snd_tag_query_t)(struct m_snd_tag *, union if_snd_tag_query_params *); typedef void (if_snd_tag_free_t)(struct m_snd_tag *); typedef struct m_snd_tag *(if_next_send_tag_t)(struct m_snd_tag *); +typedef int (if_snd_tag_status_str_t)(struct m_snd_tag *, char *buf, size_t *sz); struct if_snd_tag_sw { if_snd_tag_modify_t *snd_tag_modify; if_snd_tag_query_t *snd_tag_query; if_snd_tag_free_t *snd_tag_free; if_next_send_tag_t *next_snd_tag; + if_snd_tag_status_str_t *snd_tag_status_str; u_int type; /* One of IF_SND_TAG_TYPE_*. */ }; @@ -603,6 +622,7 @@ int if_setmtu(if_t ifp, int mtu); int if_getmtu(const if_t ifp); int if_getmtu_family(const if_t ifp, int family); void if_notifymtu(if_t ifp); +void if_setppromisc(const if_t ifp, bool ppromisc); int if_setflagbits(if_t ifp, int set, int clear); int if_setflags(if_t ifp, int flags); int if_getflags(const if_t ifp); @@ -626,11 +646,9 @@ void if_setrcvif(struct mbuf *m, if_t ifp); void if_setvtag(struct mbuf *m, u_int16_t tag); u_int16_t if_getvtag(struct mbuf *m); int if_vlantrunkinuse(if_t ifp); -caddr_t if_getlladdr(const if_t ifp); +char *if_getlladdr(const if_t ifp); struct vnet *if_getvnet(const if_t ifp); void *if_gethandle(u_char); -void if_bpfmtap(if_t ifp, struct mbuf *m); -void if_etherbpfmtap(if_t ifp, struct mbuf *m); void if_vlancap(if_t ifp); int if_transmit(if_t ifp, struct mbuf *m); void if_init(if_t ifp, void *ctx); @@ -703,6 +721,20 @@ void if_setdebugnet_methods(if_t, struct debugnet_methods *); void if_setreassignfn(if_t ifp, if_reassign_fn_t); void if_setratelimitqueryfn(if_t ifp, if_ratelimit_query_t); +/* + * NB: The interface is not yet stable, drivers implementing IPSEC + * offload need to be prepared to adapt to changes. + */ +struct if_ipsec_accel_methods { + if_spdadd_fn_t if_spdadd; + if_spddel_fn_t if_spddel; + if_sa_newkey_fn_t if_sa_newkey; + if_sa_deinstall_fn_t if_sa_deinstall; + if_sa_cnt_fn_t if_sa_cnt; + if_ipsec_hwassist_fn_t if_hwassist; +}; +void if_setipsec_accel_methods(if_t ifp, const struct if_ipsec_accel_methods *); + /* TSO */ void if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *); int if_hw_tsomax_update(if_t ifp, struct ifnet_hw_tsomax *); @@ -724,7 +756,6 @@ int ether_poll_deregister(if_t ifp); #endif /* _KERNEL */ -#include /* XXX: temporary until drivers converted. */ #include /* XXXAO: temporary unconditional include */ #endif /* !_NET_IF_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/if_vlan_var.h b/lib/libc/include/generic-freebsd/net/if_vlan_var.h index 24397ce8e91bf1a2f1863be752dca1462abd225e..5cdcc962d344e3201e60b2b62862a4cf48c4eb7b 100644 --- a/lib/libc/include/generic-freebsd/net/if_vlan_var.h +++ b/lib/libc/include/generic-freebsd/net/if_vlan_var.h @@ -126,11 +126,6 @@ struct vlanreq { #define VLAN_PCP_MAX 7 -#define DOT1Q_VID_NULL 0x0 -#define DOT1Q_VID_DEF_PVID 0x1 -#define DOT1Q_VID_DEF_SR_PVID 0x2 -#define DOT1Q_VID_RSVD_IMPL 0xfff - /* * 802.1q full tag. Proto and vid are stored in host byte order. */ @@ -166,6 +161,7 @@ extern int (*vlan_tag_p)(struct ifnet *, uint16_t *); extern int (*vlan_pcp_p)(struct ifnet *, uint16_t *); extern int (*vlan_setcookie_p)(struct ifnet *, void *); extern void *(*vlan_cookie_p)(struct ifnet *); +extern void (*vlan_input_p)(struct ifnet *, struct mbuf *); #include diff --git a/lib/libc/include/generic-freebsd/net/iflib.h b/lib/libc/include/generic-freebsd/net/iflib.h index 45be7047a35da6c2aae982380368f88326f74e35..e32f0eed63149f7d0fdcb65180c97d43704adb27 100644 --- a/lib/libc/include/generic-freebsd/net/iflib.h +++ b/lib/libc/include/generic-freebsd/net/iflib.h @@ -121,13 +121,13 @@ typedef struct if_pkt_info { uint16_t ipi_tso_segsz; /* tso segment size */ uint16_t ipi_vtag; /* VLAN tag */ uint16_t ipi_etype; /* ether header type */ - uint8_t ipi_tcp_hflags; /* tcp header flags */ - uint8_t ipi_mflags; /* packet mbuf flags */ + uint16_t ipi_tcp_hflags; /* tcp header flags */ uint32_t ipi_tcp_seq; /* tcp seqno */ uint8_t ipi_ip_tos; /* IP ToS field data */ + uint8_t ipi_mflags; /* packet mbuf flags */ uint8_t __spare0__; - uint16_t __spare1__; + uint8_t __spare1__; } *if_pkt_info_t; typedef struct if_irq { @@ -470,9 +470,9 @@ void iflib_irq_free(if_ctx_t ctx, if_irq_t irq); void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu, const char *name); -void iflib_config_gtask_init(void *ctx, struct grouptask *gtask, - gtask_fn_t *fn, const char *name); -void iflib_config_gtask_deinit(struct grouptask *gtask); +void iflib_config_task_init(if_ctx_t ctx, struct task *config_task, + task_fn_t *fn); +void iflib_config_task_enqueue(if_ctx_t ctx, struct task *config_task); void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid); void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid); diff --git a/lib/libc/include/generic-freebsd/net/ifq.h b/lib/libc/include/generic-freebsd/net/ifq.h index c114e91cc30a0c43226217212a7a0891ce889990..5a55dc1d895426fecb3f64df3f272187fa710b57 100644 --- a/lib/libc/include/generic-freebsd/net/ifq.h +++ b/lib/libc/include/generic-freebsd/net/ifq.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)if.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IFQ_H_ diff --git a/lib/libc/include/generic-freebsd/net/pfkeyv2.h b/lib/libc/include/generic-freebsd/net/pfkeyv2.h index 8b0e7d3ddcc307e53d6b862f053f96a0c9c82cf0..cd4e4b9e60725491830630f0e5321dbeee40d1e3 100644 --- a/lib/libc/include/generic-freebsd/net/pfkeyv2.h +++ b/lib/libc/include/generic-freebsd/net/pfkeyv2.h @@ -296,6 +296,13 @@ struct sadb_x_sa_replay { }; _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch"); +struct sadb_x_if_hw_offl { + u_int16_t sadb_x_if_hw_offl_len; + u_int16_t sadb_x_if_hw_offl_exttype; + u_int32_t sadb_x_if_hw_offl_flags; + u_int8_t sadb_x_if_hw_offl_if[32]; /* IF_NAMESIZE is 16, keep room */ +}; + #define SADB_EXT_RESERVED 0 #define SADB_EXT_SA 1 #define SADB_EXT_LIFETIME_CURRENT 2 @@ -326,7 +333,10 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch"); #define SADB_X_EXT_SA_REPLAY 26 /* Replay window override. */ #define SADB_X_EXT_NEW_ADDRESS_SRC 27 #define SADB_X_EXT_NEW_ADDRESS_DST 28 -#define SADB_EXT_MAX 28 +#define SADB_X_EXT_LFT_CUR_SW_OFFL 29 +#define SADB_X_EXT_LFT_CUR_HW_OFFL 30 +#define SADB_X_EXT_IF_HW_OFFL 31 +#define SADB_EXT_MAX 31 #define SADB_SATYPE_UNSPEC 0 #define SADB_SATYPE_AH 2 @@ -444,13 +454,13 @@ _Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch"); /* Utilities */ #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1))) #define PFKEY_EXTLEN(msg) \ - PFKEY_UNUNIT64(((struct sadb_ext *)(msg))->sadb_ext_len) + PFKEY_UNUNIT64(((const struct sadb_ext *)(msg))->sadb_ext_len) #define PFKEY_ADDR_PREFIX(ext) \ - (((struct sadb_address *)(ext))->sadb_address_prefixlen) + (((const struct sadb_address *)(ext))->sadb_address_prefixlen) #define PFKEY_ADDR_PROTO(ext) \ - (((struct sadb_address *)(ext))->sadb_address_proto) + (((const struct sadb_address *)(ext))->sadb_address_proto) #define PFKEY_ADDR_SADDR(ext) \ - ((struct sockaddr *)((caddr_t)(ext) + sizeof(struct sadb_address))) + ((const struct sockaddr *)((c_caddr_t)(ext) + sizeof(struct sadb_address))) /* in 64bits */ #define PFKEY_UNUNIT64(a) ((a) << 3) diff --git a/lib/libc/include/generic-freebsd/net/pflow.h b/lib/libc/include/generic-freebsd/net/pflow.h new file mode 100644 index 0000000000000000000000000000000000000000..8fcbfe666232059b424d49407ec4e2df92dc0ef0 --- /dev/null +++ b/lib/libc/include/generic-freebsd/net/pflow.h @@ -0,0 +1,382 @@ +/* $OpenBSD: if_pflow.h,v 1.19 2022/11/23 15:12:27 mvs Exp $ */ + +/* + * Copyright (c) 2008 Henning Brauer + * Copyright (c) 2008 Joerg Goltermann + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _NET_IF_PFLOW_H_ +#define _NET_IF_PFLOW_H_ + +#include +#include +#include + +#include + +#ifdef _KERNEL +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#endif + +#define PFLOW_MAX_ENTRIES 128 + +#define PFLOW_ID_LEN sizeof(u_int64_t) + +#define PFLOW_MAXFLOWS 30 +#define PFLOW_ENGINE_TYPE 42 +#define PFLOW_ENGINE_ID 42 +#define PFLOW_MAXBYTES 0xffffffff +#define PFLOW_TIMEOUT 30 +#define PFLOW_TMPL_TIMEOUT 30 /* rfc 5101 10.3.6 (p.40) recommends 600 */ + +#define PFLOW_IPFIX_TMPL_SET_ID 2 + +/* RFC 5102 Information Element Identifiers */ + +#define PFIX_IE_octetDeltaCount 1 +#define PFIX_IE_packetDeltaCount 2 +#define PFIX_IE_protocolIdentifier 4 +#define PFIX_IE_ipClassOfService 5 +#define PFIX_IE_sourceTransportPort 7 +#define PFIX_IE_sourceIPv4Address 8 +#define PFIX_IE_ingressInterface 10 +#define PFIX_IE_destinationTransportPort 11 +#define PFIX_IE_destinationIPv4Address 12 +#define PFIX_IE_egressInterface 14 +#define PFIX_IE_flowEndSysUpTime 21 +#define PFIX_IE_flowStartSysUpTime 22 +#define PFIX_IE_sourceIPv6Address 27 +#define PFIX_IE_destinationIPv6Address 28 +#define PFIX_IE_flowStartMilliseconds 152 +#define PFIX_IE_flowEndMilliseconds 153 +#define PFIX_IE_postNATSourceIPv4Address 225 +#define PFIX_IE_postNATDestinationIPv4Address 226 +#define PFIX_IE_postNAPTSourceTransportPort 227 +#define PFIX_IE_postNAPTDestinationTransportPort 228 +#define PFIX_IE_natEvent 230 +#define PFIX_NAT_EVENT_SESSION_CREATE 4 +#define PFIX_NAT_EVENT_SESSION_DELETE 5 +#define PFIX_IE_timeStamp 323 + +struct pflow_flow { + u_int32_t src_ip; + u_int32_t dest_ip; + u_int32_t nexthop_ip; + u_int16_t if_index_in; + u_int16_t if_index_out; + u_int32_t flow_packets; + u_int32_t flow_octets; + u_int32_t flow_start; + u_int32_t flow_finish; + u_int16_t src_port; + u_int16_t dest_port; + u_int8_t pad1; + u_int8_t tcp_flags; + u_int8_t protocol; + u_int8_t tos; + u_int16_t src_as; + u_int16_t dest_as; + u_int8_t src_mask; + u_int8_t dest_mask; + u_int16_t pad2; +} __packed; + +struct pflow_set_header { + u_int16_t set_id; + u_int16_t set_length; /* total length of the set, + in octets, including the set header */ +} __packed; + +#define PFLOW_SET_HDRLEN sizeof(struct pflow_set_header) + +struct pflow_tmpl_hdr { + u_int16_t tmpl_id; + u_int16_t field_count; +} __packed; + +struct pflow_tmpl_fspec { + u_int16_t field_id; + u_int16_t len; +} __packed; + +/* update pflow_clone_create() when changing pflow_ipfix_tmpl_ipv4 */ +struct pflow_ipfix_tmpl_ipv4 { + struct pflow_tmpl_hdr h; + struct pflow_tmpl_fspec src_ip; + struct pflow_tmpl_fspec dest_ip; + struct pflow_tmpl_fspec if_index_in; + struct pflow_tmpl_fspec if_index_out; + struct pflow_tmpl_fspec packets; + struct pflow_tmpl_fspec octets; + struct pflow_tmpl_fspec start; + struct pflow_tmpl_fspec finish; + struct pflow_tmpl_fspec src_port; + struct pflow_tmpl_fspec dest_port; + struct pflow_tmpl_fspec tos; + struct pflow_tmpl_fspec protocol; +#define PFLOW_IPFIX_TMPL_IPV4_FIELD_COUNT 12 +#define PFLOW_IPFIX_TMPL_IPV4_ID 256 +} __packed; + +/* update pflow_clone_create() when changing pflow_ipfix_tmpl_v6 */ +struct pflow_ipfix_tmpl_ipv6 { + struct pflow_tmpl_hdr h; + struct pflow_tmpl_fspec src_ip; + struct pflow_tmpl_fspec dest_ip; + struct pflow_tmpl_fspec if_index_in; + struct pflow_tmpl_fspec if_index_out; + struct pflow_tmpl_fspec packets; + struct pflow_tmpl_fspec octets; + struct pflow_tmpl_fspec start; + struct pflow_tmpl_fspec finish; + struct pflow_tmpl_fspec src_port; + struct pflow_tmpl_fspec dest_port; + struct pflow_tmpl_fspec tos; + struct pflow_tmpl_fspec protocol; +#define PFLOW_IPFIX_TMPL_IPV6_FIELD_COUNT 12 +#define PFLOW_IPFIX_TMPL_IPV6_ID 257 +} __packed; + +struct pflow_ipfix_tmpl_nat44 { + struct pflow_tmpl_hdr h; + struct pflow_tmpl_fspec timestamp; + struct pflow_tmpl_fspec nat_event; + struct pflow_tmpl_fspec protocol; + struct pflow_tmpl_fspec src_ip; + struct pflow_tmpl_fspec src_port; + struct pflow_tmpl_fspec postnat_src_ip; + struct pflow_tmpl_fspec postnat_src_port; + struct pflow_tmpl_fspec dst_ip; + struct pflow_tmpl_fspec dst_port; + struct pflow_tmpl_fspec postnat_dst_ip; + struct pflow_tmpl_fspec postnat_dst_port; +#define PFLOW_IPFIX_TMPL_NAT44_FIELD_COUNT 11 +#define PFLOW_IPFIX_TMPL_NAT44_ID 258 +}; + +struct pflow_ipfix_tmpl { + struct pflow_set_header set_header; + struct pflow_ipfix_tmpl_ipv4 ipv4_tmpl; + struct pflow_ipfix_tmpl_ipv6 ipv6_tmpl; + struct pflow_ipfix_tmpl_nat44 nat44_tmpl; +} __packed; + +struct pflow_ipfix_flow4 { + u_int32_t src_ip; /* sourceIPv4Address*/ + u_int32_t dest_ip; /* destinationIPv4Address */ + u_int32_t if_index_in; /* ingressInterface */ + u_int32_t if_index_out; /* egressInterface */ + u_int64_t flow_packets; /* packetDeltaCount */ + u_int64_t flow_octets; /* octetDeltaCount */ + int64_t flow_start; /* flowStartMilliseconds */ + int64_t flow_finish; /* flowEndMilliseconds */ + u_int16_t src_port; /* sourceTransportPort */ + u_int16_t dest_port; /* destinationTransportPort */ + u_int8_t tos; /* ipClassOfService */ + u_int8_t protocol; /* protocolIdentifier */ + /* XXX padding needed? */ +} __packed; + +struct pflow_ipfix_flow6 { + struct in6_addr src_ip; /* sourceIPv6Address */ + struct in6_addr dest_ip; /* destinationIPv6Address */ + u_int32_t if_index_in; /* ingressInterface */ + u_int32_t if_index_out; /* egressInterface */ + u_int64_t flow_packets; /* packetDeltaCount */ + u_int64_t flow_octets; /* octetDeltaCount */ + int64_t flow_start; /* flowStartMilliseconds */ + int64_t flow_finish; /* flowEndMilliseconds */ + u_int16_t src_port; /* sourceTransportPort */ + u_int16_t dest_port; /* destinationTransportPort */ + u_int8_t tos; /* ipClassOfService */ + u_int8_t protocol; /* protocolIdentifier */ + /* XXX padding needed? */ +} __packed; + +struct pflow_ipfix_nat4 { + u_int64_t timestamp; /* timeStamp */ + u_int8_t nat_event; /* natEvent */ + u_int8_t protocol; /* protocolIdentifier */ + u_int32_t src_ip; /* sourceIPv4Address */ + u_int16_t src_port; /* sourceTransportPort */ + u_int32_t postnat_src_ip; /* postNATSourceIPv4Address */ + u_int16_t postnat_src_port;/* postNAPTSourceTransportPort */ + u_int32_t dest_ip; /* destinationIPv4Address */ + u_int16_t dest_port; /* destinationTransportPort */ + u_int32_t postnat_dest_ip;/* postNATDestinationIPv4Address */ + u_int16_t postnat_dest_port;/* postNAPTDestinationTransportPort */ +} __packed; + +#ifdef _KERNEL + +struct pflow_softc { + int sc_id; + + struct mtx sc_lock; + + int sc_dying; /* [N] */ + struct vnet *sc_vnet; + + unsigned int sc_count; + unsigned int sc_count4; + unsigned int sc_count6; + unsigned int sc_count_nat4; + unsigned int sc_maxcount; + unsigned int sc_maxcount4; + unsigned int sc_maxcount6; + unsigned int sc_maxcount_nat4; + u_int32_t sc_gcounter; + u_int32_t sc_sequence; + struct callout sc_tmo; + struct callout sc_tmo6; + struct callout sc_tmo_nat4; + struct callout sc_tmo_tmpl; + struct intr_event *sc_swi_ie; + void *sc_swi_cookie; + struct mbufq sc_outputqueue; + struct task sc_outputtask; + struct socket *so; /* [p] */ + struct sockaddr *sc_flowsrc; + struct sockaddr *sc_flowdst; + struct pflow_ipfix_tmpl sc_tmpl_ipfix; + u_int8_t sc_version; + u_int32_t sc_observation_dom; + struct mbuf *sc_mbuf; /* current cumulative mbuf */ + struct mbuf *sc_mbuf6; /* current cumulative mbuf */ + struct mbuf *sc_mbuf_nat4; + CK_LIST_ENTRY(pflow_softc) sc_next; + struct epoch_context sc_epoch_ctx; +}; + +#endif /* _KERNEL */ + +struct pflow_header { + u_int16_t version; + u_int16_t count; + u_int32_t uptime_ms; + u_int32_t time_sec; + u_int32_t time_nanosec; + u_int32_t flow_sequence; + u_int8_t engine_type; + u_int8_t engine_id; + u_int8_t reserved1; + u_int8_t reserved2; +} __packed; + +#define PFLOW_HDRLEN sizeof(struct pflow_header) + +struct pflow_v10_header { + u_int16_t version; + u_int16_t length; + u_int32_t time_sec; + u_int32_t flow_sequence; + u_int32_t observation_dom; +} __packed; + +#define PFLOW_IPFIX_HDRLEN sizeof(struct pflow_v10_header) + +struct pflowstats { + u_int64_t pflow_flows; + u_int64_t pflow_packets; + u_int64_t pflow_onomem; + u_int64_t pflow_oerrors; +}; + +/* Supported flow protocols */ +#define PFLOW_PROTO_5 5 /* original pflow */ +#define PFLOW_PROTO_10 10 /* ipfix */ +#define PFLOW_PROTO_MAX 11 + +#define PFLOW_PROTO_DEFAULT PFLOW_PROTO_5 + +struct pflow_protos { + const char *ppr_name; + u_int8_t ppr_proto; +}; + +#define PFLOW_PROTOS { \ + { "5", PFLOW_PROTO_5 }, \ + { "10", PFLOW_PROTO_10 }, \ +} + +#define PFLOWNL_FAMILY_NAME "pflow" + +enum { + PFLOWNL_CMD_UNSPEC = 0, + PFLOWNL_CMD_LIST = 1, + PFLOWNL_CMD_CREATE = 2, + PFLOWNL_CMD_DEL = 3, + PFLOWNL_CMD_SET = 4, + PFLOWNL_CMD_GET = 5, + __PFLOWNL_CMD_MAX, +}; +#define PFLOWNL_CMD_MAX (__PFLOWNL_CMD_MAX - 1) + +enum pflow_list_type_t { + PFLOWNL_L_UNSPEC, + PFLOWNL_L_ID = 1, /* u32 */ +}; + +enum pflow_create_type_t { + PFLOWNL_CREATE_UNSPEC, + PFLOWNL_CREATE_ID = 1, /* u32 */ +}; + +enum pflow_del_type_t { + PFLOWNL_DEL_UNSPEC, + PFLOWNL_DEL_ID = 1, /* u32 */ +}; + +enum pflow_addr_type_t { + PFLOWNL_ADDR_UNSPEC, + PFLOWNL_ADDR_FAMILY = 1, /* u8 */ + PFLOWNL_ADDR_PORT = 2, /* u16 */ + PFLOWNL_ADDR_IP = 3, /* struct in_addr */ + PFLOWNL_ADDR_IP6 = 4, /* struct in6_addr */ +}; + +enum pflow_get_type_t { + PFLOWNL_GET_UNSPEC, + PFLOWNL_GET_ID = 1, /* u32 */ + PFLOWNL_GET_VERSION = 2, /* u16 */ + PFLOWNL_GET_SRC = 3, /* struct sockaddr_storage */ + PFLOWNL_GET_DST = 4, /* struct sockaddr_storage */ + PFLOWNL_GET_OBSERVATION_DOMAIN = 5, /* u32 */ + PFLOWNL_GET_SOCKET_STATUS = 6, /* u8 */ +}; + +enum pflow_set_type_t { + PFLOWNL_SET_UNSPEC, + PFLOWNL_SET_ID = 1, /* u32 */ + PFLOWNL_SET_VERSION = 2, /* u16 */ + PFLOWNL_SET_SRC = 3, /* struct sockaddr_storage */ + PFLOWNL_SET_DST = 4, /* struct sockaddr_storage */ + PFLOWNL_SET_OBSERVATION_DOMAIN = 5, /* u32 */ +}; + +#ifdef _KERNEL +int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t); +#endif /* _KERNEL */ + +#endif /* _NET_IF_PFLOW_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/pfvar.h b/lib/libc/include/generic-freebsd/net/pfvar.h index 1e61aba2b574b0765f62e6c4c61022db9579ed89..c1b72d6ca2cf0b11b83fbf87bfab6f0724a9a2a8 100644 --- a/lib/libc/include/generic-freebsd/net/pfvar.h +++ b/lib/libc/include/generic-freebsd/net/pfvar.h @@ -70,6 +70,8 @@ #ifdef _KERNEL +#define PF_PFIL_NOREFRAGMENT 0x80000000 + #if defined(__arm__) #define PF_WANT_32_TO_64_COUNTER #endif @@ -127,6 +129,14 @@ pf_counter_u64_critical_exit(void) critical_exit(); } +static inline void +pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n) +{ + + MPASS(curthread->td_critnest > 0); + pfcu64->pfcu64_value += n; +} + static inline void pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) { @@ -250,6 +260,13 @@ pf_counter_u64_critical_exit(void) } +static inline void +pf_counter_u64_rollup_protected(struct pf_counter_u64 *pfcu64, uint64_t n) +{ + + counter_u64_add(pfcu64->counter, n); +} + static inline void pf_counter_u64_add_protected(struct pf_counter_u64 *pfcu64, uint32_t n) { @@ -309,10 +326,20 @@ pf_counter_u64_zero(struct pf_counter_u64 *pfcu64) _Static_assert(sizeof(time_t) == 4 || sizeof(time_t) == 8, "unexpected time_t size"); SYSCTL_DECL(_net_pf); +MALLOC_DECLARE(M_PF); MALLOC_DECLARE(M_PFHASH); MALLOC_DECLARE(M_PF_RULE_ITEM); SDT_PROVIDER_DECLARE(pf); +SDT_PROBE_DECLARE(pf, , test, reason_set); +SDT_PROBE_DECLARE(pf, , log, log); + +#define DPFPRINTF(n, fmt, x...) \ + do { \ + SDT_PROBE2(pf, , log, log, (n), fmt); \ + if (V_pf_status.debug >= (n)) \ + printf(fmt "\n", ##x); \ + } while (0) struct pfi_dynaddr { TAILQ_ENTRY(pfi_dynaddr) entry; @@ -329,14 +356,6 @@ struct pfi_dynaddr { u_int8_t pfid_iflags; /* PFI_AFLAG_* */ }; -/* - * Address manipulation macros - */ -#define HTONL(x) (x) = htonl((__uint32_t)(x)) -#define HTONS(x) (x) = htons((__uint16_t)(x)) -#define NTOHL(x) (x) = ntohl((__uint32_t)(x)) -#define NTOHS(x) (x) = ntohs((__uint16_t)(x)) - #define PF_NAME "pf" #define PF_HASHROW_ASSERT(h) mtx_assert(&(h)->lock, MA_OWNED) @@ -433,6 +452,16 @@ VNET_DECLARE(struct rmlock, pf_rules_lock); #define PF_RULES_RASSERT() rm_assert(&V_pf_rules_lock, RA_RLOCKED) #define PF_RULES_WASSERT() rm_assert(&V_pf_rules_lock, RA_WLOCKED) +VNET_DECLARE(struct rmlock, pf_tags_lock); +#define V_pf_tags_lock VNET(pf_tags_lock) + +#define PF_TAGS_RLOCK_TRACKER struct rm_priotracker _pf_tags_tracker +#define PF_TAGS_RLOCK() rm_rlock(&V_pf_tags_lock, &_pf_tags_tracker) +#define PF_TAGS_RUNLOCK() rm_runlock(&V_pf_tags_lock, &_pf_tags_tracker) +#define PF_TAGS_WLOCK() rm_wlock(&V_pf_tags_lock) +#define PF_TAGS_WUNLOCK() rm_wunlock(&V_pf_tags_lock) +#define PF_TAGS_WASSERT() rm_assert(&V_pf_tags_lock, RA_WLOCKED) + extern struct mtx_padalign pf_table_stats_lock; #define PF_TABLE_STATS_LOCK() mtx_lock(&pf_table_stats_lock) #define PF_TABLE_STATS_UNLOCK() mtx_unlock(&pf_table_stats_lock) @@ -498,18 +527,6 @@ extern struct sx pf_end_lock; (c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \ !(a)->addr32[2] && !(a)->addr32[3] )) \ -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - pf_addrcpy(a, b, f) - -#define PF_AINC(a, f) \ - pf_addr_inc(a, f) - -#define PF_POOLMASK(a, b, c, d, f) \ - pf_poolmask(a, b, c, d, f) - #else /* Just IPv6 */ @@ -534,18 +551,6 @@ extern struct sx pf_end_lock; !(a)->addr32[2] && \ !(a)->addr32[3] ) \ -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - pf_addrcpy(a, b, f) - -#define PF_AINC(a, f) \ - pf_addr_inc(a, f) - -#define PF_POOLMASK(a, b, c, d, f) \ - pf_poolmask(a, b, c, d, f) - #else /* Just IPv4 */ @@ -560,27 +565,34 @@ extern struct sx pf_end_lock; #define PF_AZERO(a, c) \ (!(a)->addr32[0]) -#define PF_MATCHA(n, a, m, b, f) \ - pf_match_addr(n, a, m, b, f) - -#define PF_ACPY(a, b, f) \ - (a)->v4.s_addr = (b)->v4.s_addr - -#define PF_AINC(a, f) \ - do { \ - (a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \ - } while (0) - -#define PF_POOLMASK(a, b, c, d, f) \ - do { \ - (a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \ - (((c)->addr32[0] ^ 0xffffffff ) & (d)->addr32[0]); \ - } while (0) - #endif /* PF_INET_ONLY */ #endif /* PF_INET6_ONLY */ #endif /* PF_INET_INET6 */ +#ifdef _KERNEL + +void unhandled_af(int) __dead2; + +static void inline +pf_addrcpy(struct pf_addr *dst, const struct pf_addr *src, sa_family_t af) +{ + switch (af) { +#ifdef INET + case AF_INET: + memcpy(&dst->v4, &src->v4, sizeof(dst->v4)); + break; +#endif /* INET */ +#ifdef INET6 + case AF_INET6: + memcpy(&dst->v6, &src->v6, sizeof(dst->v6)); + break; +#endif /* INET6 */ + default: + unhandled_af(af); + } +} +#endif + /* * XXX callers not FIB-aware in our version of pf yet. * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio. @@ -600,19 +612,35 @@ extern struct sx pf_end_lock; &(aw)->v.a.mask, (x), (af))) || \ ((aw)->type == PF_ADDR_ADDRMASK && \ !PF_AZERO(&(aw)->v.a.mask, (af)) && \ - !PF_MATCHA(0, &(aw)->v.a.addr, \ + !pf_match_addr(0, &(aw)->v.a.addr, \ &(aw)->v.a.mask, (x), (af))))) != \ (neg) \ ) #define PF_ALGNMNT(off) (((off) % 2) == 0) +/* + * At the moment there are no rules which have both NAT and RDR actions, + * apart from af-to rules, but those don't to source tracking for address + * translation. And the r->rdr pool is used for both NAT and RDR. + * So there is no PF_SN_RDR. + */ +enum pf_sn_types { PF_SN_LIMIT, PF_SN_NAT, PF_SN_ROUTE, PF_SN_MAX }; +typedef enum pf_sn_types pf_sn_types_t; +#define PF_SN_TYPE_NAMES { \ + "limit source-track", \ + "NAT/RDR sticky-address", \ + "route sticky-address", \ + NULL \ +} + #ifdef _KERNEL struct pf_kpooladdr { struct pf_addr_wrap addr; TAILQ_ENTRY(pf_kpooladdr) entries; char ifname[IFNAMSIZ]; + sa_family_t af; struct pfi_kkif *kif; }; @@ -628,20 +656,27 @@ struct pf_kpool { int tblidx; u_int16_t proxy_port[2]; u_int8_t opts; + sa_family_t ipv6_nexthop_af; }; struct pf_rule_actions { + struct pf_addr rt_addr; + struct pfi_kkif *rt_kif; int32_t rtableid; - uint16_t qid; - uint16_t pqid; - uint16_t max_mss; - uint8_t log; - uint8_t set_tos; - uint8_t min_ttl; - uint16_t dnpipe; - uint16_t dnrpipe; /* Reverse direction pipe */ uint32_t flags; + uint16_t qid; + uint16_t pqid; + uint16_t max_mss; + uint16_t dnpipe; + uint16_t dnrpipe; /* Reverse direction pipe */ + sa_family_t rt_af; + uint8_t log; + uint8_t set_tos; + uint8_t min_ttl; uint8_t set_prio[2]; + uint8_t rt; + uint8_t allow_opts; + uint16_t max_pkt_size; }; union pf_keth_rule_ptr { @@ -667,7 +702,6 @@ struct pf_keth_ruleset { int open; uint32_t ticket; } active, inactive; - struct epoch_context epoch_ctx; struct vnet *vnet; struct pf_keth_anchor *anchor; }; @@ -746,9 +780,10 @@ struct pf_keth_rule { uint32_t ridentifier; }; -union pf_krule_ptr { - struct pf_krule *ptr; - u_int32_t nr; +struct pf_kthreshold { + uint32_t limit; + uint32_t seconds; + struct counter_rate *cr; }; RB_HEAD(pf_krule_global, pf_krule); @@ -757,10 +792,11 @@ RB_PROTOTYPE(pf_krule_global, pf_krule, entry_global, pf_krule_compare); struct pf_krule { struct pf_rule_addr src; struct pf_rule_addr dst; - union pf_krule_ptr skip[PF_SKIP_COUNT]; + struct pf_krule *skip[PF_SKIP_COUNT]; char label[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE]; uint32_t ridentifier; char ifname[IFNAMSIZ]; + char rcv_ifname[IFNAMSIZ]; char qname[PF_QNAME_SIZE]; char pqname[PF_QNAME_SIZE]; char tagname[PF_TAG_NAME_SIZE]; @@ -769,7 +805,10 @@ struct pf_krule { char overload_tblname[PF_TABLE_NAME_SIZE]; TAILQ_ENTRY(pf_krule) entries; - struct pf_kpool rpool; + struct pf_kpool nat; + struct pf_kpool rdr; + struct pf_kpool route; + struct pf_kthreshold pktrate; struct pf_counter_u64 evaluations; struct pf_counter_u64 packets[2]; @@ -777,6 +816,7 @@ struct pf_krule { time_t *timestamp; struct pfi_kkif *kif; + struct pfi_kkif *rcv_kif; struct pf_kanchor *anchor; struct pfr_ktable *overload_tbl; @@ -792,6 +832,7 @@ struct pf_krule { u_int32_t limit; u_int32_t seconds; } max_src_conn_rate; + uint16_t max_pkt_size; u_int16_t qid; u_int16_t pqid; u_int16_t dnpipe; @@ -804,7 +845,7 @@ struct pf_krule { counter_u64_t states_cur; counter_u64_t states_tot; - counter_u64_t src_nodes; + counter_u64_t src_nodes[PF_SN_MAX]; u_int16_t return_icmp; u_int16_t return_icmp6; @@ -830,8 +871,8 @@ struct pf_krule { u_int8_t keep_state; sa_family_t af; u_int8_t proto; - u_int8_t type; - u_int8_t code; + uint16_t type; + uint16_t code; u_int8_t flags; u_int8_t flagset; u_int8_t min_ttl; @@ -846,6 +887,8 @@ struct pf_krule { u_int8_t flush; u_int8_t prio; u_int8_t set_prio[2]; + sa_family_t naf; + u_int8_t rcvifnot; struct { struct pf_addr addr; @@ -869,21 +912,23 @@ SLIST_HEAD(pf_krule_slist, pf_krule_item); struct pf_ksrc_node { LIST_ENTRY(pf_ksrc_node) entry; - struct pf_addr addr; - struct pf_addr raddr; + struct pf_addr addr; + struct pf_addr raddr; struct pf_krule_slist match_rules; - union pf_krule_ptr rule; - struct pfi_kkif *rkif; - counter_u64_t bytes[2]; - counter_u64_t packets[2]; - u_int32_t states; - u_int32_t conn; - struct pf_threshold conn_rate; - u_int32_t creation; - u_int32_t expire; - sa_family_t af; - u_int8_t ruletype; - struct mtx *lock; + struct pf_krule *rule; + struct pfi_kkif *rkif; + counter_u64_t bytes[2]; + counter_u64_t packets[2]; + u_int32_t states; + u_int32_t conn; + struct pf_kthreshold conn_rate; + u_int32_t creation; + u_int32_t expire; + sa_family_t af; + sa_family_t raf; + u_int8_t ruletype; + pf_sn_types_t type; + struct mtx *lock; }; #endif @@ -925,6 +970,29 @@ struct pf_state_peer { u_int8_t pad[1]; }; +/* Keep synced with struct pf_udp_endpoint. */ +struct pf_udp_endpoint_cmp { + struct pf_addr addr; + uint16_t port; + sa_family_t af; + uint8_t pad[1]; +}; + +struct pf_udp_endpoint { + struct pf_addr addr; + uint16_t port; + sa_family_t af; + uint8_t pad[1]; + + struct pf_udp_mapping *mapping; + LIST_ENTRY(pf_udp_endpoint) entry; +}; + +struct pf_udp_mapping { + struct pf_udp_endpoint endpoints[2]; + u_int refs; +}; + /* Keep synced with struct pf_state_key. */ struct pf_state_key_cmp { struct pf_addr addr[2]; @@ -945,6 +1013,11 @@ struct pf_state_key { TAILQ_HEAD(, pf_kstate) states[2]; }; +#define PF_REVERSED_KEY(state, family) \ + (((state)->key[PF_SK_WIRE]->af != (state)->key[PF_SK_STACK]->af) && \ + ((state)->key[PF_SK_WIRE]->af != (family)) && \ + ((state)->direction == PF_IN)) + /* Keep synced with struct pf_kstate. */ struct pf_state_cmp { u_int64_t id; @@ -959,7 +1032,7 @@ struct pf_state_scrub_export { #define PF_SCRUB_FLAG_VALID 0x01 uint8_t scrub_flag; uint32_t pfss_ts_mod; /* timestamp modulation */ -}; +} __packed; struct pf_state_key_export { struct pf_addr addr[2]; @@ -976,7 +1049,7 @@ struct pf_state_peer_export { uint8_t state; /* active state level */ uint8_t wscale; /* window scaling factor */ uint8_t dummy[6]; -}; +} __packed; _Static_assert(sizeof(struct pf_state_peer_export) == 32, "size incorrect"); struct pf_state_export { @@ -1040,7 +1113,7 @@ struct pf_kstate { u_int16_t state_flags; u_int8_t timeout; u_int8_t sync_state; /* PFSYNC_S_x */ - u_int8_t sync_updates; /* XXX */ + u_int8_t sync_updates; u_int refs; struct mtx *lock; TAILQ_ENTRY(pf_kstate) sync_list; @@ -1049,56 +1122,74 @@ struct pf_kstate { struct pf_state_peer src; struct pf_state_peer dst; struct pf_krule_slist match_rules; - union pf_krule_ptr rule; - union pf_krule_ptr anchor; - union pf_krule_ptr nat_rule; - struct pf_addr rt_addr; + struct pf_krule *rule; + struct pf_krule *anchor; + struct pf_krule *nat_rule; struct pf_state_key *key[2]; /* addresses stack and wire */ + struct pf_udp_mapping *udp_mapping; struct pfi_kkif *kif; struct pfi_kkif *orig_kif; /* The real kif, even if we're a floating state (i.e. if == V_pfi_all). */ - struct pfi_kkif *rt_kif; - struct pf_ksrc_node *src_node; - struct pf_ksrc_node *nat_src_node; + struct pf_ksrc_node *sns[PF_SN_MAX];/* source nodes */ u_int64_t packets[2]; u_int64_t bytes[2]; - u_int32_t creation; - u_int32_t expire; + u_int64_t creation; + u_int64_t expire; u_int32_t pfsync_time; struct pf_rule_actions act; u_int16_t tag; - u_int8_t rt; + u_int16_t if_index_in; + u_int16_t if_index_out; }; /* - * Size <= fits 11 objects per page on LP64. Try to not grow the struct beyond that. + * 6 cache lines per struct, 10 structs per page. + * Try to not grow the struct beyond that. */ -_Static_assert(sizeof(struct pf_kstate) <= 368, "pf_kstate size crosses 368 bytes"); +_Static_assert(sizeof(struct pf_kstate) <= 384, "pf_kstate size crosses 384 bytes"); + +enum pf_test_status { + PF_TEST_FAIL = -1, + PF_TEST_OK, + PF_TEST_QUICK +}; + +struct pf_test_ctx { + enum pf_test_status test_status; + struct pf_pdesc *pd; + struct pf_rule_actions act; + uint8_t icmpcode; + uint8_t icmptype; + int icmp_dir; + int state_icmp; + int tag; + int rewrite; + u_short reason; + struct pf_src_node *sns[PF_SN_MAX]; + struct pf_krule *nr; + struct pf_krule *tr; + struct pf_krule **rm; + struct pf_krule *a; + struct pf_krule **am; + struct pf_kruleset **rsm; + struct pf_kruleset *arsm; + struct pf_kruleset *aruleset; + struct pf_state_key *sk; + struct pf_state_key *nk; + struct tcphdr *th; + struct pf_udp_mapping *udp_mapping; + struct pf_kpool *nat_pool; + uint16_t virtual_type; + uint16_t virtual_id; + int depth; +}; + +#define PF_ANCHOR_STACK_MAX 32 #endif /* * Unified state structures for pulling states out of the kernel * used by pfsync(4) and the pf(4) ioctl. */ -struct pfsync_state_scrub { - u_int16_t pfss_flags; - u_int8_t pfss_ttl; /* stashed TTL */ -#define PFSYNC_SCRUB_FLAG_VALID 0x01 - u_int8_t scrub_flag; - u_int32_t pfss_ts_mod; /* timestamp modulation */ -} __packed; - -struct pfsync_state_peer { - struct pfsync_state_scrub scrub; /* state is scrubbed */ - u_int32_t seqlo; /* Max sequence number sent */ - u_int32_t seqhi; /* Max the other end ACKd + win */ - u_int32_t seqdiff; /* Sequence number modulator */ - u_int16_t max_win; /* largest window (pre scaling) */ - u_int16_t mss; /* Maximum segment size option */ - u_int8_t state; /* active state level */ - u_int8_t wscale; /* window scaling factor */ - u_int8_t pad[6]; -} __packed; - struct pfsync_state_key { struct pf_addr addr[2]; u_int16_t port[2]; @@ -1108,8 +1199,8 @@ struct pfsync_state_1301 { u_int64_t id; char ifname[IFNAMSIZ]; struct pfsync_state_key key[2]; - struct pfsync_state_peer src; - struct pfsync_state_peer dst; + struct pf_state_peer_export src; + struct pf_state_peer_export dst; struct pf_addr rt_addr; u_int32_t rule; u_int32_t anchor; @@ -1127,16 +1218,16 @@ struct pfsync_state_1301 { u_int8_t state_flags; u_int8_t timeout; u_int8_t sync_flags; - u_int8_t updates; + u_int8_t updates; /* unused */ } __packed; struct pfsync_state_1400 { - /* The beginning of the struct is compatible with previous versions */ + /* The beginning of the struct is compatible with pfsync_state_1301 */ u_int64_t id; char ifname[IFNAMSIZ]; struct pfsync_state_key key[2]; - struct pfsync_state_peer src; - struct pfsync_state_peer dst; + struct pf_state_peer_export src; + struct pf_state_peer_export dst; struct pf_addr rt_addr; u_int32_t rule; u_int32_t anchor; @@ -1154,7 +1245,7 @@ struct pfsync_state_1400 { u_int8_t __spare; u_int8_t timeout; u_int8_t sync_flags; - u_int8_t updates; + u_int8_t updates; /* unused */ /* The rest is not */ u_int16_t qid; u_int16_t pqid; @@ -1167,12 +1258,54 @@ struct pfsync_state_1400 { u_int8_t set_prio[2]; u_int8_t rt; char rt_ifname[IFNAMSIZ]; +} __packed; +struct pfsync_state_1500 { + /* The beginning of the struct is compatible with pfsync_state_1301 */ + u_int64_t id; + char ifname[IFNAMSIZ]; + struct pfsync_state_key key[2]; + struct pf_state_peer_export src; + struct pf_state_peer_export dst; + struct pf_addr rt_addr; + u_int32_t rule; + u_int32_t anchor; + u_int32_t nat_rule; + u_int32_t creation; + u_int32_t expire; + u_int32_t packets[2][2]; + u_int32_t bytes[2][2]; + u_int32_t creatorid; + /* The rest is not, use the opportunity to fix alignment */ + char tagname[PF_TAG_NAME_SIZE]; + char rt_ifname[IFNAMSIZ]; + char orig_ifname[IFNAMSIZ]; + int32_t rtableid; + u_int16_t state_flags; + u_int16_t qid; + u_int16_t pqid; + u_int16_t dnpipe; + u_int16_t dnrpipe; + u_int16_t max_mss; + sa_family_t wire_af; + sa_family_t stack_af; + sa_family_t rt_af; + u_int8_t wire_proto; + u_int8_t stack_proto; + u_int8_t log; + u_int8_t timeout; + u_int8_t direction; + u_int8_t rt; + u_int8_t min_ttl; + u_int8_t set_tos; + u_int8_t set_prio[2]; + u_int8_t spare[3]; /* Improve struct alignment */ } __packed; union pfsync_state_union { struct pfsync_state_1301 pfs_1301; struct pfsync_state_1400 pfs_1400; + struct pfsync_state_1500 pfs_1500; } __packed; #ifdef _KERNEL @@ -1184,6 +1317,8 @@ typedef void pfsync_delete_state_t(struct pf_kstate *); typedef void pfsync_clear_states_t(u_int32_t, const char *); typedef int pfsync_defer_t(struct pf_kstate *, struct mbuf *); typedef void pfsync_detach_ifnet_t(struct ifnet *); +typedef void pflow_export_state_t(const struct pf_kstate *); +typedef bool pf_addr_filter_func_t(const sa_family_t, const struct pf_addr *); VNET_DECLARE(pfsync_state_import_t *, pfsync_state_import_ptr); #define V_pfsync_state_import_ptr VNET(pfsync_state_import_ptr) @@ -1197,6 +1332,8 @@ VNET_DECLARE(pfsync_clear_states_t *, pfsync_clear_states_ptr); #define V_pfsync_clear_states_ptr VNET(pfsync_clear_states_ptr) VNET_DECLARE(pfsync_defer_t *, pfsync_defer_ptr); #define V_pfsync_defer_ptr VNET(pfsync_defer_ptr) +VNET_DECLARE(pflow_export_state_t *, pflow_export_state_ptr); +#define V_pflow_export_state_ptr VNET(pflow_export_state_ptr) extern pfsync_detach_ifnet_t *pfsync_detach_ifnet_ptr; void pfsync_state_export(union pfsync_state_union *, @@ -1207,9 +1344,9 @@ void pf_state_export(struct pf_state_export *, /* pflog */ struct pf_kruleset; struct pf_pdesc; -typedef int pflog_packet_t(struct pfi_kkif *, struct mbuf *, sa_family_t, - u_int8_t, struct pf_krule *, struct pf_krule *, struct pf_kruleset *, - struct pf_pdesc *, int); +typedef int pflog_packet_t(uint8_t, u_int8_t, + struct pf_krule *, struct pf_krule *, struct pf_kruleset *, + struct pf_pdesc *, int, struct pf_krule *); extern pflog_packet_t *pflog_packet_ptr; #endif /* _KERNEL */ @@ -1219,39 +1356,10 @@ extern pflog_packet_t *pflog_packet_ptr; /* for copies to/from network byte order */ /* ioctl interface also uses network byte order */ -#define pf_state_peer_hton(s,d) do { \ - (d)->seqlo = htonl((s)->seqlo); \ - (d)->seqhi = htonl((s)->seqhi); \ - (d)->seqdiff = htonl((s)->seqdiff); \ - (d)->max_win = htons((s)->max_win); \ - (d)->mss = htons((s)->mss); \ - (d)->state = (s)->state; \ - (d)->wscale = (s)->wscale; \ - if ((s)->scrub) { \ - (d)->scrub.pfss_flags = \ - htons((s)->scrub->pfss_flags & PFSS_TIMESTAMP); \ - (d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl; \ - (d)->scrub.pfss_ts_mod = htonl((s)->scrub->pfss_ts_mod);\ - (d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID; \ - } \ -} while (0) - -#define pf_state_peer_ntoh(s,d) do { \ - (d)->seqlo = ntohl((s)->seqlo); \ - (d)->seqhi = ntohl((s)->seqhi); \ - (d)->seqdiff = ntohl((s)->seqdiff); \ - (d)->max_win = ntohs((s)->max_win); \ - (d)->mss = ntohs((s)->mss); \ - (d)->state = (s)->state; \ - (d)->wscale = (s)->wscale; \ - if ((s)->scrub.scrub_flag == PFSYNC_SCRUB_FLAG_VALID && \ - (d)->scrub != NULL) { \ - (d)->scrub->pfss_flags = \ - ntohs((s)->scrub.pfss_flags) & PFSS_TIMESTAMP; \ - (d)->scrub->pfss_ttl = (s)->scrub.pfss_ttl; \ - (d)->scrub->pfss_ts_mod = ntohl((s)->scrub.pfss_ts_mod);\ - } \ -} while (0) +void pf_state_peer_hton(const struct pf_state_peer *, + struct pf_state_peer_export *); +void pf_state_peer_ntoh(const struct pf_state_peer_export *, + struct pf_state_peer *); #define pf_state_counter_hton(s,d) do { \ d[0] = htonl((s>>32)&0xffffffff); \ @@ -1276,7 +1384,6 @@ struct pf_kruleset { struct pf_krulequeue queues[2]; struct { struct pf_krulequeue *ptr; - struct pf_krule **ptr_array; u_int32_t rcount; u_int32_t ticket; int open; @@ -1329,7 +1436,6 @@ RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare); PFR_TFLAG_REFDANCHOR | \ PFR_TFLAG_COUNTERS) -struct pf_kanchor_stackframe; struct pf_keth_anchor_stackframe; struct pfr_table { @@ -1366,7 +1472,7 @@ struct pfr_astats { struct pfr_addr pfras_a; u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; - long pfras_tzero; + time_t pfras_tzero; }; enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX }; @@ -1377,7 +1483,7 @@ struct pfr_tstats { u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; u_int64_t pfrts_match; u_int64_t pfrts_nomatch; - long pfrts_tzero; + time_t pfrts_tzero; int pfrts_cnt; int pfrts_refcnt[PFR_REFCNT_MAX]; }; @@ -1439,7 +1545,7 @@ struct pfr_ktstats { struct pfr_kstate_counter pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; struct pfr_kstate_counter pfrkts_match; struct pfr_kstate_counter pfrkts_nomatch; - long pfrkts_tzero; + time_t pfrkts_tzero; int pfrkts_cnt; int pfrkts_refcnt[PFR_REFCNT_MAX]; }; @@ -1460,7 +1566,7 @@ union sockaddr_union { struct pfr_kcounters { counter_u64_t pfrkc_counters; - long pfrkc_tzero; + time_t pfrkc_tzero; }; #define pfr_kentry_counter(kc, dir, op, t) \ ((kc)->pfrkc_counters + \ @@ -1518,7 +1624,7 @@ struct pfi_kkif { #define pfik_list _pfik_glue._pfik_list struct pf_counter_u64 pfik_packets[2][2][2]; struct pf_counter_u64 pfik_bytes[2][2][2]; - u_int32_t pfik_tzero; + time_t pfik_tzero; u_int pfik_flags; struct ifnet *pfik_ifp; struct ifg_group *pfik_group; @@ -1532,6 +1638,7 @@ struct pfi_kkif { #define PFI_IFLAG_REFS 0x0001 /* has state references */ #define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */ +#define PFI_IFLAG_ANY 0x0200 /* match any non-loopback interface */ #ifdef _KERNEL struct pf_sctp_multihome_job; @@ -1555,25 +1662,49 @@ struct pf_pdesc { char any[0]; } hdr; - struct pf_krule *nat_rule; /* nat/rdr rule applied to packet */ + struct pf_addr nsaddr; /* src address after NAT */ + struct pf_addr ndaddr; /* dst address after NAT */ + + struct pfi_kkif *kif; /* incomming interface */ + struct mbuf *m; + struct pf_addr *src; /* src address */ struct pf_addr *dst; /* dst address */ - u_int16_t *sport; - u_int16_t *dport; + struct pf_addr osrc; + struct pf_addr odst; + u_int16_t *pcksum; /* proto cksum */ + u_int16_t *sport; + u_int16_t *dport; + u_int16_t osport; + u_int16_t odport; + u_int16_t nsport; /* src port after NAT */ + u_int16_t ndport; /* dst port after NAT */ struct pf_mtag *pf_mtag; struct pf_rule_actions act; - u_int32_t p_len; /* total length of payload */ + u_int32_t off; /* protocol header offset */ + bool df; /* IPv4 Don't fragment flag. */ + u_int32_t hdrlen; /* protocol header length */ + u_int32_t p_len; /* total length of protocol payload */ + u_int32_t extoff; /* extentsion header offset */ + u_int32_t fragoff; /* fragment header offset */ + u_int32_t jumbolen; /* length from v6 jumbo header */ + u_int32_t badopts; /* v4 options or v6 routing headers */ +#define PF_OPT_OTHER 0x0001 +#define PF_OPT_JUMBO 0x0002 +#define PF_OPT_ROUTER_ALERT 0x0004 u_int16_t *ip_sum; - u_int16_t *proto_sum; u_int16_t flags; /* Let SCRUB trigger behavior in * state code. Easier than tags */ #define PFDESC_TCP_NORM 0x0001 /* TCP shall be statefully scrubbed */ -#define PFDESC_IP_REAS 0x0002 /* IP frags would've been reassembled */ + u_int16_t virtual_proto; +#define PF_VPROTO_FRAGMENT 256 sa_family_t af; + sa_family_t naf; u_int8_t proto; u_int8_t tos; + u_int8_t ttl; u_int8_t dir; /* direction */ u_int8_t sidx; /* key index for source */ u_int8_t didx; /* key index for destination */ @@ -1592,6 +1723,8 @@ struct pf_pdesc { #define PFDESC_SCTP_ADD_IP 0x1000 u_int16_t sctp_flags; u_int32_t sctp_initiate_tag; + u_int16_t sctp_dummy_sum; + struct pf_krule *related_rule; struct pf_sctp_multihome_jobs sctp_multihome_jobs; }; @@ -1601,7 +1734,6 @@ struct pf_sctp_multihome_job { struct pf_pdesc pd; struct pf_addr src; struct pf_addr dst; - struct mbuf *m; int op; }; @@ -1647,6 +1779,7 @@ struct pf_sctp_multihome_job { #define REASON_SET(a, x) \ do { \ + SDT_PROBE2(pf, , test, reason_set, x, __LINE__); \ if ((a) != NULL) \ *(a) = (x); \ if (x < PFRES_MAX) \ @@ -1697,6 +1830,13 @@ struct pf_divert { #define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */ #define PFR_KENTRY_HIWAT 200000 /* Number of table entries */ +struct pf_fragment_tag { + uint16_t ft_hdrlen; /* header length of reassembled pkt */ + uint16_t ft_extoff; /* last extension header offset or 0 */ + uint16_t ft_maxlen; /* maximum fragment payload length */ + uint32_t ft_id; /* fragment id */ +}; + /* * Limit the length of the fragment queue traversal. Remember * search entry points based on the fragment offset. @@ -1773,6 +1913,7 @@ struct pf_kstate_kill { char psk_label[PF_RULE_LABEL_SIZE]; u_int psk_killed; bool psk_kill_match; + bool psk_nat; }; #endif @@ -1944,29 +2085,25 @@ struct pfioc_iface { #define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule) #define DIOCADDRULENV _IOWR('D', 4, struct pfioc_nv) #define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule) -#define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule) #define DIOCGETRULENV _IOWR('D', 7, struct pfioc_nv) -/* XXX cut 8 - 17 */ -#define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) #define DIOCCLRSTATESNV _IOWR('D', 18, struct pfioc_nv) #define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) #define DIOCGETSTATENV _IOWR('D', 19, struct pfioc_nv) #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) -#define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) #define DIOCGETSTATUSNV _IOWR('D', 21, struct pfioc_nv) #define DIOCCLRSTATUS _IO ('D', 22) #define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) #define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) +#ifdef COMPAT_FREEBSD14 #define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states) +#endif #define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule) -/* XXX cut 26 - 28 */ #define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm) #define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm) #define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state) #define DIOCCLRRULECTRS _IO ('D', 38) #define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit) #define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit) -#define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill) #define DIOCKILLSTATESNV _IOWR('D', 41, struct pfioc_nv) #define DIOCSTARTALTQ _IO ('D', 42) #define DIOCSTOPALTQ _IO ('D', 43) @@ -1985,7 +2122,6 @@ struct pfioc_iface { #define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr) #define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr) #define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr) -/* XXX cut 55 - 57 */ #define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset) #define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset) #define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table) @@ -2019,7 +2155,9 @@ struct pfioc_iface { #define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) #define DIOCGIFSPEEDV0 _IOWR('D', 92, struct pf_ifspeed_v0) #define DIOCGIFSPEEDV1 _IOWR('D', 92, struct pf_ifspeed_v1) +#ifdef COMPAT_FREEBSD14 #define DIOCGETSTATESV2 _IOWR('D', 93, struct pfioc_states_v2) +#endif #define DIOCGETSYNCOOKIES _IOWR('D', 94, struct pfioc_nv) #define DIOCSETSYNCOOKIES _IOWR('D', 95, struct pfioc_nv) #define DIOCKEEPCOUNTERS _IOWR('D', 96, struct pfioc_nv) @@ -2103,21 +2241,33 @@ struct pf_idhash { struct mtx lock; }; +struct pf_udpendpointhash { + LIST_HEAD(, pf_udp_endpoint) endpoints; + /* refcont is synchronized on the source endpoint's row lock */ + struct mtx lock; +}; + extern u_long pf_ioctl_maxcount; VNET_DECLARE(u_long, pf_hashmask); #define V_pf_hashmask VNET(pf_hashmask) VNET_DECLARE(u_long, pf_srchashmask); #define V_pf_srchashmask VNET(pf_srchashmask) +VNET_DECLARE(u_long, pf_udpendpointhashmask); +#define V_pf_udpendpointhashmask VNET(pf_udpendpointhashmask) #define PF_HASHSIZ (131072) #define PF_SRCHASHSIZ (PF_HASHSIZ/4) +#define PF_UDPENDHASHSIZ (PF_HASHSIZ/4) VNET_DECLARE(struct pf_keyhash *, pf_keyhash); VNET_DECLARE(struct pf_idhash *, pf_idhash); +VNET_DECLARE(struct pf_udpendpointhash *, pf_udpendpointhash); #define V_pf_keyhash VNET(pf_keyhash) #define V_pf_idhash VNET(pf_idhash) +#define V_pf_udpendpointhash VNET(pf_udpendpointhash) VNET_DECLARE(struct pf_srchash *, pf_srchash); #define V_pf_srchash VNET(pf_srchash) -#define PF_IDHASH(s) (be64toh((s)->id) % (V_pf_hashmask + 1)) +#define PF_IDHASHID(id) (be64toh(id) % (V_pf_hashmask + 1)) +#define PF_IDHASH(s) PF_IDHASHID((s)->id) VNET_DECLARE(void *, pf_swi_cookie); #define V_pf_swi_cookie VNET(pf_swi_cookie) @@ -2130,7 +2280,7 @@ VNET_DECLARE(struct unrhdr64, pf_stateid); TAILQ_HEAD(pf_altqqueue, pf_altq); VNET_DECLARE(struct pf_altqqueue, pf_altqs[4]); #define V_pf_altqs VNET(pf_altqs) -VNET_DECLARE(struct pf_kpalist, pf_pabuf); +VNET_DECLARE(struct pf_kpalist, pf_pabuf[3]); #define V_pf_pabuf VNET(pf_pabuf) VNET_DECLARE(u_int32_t, ticket_altqs_active); @@ -2171,6 +2321,8 @@ VNET_DECLARE(struct pf_krule *, pf_rulemarker); #define V_pf_rulemarker VNET(pf_rulemarker) #endif +int pf_start(void); +int pf_stop(void); void pf_initialize(void); void pf_mtag_initialize(void); void pf_mtag_cleanup(void); @@ -2186,15 +2338,21 @@ VNET_DECLARE(uma_zone_t, pf_state_z); #define V_pf_state_z VNET(pf_state_z) VNET_DECLARE(uma_zone_t, pf_state_key_z); #define V_pf_state_key_z VNET(pf_state_key_z) +VNET_DECLARE(uma_zone_t, pf_udp_mapping_z); +#define V_pf_udp_mapping_z VNET(pf_udp_mapping_z) VNET_DECLARE(uma_zone_t, pf_state_scrub_z); #define V_pf_state_scrub_z VNET(pf_state_scrub_z) +VNET_DECLARE(uma_zone_t, pf_anchor_z); +#define V_pf_anchor_z VNET(pf_anchor_z) +VNET_DECLARE(uma_zone_t, pf_eth_anchor_z); +#define V_pf_eth_anchor_z VNET(pf_eth_anchor_z) extern void pf_purge_thread(void *); extern void pf_unload_vnet_purge(void); extern void pf_intr(void *); extern void pf_purge_expired_src_nodes(void); -extern int pf_unlink_state(struct pf_kstate *); +extern int pf_remove_state(struct pf_kstate *); extern int pf_state_insert(struct pfi_kkif *, struct pfi_kkif *, struct pf_state_key *, @@ -2202,6 +2360,9 @@ extern int pf_state_insert(struct pfi_kkif *, struct pf_kstate *); extern struct pf_kstate *pf_alloc_state(int); extern void pf_free_state(struct pf_kstate *); +extern void pf_killstates(struct pf_kstate_kill *, + unsigned int *); +extern unsigned int pf_clear_states(const struct pf_kstate_kill *); static __inline void pf_ref_state(struct pf_kstate *s) @@ -2232,6 +2393,22 @@ pf_release_staten(struct pf_kstate *s, u_int n) return (0); } +static __inline uint64_t +pf_get_uptime(void) +{ + struct timeval t; + microuptime(&t); + return ((t.tv_sec * 1000) + (t.tv_usec / 1000)); +} + +static __inline uint64_t +pf_get_time(void) +{ + struct timeval t; + microtime(&t); + return ((t.tv_sec * 1000) + (t.tv_usec / 1000)); +} + extern struct pf_kstate *pf_find_state_byid(uint64_t, uint32_t); extern struct pf_kstate *pf_find_state_all( const struct pf_state_key_cmp *, @@ -2239,13 +2416,25 @@ extern struct pf_kstate *pf_find_state_all( extern bool pf_find_state_all_exists( const struct pf_state_key_cmp *, u_int); +extern struct pf_udp_mapping *pf_udp_mapping_find(struct pf_udp_endpoint_cmp + *endpoint); +extern struct pf_udp_mapping *pf_udp_mapping_create(sa_family_t af, + struct pf_addr *src_addr, uint16_t src_port, + struct pf_addr *nat_addr, uint16_t nat_port); +extern int pf_udp_mapping_insert(struct pf_udp_mapping + *mapping); +extern void pf_udp_mapping_release(struct pf_udp_mapping + *mapping); +uint32_t pf_hashsrc(struct pf_addr *, sa_family_t); +extern bool pf_src_node_exists(struct pf_ksrc_node **, + struct pf_srchash *); extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *, struct pf_krule *, sa_family_t, - struct pf_srchash **, bool); + struct pf_srchash **, pf_sn_types_t, bool); extern void pf_unlink_src_node(struct pf_ksrc_node *); extern u_int pf_free_src_nodes(struct pf_ksrc_node_list *); extern void pf_print_state(struct pf_kstate *); -extern void pf_print_flags(u_int8_t); +extern void pf_print_flags(uint16_t); extern int pf_addr_wrap_neq(struct pf_addr_wrap *, struct pf_addr_wrap *); extern u_int16_t pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t, @@ -2257,80 +2446,85 @@ VNET_DECLARE(struct ifnet *, sync_ifp); #define V_sync_ifp VNET(sync_ifp); VNET_DECLARE(struct pf_krule, pf_default_rule); #define V_pf_default_rule VNET(pf_default_rule) -extern void pf_addrcpy(struct pf_addr *, struct pf_addr *, +extern void pf_addrcpy(struct pf_addr *, const struct pf_addr *, sa_family_t); void pf_free_rule(struct pf_krule *); int pf_test_eth(int, int, struct ifnet *, struct mbuf **, struct inpcb *); +int pf_scan_sctp(struct pf_pdesc *); +#if defined(INET) || defined(INET6) +int pf_test(sa_family_t, int, int, struct ifnet *, struct mbuf **, struct inpcb *, + struct pf_rule_actions *); +#endif #ifdef INET -int pf_test(int, int, struct ifnet *, struct mbuf **, struct inpcb *, - struct pf_rule_actions *); -int pf_normalize_ip(struct mbuf **, struct pfi_kkif *, u_short *, - struct pf_pdesc *); +int pf_normalize_ip(u_short *, struct pf_pdesc *); #endif /* INET */ -#ifdef INET6 -int pf_test6(int, int, struct ifnet *, struct mbuf **, struct inpcb *, - struct pf_rule_actions *); -int pf_normalize_ip6(struct mbuf **, struct pfi_kkif *, u_short *, - struct pf_pdesc *); void pf_poolmask(struct pf_addr *, struct pf_addr*, struct pf_addr *, struct pf_addr *, sa_family_t); void pf_addr_inc(struct pf_addr *, sa_family_t); -int pf_refragment6(struct ifnet *, struct mbuf **, struct m_tag *, bool); +#ifdef INET6 +int pf_normalize_ip6(int, u_short *, struct pf_pdesc *); +int pf_max_frag_size(struct mbuf *); +int pf_refragment6(struct ifnet *, struct mbuf **, struct m_tag *, + struct ifnet *, bool); #endif /* INET6 */ -int pf_multihome_scan_init(struct mbuf *, int, int, struct pf_pdesc *, - struct pfi_kkif *); -int pf_multihome_scan_asconf(struct mbuf *, int, int, struct pf_pdesc *, - struct pfi_kkif *); +int pf_multihome_scan_init(int, int, struct pf_pdesc *); +int pf_multihome_scan_asconf(int, int, struct pf_pdesc *); u_int32_t pf_new_isn(struct pf_kstate *); -void *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, u_short *, +void *pf_pull_hdr(const struct mbuf *, int, void *, int, u_short *, u_short *, sa_family_t); void pf_change_a(void *, u_int16_t *, u_int32_t, u_int8_t); void pf_change_proto_a(struct mbuf *, void *, u_int16_t *, u_int32_t, u_int8_t); void pf_change_tcp_a(struct mbuf *, void *, u_int16_t *, u_int32_t); -void pf_patch_16_unaligned(struct mbuf *, u_int16_t *, void *, u_int16_t, - bool, u_int8_t); -void pf_patch_32_unaligned(struct mbuf *, u_int16_t *, void *, u_int32_t, - bool, u_int8_t); +int pf_patch_16(struct pf_pdesc *, void *, u_int16_t, bool); +int pf_patch_32(struct pf_pdesc *, void *, u_int32_t, bool); void pf_send_deferred_syn(struct pf_kstate *); -int pf_match_addr(u_int8_t, struct pf_addr *, struct pf_addr *, - struct pf_addr *, sa_family_t); -int pf_match_addr_range(struct pf_addr *, struct pf_addr *, - struct pf_addr *, sa_family_t); +int pf_match_addr(u_int8_t, const struct pf_addr *, + const struct pf_addr *, const struct pf_addr *, sa_family_t); +int pf_match_addr_range(const struct pf_addr *, const struct pf_addr *, + const struct pf_addr *, sa_family_t); int pf_match_port(u_int8_t, u_int16_t, u_int16_t, u_int16_t); void pf_normalize_init(void); void pf_normalize_cleanup(void); -int pf_normalize_tcp(struct pfi_kkif *, struct mbuf *, int, int, void *, - struct pf_pdesc *); +int pf_normalize_tcp(struct pf_pdesc *); void pf_normalize_tcp_cleanup(struct pf_kstate *); -int pf_normalize_tcp_init(struct mbuf *, int, struct pf_pdesc *, - struct tcphdr *, struct pf_state_peer *, struct pf_state_peer *); -int pf_normalize_tcp_stateful(struct mbuf *, int, struct pf_pdesc *, +int pf_normalize_tcp_init(struct pf_pdesc *, + struct tcphdr *, struct pf_state_peer *); +int pf_normalize_tcp_stateful(struct pf_pdesc *, u_short *, struct tcphdr *, struct pf_kstate *, struct pf_state_peer *, struct pf_state_peer *, int *); -int pf_normalize_sctp_init(struct mbuf *, int, struct pf_pdesc *, +int pf_normalize_sctp_init(struct pf_pdesc *, struct pf_state_peer *, struct pf_state_peer *); -int pf_normalize_sctp(int, struct pfi_kkif *, struct mbuf *, int, - int, void *, struct pf_pdesc *); +int pf_normalize_sctp(struct pf_pdesc *); u_int32_t pf_state_expires(const struct pf_kstate *); void pf_purge_expired_fragments(void); void pf_purge_fragments(uint32_t); int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kkif *, int); -int pf_socket_lookup(struct pf_pdesc *, struct mbuf *); +int pf_socket_lookup(struct pf_pdesc *); struct pf_state_key *pf_alloc_state_key(int); +int pf_translate(struct pf_pdesc *, struct pf_addr *, u_int16_t, + struct pf_addr *, u_int16_t, u_int16_t, int); +int pf_translate_af(struct pf_pdesc *); +bool pf_init_threshold(struct pf_kthreshold *, uint32_t, uint32_t); +uint16_t pf_tagname2tag(const char *); +#ifdef ALTQ +uint16_t pf_qname2qid(const char *, bool); +#endif /* ALTQ */ + void pfr_initialize(void); void pfr_cleanup(void); int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t); void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t, u_int64_t, int, int, int); -int pfr_pool_get(struct pfr_ktable *, int *, struct pf_addr *, sa_family_t); +int pfr_pool_get(struct pfr_ktable *, int *, struct pf_addr *, sa_family_t, + pf_addr_filter_func_t, bool); void pfr_dynaddr_update(struct pfr_ktable *, struct pfi_dynaddr *); struct pfr_ktable * pfr_attach_table(struct pf_kruleset *, char *); @@ -2346,7 +2540,7 @@ int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int); int pfr_clr_tstats(struct pfr_table *, int, int *, int); int pfr_set_tflags(struct pfr_table *, int, int, int, int *, int *, int); int pfr_clr_addrs(struct pfr_table *, int *, int); -int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, long); +int pfr_insert_kentry(struct pfr_ktable *, struct pfr_addr *, time_t); int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *, @@ -2364,6 +2558,8 @@ int pfr_ina_rollback(struct pfr_table *, u_int32_t, int *, int); int pfr_ina_commit(struct pfr_table *, u_int32_t, int *, int *, int); int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *, int *, u_int32_t, int); +struct pfr_ktable + *pfr_ktable_select_active(struct pfr_ktable *); MALLOC_DECLARE(PFI_MTYPE); VNET_DECLARE(struct pfi_kkif *, pfi_all); @@ -2390,21 +2586,23 @@ int pfi_set_flags(const char *, int); int pfi_clear_flags(const char *, int); int pf_match_tag(struct mbuf *, struct pf_krule *, int *, int); -int pf_tag_packet(struct mbuf *, struct pf_pdesc *, int); +int pf_tag_packet(struct pf_pdesc *, int); int pf_addr_cmp(struct pf_addr *, struct pf_addr *, sa_family_t); -u_int16_t pf_get_mss(struct mbuf *, int, u_int16_t, sa_family_t); -u_int8_t pf_get_wscale(struct mbuf *, int, u_int16_t, sa_family_t); +uint8_t* pf_find_tcpopt(u_int8_t *, u_int8_t *, size_t, + u_int8_t, u_int8_t); +u_int16_t pf_get_mss(struct pf_pdesc *); +u_int8_t pf_get_wscale(struct pf_pdesc *); struct mbuf *pf_build_tcp(const struct pf_krule *, sa_family_t, const struct pf_addr *, const struct pf_addr *, u_int16_t, u_int16_t, u_int32_t, u_int32_t, - u_int8_t, u_int16_t, u_int16_t, u_int8_t, bool, - u_int16_t, u_int16_t, int); + u_int8_t, u_int16_t, u_int16_t, u_int8_t, int, + u_int16_t, u_int16_t, u_int, int); void pf_send_tcp(const struct pf_krule *, sa_family_t, const struct pf_addr *, const struct pf_addr *, u_int16_t, u_int16_t, u_int32_t, u_int32_t, - u_int8_t, u_int16_t, u_int16_t, u_int8_t, bool, + u_int8_t, u_int16_t, u_int16_t, u_int8_t, int, u_int16_t, u_int16_t, int); void pf_syncookies_init(void); @@ -2412,12 +2610,10 @@ void pf_syncookies_cleanup(void); int pf_get_syncookies(struct pfioc_nv *); int pf_set_syncookies(struct pfioc_nv *); int pf_synflood_check(struct pf_pdesc *); -void pf_syncookie_send(struct mbuf *m, int off, - struct pf_pdesc *); +void pf_syncookie_send(struct pf_pdesc *); bool pf_syncookie_check(struct pf_pdesc *); u_int8_t pf_syncookie_validate(struct pf_pdesc *); -struct mbuf * pf_syncookie_recreate_syn(uint8_t, int, - struct pf_pdesc *); +struct mbuf * pf_syncookie_recreate_syn(struct pf_pdesc *); VNET_DECLARE(struct pf_kstatus, pf_status); #define V_pf_status VNET(pf_status) @@ -2432,6 +2628,20 @@ VNET_DECLARE(struct pf_limit, pf_limits[PF_LIMIT_MAX]); #endif /* _KERNEL */ #ifdef _KERNEL +struct pf_nl_pooladdr { + u_int32_t action; + u_int32_t ticket; + u_int32_t nr; + u_int32_t r_num; + u_int8_t r_action; + u_int8_t r_last; + u_int8_t af; + char anchor[MAXPATHLEN]; + struct pf_pooladdr addr; + /* Above this is identical to pfioc_pooladdr */ + int which; +}; + VNET_DECLARE(struct pf_kanchor_global, pf_anchors); #define V_pf_anchors VNET(pf_anchors) VNET_DECLARE(struct pf_kanchor, pf_main_anchor); @@ -2449,15 +2659,17 @@ void pf_init_kruleset(struct pf_kruleset *); void pf_init_keth(struct pf_keth_ruleset *); int pf_kanchor_setup(struct pf_krule *, const struct pf_kruleset *, const char *); +int pf_kanchor_copyout(const struct pf_kruleset *, + const struct pf_krule *, char *, size_t); int pf_kanchor_nvcopyout(const struct pf_kruleset *, const struct pf_krule *, nvlist_t *); -int pf_kanchor_copyout(const struct pf_kruleset *, - const struct pf_krule *, struct pfioc_rule *); -void pf_kanchor_remove(struct pf_krule *); +void pf_remove_kanchor(struct pf_krule *); void pf_remove_if_empty_kruleset(struct pf_kruleset *); struct pf_kruleset *pf_find_kruleset(const char *); +struct pf_kruleset *pf_get_leaf_kruleset(char *, char **); struct pf_kruleset *pf_find_or_create_kruleset(const char *); void pf_rs_initialize(void); +void pf_rule_tree_free(struct pf_krule_global *); struct pf_krule *pf_krule_alloc(void); @@ -2474,15 +2686,33 @@ int pf_keth_anchor_nvcopyout( struct pf_keth_ruleset *pf_find_or_create_keth_ruleset(const char *); void pf_keth_anchor_remove(struct pf_keth_rule *); +int pf_ioctl_getrules(struct pfioc_rule *); +int pf_ioctl_addrule(struct pf_krule *, uint32_t, + uint32_t, const char *, const char *, uid_t uid, + pid_t); +void pf_ioctl_clear_status(void); +int pf_ioctl_get_timeout(int, int *); +int pf_ioctl_set_timeout(int, int, int *); +int pf_ioctl_get_limit(int, unsigned int *); +int pf_ioctl_set_limit(int, unsigned int, unsigned int *); +int pf_ioctl_begin_addrs(uint32_t *); +int pf_ioctl_add_addr(struct pf_nl_pooladdr *); +int pf_ioctl_get_addrs(struct pf_nl_pooladdr *); +int pf_ioctl_get_addr(struct pf_nl_pooladdr *); +int pf_ioctl_get_rulesets(struct pfioc_ruleset *); +int pf_ioctl_get_ruleset(struct pfioc_ruleset *); +int pf_ioctl_natlook(struct pfioc_natlook *); + void pf_krule_free(struct pf_krule *); +void pf_krule_clear_counters(struct pf_krule *); +void pf_addr_copyout(struct pf_addr_wrap *); #endif /* The fingerprint functions can be linked into userland programs (tcpdump) */ int pf_osfp_add(struct pf_osfp_ioctl *); #ifdef _KERNEL struct pf_osfp_enlist * - pf_osfp_fingerprint(struct pf_pdesc *, struct mbuf *, int, - const struct tcphdr *); + pf_osfp_fingerprint(struct pf_pdesc *, const struct tcphdr *); #endif /* _KERNEL */ void pf_osfp_flush(void); int pf_osfp_get(struct pf_osfp_ioctl *); @@ -2491,12 +2721,10 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t); #ifdef _KERNEL void pf_print_host(struct pf_addr *, u_int16_t, sa_family_t); -void pf_step_into_anchor(struct pf_kanchor_stackframe *, int *, - struct pf_kruleset **, int, struct pf_krule **, - struct pf_krule **, int *); -int pf_step_out_of_anchor(struct pf_kanchor_stackframe *, int *, - struct pf_kruleset **, int, struct pf_krule **, - struct pf_krule **, int *); +enum pf_test_status pf_step_into_anchor(struct pf_test_ctx *, struct pf_krule *, + struct pf_krule_slist *match_rules); +enum pf_test_status pf_match_rule(struct pf_test_ctx *, struct pf_kruleset *, + struct pf_krule_slist *); void pf_step_into_keth_anchor(struct pf_keth_anchor_stackframe *, int *, struct pf_keth_ruleset **, struct pf_keth_rule **, struct pf_keth_rule **, @@ -2506,33 +2734,48 @@ int pf_step_out_of_keth_anchor(struct pf_keth_anchor_stackframe *, struct pf_keth_rule **, struct pf_keth_rule **, int *); -u_short pf_map_addr(u_int8_t, struct pf_krule *, +u_short pf_map_addr(sa_family_t, struct pf_krule *, struct pf_addr *, struct pf_addr *, - struct pfi_kkif **nkif, struct pf_addr *, - struct pf_ksrc_node **); -struct pf_krule *pf_get_translation(struct pf_pdesc *, struct mbuf *, - int, struct pfi_kkif *, struct pf_ksrc_node **, - struct pf_state_key **, struct pf_state_key **, + struct pfi_kkif **nkif, sa_family_t *, + struct pf_addr *, struct pf_kpool *); +u_short pf_map_addr_sn(u_int8_t, struct pf_krule *, struct pf_addr *, struct pf_addr *, - uint16_t, uint16_t, struct pf_kanchor_stackframe *); + sa_family_t *, struct pfi_kkif **, + struct pf_addr *, struct pf_kpool *, + pf_sn_types_t); +int pf_get_transaddr_af(struct pf_krule *, + struct pf_pdesc *); +u_short pf_get_translation(struct pf_test_ctx *); +u_short pf_get_transaddr(struct pf_test_ctx *, + struct pf_krule *, + u_int8_t, struct pf_kpool *); +int pf_translate_compat(struct pf_test_ctx *); -struct pf_state_key *pf_state_key_setup(struct pf_pdesc *, struct mbuf *, int, - struct pf_addr *, struct pf_addr *, u_int16_t, u_int16_t); +int pf_state_key_setup(struct pf_pdesc *, + u_int16_t, u_int16_t, + struct pf_state_key **sk, struct pf_state_key **nk); struct pf_state_key *pf_state_key_clone(const struct pf_state_key *); void pf_rule_to_actions(struct pf_krule *, struct pf_rule_actions *); -int pf_normalize_mss(struct mbuf *m, int off, - struct pf_pdesc *pd); -#ifdef INET -void pf_scrub_ip(struct mbuf **, struct pf_pdesc *); -#endif /* INET */ -#ifdef INET6 -void pf_scrub_ip6(struct mbuf **, struct pf_pdesc *); -#endif /* INET6 */ +int pf_normalize_mss(struct pf_pdesc *pd); +#if defined(INET) || defined(INET6) +void pf_scrub(struct pf_pdesc *); +#endif struct pfi_kkif *pf_kkif_create(int); void pf_kkif_free(struct pfi_kkif *); void pf_kkif_zero(struct pfi_kkif *); + + +/* NAT64 functions. */ +int inet_nat64(int, const void *, void *, const void *, u_int8_t); +int inet_nat64_inet(const void *, void *, const void *, u_int8_t); +int inet_nat64_inet6(const void *, void *, const void *, u_int8_t); + +int inet_nat46(int, const void *, void *, const void *, u_int8_t); +int inet_nat46_inet(const void *, void *, const void *, u_int8_t); +int inet_nat46_inet6(const void *, void *, const void *, u_int8_t); + #endif /* _KERNEL */ #endif /* _NET_PFVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/radix.h b/lib/libc/include/generic-freebsd/net/radix.h index 9ba671a9684ada0c0a8134d45ae78998410edf73..09b7a8be81435c2df6a7e66292e21ba4c372b987 100644 --- a/lib/libc/include/generic-freebsd/net/radix.h +++ b/lib/libc/include/generic-freebsd/net/radix.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)radix.h 8.2 (Berkeley) 10/31/94 */ #ifndef _RADIX_H_ diff --git a/lib/libc/include/generic-freebsd/net/rndis.h b/lib/libc/include/generic-freebsd/net/rndis.h index d2883342f4b4569bd7d935844af84b82b434542f..2e437069f24c21df34117a0c9b839adf961de608 100644 --- a/lib/libc/include/generic-freebsd/net/rndis.h +++ b/lib/libc/include/generic-freebsd/net/rndis.h @@ -339,7 +339,7 @@ struct rndis_diag_info { uint32_t rm_erroffset; }; -/* Keepalive messsage. May be sent by device. */ +/* Keepalive message. May be sent by device. */ #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 diff --git a/lib/libc/include/generic-freebsd/net/route.h b/lib/libc/include/generic-freebsd/net/route.h index 1f82a835a5728fec7cfd64943cab67d3977d3c67..284e5dabf88752b1924aa159fedfcf6dd5d5c11b 100644 --- a/lib/libc/include/generic-freebsd/net/route.h +++ b/lib/libc/include/generic-freebsd/net/route.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)route.h 8.4 (Berkeley) 1/9/95 */ #ifndef _NET_ROUTE_H_ @@ -241,6 +239,7 @@ struct rtstat { uint64_t rts_add_retry; /* # of route addition retries */ uint64_t rts_del_failure; /* # of route deletion failure */ uint64_t rts_del_retry; /* # of route deletion retries */ + uint64_t rts_spare[5]; }; /* @@ -296,6 +295,7 @@ struct rt_msghdr { #define RTM_DELMADDR 0x10 /* (4) mcast group membership being deleted */ #define RTM_IFANNOUNCE 0x11 /* (5) iface arrival/departure */ #define RTM_IEEE80211 0x12 /* (5) IEEE80211 wireless event */ +#define RTM_IPFWLOG 0x13 /* (1) IPFW rule match log event */ #endif /* NETLINK_COMPAT*/ diff --git a/lib/libc/include/generic-freebsd/net/route/route_ctl.h b/lib/libc/include/generic-freebsd/net/route/route_ctl.h index befc51d099c52c74a9ecf39f16c1cafdcd4d48bc..1225444541f20ca2808166fcc25d6f95936b627a 100644 --- a/lib/libc/include/generic-freebsd/net/route/route_ctl.h +++ b/lib/libc/include/generic-freebsd/net/route/route_ctl.h @@ -61,11 +61,11 @@ int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen, const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc); /* operation flags */ -#define RTM_F_CREATE 0x01 -#define RTM_F_EXCL 0x02 -#define RTM_F_REPLACE 0x04 -#define RTM_F_APPEND 0x08 -#define RTM_F_FORCE 0x10 +#define RTM_F_CREATE 0x01 /* Create object if not exists */ +#define RTM_F_EXCL 0x02 /* (Deprecated) Do not replace or append if exists */ +#define RTM_F_REPLACE 0x04 /* Replace if route (even multipath) if exists */ +#define RTM_F_APPEND 0x08 /* Append path to the route */ +#define RTM_F_FORCE 0x10 /* Bump operation priority to highest */ int rib_add_route(uint32_t fibnum, struct rt_addrinfo *info, struct rib_cmd_info *rc); diff --git a/lib/libc/include/generic-freebsd/net/route/route_debug.h b/lib/libc/include/generic-freebsd/net/route/route_debug.h index b0b8be53f5e12d24d0776bdd8637932bf72290e6..e28543c2fd42c521ca0e738194f592f070b8f40d 100644 --- a/lib/libc/include/generic-freebsd/net/route/route_debug.h +++ b/lib/libc/include/generic-freebsd/net/route/route_debug.h @@ -116,10 +116,11 @@ SYSCTL_DECL(_net_route_debug); * Example: [nhop_neigh] nhops_update_neigh: */ #define RT_LOG(_l, _fmt, ...) RT_LOG_##_l(_l, _fmt, ## __VA_ARGS__) -#define _RT_LOG(_l, _fmt, ...) if (_DEBUG_PASS_MSG(_l)) { \ - _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", __func__, ##__VA_ARGS__); \ -} - +#define _RT_LOG(_l, _fmt, ...) do { \ + if (_DEBUG_PASS_MSG(_l)) \ + _output("[" DEBUG_PREFIX_NAME "] %s: " _fmt "\n", \ + __func__, ##__VA_ARGS__); \ +} while (0) /* * Wrapper logic to avoid compiling high levels of debugging messages for diff --git a/lib/libc/include/generic-freebsd/net/sff8472.h b/lib/libc/include/generic-freebsd/net/sff8472.h index ee61377ac1a735dd9ea6db2f410f0ff4cebed512..6ffdba9d6660c7c16ef0ff8118c97ed9be001032 100644 --- a/lib/libc/include/generic-freebsd/net/sff8472.h +++ b/lib/libc/include/generic-freebsd/net/sff8472.h @@ -26,6 +26,9 @@ * SUCH DAMAGE. */ +#ifndef _NET_SFF8472_H_ +#define _NET_SFF8472_H_ + /* * The following set of constants are from Document SFF-8472 * "Diagnostic Monitoring Interface for Optical Transceivers" revision @@ -415,6 +418,7 @@ enum { SFF_8024_ID_LAST = SFF_8024_ID_QSFP_CMIS }; +#if defined(_WANT_SFF_8024_ID) || defined(_WANT_SFF_8472_ID) static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = { "Unknown", "GBIC", @@ -448,6 +452,7 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = { "x8MiniLink", "QSFP+(CIMS)" }; +#endif /* Keep compatibility with old definitions */ #define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN @@ -523,4 +528,6 @@ static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = { * yielding a total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). */ -#define SFF_8472_POWER_FACTOR 10000.0 \ No newline at end of file +#define SFF_8472_POWER_FACTOR 10000.0 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net/vnet.h b/lib/libc/include/generic-freebsd/net/vnet.h index 33cf304daf7505391e81bf235b84bd3f7c4ae03f..54d35cbeb39227432f5ebe43f1e20703e33eb6d8 100644 --- a/lib/libc/include/generic-freebsd/net/vnet.h +++ b/lib/libc/include/generic-freebsd/net/vnet.h @@ -311,6 +311,12 @@ void *vnet_data_alloc(int size); void vnet_data_copy(void *start, int size); void vnet_data_free(void *start_arg, int size); +/* + * Interfaces to manipulate the initial values of virtualized global variables. + */ +void vnet_save_init(void *, size_t); +void vnet_restore_init(void *, size_t); + /* * Virtual sysinit mechanism, allowing network stack components to declare * startup and shutdown methods to be run when virtual network stack @@ -400,7 +406,7 @@ do { \ #define CURVNET_SET(arg) #define CURVNET_SET_QUIET(arg) #define CURVNET_RESTORE() -#define CURVNET_ASSERT_SET() \ +#define CURVNET_ASSERT_SET() #define VNET_LIST_RLOCK() #define VNET_LIST_RLOCK_NOSLEEP() diff --git a/lib/libc/include/generic-freebsd/net80211/_ieee80211.h b/lib/libc/include/generic-freebsd/net80211/_ieee80211.h index 442bac97aff67325e04a74248d2da28612719472..23d3d75d00f9e8c5d905621e2815d0df61df0a69 100644 --- a/lib/libc/include/generic-freebsd/net80211/_ieee80211.h +++ b/lib/libc/include/generic-freebsd/net80211/_ieee80211.h @@ -536,6 +536,27 @@ struct ieee80211_mimo_info { "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS\32TXLDPC\33RXAMSDUAMPDU" \ "\34TXAMSDUAMPDU" +/* + * AKM (key management) suite capability list. + * + * These represent what's in 802.11-2016 - Table 9-133 - AKM Suite Selectors. + * Note that they do not match what the table values are, in case other key + * management suites want to be added with different OUIs. + */ +#define IEEE80211_KEYMGMT_RSN_UNSPEC_802_1X 0x00000001 /* RSN suite 1 */ +#define IEEE80211_KEYMGMT_RSN_PSK_OVER_802_1X 0x00000002 /* RSN suite 2 */ +#define IEEE80211_KEYMGMT_RSN_FT_OVER_802_1X 0x00000004 /* RSN suite 3 */ +#define IEEE80211_KEYMGMT_RSN_FT_PSK 0x00000008 /* RSN suite 4 */ +#define IEEE80211_KEYMGMT_RSN_802_1X_SHA256 0x00000010 /* RSN suite 5 */ +#define IEEE80211_KEYMGMT_RSN_PSK_SHA256 0x00000020 /* RSN suite 6 */ +#define IEEE80211_KEYMGMT_RSN_TPK_HANDSHAKE 0x00000040 /* RSN suite 7 */ +#define IEEE80211_KEYMGMT_RSN_SAE 0x00000080 /* RSN suite 8 */ +#define IEEE80211_KEYMGMT_RSN_FT_SAE 0x00000100 /* RSN suite 9 */ +#define IEEE80211_KEYMGMT_RSN_APPEERKEY_SHA256 0x00000200 /* RSN suite 10 */ +#define IEEE80211_KEYMGMT_RSN_802_1X_SUITE_B 0x00000400 /* RSN suite 11 */ +#define IEEE80211_KEYMGMT_RSN_802_1X_SUITE_B_192 0x00000800 /* RSN suite 12 */ +#define IEEE80211_KEYMGMT_RSN_FT_802_1X_SHA384 0x00001000 /* RSN suite 13 */ + /* * RX status notification - which fields are valid. */ @@ -564,15 +585,18 @@ struct ieee80211_mimo_info { #define IEEE80211_RX_F_AMPDU 0x00000010 /* This is the start of an decap AMPDU list */ #define IEEE80211_RX_F_AMPDU_MORE 0x00000020 /* This is another decap AMPDU frame in the batch */ #define IEEE80211_RX_F_FAIL_FCSCRC 0x00000040 /* Failed CRC/FCS */ -#define IEEE80211_RX_F_FAIL_MIC 0x00000080 /* Failed MIC check */ +#define IEEE80211_RX_F_FAIL_MMIC 0x00000080 /* Failed Michael MIC (MMIC) check */ #define IEEE80211_RX_F_DECRYPTED 0x00000100 /* Hardware decrypted */ #define IEEE80211_RX_F_IV_STRIP 0x00000200 /* Decrypted; IV stripped */ -#define IEEE80211_RX_F_MMIC_STRIP 0x00000400 /* Decrypted; MMIC stripped */ +#define IEEE80211_RX_F_MMIC_STRIP 0x00000400 /* Decrypted; Michael MIC (MMIC) stripped */ #define IEEE80211_RX_F_SHORTGI 0x00000800 /* This is a short-GI frame */ #define IEEE80211_RX_F_CCK 0x00001000 #define IEEE80211_RX_F_OFDM 0x00002000 #define IEEE80211_RX_F_HT 0x00004000 #define IEEE80211_RX_F_VHT 0x00008000 +#define IEEE80211_RX_F_PN_VALIDATED 0x00010000 /* Decrypted; PN validated */ +#define IEEE80211_RX_F_MIC_STRIP 0x00020000 /* Decrypted; MIC stripped */ +#define IEEE80211_RX_F_ICV_STRIP 0x00040000 /* Decrypted: ICV (ic_trailer) stripped */ /* Channel width */ #define IEEE80211_RX_FW_20MHZ 1 diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211.h b/lib/libc/include/generic-freebsd/net80211/ieee80211.h index 04b62c98718d9d146e8b16be8e856314383a74bb..8b68116251e811ae25371e43d377389cfb5a975c 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211.h @@ -4,6 +4,10 @@ * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. + * Copyright (c) 2020-2025 The FreeBSD Foundation + * + * Portions of this software were developed by Björn Zeeb + * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,6 +32,12 @@ #ifndef _NET80211_IEEE80211_H_ #define _NET80211_IEEE80211_H_ +#include + +#ifndef _KERNEL +#include +#endif + /* * 802.11 protocol definitions. */ @@ -161,6 +171,7 @@ struct ieee80211_qosframe_addr4 { /* 0001-0011 Reserved 0x10-0x30 */ /* Were: CF_ACK, CF_POLL, CF_ACPL */ #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 /* Null */ /* 0101-0111 Reserved 0x50-0x70 */ /* Were: CFACK, CFPOLL, CF_ACK_CF_ACK */ +#define IEEE80211_FC0_SUBTYPE_QOS_MASK_ANY 0x80 /* QoS mask - matching any subtypes 8..15 */ #define IEEE80211_FC0_SUBTYPE_QOS_DATA 0x80 /* QoS Data */ #define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFACK 0x90 /* QoS Data +CF-Ack */ #define IEEE80211_FC0_SUBTYPE_QOS_DATA_CFPOLL 0xa0 /* QoS Data +CF-Poll */ @@ -190,24 +201,98 @@ struct ieee80211_qosframe_addr4 { #define IEEE80211_CTL_EXT_TDD_BF 0x0b /* TDD Beamforming, 80211ay-2021 */ /* 1100-1111 Reserved 0xc-0xf */ -#define IEEE80211_IS_MGMT(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_MGT)) +/* Check the version field */ +#define IEEE80211_IS_FC0_CHECK_VER(wh, v) \ + (((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v)) + +/* Check the version and type field */ +#define IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, v, t) \ + (((((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t))) + +/* Check the version, type and subtype field */ +#define IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, v, t, st) \ + (((((wh)->i_fc[0] & IEEE80211_FC0_VERSION_MASK) == (v))) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == (t)) && \ + (((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == (st))) + +#define IEEE80211_IS_MGMT(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT)) #define IEEE80211_IS_CTL(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_CTL)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_CTL)) #define IEEE80211_IS_DATA(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_DATA)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_DATA)) #define IEEE80211_IS_EXT(wh) \ - (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ - == IEEE80211_FC0_TYPE_EXT)) + (IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_EXT)) -#define IEEE80211_FC0_QOSDATA \ - (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS_DATA|IEEE80211_FC0_VERSION_0) +/* Management frame types */ + +#define IEEE80211_IS_MGMT_BEACON(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_BEACON)) + +#define IEEE80211_IS_MGMT_PROBE_RESP(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_PROBE_RESP)) + +#define IEEE80211_IS_MGMT_ACTION(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_MGT, \ + IEEE80211_FC0_SUBTYPE_ACTION)) + +/* Control frame types */ + +#define IEEE80211_IS_CTL_PS_POLL(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_CTL, \ + IEEE80211_FC0_SUBTYPE_PS_POLL)) + +#define IEEE80211_IS_CTL_BAR(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_CTL, \ + IEEE80211_FC0_SUBTYPE_BAR)) + +/* Data frame types */ + +/* + * Return true if the frame is any of the QOS frame types, not just + * data frames. Matching on the IEEE80211_FC0_SUBTYPE_QOS_ANY bit + * being set also matches on subtypes 8..15. + */ +#define IEEE80211_IS_QOS_ANY(wh) \ + ((IEEE80211_IS_FC0_CHECK_VER_TYPE(wh, IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_DATA)) && \ + ((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS_MASK_ANY)) + +/* + * Return true if this frame is QOS data, and only QOS data. + */ +#define IEEE80211_IS_QOSDATA(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_DATA, \ + IEEE80211_FC0_SUBTYPE_QOS_DATA)) + +/* + * Return true if this frame is a QoS NULL data frame. + */ +#define IEEE80211_IS_QOS_NULL(wh) \ + (IEEE80211_IS_FC0_CHECK_VER_TYPE_SUBTYPE(wh, \ + IEEE80211_FC0_VERSION_0, \ + IEEE80211_FC0_TYPE_DATA, \ + IEEE80211_FC0_SUBTYPE_QOS_NULL)) -#define IEEE80211_IS_QOSDATA(wh) \ - ((wh)->i_fc[0] == IEEE80211_FC0_QOSDATA) #define IEEE80211_FC1_DIR_MASK 0x03 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ @@ -421,7 +506,7 @@ struct ieee80211_action { #define IEEE80211_ACTION_CAT_BA 3 /* 9.6.4 Block Ack */ #define IEEE80211_ACTION_CAT_PUBLIC 4 /* 9.6.7 Public */ #define IEEE80211_ACTION_CAT_RADIO_MEASUREMENT 5 /* 9.6.6 Radio Measurement */ -#define IEEE80211_ACTION_CAT_FAST_BBS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */ +#define IEEE80211_ACTION_CAT_FAST_BSS_TRANSITION 6 /* 9.6.8 Fast BSS Transition */ #define IEEE80211_ACTION_CAT_HT 7 /* 9.6.11 HT */ #define IEEE80211_ACTION_CAT_SA_QUERY 8 /* 9.6.9 SA Query */ #define IEEE80211_ACTION_CAT_PROTECTED_DUAL_OF_PUBLIC_ACTION 9 /* 9.6.10 Protected Dual of Public Action */ @@ -856,6 +941,7 @@ enum ieee80211_vht_mcs_support { IEEE80211_VHT_MCS_NOT_SUPPORTED = 3 /* not supported */ }; +/* 802.11ac-2013, 8.4.2.160.3 Supported VHT-MCS and NSS Set field */ struct ieee80211_vht_mcs_info { uint16_t rx_mcs_map; uint16_t rx_highest; @@ -869,12 +955,15 @@ struct ieee80211_vht_cap { struct ieee80211_vht_mcs_info supp_mcs; } __packed; -/* 802.11ac-2013, Table 8-183x-VHT Operation Information subfields */ +/* + * 802.11ac-2013, Table 8-183x-VHT Operation Information subfields. + * 802.11-2020, Table 9-274-VHT Operation Information subfields (for deprecations) + */ enum ieee80211_vht_chanwidth { IEEE80211_VHT_CHANWIDTH_USE_HT = 0, /* 20 MHz or 40 MHz */ IEEE80211_VHT_CHANWIDTH_80MHZ = 1, /* 80MHz */ - IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz */ - IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz */ + IEEE80211_VHT_CHANWIDTH_160MHZ = 2, /* 160MHz (deprecated) */ + IEEE80211_VHT_CHANWIDTH_80P80MHZ = 3, /* 80+80MHz (deprecated) */ /* 4..255 reserved. */ }; @@ -898,7 +987,7 @@ struct ieee80211_vht_operation { #define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK 0x0000000C #define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK_S 2 -#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NONE 0 +#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_NO160 0 #define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ 1 #define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ 2 #define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_RESERVED 3 @@ -969,11 +1058,15 @@ struct ieee80211_vht_operation { #define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN 0x20000000 #define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN_S 29 +/* 802.11-2016, 9.4.2.158.2 VHT Capabilities Information field. */ +#define IEEE80211_VHTCAP_EXT_NSS_BW 0xc0000000 +#define IEEE80211_VHTCAP_EXT_NSS_BW_S 30 + /* * XXX TODO: add the rest of the bits */ #define IEEE80211_VHTCAP_BITS \ - "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN8080\5RXLDPC\6SHORTGI80" \ + "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN160+80P80\5RXLDPC\6SHORTGI80" \ "\7SHORTGI160\10RXSTBC1\11RXSTBC2\12RXSTBC3\13RXSTBC4\14BFERCAP" \ "\15BFEECAP\27VHT\37RXANTPTN\40TXANTPTN" @@ -1015,22 +1108,296 @@ struct ieee80211_ie_vht_txpwrenv { #define WLAN_ACTION_VHT_GROUPID_MGMT 1 #define WLAN_ACTION_VHT_OPMODE_NOTIF 2 +#if defined(_KERNEL) || defined(WANT_NET80211) +/* + * HE + */ + +/* + * 802.11ax-2021, 9.4.2.248.2 HE MAC Capabilities Information field. + */ +/* B0..B7 */ +#define IEEE80211_HE_MAC_CAP0_HTC_HE (1<<0) +#define IEEE80211_HE_MAC_CAP0_TWT_REQ (1<<1) +#define IEEE80211_HE_MAC_CAP0_TWT_RES (1<<2) + +/* B8..B15 */ +#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US (1<<3) +#define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK (1<<3 | 1<<2) +#define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8 (1<<6 | 1<<5 | 1<<4) +#define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION (1<<7) +/* Note: B15|B16 are split between octets %!$@??? */ + +/* B16..B23 */ +#define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION (1<<0) +#define IEEE80211_HE_MAC_CAP2_ALL_ACK (1<<1) +#define IEEE80211_HE_MAC_CAP2_TRS (1<<2) +#define IEEE80211_HE_MAC_CAP2_BSR (1<<3) +#define IEEE80211_HE_MAC_CAP2_BCAST_TWT (1<<4) +#define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP (1<<5) +#define IEEE80211_HE_MAC_CAP2_MU_CASCADING (1<<6) +#define IEEE80211_HE_MAC_CAP2_ACK_EN (1<<7) + +/* B24..B31 */ +#define IEEE80211_HE_MAC_CAP3_OMI_CONTROL (1<<1) +#define IEEE80211_HE_MAC_CAP3_OFDMA_RA (1<<2) +#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_1 (1<<3) +#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_2 (1<<4) +#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_EXT_3 (1<<4 | 1<<3) +#define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK (1<<4 | 1<<3) +#define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED (1<<6) +#define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS (1<<7) + +/* B32..B39 */ +#define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG (1<<0) +#define IEEE80211_HE_MAC_CAP4_BQR (1<<2) +#define IEEE80211_HE_MAC_CAP4_OPS (1<<5) +#define IEEE80211_HE_MAC_CAP4_AMSDU_IN_AMPDU (1<<6) +#define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39 (1<<7) +/* Note: B39|B40|B41 are split between octets %!$@??? */ + +/* B40..B47 */ +#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40 (1<<0) +#define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41 (1<<1) +#define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECTIVE_TRANSMISSION (1<<2) +#define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU (1<<3) +#define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX (1<<4) +#define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS (1<<5) +#define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING (1<<6) +#define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX (1<<7) + +/* + * 802.11ax-2021, 9.4.2.248.3 HE PHY Capabilities Information field. + */ +/* B0..B7 */ +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G (1<<1) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G (1<<2) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G (1<<3) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G (1<<4) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK_ALL (1<<4 | 1<<3 | 1<<2 | 1<<1) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G (1<<5) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G (1<<6) +#define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK (1<<6 | 1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1) + +/* B8..B15 */ +#define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK (1<<3 | 1<<2 | 1<<1 | 1<<0) +#define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A (1<<4) +#define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD (1<<5) +#define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US (1<<6) +#define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS (1<<7) +/* Note: B15|B16 are split between octets %!$@??? */ + +/* B16..B23 */ +#define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS (1<<0) +#define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US (1<<1) +#define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ (1<<2) +#define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ (1<<3) +#define IEEE80211_HE_PHY_CAP2_DOPPLER_TX (1<<4) +#define IEEE80211_HE_PHY_CAP2_DOPPLER_RX (1<<5) +#define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO (1<<6) +#define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO (1<<7) + +/* B24..B31 */ +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM 0x00 +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK (1<<0) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK (1<<1) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM (1<<1 | 1<<0) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK (1<<1 | 1<<0) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1 0x00 +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2 (1<<2) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM 0x00 +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK (1<<3) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK (1<<4) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM (1<<4 | 1<<3) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK (1<<4 | 1<<3) +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1 0x00 +#define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2 (1<<5) +#define IEEE80211_HE_PHY_CAP3_RX_PARTIAL_BW_SU_IN_20MHZ_MU (1<<6) +#define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER (1<<7) + +/* B32..B39 */ +#define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE (1<<0) +#define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER (1<<1) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4 (1<<3 | 1<<2) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5 (1<<4) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8 (1<<4 | 1<<3 | 1<<2) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK (1<<4 | 1<<3 | 1<<2) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4 (1<<6 | 1<<5) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5 (1<<7) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8 (1<<7 | 1<<6 | 1<<5) +#define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK (1<<7 | 1<<6 | 1<<5) + +/* B40..B47 */ +#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2 (1<<0) +#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK (1<<2 | 1<<1 | 1<<0) +#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2 (1<<3) +#define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK (1<<5 | 1<<4 | 1<<3) +#define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK (1<<6) +#define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK (1<<7) + +/* B48..B55 */ +#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU (1<<0) +#define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU (1<<1) +#define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMING_FB (1<<2) +#define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMING_PARTIAL_BW_FB (1<<3) +#define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB (1<<4) +#define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE (1<<5) +#define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO (1<<6) +#define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT (1<<7) + +/* B56..B63 */ +#define IEEE80211_HE_PHY_CAP7_PSR_BASED_SR (1<<0) +#define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_SUPP (1<<1) +#define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI (1<<2) +#define IEEE80211_HE_PHY_CAP7_MAX_NC_1 (1<<3) +#define IEEE80211_HE_PHY_CAP7_MAX_NC_2 (1<<4) +#define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK (1<<5 | 1<<4 | 1<<3) +#define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ (1<<6) +#define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ (1<<7) + +/* B64..B71 */ +#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI (1<<0) +#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G (1<<1) +#define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU (1<<2) +#define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU (1<<3) +#define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI (1<<4) +#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 0x00 +#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 (1<<6) +#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 (1<<7) +#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996 (1<<7 | 1<<6) +#define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK (1<<7 | 1<<6) + +/* B72..B79 */ +#define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM (1<<0) +#define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK (1<<1) +#define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU (1<<2) +#define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU (1<<3) +#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB (1<<4) +#define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB (1<<5) +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_0US 0x00 +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_8US 1 +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_16US 2 +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED 3 +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_POS 6 +#define IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK (1<<7 | 1<<6) + +/* B80..B87 */ +#define IEEE80211_HE_PHY_CAP10_HE_MU_M1RU_MAX_LTF (1<<0) + +/* + * 802.11ax-2021, + * 9.4.2.248.2 HE MAC Capabilities Information field. + * 9.4.2.248.3 HE PHY Capabilities Information field. + */ +struct ieee80211_he_cap_elem { + uint8_t mac_cap_info[6]; + uint8_t phy_cap_info[11]; +} __packed; + +/* 802.11ax-2021, 9.4.2.248.4 Supported HE-MCS And NSS Set field. */ +enum ieee80211_he_mcs_support { + IEEE80211_HE_MCS_SUPPORT_0_7 = 0, /* HE-MCS 0-7 for n NSS */ + IEEE80211_HE_MCS_SUPPORT_0_9 = 1, /* HE-MCS 0-9 for n NSS */ + IEEE80211_HE_MCS_SUPPORT_0_11 = 2, /* HE-MCS 0-11 for n NSS */ + IEEE80211_HE_MCS_NOT_SUPPORTED = 3 /* n NSS not supported. */ +}; + +struct ieee80211_he_mcs_nss_supp { + uint16_t rx_mcs_80; + uint16_t tx_mcs_80; + uint16_t rx_mcs_160; + uint16_t tx_mcs_160; + uint16_t rx_mcs_80p80; + uint16_t tx_mcs_80p80; +} __packed; + +#define IEEE80211_HE_CAP_PPE_THRES_MAX 25 + +/* XXX this should only be internal. */ +struct net80211_he_cap { + bool has_he; + struct ieee80211_he_cap_elem he_cap_elem; + struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp; + uint8_t ppe_thres[IEEE80211_HE_CAP_PPE_THRES_MAX]; +}; + +/* 802.11ax-2021, 9.4.2.249 HE Operation element. */ +#define IEEE80211_HE_OPERATION_ER_SU_DISABLE (1<<16) +#define IEEE80211_HE_OPERATION_BSS_COLOR_OFFSET 24 +#define IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED (1<<31) + +struct ieee80211_he_operation { + uint32_t he_oper_params; /* (3) params | (1) bss color info */ + uint16_t he_mcs_nss_set; + uint8_t optional[0]; +} __packed; + +/* 802.11ax-2021, 9.4.2.251 MU EDCA Parameter Set element. */ +struct ieee80211_he_mu_edca_param_ac_rec { + uint8_t aifsn; + uint8_t ecw_min_max; + uint8_t mu_edca_timer; +} __packed; + +struct ieee80211_mu_edca_param_set { + uint8_t mu_qos_info; + union { + struct { + struct ieee80211_he_mu_edca_param_ac_rec ac_be; + struct ieee80211_he_mu_edca_param_ac_rec ac_bk; + struct ieee80211_he_mu_edca_param_ac_rec ac_vi; + struct ieee80211_he_mu_edca_param_ac_rec ac_vo; + }; + struct ieee80211_he_mu_edca_param_ac_rec param_ac_recs[4]; + }; +} __packed; + +/* 802.11ax-2021, 9.4.2.252 Spatial Reuse Parameter Set element */ +/* Figure 9-788r-SR Control field format */ +#define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED (1<<1) +#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT (1<<2) +#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT (1<<3) +#define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED (1<<4) + +/* 802.11ax-2021, 9.4.2.263 HE 6 GHz Band Capabilities element */ +/* Figure 9-788aj-Capabilities Information field format */ +#define IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START (1<<2 | 1<<1 | 1<<0) +#define IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP (1<<5 | 1<<4 | 1<<3) +#define IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN (1<<7 | 1<<6) +#define IEEE80211_HE_6GHZ_CAP_SM_PS (1<<10 | 1<<9) +#define IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS (1<<12) +#define IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS (1<<13) + +struct ieee80211_he_6ghz_capa { + uint16_t capa; +}; +#endif /* _KERNEL || WANT_NET80211 */ + /* * Management information element payloads. + * + * 802.11-2020 Table 9-92 (Element IDs). + * 802.11ax-2021 */ enum { IEEE80211_ELEMID_SSID = 0, IEEE80211_ELEMID_RATES = 1, - IEEE80211_ELEMID_FHPARMS = 2, + /* 2 Reserved */ + IEEE80211_ELEMID_FHPARMS = 2, /* remove? */ IEEE80211_ELEMID_DSPARMS = 3, - IEEE80211_ELEMID_CFPARMS = 4, + /* 4 Reserved */ + IEEE80211_ELEMID_CFPARMS = 4, /* remove? */ IEEE80211_ELEMID_TIM = 5, IEEE80211_ELEMID_IBSSPARMS = 6, IEEE80211_ELEMID_COUNTRY = 7, + /* 8, 9 reserved */ + IEEE80211_ELEMID_REQUEST = 10, IEEE80211_ELEMID_BSSLOAD = 11, + IEEE80211_ELEMID_EDCA_PARAM_SET = 12, IEEE80211_ELEMID_TSPEC = 13, IEEE80211_ELEMID_TCLAS = 14, + IEEE80211_ELEMID_SCHEDULE = 15, IEEE80211_ELEMID_CHALLENGE = 16, /* 17-31 reserved for challenge text extension */ IEEE80211_ELEMID_PWRCNSTR = 32, @@ -1044,28 +1411,77 @@ enum { IEEE80211_ELEMID_QUIET = 40, IEEE80211_ELEMID_IBSSDFS = 41, IEEE80211_ELEMID_ERP = 42, + IEEE80211_ELEMID_TS_DELAY = 43, + IEEE80211_ELEMID_TCLAS_PROCES = 44, IEEE80211_ELEMID_HTCAP = 45, IEEE80211_ELEMID_QOS = 46, + /* 47 reserved */ IEEE80211_ELEMID_RESERVED_47 = 47, IEEE80211_ELEMID_RSN = 48, + /* 49 reserved */ IEEE80211_ELEMID_XRATES = 50, IEEE80211_ELEMID_APCHANREP = 51, - IEEE80211_ELEMID_MOBILITY_DOMAIN = 54, - IEEE80211_ELEMID_HTINFO = 61, + IEEE80211_ELEMID_NEIGHBOR_REP = 52, + IEEE80211_ELEMID_RCPI = 53, + IEEE80211_ELEMID_MOBILITY_DOMAIN = 54, /* MDE */ + IEEE80211_ELEMID_FAST_BSS_TRANS = 55, /* FTE */ + IEEE80211_ELEMID_TIMEOUT_INTVL = 56, + IEEE80211_ELEMID_RIC_DATA = 57, /* RDE */ + IEEE80211_ELEMID_DSE_REG_LOC = 58, + IEEE80211_ELEMID_SUP_OP_CLASS = 59, + IEEE80211_ELEMID_EXT_CSA = 60, + IEEE80211_ELEMID_HTINFO = 61, /* HTOPER */ IEEE80211_ELEMID_SECCHAN_OFFSET = 62, - IEEE80211_ELEMID_RRM_ENACAPS = 70, + IEEE80211_ELEMID_BSS_AVG_ACC_DELAY = 63, + IEEE80211_ELEMID_ANTENNA = 64, + IEEE80211_ELEMID_RSNI = 65, + IEEE80211_ELEMID_MEAS_PILOT_TRANS = 66, + IEEE80211_ELEMID_BSS_AVAIL_AD_CAP = 67, + IEEE80211_ELEMID_BSS_AC_ACC_DELAY = 68, + IEEE80211_ELEMID_TIME_ADV = 69, + IEEE80211_ELEMID_RRM_ENACAPS = 70, /* RM_ENCAPS */ IEEE80211_ELEMID_MULTIBSSID = 71, IEEE80211_ELEMID_COEX_2040 = 72, - IEEE80211_ELEMID_INTOL_CHN_REPORT = 73, + IEEE80211_ELEMID_2040_INTOL_CHAN_REPORT = 73, IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM = 74, + IEEE80211_ELEMID_RIC_DESC = 75, + IEEE80211_ELEMID_MGMT_MIC = 76, + /* 77 reserved */ + IEEE80211_ELEMID_EVENT_REQ = 78, + IEEE80211_ELEMID_EVENT_REP = 79, + IEEE80211_ELEMID_DIAGNOSTIC_REQ = 80, + IEEE80211_ELEMID_DIAGNOSTIC_REP = 81, + IEEE80211_ELEMID_LOCATION_PARAM = 82, + IEEE80211_ELEMID_NONTRANS_BSSID_CAP = 83, + IEEE80211_ELEMID_SSID_LIST = 84, + IEEE80211_ELEMID_MULTI_BSSID_IDX = 85, + IEEE80211_ELEMID_FMS_DESC = 86, + IEEE80211_ELEMID_FMS_REQ = 87, + IEEE80211_ELEMID_FMS_RESP = 88, + IEEE80211_ELEMID_QOS_TRAFFIC_CAP = 89, + IEEE80211_ELEMID_BSS_MAX_IDLE_P = 90, IEEE80211_ELEMID_TSF_REQ = 91, IEEE80211_ELEMID_TSF_RESP = 92, IEEE80211_ELEMID_WNM_SLEEP_MODE = 93, IEEE80211_ELEMID_TIM_BCAST_REQ = 94, IEEE80211_ELEMID_TIM_BCAST_RESP = 95, - IEEE80211_ELEMID_TPC = 150, - IEEE80211_ELEMID_CCKM = 156, - IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ + IEEE80211_ELEMID_COL_INTERF_REP = 96, + IEEE80211_ELEMID_CHAN_USAGE = 97, + IEEE80211_ELEMID_TIME_ZONE = 98, + IEEE80211_ELEMID_DMS_REQ = 99, + IEEE80211_ELEMID_DMS_RESP = 100, + IEEE80211_ELEMID_LINK_ID = 101, + IEEE80211_ELEMID_WAKEUP_SCHED = 102, + /* 103 reserved */ + IEEE80211_ELEMID_CHAN_SW_TIMING = 104, + IEEE80211_ELEMID_PTI_CONTROL = 105, + IEEE80211_ELEMID_TPU_BUF_STATUS = 106, + IEEE80211_ELEMID_INTERWORKING = 107, + IEEE80211_ELEMID_ADV_PROTO = 108, + IEEE80211_ELEMID_EXP_BW_REQ = 109, + IEEE80211_ELEMID_QOS_MAP = 110, + IEEE80211_ELEMID_ROAM_CONSORT = 111, + IEEE80211_ELEMID_EMERG_ALERT_ID = 112, /* * 802.11s IEs @@ -1095,17 +1511,180 @@ enum { IEEE80211_ELEMID_MESHPXU = 137, IEEE80211_ELEMID_MESHPXUC = 138, IEEE80211_ELEMID_MESHAH = 60, /* XXX: remove */ + /* XXX 139 */ - /* 802.11ac-2013, Table 8-54-Element IDs */ + IEEE80211_ELEMID_MIC = 140, + IEEE80211_ELEMID_DEST_URI = 141, + IEEE80211_ELEMID_U_APSD_COEX = 142, + IEEE80211_ELEMID_DMG_WAKEUP_SCHED = 143, + IEEE80211_ELEMID_EXT_SCHED = 144, + IEEE80211_ELEMID_STA_AVAIL = 145, + IEEE80211_ELEMID_DMG_TSPEC = 146, + IEEE80211_ELEMID_NEXT_DMG_ATI = 147, + IEEE80211_ELEMID_DMG_CAP = 148, + /* 149-150 reserved. */ + IEEE80211_ELEMID_TPC = 150, /* XXX: remove */ + IEEE80211_ELEMID_DMG_OPER = 151, + IEEE80211_ELEMID_DMG_BSS_PARAM_CHANGE = 152, + IEEE80211_ELEMID_DMG_BEAM_REF = 153, + IEEE80211_ELEMID_CHAN_MEAS_FEEDB = 154, + /* 155-156 reserved. */ + IEEE80211_ELEMID_CCKM = 156, /* XXX: remove? */ + IEEE80211_ELEMID_AWAKE_WIN = 157, + IEEE80211_ELEMID_MULTI_BAND = 158, + IEEE80211_ELEMID_ADDBA_EXT = 159, + IEEE80211_ELEMID_NEXTPCP_LIST = 160, + IEEE80211_ELEMID_PCP_HANDOVER = 161, + IEEE80211_ELEMID_DMG_LINK_MARGIN = 162, + IEEE80211_ELEMID_SW_STREAM = 163, + IEEE80211_ELEMID_SESS_TRANS = 164, + /* 165 reserved. */ + IEEE80211_ELEMID_CLUSTER_REP = 166, + IEEE80211_ELEMID_RELAY_CAP = 167, + IEEE80211_ELEMID_RELAY_TRANS_PARAM_SET = 168, + IEEE80211_ELEMID_BEAMLINK_MAINT = 169, + IEEE80211_ELEMID_MULTI_MAC_SUBL = 170, + IEEE80211_ELEMID_U_PID = 171, + IEEE80211_ELEMID_DMG_LINK_ADAP_ACK = 172, + /* 173 reserved. */ + IEEE80211_ELEMID_MCCAOP_ADV_OV = 174, + IEEE80211_ELEMID_QUIET_PERIOD_REQ = 175, + /* 176 reserved. */ + IEEE80211_ELEMID_QUIET_PERIOD_RESP = 177, + /* 178-180 reserved. */ + IEEE80211_ELEMID_QMF_POLICY = 181, + IEEE80211_ELEMID_ECAPC_POLICY = 182, + IEEE80211_ELEMID_CLUSTER_TIME_OFFSET = 183, + IEEE80211_ELEMID_INTRA_ACC_CAT_PRIO = 184, + IEEE80211_ELEMID_SCS_DESCR = 185, + IEEE80211_ELEMID_QLOAD_REPORT = 186, + IEEE80211_ELEMID_HCCA_TXOP_UP_CNT = 187, + IEEE80211_ELEMID_HL_STREAM_ID = 188, + IEEE80211_ELEMID_GCR_GROUP_ADDR = 189, + IEEE80211_ELEMID_ANTENNA_SECTOR_ID_PAT = 190, IEEE80211_ELEMID_VHT_CAP = 191, IEEE80211_ELEMID_VHT_OPMODE = 192, IEEE80211_ELEMID_EXTENDED_BSS_LOAD = 193, - IEEE80211_ELEMID_WIDE_BW_CHANNEL_SWITCH = 194, - IEEE80211_ELEMID_VHT_PWR_ENV = 195, + IEEE80211_ELEMID_WIDE_BW_CHAN_SW = 194, + IEEE80211_ELEMID_VHT_PWR_ENV = 195, /* TX_PWR_ENV */ IEEE80211_ELEMID_CHANNEL_SWITCH_WRAPPER = 196, IEEE80211_ELEMID_AID = 197, IEEE80211_ELEMID_QUIET_CHANNEL = 198, IEEE80211_ELEMID_OPMODE_NOTIF = 199, + IEEE80211_ELEMID_UPSIM = 200, + IEEE80211_ELEMID_RED_NEIGH_REP = 201, + IEEE80211_ELEMID_TVHT_OP = 202, + /* 203 reserved. */ + IEEE80211_ELEMID_DEVICE_LOC = 204, + IEEE80211_ELEMID_WHITE_SPACE_MAP = 205, + IEEE80211_ELEMID_FINE_TIME_MEAS_PARAM = 206, + IEEE80211_ELEMID_SIG_OPEN_LOOP_LINK_MARGIN_IDX = 207, + IEEE80211_ELEMID_RPS = 208, + IEEE80211_ELEMID_PAGE_SLICE = 209, + IEEE80211_ELEMID_AID_REQ = 210, + IEEE80211_ELEMID_AID_RESP = 211, + IEEE80211_ELEMID_SIG_SECTOR_OP = 212, + IEEE80211_ELEMID_SIG_BEACON_COMPAT = 213, + IEEE80211_ELEMID_SHORT_BEACON_INTVL = 214, + IEEE80211_ELEMID_CHANGE_SEQ = 215, + IEEE80211_ELEMID_TWT = 216, + IEEE80211_ELEMID_SIG_CAPS = 217, + /* 218-219 reserved. */ + IEEE80211_ELEMID_SUBCHAN_SELECT_TRANS = 220, + IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ + IEEE80211_ELEMID_AUTH_CONTROL = 222, + IEEE80211_ELEMID_TSF_TIMER_ACC = 223, + IEEE80211_ELEMID_S1G_RELAY = 224, + IEEE80211_ELEMID_REACHABLE_ADDR = 225, + IEEE80211_ELEMID_SIG_RELAY_DISC = 226, + /* 227 reserved. */ + IEEE80211_ELEMID_AID_ANNOUNCEMENT = 228, + IEEE80211_ELEMID_PV1_PROBE_RESP_OPT = 229, + IEEE80211_ELEMID_EL_OP = 230, + IEEE80211_ELEMID_SECTORIZED_GRP_ID_LIST = 231, + IEEE80211_ELEMID_SIG_OP = 232, + IEEE80211_ELEMID_HDR_COMPRESSION = 233, + IEEE80211_ELEMID_SST_OP = 234, + IEEE80211_ELEMID_MAD = 235, + IEEE80211_ELEMID_SIG_RELAY_ACT = 236, + IEEE80211_ELEMID_CAG_NUMBER = 237, + /* 238 reserved. */ + IEEE80211_ELEMID_AP_CSN = 239, + IEEE80211_ELEMID_FILS_INDICATION = 240, + IEEE80211_ELEMID_DILS = 241, + IEEE80211_ELEMID_FRAGMENT = 242, + /* 243 reserved. */ + IEEE80211_ELEMID_RSN_EXT = 244, + /* 245-254 reserved. */ + IEEE80211_ELEMID_EXTFIELD = 255 +}; + +enum ieee80211_elemid_ext { + IEEE80211_ELEMID_EXT_ASSOC_DELAY_INFO = 1, + IEEE80211_ELEMID_EXT_FILS_REQ_PARAMS = 2, + IEEE80211_ELEMID_EXT_FILS_KEY_CONFIRM = 3, + IEEE80211_ELEMID_EXT_FILS_SESSION = 4, + IEEE80211_ELEMID_EXT_FILS_HLP_CONTAINER = 5, + IEEE80211_ELEMID_EXT_FILS_IP_ADDR_ASSIGNMENT = 6, + IEEE80211_ELEMID_EXT_KEY_DELIVERY = 7, + IEEE80211_ELEMID_EXT_FILS_WRAPPED_DATA = 8, + IEEE80211_ELEMID_EXT_FTM_SYNC_INFO = 9, + IEEE80211_ELEMID_EXT_EXT_REQ = 10, + IEEE80211_ELEMID_EXT_EST_SERVICE_PARAM_INBOUND = 11, + IEEE80211_ELEMID_EXT_FILS_PUBLIC_KEY = 12, + IEEE80211_ELEMID_EXT_FILS_NONCE = 13, + IEEE80211_ELEMID_EXT_FUTURE_CHAN_GUIDANCE = 14, + IEEE80211_ELEMID_EXT_SERVICE_HINT = 15, + IEEE80211_ELEMID_EXT_SERVICE_HASH = 16, + IEEE80211_ELEMID_EXT_CDMG_CAPA = 17, + IEEE80211_ELEMID_EXT_DYN_BW_CTRL = 18, + IEEE80211_ELEMID_EXT_CDMG_EXT_SCHEDULE = 19, + IEEE80211_ELEMID_EXT_SSW_REPORT = 20, + IEEE80211_ELEMID_EXT_CLUSTER_PROBE = 21, + IEEE80211_ELEMID_EXT_EXT_CLUSTER_REPORT = 22, + IEEE80211_ELEMID_EXT_CLUSTER_SW_ANNOUNCEMENT = 23, + IEEE80211_ELEMID_EXT_ENHANCED_BEAM_TRACKING = 24, + IEEE80211_ELEMID_EXT_SPSH_REPORT = 25, + IEEE80211_ELEMID_EXT_CLUSTER_INTERF_ASSESS = 26, + IEEE80211_ELEMID_EXT_CMMG_CAPA = 27, + IEEE80211_ELEMID_EXT_CMMG_OPER = 28, + IEEE80211_ELEMID_EXT_CMMG_OPMODE_NOTIF = 29, + IEEE80211_ELEMID_EXT_CMMG_LINK_MARGIN = 30, + IEEE80211_ELEMID_EXT_CMMG_LINK_ADAP_ACK = 31, + /* 32 reserved. */ + IEEE80211_ELEMID_EXT_PASSWORD_ID = 33, + IEEE80211_ELEMID_EXT_GLK_GCR_PARAM_SET = 34, + IEEE80211_ELEMID_EXT_HE_CAPA = 35, + IEEE80211_ELEMID_EXT_HE_OPER = 36, + IEEE80211_ELEMID_EXT_UORA_PARAM_SET = 37, + IEEE80211_ELEMID_EXT_MU_EDCA_PARAM_SET = 38, + IEEE80211_ELEMID_EXT_SPATIAL_REUSE_PARAM_SET = 39, + IEEE80211_ELEMID_EXT_GAS_EXTENSION = 40, + IEEE80211_ELEMID_EXT_NDP_FEEDB_REPORT_PARAM = 41, + IEEE80211_ELEMID_EXT_BSS_COLOR_CHG_ANNOUNCE = 42, + IEEE80211_ELEMID_EXT_QUIET_TIMME_PERIOD = 43, + IEEE80211_ELEMID_EXT_VENDOR_SPECIFIC_REQ_ELEM = 44, + IEEE80211_ELEMID_EXT_ESS_REPORT = 45, + IEEE80211_ELEMID_EXT_OPS = 46, + IEEE80211_ELEMID_EXT_HE_BSS_LOAD = 47, + /* 48-51 reserved. */ + IEEE80211_ELEMID_EXT_MAC_CH_SW_TIME = 52, + IEEE80211_ELEMID_EXT_EST_SERVICE_PARAM_OUTBOUND = 53, + IEEE80211_ELEMID_EXT_OCI = 54, + IEEE80211_ELEMID_EXT_MULTI_BSSID_CONFIG = 55, + IEEE80211_ELEMID_EXT_NON_INHERITANCE = 56, + IEEE80211_ELEMID_EXT_KNOWN_BSSID = 57, + IEEE80211_ELEMID_EXT_SHORT_SSID_LIST = 58, + IEEE80211_ELEMID_EXT_HE_6GHZ_BAND_CAPA = 59, + IEEE80211_ELEMID_EXT_ULMU_POWER_CAAP = 60, + /* 61-87 reserved. */ + IEEE80211_ELEMID_EXT_MSCS_DESCRIPTOR = 88, + IEEE80211_ELEMID_EXT_TCLAS_MASK = 89, + IEEE80211_ELEMID_EXT_SUPPL_CLASS_2_CAPA = 90, + IEEE80211_ELEMID_EXT_OCT_SOURCE = 91, + IEEE80211_ELEMID_EXT_REJECTED_GROUPS = 92, + IEEE80211_ELEMID_EXT_ANTI_CLOGGING_TAOKEN_CONTAINER = 93, + /* 94-255 reserved. */ }; struct ieee80211_tim_ie { @@ -1266,7 +1845,7 @@ struct ieee80211_csa_ie { #define WPA_CSE_NULL 0x00 #define WPA_CSE_WEP40 0x01 #define WPA_CSE_TKIP 0x02 -#define WPA_CSE_CCMP 0x04 +#define WPA_CSE_CCMP 0x04 /* CCMP 128-bit */ #define WPA_CSE_WEP104 0x05 #define WPA_ASE_NONE 0x00 @@ -1275,21 +1854,62 @@ struct ieee80211_csa_ie { #define WPS_OUI_TYPE 0x04 +/* 802.11-2016 Table 9-131 - Cipher Suite Selectors */ #define RSN_OUI 0xac0f00 #define RSN_VERSION 1 /* current supported version */ -#define RSN_CSE_NULL 0x00 -#define RSN_CSE_WEP40 0x01 -#define RSN_CSE_TKIP 0x02 -#define RSN_CSE_WRAP 0x03 -#define RSN_CSE_CCMP 0x04 -#define RSN_CSE_WEP104 0x05 +/* RSN cipher suite element */ +#define RSN_CSE_NULL 0 +#define RSN_CSE_WEP40 1 +#define RSN_CSE_TKIP 2 +#define RSN_CSE_WRAP 3 /* Reserved in the 802.11-2016 */ +#define RSN_CSE_CCMP 4 /* CCMP 128 bit */ +#define RSN_CSE_WEP104 5 +#define RSN_CSE_BIP_CMAC_128 6 +/* 7 - "Group addressed traffic not allowed" */ +#define RSN_CSE_GCMP_128 8 +#define RSN_CSE_GCMP_256 9 +#define RSN_CSE_CCMP_256 10 +#define RSN_CSE_BIP_GMAC_128 11 +#define RSN_CSE_BIP_GMAC_256 12 +#define RSN_CSE_BIP_CMAC_256 13 -#define RSN_ASE_NONE 0x00 -#define RSN_ASE_8021X_UNSPEC 0x01 -#define RSN_ASE_8021X_PSK 0x02 +/* 802.11-2016 Table 9-133 - AKM suite selectors */ +/* RSN AKM suite element */ +#define RSN_ASE_NONE 0 +#define RSN_ASE_8021X_UNSPEC 1 +#define RSN_ASE_8021X_PSK 2 +#define RSN_ASE_FT_8021X 3 /* SHA-256 */ +#define RSN_ASE_FT_PSK 4 /* SHA-256 */ +#define RSN_ASE_8021X_UNSPEC_SHA256 5 +#define RSN_ASE_8021X_PSK_SHA256 6 +#define RSN_ASE_8021X_TDLS 7 /* SHA-256 */ +#define RSN_ASE_SAE_UNSPEC 8 /* SHA-256 */ +#define RSN_ASE_FT_SAE 9 /* SHA-256 */ +#define RSN_ASE_AP_PEERKEY 10 /* SHA-256 */ +#define RSN_ASE_8021X_SUITE_B_SHA256 11 +#define RSN_ASE_8021X_SUITE_B_SHA384 12 +#define RSN_ASE_FT_8021X_SHA384 13 -#define RSN_CAP_PREAUTH 0x01 +/* 802.11-2016 Figure 9-257 - RSN Capabilities (2 byte field) */ +#define RSN_CAP_PREAUTH 0x0001 +#define RSN_CAP_NO_PAIRWISE 0x0002 +#define RSN_CAP_PTKSA_REPLAY_COUNTER 0x000c /* 2 bit field */ +#define RSN_CAP_GTKSA_REPLAY_COUNTER 0x0030 /* 2 bit field */ +#define RSN_CAP_MFP_REQUIRED 0x0040 +#define RSN_CAP_MFP_CAPABLE 0x0080 +#define RSN_CAP_JOINT_MULTIBAND_RSNA 0x0100 +#define RSN_CAP_PEERKEY_ENABLED 0x0200 +#define RSN_CAP_SPP_AMSDU_CAPABLE 0x0400 +#define RSN_CAP_SPP_AMSDU_REQUIRED 0x0800 +#define RSN_CAP_PBAC_CAPABLE 0x1000 +#define RSN_CAP_EXT_KEYID_CAPABLE 0x0200 + +/* 802.11-2016 Table 9-134 PTKSA/GTKSA/STKSA replay counters usage */ +#define RSN_CAP_REPLAY_COUNTER_1_PER 0 +#define RSN_CAP_REPLAY_COUNTER_2_PER 1 +#define RSN_CAP_REPLAY_COUNTER_4_PER 2 +#define RSN_CAP_REPLAY_COUNTER_16_PER 3 #define WME_OUI 0xf25000 #define WME_OUI_TYPE 0x02 diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h index dc593b0dd9f0cf75142dbe34131735f08a5e810f..0039f7383c5e216a79ee31f6acca65357d1fba09 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_amrr.h @@ -49,6 +49,10 @@ struct ieee80211_amrr_node { struct ieee80211_amrr *amn_amrr;/* backpointer */ int amn_rix; /* current rate index */ int amn_ticks; /* time of last update */ + /* for VHT, since there's no VHT RIX right now */ + int amn_vht_mcs; + int amn_vht_nss; + /* statistics */ u_int amn_txcnt; u_int amn_success; diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h index a261385ac75625ab8988e354e8ac1440cd8c4b0a..8e64e8d81f0bc1e8327ebc8ab0aeb209470412e4 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_crypto.h @@ -118,8 +118,8 @@ struct ieee80211_key { IEEE80211_KEY_NOIVMGT|IEEE80211_KEY_NOMIC|IEEE80211_KEY_NOMICMGT) #define IEEE80211_KEY_BITS \ - "\20\1XMIT\2RECV\3GROUP\4SWENCRYPT\5SWDECRYPT\6SWENMIC\7SWDEMIC" \ - "\10DEVKEY\11CIPHER0\12CIPHER1" + "\20\1XMIT\2RECV\3GROUP\4NOREPLAY\5SWENCRYPT\6SWDECRYPT\7SWENMIC\10SWDEMIC" \ + "\11DEVKEY\12CIPHER0\13CIPHER1\14NOIV\15NOIVMGT\16NOMIC\17NOMICMGT" #define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1) @@ -137,8 +137,17 @@ struct ieee80211_key { #define IEEE80211_CIPHER_TKIPMIC 4 /* TKIP MIC capability */ #define IEEE80211_CIPHER_CKIP 5 #define IEEE80211_CIPHER_NONE 6 /* pseudo value */ +#define IEEE80211_CIPHER_AES_CCM_256 7 +#define IEEE80211_CIPHER_BIP_CMAC_128 8 +#define IEEE80211_CIPHER_BIP_CMAC_256 9 +#define IEEE80211_CIPHER_BIP_GMAC_128 10 +#define IEEE80211_CIPHER_BIP_GMAC_256 11 +#define IEEE80211_CIPHER_AES_GCM_128 12 +#define IEEE80211_CIPHER_AES_GCM_256 13 -#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1) +#define IEEE80211_CIPHER_LAST 13 + +#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_LAST+1) /* capability bits in ic_cryptocaps/iv_cryptocaps */ #define IEEE80211_CRYPTO_WEP (1< + * All rights reserved. + * + * Galois/Counter Mode (GCM) and GMAC with AES + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __IEEE80211_CRYPTO_GCM_H__ +#define __IEEE80211_CRYPTO_GCM_H__ + +#if defined(__KERNEL__) || defined(_KERNEL) + +#include + +#define AES_BLOCK_LEN 16 + +/* + * buffer is 2x the AES_BLOCK_LEN, but the AAD contents may be variable + * and are padded. + */ +#define GCM_AAD_LEN (AES_BLOCK_LEN * 2) + +/* GCMP is always 128 bit / 16 byte MIC */ +#define GCMP_MIC_LEN 16 + +void ieee80211_crypto_aes_gcm_ae(rijndael_ctx *aes, const uint8_t *iv, + size_t iv_len, const uint8_t *plain, size_t plain_len, + const uint8_t *aad, size_t aad_len, uint8_t *crypt, uint8_t *tag); + +int ieee80211_crypto_aes_gcm_ad(rijndael_ctx *aes, const uint8_t *iv, + size_t iv_len, const uint8_t *crypt, size_t crypt_len, + const uint8_t *aad, size_t aad_len, const uint8_t *tag, + uint8_t *plain); + +#endif /* __KERNEL__ */ + +#endif /* __IEEE80211_CRYPTO_GCM_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_freebsd.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_freebsd.h index 11453c7f6b43701ab6f1244c1494ed38567fa2c9..7b1460b5fa0e648c529726dacd76b5c9caf1dba8 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_freebsd.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_freebsd.h @@ -73,6 +73,8 @@ typedef struct { mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED) #define IEEE80211_UNLOCK_ASSERT(_ic) \ mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED) +#define IEEE80211_IS_LOCKED(_ic) \ + mtx_owned(IEEE80211_LOCK_OBJ(_ic)) /* * Transmit lock. @@ -91,12 +93,22 @@ typedef struct { } while (0) #define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx) #define IEEE80211_TX_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_TX_LOCK_OBJ(_ic)) -#define IEEE80211_TX_LOCK(_ic) mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic)) -#define IEEE80211_TX_UNLOCK(_ic) mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic)) -#define IEEE80211_TX_LOCK_ASSERT(_ic) \ - mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED) -#define IEEE80211_TX_UNLOCK_ASSERT(_ic) \ - mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED) +#define IEEE80211_TX_LOCK(_ic) do { \ + if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \ + mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic)); \ + } while (0); +#define IEEE80211_TX_UNLOCK(_ic) do { \ + if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \ + mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic)); \ + } while (0); +#define IEEE80211_TX_LOCK_ASSERT(_ic) do { \ + if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \ + mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED); \ + } while (0) +#define IEEE80211_TX_UNLOCK_ASSERT(_ic) { \ + if (!IEEE80211_CONF_SEQNO_OFFLOAD(_ic)) \ + mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED); \ + } while (0) /* * Stageq / ni_tx_superg lock @@ -260,9 +272,9 @@ void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *); void ieee80211_vap_destroy(struct ieee80211vap *); const char * ieee80211_get_vap_ifname(struct ieee80211vap *); -#define IFNET_IS_UP_RUNNING(_ifp) \ - (((_ifp)->if_flags & IFF_UP) && \ - ((_ifp)->if_drv_flags & IFF_DRV_RUNNING)) +#define IFNET_IS_UP_RUNNING(_ifp) \ + (((if_getflags(_ifp) & IFF_UP) != 0) && \ + ((if_getdrvflags(_ifp) & IFF_DRV_RUNNING) != 0)) #define msecs_to_ticks(ms) MSEC_2_TICKS(ms) #define ticks_to_msecs(t) TICKS_2_MSEC(t) @@ -329,11 +341,16 @@ struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen); #define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj) /* - * Store the sequence number. + * Store / retrieve the sequence number in an mbuf. + * + * The sequence number being stored/retreived is the 12 bit + * base sequence number, not the 16 bit sequence number field. + * I.e., it's from 0..4095 inclusive, with no 4 bit padding for + * fragment numbers. */ #define M_SEQNO_SET(m, seqno) \ - ((m)->m_pkthdr.tso_segsz = (seqno)) -#define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz) + ((m)->m_pkthdr.tso_segsz = ((seqno) % IEEE80211_SEQ_RANGE)) +#define M_SEQNO_GET(m) (((m)->m_pkthdr.tso_segsz) % IEEE80211_SEQ_RANGE) #define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */ @@ -417,8 +434,7 @@ MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1) /* * Crypto modules implement cipher support. */ -#define IEEE80211_CRYPTO_MODULE(name, version) \ -_IEEE80211_POLICY_MODULE(crypto, name, version); \ +#define IEEE80211_CRYPTO_MODULE_ADD(name) \ static void \ name##_modevent(int type) \ { \ @@ -429,6 +445,10 @@ name##_modevent(int type) \ } \ TEXT_SET(crypto##_set, name##_modevent) +#define IEEE80211_CRYPTO_MODULE(name, version) \ + _IEEE80211_POLICY_MODULE(crypto, name, version); \ + IEEE80211_CRYPTO_MODULE_ADD(name) + /* * Scanner modules provide scanning policy. */ @@ -535,6 +555,21 @@ struct debugnet80211_methods { #define DEBUGNET80211_SET(ic, driver) #endif /* DEBUGNET */ +void ieee80211_vap_sync_mac_address(struct ieee80211vap *); +void ieee80211_vap_copy_mac_address(struct ieee80211vap *); +void ieee80211_vap_deliver_data(struct ieee80211vap *, struct mbuf *); +bool ieee80211_vap_ifp_check_is_monitor(struct ieee80211vap *); +bool ieee80211_vap_ifp_check_is_simplex(struct ieee80211vap *); +bool ieee80211_vap_ifp_check_is_running(struct ieee80211vap *); +void ieee80211_vap_ifp_set_running_state(struct ieee80211vap *, bool); +const uint8_t * ieee80211_vap_get_broadcast_address(struct ieee80211vap *); + +void net80211_printf(const char *fmt, ...) __printflike(1, 2); +void net80211_vap_printf(const struct ieee80211vap *, const char *fmt, ...) + __printflike(2, 3); +void net80211_ic_printf(const struct ieee80211com *, const char *fmt, ...) + __printflike(2, 3); + #endif /* _KERNEL */ /* XXX this stuff belongs elsewhere */ diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h index 87821591010476e974a69613fcb168cdc8e25848..5f51a78906bfafa483cf9d56b29000cf60e314fb 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_ht.h @@ -87,7 +87,8 @@ struct ieee80211_tx_ampdu { (IEEE80211_AGGR_RUNNING|IEEE80211_AGGR_XCHGPEND|IEEE80211_AGGR_NAK)) != 0) #define IEEE80211_AGGR_BITS \ - "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK" + "\20\1IMMEDIATE\2XCHGPEND\3RUNNING\4SETUP\5NAK" \ + "\6BARPEND\7WAITRX\10AMSDU" /* * Traffic estimator support. We estimate packets/sec for @@ -240,5 +241,11 @@ int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid); int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni, int tid, int status); void ieee80211_htinfo_notify(struct ieee80211vap *vap); +int ieee80211_ht_get_node_ampdu_density(const struct ieee80211_node *ni); +int ieee80211_ht_get_node_ampdu_limit(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_shortgi_20(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_shortgi_40(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_ht40(const struct ieee80211_node *ni); +bool ieee80211_ht_check_tx_ht(const struct ieee80211_node *ht); #endif /* _NET80211_IEEE80211_HT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_ioctl.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_ioctl.h index 44567d5d6bb1c62dd9ae7a256559bb0ca76e2aa0..37c490e1c479073a314e89e9c071ff36d1a3406c 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_ioctl.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_ioctl.h @@ -253,6 +253,14 @@ struct ieee80211_stats { uint32_t is_ff_encapfail; /* failed FF encap */ uint32_t is_amsdu_encapfail; /* failed A-MSDU encap */ + uint32_t is_crypto_gcmp; /* gcmp crypto done in s/w */ + uint32_t is_rx_gcmpreplay; /* rx seq# violation (GCMP) */ + uint32_t is_rx_gcmpformat; /* rx format bad (GCMP) */ + uint32_t is_rx_gcmpmic; /* rx MIC check failed (GCMP) */ + uint32_t is_crypto_gcmp_nomem; /* gcmp crypto failed; no mem */ + uint32_t is_crypto_gcmp_nospc; /* gcmp crypto failed; no mbuf space */ + uint32_t is_crypto_swcipherfail; /* no support for SW cipher */ + uint32_t is_spare[5]; }; @@ -551,13 +559,13 @@ struct ieee80211_regdomain_req { IEEE80211_REGDOMAIN_SIZE((_req)->chaninfo.ic_nchans) /* - * Get driver capabilities. Driver, hardware crypto, and + * Get driver capabilities. Driver, hardware/software crypto, and * HT/802.11n capabilities, and a table that describes what * the radio can do. */ struct ieee80211_devcaps_req { uint32_t dc_drivercaps; /* general driver caps */ - uint32_t dc_cryptocaps; /* hardware crypto support */ + uint32_t dc_cryptocaps; /* software + hardware crypto support */ uint32_t dc_htcaps; /* HT/802.11n support */ uint32_t dc_vhtcaps; /* VHT/802.11ac capabilities */ struct ieee80211req_chaninfo dc_chaninfo; diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_node.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_node.h index 1a7f4db634e7e119dc9d625a1d9a090a08e376e0..927fb329f22fb4e1e97cb82fc89e9f687b8d66ad 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_node.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_node.h @@ -108,6 +108,69 @@ enum ieee80211_mesh_mlstate { #define IEEE80211_MESH_MLSTATE_BITS \ "\20\1IDLE\2OPENSNT\2OPENRCV\3CONFIRMRCV\4ESTABLISHED\5HOLDING" +/* + * This enum was shared with the LinuxKPI enum ieee80211_sta_rx_bandwidth + * describing up-to which channel width the station can receive. + * Rather than using hardcoded MHz values for the channel width use an enum with + * flags. This allows us to keep the uint8_t slot for ni_chw in + * struct ieee80211_node it means we do not have to sync to the value for + * LinuxKPI (just the names). + * + * NB: BW_20 needs to 0 and values need to be sorted! Cannot make it + * bitfield-alike for use with %b. + */ +enum net80211_sta_rx_bw { + NET80211_STA_RX_BW_20 = 0x00, + NET80211_STA_RX_BW_40, + NET80211_STA_RX_BW_80, + NET80211_STA_RX_BW_160, + NET80211_STA_RX_BW_320, +} __packed; + +static inline const char * +net80211_ni_chw_to_str(enum net80211_sta_rx_bw bw) +{ + switch (bw) { + case NET80211_STA_RX_BW_20: return ("BW_20"); + case NET80211_STA_RX_BW_40: return ("BW_40"); + case NET80211_STA_RX_BW_80: return ("BW_80"); + case NET80211_STA_RX_BW_160: return ("BW_160"); + case NET80211_STA_RX_BW_320: return ("BW_320"); + } +} + +enum ieee80211_node_txrate_type { + IEEE80211_NODE_TXRATE_UNDEFINED = 0, + IEEE80211_NODE_TXRATE_LEGACY = 1, /* CCK/OFDM, HT for now */ + IEEE80211_NODE_TXRATE_HT = 2, /* HT */ + IEEE80211_NODE_TXRATE_VHT = 3, /* VHT */ +}; + +struct ieee80211_node_txrate { + enum ieee80211_node_txrate_type type; + uint8_t nss; /* VHT - number of spatial streams */ + uint8_t mcs; /* HT/VHT - MCS */ + uint8_t dot11rate; /* Legacy/HT - dot11rate / ratecode */ +}; + +#define IEEE80211_NODE_TXRATE_INIT_LEGACY(rate) \ + (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_LEGACY, \ + .nss = 0, \ + .mcs = 0, \ + .dot11rate = (rate) } + +#define IEEE80211_NODE_TXRATE_INIT_HT(i_mcs) \ + (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_HT, \ + .nss = 0, \ + .mcs = (i_mcs), \ + .dot11rate = (i_mcs) | IEEE80211_RATE_MCS } + +#define IEEE80211_NODE_TXRATE_INIT_VHT(i_nss, i_mcs) \ + (struct ieee80211_node_txrate) { .type = IEEE80211_NODE_TXRATE_VHT, \ + .nss = (i_nss), \ + .mcs = (i_mcs), \ + .dot11rate = 0 } + /* * Node specific information. Note that drivers are expected * to derive from this structure to add device-specific per-node @@ -222,15 +285,15 @@ struct ieee80211_node { uint8_t ni_ht2ndchan; /* HT 2nd channel */ uint8_t ni_htopmode; /* HT operating mode */ uint8_t ni_htstbc; /* HT */ - uint8_t ni_chw; /* negotiated channel width */ + enum net80211_sta_rx_bw ni_chw; /* negotiated channel width */ struct ieee80211_htrateset ni_htrates; /* negotiated ht rate set */ struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID]; struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID]; /* VHT state */ uint32_t ni_vhtcap; - uint16_t ni_vht_basicmcs; - uint16_t ni_vht_pad2; + uint16_t ni_vht_basicmcs; /* Basic VHT MCS bitmap from IE */ + uint16_t ni_vht_tx_map; /* Negotiated MCS TX map with peer */ struct ieee80211_vht_mcs_info ni_vht_mcsinfo; uint8_t ni_vht_chan1; /* 20/40/80/160 - VHT chan1 */ uint8_t ni_vht_chan2; /* 80+80 - VHT chan2 */ @@ -244,7 +307,7 @@ struct ieee80211_node { /* others */ short ni_inact; /* inactivity mark count */ short ni_inact_reload;/* inactivity reload value */ - int ni_txrate; /* legacy rate/MCS */ + struct ieee80211_node_txrate ni_txrate; /* current transmit rate */ struct ieee80211_psq ni_psq; /* power save queue */ struct ieee80211_nodestats ni_stats; /* per-node statistics */ @@ -279,7 +342,7 @@ MALLOC_DECLARE(M_80211_NODE_IE); #define IEEE80211_NODE_BITS \ "\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \ "\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40" \ - "\22ASSOCID" + "\22ASSOCID\23AMSDU_RX\24AMSDU_TX\25VHT\26LDPC\27UAPSD" #define IEEE80211_NODE_AID(ni) IEEE80211_AID(ni->ni_associd) @@ -467,4 +530,27 @@ void ieee80211_node_join(struct ieee80211_node *,int); void ieee80211_node_leave(struct ieee80211_node *); int8_t ieee80211_getrssi(struct ieee80211vap *); void ieee80211_getsignal(struct ieee80211vap *, int8_t *, int8_t *); + +/* TX sequence space related routines */ +ieee80211_seq ieee80211_tx_seqno_fetch_incr(struct ieee80211_node *, + uint8_t); +ieee80211_seq ieee80211_tx_seqno_fetch(const struct ieee80211_node *, + uint8_t); + +/* + * Node transmit rate specific manipulation. + * + * This should eventually be refactored into its own type. + */ +uint8_t ieee80211_node_get_txrate_dot11rate(struct ieee80211_node *); +void ieee80211_node_get_txrate(struct ieee80211_node *, + struct ieee80211_node_txrate *); +void ieee80211_node_set_txrate(struct ieee80211_node *, + const struct ieee80211_node_txrate *); +void ieee80211_node_set_txrate_dot11rate(struct ieee80211_node *, uint8_t); +void ieee80211_node_set_txrate_ht_mcsrate(struct ieee80211_node *, uint8_t); +uint32_t ieee80211_node_get_txrate_kbit(struct ieee80211_node *); +void ieee80211_node_set_txrate_vht_rate(struct ieee80211_node *ni, + uint8_t nss, uint8_t mcs); + #endif /* _NET80211_IEEE80211_NODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_phy.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_phy.h index 44103caed983b13955653d8895ed0e029751c165..27521544ef146953e93e933178be894ef5cec549 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_phy.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_phy.h @@ -221,5 +221,14 @@ uint32_t ieee80211_compute_duration_ht(uint32_t frameLen, uint16_t rate, int streams, int isht40, int isShortGI); +enum net80211_sta_rx_bw; + +uint16_t ieee80211_phy_vht_get_mcs_mask(enum net80211_sta_rx_bw, + uint8_t); +bool ieee80211_phy_vht_validate_mcs(enum net80211_sta_rx_bw, + uint8_t, uint8_t); +uint32_t ieee80211_phy_vht_get_mcs_kbit(enum net80211_sta_rx_bw, + uint8_t, uint8_t, bool); + #endif /* _KERNEL */ #endif /* !_NET80211_IEEE80211_PHY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_proto.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_proto.h index e88cdbfc67341953c962a268474eb569ab479a86..c7a79c945be270a5cbd865ac3d8477746a3563a9 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_proto.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_proto.h @@ -123,6 +123,10 @@ struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *, const struct ether_header *); void ieee80211_tx_complete(struct ieee80211_node *, struct mbuf *, int); +void ieee80211_output_seqno_assign(struct ieee80211_node *, + int, struct mbuf *); +void ieee80211_output_beacon_seqno_assign(struct ieee80211_node *, + struct mbuf *); /* * The formation of ProbeResponse frames requires guidance to diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_ratectl.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_ratectl.h index bd24f42cc37da71bbcf8d6f381f81b3de9863cee..2880e73e44d9769c4680c191875743e494e4c98d 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_ratectl.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_ratectl.h @@ -127,12 +127,12 @@ ieee80211_ratectl_node_deinit(struct ieee80211_node *ni) vap->iv_rate->ir_node_deinit(ni); } -static int __inline +static void __inline ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg) { const struct ieee80211vap *vap = ni->ni_vap; - return vap->iv_rate->ir_rate(ni, arg, iarg); + vap->iv_rate->ir_rate(ni, arg, iarg); } static __inline void diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_var.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_var.h index 4aa9db39ab48929de971d33c7603d8cdfc832ca4..6041f28c9772056b1ceafef25313641e990e3a86 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_var.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_var.h @@ -100,6 +100,8 @@ ((ic)->ic_flags_ext & IEEE80211_FEXT_SEQNO_OFFLOAD) #define IEEE80211_CONF_FRAG_OFFLOAD(ic) \ ((ic)->ic_flags_ext & IEEE80211_FEXT_FRAG_OFFLOAD) +#define IEEE80211_CONF_AMPDU_OFFLOAD(ic) \ + ((ic)->ic_flags_ext & IEEE80211_FEXT_AMPDU_OFFLOAD) /* * 802.11 control state is split into a common portion that maps @@ -163,8 +165,12 @@ struct ieee80211com { uint32_t ic_caps; /* capabilities */ uint32_t ic_htcaps; /* HT capabilities */ uint32_t ic_htextcaps; /* HT extended capabilities */ - uint32_t ic_cryptocaps; /* crypto capabilities */ + /* driver-supported software crypto caps */ + uint32_t ic_sw_cryptocaps; + uint32_t ic_cryptocaps; /* hardware crypto caps */ /* set of mode capabilities */ + /* driver/net80211 sw KEYMGMT capabilities */ + uint32_t ic_sw_keymgmtcaps; uint8_t ic_modecaps[IEEE80211_MODE_BYTES]; uint8_t ic_promisc; /* vap's needing promisc mode */ uint8_t ic_allmulti; /* vap's needing all multicast*/ @@ -693,13 +699,14 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_FEXT_VHT 0x00400000 /* CONF: VHT support */ #define IEEE80211_FEXT_QUIET_IE 0x00800000 /* STATUS: quiet IE in a beacon has been added */ #define IEEE80211_FEXT_UAPSD 0x01000000 /* CONF: enable U-APSD */ +#define IEEE80211_FEXT_AMPDU_OFFLOAD 0x02000000 /* CONF: driver/fw handles AMPDU[-TX] itself */ #define IEEE80211_FEXT_BITS \ "\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \ "\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \ "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD\25SEQNO_OFFLOAD" \ "\26FRAG_OFFLOAD\27VHT" \ - "\30QUIET_IE\31UAPSD" + "\30QUIET_IE\31UAPSD\32AMPDU_OFFLOAD" /* ic_flags_ht/iv_flags_ht */ #define IEEE80211_FHT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */ @@ -728,17 +735,29 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_FVEN_BITS "\20" +/* + * These flags are compared in ieee80211_setupcurchan(). + * Thus 160 should be > 80P80. + */ #define IEEE80211_FVHT_VHT 0x000000001 /* CONF: VHT supported */ #define IEEE80211_FVHT_USEVHT40 0x000000002 /* CONF: Use VHT40 */ #define IEEE80211_FVHT_USEVHT80 0x000000004 /* CONF: Use VHT80 */ -#define IEEE80211_FVHT_USEVHT160 0x000000008 /* CONF: Use VHT160 */ -#define IEEE80211_FVHT_USEVHT80P80 0x000000010 /* CONF: Use VHT 80+80 */ -#define IEEE80211_FVHT_MASK \ +#define IEEE80211_FVHT_USEVHT80P80 0x000000008 /* CONF: Use VHT 80+80 */ +#define IEEE80211_FVHT_USEVHT160 0x000000010 /* CONF: Use VHT160 */ +#define IEEE80211_FVHT_STBC_TX 0x00000020 /* CONF: STBC tx enabled */ +#define IEEE80211_FVHT_STBC_RX 0x00000040 /* CONF: STBC rx enabled */ + +#define IEEE80211_FVHT_CHANWIDTH_MASK \ (IEEE80211_FVHT_VHT | IEEE80211_FVHT_USEVHT40 | \ IEEE80211_FVHT_USEVHT80 | IEEE80211_FVHT_USEVHT160 | \ IEEE80211_FVHT_USEVHT80P80) + +#define IEEE80211_FVHT_MASK \ + (IEEE80211_FVHT_CHANWIDTH_MASK | \ + IEEE80211_FVHT_STBC_TX | IEEE80211_FVHT_STBC_RX) + #define IEEE80211_VFHT_BITS \ - "\20\1VHT\2VHT40\3VHT80\4VHT160\5VHT80P80" + "\20\1VHT\2VHT40\3VHT80\4VHT80P80\5VHT160\6STBC_TX\7STBC_RX" #define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */ #define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */ @@ -746,9 +765,17 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_COM_REF_S 1 #define IEEE80211_COM_REF_MAX (IEEE80211_COM_REF >> IEEE80211_COM_REF_S) -int ic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3); +/* TODO: Transition macro */ +#define ic_printf net80211_ic_printf + void ieee80211_ifattach(struct ieee80211com *); void ieee80211_ifdetach(struct ieee80211com *); +void ieee80211_set_software_ciphers(struct ieee80211com *, + uint32_t cipher_suite); +void ieee80211_set_hardware_ciphers(struct ieee80211com *, + uint32_t cipher_suite); +void ieee80211_set_driver_keymgmt_suites(struct ieee80211com *ic, + uint32_t keymgmt_set); int ieee80211_vap_setup(struct ieee80211com *, struct ieee80211vap *, const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode, int flags, @@ -772,7 +799,8 @@ void ieee80211_iterate_coms(ieee80211_com_iter_func *, void *); int ieee80211_media_change(struct ifnet *); void ieee80211_media_status(struct ifnet *, struct ifmediareq *); int ieee80211_ioctl(struct ifnet *, u_long, caddr_t); -int ieee80211_rate2media(struct ieee80211com *, int, +int ieee80211_rate2media(struct ieee80211com *, + const struct ieee80211_node_txrate *, enum ieee80211_phymode); int ieee80211_media2rate(int); int ieee80211_mhz2ieee(u_int, u_int); @@ -814,6 +842,14 @@ char ieee80211_channel_type_char(const struct ieee80211_channel *c); #define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan) #define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan) +bool ieee80211_is_key_global(const struct ieee80211vap *vap, + const struct ieee80211_key *key); +bool ieee80211_is_key_unicast(const struct ieee80211vap *vap, + const struct ieee80211_key *key); + +bool ieee80211_is_ctl_frame_for_vap(struct ieee80211_node *, + const struct mbuf *); + void ieee80211_radiotap_attach(struct ieee80211com *, struct ieee80211_radiotap_header *th, int tlen, uint32_t tx_radiotap, @@ -976,7 +1012,7 @@ ieee80211_get_node_txpower(struct ieee80211_node *ni) * Debugging facilities compiled in when IEEE80211_DEBUG is defined. * * The intent is that any problem in the net80211 layer can be - * diagnosed by inspecting the statistics (dumped by the wlanstats + * diagnosed by inspecting the statistics (dumped by the wlanstat * program) and/or the msgs generated by net80211. Messages are * broken into functional classes and can be controlled with the * wlandebug program. Certain of these msg groups are for facilities diff --git a/lib/libc/include/generic-freebsd/net80211/ieee80211_vht.h b/lib/libc/include/generic-freebsd/net80211/ieee80211_vht.h index 20a3b6d8fe5444d3e12f51464d3d943ca8d3cb96..621c39ebc695211c28aadb42e78e37fe4e77e2cd 100644 --- a/lib/libc/include/generic-freebsd/net80211/ieee80211_vht.h +++ b/lib/libc/include/generic-freebsd/net80211/ieee80211_vht.h @@ -40,8 +40,7 @@ void ieee80211_parse_vhtcap(struct ieee80211_node *, const uint8_t *); int ieee80211_vht_updateparams(struct ieee80211_node *, const uint8_t *, const uint8_t *); -void ieee80211_setup_vht_rates(struct ieee80211_node *, - const uint8_t *, const uint8_t *); +void ieee80211_setup_vht_rates(struct ieee80211_node *); void ieee80211_vht_timeout(struct ieee80211vap *vap); @@ -53,8 +52,7 @@ uint8_t * ieee80211_add_vhtinfo(uint8_t *frm, struct ieee80211_node *); uint8_t *ieee80211_add_vhtcap_ch(uint8_t *, struct ieee80211vap *, struct ieee80211_channel *); -void ieee80211_vht_update_cap(struct ieee80211_node *, - const uint8_t *, const uint8_t *); +void ieee80211_vht_update_cap(struct ieee80211_node *, const uint8_t *); struct ieee80211_channel * ieee80211_vht_adjust_channel(struct ieee80211com *, @@ -65,4 +63,10 @@ void ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, void ieee80211_vht_get_vhtinfo_ie(struct ieee80211_node *ni, struct ieee80211_vht_operation *, int); +bool ieee80211_vht_check_tx_vht(const struct ieee80211_node *); +bool ieee80211_vht_check_tx_bw(const struct ieee80211_node *, + enum net80211_sta_rx_bw); +bool ieee80211_vht_node_check_tx_valid_mcs(const struct ieee80211_node *, + enum net80211_sta_rx_bw bw, uint8_t, uint8_t); + #endif /* _NET80211_IEEE80211_VHT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netdb.h b/lib/libc/include/generic-freebsd/netdb.h index 3a3c6033a652a55633c76d090fe32f25c1d28d4c..8b2eda8b0ac9a208bf753f18d809126bb69bb7c6 100644 --- a/lib/libc/include/generic-freebsd/netdb.h +++ b/lib/libc/include/generic-freebsd/netdb.h @@ -51,7 +51,6 @@ */ /* - * @(#)netdb.h 8.1 (Berkeley) 6/2/93 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ */ diff --git a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_hci_raw.h b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_hci_raw.h index cc9b546ee6611e64e78ad18cbdb5061205da2ed5..81af1bdc97e072b9d6723e0cd3e8f292bf8e7b1f 100644 --- a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_hci_raw.h +++ b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_hci_raw.h @@ -78,11 +78,10 @@ int ng_btsocket_hci_raw_control (struct socket *, u_long, void *, int ng_btsocket_hci_raw_ctloutput (struct socket *, struct sockopt *); void ng_btsocket_hci_raw_detach (struct socket *); int ng_btsocket_hci_raw_disconnect (struct socket *); -int ng_btsocket_hci_raw_peeraddr (struct socket *, struct sockaddr **); int ng_btsocket_hci_raw_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); -int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr **); +int ng_btsocket_hci_raw_sockaddr (struct socket *, struct sockaddr *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_l2cap.h b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_l2cap.h index e0d8e63450839155b3bf870756e761f9f380fdc0..6e7975a6675a34688c558d201e069cae59384b33 100644 --- a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_l2cap.h +++ b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_l2cap.h @@ -105,11 +105,11 @@ int ng_btsocket_l2cap_raw_control (struct socket *, u_long, void *, struct ifnet *, struct thread *); void ng_btsocket_l2cap_raw_detach (struct socket *); int ng_btsocket_l2cap_raw_disconnect (struct socket *); -int ng_btsocket_l2cap_raw_peeraddr (struct socket *, struct sockaddr **); +int ng_btsocket_l2cap_raw_peeraddr (struct socket *, struct sockaddr *); int ng_btsocket_l2cap_raw_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); -int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr **); +int ng_btsocket_l2cap_raw_sockaddr (struct socket *, struct sockaddr *); #endif /* _KERNEL */ @@ -191,7 +191,6 @@ typedef struct ng_btsocket_l2cap_pcb * ng_btsocket_l2cap_pcb_p; void ng_btsocket_l2cap_abort (struct socket *); void ng_btsocket_l2cap_close (struct socket *); -int ng_btsocket_l2cap_accept (struct socket *, struct sockaddr **); int ng_btsocket_l2cap_attach (struct socket *, int, struct thread *); int ng_btsocket_l2cap_bind (struct socket *, struct sockaddr *, struct thread *); @@ -203,11 +202,11 @@ int ng_btsocket_l2cap_ctloutput (struct socket *, struct sockopt *); void ng_btsocket_l2cap_detach (struct socket *); int ng_btsocket_l2cap_disconnect (struct socket *); int ng_btsocket_l2cap_listen (struct socket *, int, struct thread *); -int ng_btsocket_l2cap_peeraddr (struct socket *, struct sockaddr **); +int ng_btsocket_l2cap_peeraddr (struct socket *, struct sockaddr *); int ng_btsocket_l2cap_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); -int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr **); +int ng_btsocket_l2cap_sockaddr (struct socket *, struct sockaddr *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_rfcomm.h b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_rfcomm.h index 399f13390f01220b04f4ede7d44e5db23113a0ee..1535e08497991af1fd25c5a5823328087f7a110d 100644 --- a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_rfcomm.h +++ b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_rfcomm.h @@ -316,7 +316,7 @@ typedef struct ng_btsocket_rfcomm_pcb * ng_btsocket_rfcomm_pcb_p; void ng_btsocket_rfcomm_abort (struct socket *); void ng_btsocket_rfcomm_close (struct socket *); -int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr **); +int ng_btsocket_rfcomm_accept (struct socket *, struct sockaddr *); int ng_btsocket_rfcomm_attach (struct socket *, int, struct thread *); int ng_btsocket_rfcomm_bind (struct socket *, struct sockaddr *, struct thread *); @@ -328,11 +328,11 @@ int ng_btsocket_rfcomm_ctloutput (struct socket *, struct sockopt *); void ng_btsocket_rfcomm_detach (struct socket *); int ng_btsocket_rfcomm_disconnect (struct socket *); int ng_btsocket_rfcomm_listen (struct socket *, int, struct thread *); -int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr **); +int ng_btsocket_rfcomm_peeraddr (struct socket *, struct sockaddr *); int ng_btsocket_rfcomm_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); -int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr **); +int ng_btsocket_rfcomm_sockaddr (struct socket *, struct sockaddr *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_sco.h b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_sco.h index 14d364c07502c066310ccd0385898daa68a2173a..39d1644e1e4d119a376f02d5119fc33e07e52b31 100644 --- a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_sco.h +++ b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_btsocket_sco.h @@ -106,7 +106,7 @@ typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p; void ng_btsocket_sco_abort (struct socket *); void ng_btsocket_sco_close (struct socket *); -int ng_btsocket_sco_accept (struct socket *, struct sockaddr **); +int ng_btsocket_sco_accept (struct socket *, struct sockaddr *); int ng_btsocket_sco_attach (struct socket *, int, struct thread *); int ng_btsocket_sco_bind (struct socket *, struct sockaddr *, struct thread *); @@ -118,11 +118,11 @@ int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *); void ng_btsocket_sco_detach (struct socket *); int ng_btsocket_sco_disconnect (struct socket *); int ng_btsocket_sco_listen (struct socket *, int, struct thread *); -int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr **); +int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr *); int ng_btsocket_sco_send (struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); -int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **); +int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h index 79ce0160340f0d1ad37b9a01c24be580ecbb1245..8947ce1c0d194db08c62b3be9e72839743347ad1 100644 --- a/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h +++ b/lib/libc/include/generic-freebsd/netgraph/bluetooth/include/ng_hci.h @@ -114,6 +114,8 @@ #define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10 #define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20 #define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40 +/* ------------------- byte 6 --------------------*/ +#define NG_HCI_LMP_SECURE_SIMPLE_PAIRING 0x08 /* Link types */ #define NG_HCI_LINK_SCO 0x00 /* Voice */ @@ -446,7 +448,7 @@ typedef struct { typedef bdaddr_t * bdaddr_p; /* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */ -#define NG_HCI_BDADDR_ANY ((bdaddr_p) "\000\000\000\000\000\000") +#define NG_HCI_BDADDR_ANY (&(const bdaddr_t){"\000\000\000\000\000\000"}) /* HCI status return parameter */ typedef struct { @@ -860,6 +862,50 @@ typedef struct { } __attribute__ ((packed)) ng_hci_read_clock_offset_cp; /* No return parameter(s) */ +#define NG_HCI_IO_CAPABILITY_REQUEST_REPLY 0x002b +typedef struct { + bdaddr_t bdaddr; + u_int8_t io_capability; + u_int8_t oob_data_present; + u_int8_t authentication_requirements; +} __attribute__ ((packed)) ng_hci_io_capability_request_reply_cp; + +typedef struct { + u_int8_t status; + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_io_capability_request_reply_rp; + +#define NG_HCI_USER_CONFIRMATION_REQUEST_REPLY 0x002c +typedef struct { + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_cp; + +typedef struct { + u_int8_t status; + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_rp; + +#define NG_HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY 0x002d +typedef struct { + bdaddr_t bdaddr; +} __attribute__((packed)) ng_hci_user_confirmation_request_negative_reply_cp; + +typedef struct { + u_int8_t status; + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_user_confirmation_request_negative_reply_rp; + +#define NG_HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY 0x0034 +typedef struct { + bdaddr_t bdaddr; + u_int8_t reason; +} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_cp; + +typedef struct { + u_int8_t status; + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_rp; + /************************************************************************** ************************************************************************** ** Link policy commands and return parameters @@ -1374,6 +1420,13 @@ typedef struct { typedef ng_hci_status_rp ng_hci_write_page_scan_rp; +#define NG_HCI_OCF_WRITE_SIMPLE_PAIRING 0x0056 +typedef struct { + u_int8_t simple_pairing; /* 1 -> enabled, 0 -> disabled */ +} __attribute__ ((packed)) ng_hci_write_simple_pairing_cp; + +typedef ng_hci_status_rp ng_hci_write_simple_pairing_rp; + #define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c typedef struct { u_int8_t status; /* 0x00 - success */ @@ -1389,6 +1442,13 @@ typedef struct { typedef ng_hci_status_rp ng_hci_write_le_host_supported_rp; +#define NG_HCI_OCF_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT 0x007a +typedef struct { + u_int8_t support; /* 0 - disabled, 1 - enabled */ +} __attribute__ ((packed)) ng_hci_write_secure_connections_host_support_cp; + +typedef ng_hci_status_rp ng_hci_write_secure_connections_host_support_rp; + /************************************************************************** ************************************************************************** ** Informational commands and return parameters @@ -2025,6 +2085,24 @@ typedef struct { bdaddr_t bdaddr; /* destination address */ u_int8_t page_scan_rep_mode; /* page scan repetition mode */ } __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep; + +#define NG_HCI_EVENT_IO_CAPABILITY_REQUEST 0x31 +typedef struct { + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_io_capability_request_ep; + +#define NG_HCI_EVENT_USER_CONFIRMATION_REQUEST 0x33 +typedef struct { + bdaddr_t bdaddr; + u_int32_t numeric_value; +} __attribute__ ((packed)) ng_hci_user_confirmation_request_ep; + +#define NG_HCI_EVENT_SIMPLE_PAIRING_COMPLETE 0x36 +typedef struct { + u_int8_t status; + bdaddr_t bdaddr; +} __attribute__ ((packed)) ng_hci_simple_pairing_complete_ep; + #define NG_HCI_EVENT_LE 0x3e typedef struct { u_int8_t subevent_code; diff --git a/lib/libc/include/generic-freebsd/netgraph/netflow/ng_netflow.h b/lib/libc/include/generic-freebsd/netgraph/netflow/ng_netflow.h index f7d914a015b9324d8cf4e923c9f13bca18176e7b..8ceee77652382df5b75ed329cc742f1495da1ee9 100644 --- a/lib/libc/include/generic-freebsd/netgraph/netflow/ng_netflow.h +++ b/lib/libc/include/generic-freebsd/netgraph/netflow/ng_netflow.h @@ -259,7 +259,7 @@ struct flow_entry_data { u_long bytes; long first; /* uptime on first packet */ long last; /* uptime on last packet */ - u_char tcp_flags; /* cumulative OR */ + uint16_t tcp_flags; /* cumulative OR */ }; struct flow6_entry_data { @@ -277,7 +277,7 @@ struct flow6_entry_data { u_long bytes; long first; /* uptime on first packet */ long last; /* uptime on last packet */ - u_char tcp_flags; /* cumulative OR */ + uint16_t tcp_flags; /* cumulative OR */ }; /* diff --git a/lib/libc/include/generic-freebsd/netgraph/netgraph.h b/lib/libc/include/generic-freebsd/netgraph/netgraph.h index 406419032f4ab17e6b7dcce0898f17c79c4c8aaf..2561b72f624daa42d2b4e1c1187bf70cae47e808 100644 --- a/lib/libc/include/generic-freebsd/netgraph/netgraph.h +++ b/lib/libc/include/generic-freebsd/netgraph/netgraph.h @@ -69,11 +69,20 @@ * modules. */ #define _NG_ABI_VERSION 12 -#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/ -#define NG_ABI_VERSION (_NG_ABI_VERSION + 0x10000) -#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ -#define NG_ABI_VERSION _NG_ABI_VERSION -#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ + +#ifdef NETGRAPH_DEBUG +#define _NG_ABI_PREFIX1 0x10000 +#else +#define _NG_ABI_PREFIX1 0 +#endif + +#ifdef INVARIANTS +#define _NG_ABI_PREFIX2 0x20000 +#else +#define _NG_ABI_PREFIX2 0 +#endif + +#define NG_ABI_VERSION (_NG_ABI_PREFIX1 + _NG_ABI_PREFIX2 + _NG_ABI_VERSION) /* * Forward references for the basic structures so we can diff --git a/lib/libc/include/generic-freebsd/netgraph/ng_message.h b/lib/libc/include/generic-freebsd/netgraph/ng_message.h index 74b19ce59a668594986ae767feb2b8511876dd0d..8781253ed0a1517769ab53a75328ed48357e3787 100644 --- a/lib/libc/include/generic-freebsd/netgraph/ng_message.h +++ b/lib/libc/include/generic-freebsd/netgraph/ng_message.h @@ -42,7 +42,10 @@ #ifndef _NETGRAPH_NG_MESSAGE_H_ #define _NETGRAPH_NG_MESSAGE_H_ -/* ASCII string size limits */ +/* + * ASCII string size limits + * Check with struct sockaddr_ng if changing. + */ #define NG_TYPESIZ 32 /* max type name len (including null) */ #define NG_HOOKSIZ 32 /* max hook name len (including null) */ #define NG_NODESIZ 32 /* max node name len (including null) */ diff --git a/lib/libc/include/generic-freebsd/netgraph/ng_nat.h b/lib/libc/include/generic-freebsd/netgraph/ng_nat.h index fbdbcf646df414657e4731f1a6896dac8fdabc95..47823930b09eaa4dde43b52cd5a7ea38e645dd9d 100644 --- a/lib/libc/include/generic-freebsd/netgraph/ng_nat.h +++ b/lib/libc/include/generic-freebsd/netgraph/ng_nat.h @@ -53,6 +53,7 @@ struct ng_nat_mode { #define NG_NAT_PROXY_ONLY 0x40 #define NG_NAT_REVERSE 0x80 #define NG_NAT_UNREGISTERED_CGN 0x100 +#define NG_NAT_UDP_EIM 0x200 #define NG_NAT_DESC_LENGTH 64 #define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) /* LibAlias' LINK_ADDR, also unused in in.h */ diff --git a/lib/libc/include/generic-freebsd/netgraph/ng_socket.h b/lib/libc/include/generic-freebsd/netgraph/ng_socket.h index 5244d03e7f8693d2da145ce342cfcef8816363c1..2dc386bd8ea368497c56b965ff6a3fdefb2786d8 100644 --- a/lib/libc/include/generic-freebsd/netgraph/ng_socket.h +++ b/lib/libc/include/generic-freebsd/netgraph/ng_socket.h @@ -60,7 +60,7 @@ enum { struct sockaddr_ng { unsigned char sg_len; /* total length */ sa_family_t sg_family; /* address family */ - char sg_data[14]; /* actually longer; address value */ + char sg_data[32]; /* see NG_NODESIZ in ng_message.h */ }; #endif /* _NETGRAPH_NG_SOCKET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/cc/cc.h b/lib/libc/include/generic-freebsd/netinet/cc/cc.h index 48472f8fd3322b6a429eed0839d16368e8113a67..e04dfcfc17de44a6443534a7445495f1f68fbe00 100644 --- a/lib/libc/include/generic-freebsd/netinet/cc/cc.h +++ b/lib/libc/include/generic-freebsd/netinet/cc/cc.h @@ -87,21 +87,12 @@ int cc_deregister_algo(struct cc_algo *remove_cc); #endif /* _KERNEL */ #if defined(_KERNEL) || defined(_WANT_TCPCB) -/* - * Wrapper around transport structs that contain same-named congestion - * control variables. Allows algos to be shared amongst multiple CC aware - * transprots. - */ struct cc_var { void *cc_data; /* Per-connection private CC algorithm data. */ int bytes_this_ack; /* # bytes acked by the current ACK. */ tcp_seq curack; /* Most recent ACK. */ uint32_t flags; /* Flags for cc_var (see below) */ - int type; /* Indicates which ptr is valid in ccvc. */ - union ccv_container { - struct tcpcb *tcp; - struct sctp_nets *sctp; - } ccvc; + struct tcpcb *tp; /* Pointer to tcpcb */ uint16_t nsegs; /* # segments coalesced into current chain. */ uint8_t labc; /* Dont use system abc use passed in */ }; @@ -113,32 +104,34 @@ struct cc_var { #define CCF_ACKNOW 0x0008 /* Will this ack be sent now? */ #define CCF_IPHDR_CE 0x0010 /* Does this packet set CE bit? */ #define CCF_TCPHDR_CWR 0x0020 /* Does this packet set CWR bit? */ -#define CCF_MAX_CWND 0x0040 /* Have we reached maximum cwnd? */ -#define CCF_CHG_MAX_CWND 0x0080 /* CUBIC max_cwnd changed, for K */ -#define CCF_USR_IWND 0x0100 /* User specified initial window */ -#define CCF_USR_IWND_INIT_NSEG 0x0200 /* Convert segs to bytes on conn init */ +#define CCF_UNUSED1 0x0040 +#define CCF_UNUSED2 0x0080 +#define CCF_UNUSED3 0x0100 +#define CCF_UNUSED4 0x0200 #define CCF_HYSTART_ALLOWED 0x0400 /* If the CC supports it Hystart is allowed */ #define CCF_HYSTART_CAN_SH_CWND 0x0800 /* Can hystart when going CSS -> CA slam the cwnd */ #define CCF_HYSTART_CONS_SSTH 0x1000 /* Should hystart use the more conservative ssthresh */ -/* ACK types passed to the ack_received() hook. */ -#define CC_ACK 0x0001 /* Regular in sequence ACK. */ -#define CC_DUPACK 0x0002 /* Duplicate ACK. */ -#define CC_PARTIALACK 0x0004 /* Not yet. */ -#define CC_SACK 0x0008 /* Not yet. */ #endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */ - -/* - * Congestion signal types passed to the cong_signal() hook. The highest order 8 - * bits (0x01000000 - 0x80000000) are reserved for CC algos to declare their own - * congestion signal types. - */ -#define CC_ECN 0x00000001 /* ECN marked packet received. */ -#define CC_RTO 0x00000002 /* RTO fired. */ -#define CC_RTO_ERR 0x00000004 /* RTO fired in error. */ -#define CC_NDUPACK 0x00000008 /* Threshold of dupack's reached. */ - -#define CC_SIGPRIVMASK 0xFF000000 /* Mask to check if sig is private. */ +typedef enum { +#if defined(_KERNEL) || defined(_WANT_TCPCB) + /* ACK types passed to the ack_received() hook. */ + CC_ACK = 0x0001, /* Regular in sequence ACK. */ + CC_DUPACK = 0x0002, /* Duplicate ACK. */ + CC_PARTIALACK = 0x0004, /* Not yet. */ + CC_SACK = 0x0008, /* Not yet. */ +#endif /* defined(_KERNEL) || defined(_WANT_TCPCB) */ + /* Congestion signal types passed to the cong_signal() hook. */ + CC_ECN = 0x0100, /* ECN marked packet received. */ + CC_RTO = 0x0200, /* RTO fired. */ + CC_RTO_ERR = 0x0400, /* RTO fired in error. */ + CC_NDUPACK = 0x0800, /* Threshold of dupack's reached. */ + /* + * The highest order 8 bits (0x01000000 - 0x80000000) are reserved + * for CC algos to declare their own congestion signal types. + */ + CC_SIGPRIVMASK = 0xFF000000 /* Mask to check if sig is private. */ +} ccsignal_t; #ifdef _KERNEL /* @@ -175,10 +168,10 @@ struct cc_algo { void (*conn_init)(struct cc_var *ccv); /* Called on receipt of an ack. */ - void (*ack_received)(struct cc_var *ccv, uint16_t type); + void (*ack_received)(struct cc_var *ccv, ccsignal_t type); /* Called on detection of a congestion signal. */ - void (*cong_signal)(struct cc_var *ccv, uint32_t type); + void (*cong_signal)(struct cc_var *ccv, ccsignal_t type); /* Called after exiting congestion recovery. */ void (*post_recovery)(struct cc_var *ccv); @@ -236,8 +229,11 @@ extern struct rwlock cc_list_lock; */ void newreno_cc_post_recovery(struct cc_var *); void newreno_cc_after_idle(struct cc_var *); -void newreno_cc_cong_signal(struct cc_var *, uint32_t ); -void newreno_cc_ack_received(struct cc_var *, uint16_t); +void newreno_cc_cong_signal(struct cc_var *, ccsignal_t); +void newreno_cc_ack_received(struct cc_var *, ccsignal_t); +u_int newreno_cc_cwnd_on_multiplicative_decrease(struct cc_var *ccv, uint32_t mss); +u_int newreno_cc_cwnd_in_cong_avoid(struct cc_var *ccv); +u_int newreno_cc_cwnd_in_slow_start(struct cc_var *ccv); /* Called to temporarily keep an algo from going away during change */ void cc_refer(struct cc_algo *algo); diff --git a/lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h b/lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h index c9547b29f2ae925a106e605fad54060872a0a01d..ae93df284bfa02251ee8a8be619665f52a7b8eaf 100644 --- a/lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h +++ b/lib/libc/include/generic-freebsd/netinet/cc/cc_cubic.h @@ -83,26 +83,28 @@ #define CUBICFLAG_RTO_EVENT 0x00000008 /* RTO experienced */ #define CUBICFLAG_HYSTART_ENABLED 0x00000010 /* Hystart++ is enabled */ #define CUBICFLAG_HYSTART_IN_CSS 0x00000020 /* We are in Hystart++ CSS */ +#define CUBICFLAG_IN_TF 0x00000040 /* We are in TCP friendly region */ /* Kernel only bits */ #ifdef _KERNEL struct cubic { - /* CUBIC K in fixed point form with CUBIC_SHIFT worth of precision. */ + /* + * CUBIC K in fixed point form with CUBIC_SHIFT worth of precision. + * Also means the time period in seconds it takes to increase the + * congestion window size at the beginning of the current congestion + * avoidance stage to W_max. + */ int64_t K; /* Sum of RTT samples across an epoch in usecs. */ int64_t sum_rtt_usecs; - /* Size of cwnd just before cwnd was reduced in the last congestion event */ - uint64_t W_max; - /* An estimate for the congestion window in the Reno-friendly region */ - uint64_t W_est; - /* The cwnd at the beginning of the current congestion avoidance stage */ - uint64_t cwnd_epoch; - /* - * Size of cwnd at the time of setting ssthresh most recently, - * either upon exiting the first slow start, or just before cwnd - * was reduced in the last congestion event - */ - uint64_t cwnd_prior; + /* Size of cwnd (in bytes) just before cwnd was reduced in the last congestion event. */ + uint32_t W_max; + /* An estimate (in bytes) for the congestion window in the Reno-friendly region */ + uint32_t W_est; + /* An estimate (in bytes) for the congestion window in the CUBIC region */ + uint32_t W_cubic; + /* The cwnd (in bytes) at the beginning of the current congestion avoidance stage. */ + uint32_t cwnd_epoch; /* various flags */ uint32_t flags; /* Minimum observed rtt in usecs. */ @@ -117,12 +119,8 @@ struct cubic { int undo_t_epoch; /* Few variables to restore the state after RTO_ERR */ int64_t undo_K; - uint64_t undo_cwnd_prior; - uint64_t undo_W_max; - uint64_t undo_W_est; - uint64_t undo_cwnd_epoch; - /* Number of congestion events experienced */ - uint64_t num_cong_events; + uint32_t undo_W_max; + uint32_t undo_cwnd_epoch; uint32_t css_baseline_minrtt; uint32_t css_current_round_minrtt; uint32_t css_lastround_minrtt; @@ -141,60 +139,103 @@ struct cubic { extern int hz; /* - * Implementation based on the formulae found in the CUBIC Internet Draft - * "draft-ietf-tcpm-cubic-04". + * Implementation based on the formulas in RFC9438. * */ -static __inline float -theoretical_cubic_k(double wmax_pkts) + +/* + * Returns K, the time period in seconds it takes to increase the congestion + * window size at the beginning of the current congestion avoidance stage to + * W_max. + */ +static inline float +theoretical_cubic_k(uint32_t wmax_segs, uint32_t cwnd_epoch_segs) { double C; C = 0.4; + if (wmax_segs <= cwnd_epoch_segs) + return 0.0; - return (pow((wmax_pkts * 0.3) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT)); + /* + * Figure 2: K = ((W_max - cwnd_epoch) / C)^(1/3) + */ + return (pow((wmax_segs - cwnd_epoch_segs) / C, (1.0 / 3.0)) * pow(2, CUBIC_SHIFT)); } -static __inline unsigned long -theoretical_cubic_cwnd(int ticks_since_epoch, unsigned long wmax, uint32_t smss) +/* + * Returns the congestion window in segments at time t in seconds based on the + * cubic increase function, where t is the elapsed time in seconds from the + * beginning of the current congestion avoidance stage, as described in RFC9438 + * Section 4.2. + */ +static inline unsigned long +theoretical_cubic_cwnd(int ticks_elapsed, uint32_t wmax_segs, uint32_t cwnd_epoch_segs) { - double C, wmax_pkts; + double C, t; + float K; C = 0.4; - wmax_pkts = wmax / (double)smss; + t = ticks_elapsed / (double)hz; + K = theoretical_cubic_k(wmax_segs, cwnd_epoch_segs); - return (smss * (wmax_pkts + - (C * pow(ticks_since_epoch / (double)hz - - theoretical_cubic_k(wmax_pkts) / pow(2, CUBIC_SHIFT), 3.0)))); + /* + * Figure 1: W_cubic(t) = C * (t - K)^3 + W_max + */ + return (C * pow(t - K / pow(2, CUBIC_SHIFT), 3.0) + wmax_segs); } -static __inline unsigned long -theoretical_reno_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax, - uint32_t smss) +/* + * Returns estimated Reno congestion window in segments. + */ +static inline unsigned long +theoretical_reno_cwnd(int ticks_elapsed, int rtt_ticks, uint32_t wmax_segs) { - return ((wmax * 0.5) + ((ticks_since_epoch / (float)rtt_ticks) * smss)); + return (wmax_segs * 0.5 + ticks_elapsed / (float)rtt_ticks); } -static __inline unsigned long -theoretical_tf_cwnd(int ticks_since_epoch, int rtt_ticks, unsigned long wmax, - uint32_t smss) +/* + * Returns an estimate for the congestion window in segments in the + * Reno-friendly region -- that is, an estimate for the congestion window of + * Reno, as described in RFC9438 Section 4.3, where: + * cwnd: Current congestion window in segments. + * cwnd_prior: Size of cwnd in segments at the time of setting ssthresh most + * recently, either upon exiting the first slow start or just before + * cwnd was reduced in the last congestion event. + * W_est: An estimate for the congestion window in segments in the Reno-friendly + * region -- that is, an estimate for the congestion window of Reno. + */ +static inline unsigned long +theoretical_tf_cwnd(unsigned long W_est, unsigned long segs_acked, unsigned long cwnd, + unsigned long cwnd_prior) { + float cubic_alpha, cubic_beta; - return ((wmax * 0.7) + ((3 * 0.3) / (2 - 0.3) * - (ticks_since_epoch / (float)rtt_ticks) * smss)); + /* RFC9438 Section 4.6: The parameter β_cubic SHOULD be set to 0.7. */ + cubic_beta = 0.7; + + if (W_est >= cwnd_prior) + cubic_alpha = 1.0; + else + cubic_alpha = (3.0 * (1.0 - cubic_beta)) / (1.0 + cubic_beta); + + /* + * Figure 4: W_est = W_est + α_cubic * segments_acked / cwnd + */ + return (W_est + cubic_alpha * segs_acked / cwnd); } #endif /* !_KERNEL */ /* * Compute the CUBIC K value used in the cwnd calculation, using an - * implementation of eqn 2 in the I-D. The method used - * here is adapted from Apple Computer Technical Report #KT-32. + * implementation mentioned in Figure. 2 of RFC9438. + * The method used here is adapted from Apple Computer Technical Report #KT-32. */ -static __inline int64_t -cubic_k(unsigned long wmax_pkts) +static inline int64_t +cubic_k(uint32_t wmax_segs, uint32_t cwnd_epoch_segs) { int64_t s, K; uint16_t p; @@ -202,8 +243,13 @@ cubic_k(unsigned long wmax_pkts) K = s = 0; p = 0; - /* (wmax * beta)/C with CUBIC_SHIFT worth of precision. */ - s = ((wmax_pkts * ONE_SUB_CUBIC_BETA) << CUBIC_SHIFT) / CUBIC_C_FACTOR; + /* Handle the corner case where W_max <= cwnd_epoch */ + if (wmax_segs <= cwnd_epoch_segs) { + return 0; + } + + /* (wmax - cwnd_epoch) / C with CUBIC_SHIFT worth of precision. */ + s = ((wmax_segs - cwnd_epoch_segs) << (2 * CUBIC_SHIFT)) / CUBIC_C_FACTOR; /* Rebase s to be between 1 and 1/8 with a shift of CUBIC_SHIFT. */ while (s >= 256) { @@ -224,13 +270,14 @@ cubic_k(unsigned long wmax_pkts) } /* - * Compute the new cwnd value using an implementation of eqn 1 from the I-D. + * Compute and return the new cwnd value in bytes using an implementation + * mentioned in Figure. 1 of RFC9438. * Thanks to Kip Macy for help debugging this function. * * XXXLAS: Characterise bounds for overflow. */ -static __inline unsigned long -cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K) +static inline uint32_t +cubic_cwnd(int usecs_since_epoch, uint32_t wmax, uint32_t smss, int64_t K) { int64_t cwnd; @@ -249,7 +296,7 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K) cwnd *= (cwnd * cwnd); /* - * C(t - K)^3 + wmax + * Figure 1: C * (t - K)^3 + wmax * The down shift by CUBIC_SHIFT_4 is because cwnd has 4 lots of * CUBIC_SHIFT included in the value. 3 from the cubing of cwnd above, * and an extra from multiplying through by CUBIC_C_FACTOR. @@ -264,46 +311,13 @@ cubic_cwnd(int usecs_since_epoch, unsigned long wmax, uint32_t smss, int64_t K) } /* - * Compute an approximation of the NewReno cwnd some number of usecs after a - * congestion event. RTT should be the average RTT estimate for the path - * measured over the previous congestion epoch and wmax is the value of cwnd at - * the last congestion event. The "TCP friendly" concept in the CUBIC I-D is - * rather tricky to understand and it turns out this function is not required. - * It is left here for reference. - * - * XXX: Not used + * Compute the "TCP friendly" cwnd by newreno in congestion avoidance state. */ -static __inline unsigned long -reno_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax, - uint32_t smss) +static inline uint32_t +tf_cwnd(struct cc_var *ccv) { - - /* - * For NewReno, beta = 0.5, therefore: W_tcp(t) = wmax*0.5 + t/RTT - * W_tcp(t) deals with cwnd/wmax in pkts, so because our cwnd is in - * bytes, we have to multiply by smss. - */ - return (((wmax * RENO_BETA) + (((usecs_since_epoch * smss) - << CUBIC_SHIFT) / rtt_usecs)) >> CUBIC_SHIFT); -} - -/* - * Compute an approximation of the "TCP friendly" cwnd some number of usecs - * after a congestion event that is designed to yield the same average cwnd as - * NewReno while using CUBIC's beta of 0.7. RTT should be the average RTT - * estimate for the path measured over the previous congestion epoch and wmax is - * the value of cwnd at the last congestion event. - */ -static __inline unsigned long -tf_cwnd(int usecs_since_epoch, int rtt_usecs, unsigned long wmax, - uint32_t smss) -{ - - /* Equation 4 of I-D. */ - return (((wmax * CUBIC_BETA) + - (((THREE_X_PT3 * (unsigned long)usecs_since_epoch * - (unsigned long)smss) << CUBIC_SHIFT) / (TWO_SUB_PT3 * rtt_usecs))) - >> CUBIC_SHIFT); + /* newreno is "TCP friendly" */ + return newreno_cc_cwnd_in_cong_avoid(ccv); } #endif /* _NETINET_CC_CUBIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/cc/cc_module.h b/lib/libc/include/generic-freebsd/netinet/cc/cc_module.h index 32e2c0b21a98c8fdef4801900f54c860b42f3ad8..2859864554920d8b2771e9805d9bbd08aff65c6a 100644 --- a/lib/libc/include/generic-freebsd/netinet/cc/cc_module.h +++ b/lib/libc/include/generic-freebsd/netinet/cc/cc_module.h @@ -43,18 +43,7 @@ #ifndef _NETINET_CC_MODULE_H_ #define _NETINET_CC_MODULE_H_ -/* - * Allows a CC algorithm to manipulate a commonly named CC variable regardless - * of the transport protocol and associated C struct. - * XXXLAS: Out of action until the work to support SCTP is done. - * -#define CCV(ccv, what) \ -(*( \ - (ccv)->type == IPPROTO_TCP ? &(ccv)->ccvc.tcp->what : \ - &(ccv)->ccvc.sctp->what \ -)) - */ -#define CCV(ccv, what) (ccv)->ccvc.tcp->what +#define CCV(ccv, what) (ccv)->tp->what #define DECLARE_CC_MODULE(ccname, ccalgo) \ static moduledata_t cc_##ccname = { \ diff --git a/lib/libc/include/generic-freebsd/netinet/dccp.h b/lib/libc/include/generic-freebsd/netinet/dccp.h index 6a9f037126934028e5fb0f6a6141d85531aac0bf..02f8aa00c76b45ab149724b21f460be07233f027 100644 --- a/lib/libc/include/generic-freebsd/netinet/dccp.h +++ b/lib/libc/include/generic-freebsd/netinet/dccp.h @@ -64,7 +64,7 @@ struct dccphdr { uint8_t seq[6]; } longseq; } d_seqno; -}; +} __packed; #define d_seqno_short d_seqno.shortseq; #define d_seqno_long d_seqno.longseq.seq; diff --git a/lib/libc/include/generic-freebsd/netinet/icmp6.h b/lib/libc/include/generic-freebsd/netinet/icmp6.h index d8d4bfd165dd5bdd33f2ef2f36fcde4fbf7d1625..5a840ba85448836778f04c1ed3d55fd18171ee93 100644 --- a/lib/libc/include/generic-freebsd/netinet/icmp6.h +++ b/lib/libc/include/generic-freebsd/netinet/icmp6.h @@ -58,13 +58,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_ICMP6_H_ #define _NETINET_ICMP6_H_ +#include + #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) - sizeof(struct icmp6_hdr) */ @@ -309,7 +309,8 @@ struct nd_opt_hdr { /* Neighbor discovery option header */ #define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */ #define ND_OPT_RDNSS 25 /* RFC 6106 */ #define ND_OPT_DNSSL 31 /* RFC 6106 */ -#define ND_OPT_MAX 31 +#define ND_OPT_PREF64 38 /* RFC 8781 */ +#define ND_OPT_MAX 38 struct nd_opt_prefix_info { /* prefix information */ u_int8_t nd_opt_pi_type; @@ -375,6 +376,14 @@ struct nd_opt_dnssl { /* DNSSL option (RFC 6106) */ /* followed by list of DNS search domains */ } __packed; +struct nd_opt_pref64 { /* PREF64 option (RFC 8781) */ + uint8_t nd_opt_pref64_type; + uint8_t nd_opt_pref64_len; + /* bits 0-12 are the SL, bits 13-15 are the PLC */ + uint16_t nd_opt_pref64_sl_plc; + char nd_opt_prefix[12]; +} __packed; + /* * icmp6 namelookup */ @@ -574,22 +583,6 @@ do { \ * Variables related to this implementation * of the internet control message protocol version 6. */ -struct icmp6errstat { - uint64_t icp6errs_dst_unreach_noroute; - uint64_t icp6errs_dst_unreach_admin; - uint64_t icp6errs_dst_unreach_beyondscope; - uint64_t icp6errs_dst_unreach_addr; - uint64_t icp6errs_dst_unreach_noport; - uint64_t icp6errs_packet_too_big; - uint64_t icp6errs_time_exceed_transit; - uint64_t icp6errs_time_exceed_reassembly; - uint64_t icp6errs_paramprob_header; - uint64_t icp6errs_paramprob_nextheader; - uint64_t icp6errs_paramprob_option; - uint64_t icp6errs_redirect; /* we regard redirect as an error here */ - uint64_t icp6errs_unknown; -}; - struct icmp6stat { /* statistics related to icmp6 packets generated */ uint64_t icp6s_error; /* # of calls to icmp6_error */ @@ -609,25 +602,19 @@ struct icmp6stat { uint64_t icp6s_reflect; uint64_t icp6s_inhist[256]; uint64_t icp6s_nd_toomanyopt; /* too many ND options */ - struct icmp6errstat icp6s_outerrhist; -#define icp6s_odst_unreach_noroute \ - icp6s_outerrhist.icp6errs_dst_unreach_noroute -#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin -#define icp6s_odst_unreach_beyondscope \ - icp6s_outerrhist.icp6errs_dst_unreach_beyondscope -#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr -#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport -#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big -#define icp6s_otime_exceed_transit \ - icp6s_outerrhist.icp6errs_time_exceed_transit -#define icp6s_otime_exceed_reassembly \ - icp6s_outerrhist.icp6errs_time_exceed_reassembly -#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header -#define icp6s_oparamprob_nextheader \ - icp6s_outerrhist.icp6errs_paramprob_nextheader -#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option -#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect -#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown + uint64_t icp6s_odst_unreach_noroute; + uint64_t icp6s_odst_unreach_admin; + uint64_t icp6s_odst_unreach_beyondscope; + uint64_t icp6s_odst_unreach_addr; + uint64_t icp6s_odst_unreach_noport; + uint64_t icp6s_opacket_too_big; + uint64_t icp6s_otime_exceed_transit; + uint64_t icp6s_otime_exceed_reassembly; + uint64_t icp6s_oparamprob_header; + uint64_t icp6s_oparamprob_nextheader; + uint64_t icp6s_oparamprob_option; + uint64_t icp6s_oredirect; + uint64_t icp6s_ounknown; uint64_t icp6s_pmtuchg; /* path MTU changes */ uint64_t icp6s_nd_badopt; /* bad ND options */ uint64_t icp6s_badns; /* bad neighbor solicitation */ @@ -645,6 +632,7 @@ struct icmp6stat { #ifdef _KERNEL #include +#include #ifdef SYSCTL_DECL SYSCTL_DECL(_net_inet6_icmp6); @@ -655,16 +643,28 @@ VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat); * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define ICMP6STAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val)) -#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) +#define ICMP6STAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(icmp6, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val)); \ + } while (0) +#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) +#define ICMP6STAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(icmp6, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name[type], 1); \ + } while (0) /* * Kernel module consumers must use this accessor macro. */ void kmod_icmp6stat_inc(int statnum); -#define KMOD_ICMP6STAT_INC(name) \ - kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t)) +#define KMOD_ICMP6STAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(icmp6, count, name, 1); \ + kmod_icmp6stat_inc( \ + offsetof(struct icmp6stat, name) / sizeof(uint64_t)); \ + } while (0) #endif /* @@ -713,9 +713,6 @@ void icmp6_redirect_input(struct mbuf *, int); void icmp6_redirect_output(struct mbuf *, struct nhop_object *); int icmp6_ratelimit(const struct in6_addr *, const int, const int); -struct ip6ctlparam; -void icmp6_mtudisc_update(struct ip6ctlparam *, int); - /* XXX: is this the right place for these macros? */ #define icmp6_ifstat_inc(ifp, tag) \ do { \ diff --git a/lib/libc/include/generic-freebsd/netinet/icmp_var.h b/lib/libc/include/generic-freebsd/netinet/icmp_var.h index f2283c4a389115d9f703e5bb6623ddf444bf8ff5..a2a03590328b17f096b127ed96a9d14bbe9adbb7 100644 --- a/lib/libc/include/generic-freebsd/netinet/icmp_var.h +++ b/lib/libc/include/generic-freebsd/netinet/icmp_var.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_ICMP_VAR_H_ @@ -59,22 +57,36 @@ struct icmpstat { #ifdef _KERNEL #include +#include VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define ICMPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)) +#define ICMPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(icmp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)); \ + } while (0) + #define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1) +#define ICMPSTAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(icmp, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name[type], 1); \ + } while (0) /* * Kernel module consumers must use this accessor macro. */ void kmod_icmpstat_inc(int statnum); -#define KMOD_ICMPSTAT_INC(name) \ - kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t)) +#define KMOD_ICMPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(icmp, count, name, 1); \ + kmod_icmpstat_inc( \ + offsetof(struct icmpstat, name) / sizeof(uint64_t)); \ + } while (0) #endif /* @@ -88,15 +100,13 @@ void kmod_icmpstat_inc(int statnum); SYSCTL_DECL(_net_inet_icmp); extern int badport_bandlim(int); -#define BANDLIM_UNLIMITED -1 #define BANDLIM_ICMP_UNREACH 0 #define BANDLIM_ICMP_ECHO 1 #define BANDLIM_ICMP_TSTAMP 2 -#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */ -#define BANDLIM_RST_OPENPORT 4 /* No connection, listener */ -#define BANDLIM_ICMP6_UNREACH 5 -#define BANDLIM_SCTP_OOTB 6 -#define BANDLIM_MAX 7 +#define BANDLIM_TCP_RST 3 +#define BANDLIM_ICMP6_UNREACH 4 +#define BANDLIM_SCTP_OOTB 5 +#define BANDLIM_MAX 6 #endif #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/if_ether.h b/lib/libc/include/generic-freebsd/netinet/if_ether.h index e0ba1a8809c733594759578b0955439ccb68ec2c..0740e972ef61a40e951448972f458fe3097fa8dc 100644 --- a/lib/libc/include/generic-freebsd/netinet/if_ether.h +++ b/lib/libc/include/generic-freebsd/netinet/if_ether.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 */ #ifndef _NETINET_IF_ETHER_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/igmp.h b/lib/libc/include/generic-freebsd/netinet/igmp.h index fc686fbb1ad77356c4e1693643d60efccc672838..71eadad239402bd00241dac05089417513833724 100644 --- a/lib/libc/include/generic-freebsd/netinet/igmp.h +++ b/lib/libc/include/generic-freebsd/netinet/igmp.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)igmp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IGMP_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/igmp_var.h b/lib/libc/include/generic-freebsd/netinet/igmp_var.h index a55c0eba5ab9043b26a5d4907522adf08f505c4b..3f75dad32f6bae240c038a9fb49051aa6d0f72b8 100644 --- a/lib/libc/include/generic-freebsd/netinet/igmp_var.h +++ b/lib/libc/include/generic-freebsd/netinet/igmp_var.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)igmp_var.h 8.1 (Berkeley) 7/19/93 */ #ifndef _NETINET_IGMP_VAR_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/in.h b/lib/libc/include/generic-freebsd/netinet/in.h index eb0b586624ac87f37174785f28d731c00aec3dd9..ed7ecda8304142b0cb4546a3ccfda9cc7b8c7718 100644 --- a/lib/libc/include/generic-freebsd/netinet/in.h +++ b/lib/libc/include/generic-freebsd/netinet/in.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in.h 8.3 (Berkeley) 1/3/94 */ #ifndef _NETINET_IN_H_ @@ -674,13 +672,13 @@ int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, struct ifnet; struct mbuf; /* forward declarations for Standard C */ struct in_ifaddr; -int in_broadcast(struct in_addr, struct ifnet *); -int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *); -int in_canforward(struct in_addr); -int in_localaddr(struct in_addr); +bool in_ifnet_broadcast(struct in_addr, struct ifnet *); +bool in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *); +bool in_canforward(struct in_addr); +bool in_localaddr(struct in_addr); bool in_localip(struct in_addr); bool in_localip_fib(struct in_addr, uint16_t); -int in_ifhasaddr(struct ifnet *, struct in_addr); +bool in_ifhasaddr(struct ifnet *, struct in_addr); struct in_ifaddr *in_findlocal(uint32_t, bool); int inet_aton(const char *, struct in_addr *); /* in libkern */ char *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */ @@ -688,6 +686,13 @@ char *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */ int inet_pton(int af, const char *, void *); /* in libkern */ void in_ifdetach(struct ifnet *); +static inline bool +in_broadcast(struct in_addr in) +{ + return (in.s_addr == __htonl(INADDR_BROADCAST) || + in.s_addr == __htonl(INADDR_ANY)); +} + #define in_hosteq(s, t) ((s).s_addr == (t).s_addr) #define in_nullhost(x) ((x).s_addr == INADDR_ANY) #define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP)) diff --git a/lib/libc/include/generic-freebsd/netinet/in_kdtrace.h b/lib/libc/include/generic-freebsd/netinet/in_kdtrace.h index 768feb147c96a0793d1d1ac5af8f50f917cd5b4f..b37b3dda484957dd5e698cea979a7517a5881a44 100644 --- a/lib/libc/include/generic-freebsd/netinet/in_kdtrace.h +++ b/lib/libc/include/generic-freebsd/netinet/in_kdtrace.h @@ -28,6 +28,8 @@ #ifndef _SYS_IN_KDTRACE_H_ #define _SYS_IN_KDTRACE_H_ +#include + #define IP_PROBE(probe, arg0, arg1, arg2, arg3, arg4, arg5) \ SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5) #define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \ @@ -52,6 +54,371 @@ SDT_PROVIDER_DECLARE(tcp); SDT_PROVIDER_DECLARE(udp); SDT_PROVIDER_DECLARE(udplite); +#ifdef KDTRACE_MIB_SDT +SDT_PROVIDER_DECLARE(mib); + +SDT_PROBE_DECLARE(mib, ip, count, ips_total); +SDT_PROBE_DECLARE(mib, ip, count, ips_badsum); +SDT_PROBE_DECLARE(mib, ip, count, ips_tooshort); +SDT_PROBE_DECLARE(mib, ip, count, ips_toosmall); +SDT_PROBE_DECLARE(mib, ip, count, ips_badhlen); +SDT_PROBE_DECLARE(mib, ip, count, ips_badlen); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragments); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragdropped); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragtimeout); +SDT_PROBE_DECLARE(mib, ip, count, ips_forward); +SDT_PROBE_DECLARE(mib, ip, count, ips_fastforward); +SDT_PROBE_DECLARE(mib, ip, count, ips_cantforward); +SDT_PROBE_DECLARE(mib, ip, count, ips_redirectsent); +SDT_PROBE_DECLARE(mib, ip, count, ips_noproto); +SDT_PROBE_DECLARE(mib, ip, count, ips_delivered); +SDT_PROBE_DECLARE(mib, ip, count, ips_localout); +SDT_PROBE_DECLARE(mib, ip, count, ips_odropped); +SDT_PROBE_DECLARE(mib, ip, count, ips_reassembled); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragmented); +SDT_PROBE_DECLARE(mib, ip, count, ips_ofragments); +SDT_PROBE_DECLARE(mib, ip, count, ips_cantfrag); +SDT_PROBE_DECLARE(mib, ip, count, ips_badoptions); +SDT_PROBE_DECLARE(mib, ip, count, ips_noroute); +SDT_PROBE_DECLARE(mib, ip, count, ips_badvers); +SDT_PROBE_DECLARE(mib, ip, count, ips_rawout); +SDT_PROBE_DECLARE(mib, ip, count, ips_toolong); +SDT_PROBE_DECLARE(mib, ip, count, ips_notmember); +SDT_PROBE_DECLARE(mib, ip, count, ips_nogif); +SDT_PROBE_DECLARE(mib, ip, count, ips_badaddr); + +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_total); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_tooshort); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toosmall); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragments); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragdropped); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragtimeout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragoverflow); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_forward); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantforward); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_redirectsent); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_delivered); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_localout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_odropped); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_reassembled); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_atomicfrags); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragmented); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_ofragments); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantfrag); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badoptions); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_noroute); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badvers); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_rawout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badscope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_notmember); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nxthist); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m1); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m2m); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext1); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext2m); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_exthdrtoolong); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nogif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toomanyhdr); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_none); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_sameif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_samescope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherscope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_deprecated); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_rule); + +SDT_PROBE_DECLARE(mib, icmp, count, icps_error); +SDT_PROBE_DECLARE(mib, icmp, count, icps_oldshort); +SDT_PROBE_DECLARE(mib, icmp, count, icps_oldicmp); +SDT_PROBE_DECLARE(mib, icmp, count, icps_outhist); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badcode); +SDT_PROBE_DECLARE(mib, icmp, count, icps_tooshort); +SDT_PROBE_DECLARE(mib, icmp, count, icps_checksum); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badlen); +SDT_PROBE_DECLARE(mib, icmp, count, icps_reflect); +SDT_PROBE_DECLARE(mib, icmp, count, icps_inhist); +SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcastecho); +SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcasttstamp); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badaddr); +SDT_PROBE_DECLARE(mib, icmp, count, icps_noroute); + +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_error); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_canterror); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_toofreq); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_outhist); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badcode); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_tooshort); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_checksum); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badlen); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_dropped); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_reflect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_inhist); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_toomanyopt); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noroute); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_admin); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_beyondscope); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_addr); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noport); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_opacket_too_big); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_transit); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_reassembly); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_header); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_nextheader); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_option); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_ounknown); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_pmtuchg); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_badopt); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badns); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badna); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badrs); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badra); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowdefrtr); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowprfx); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflownndp); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_invlhlim); + +SDT_PROBE_DECLARE(mib, udp, count, udps_ipackets); +SDT_PROBE_DECLARE(mib, udp, count, udps_hdrops); +SDT_PROBE_DECLARE(mib, udp, count, udps_badsum); +SDT_PROBE_DECLARE(mib, udp, count, udps_nosum); +SDT_PROBE_DECLARE(mib, udp, count, udps_badlen); +SDT_PROBE_DECLARE(mib, udp, count, udps_noport); +SDT_PROBE_DECLARE(mib, udp, count, udps_noportbcast); +SDT_PROBE_DECLARE(mib, udp, count, udps_fullsock); +SDT_PROBE_DECLARE(mib, udp, count, udps_pcbcachemiss); +SDT_PROBE_DECLARE(mib, udp, count, udps_pcbhashmiss); +SDT_PROBE_DECLARE(mib, udp, count, udps_opackets); +SDT_PROBE_DECLARE(mib, udp, count, udps_fastout); +SDT_PROBE_DECLARE(mib, udp, count, udps_noportmcast); +SDT_PROBE_DECLARE(mib, udp, count, udps_filtermcast); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_connattempt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_accepts); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_connects); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_drops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_conndrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_minmssdrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_closed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_segstimed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rttupdated); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_delack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_timeoutdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rexmttimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_persisttimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keeptimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepdrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_progdrops); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndtotal); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbad); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndacks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndurg); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndwinup); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndctrl); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvtotal); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadsum); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadoff); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvreassfull); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvshort); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvduppack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartduppack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartdupbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoopack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoobyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpackafterwin); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyteafterwin); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvafterclose); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvacktoomuch); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinupd); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pawsdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_predack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_preddat); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pcbcachemiss); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrtt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrttvar); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedssthresh); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrtt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrttvar); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedssthresh); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_persistdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_badsyn); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_mturesent); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_listendrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_badrst); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_added); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_retransmitted); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dupsyn); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dropped); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_completed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_bucketoverflow); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_cacheoverflow); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_reset); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_stale); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_aborted); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_badack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_unreach); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_zonefail); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_sendcookie); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_recvcookie); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_spurcookie); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_failcookie); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_added); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_bucketoverflow); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_finwait2_drops); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_recovery_episode); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmits); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmits_tso); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmit_bytes); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rcv_blocks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_send_blocks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_lostrexmt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_sboverflow); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvce); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect1); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_shs); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcwnd); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvgoodsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvbadsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_buildsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_sigopt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_nosigopt); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated_min_mss); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_failed); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_pkts); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_errs); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_count); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_bytes); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_tlp_bytes); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_recycles); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_resets); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_responds); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_nect); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect1); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ce); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect1); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresends); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresend_bytes); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvghostack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvacktooold); + +SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_polvio); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_nomem); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_in_inval); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_polvio); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_nosa); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_nomem); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_noroute); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_inval); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_out_bundlesa); + +SDT_PROBE_DECLARE(mib, ipsec, count, ips_spdcache_hits); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_spdcache_misses); + +SDT_PROBE_DECLARE(mib, ipsec, count, ips_clcopied); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_mbinserted); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_front); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_middle); +SDT_PROBE_DECLARE(mib, ipsec, count, ips_input_end); + +SDT_PROBE_DECLARE(mib, esp, count, esps_hdrops); +SDT_PROBE_DECLARE(mib, esp, count, esps_nopf); +SDT_PROBE_DECLARE(mib, esp, count, esps_notdb); +SDT_PROBE_DECLARE(mib, esp, count, esps_badkcr); +SDT_PROBE_DECLARE(mib, esp, count, esps_qfull); +SDT_PROBE_DECLARE(mib, esp, count, esps_noxform); +SDT_PROBE_DECLARE(mib, esp, count, esps_badilen); +SDT_PROBE_DECLARE(mib, esp, count, esps_wrap); +SDT_PROBE_DECLARE(mib, esp, count, esps_badenc); +SDT_PROBE_DECLARE(mib, esp, count, esps_badauth); +SDT_PROBE_DECLARE(mib, esp, count, esps_replay); +SDT_PROBE_DECLARE(mib, esp, count, esps_input); +SDT_PROBE_DECLARE(mib, esp, count, esps_output); +SDT_PROBE_DECLARE(mib, esp, count, esps_invalid); +SDT_PROBE_DECLARE(mib, esp, count, esps_ibytes); +SDT_PROBE_DECLARE(mib, esp, count, esps_obytes); +SDT_PROBE_DECLARE(mib, esp, count, esps_toobig); +SDT_PROBE_DECLARE(mib, esp, count, esps_pdrops); +SDT_PROBE_DECLARE(mib, esp, count, esps_crypto); +SDT_PROBE_DECLARE(mib, esp, count, esps_tunnel); +SDT_PROBE_DECLARE(mib, esp, count, esps_hist); + +SDT_PROBE_DECLARE(mib, ah, count, ahs_hdrops); +SDT_PROBE_DECLARE(mib, ah, count, ahs_nopf); +SDT_PROBE_DECLARE(mib, ah, count, ahs_notdb); +SDT_PROBE_DECLARE(mib, ah, count, ahs_badkcr); +SDT_PROBE_DECLARE(mib, ah, count, ahs_badauth); +SDT_PROBE_DECLARE(mib, ah, count, ahs_noxform); +SDT_PROBE_DECLARE(mib, ah, count, ahs_qfull); +SDT_PROBE_DECLARE(mib, ah, count, ahs_wrap); +SDT_PROBE_DECLARE(mib, ah, count, ahs_replay); +SDT_PROBE_DECLARE(mib, ah, count, ahs_badauthl); +SDT_PROBE_DECLARE(mib, ah, count, ahs_input); +SDT_PROBE_DECLARE(mib, ah, count, ahs_output); +SDT_PROBE_DECLARE(mib, ah, count, ahs_invalid); +SDT_PROBE_DECLARE(mib, ah, count, ahs_ibytes); +SDT_PROBE_DECLARE(mib, ah, count, ahs_obytes); +SDT_PROBE_DECLARE(mib, ah, count, ahs_toobig); +SDT_PROBE_DECLARE(mib, ah, count, ahs_pdrops); +SDT_PROBE_DECLARE(mib, ah, count, ahs_crypto); +SDT_PROBE_DECLARE(mib, ah, count, ahs_tunnel); +SDT_PROBE_DECLARE(mib, ah, count, ahs_hist); + +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_hdrops); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_nopf); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_notdb); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_badkcr); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_qfull); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_noxform); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_wrap); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_input); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_output); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_invalid); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_ibytes); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_obytes); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_toobig); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_pdrops); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_crypto); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_hist); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_threshold); +SDT_PROBE_DECLARE(mib, ipcomp, count, ipcomps_uncompr); + +#endif + SDT_PROBE_DECLARE(ip, , , receive); SDT_PROBE_DECLARE(ip, , , send); diff --git a/lib/libc/include/generic-freebsd/netinet/in_pcb.h b/lib/libc/include/generic-freebsd/netinet/in_pcb.h index be69e6a40be2f86f4e3a3785f1d28e736b4e3561..a1caca964fa43bad4632fe57114e69ca2372dafb 100644 --- a/lib/libc/include/generic-freebsd/netinet/in_pcb.h +++ b/lib/libc/include/generic-freebsd/netinet/in_pcb.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IN_PCB_H_ @@ -66,7 +64,6 @@ * protocol-specific control block) are stored here. */ CK_LIST_HEAD(inpcbhead, inpcb); -CK_LIST_HEAD(inpcbporthead, inpcbport); CK_LIST_HEAD(inpcblbgrouphead, inpcblbgroup); typedef uint64_t inp_gen_t; @@ -135,8 +132,9 @@ struct in_conninfo { /* * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4 and * IPv6 sockets. In the case of TCP and UDP, further per-connection state is - * hung off of inp_ppcb most of the time. Almost all fields of struct inpcb - * are static after creation or protected by a per-inpcb rwlock, inp_lock. + * located in a larger protocol specific structure that embeds inpcb in it. + * Almost all fields of struct inpcb are static after creation or protected by + * a per-inpcb rwlock, inp_lock. * * A inpcb database is indexed by addresses/ports hash as well as list of * all pcbs that belong to a certain proto. Database lookups or list traversals @@ -168,7 +166,10 @@ struct inpcbpolicy; struct m_snd_tag; struct inpcb { /* Cache line #1 (amd64) */ - CK_LIST_ENTRY(inpcb) inp_hash_exact; /* hash table linkage */ + union { + CK_LIST_ENTRY(inpcb) inp_hash_exact; /* hash table linkage */ + LIST_ENTRY(inpcb) inp_lbgroup_list; /* lb group list */ + }; CK_LIST_ENTRY(inpcb) inp_hash_wild; /* hash table linkage */ struct rwlock inp_lock; /* Cache line #2 (amd64) */ @@ -179,7 +180,6 @@ struct inpcb { int inp_flags; /* (i) generic IP/datagram flags */ int inp_flags2; /* (i) generic IP/datagram flags #2*/ uint8_t inp_numa_domain; /* numa domain */ - void *inp_ppcb; /* (i) pointer to per-protocol pcb */ struct socket *inp_socket; /* (i) back pointer to socket */ struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */ struct ucred *inp_cred; /* (c) cache of socket cred */ @@ -220,7 +220,6 @@ struct inpcb { short in6p_hops; }; CK_LIST_ENTRY(inpcb) inp_portlist; /* (r:e/w:h) port list */ - struct inpcbport *inp_phd; /* (r:e/w:h) head of this list */ inp_gen_t inp_gencnt; /* (c) generation count */ void *spare_ptr; /* Spare pointer. */ rt_gen_t inp_rt_cookie; /* generation for route entry */ @@ -268,8 +267,7 @@ struct xinpcb { struct xsocket xi_socket; /* (s,p) */ struct in_conninfo inp_inc; /* (s,p) */ uint64_t inp_gencnt; /* (s,p) */ - kvaddr_t inp_ppcb; /* (s) netstat(1) */ - int64_t inp_spare64[4]; + int64_t inp_spare64[5]; uint32_t inp_flow; /* (s) */ uint32_t inp_flowid; /* (s) */ uint32_t inp_flowtype; /* (s) */ @@ -305,6 +303,30 @@ struct sockopt_parameters { char sop_optval[]; }; +#ifdef _SYS_KTLS_H_ +struct xktls_session { + uint32_t tsz; /* total sz of elm, next elm is at this+tsz */ + uint32_t fsz; /* size of the struct up to keys */ + uint64_t inp_gencnt; + kvaddr_t so_pcb; + struct in_conninfo coninf; + u_short rx_vlan_id; + struct xktls_session_onedir rcv; + struct xktls_session_onedir snd; +/* + * Next are + * - keydata for rcv, first cipher of length rcv.cipher_key_len, then + * authentication of length rcv.auth_key_len; + * - driver data (string) of length rcv.drv_st_len, if the rcv session is + * offloaded to ifnet rcv.ifnet; + * - keydata for snd, first cipher of length snd.cipher_key_len, then + * authentication of length snd.auth_key_len; + * - driver data (string) of length snd.drv_st_len, if the snd session is + * offloaded to ifnet snd.ifnet; + */ +}; +#endif /* _SYS_KTLS_H_ */ + #ifdef _KERNEL int sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo, int (*ctloutput_set)(struct inpcb *, struct sockopt *)); @@ -370,7 +392,7 @@ struct inpcbinfo { /* * Global hash of inpcbs, hashed by only local port number. */ - struct inpcbporthead *ipi_porthashbase; /* (h) */ + struct inpcbhead *ipi_porthashbase; /* (h) */ u_long ipi_porthashmask; /* (h) */ /* @@ -392,11 +414,9 @@ struct inpcbinfo { */ struct inpcbstorage { uma_zone_t ips_zone; - uma_zone_t ips_portzone; uma_init ips_pcbinit; size_t ips_size; const char * ips_zone_name; - const char * ips_portzone_name; const char * ips_infolock_name; const char * ips_hashlock_name; }; @@ -414,7 +434,6 @@ static struct inpcbstorage prot = { \ .ips_size = sizeof(struct ppcb), \ .ips_pcbinit = prot##_inpcb_init, \ .ips_zone_name = zname, \ - .ips_portzone_name = zname " ports", \ .ips_infolock_name = iname, \ .ips_hashlock_name = hname, \ }; \ @@ -423,28 +442,6 @@ SYSINIT(prot##_inpcbstorage_init, SI_SUB_PROTO_DOMAIN, \ SYSUNINIT(prot##_inpcbstorage_uninit, SI_SUB_PROTO_DOMAIN, \ SI_ORDER_SECOND, in_pcbstorage_destroy, &prot) -/* - * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group - * (or unique address:port combination) can be re-used at most - * INPCBLBGROUP_SIZMAX (256) times. The inpcbs are stored in il_inp which - * is dynamically resized as processes bind/unbind to that specific group. - */ -struct inpcblbgroup { - CK_LIST_ENTRY(inpcblbgroup) il_list; - struct epoch_context il_epoch_ctx; - struct ucred *il_cred; - uint16_t il_lport; /* (c) */ - u_char il_vflag; /* (c) */ - uint8_t il_numa_domain; - uint32_t il_pad2; - union in_dependaddr il_dependladdr; /* (c) */ -#define il_laddr il_dependladdr.id46_addr.ia46_addr4 -#define il6_laddr il_dependladdr.id6_addr - uint32_t il_inpsiz; /* max count in il_inp[] (h) */ - uint32_t il_inpcnt; /* cur count in il_inp[] (h) */ - struct inpcb *il_inp[]; /* (h) */ -}; - #define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock) #define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock) #define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock) @@ -481,12 +478,8 @@ void inp_unlock_assert(struct inpcb *); void inp_apply_all(struct inpcbinfo *, void (*func)(struct inpcb *, void *), void *arg); -int inp_ip_tos_get(const struct inpcb *inp); -void inp_ip_tos_set(struct inpcb *inp, int val); struct socket * inp_inpcbtosocket(struct inpcb *inp); -struct tcpcb * - inp_inpcbtotcpcb(struct inpcb *inp); void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, uint32_t *faddr, uint16_t *fp); @@ -578,7 +571,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, #define INP_DROPPED 0x04000000 /* protocol drop flag */ #define INP_SOCKREF 0x08000000 /* strong socket reference */ #define INP_RESERVED_0 0x10000000 /* reserved field */ -#define INP_RESERVED_1 0x20000000 /* reserved field */ +#define INP_BOUNDFIB 0x20000000 /* Bound to a specific FIB. */ #define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */ #define IN6P_MTU 0x80000000 /* receive path MTU */ @@ -624,10 +617,11 @@ typedef enum { INPLOOKUP_WILDCARD = 0x00000001, /* Allow wildcard sockets. */ INPLOOKUP_RLOCKPCB = 0x00000002, /* Return inpcb read-locked. */ INPLOOKUP_WLOCKPCB = 0x00000004, /* Return inpcb write-locked. */ + INPLOOKUP_FIB = 0x00000008, /* inp must be from same FIB. */ } inp_lookup_t; #define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \ - INPLOOKUP_WLOCKPCB) + INPLOOKUP_WLOCKPCB | INPLOOKUP_FIB) #define INPLOOKUP_LOCKMASK (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB) #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) @@ -665,34 +659,29 @@ void in_pcbstorage_destroy(void *); void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); int in_pcballoc(struct socket *, struct inpcbinfo *); -int in_pcbbind(struct inpcb *, struct sockaddr_in *, struct ucred *); +#define INPBIND_FIB 0x0001 /* bind to the PCB's FIB only */ +int in_pcbbind(struct inpcb *, struct sockaddr_in *, int, struct ucred *); int in_pcbbind_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *, - u_short *, struct ucred *); -int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *, - bool); -int in_pcbconnect_setup(struct inpcb *, struct sockaddr_in *, in_addr_t *, - u_short *, in_addr_t *, u_short *, struct ucred *); + u_short *, int, struct ucred *); +int in_pcbconnect(struct inpcb *, struct sockaddr_in *, struct ucred *); void in_pcbdisconnect(struct inpcb *); void in_pcbdrop(struct inpcb *); void in_pcbfree(struct inpcb *); -int in_pcbinshash(struct inpcb *); -int in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *, +int in_pcbladdr(const struct inpcb *, struct in_addr *, struct in_addr *, struct ucred *); int in_pcblbgroup_numa(struct inpcb *, int arg); +void in_pcblisten(struct inpcb *); struct inpcb * in_pcblookup(struct inpcbinfo *, struct in_addr, u_int, struct in_addr, u_int, int, struct ifnet *); struct inpcb * in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int, struct in_addr, u_int, int, struct ifnet *, struct mbuf *); -void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, - int, struct inpcb *(*)(struct inpcb *, int)); void in_pcbref(struct inpcb *); -void in_pcbrehash(struct inpcb *); -void in_pcbremhash_locked(struct inpcb *); bool in_pcbrele(struct inpcb *, inp_lookup_t); bool in_pcbrele_rlocked(struct inpcb *); bool in_pcbrele_wlocked(struct inpcb *); +bool in_pcbrele_rlock(struct inpcb *inp); typedef bool inp_match_t(const struct inpcb *, void *); struct inpcb_iterator { @@ -724,10 +713,8 @@ struct inpcb_iterator { struct inpcb *inp_next(struct inpcb_iterator *); void in_losing(struct inpcb *); void in_pcbsetsolabel(struct socket *so); -int in_getpeeraddr(struct socket *so, struct sockaddr **nam); -int in_getsockaddr(struct socket *so, struct sockaddr **nam); -struct sockaddr * - in_sockaddr(in_port_t port, struct in_addr *addr); +int in_getpeeraddr(struct socket *, struct sockaddr *sa); +int in_getsockaddr(struct socket *, struct sockaddr *sa); void in_pcbsosetlabel(struct socket *so); #ifdef RATELIMIT int diff --git a/lib/libc/include/generic-freebsd/netinet/in_pcb_var.h b/lib/libc/include/generic-freebsd/netinet/in_pcb_var.h index f17d6c876faa61f299632414ad5fcf591cb1c583..6fb09157c7d47a0948d584a364db7101b60ddad7 100644 --- a/lib/libc/include/generic-freebsd/netinet/in_pcb_var.h +++ b/lib/libc/include/generic-freebsd/netinet/in_pcb_var.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IN_PCB_VAR_H_ @@ -52,16 +50,37 @@ int inp_trylock(struct inpcb *inp, const inp_lookup_t lock); bool inp_smr_lock(struct inpcb *, const inp_lookup_t); int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *, struct ucred *, int); -int in_pcb_lport_dest(struct inpcb *inp, struct sockaddr *lsa, +int in_pcb_lport_dest(const struct inpcb *inp, struct sockaddr *lsa, u_short *lportp, struct sockaddr *fsa, u_short fport, struct ucred *cred, int lookupflags); -struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, - int, struct ucred *); +struct inpcb *in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, + int, int, struct ucred *); +int in_pcbinshash(struct inpcb *); +void in_pcbrehash(struct inpcb *); +void in_pcbremhash_locked(struct inpcb *); -struct inpcbport { - struct inpcbhead phd_pcblist; - CK_LIST_ENTRY(inpcbport) phd_hash; - u_short phd_port; +/* + * Load balance groups used for the SO_REUSEPORT_LB socket option. Each group + * (or unique address:port combination) can be re-used at most + * INPCBLBGROUP_SIZMAX (256) times. The inpcbs are stored in il_inp which + * is dynamically resized as processes bind/unbind to that specific group. + */ +struct inpcblbgroup { + CK_LIST_ENTRY(inpcblbgroup) il_list; + LIST_HEAD(, inpcb) il_pending; /* PCBs waiting for listen() */ + struct epoch_context il_epoch_ctx; + struct ucred *il_cred; + uint16_t il_lport; /* (c) */ + u_char il_vflag; /* (c) */ + uint8_t il_numa_domain; + int il_fibnum; + union in_dependaddr il_dependladdr; /* (c) */ +#define il_laddr il_dependladdr.id46_addr.ia46_addr4 +#define il6_laddr il_dependladdr.id6_addr + uint32_t il_inpsiz; /* max count in il_inp[] (h) */ + uint32_t il_inpcnt; /* cur count in il_inp[] (h) */ + uint32_t il_pendcnt; /* cur count in il_pending (h) */ + struct inpcb *il_inp[]; /* (h) */ }; #endif /* !_NETINET_IN_PCB_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/in_systm.h b/lib/libc/include/generic-freebsd/netinet/in_systm.h index aa601357a80d78503415622fea4424bb16ce8560..b4e5879c810b7a6ba9d23fb7eef9d0e989c38999 100644 --- a/lib/libc/include/generic-freebsd/netinet/in_systm.h +++ b/lib/libc/include/generic-freebsd/netinet/in_systm.h @@ -27,13 +27,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IN_SYSTM_H_ #define _NETINET_IN_SYSTM_H_ +#include + /* * Miscellaneous internetwork * definitions for kernel. @@ -58,8 +58,10 @@ typedef u_int32_t n_time; /* ms since 00:00 UTC, byte rev */ #ifdef _KERNEL struct inpcb; struct ucred; +struct thread; int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); +bool cr_canexport_ktlskeys(struct thread *td, struct inpcb *inp); uint32_t iptime(void); #endif diff --git a/lib/libc/include/generic-freebsd/netinet/in_var.h b/lib/libc/include/generic-freebsd/netinet/in_var.h index 96557fc052ac119c11f108c1577910b855dabd40..7282aac363f0590ff7a3930174968e396a9f7d25 100644 --- a/lib/libc/include/generic-freebsd/netinet/in_var.h +++ b/lib/libc/include/generic-freebsd/netinet/in_var.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_var.h 8.2 (Berkeley) 1/9/95 */ #ifndef _NETINET_IN_VAR_H_ @@ -99,6 +97,11 @@ struct in_ifaddr { #define IN_LNAOF(in, ifa) \ ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask)) +#ifdef _KERNEL +#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + ((((d).s_addr ^ (a).s_addr) & (m).s_addr)) == 0 ) +#endif + #define LLTABLE(ifp) \ ((struct in_ifinfo *)(ifp)->if_afdata[AF_INET])->ii_llt /* @@ -456,6 +459,7 @@ int in_joingroup_locked(struct ifnet *, const struct in_addr *, int in_leavegroup(struct in_multi *, /*const*/ struct in_mfilter *); int in_leavegroup_locked(struct in_multi *, /*const*/ struct in_mfilter *); +int in_mask2len(struct in_addr *); int in_control(struct socket *, u_long, void *, struct ifnet *, struct thread *); int in_control_ioctl(u_long, void *, struct ifnet *, diff --git a/lib/libc/include/generic-freebsd/netinet/ip.h b/lib/libc/include/generic-freebsd/netinet/ip.h index 636b48e623417d81fecad08fd788da2467a5a0df..1843027a58e7975daa3d89259931e20d6a1659c2 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip.h +++ b/lib/libc/include/generic-freebsd/netinet/ip.h @@ -28,14 +28,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip.h 8.2 (Berkeley) 6/1/94 */ #ifndef _NETINET_IP_H_ #define _NETINET_IP_H_ -#include +#include +#include /* * Definitions for internet protocol version 4. @@ -68,7 +67,7 @@ struct ip { u_char ip_p; /* protocol */ u_short ip_sum; /* checksum */ struct in_addr ip_src,ip_dst; /* source and dest address */ -} __packed __aligned(2); +} __packed; #define IP_MAXPACKET 65535 /* maximum packet size */ @@ -188,7 +187,7 @@ struct ip_timestamp { uint32_t ipt_time; /* network format */ } ipt_ta[1]; } ipt_timestamp; -}; +} __packed; /* Flag bits for ipt_flg. */ #define IPOPT_TS_TSONLY 0 /* timestamps only */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip6.h b/lib/libc/include/generic-freebsd/netinet/ip6.h index 873cf9a910080a0097ed34868454cc7a902dfcc8..b26826250ad4813991b966ced46cbf605c162293 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip6.h +++ b/lib/libc/include/generic-freebsd/netinet/ip6.h @@ -58,8 +58,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IP6_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_carp.h b/lib/libc/include/generic-freebsd/netinet/ip_carp.h index c043153d3007b93ff98ef8a30e6fe833bdb5c953..495e298a6b9b3280e53aeae9c94a37b26dbcbb7a 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_carp.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_carp.h @@ -31,6 +31,7 @@ #ifndef _IP_CARP_H #define _IP_CARP_H +#ifdef _KERNEL /* * The CARP header layout is as follows: * @@ -77,15 +78,54 @@ struct carp_header { unsigned char carp_md[20]; /* SHA1 HMAC */ } __packed; -#ifdef CTASSERT CTASSERT(sizeof(struct carp_header) == 36); + +/* + * The VRRPv3 header layout is as follows: + * See RFC9568, 5.1. VRRP Packet Format + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr| + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |(rsvd) | Max Adver Int | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * + + + * | IPvX Address(es) | + * + + + * + + + * + + + * + + + * | | + * + + + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +struct vrrpv3_header { +#if BYTE_ORDER == LITTLE_ENDIAN + uint8_t vrrp_type:4, + vrrp_version:4; #endif +#if BYTE_ORDER == BIG_ENDIAN + uint8_t vrrp_version:4, + vrrp_type:4; +#endif + uint8_t vrrp_vrtid; + uint8_t vrrp_priority; + uint8_t vrrp_count_addr; + uint16_t vrrp_max_adver_int; + uint16_t vrrp_checksum; +} __packed; + +CTASSERT(sizeof(struct vrrpv3_header) == 8); +#endif /* _KERNEL */ #define CARP_DFLTTL 255 -/* carp_version */ -#define CARP_VERSION 2 - /* carp_type */ #define CARP_ADVERTISEMENT 0x01 @@ -94,6 +134,8 @@ CTASSERT(sizeof(struct carp_header) == 36); /* carp_advbase */ #define CARP_DFLTINTV 1 +#define VRRP_TYPE_ADVERTISEMENT 0x01 +#define VRRP_MAX_INTERVAL (0x1000 - 1) /* * Statistics. */ @@ -136,6 +178,11 @@ struct carpreq { #define SIOCSVH _IOWR('i', 245, struct ifreq) #define SIOCGVH _IOWR('i', 246, struct ifreq) +typedef enum carp_version { + CARP_VERSION_CARP = 2, + CARP_VERSION_VRRPv3 = 3, +} carp_version_t; + #ifdef _KERNEL int carp_ioctl(struct ifreq *, u_long, struct thread *); int carp_attach(struct ifaddr *, int); diff --git a/lib/libc/include/generic-freebsd/netinet/ip_carp_nl.h b/lib/libc/include/generic-freebsd/netinet/ip_carp_nl.h index 3f56c8170ae918e1fd22507162f4a836a51807cb..ab155b6ba6ed5aa73d02aae7ced1c9ccf983df70 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_carp_nl.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_carp_nl.h @@ -32,6 +32,9 @@ enum carp_nl_type_t { CARP_NL_ADDR = 7, /* in_addr_t */ CARP_NL_ADDR6 = 8, /* in6_addr_t */ CARP_NL_IFNAME = 9, /* string */ + CARP_NL_VERSION = 10, /* u8 */ + CARP_NL_VRRP_PRIORITY = 11, /* u8 */ + CARP_NL_VRRP_ADV_INTER = 12, /* u16, 12-bit field in centiseconds*/ }; #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/ip_compat.h b/lib/libc/include/generic-freebsd/netinet/ip_compat.h index ee33c6515acac30f01d3ed4e23c77fc1a02219ed..5ca48ab9928ed7f1c36a4d5ccd8f3254eae65f1b 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_compat.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_compat.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_compat.h 1.8 1/14/96 * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $ */ @@ -689,12 +687,6 @@ typedef struct tcpiphdr tcpiphdr_t; #ifndef IP_HL_A # define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf) #endif -#ifndef TCP_X2 -# define TCP_X2(x) (x)->th_x2 -#endif -#ifndef TCP_X2_A -# define TCP_X2_A(x,y) (x)->th_x2 = (y) -#endif #ifndef TCP_OFF # define TCP_OFF(x) (x)->th_off #endif @@ -703,9 +695,6 @@ typedef struct tcpiphdr tcpiphdr_t; #endif #define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) -#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ - TH_ECN|TH_CWR) - #if !SOLARIS && !defined(m_act) # define m_act m_nextpkt #endif @@ -1136,7 +1125,10 @@ typedef struct tcpiphdr tcpiphdr_t; #ifndef TH_CWR # define TH_CWR 0x80 #endif -#define TH_ECNALL (TH_ECN|TH_CWR) +#ifndef TH_AE +# define TH_AE 0x100 +#endif +#define TH_ECNALL (TH_ECN|TH_CWR|TH_AE) /* * TCP States diff --git a/lib/libc/include/generic-freebsd/netinet/ip_dummynet.h b/lib/libc/include/generic-freebsd/netinet/ip_dummynet.h index 23e61b4135f82995e5d3c211887279b66b759aae..035dfa92463dcc6670aec1668224dc50fb9c8547 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_dummynet.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_dummynet.h @@ -145,7 +145,7 @@ struct dn_fs { uint32_t fs_nr; /* the flowset number */ uint32_t flags; /* userland flags */ int qsize; /* queue size in slots or bytes */ - int32_t plr; /* PLR, pkt loss rate (2^31-1 means 100%) */ + int32_t pl_state; /* packet loss state */ uint32_t buckets; /* buckets used for the queue hash table */ struct ipfw_flow_id flow_mask; @@ -168,6 +168,7 @@ struct dn_fs { int min_th ; /* minimum threshold for queue (scaled) */ int max_p ; /* maximum value for p_b (scaled) */ + int32_t plr[4]; /* PLR, pkt loss rate (2^31-1 means 100%) */ }; /* diff --git a/lib/libc/include/generic-freebsd/netinet/ip_fil.h b/lib/libc/include/generic-freebsd/netinet/ip_fil.h index 0a169736393e15f244569049c6224834ed22acc7..db2689cc38f030200d342b2d79808d92d0e32b7b 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_fil.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_fil.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_fil.h 1.35 6/5/96 * Id: ip_fil.h,v 2.170.2.51 2007/10/10 09:48:03 darrenr Exp $ */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_frag.h b/lib/libc/include/generic-freebsd/netinet/ip_frag.h index dcd6d4d1652b829eaecc3fd23e66061ec184737a..25602dbab84fc4c38fcabd2d9e4b2ee34867b06a 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_frag.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_frag.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_frag.h 1.5 3/24/96 * Id: ip_frag.h,v 2.23.2.1 2004/03/29 16:21:56 darrenr Exp */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_fw.h b/lib/libc/include/generic-freebsd/netinet/ip_fw.h index a6002a6c5a9247998f85167d197427ce3fde06b3..76b1ee577226c0b77c58a5cfbab342a91fef4656 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_fw.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_fw.h @@ -75,6 +75,10 @@ typedef struct _ip_fw3_opheader { uint16_t reserved[2]; /* Align to 64-bit boundary */ } ip_fw3_opheader; +#define IP_FW3_OPVER_0 0 +#define IP_FW3_OPVER_1 1 /* 32bit rulenum */ +#define IP_FW3_OPVER IP_FW3_OPVER_1 + /* IP_FW3 opcodes */ #define IP_FW_TABLE_XADD 86 /* add entry */ #define IP_FW_TABLE_XDEL 87 /* delete entry */ @@ -109,6 +113,7 @@ typedef struct _ip_fw3_opheader { #define IP_FW_DUMP_SOPTCODES 116 /* Dump available sopts/versions */ #define IP_FW_DUMP_SRVOBJECTS 117 /* Dump existing named objects */ +#define IP_FW_SKIPTO_CACHE 118 /* Manage skipto cache */ #define IP_FW_NAT64STL_CREATE 130 /* Create stateless NAT64 instance */ #define IP_FW_NAT64STL_DESTROY 131 /* Destroy stateless NAT64 instance */ @@ -162,162 +167,153 @@ typedef struct _ip_fw3_opheader { */ enum ipfw_opcodes { /* arguments (4 byte each) */ - O_NOP, - - O_IP_SRC, /* u32 = IP */ - O_IP_SRC_MASK, /* ip = IP/mask */ - O_IP_SRC_ME, /* none */ - O_IP_SRC_SET, /* u32=base, arg1=len, bitmap */ - - O_IP_DST, /* u32 = IP */ - O_IP_DST_MASK, /* ip = IP/mask */ - O_IP_DST_ME, /* none */ - O_IP_DST_SET, /* u32=base, arg1=len, bitmap */ - - O_IP_SRCPORT, /* (n)port list:mask 4 byte ea */ - O_IP_DSTPORT, /* (n)port list:mask 4 byte ea */ - O_PROTO, /* arg1=protocol */ - - O_MACADDR2, /* 2 mac addr:mask */ - O_MAC_TYPE, /* same as srcport */ - - O_LAYER2, /* none */ - O_IN, /* none */ - O_FRAG, /* none */ - - O_RECV, /* none */ - O_XMIT, /* none */ - O_VIA, /* none */ - - O_IPOPT, /* arg1 = 2*u8 bitmap */ - O_IPLEN, /* arg1 = len */ - O_IPID, /* arg1 = id */ - - O_IPTOS, /* arg1 = id */ - O_IPPRECEDENCE, /* arg1 = precedence << 5 */ - O_IPTTL, /* arg1 = TTL */ - - O_IPVER, /* arg1 = version */ - O_UID, /* u32 = id */ - O_GID, /* u32 = id */ - O_ESTAB, /* none (tcp established) */ - O_TCPFLAGS, /* arg1 = 2*u8 bitmap */ - O_TCPWIN, /* arg1 = desired win */ - O_TCPSEQ, /* u32 = desired seq. */ - O_TCPACK, /* u32 = desired seq. */ - O_ICMPTYPE, /* u32 = icmp bitmap */ - O_TCPOPTS, /* arg1 = 2*u8 bitmap */ - - O_VERREVPATH, /* none */ - O_VERSRCREACH, /* none */ - - O_PROBE_STATE, /* none */ - O_KEEP_STATE, /* none */ - O_LIMIT, /* ipfw_insn_limit */ - O_LIMIT_PARENT, /* dyn_type, not an opcode. */ + O_NOP = 0, + + O_IP_SRC = 1, /* u32 = IP */ + O_IP_SRC_MASK = 2, /* ip = IP/mask */ + O_IP_SRC_ME = 3, /* none */ + O_IP_SRC_SET = 4, /* u32=base, arg1=len, bitmap */ + + O_IP_DST = 5, /* u32 = IP */ + O_IP_DST_MASK = 6, /* ip = IP/mask */ + O_IP_DST_ME = 7, /* none */ + O_IP_DST_SET = 8, /* u32=base, arg1=len, bitmap */ + + O_IP_SRCPORT = 9, /* (n)port list:mask 4 byte ea */ + O_IP_DSTPORT = 10, /* (n)port list:mask 4 byte ea */ + O_PROTO = 11, /* arg1=protocol */ + + O_MACADDR2 = 12, /* 2 mac addr:mask */ + O_MAC_TYPE = 13, /* same as srcport */ + + O_LAYER2 = 14, /* none */ + O_IN = 15, /* none */ + O_FRAG = 16, /* none */ + + O_RECV = 17, /* none */ + O_XMIT = 18, /* none */ + O_VIA = 19, /* none */ + + O_IPOPT = 20, /* arg1 = 2*u8 bitmap */ + O_IPLEN = 21, /* arg1 = len */ + O_IPID = 22, /* arg1 = id */ + + O_IPTOS = 23, /* arg1 = id */ + O_IPPRECEDENCE = 24, /* arg1 = precedence << 5 */ + O_IPTTL = 25, /* arg1 = TTL */ + + O_IPVER = 26, /* arg1 = version */ + O_UID = 27, /* u32 = id */ + O_GID = 28, /* u32 = id */ + O_ESTAB = 29, /* none (tcp established) */ + O_TCPFLAGS = 30, /* arg1 = 2*u8 bitmap */ + O_TCPWIN = 31, /* arg1 = desired win */ + O_TCPSEQ = 32, /* u32 = desired seq. */ + O_TCPACK = 33, /* u32 = desired seq. */ + O_ICMPTYPE = 34, /* u32 = icmp bitmap */ + O_TCPOPTS = 35, /* arg1 = 2*u8 bitmap */ + + O_VERREVPATH = 36, /* none */ + O_VERSRCREACH = 37, /* none */ + + O_PROBE_STATE = 38, /* v0:arg1=kidx, v1:kidx=kidx */ + O_KEEP_STATE = 39, /* v0:arg1=kidx, v1:kidx=kidx */ + O_LIMIT = 40, /* ipfw_insn_limit */ + O_LIMIT_PARENT = 41, /* dyn_type, not an opcode. */ /* * These are really 'actions'. */ - O_LOG, /* ipfw_insn_log */ - O_PROB, /* u32 = match probability */ + O_LOG = 42, /* ipfw_insn_log */ + O_PROB = 43, /* u32 = match probability */ - O_CHECK_STATE, /* none */ - O_ACCEPT, /* none */ - O_DENY, /* none */ - O_REJECT, /* arg1=icmp arg (same as deny) */ - O_COUNT, /* none */ - O_SKIPTO, /* arg1=next rule number */ - O_PIPE, /* arg1=pipe number */ - O_QUEUE, /* arg1=queue number */ - O_DIVERT, /* arg1=port number */ - O_TEE, /* arg1=port number */ - O_FORWARD_IP, /* fwd sockaddr */ - O_FORWARD_MAC, /* fwd mac */ - O_NAT, /* nope */ - O_REASS, /* none */ + O_CHECK_STATE = 44, /* v0:arg1=kidx, v1:kidx=kidx */ + O_ACCEPT = 45, /* none */ + O_DENY = 46, /* none */ + O_REJECT = 47, /* arg1=icmp arg (same as deny) */ + O_COUNT = 48, /* none */ + O_SKIPTO = 49, /* v0:arg1=next rule number */ + /* v1:kidx= next rule number */ + O_PIPE = 50, /* arg1=pipe number */ + O_QUEUE = 51, /* arg1=queue number */ + O_DIVERT = 52, /* arg1=port number */ + O_TEE = 53, /* arg1=port number */ + O_FORWARD_IP = 54, /* fwd sockaddr */ + O_FORWARD_MAC = 55, /* fwd mac */ + O_NAT = 56, /* nope */ + O_REASS = 57, /* none */ /* * More opcodes. */ - O_IPSEC, /* has ipsec history */ - O_IP_SRC_LOOKUP, /* arg1=table number, u32=value */ - O_IP_DST_LOOKUP, /* arg1=table number, u32=value */ - O_ANTISPOOF, /* none */ - O_JAIL, /* u32 = id */ - O_ALTQ, /* u32 = altq classif. qid */ - O_DIVERTED, /* arg1=bitmap (1:loop, 2:out) */ - O_TCPDATALEN, /* arg1 = tcp data len */ - O_IP6_SRC, /* address without mask */ - O_IP6_SRC_ME, /* my addresses */ - O_IP6_SRC_MASK, /* address with the mask */ - O_IP6_DST, - O_IP6_DST_ME, - O_IP6_DST_MASK, - O_FLOW6ID, /* for flow id tag in the ipv6 pkt */ - O_ICMP6TYPE, /* icmp6 packet type filtering */ - O_EXT_HDR, /* filtering for ipv6 extension header */ - O_IP6, + O_IPSEC = 58, /* has ipsec history */ + O_IP_SRC_LOOKUP = 59, /* v0:arg1=table number, u32=value */ + /* v1:kidx=name, u32=value, arg1=key */ + O_IP_DST_LOOKUP = 60, /* arg1=table number, u32=value */ + /* v1:kidx=name, u32=value, arg1=key */ + O_ANTISPOOF = 61, /* none */ + O_JAIL = 62, /* u32 = id */ + O_ALTQ = 63, /* u32 = altq classif. qid */ + O_DIVERTED = 64, /* arg1=bitmap (1:loop, 2:out) */ + O_TCPDATALEN = 65, /* arg1 = tcp data len */ + O_IP6_SRC = 66, /* address without mask */ + O_IP6_SRC_ME = 67, /* my addresses */ + O_IP6_SRC_MASK = 68, /* address with the mask */ + O_IP6_DST = 69, + O_IP6_DST_ME = 70, + O_IP6_DST_MASK = 71, + O_FLOW6ID = 72, /* for flow id tag in the ipv6 pkt */ + O_ICMP6TYPE = 73, /* icmp6 packet type filtering */ + O_EXT_HDR = 74, /* filtering for ipv6 extension header */ + O_IP6 = 75, /* * actions for ng_ipfw */ - O_NETGRAPH, /* send to ng_ipfw */ - O_NGTEE, /* copy to ng_ipfw */ + O_NETGRAPH = 76, /* send to ng_ipfw */ + O_NGTEE = 77, /* copy to ng_ipfw */ - O_IP4, + O_IP4 = 78, - O_UNREACH6, /* arg1=icmpv6 code arg (deny) */ + O_UNREACH6 = 79, /* arg1=icmpv6 code arg (deny) */ - O_TAG, /* arg1=tag number */ - O_TAGGED, /* arg1=tag number */ + O_TAG = 80, /* arg1=tag number */ + O_TAGGED = 81, /* arg1=tag number */ - O_SETFIB, /* arg1=FIB number */ - O_FIB, /* arg1=FIB desired fib number */ + O_SETFIB = 82, /* arg1=FIB number */ + O_FIB = 83, /* arg1=FIB desired fib number */ - O_SOCKARG, /* socket argument */ + O_SOCKARG = 84, /* socket argument */ - O_CALLRETURN, /* arg1=called rule number */ + O_CALLRETURN = 85, /* v0:arg1=called rule number */ + /* v1:kidx=called rule number */ - O_FORWARD_IP6, /* fwd sockaddr_in6 */ + O_FORWARD_IP6 = 86, /* fwd sockaddr_in6 */ - O_DSCP, /* 2 u32 = DSCP mask */ - O_SETDSCP, /* arg1=DSCP value */ - O_IP_FLOW_LOOKUP, /* arg1=table number, u32=value */ + O_DSCP = 87, /* 2 u32 = DSCP mask */ + O_SETDSCP = 88, /* arg1=DSCP value */ + O_IP_FLOW_LOOKUP = 89, /* v0:arg1=table number, u32=value */ + /* v1:kidx=name, u32=value */ - O_EXTERNAL_ACTION, /* arg1=id of external action handler */ - O_EXTERNAL_INSTANCE, /* arg1=id of eaction handler instance */ - O_EXTERNAL_DATA, /* variable length data */ + O_EXTERNAL_ACTION = 90, /* v0:arg1=id of external action handler */ + /* v1:kidx=id of external action handler */ + O_EXTERNAL_INSTANCE = 91, /* v0:arg1=id of eaction handler instance */ + /* v1:kidx=id of eaction handler instance */ + O_EXTERNAL_DATA = 92, /* variable length data */ - O_SKIP_ACTION, /* none */ - O_TCPMSS, /* arg1=MSS value */ + O_SKIP_ACTION = 93, /* none */ + O_TCPMSS = 94, /* arg1=MSS value */ - O_MAC_SRC_LOOKUP, /* arg1=table number, u32=value */ - O_MAC_DST_LOOKUP, /* arg1=table number, u32=value */ + O_MAC_SRC_LOOKUP = 95, /* kidx=name, u32=value, arg1=key */ + O_MAC_DST_LOOKUP = 96, /* kidx=name, u32=value, arg1=key */ - O_SETMARK, /* u32 = value */ - O_MARK, /* 2 u32 = value, bitmask */ + O_SETMARK = 97, /* u32 = value */ + O_MARK = 98, /* 2 u32 = value, bitmask */ O_LAST_OPCODE /* not an opcode! */ }; -/* - * Defines key types used by lookup instruction - */ -enum ipfw_table_lookup_type { - LOOKUP_DST_IP, - LOOKUP_SRC_IP, - LOOKUP_DST_PORT, - LOOKUP_SRC_PORT, - LOOKUP_UID, - LOOKUP_JAIL, - LOOKUP_DSCP, - LOOKUP_DST_MAC, - LOOKUP_SRC_MAC, - LOOKUP_MARK, -}; - /* * The extension header are filtered only for presence using a bit * vector with a flag for each header. @@ -392,6 +388,11 @@ typedef struct _ipfw_insn_u32 { u_int32_t d[1]; /* one or more */ } ipfw_insn_u32; +typedef struct _ipfw_insn_kidx { + ipfw_insn o; + uint32_t kidx; +} ipfw_insn_kidx; + /* * This is used to store IP addr-mask pairs. */ @@ -401,6 +402,47 @@ typedef struct _ipfw_insn_ip { struct in_addr mask; } ipfw_insn_ip; +typedef struct _ipfw_insn_table { + ipfw_insn o; /* arg1 is optional lookup key */ + uint32_t kidx; /* table name index */ + uint32_t value; /* table value */ +} ipfw_insn_table; + +#define IPFW_LOOKUP_TYPE_MASK 0x00FF +#define IPFW_LOOKUP_TYPE(insn) ((insn)->arg1 & IPFW_LOOKUP_TYPE_MASK) +#define IPFW_SET_LOOKUP_TYPE(insn, type) do { \ + (insn)->arg1 &= ~IPFW_LOOKUP_TYPE_MASK; \ + (insn)->arg1 |= (type) & IPFW_LOOKUP_TYPE_MASK; \ +} while (0) + +/* + * Defines key types used by lookup instruction + */ +enum ipfw_table_lookup_type { + LOOKUP_NONE = 0, + LOOKUP_DST_IP, + LOOKUP_SRC_IP, + LOOKUP_DST_PORT, + LOOKUP_SRC_PORT, + LOOKUP_UID, + LOOKUP_JAIL, + LOOKUP_DSCP, + LOOKUP_DST_MAC, + LOOKUP_SRC_MAC, + LOOKUP_MARK, + LOOKUP_RULENUM, +}; + +enum ipfw_return_type { + RETURN_NEXT_RULENUM = 0, + RETURN_NEXT_RULE, +}; + +enum ipfw_skipto_cache_op { + SKIPTO_CACHE_DISABLE = 0, + SKIPTO_CACHE_ENABLE, +}; + /* * This is used to forward to a given address (ip). */ @@ -434,7 +476,8 @@ typedef struct _ipfw_insn_if { union { struct in_addr ip; int glob; - uint16_t kidx; + uint16_t kidx_v0; + uint32_t kidx; } p; char name[IFNAMSIZ]; } ipfw_insn_if; @@ -452,6 +495,7 @@ typedef struct _ipfw_insn_altq { */ typedef struct _ipfw_insn_limit { ipfw_insn o; + u_int32_t kidx; u_int8_t _pad; u_int8_t limit_mask; /* combination of DYN_* below */ #define DYN_SRC_ADDR 0x1 @@ -462,6 +506,9 @@ typedef struct _ipfw_insn_limit { u_int16_t conn_limit; } ipfw_insn_limit; +/* MAC/InfiniBand/etc address length */ +#define IPFW_MAX_L2_ADDR_LEN 20 + /* * This is used for log instructions. */ @@ -471,6 +518,22 @@ typedef struct _ipfw_insn_log { u_int32_t log_left; /* how many left to log */ } ipfw_insn_log; +/* ipfw_insn_log->o.arg1 bitmasks */ +#define IPFW_LOG_DEFAULT 0x0000 +#define IPFW_LOG_SYSLOG (1 << 15) +#define IPFW_LOG_IPFW0 (1 << 14) +#define IPFW_LOG_RTSOCK (1 << 13) + +typedef struct _ipfwlog_rtsock_hdr_v2 { + uint32_t rulenum; + uint32_t tablearg; + ipfw_insn cmd; + u_char ether_shost[IPFW_MAX_L2_ADDR_LEN]; + u_char ether_dhost[IPFW_MAX_L2_ADDR_LEN]; + uint32_t mark; + char comment[0]; +} ipfwlog_rtsock_hdr_v2; + /* Legacy NAT structures, compat only */ #ifndef _KERNEL /* @@ -604,6 +667,10 @@ typedef struct _ipfw_insn_icmp6 { */ } ipfw_insn_icmp6; +/* Convert pointer to instruction with specified type */ +#define insntod(p, type) ((ipfw_insn_ ## type *)(p)) +#define insntoc(p, type) ((const ipfw_insn_ ## type *)(p)) + /* * Here we have the structure representing an ipfw rule. * @@ -719,30 +786,29 @@ struct ipfw_flow_id { /* * Dynamic ipfw rule. */ -typedef struct _ipfw_dyn_rule ipfw_dyn_rule; +#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */ -struct _ipfw_dyn_rule { - ipfw_dyn_rule *next; /* linked list of rules. */ - struct ip_fw *rule; /* pointer to rule */ - /* 'rule' is used to pass up the rule number (from the parent) */ - - ipfw_dyn_rule *parent; /* pointer to parent rule */ - u_int64_t pcnt; /* packet match counter */ - u_int64_t bcnt; /* byte match counter */ +typedef struct _ipfw_dyn_rule { struct ipfw_flow_id id; /* (masked) flow id */ - u_int32_t expire; /* expire time */ - u_int32_t bucket; /* which bucket in hash table */ - u_int32_t state; /* state of this rule (typically a + uint8_t set; + uint8_t type; /* rule type */ + uint16_t pad; + uint32_t expire; /* expire time */ + uint32_t rulenum; /* parent's rule number */ + uint32_t kidx; /* index of named object */ + uint64_t pcnt; /* packet match counter */ + uint64_t bcnt; /* byte match counter */ + uint32_t hashval; /* hash value */ + union { + uint32_t state; /* state of this rule (typically a * combination of TCP flags) */ -#define IPFW_DYN_ORPHANED 0x40000 /* state's parent rule was deleted */ - u_int32_t ack_fwd; /* most recent ACKs in forward */ - u_int32_t ack_rev; /* and reverse directions (used */ + uint32_t count; /* number of linked states */ + }; + uint32_t ack_fwd; /* most recent ACKs in forward */ + uint32_t ack_rev; /* and reverse directions (used */ /* to generate keepalives) */ - u_int16_t dyn_type; /* rule type */ - u_int16_t count; /* refcount */ - u_int16_t kidx; /* index of named object */ -} __packed __aligned(8); +} __packed __aligned(8) ipfw_dyn_rule; /* * Definitions for IP option names. @@ -794,16 +860,6 @@ struct _ipfw_dyn_rule { #define IPFW_VTYPE_NH6 0x00000400 /* IPv6 nexthop */ #define IPFW_VTYPE_MARK 0x00000800 /* [fw]mark */ -/* MAC/InfiniBand/etc address length */ -#define IPFW_MAX_L2_ADDR_LEN 20 - -typedef struct _ipfw_table_entry { - in_addr_t addr; /* network address */ - u_int32_t value; /* value */ - u_int16_t tbl; /* table number */ - u_int8_t masklen; /* mask length */ -} ipfw_table_entry; - typedef struct _ipfw_table_xentry { uint16_t len; /* Total entry length */ uint8_t type; /* entry type */ @@ -819,13 +875,6 @@ typedef struct _ipfw_table_xentry { } ipfw_table_xentry; #define IPFW_TCF_INET 0x01 /* CIDR flags: IPv4 record */ -typedef struct _ipfw_table { - u_int32_t size; /* size of entries in bytes */ - u_int32_t cnt; /* # of entries */ - u_int16_t tbl; /* table number */ - ipfw_table_entry ent[0]; /* entries */ -} ipfw_table; - typedef struct _ipfw_xtable { ip_fw3_opheader opheader; /* IP_FW3 opcode */ uint32_t size; /* size of entries in bytes */ @@ -865,10 +914,10 @@ typedef struct _ipfw_obj_data { /* Object name TLV */ typedef struct _ipfw_obj_ntlv { ipfw_obj_tlv head; /* TLV header */ - uint16_t idx; /* Name index */ + uint32_t idx; /* Name index */ uint8_t set; /* set, if applicable */ uint8_t type; /* object type, if applicable */ - uint32_t spare; /* unused */ + uint16_t spare; /* unused */ char name[64]; /* Null-terminated name */ } ipfw_obj_ntlv; @@ -891,19 +940,40 @@ struct tflow_entry { } a; }; +#define IPFW_TVALUE_TYPE_MASK 0xFF00 +#define IPFW_TVALUE_TYPE(insn) (((insn)->arg1 & IPFW_TVALUE_TYPE_MASK) >> 8) +#define IPFW_SET_TVALUE_TYPE(insn, type) do { \ + (insn)->arg1 &= ~IPFW_TVALUE_TYPE_MASK; \ + (insn)->arg1 |= ((type) << 8) & IPFW_TVALUE_TYPE_MASK; \ +} while (0) + +enum ipfw_table_value_type { + TVALUE_TAG = 0, + TVALUE_PIPE, + TVALUE_DIVERT, + TVALUE_SKIPTO, + TVALUE_NETGRAPH, + TVALUE_FIB, + TVALUE_NAT, + TVALUE_NH4, + TVALUE_DSCP, + TVALUE_LIMIT, + TVALUE_MARK, +}; + /* 64-byte structure representing multi-field table value */ typedef struct _ipfw_table_value { uint32_t tag; /* O_TAG/O_TAGGED */ - uint32_t pipe; /* O_PIPE/O_QUEUE */ + uint16_t pipe; /* O_PIPE/O_QUEUE */ uint16_t divert; /* O_DIVERT/O_TEE */ - uint16_t skipto; /* skipto, CALLRET */ + uint32_t skipto; /* skipto, CALLRET */ uint32_t netgraph; /* O_NETGRAPH/O_NGTEE */ - uint32_t fib; /* O_SETFIB */ uint32_t nat; /* O_NAT */ uint32_t nh4; + uint16_t fib; /* O_SETFIB */ uint8_t dscp; uint8_t spare0; - uint16_t kidx; /* value kernel index */ + uint32_t kidx; /* value kernel index */ struct in6_addr nh6; uint32_t limit; /* O_LIMIT */ uint32_t zoneid; /* scope zone id for nh6 */ @@ -918,8 +988,7 @@ typedef struct _ipfw_obj_tentry { uint8_t masklen; /* mask length */ uint8_t result; /* request result */ uint8_t spare0; - uint16_t idx; /* Table name index */ - uint16_t spare1; + uint32_t idx; /* Table name index */ union { /* Longest field needs to be aligned by 8-byte boundary */ struct in_addr addr; /* IPv4 address */ @@ -966,8 +1035,8 @@ typedef struct _ipfw_obj_ctlv { typedef struct _ipfw_range_tlv { ipfw_obj_tlv head; /* TLV header */ uint32_t flags; /* Range flags */ - uint16_t start_rule; /* Range start */ - uint16_t end_rule; /* Range end */ + uint32_t start_rule; /* Range start */ + uint32_t end_rule; /* Range end */ uint32_t set; /* Range set to match */ uint32_t new_set; /* New set to move/swap to */ } ipfw_range_tlv; @@ -1051,10 +1120,16 @@ typedef struct _ipfw_ta_info { uint64_t spare1; } ipfw_ta_info; +typedef struct _ipfw_cmd_header { /* control command header */ + ip_fw3_opheader opheader; /* IP_FW3 opcode */ + uint32_t size; /* Total size (incl. header) */ + uint32_t cmd; /* command */ +} ipfw_cmd_header; + typedef struct _ipfw_obj_header { ip_fw3_opheader opheader; /* IP_FW3 opcode */ - uint32_t spare; - uint16_t idx; /* object name index */ + uint32_t idx; /* object name index */ + uint16_t spare; uint8_t objtype; /* object type */ uint8_t objsubtype; /* object subtype */ ipfw_obj_ntlv ntlv; /* object name tlv */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_icmp.h b/lib/libc/include/generic-freebsd/netinet/ip_icmp.h index 68b017287a8b848a84d1a705612ded1e48732047..a1c025d1afd71dafae5c932b46a95e1c193c6778 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_icmp.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_icmp.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IP_ICMP_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_mroute.h b/lib/libc/include/generic-freebsd/netinet/ip_mroute.h index 6dbb6ae90943ff3952e6fbd1cddde0c4bb6ba3de..a57b0de54fde6f6652b9e36ecda6775575d549ed 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_mroute.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_mroute.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_IP_MROUTE_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_nat.h b/lib/libc/include/generic-freebsd/netinet/ip_nat.h index 7c2defc30604ec88e8af01ec8c43bdef095bffb8..81da2c778d84466c58c5cf4033e03591d17c6432 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_nat.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_nat.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_nat.h 1.5 2/4/96 * Id: ip_nat.h,v 2.90.2.20 2007/09/25 08:27:32 darrenr Exp $ */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_scan.h b/lib/libc/include/generic-freebsd/netinet/ip_scan.h index 0aa120c3b98ad59ad51cca4592dc022284bf4573..e7f2e63c6c296d4cb9437d040b5bd04cefb6b4e4 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_scan.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_scan.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_fil.h 1.35 6/5/96 * $Id$ */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_state.h b/lib/libc/include/generic-freebsd/netinet/ip_state.h index 10dcd43fac023a8df9884fe23afbf578ec5ddb0e..c53e5761938b833644b4522612c5d980309b1973 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_state.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_state.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_state.h 1.3 1/12/96 (C) 1995 Darren Reed * Id: ip_state.h,v 2.68.2.10 2007/10/16 09:33:24 darrenr Exp $ */ #ifndef __IP_STATE_H__ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_sync.h b/lib/libc/include/generic-freebsd/netinet/ip_sync.h index 4188fce1fe543f9fdb3c3e549da5095319d9efe7..398ef091ffca56192dd979da16ef0aba46153783 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_sync.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_sync.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ip_fil.h 1.35 6/5/96 * $Id$ */ diff --git a/lib/libc/include/generic-freebsd/netinet/ip_var.h b/lib/libc/include/generic-freebsd/netinet/ip_var.h index 0b359c8175f0a188e748653df1e1b2652678f81a..5b9097d244e9c5423383c689bfee5252f4c9985c 100644 --- a/lib/libc/include/generic-freebsd/netinet/ip_var.h +++ b/lib/libc/include/generic-freebsd/netinet/ip_var.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip_var.h 8.2 (Berkeley) 1/9/95 */ #ifndef _NETINET_IP_VAR_H_ @@ -49,7 +47,7 @@ struct ipovly { u_short ih_len; /* protocol length */ struct in_addr ih_src; /* source internet address */ struct in_addr ih_dst; /* destination internet address */ -}; +} __packed; #ifdef _KERNEL /* @@ -138,15 +136,19 @@ struct ipstat { #include #include +#include VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define IPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)) -#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val)) +#define IPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)); \ + } while (0) +#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val)) #define IPSTAT_INC(name) IPSTAT_ADD(name, 1) #define IPSTAT_DEC(name) IPSTAT_SUB(name, 1) @@ -154,11 +156,19 @@ VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat); * Kernel module consumers must use this accessor macro. */ void kmod_ipstat_inc(int statnum); -#define KMOD_IPSTAT_INC(name) \ - kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t)) -void kmod_ipstat_dec(int statnum); -#define KMOD_IPSTAT_DEC(name) \ - kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t)) +#define KMOD_IPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, 1); \ + kmod_ipstat_inc( \ + offsetof(struct ipstat, name) / sizeof(uint64_t)); \ + } while (0) +void kmod_ipstat_dec(int statnum); +#define KMOD_IPSTAT_DEC(name) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, -1); \ + kmod_ipstat_dec( \ + offsetof(struct ipstat, name) / sizeof(uint64_t)); \ + } while (0) /* flags passed to ip_output as last parameter */ #define IP_FORWARDING 0x1 /* most of ip header exists */ @@ -194,6 +204,7 @@ extern int (*legal_vif_num)(int); extern u_long (*ip_mcast_src)(int); VNET_DECLARE(int, rsvp_on); VNET_DECLARE(int, drop_redirect); +VNET_DECLARE(int, ip_random_id); #define V_ip_id VNET(ip_id) #define V_ip_defttl VNET(ip_defttl) @@ -206,6 +217,7 @@ VNET_DECLARE(int, drop_redirect); #define V_ip_mrouter VNET(ip_mrouter) #define V_rsvp_on VNET(rsvp_on) #define V_drop_redirect VNET(drop_redirect) +#define V_ip_random_id VNET(ip_random_id) void inp_freemoptions(struct ip_moptions *); int inp_getmoptions(struct inpcb *, struct sockopt *); @@ -225,7 +237,7 @@ struct mbuf * ip_reass(struct mbuf *); void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *, struct mbuf *); -void ip_fillid(struct ip *); +void ip_fillid(struct ip *, bool); int rip_ctloutput(struct socket *, struct sockopt *); int ipip_input(struct mbuf **, int *, int); int rsvp_input(struct mbuf **, int *, int); @@ -259,6 +271,7 @@ VNET_DECLARE(struct pfil_head *, inet_local_pfil_head); #define PFIL_INET_LOCAL_NAME "inet-local" void in_delayed_cksum(struct mbuf *m); +void in_delayed_cksum_o(struct mbuf *m, uint16_t o); /* Hooks for ipfw, dummynet, divert etc. Most are declared in raw_ip.c */ /* diff --git a/lib/libc/include/generic-freebsd/netinet/ipf_rb.h b/lib/libc/include/generic-freebsd/netinet/ipf_rb.h index 6bd46513307a62f181203b92302be9f2f621a195..ae0b8b1a44549d4070212ec333539a1ee5bda387 100644 --- a/lib/libc/include/generic-freebsd/netinet/ipf_rb.h +++ b/lib/libc/include/generic-freebsd/netinet/ipf_rb.h @@ -305,13 +305,11 @@ _n##_rb_walktree(struct _n##_rb_head *head, _n##_rb_walker_t func, void *arg)\ _t *prev; \ _t *next; \ _t *node = head->top._f.right; \ - _t *base; \ \ while (node != &_n##_rb_zero) \ node = node->_f.left; \ \ for (;;) { \ - base = node; \ prev = node; \ while ((node->_f.parent->_f.right == node) && \ (node != &_n##_rb_zero)) { \ diff --git a/lib/libc/include/generic-freebsd/netinet/ipl.h b/lib/libc/include/generic-freebsd/netinet/ipl.h index 25cfa011388ced22e9836ad29ffac81bf6cf78d8..f7d9d3f463a9377b1f87d6401da9ad755f3039e7 100644 --- a/lib/libc/include/generic-freebsd/netinet/ipl.h +++ b/lib/libc/include/generic-freebsd/netinet/ipl.h @@ -2,8 +2,6 @@ * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. - * - * @(#)ipl.h 1.21 6/5/96 * Id: ipl.h,v 2.52.2.30 2007/10/16 09:41:00 darrenr Exp $ */ diff --git a/lib/libc/include/generic-freebsd/netinet/pim.h b/lib/libc/include/generic-freebsd/netinet/pim.h index c13c619888f6a50015d5d64a4050fe7abe67a952..1f2996d0a5058283c76f89f270e78ecbf9ec5196 100644 --- a/lib/libc/include/generic-freebsd/netinet/pim.h +++ b/lib/libc/include/generic-freebsd/netinet/pim.h @@ -71,7 +71,7 @@ struct pim { #endif /* ! _PIM_VT */ uint8_t pim_reserved; /* Reserved */ uint16_t pim_cksum; /* IP-style checksum */ -}; +} __packed; /* KAME-related name backward compatibility */ #define pim_ver pim_vers #define pim_rsv pim_reserved diff --git a/lib/libc/include/generic-freebsd/netinet/sctp.h b/lib/libc/include/generic-freebsd/netinet/sctp.h index 4336ce888744735033babb8b3c87d82a18fe825f..ecfad467911726cdcc803cb2390b5f3d5c9d0b72 100644 --- a/lib/libc/include/generic-freebsd/netinet/sctp.h +++ b/lib/libc/include/generic-freebsd/netinet/sctp.h @@ -35,7 +35,6 @@ #ifndef _NETINET_SCTP_H_ #define _NETINET_SCTP_H_ -#include #include #define SCTP_PACKED __attribute__((packed)) diff --git a/lib/libc/include/generic-freebsd/netinet/sctp_os.h b/lib/libc/include/generic-freebsd/netinet/sctp_os.h index 8ec0c37a563e477221e79a9796a428a3f9d337f4..25805dd14c9f0c7a08cc16a0cc30e02a8832b64f 100644 --- a/lib/libc/include/generic-freebsd/netinet/sctp_os.h +++ b/lib/libc/include/generic-freebsd/netinet/sctp_os.h @@ -39,9 +39,6 @@ * General kernel memory allocation: * SCTP_MALLOC(element, type, size, name) * SCTP_FREE(element) - * Kernel memory allocation for "soname"- memory must be zeroed. - * SCTP_MALLOC_SONAME(name, type, size) - * SCTP_FREE_SONAME(name) */ /* diff --git a/lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h b/lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h index abec26447f5b649fdf02cc2821e530a69e2c7e02..d6ea7ecb70472ead0905bbe5a506360db46b807f 100644 --- a/lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h +++ b/lib/libc/include/generic-freebsd/netinet/sctp_os_bsd.h @@ -219,13 +219,6 @@ MALLOC_DECLARE(SCTP_M_MCORE); #define SCTP_FREE(var, type) free(var, type) -#define SCTP_MALLOC_SONAME(var, type, size) \ - do { \ - var = (type)malloc(size, M_SONAME, M_WAITOK | M_ZERO); \ - } while (0) - -#define SCTP_FREE_SONAME(var) free(var, M_SONAME) - #define SCTP_PROCESS_STRUCT struct proc * /* @@ -349,7 +342,7 @@ typedef struct callout sctp_os_timer_t; } while(0) /* Other m_pkthdr type things */ -#define SCTP_IS_IT_BROADCAST(dst, m) ((m->m_flags & M_PKTHDR) ? in_broadcast(dst, m->m_pkthdr.rcvif) : 0) +#define SCTP_IS_IT_BROADCAST(dst, m) ((m->m_flags & M_PKTHDR) ? in_ifnet_broadcast(dst, m->m_pkthdr.rcvif) : 0) #define SCTP_IS_IT_LOOPBACK(m) ((m->m_flags & M_PKTHDR) && ((m->m_pkthdr.rcvif == NULL) || (m->m_pkthdr.rcvif->if_type == IFT_LOOP))) /* This converts any input packet header diff --git a/lib/libc/include/generic-freebsd/netinet/sctp_var.h b/lib/libc/include/generic-freebsd/netinet/sctp_var.h index b7bbab2d484a5da5b973c3325d609b585c05aa4c..79a7db27e47658de1ef02804bf65a9cbc0f157b5 100644 --- a/lib/libc/include/generic-freebsd/netinet/sctp_var.h +++ b/lib/libc/include/generic-freebsd/netinet/sctp_var.h @@ -331,17 +331,17 @@ void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *, uint8_t, uint8_t, uint16_t, uint32_t); int sctp_flush(struct socket *, int); -int sctp_shutdown(struct socket *); +int sctp_shutdown(struct socket *, enum shutdown_how); int sctp_bindx(struct socket *, int, struct sockaddr_storage *, int, int, struct proc *); /* can't use sctp_assoc_t here */ int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); -int sctp_ingetaddr(struct socket *, struct sockaddr **); -int sctp_peeraddr(struct socket *, struct sockaddr **); +int sctp_ingetaddr(struct socket *, struct sockaddr *); +int sctp_peeraddr(struct socket *, struct sockaddr *); int sctp_listen(struct socket *, int, struct thread *); -int sctp_accept(struct socket *, struct sockaddr **); +int sctp_accept(struct socket *, struct sockaddr *); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp.h b/lib/libc/include/generic-freebsd/netinet/tcp.h index 67d3e2e201670af9b2d634bf098f57cf38523688..7918489df4987ca04c6cdda43cb85d6bdf4c0e36 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp.h @@ -27,14 +27,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_TCP_H_ #define _NETINET_TCP_H_ -#include #include #if __BSD_VISIBLE @@ -74,13 +71,31 @@ struct tcphdr { #define TH_RES3 0x200 #define TH_RES2 0x400 #define TH_RES1 0x800 -#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR) +#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR|TH_AE) #define PRINT_TH_FLAGS "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR\11AE" u_short th_win; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */ -}; +} __packed; + +static __inline uint16_t +__tcp_get_flags(const struct tcphdr *th) +{ + return (((uint16_t)th->th_x2 << 8) | th->th_flags); +} + +static __inline void +__tcp_set_flags(struct tcphdr *th, uint16_t flags) +{ + th->th_x2 = (flags >> 8) & 0x0f; + th->th_flags = flags & 0xff; +} + +#ifdef _KERNEL +#define tcp_get_flags(th) __tcp_get_flags(th) +#define tcp_set_flags(th, flags) __tcp_set_flags(th, flags) +#endif #define PADTCPOLEN(len) ((((len) / 4) + !!((len) % 4)) * 4) @@ -151,8 +166,6 @@ struct tcphdr { #define TCP_MAX_WINSHIFT 14 /* maximum window shift */ -#define TCP_MAXBURST 4 /* maximum segments in a burst */ - #define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ #define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) /* max space left for options */ @@ -167,165 +180,170 @@ struct tcphdr { * values and are not masked together. Some values appear to be * bitmasks for historical reasons. */ -#define TCP_NODELAY 1 /* don't delay send to coalesce packets */ +#define TCP_NODELAY 1 /* don't delay send to coalesce packets */ #if __BSD_VISIBLE -#define TCP_MAXSEG 2 /* set maximum segment size */ -#define TCP_NOPUSH 4 /* don't push last block of write */ -#define TCP_NOOPT 8 /* don't use TCP options */ -#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */ -#define TCP_INFO 32 /* retrieve tcp_info structure */ -#define TCP_STATS 33 /* retrieve stats blob structure */ -#define TCP_LOG 34 /* configure event logging for connection */ -#define TCP_LOGBUF 35 /* retrieve event log for connection */ -#define TCP_LOGID 36 /* configure log ID to correlate connections */ -#define TCP_LOGDUMP 37 /* dump connection log events to device */ -#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to - device */ -#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */ -#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */ -#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */ -#define TCP_RXTLS_MODE 42 /* Receive TLS mode */ -#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */ -#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */ +#define TCP_MAXSEG 2 /* set maximum segment size */ +#define TCP_NOPUSH 4 /* don't push last block of write */ +#define TCP_NOOPT 8 /* don't use TCP options */ +#define TCP_MD5SIG 16 /* use MD5 digests (RFC2385) */ +#define TCP_INFO 32 /* retrieve tcp_info structure */ +#define TCP_STATS 33 /* retrieve stats blob structure */ +#define TCP_LOG 34 /* configure event logging for connection */ +#define TCP_LOGBUF 35 /* retrieve event log for connection */ +#define TCP_LOGID 36 /* configure log ID to correlate connections */ +#define TCP_LOGDUMP 37 /* dump connection log events to device */ +#define TCP_LOGDUMPID 38 /* dump events from connections with same ID to + device */ +#define TCP_TXTLS_ENABLE 39 /* TLS framing and encryption for transmit */ +#define TCP_TXTLS_MODE 40 /* Transmit TLS mode */ +#define TCP_RXTLS_ENABLE 41 /* TLS framing and encryption for receive */ +#define TCP_RXTLS_MODE 42 /* Receive TLS mode */ +#define TCP_IWND_NB 43 /* Override initial window (units: bytes) */ +#define TCP_IWND_NSEG 44 /* Override initial window (units: MSS segs) */ #ifdef _KERNEL -#define TCP_USE_DDP 45 /* Use direct data placement for so_rcvbuf */ +#define TCP_USE_DDP 45 /* Use direct data placement for so_rcvbuf */ #endif -#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */ -#define TCP_LOG_TAG 47 /* configure tag for grouping logs */ -#define TCP_USER_LOG 48 /* userspace log event */ -#define TCP_CONGESTION 64 /* get/set congestion control algorithm */ -#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */ -#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */ -#define TCP_MAXPEAKRATE 69 /* maximum peak rate allowed (kbps) */ -#define TCP_IDLE_REDUCE 70 /* Reduce cwnd on idle input */ -#define TCP_REMOTE_UDP_ENCAPS_PORT 71 /* Enable TCP over UDP tunneling via the specified port */ -#define TCP_DELACK 72 /* socket option for delayed ack */ -#define TCP_FIN_IS_RST 73 /* A fin from the peer is treated has a RST */ -#define TCP_LOG_LIMIT 74 /* Limit to number of records in tcp-log */ -#define TCP_SHARED_CWND_ALLOWED 75 /* Use of a shared cwnd is allowed */ -#define TCP_PROC_ACCOUNTING 76 /* Do accounting on tcp cpu usage and counts */ -#define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */ -#define TCP_PERF_INFO 78 /* retrieve accounting counters */ -#define TCP_LRD 79 /* toggle Lost Retransmission Detection for A/B testing */ -#define TCP_KEEPINIT 128 /* N, time to establish connection */ -#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */ -#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */ -#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */ -#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */ -#define TCP_PCAP_OUT 2048 /* number of output packets to keep */ -#define TCP_PCAP_IN 4096 /* number of input packets to keep */ -#define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */ -#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */ +#define TCP_LOGID_CNT 46 /* get number of connections with the same ID */ +#define TCP_LOG_TAG 47 /* configure tag for grouping logs */ +#define TCP_USER_LOG 48 /* userspace log event */ +#define TCP_CONGESTION 64 /* get/set congestion control algorithm */ +#define TCP_CCALGOOPT 65 /* get/set cc algorithm specific options */ +#define TCP_MAXUNACKTIME 68 /* maximum time without making progress (sec) */ +/* unused 69 */ +#define TCP_IDLE_REDUCE 70 /* Reduce cwnd on idle input */ +#define TCP_REMOTE_UDP_ENCAPS_PORT 71 /* Enable TCP over UDP tunneling via the specified port */ +#define TCP_DELACK 72 /* socket option for delayed ack */ +#define TCP_FIN_IS_RST 73 /* A fin from the peer is treated has a RST */ +#define TCP_LOG_LIMIT 74 /* Limit to number of records in tcp-log */ +#define TCP_SHARED_CWND_ALLOWED 75 /* Use of a shared cwnd is allowed */ +#define TCP_PROC_ACCOUNTING 76 /* Do accounting on tcp cpu usage and counts */ +#define TCP_USE_CMP_ACKS 77 /* The transport can handle the Compressed mbuf acks */ +#define TCP_PERF_INFO 78 /* retrieve accounting counters */ +#define TCP_KEEPINIT 128 /* N, time to establish connection */ +#define TCP_KEEPIDLE 256 /* L,N,X start keeplives after this period */ +#define TCP_KEEPINTVL 512 /* L,N interval between keepalives */ +#define TCP_KEEPCNT 1024 /* L,N number of keepalives before close */ +#define TCP_FASTOPEN 1025 /* enable TFO / was created via TFO */ +/* unused 2048 was TCP_PCAP_OUT */ +/* unused 4096 was TCP_PCAP_IN */ +#define TCP_FUNCTION_BLK 8192 /* Set the tcp function pointers to the specified stack */ +#define TCP_FUNCTION_ALIAS 8193 /* Get the current tcp function pointer name alias */ /* Options for Rack and BBR */ -#define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */ -#define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */ -#define TCP_RACK_PROP 1051 /* Not used */ -#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */ -#define TCP_RACK_PACE_REDUCE 1053 /* RACK Pacingv reduction factor (divisor) */ -#define TCP_RACK_PACE_MAX_SEG 1054 /* Max TSO size we will send */ -#define TCP_RACK_PACE_ALWAYS 1055 /* Use the always pace method */ -#define TCP_RACK_PROP_RATE 1056 /* Not used */ -#define TCP_RACK_PRR_SENDALOT 1057 /* Allow PRR to send more than one seg */ -#define TCP_RACK_MIN_TO 1058 /* Minimum time between rack t-o's in ms */ -#define TCP_RACK_EARLY_RECOV 1059 /* Not used */ -#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */ -#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */ -#define TCP_RACK_REORD_FADE 1062 /* Does reordering fade after ms time */ -#define TCP_RACK_TLP_THRESH 1063 /* RACK TLP theshold i.e. srtt+(srtt/N) */ -#define TCP_RACK_PKT_DELAY 1064 /* RACK added ms i.e. rack-rtt + reord + N */ -#define TCP_RACK_TLP_INC_VAR 1065 /* Does TLP include rtt variance in t-o */ -#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */ -#define TCP_BBR_RECFORCE 1068 /* Enter recovery force out a segment disregard pacer no longer valid */ -#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */ -#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */ -#define TCP_BBR_RWND_IS_APP 1071 /* Rwnd limited is considered app limited */ -#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */ -#define TCP_BBR_ONE_RETRAN 1073 /* Is only one segment allowed out during retran */ -#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */ -#define TCP_BBR_USE_LOWGAIN 1075 /* lower the gain in PROBE_BW enable */ -#define TCP_BBR_LOWGAIN_THRESH 1076 /* Unused after 2.3 morphs to TSLIMITS >= 2.3 */ -#define TCP_BBR_TSLIMITS 1076 /* Do we use experimental Timestamp limiting for our algo */ -#define TCP_BBR_LOWGAIN_HALF 1077 /* Unused after 2.3 */ -#define TCP_BBR_PACE_OH 1077 /* Reused in 4.2 for pacing overhead setting */ -#define TCP_BBR_LOWGAIN_FD 1078 /* Unused after 2.3 */ -#define TCP_BBR_HOLD_TARGET 1078 /* For 4.3 on */ -#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */ -#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */ -#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */ -#define TCP_BBR_REC_OVER_HPTS 1082 /* Recovery override htps settings 0/1/3 */ -#define TCP_BBR_UNLIMITED 1083 /* Not used before 2.3 and morphs to algorithm >= 2.3 */ -#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */ -#define TCP_BBR_DRAIN_INC_EXTRA 1084 /* Does the 3/4 drain target include the extra gain */ -#define TCP_BBR_STARTUP_EXIT_EPOCH 1085 /* what epoch gets us out of startup */ -#define TCP_BBR_PACE_PER_SEC 1086 -#define TCP_BBR_PACE_DEL_TAR 1087 -#define TCP_BBR_PACE_SEG_MAX 1088 -#define TCP_BBR_PACE_SEG_MIN 1089 -#define TCP_BBR_PACE_CROSS 1090 -#define TCP_RACK_IDLE_REDUCE_HIGH 1092 /* Reduce the highest cwnd seen to IW on idle */ -#define TCP_RACK_MIN_PACE 1093 /* Do we enforce rack min pace time */ -#define TCP_RACK_MIN_PACE_SEG 1094 /* If so what is the seg threshould */ -#define TCP_RACK_GP_INCREASE 1094 /* After 4.1 its the GP increase in older rack */ -#define TCP_RACK_TLP_USE 1095 -#define TCP_BBR_ACK_COMP_ALG 1096 /* Not used */ -#define TCP_BBR_TMR_PACE_OH 1096 /* Recycled in 4.2 */ -#define TCP_BBR_EXTRA_GAIN 1097 -#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */ -#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */ -#define TCP_BBR_RETRAN_WTSO 1099 -#define TCP_DATA_AFTER_CLOSE 1100 -#define TCP_BBR_PROBE_RTT_GAIN 1101 -#define TCP_BBR_PROBE_RTT_LEN 1102 -#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */ -#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */ -#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */ -#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */ -#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */ -#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */ -#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */ -#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */ -#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */ -#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */ -#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */ -#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/ -#define TCP_RACK_CHEAT_NOT_CONF_RATE TCP_RACK_RR_CONF -#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */ -#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */ -#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */ -#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */ -#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */ -#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */ -#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */ -#define TCP_NO_PRR 1122 /* If pacing, don't use prr */ -#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */ -#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */ -#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */ -#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */ -#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */ -#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */ -#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */ -#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */ -#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */ -#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */ -#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */ -#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */ -#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */ -#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */ -#define TCP_FAST_RSM_HACK 1137 /* Not used in modern stacks */ -#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */ -#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */ -#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */ -#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */ -#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */ -#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */ -#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */ -#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */ -#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */ -#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */ -#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */ -#define TCP_RXT_CLAMP 1149 /* Do we apply a threshold to rack so if excess rxt clamp cwnd? */ -#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */ -#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */ +#define TCP_REUSPORT_LB_NUMA 1026 /* set listen socket numa domain */ +#define TCP_RACK_MBUF_QUEUE 1050 /* Do we allow mbuf queuing if supported */ +/* unused 1051 */ +#define TCP_RACK_TLP_REDUCE 1052 /* RACK TLP cwnd reduction (bool) */ +/* unused 1053 */ +#define TCP_RACK_PACE_MAX_SEG 1054 /* Max TSO size we will send */ +#define TCP_RACK_PACE_ALWAYS 1055 /* Use the always pace method */ +/* unused 1056 */ +#define TCP_RACK_PRR_SENDALOT 1057 /* Allow PRR to send more than one seg */ +#define TCP_RACK_MIN_TO 1058 /* Minimum time between rack t-o's in ms */ +/* unused 1059 */ +#define TCP_RACK_EARLY_SEG 1060 /* If early recovery max segments */ +#define TCP_RACK_REORD_THRESH 1061 /* RACK reorder threshold (shift amount) */ +#define TCP_RACK_REORD_FADE 1062 /* Does reordering fade after ms time */ +#define TCP_RACK_TLP_THRESH 1063 /* RACK TLP theshold i.e. srtt+(srtt/N) */ +#define TCP_RACK_PKT_DELAY 1064 /* RACK added ms i.e. rack-rtt + reord + N */ +/* unused 1065 */ +/* unused 1066 */ +#define TCP_BBR_IWINTSO 1067 /* Initial TSO window for BBRs first sends */ +/* unused 1068 */ +#define TCP_BBR_STARTUP_PG 1069 /* Startup pacing gain */ +#define TCP_BBR_DRAIN_PG 1070 /* Drain pacing gain */ +/* unused 1071 */ +#define TCP_BBR_PROBE_RTT_INT 1072 /* How long in useconds between probe-rtt */ +/* unused 1073 */ +#define TCP_BBR_STARTUP_LOSS_EXIT 1074 /* Do we exit a loss during startup if not 20% incr */ +/* unused 1075 */ +#define TCP_BBR_TSLIMITS 1076 /* Do we use experimental Timestamp limiting for our algo */ +#define TCP_BBR_PACE_OH 1077 /* pacing overhead setting */ +/* unused 1078 */ +#define TCP_BBR_USEDEL_RATE 1079 /* Enable use of delivery rate for loss recovery */ +#define TCP_BBR_MIN_RTO 1080 /* Min RTO in milliseconds */ +#define TCP_BBR_MAX_RTO 1081 /* Max RTO in milliseconds */ +/* unused 1082 */ +#define TCP_BBR_ALGORITHM 1083 /* What measurement algo does BBR use netflix=0, google=1 */ +/* unused 1084 */ +/* unused 1085 */ +#define TCP_BBR_PACE_PER_SEC 1086 +#define TCP_BBR_PACE_DEL_TAR 1087 +#define TCP_BBR_PACE_SEG_MAX 1088 +#define TCP_BBR_PACE_SEG_MIN 1089 +#define TCP_BBR_PACE_CROSS 1090 +/* unused 1091 */ +/* unused 1092 */ +/* unused 1093 */ +/* unused 1094 */ +#define TCP_RACK_TLP_USE 1095 +#define TCP_BBR_TMR_PACE_OH 1096 /* ??? */ +#define TCP_RACK_DO_DETECTION 1097 /* Recycle of extra gain for rack, attack detection */ +#define TCP_BBR_RACK_RTT_USE 1098 /* what RTT should we use 0, 1, or 2? */ +#define TCP_BBR_RETRAN_WTSO 1099 +#define TCP_DATA_AFTER_CLOSE 1100 +#define TCP_BBR_PROBE_RTT_GAIN 1101 +#define TCP_BBR_PROBE_RTT_LEN 1102 +#define TCP_BBR_SEND_IWND_IN_TSO 1103 /* Do we burst out whole iwin size chunks at start? */ +#define TCP_BBR_USE_RACK_RR 1104 /* Do we use the rack rapid recovery for pacing rxt's */ +#define TCP_BBR_USE_RACK_CHEAT TCP_BBR_USE_RACK_RR /* Compat. */ +#define TCP_BBR_HDWR_PACE 1105 /* Enable/disable hardware pacing */ +#define TCP_BBR_UTTER_MAX_TSO 1106 /* Do we enforce an utter max TSO size */ +#define TCP_BBR_EXTRA_STATE 1107 /* Special exit-persist catch up */ +#define TCP_BBR_FLOOR_MIN_TSO 1108 /* The min tso size */ +#define TCP_BBR_MIN_TOPACEOUT 1109 /* Do we suspend pacing until */ +#define TCP_BBR_TSTMP_RAISES 1110 /* Can a timestamp measurement raise the b/w */ +#define TCP_BBR_POLICER_DETECT 1111 /* Turn on/off google mode policer detection */ +#define TCP_BBR_RACK_INIT_RATE 1112 /* Set an initial pacing rate for when we have no b/w in kbits per sec */ +#define TCP_RACK_RR_CONF 1113 /* Rack rapid recovery configuration control*/ +#define TCP_RACK_GP_INCREASE_CA 1114 /* GP increase for Congestion Avoidance */ +#define TCP_RACK_GP_INCREASE_SS 1115 /* GP increase for Slow Start */ +#define TCP_RACK_GP_INCREASE_REC 1116 /* GP increase for Recovery */ +#define TCP_RACK_FORCE_MSEG 1117 /* Override to use the user set max-seg value */ +#define TCP_RACK_PACE_RATE_CA 1118 /* Pacing rate for Congestion Avoidance */ +#define TCP_RACK_PACE_RATE_SS 1119 /* Pacing rate for Slow Start */ +#define TCP_RACK_PACE_RATE_REC 1120 /* Pacing rate for Recovery */ +#define TCP_NO_PRR 1122 /* If pacing, don't use prr */ +#define TCP_RACK_NONRXT_CFG_RATE 1123 /* In recovery does a non-rxt use the cfg rate */ +#define TCP_SHARED_CWND_ENABLE 1124 /* Use a shared cwnd if allowed */ +#define TCP_TIMELY_DYN_ADJ 1125 /* Do we attempt dynamic multipler adjustment with timely. */ +#define TCP_RACK_NO_PUSH_AT_MAX 1126 /* For timely do not push if we are over max rtt */ +#define TCP_RACK_PACE_TO_FILL 1127 /* If we are not in recovery, always pace to fill the cwnd in 1 RTT */ +#define TCP_SHARED_CWND_TIME_LIMIT 1128 /* we should limit to low time values the scwnd life */ +#define TCP_RACK_PROFILE 1129 /* Select a profile that sets multiple options */ +#define TCP_HDWR_RATE_CAP 1130 /* Allow hardware rates to cap pacing rate */ +#define TCP_PACING_RATE_CAP 1131 /* Highest rate allowed in pacing in bytes per second (uint64_t) */ +#define TCP_HDWR_UP_ONLY 1132 /* Allow the pacing rate to climb but not descend (with the exception of fill-cw */ +#define TCP_RACK_ABC_VAL 1133 /* Set a local ABC value different then the system default */ +#define TCP_REC_ABC_VAL 1134 /* Do we use the ABC value for recovery or the override one from sysctl */ +#define TCP_RACK_MEASURE_CNT 1135 /* How many measurements are required in GP pacing */ +#define TCP_DEFER_OPTIONS 1136 /* Defer options until the proper number of measurements occur, does not defer TCP_RACK_MEASURE_CNT */ +/* unused 1137 */ +#define TCP_RACK_PACING_BETA 1138 /* Changing the beta for pacing */ +#define TCP_RACK_PACING_BETA_ECN 1139 /* Changing the beta for ecn with pacing */ +#define TCP_RACK_TIMER_SLOP 1140 /* Set or get the timer slop used */ +#define TCP_RACK_DSACK_OPT 1141 /* How do we setup rack timer DSACK options bit 1/2 */ +#define TCP_RACK_ENABLE_HYSTART 1142 /* Do we allow hystart in the CC modules */ +#define TCP_RACK_SET_RXT_OPTIONS 1143 /* Set the bits in the retransmit options */ +#define TCP_RACK_HI_BETA 1144 /* Turn on/off high beta */ +#define TCP_RACK_SPLIT_LIMIT 1145 /* Set a split limit for split allocations */ +#define TCP_RACK_PACING_DIVISOR 1146 /* Pacing divisor given to rate-limit code for burst sizing */ +#define TCP_RACK_PACE_MIN_SEG 1147 /* Pacing min seg size rack will use */ +#define TCP_RACK_DGP_IN_REC 1148 /* Do we use full DGP in recovery? */ +/* unused 1149 */ +#define TCP_HYBRID_PACING 1150 /* Hybrid pacing enablement */ +#define TCP_PACING_DND 1151 /* When pacing with rr_config=3 can sacks disturb us */ +#define TCP_SS_EEXIT 1152 /* Do we do early exit from slowtart if no b/w growth */ +#define TCP_DGP_UPPER_BOUNDS 1153 /* SS and CA upper bound in percentage */ +#define TCP_NO_TIMELY 1154 /* Disable/enable Timely */ +#define TCP_HONOR_HPTS_MIN 1155 /* Do we honor hpts min to */ +#define TCP_REC_IS_DYN 1156 /* Do we allow timely to change recovery multiplier? */ +#define TCP_SIDECHAN_DIS 1157 /* Disable/enable the side-channel */ +#define TCP_FILLCW_RATE_CAP 1158 /* Set a cap for DGP's fillcw */ +/* unused 1159 */ +#define TCP_STACK_SPEC_INFO 1160 /* Get stack specific information (if present) */ +#define RACK_CSPR_IS_FCC 1161 +#define TCP_GP_USE_LTBW 1162 /* how we use lt_bw 0=not, 1=min, 2=max */ + /* Start of reserved space for third-party user-settable options. */ #define TCP_VENDOR SO_VENDOR @@ -436,8 +454,9 @@ struct tcp_info { u_int32_t tcpi_rcv_adv; /* Peer advertised window */ u_int32_t tcpi_dupacks; /* Consecutive dup ACKs recvd */ + u_int32_t tcpi_rttmin; /* Min observed RTT */ /* Padding to grow without breaking ABI. */ - u_int32_t __tcpi_pad[10]; /* Padding. */ + u_int32_t __tcpi_pad[14]; /* Padding. */ }; /* @@ -449,9 +468,23 @@ struct tcp_fastopen { int enable; uint8_t psk[TCP_FASTOPEN_PSK_LEN]; }; -#endif + #define TCP_FUNCTION_NAME_LEN_MAX 32 +struct stack_specific_info { + char stack_name[TCP_FUNCTION_NAME_LEN_MAX]; + uint64_t policer_last_bw; /* Only valid if detection enabled and policer detected */ + uint64_t bytes_transmitted; + uint64_t bytes_retransmitted; + uint32_t policer_detection_enabled: 1, + policer_detected : 1, /* transport thinks a policer is on path */ + highly_buffered : 1, /* transport considers the path highly buffered */ + spare : 29; + uint32_t policer_bucket_size; /* Only valid if detection enabled and policer detected */ + uint32_t current_round; + uint32_t _rack_i_pad[18]; +}; + struct tcp_function_set { char function_set_name[TCP_FUNCTION_NAME_LEN_MAX]; uint32_t pcbcnt; @@ -477,6 +510,7 @@ struct tcp_snd_req { uint64_t start; uint64_t end; uint32_t flags; + uint32_t playout_ms; }; union tcp_log_userdata { @@ -507,9 +541,12 @@ struct tcp_log_user { #define TCP_HYBRID_PACING_H_MS 0x0008 /* A client hint for maxseg is present */ #define TCP_HYBRID_PACING_ENABLE 0x0010 /* We are enabling hybrid pacing else disable */ #define TCP_HYBRID_PACING_S_MSS 0x0020 /* Clent wants us to set the mss overriding gp est in CU */ -#define TCP_HYBRID_PACING_SETMSS 0x1000 /* Internal flag that tellsus we set the mss on this entry */ +#define TCP_HAS_PLAYOUT_MS 0x0040 /* The client included the chunk playout milliseconds: deprecate */ +/* the below are internal only flags */ +#define TCP_HYBRID_PACING_USER_MASK 0x0FFF /* Non-internal flags mask */ +#define TCP_HYBRID_PACING_SETMSS 0x1000 /* Internal flag that tells us we set the mss on this entry */ #define TCP_HYBRID_PACING_WASSET 0x2000 /* We init to this to know if a hybrid command was issued */ - +#define TCP_HYBRID_PACING_SENDTIME 0x4000 /* Duplicate tm to last, use sendtime for catch up mode */ struct tcp_hybrid_req { struct tcp_snd_req req; @@ -536,4 +573,5 @@ struct tcp_hybrid_req { #define TCP_REUSPORT_LB_NUMA_NODOM (-2) /* remove numa binding */ #define TCP_REUSPORT_LB_NUMA_CURDOM (-1) /* bind to current domain */ +#endif /* __BSD_VISIBLE */ #endif /* !_NETINET_TCP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_ecn.h b/lib/libc/include/generic-freebsd/netinet/tcp_ecn.h index 8d312344bb3f2bf0a85c32a740396c291cbdec9f..94636ce646dfa49c720c1dbca673c180cc8824c8 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_ecn.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_ecn.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_ecn.h 8.4 (Berkeley) 5/24/95 */ #ifndef _NETINET_TCP_ECN_H_ @@ -40,6 +38,8 @@ #include #include +#define TH_ACE_SHIFT 6 + void tcp_ecn_input_syn_sent(struct tcpcb *, uint16_t, int); void tcp_ecn_input_parallel_syn(struct tcpcb *, uint16_t, int); int tcp_ecn_input_segment(struct tcpcb *, uint16_t, int, int, int); @@ -48,7 +48,6 @@ int tcp_ecn_output_established(struct tcpcb *, uint16_t *, int, bool); void tcp_ecn_syncache_socket(struct tcpcb *, struct syncache *); int tcp_ecn_syncache_add(uint16_t, int); uint16_t tcp_ecn_syncache_respond(uint16_t, struct syncache *); -int tcp_ecn_get_ace(uint16_t); #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h b/lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h index 4028b9191f0002b18dbefbea74cd1bd1376293ed..2eb22ea47603a064ca0722670cad1a115563199e 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_fastopen.h @@ -79,6 +79,7 @@ struct tcp_fastopen_ccache { uint32_t secret; }; +struct tcpcb; #ifdef TCP_RFC7413 void tcp_fastopen_init(void); void tcp_fastopen_destroy(void); diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_fsm.h b/lib/libc/include/generic-freebsd/netinet/tcp_fsm.h index 0d93b132e6e10e84b266fadfd145a5f6e8f2fbb8..be9203016810dbc7886d97a6f79ee954440356b7 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_fsm.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_fsm.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_TCP_FSM_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_hpts.h b/lib/libc/include/generic-freebsd/netinet/tcp_hpts.h index abb23403ca46e1cfae7c94fc01c83115ad348a9f..1433579c86e8a2e8ea7143d8550e7e3a590b6fff 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_hpts.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_hpts.h @@ -26,14 +26,38 @@ #ifndef __tcp_hpts_h__ #define __tcp_hpts_h__ -/* Number of useconds in a hpts tick */ -#define HPTS_TICKS_PER_SLOT 10 +/* Number of useconds represented by an hpts slot */ +#define HPTS_USECS_PER_SLOT 10 #define HPTS_MS_TO_SLOTS(x) ((x * 100) + 1) #define HPTS_USEC_TO_SLOTS(x) ((x+9) /10) #define HPTS_USEC_IN_SEC 1000000 #define HPTS_MSEC_IN_SEC 1000 #define HPTS_USEC_IN_MSEC 1000 +static inline uint32_t +tcp_tv_to_hpts_slot(const struct timeval *sv) +{ + return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_USECS_PER_SLOT)); +} + +static inline uint32_t +tcp_tv_to_usec(const struct timeval *sv) +{ + return ((uint32_t) ((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec)); +} + +static inline uint32_t +tcp_tv_to_msec(const struct timeval *sv) +{ + return ((uint32_t) ((sv->tv_sec * HPTS_MSEC_IN_SEC) + (sv->tv_usec/HPTS_USEC_IN_MSEC))); +} + +static inline uint64_t +tcp_tv_to_lusec(const struct timeval *sv) +{ + return ((uint64_t)((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec)); +} + struct hpts_diag { uint32_t p_hpts_active; /* bbr->flex7 x */ uint32_t p_nxt_slot; /* bbr->flex1 x */ @@ -66,52 +90,16 @@ struct hpts_diag { #define PACE_PKT_OUTPUT 0x40 /* Output Packets being paced */ #define PACE_TMR_MASK (PACE_TMR_KEEP|PACE_TMR_PERSIT|PACE_TMR_RXT|PACE_TMR_TLP|PACE_TMR_RACK|PACE_TMR_DELACK) -#define DEFAULT_CONNECTION_THESHOLD 100 - -/* - * When using the hpts, a TCP stack must make sure - * that once a INP_DROPPED flag is applied to a INP - * that it does not expect tcp_output() to ever be - * called by the hpts. The hpts will *not* call - * any output (or input) functions on a TCB that - * is in the DROPPED state. - * - * This implies final ACK's and RST's that might - * be sent when a TCB is still around must be - * sent from a routine like tcp_respond(). - */ -#define LOWEST_SLEEP_ALLOWED 50 -#define DEFAULT_MIN_SLEEP 250 /* How many usec's is default for hpts sleep - * this determines min granularity of the - * hpts. If 1, granularity is 10useconds at - * the cost of more CPU (context switching). - * Note do not set this to 0. - */ -#define DYNAMIC_MIN_SLEEP DEFAULT_MIN_SLEEP -#define DYNAMIC_MAX_SLEEP 5000 /* 5ms */ - -/* Thresholds for raising/lowering sleep */ -#define TICKS_INDICATE_MORE_SLEEP 100 /* This would be 1ms */ -#define TICKS_INDICATE_LESS_SLEEP 1000 /* This would indicate 10ms */ -/** - * - * Dynamic adjustment of sleeping times is done in "new" mode - * where we are depending on syscall returns and lro returns - * to push hpts forward mainly and the timer is only a backstop. - * - * When we are in the "new" mode i.e. conn_cnt > conn_cnt_thresh - * then we do a dynamic adjustment on the time we sleep. - * Our threshold is if the lateness of the first client served (in ticks) is - * greater than or equal too ticks_indicate_more_sleep (10ms - * or 10000 ticks). If we were that late, the actual sleep time - * is adjusted down by 50%. If the ticks_ran is less than - * ticks_indicate_more_sleep (100 ticks or 1000usecs). - * - */ - #ifdef _KERNEL + +/* + * The following are the definitions for the kernel HPTS interface for managing + * the HPTS ring and the TCBs on it. +*/ + void tcp_hpts_init(struct tcpcb *); void tcp_hpts_remove(struct tcpcb *); + static inline bool tcp_in_hpts(struct tcpcb *tp) { @@ -149,57 +137,17 @@ uint32_t tcp_hpts_insert_diag(struct tcpcb *tp, uint32_t slot, int32_t line, #define tcp_hpts_insert(inp, slot) \ tcp_hpts_insert_diag((inp), (slot), __LINE__, NULL) -void __tcp_set_hpts(struct tcpcb *tp, int32_t line); -#define tcp_set_hpts(a) __tcp_set_hpts(a, __LINE__) - -void tcp_set_inp_to_drop(struct inpcb *inp, uint16_t reason); - -void tcp_lro_hpts_init(void); -void tcp_lro_hpts_uninit(void); - -extern int32_t tcp_min_hptsi_time; - -#endif /* _KERNEL */ - -/* - * The following functions should also be available - * to userspace as well. - */ -static __inline uint32_t -tcp_tv_to_hptstick(const struct timeval *sv) -{ - return ((sv->tv_sec * 100000) + (sv->tv_usec / HPTS_TICKS_PER_SLOT)); -} - -static __inline uint32_t -tcp_tv_to_usectick(const struct timeval *sv) -{ - return ((uint32_t) ((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec)); -} - -static __inline uint32_t -tcp_tv_to_mssectick(const struct timeval *sv) -{ - return ((uint32_t) ((sv->tv_sec * HPTS_MSEC_IN_SEC) + (sv->tv_usec/HPTS_USEC_IN_MSEC))); -} - -static __inline uint64_t -tcp_tv_to_lusectick(const struct timeval *sv) -{ - return ((uint64_t)((sv->tv_sec * HPTS_USEC_IN_SEC) + sv->tv_usec)); -} - -#ifdef _KERNEL +void tcp_set_hpts(struct tcpcb *tp); extern int32_t tcp_min_hptsi_time; static inline int32_t get_hpts_min_sleep_time(void) { - return (tcp_min_hptsi_time + HPTS_TICKS_PER_SLOT); + return (tcp_min_hptsi_time + HPTS_USECS_PER_SLOT); } -static __inline uint32_t +static inline uint32_t tcp_gethptstick(struct timeval *sv) { struct timeval tv; @@ -207,10 +155,10 @@ tcp_gethptstick(struct timeval *sv) if (sv == NULL) sv = &tv; microuptime(sv); - return (tcp_tv_to_hptstick(sv)); + return (tcp_tv_to_hpts_slot(sv)); } -static __inline uint64_t +static inline uint64_t tcp_get_u64_usecs(struct timeval *tv) { struct timeval tvd; @@ -218,10 +166,10 @@ tcp_get_u64_usecs(struct timeval *tv) if (tv == NULL) tv = &tvd; microuptime(tv); - return (tcp_tv_to_lusectick(tv)); + return (tcp_tv_to_lusec(tv)); } -static __inline uint32_t +static inline uint32_t tcp_get_usecs(struct timeval *tv) { struct timeval tvd; @@ -229,8 +177,15 @@ tcp_get_usecs(struct timeval *tv) if (tv == NULL) tv = &tvd; microuptime(tv); - return (tcp_tv_to_usectick(tv)); + return (tcp_tv_to_usec(tv)); } +/* + * LRO HPTS initialization and uninitialization, only for internal use by the + * HPTS code. + */ +void tcp_lro_hpts_init(void); +void tcp_lro_hpts_uninit(void); + #endif /* _KERNEL */ #endif /* __tcp_hpts_h__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_log_buf.h b/lib/libc/include/generic-freebsd/netinet/tcp_log_buf.h index 286762f8ee94d8bba86dc6f54f5b11af46212350..d3ab8f6e18d41d8266da8bf944c20cd760b17929 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_log_buf.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_log_buf.h @@ -60,14 +60,6 @@ struct tcp_log_verbose uint8_t _pad[4]; } ALIGN_TCP_LOG; -/* Internal RACK state variables. */ -struct tcp_log_rack -{ - uint32_t tlr_rack_rtt; /* rc_rack_rtt */ - uint8_t tlr_state; /* Internal RACK state */ - uint8_t _pad[3]; /* Padding */ -}; - struct tcp_log_bbr { uint64_t cur_del_rate; uint64_t delRate; @@ -126,7 +118,6 @@ struct tcp_log_sendfile { */ union tcp_log_stackspecific { - struct tcp_log_rack u_rack; struct tcp_log_bbr u_bbr; struct tcp_log_sendfile u_sf; struct tcp_log_raw u_raw; /* "raw" log access */ @@ -185,7 +176,6 @@ struct tcp_log_buffer uint8_t _pad[3]; /* Padding */ /* Per-stack info */ union tcp_log_stackspecific tlb_stackinfo; -#define tlb_rack tlb_stackinfo.u_rack /* The packet */ uint32_t tlb_len; /* The packet's data length */ @@ -201,14 +191,14 @@ enum tcp_log_events { TCP_LOG_OUT, /* Transmit (without other event) 2 */ TCP_LOG_RTO, /* Retransmit timeout 3 */ TCP_LOG_SB_WAKE, /* Awaken socket buffer 4 */ - TCP_LOG_BAD_RETRAN, /* Detected bad retransmission 5 */ + TCP_UNUSED_5, /* Detected bad retransmission 5 */ TCP_LOG_PRR, /* Doing PRR 6 */ - TCP_LOG_REORDER, /* Detected reorder 7 */ + TCP_UNUSED_7, /* Detected reorder 7 */ TCP_LOG_HPTS, /* Hpts sending a packet 8 */ BBR_LOG_BBRUPD, /* We updated BBR info 9 */ BBR_LOG_BBRSND, /* We did a slot calculation and sending is done 10 */ BBR_LOG_ACKCLEAR, /* A ack clears all outstanding 11 */ - BBR_LOG_INQUEUE, /* The tcb had a packet input to it 12 */ + TCP_UNUSED_12, /* The tcb had a packet input to it 12 */ BBR_LOG_TIMERSTAR, /* Start a timer 13 */ BBR_LOG_TIMERCANC, /* Cancel a timer 14 */ BBR_LOG_ENTREC, /* Entered recovery 15 */ @@ -245,7 +235,7 @@ enum tcp_log_events { BBR_LOG_REDUCE, /* old bbr log reduce for 4.1 and earlier 46*/ TCP_LOG_RTT, /* A rtt (in useconds) is being sampled and applied to the srtt algo 47 */ BBR_LOG_SETTINGS_CHG, /* Settings changed for loss response 48 */ - BBR_LOG_SRTT_GAIN_EVENT, /* SRTT gaining -- now not used 49 */ + TCP_UNUSED_49, /* SRTT gaining -- now not used 49 */ TCP_LOG_REASS, /* Reassembly buffer logging 50 */ TCP_HDWR_PACE_SIZE, /* TCP pacing size set (rl and rack uses this) 51 */ BBR_LOG_HDWR_PACE, /* TCP Hardware pacing log 52 */ @@ -253,9 +243,9 @@ enum tcp_log_events { TCP_LOG_CONNEND, /* End of connection 54 */ TCP_LOG_LRO, /* LRO entry 55 */ TCP_SACK_FILTER_RES, /* Results of SACK Filter 56 */ - TCP_SAD_DETECT, /* Sack Attack Detection 57 */ + TCP_UNUSED_57, /* Sack Attack Detection 57 */ TCP_TIMELY_WORK, /* Logs regarding Timely CC tweaks 58 */ - TCP_LOG_USER_EVENT, /* User space event data 59 */ + TCP_UNUSED_59, /* User space event data 59 */ TCP_LOG_SENDFILE, /* sendfile() logging for TCP connections 60 */ TCP_LOG_REQ_T, /* logging of request tracking 61 */ TCP_LOG_ACCOUNTING, /* Log of TCP Accounting data 62 */ @@ -267,7 +257,9 @@ enum tcp_log_events { TCP_RACK_TP_TRIGGERED, /* A rack tracepoint is triggered 68 */ TCP_HYBRID_PACING_LOG, /* Hybrid pacing log 69 */ TCP_LOG_PRU, /* TCP protocol user request 70 */ - TCP_LOG_END /* End (keep at end) 71 */ + TCP_UNUSED_71, /* old TCP Policer detectionn, not used 71 */ + TCP_PCM_MEASURE, /* TCP Path Capacity Measurement 72 */ + TCP_LOG_END /* End (keep at end) 73 */ }; enum tcp_log_states { @@ -371,10 +363,11 @@ struct tcp_log_dev_log_queue { #define TCP_TP_COLLAPSED_RXT 0x00000004 /* When we actually retransmit a collapsed window rsm */ #define TCP_TP_REQ_LOG_FAIL 0x00000005 /* We tried to allocate a Request log but had no space */ #define TCP_TP_RESET_RCV 0x00000006 /* Triggers when we receive a RST */ -#define TCP_TP_EXCESS_RXT 0x00000007 /* When we get excess RXT's clamping the cwnd */ +#define TCP_TP_POLICER_DET 0x00000007 /* When we detect a policer */ +#define TCP_TP_EXCESS_RXT TCP_TP_POLICER_DET /* alias */ #define TCP_TP_SAD_TRIGGERED 0x00000008 /* Sack Attack Detection triggers */ - #define TCP_TP_SAD_SUSPECT 0x0000000a /* A sack has supicious information in it */ +#define TCP_TP_PACED_BOTTOM 0x0000000b /* We have paced at the bottom */ #ifdef _KERNEL @@ -384,12 +377,12 @@ extern int32_t tcp_trace_point_count; /* * Returns true if any sort of BB logging is enabled, - * commonly used throughout the codebase. + * commonly used throughout the codebase. */ static inline int tcp_bblogging_on(struct tcpcb *tp) { - if (tp->_t_logstate <= TCP_LOG_STATE_OFF) + if (tp->_t_logstate <= TCP_LOG_STATE_OFF) return (0); if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS) return (0); @@ -434,7 +427,7 @@ tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint) } } -static inline uint32_t +static inline uint32_t tcp_get_bblog_state(struct tcpcb *tp) { return (tp->_t_logstate); @@ -546,12 +539,12 @@ struct tcpcb; NULL, NULL, 0, NULL); \ } while (0) #endif /* TCP_LOG_FORCEVERBOSE */ +/* Assumes/requires the caller has already checked tcp_bblogging_on(tp). */ #define TCP_LOG_EVENTP(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \ do { \ - if (tcp_bblogging_on(tp)) \ - tcp_log_event(tp, th, rxbuf, txbuf, eventid, \ - errornum, len, stackinfo, th_hostorder, \ - NULL, NULL, 0, tv); \ + KASSERT(tcp_bblogging_on(tp), ("bblogging is off")); \ + tcp_log_event(tp, th, rxbuf, txbuf, eventid, errornum, len, \ + stackinfo, th_hostorder, NULL, NULL, 0, tv); \ } while (0) #ifdef TCP_BLACKBOX @@ -577,6 +570,9 @@ void tcp_log_flowend(struct tcpcb *tp); void tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes, int flags); int tcp_log_apply_ratio(struct tcpcb *tp, int ratio); +#ifdef DDB +void db_print_bblog_entries(struct tcp_log_stailq *log_entries, int indent); +#endif #else /* !TCP_BLACKBOX */ #define tcp_log_verbose (false) diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_offload.h b/lib/libc/include/generic-freebsd/netinet/tcp_offload.h index fcc33734eafa7653020a72e4152bf3be0fb15d62..f06c2932cdf10dca2439079a5a2d97d48c9376ce 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_offload.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_offload.h @@ -38,6 +38,8 @@ extern int registered_toedevs; +struct tcpcb; + int tcp_offload_connect(struct socket *, struct sockaddr *); void tcp_offload_listen_start(struct tcpcb *); void tcp_offload_listen_stop(struct tcpcb *); diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_pcap.h b/lib/libc/include/generic-freebsd/netinet/tcp_pcap.h deleted file mode 100644 index f6af5dc5723c099c428744136edd2047de03f2eb..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/netinet/tcp_pcap.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2015 - * Jonathan Looney. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _NETINET_TCP_PCAP_H_ -#define _NETINET_TCP_PCAP_H_ - -void tcp_pcap_init(void); -void tcp_pcap_add(struct tcphdr *th, struct mbuf *m, struct mbufq *queue); -void tcp_pcap_drain(struct mbufq *queue); -void tcp_pcap_tcpcb_init(struct tcpcb *tp); -void tcp_pcap_set_sock_max(struct mbufq *queue, int newval); -int tcp_pcap_get_sock_max(struct mbufq *queue); - -extern int tcp_pcap_aggressive_free; - -#endif /* _NETINET_TCP_PCAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_ratelimit.h b/lib/libc/include/generic-freebsd/netinet/tcp_ratelimit.h index cf9278bb68a0d1cb59c54b3fb6190ab5212c3104..347802d9f0414f0fbcb220066351d362c53fa6ec 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_ratelimit.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_ratelimit.h @@ -94,6 +94,8 @@ CK_LIST_HEAD(head_tcp_rate_set, tcp_rate_set); #ifndef ETHERNET_SEGMENT_SIZE #define ETHERNET_SEGMENT_SIZE 1514 #endif +struct tcpcb; + #ifdef RATELIMIT #define DETAILED_RATELIMIT_SYSCTL 1 /* * Undefine this if you don't want @@ -131,6 +133,9 @@ tcp_get_pacing_burst_size_w_divisor(struct tcpcb *tp, uint64_t bw, uint32_t segs void tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte); +void +tcp_rl_release_ifnet(struct ifnet *ifp); + #else static inline const struct tcp_hwrate_limit_table * tcp_set_pacing_rate(struct tcpcb *tp, struct ifnet *ifp, @@ -218,6 +223,10 @@ tcp_rl_log_enobuf(const struct tcp_hwrate_limit_table *rte) { } +static inline void +tcp_rl_release_ifnet(struct ifnet *ifp) +{ +} #endif /* diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_seq.h b/lib/libc/include/generic-freebsd/netinet/tcp_seq.h index c1517dc5037d354d8566879231191046a92140b6..83e344e4adf5c961144b7584e638486d8c43869b 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_seq.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_seq.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_seq.h 8.3 (Berkeley) 6/21/95 */ #ifndef _NETINET_TCP_SEQ_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/rack_bbr_common.h b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/rack_bbr_common.h index 860cc1a7ba3ba966bd0072b2940ab1045c4a739f..8202e5bd0ae02afc694c206743eaa449dac15a19 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/rack_bbr_common.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/rack_bbr_common.h @@ -89,30 +89,25 @@ int ctf_do_queued_segments(struct tcpcb *tp, int have_pkt); uint32_t ctf_outstanding(struct tcpcb *tp); uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked); int -_ctf_drop_checks(struct tcpopt *to, struct mbuf *m, struct tcphdr *th, +ctf_drop_checks(struct tcpopt *to, struct mbuf *m, struct tcphdr *th, struct tcpcb *tp, int32_t *tlenp, - int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val, - uint32_t *ts, uint32_t *cnt); -void ctf_ack_war_checks(struct tcpcb *tp, uint32_t *ts, uint32_t *cnt); -#define ctf_drop_checks(a, b, c, d, e, f, g, h) _ctf_drop_checks(a, b, c, d, e, f, g, h, NULL, NULL) + int32_t *thf, int32_t *drop_hdrlen, int32_t *ret_val); +void ctf_ack_war_checks(struct tcpcb *tp); void -__ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp, +ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th, int32_t thflags, int32_t tlen, - int32_t *ret_val, uint32_t *ts, uint32_t *cnt); - -#define ctf_do_dropafterack(a, b, c, d, e, f) __ctf_do_dropafterack(a, b, c, d, e, f, NULL, NULL) + int32_t *ret_val); void ctf_do_dropwithreset(struct mbuf *m, struct tcpcb *tp, - struct tcphdr *th, int32_t rstreason, int32_t tlen); + struct tcphdr *th, int32_t tlen); void ctf_do_drop(struct mbuf *m, struct tcpcb *tp); int -__ctf_process_rst(struct mbuf *m, struct tcphdr *th, - struct socket *so, struct tcpcb *tp, uint32_t *ts, uint32_t *cnt); -#define ctf_process_rst(m, t, s, p) __ctf_process_rst(m, t, s, p, NULL, NULL) +ctf_process_rst(struct mbuf *m, struct tcphdr *th, + struct socket *so, struct tcpcb *tp); void ctf_challenge_ack(struct mbuf *m, struct tcphdr *th, @@ -130,7 +125,7 @@ ctf_calc_rwin(struct socket *so, struct tcpcb *tp); void ctf_do_dropwithreset_conn(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th, - int32_t rstreason, int32_t tlen); + int32_t tlen); uint32_t ctf_fixed_maxseg(struct tcpcb *tp); diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h index 37c172666985710bea2c8be01a6b48125f64157b..7823fa577a18f2ce900fe175994f322ed9261ec9 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/sack_filter.h @@ -25,19 +25,84 @@ * SUCH DAMAGE. */ -/* - * Seven entry's is carefully choosen to - * fit in one cache line. We can easily - * change this to 15 (but it gets very - * little extra filtering). To change it - * to be larger than 15 would require either - * sf_bits becoming a uint32_t and then you - * could go to 31.. or change it to a full - * bitstring.. It is really doubtful you - * will get much benefit beyond 7, in testing - * there was a small amount but very very small. +/** + * + * The Sack filter is designed to do two functions, first it trys to reduce + * the processing of sacks. Consider that often times you get something like + * + * ack 1 (sack 100:200) + * ack 1 (sack 100:300) + * ack 1 (sack(100:400) + * + * You really want to process the 100:200 and then on the next sack process + * only 200:300 (the new data) and then finally on the third 300:400. The filter + * removes from your processing routines the already processed sack information so + * that after the filter completes you only have "new" sacks that you have not + * processed. This saves computation time so you do not need to worry about + * previously processed sack information. + * + * The second thing that the sack filter does is help protect against malicious + * attackers that are trying to attack any linked lists (or other data structures) + * that are used in sack processing. Consider an attacker sending in sacks for + * every other byte of data outstanding. This could in theory drastically split + * up any scoreboard you are maintaining and make you search through a very large + * linked list (or other structure) eating up CPU. If you split far enough and + * fracture your data structure enough you could potentially be crippled by a malicious + * peer. How the filter works here is it filters out sacks that are less than an MSS. + * We do this because generally a packet (aka MSS) should be kept whole. The only place + * we allow a smaller SACK is when the SACK touches the end of our socket buffer. This allows + * TLP to still work properly and yet protects us from splitting. The filter also only allows + * a set number of splits (defined in SACK_FILTER_BLOCKS). If more than that many sacks locations + * are being sent we discard additional ones until the earlier holes are filled up. The maximum + * the current filter can be is 15, which we have moved to since we want to be as generous as + * possible with allowing for loss. However, in previous testing of the filter it was found + * that there was very little benefit from moving from 7 to 15 sack points. Though at + * that previous set of tests, we would just discard earlier information in the filter. Now + * that we do not do that i.e. discard information and instead drop sack data we have raised + * the value to the max i.e. 15. If you want to expand beyond 15 one would have to either increase + * the size of the sf_bits to a uint32_t which could then get you a maximum of 31 splits or + * move to a true bitstring. If this is done however it further increases your risk to + * sack attacks, the bigger the number of splits (filter blocks) that are allowed + * the larger your processing arrays will grow as well as the filter. + * + * Note that this protection does not prevent an attacker from asking for a 20 byte + * MSS, that protection must be done elsewhere during the negotiation of the connection + * and is done now by just ignoring sack's from connections with too small of MSS which + * prevents sack from working and thus makes the connection less efficient but protects + * the system from harm. + * + * We may actually want to consider dropping the size of the array back to 7 to further + * protect the system which would be a more cautious approach. + * + * TCP Developer information: + * + * To use the sack filter its actually pretty simple. All you do is the normal sorting + * and sanity checks of your sacks but then after that you call out to sack_filter_blks() + * passing in the tcpcb, the sack-filter you are using (memory you have allocated) the + * pointer to the sackblk array and how many sorted valid blocks there are as well + * as what the new th_ack point is. The filter will return to you the number of + * blocks left after filtering. It will reshape the blocks based on the previous + * sacks you have received and processed. If sack_filter_blks() returns 0 then no + * new sack data is present to be processed. + * + * Whenever you reach the point of snd_una == snd_max, you should call sack_filter_clear with + * the snd_una point. You also need to call this if you invalidate your sack array for any + * reason (such as RTO's or MTU changes or some other thing that makes you think all + * data is now un-acknowledged). You can also pass in sack_filter_blks(tp, sf, NULL, 0, th_ack) to + * advance the cum-ack point. You can use sack_filter_blks_used(sf) to determine if you have filter blocks as + * well. So putting these two together, anytime the cum-ack moves forward you probably want to + * do: + * if (sack_filter_blks_used(sf)) + * sack_filter_blks(tp, sf, NULL, 0, th_ack); + * + * If for some reason you have ran the sack-filter and something goes wrong (you can't allocate space + * for example to split your sack-array. You can "undo" the data within the sack filter by calling + * sack_filter_rject(sf, in) passing in the list of blocks to be "removed" from the sack-filter. + * You can see an example of this use in bbr.c though rack.c has never found it needed. + * */ -#define SACK_FILTER_BLOCKS 7 + +#define SACK_FILTER_BLOCKS 15 struct sack_filter { tcp_seq sf_ack; @@ -48,8 +113,13 @@ struct sack_filter { }; #ifdef _KERNEL void sack_filter_clear(struct sack_filter *sf, tcp_seq seq); -int sack_filter_blks(struct sack_filter *sf, struct sackblk *in, int numblks, +int sack_filter_blks(struct tcpcb *tp, struct sack_filter *sf, struct sackblk *in, int numblks, tcp_seq th_ack); void sack_filter_reject(struct sack_filter *sf, struct sackblk *in); +static inline uint8_t sack_filter_blks_used(struct sack_filter *sf) +{ + return (sf->sf_used); +} + #endif #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h index cf0314c6c0fda714c255264fa3721f374f37050c..853928f0a4180454b5e07698392246a20fb3478f 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tailq_hash.h @@ -13,10 +13,12 @@ #define MAX_ALLOWED_SEQ_RANGE (SEQ_BUCKET_SIZE * (MAX_HASH_ENTRIES-1)) struct tailq_hash { - struct rack_head ht[MAX_HASH_ENTRIES]; uint32_t min; uint32_t max; uint32_t count; + struct rack_sendmap *rsm_min; + struct rack_sendmap *rsm_max; + struct rack_head ht[MAX_HASH_ENTRIES]; }; struct rack_sendmap * @@ -53,6 +55,10 @@ tqhash_init(struct tailq_hash *hs); int tqhash_trim(struct tailq_hash *hs, uint32_t th_ack); +void +tqhash_update_end(struct tailq_hash *hs, struct rack_sendmap *rsm, + uint32_t th_ack); + #define TQHASH_FOREACH(var, head) \ for ((var) = tqhash_min((head)); \ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_bbr.h b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_bbr.h index d79315ac49dc7debb2a2b455e60e399293c66a41..88cdfd44fa353505700269b5cd1867c9e52ccf3c 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_bbr.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_bbr.h @@ -347,8 +347,6 @@ struct bbr_log_sysctl_out { /* * Locking for the rack control block. * a) Locked by INP_WLOCK - * b) Locked by the hpts-mutex - * */ #define BBR_STATE_STARTUP 0x01 #define BBR_STATE_DRAIN 0x02 diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h index ad5a0d889df2a456d65710bf213eefbe411947b7..5e312158b4f70d4dfa87e4f3edf5a7f845a3109f 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_stacks/tcp_rack.h @@ -48,6 +48,8 @@ #define RACK_MERGED 0x080000/* The RSM was merged */ #define RACK_PMTU_CHG 0x100000/* The path mtu changed on this guy */ #define RACK_STRADDLE 0x200000/* The seq straddles the bucket line */ +#define RACK_WAS_LOST 0x400000/* Is the rsm considered lost */ +#define RACK_IS_PCM 0x800000/* A PCM measurement is being taken */ #define RACK_NUM_OF_RETRANS 3 #define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */ @@ -63,6 +65,7 @@ struct rack_sendmap { uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */ uint32_t r_flags : 24, /* Flags as defined above */ r_rtr_cnt : 8; /* Retran count, index this -1 to get time */ + uint32_t r_act_rxt_cnt; /* The actual total count of transmits */ struct mbuf *m; uint32_t soff; uint32_t orig_m_len; /* The original mbuf len when we sent (can update) */ @@ -174,6 +177,8 @@ struct rack_rtt_sample { #define RACK_TO_FRM_PERSIST 5 #define RACK_TO_FRM_DELACK 6 +#define RCV_PATH_RTT_MS 10 /* How many ms between recv path RTT's */ + struct rack_opts_stats { uint64_t tcp_rack_tlp_reduce; uint64_t tcp_rack_pace_always; @@ -194,7 +199,6 @@ struct rack_opts_stats { uint64_t tcp_rack_min_pace_seg; uint64_t tcp_rack_pace_rate_ca; uint64_t tcp_rack_rr; - uint64_t tcp_rack_do_detection; uint64_t tcp_rack_rrr_no_conf_rate; uint64_t tcp_initial_rate; uint64_t tcp_initial_win; @@ -232,7 +236,7 @@ struct rack_opts_stats { uint64_t tcp_rack_rtt_use; uint64_t tcp_data_after_close; uint64_t tcp_defer_opt; - uint64_t tcp_rxt_clamp; + uint64_t tcp_pol_detect; uint64_t tcp_rack_beta; uint64_t tcp_rack_beta_ecn; uint64_t tcp_rack_timer_slop; @@ -242,6 +246,11 @@ struct rack_opts_stats { uint64_t tcp_rack_pacing_divisor; uint64_t tcp_rack_min_seg; uint64_t tcp_dgp_in_rec; + uint64_t tcp_notimely; + uint64_t tcp_honor_hpts; + uint64_t tcp_dyn_rec; + uint64_t tcp_fillcw_rate_cap; + uint64_t tcp_pol_mss; }; /* RTT shrink reasons */ @@ -263,6 +272,9 @@ struct rack_opts_stats { #define TLP_USE_TWO_TWO 3 /* Use 2.2 behavior */ #define RACK_MIN_BW 8000 /* 64kbps in Bps */ +#define CCSP_DIS_MASK 0x0001 +#define HYBRID_DIS_MASK 0x0002 + /* Rack quality indicators for GPUT measurements */ #define RACK_QUALITY_NONE 0 /* No quality stated */ #define RACK_QUALITY_HIGH 1 /* A normal measurement of a GP RTT */ @@ -315,10 +327,9 @@ extern counter_u64_t rack_opts_arry[RACK_OPTS_SIZE]; /* * Locking for the rack control block. * a) Locked by INP_WLOCK - * b) Locked by the hpts-mutex - * */ #define RACK_GP_HIST 4 /* How much goodput history do we maintain? */ +#define RETRAN_CNT_SIZE 16 #define RACK_NUM_FSB_DEBUG 16 #ifdef _KERNEL @@ -342,6 +353,26 @@ struct rack_fast_send_blk { struct tailq_hash; +struct rack_pcm_info { + /* Base send time and s/e filled in by rack_log_output */ + uint64_t send_time; + uint32_t sseq; + uint32_t eseq; + /* Ack's fill in the rest of the data */ + uint16_t cnt; + /* Maximum acks present */ + uint16_t cnt_alloc; +}; + +#define RACK_DEFAULT_PCM_ARRAY 16 + +struct rack_pcm_stats { + uint32_t sseq; + uint32_t eseq; + uint64_t ack_time; +}; + + struct rack_control { /* Second cache line 0x40 from tcp_rack */ struct tailq_hash *tqh; /* Tree of all segments Lock(a) */ @@ -423,20 +454,14 @@ struct rack_control { uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */ uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */ uint32_t rc_high_rwnd; - uint32_t ack_count; - uint32_t sack_count; - uint32_t sack_noextra_move; - uint32_t sack_moved_extra; struct rack_rtt_sample rack_rs; const struct tcp_hwrate_limit_table *crte; uint32_t rc_agg_early; uint32_t rc_agg_delayed; uint32_t rc_tlp_rxt_last_time; - uint32_t rc_saved_cwnd; uint64_t rc_gp_output_ts; /* chg*/ uint64_t rc_gp_cumack_ts; /* chg*/ struct timeval act_rcv_time; - struct timeval rc_last_time_decay; /* SAD time decay happened here */ uint64_t gp_bw; uint64_t init_rate; #ifdef NETFLIX_SHARED_CWND @@ -452,19 +477,29 @@ struct rack_control { struct tcp_sendfile_track *rc_last_sft; uint32_t lt_seq; /* Seq at start of lt_bw gauge */ int32_t rc_rtt_diff; /* Timely style rtt diff of our gp_srtt */ - uint64_t last_sndbytes; - uint64_t last_snd_rxt_bytes; - uint64_t rxt_threshold; uint64_t last_tmit_time_acked; /* Holds the last cumack point's last send time */ - uint32_t last_rnd_rxt_clamped; - uint32_t num_of_clamps_applied; - uint32_t clamp_options; - uint32_t max_clamps; + /* Recovery stats */ + uint64_t last_sendtime; + + uint64_t last_gpest; + uint64_t last_tm_mark; /* Last tm mark used */ + uint64_t fillcw_cap; /* B/W cap on fill cw */ + struct rack_pcm_info pcm_i; + struct rack_pcm_stats *pcm_s; + uint32_t gp_gain_req; /* Percent off gp gain req */ + uint32_t last_rnd_of_gp_rise; + uint32_t gp_rnd_thresh; + uint32_t ss_hi_fs; + uint32_t gate_to_fs; + uint32_t pcm_max_seg; + uint32_t last_pcm_round; + uint32_t pcm_idle_rounds; uint32_t rc_gp_srtt; /* Current GP srtt */ uint32_t rc_prev_gp_srtt; /* Previous RTT */ uint32_t rc_entry_gp_rtt; /* Entry to PRTT gp-rtt */ uint32_t rc_loss_at_start; /* At measurement window where was our lost value */ + uint32_t rc_considered_lost; /* Count in recovery of non-retransmitted bytes considered lost */ uint32_t dsack_round_end; /* In a round of seeing a DSACK */ uint32_t current_round; /* Starting at zero */ @@ -491,22 +526,23 @@ struct rack_control { uint32_t rc_snd_max_at_rto; /* For non-sack when the RTO occurred what was snd-max */ uint32_t rc_out_at_rto; int32_t rc_scw_index; + uint32_t max_reduction; + uint32_t side_chan_dis_mask; /* Bit mask of socket opt's disabled */ uint32_t rc_tlp_threshold; /* Socket option value Lock(a) */ uint32_t rc_last_timeout_snduna; uint32_t last_tlp_acked_start; uint32_t last_tlp_acked_end; - uint32_t challenge_ack_ts; - uint32_t challenge_ack_cnt; uint32_t rc_min_to; /* Socket option value Lock(a) */ uint32_t rc_pkt_delay; /* Socket option value Lock(a) */ uint32_t persist_lost_ends; - uint32_t ack_during_sd; - uint32_t input_pkt; - uint32_t saved_input_pkt; - uint32_t saved_rxt_clamp_val; /* The encoded value we used to setup clamping */ - struct newreno rc_saved_beta; /* - * For newreno cc: - * rc_saved_cc are the values we have had + uint32_t cleared_app_ack_seq; + uint32_t last_rcv_tstmp_for_rtt; + uint32_t last_time_of_arm_rcv; + uint32_t rto_ssthresh; + uint32_t rc_saved_beta; + uint32_t rc_saved_beta_ecn; /* + * For newreno cc: rc_saved_beta and + * rc_saved_beta_ecn are the values we have had * set by the user, if pacing is not happening * (i.e. its early and we have not turned on yet * or it was turned off). The minute pacing @@ -516,10 +552,12 @@ struct rack_control { * we also set the flag (if ecn_beta is set) to make * new_reno do less of a backoff for ecn (think abe). */ + uint16_t rc_cnt_of_retran[RETRAN_CNT_SIZE]; uint16_t rc_early_recovery_segs; /* Socket option value Lock(a) */ uint16_t rc_reorder_shift; /* Socket option value Lock(a) */ uint8_t rack_per_upper_bound_ss; uint8_t rack_per_upper_bound_ca; + uint8_t cleared_app_ack; uint8_t dsack_persist; uint8_t rc_no_push_at_mrtt; /* No push when we exceed max rtt */ uint8_t num_measurements; /* Number of measurements (up to 0xff, we freeze at 0xff) */ @@ -528,37 +566,15 @@ struct rack_control { uint8_t rc_tlp_cwnd_reduce; /* Socket option value Lock(a) */ uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */ uint8_t rc_rate_sample_method; - uint8_t rc_dgp_bl_agg; /* Buffer Level aggression during DGP */ - uint8_t full_dgp_in_rec; /* Flag to say if we do full DGP in recovery */ uint8_t client_suggested_maxseg; /* Not sure what to do with this yet */ - uint8_t pacing_discount_amm; /* - * This is a multipler to the base discount that - * can be used to increase the discount. - */ - uint8_t already_had_a_excess; + uint8_t use_gp_not_last; + uint8_t pacing_method; /* If pace_always, what type of pacing */ }; #endif -/* DGP with no buffer level mitigations */ -#define DGP_LEVEL0 0 - -/* - * DGP with buffer level mitigation where BL:4 caps fillcw and BL:5 - * turns off fillcw. - */ -#define DGP_LEVEL1 1 - -/* - * DGP with buffer level mitigation where BL:3 caps fillcw and BL:4 turns off fillcw - * and BL:5 reduces by 10% - */ -#define DGP_LEVEL2 2 - -/* - * DGP with buffer level mitigation where BL:2 caps fillcw and BL:3 turns off - * fillcw BL:4 reduces by 10% and BL:5 reduces by 20% - */ -#define DGP_LEVEL3 3 +#define RACK_PACING_NONE 0x00 +#define RACK_DGP_PACING 0x01 +#define RACK_REG_PACING 0x02 /* Hybrid pacing log defines */ #define HYBRID_LOG_NO_ROOM 0 /* No room for the clients request */ @@ -579,7 +595,6 @@ struct rack_control { #define HYBRID_LOG_SENT_LOST 15 /* A closing sent/lost report */ #define RACK_TIMELY_CNT_BOOST 5 /* At 5th increase boost */ -#define RACK_MINRTT_FILTER_TIM 10 /* Seconds */ #define RACK_HYSTART_OFF 0 #define RACK_HYSTART_ON 1 /* hystart++ on */ @@ -590,19 +605,20 @@ struct rack_control { */ #define MAX_USER_SET_SEG 0x3f /* The max we can set is 63 which is probably too many */ +#define RACK_FREE_CNT_MAX 0x2f /* Max our counter can do */ #ifdef _KERNEL struct tcp_rack { /* First cache line 0x00 */ - TAILQ_ENTRY(tcp_rack) r_hpts; /* hptsi queue next Lock(b) */ int32_t(*r_substate) (struct mbuf *, struct tcphdr *, struct socket *, struct tcpcb *, struct tcpopt *, int32_t, int32_t, uint32_t, int, int, uint8_t); /* Lock(a) */ struct tcpcb *rc_tp; /* The tcpcb Lock(a) */ struct inpcb *rc_inp; /* The inpcb Lock(a) */ - uint8_t rc_free_cnt; /* Number of free entries on the rc_free list - * Lock(a) */ + uint8_t rc_free_cnt : 6, + rc_skip_timely : 1, + pcm_enabled : 1; /* Is PCM enabled */ uint8_t client_bufferlvl : 3, /* Expected range [0,5]: 0=unset, 1=low/empty */ rack_deferred_inited : 1, /* ******************************************************************** */ @@ -612,11 +628,11 @@ struct tcp_rack { shape_rxt_to_pacing_min : 1, /* ******************************************************************** */ rc_ack_required: 1, - r_pacing_discount : 1; + r_use_hpts_min : 1; uint8_t no_prr_addback : 1, gp_ready : 1, defer_options: 1, - excess_rxt_on: 1, /* Are actions on for excess retransmissions? */ + dis_lt_bw : 1, rc_ack_can_sendout_data: 1, /* * If set it will override pacing restrictions on not sending * data when the pacing timer is running. I.e. you set this @@ -659,7 +675,7 @@ struct tcp_rack { r_rack_hw_rate_caps: 1, r_up_only: 1, r_via_fill_cw : 1, - r_fill_less_agg : 1; + r_rcvpath_rtt_up : 1; uint8_t rc_user_set_max_segs : 7, /* Socket option value Lock(a) */ rc_fillcw_apply_discount; @@ -673,7 +689,7 @@ struct tcp_rack { rc_highly_buffered: 1, /* The path is highly buffered */ rc_dragged_bottom: 1, rc_pace_dnd : 1, /* The pace do not disturb bit */ - rc_avali2 : 1, + rc_initial_ss_comp : 1, rc_gp_filled : 1, rc_hw_nobuf : 1; uint8_t r_state : 4, /* Current rack state Lock(a) */ @@ -696,8 +712,8 @@ struct tcp_rack { uint8_t app_limited_needs_set : 1, use_fixed_rate : 1, rc_has_collapsed : 1, - r_cwnd_was_clamped : 1, - r_clamped_gets_lower : 1, + use_lesser_lt_bw : 1, + cspr_is_fcc : 1, rack_hdrw_pacing : 1, /* We are doing Hardware pacing */ rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */ rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */ @@ -712,8 +728,7 @@ struct tcp_rack { set_pacing_done_a_iw : 1, use_rack_rr : 1, alloc_limit_reported : 1, - sack_attack_disable : 1, - do_detection : 1, + rack_avail : 2, rc_force_max_seg : 1; uint8_t r_early : 1, r_late : 1, @@ -722,7 +737,11 @@ struct tcp_rack { r_persist_lt_bw_off : 1, r_collapse_point_valid : 1, dgp_on : 1; - uint16_t rc_init_win : 8, + uint16_t rto_from_rec: 1, + avail_bit: 4, + pcm_in_progress: 1, + pcm_needed: 1, + rc_sendvars_notset : 1, /* Inside rack_init send variables (snd_max/una etc) were not set */ rc_gp_rtt_set : 1, rc_gp_dyn_mul : 1, rc_gp_saw_rec : 1, @@ -735,5 +754,9 @@ struct tcp_rack { struct rack_control r_ctl; } __aligned(CACHE_LINE_SIZE); + +void rack_update_pcm_ack(struct tcp_rack *rack, int was_cumack, + uint32_t ss, uint32_t es); + #endif #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_syncache.h b/lib/libc/include/generic-freebsd/netinet/tcp_syncache.h index 43984cebe6b4c1d15051ac08ea557fdcc636f54f..d583416bb74ddb7ebc1eb73d1dbf7c99d90c4d45 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_syncache.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_syncache.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 */ #ifndef _NETINET_TCP_SYNCACHE_H_ @@ -47,12 +45,11 @@ struct socket * syncache_add(struct in_conninfo *, struct tcpopt *, void *, void *, uint8_t, uint16_t); void syncache_chkrst(struct in_conninfo *, struct tcphdr *, struct mbuf *, uint16_t); -void syncache_badack(struct in_conninfo *, uint16_t); int syncache_pcblist(struct sysctl_req *); struct syncache { TAILQ_ENTRY(syncache) sc_hash; - struct in_conninfo sc_inc; /* addresses */ + struct in_conninfo sc_inc; /* addresses */ int sc_rxttime; /* retransmit time */ u_int16_t sc_rxmits; /* retransmit counter */ u_int16_t sc_port; /* remote UDP encaps port */ @@ -61,7 +58,7 @@ struct syncache { u_int32_t sc_flowlabel; /* IPv6 flowlabel */ tcp_seq sc_irs; /* seq from peer */ tcp_seq sc_iss; /* our ISS */ - struct mbuf *sc_ipopts; /* source route */ + struct mbuf *sc_ipopts; /* source route */ u_int16_t sc_peer_mss; /* peer's MSS */ u_int16_t sc_wnd; /* advertised window */ u_int8_t sc_ip_ttl; /* TTL / Hop Limit */ @@ -69,7 +66,9 @@ struct syncache { u_int8_t sc_requested_s_scale:4, sc_requested_r_scale:4; u_int16_t sc_flags; -#if defined(TCP_OFFLOAD) || !defined(TCP_OFFLOAD_DISABLE) + u_int32_t sc_challenge_ack_cnt; /* chall. ACKs sent in epoch */ + sbintime_t sc_challenge_ack_end; /* End of chall. ack epoch */ +#if defined(TCP_OFFLOAD) struct toedev *sc_tod; /* entry added by this TOE */ void *sc_todctx; /* TOE driver context */ #endif @@ -129,7 +128,9 @@ struct tcp_syncache { u_int cache_limit; u_int rexmt_limit; uint32_t hash_secret; +#ifdef VIMAGE struct vnet *vnet; +#endif struct syncookie_secret secret; struct mtx pause_mtx; struct callout pause_co; diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_timer.h b/lib/libc/include/generic-freebsd/netinet/tcp_timer.h index 1d0d3e16176b19fe110be61cbe67ddb2da4f29ac..95ea610a37ef753acb56fd26b241aa9af2df0856 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_timer.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_timer.h @@ -27,13 +27,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_timer.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_TCP_TIMER_H_ #define _NETINET_TCP_TIMER_H_ +#ifdef _KERNEL + /* * The TCPT_REXMT timer is used to force retransmissions. * The TCP has the TCPT_REXMT timer set whenever segments @@ -73,21 +73,22 @@ /* * Time constants. */ -#define TCPTV_MSL ( 30*hz) /* max seg lifetime (hah!) */ +#define TCPTV_MSL MSEC_2_TICKS(30000) /* max seg lifetime (hah!) */ +#define TCPTV_MSL_LOCAL MSEC_2_TICKS(10) /* max seg lifetime for local comm */ #define TCPTV_SRTTBASE 0 /* base roundtrip time; if 0, no idea yet */ -#define TCPTV_RTOBASE ( 1*hz) /* assumed RTO if no info */ +#define TCPTV_RTOBASE MSEC_2_TICKS(1000) /* assumed RTO if no info */ -#define TCPTV_PERSMIN ( 5*hz) /* minimum persist interval */ -#define TCPTV_PERSMAX ( 60*hz) /* maximum persist interval */ +#define TCPTV_PERSMIN MSEC_2_TICKS(5000) /* minimum persist interval */ +#define TCPTV_PERSMAX MSEC_2_TICKS(60000) /* maximum persist interval */ -#define TCPTV_KEEP_INIT ( 75*hz) /* initial connect keepalive */ -#define TCPTV_KEEP_IDLE (120*60*hz) /* dflt time before probing */ -#define TCPTV_KEEPINTVL ( 75*hz) /* default probe interval */ +#define TCPTV_KEEP_INIT MSEC_2_TICKS(75000) /* initial connect keepalive */ +#define TCPTV_KEEP_IDLE MSEC_2_TICKS(120*60*1000) /* dflt time before probing */ +#define TCPTV_KEEPINTVL MSEC_2_TICKS(75000) /* default probe interval */ #define TCPTV_KEEPCNT 8 /* max probes before drop */ #define TCPTV_MAXUNACKTIME 0 /* max time without making progress */ -#define TCPTV_FINWAIT2_TIMEOUT (60*hz) /* FIN_WAIT_2 timeout if no receiver */ +#define TCPTV_FINWAIT2_TIMEOUT MSEC_2_TICKS(60000) /* FIN_WAIT_2 timeout if no receiver */ /* * Minimum retransmit timer is 3 ticks, for algorithmic stability. @@ -109,15 +110,13 @@ * The prior minimum of 1*hz (1 second) badly breaks throughput on any * networks faster then a modem that has minor (e.g. 1%) packet loss. */ -#define TCPTV_MIN ( hz/33 ) /* minimum allowable value */ -#define TCPTV_CPU_VAR ( hz/5 ) /* cpu variance allowed (200ms) */ -#define TCPTV_REXMTMAX ( 64*hz) /* max allowable REXMT value */ - -#define TCPTV_TWTRUNC 8 /* RTO factor to truncate TW */ +#define TCPTV_MIN MSEC_2_TICKS(30) /* minimum allowable value */ +#define TCPTV_CPU_VAR MSEC_2_TICKS(200) /* cpu variance allowed (200ms) */ +#define TCPTV_REXMTMAX MSEC_2_TICKS(64000) /* max allowable REXMT value */ #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ -#define TCPTV_DELACK ( hz/25 ) /* 40ms timeout */ +#define TCPTV_DELACK MSEC_2_TICKS(40) /* 40ms timeout */ /* * If we exceed this number of retransmits for a single segment, we'll consider @@ -137,8 +136,6 @@ (tv) = (tvmax); \ } while(0) -#ifdef _KERNEL - #define TP_KEEPINIT(tp) ((tp)->t_keepinit ? (tp)->t_keepinit : tcp_keepinit) #define TP_KEEPIDLE(tp) ((tp)->t_keepidle ? (tp)->t_keepidle : tcp_keepidle) #define TP_KEEPINTVL(tp) ((tp)->t_keepintvl ? (tp)->t_keepintvl : tcp_keepintvl) @@ -167,6 +164,7 @@ extern int tcp_maxunacktime; /* max time without making progress */ extern int tcp_maxpersistidle; extern int tcp_rexmit_initial; extern int tcp_rexmit_min; +extern int tcp_rexmit_max; extern int tcp_rexmit_slop; extern int tcp_ttl; /* time to live for TCP segs */ extern int tcp_backoff[]; @@ -186,6 +184,8 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss); #define V_tcp_v6pmtud_blackhole_mss VNET(tcp_v6pmtud_blackhole_mss) VNET_DECLARE(int, tcp_msl); #define V_tcp_msl VNET(tcp_msl) +VNET_DECLARE(int, tcp_msl_local); +#define V_tcp_msl_local VNET(tcp_msl_local) #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netinet/tcp_var.h b/lib/libc/include/generic-freebsd/netinet/tcp_var.h index 458235fcfb392ccb3495af5ab9258bcb6e3c7d4d..818e23205ce5b2a7c949faf18299b44baf25c55e 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcp_var.h +++ b/lib/libc/include/generic-freebsd/netinet/tcp_var.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 */ #ifndef _NETINET_TCP_VAR_H_ @@ -130,6 +128,8 @@ struct sackhint { uint32_t recover_fs; /* Flight Size at the start of Loss recovery */ uint32_t prr_delivered; /* Total bytes delivered using PRR */ uint32_t prr_out; /* Bytes sent during IN_RECOVERY */ + int32_t hole_bytes; /* current number of bytes in scoreboard holes */ + int32_t lost_bytes; /* number of rfc6675 IsLost() bytes */ }; #define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq) @@ -141,7 +141,8 @@ STAILQ_HEAD(tcp_log_stailq, tcp_log_mem); #define TCP_TRK_TRACK_FLG_OPEN 0x02 /* End is not valid (open range request) */ #define TCP_TRK_TRACK_FLG_SEQV 0x04 /* We had a sendfile that touched it */ #define TCP_TRK_TRACK_FLG_COMP 0x08 /* Sendfile as placed the last bits (range req only) */ -#define TCP_TRK_TRACK_FLG_FSND 0x10 /* First send has been done into the seq space */ +#define TCP_TRK_TRACK_FLG_FSND 0x10 /* First send has been done into the seq space */ +#define TCP_TRK_TRACK_FLG_LSND 0x20 /* We were able to set the Last Sent */ #define MAX_TCP_TRK_REQ 5 /* Max we will have at once */ struct tcp_sendfile_track { @@ -154,11 +155,14 @@ struct tcp_sendfile_track { uint64_t cspr; /* Client suggested pace rate */ uint64_t sent_at_fs; /* What was t_sndbytes as we begun sending */ uint64_t rxt_at_fs; /* What was t_snd_rxt_bytes as we begun sending */ + uint64_t sent_at_ls; /* Sent value at the last send */ + uint64_t rxt_at_ls; /* Retransmit value at the last send */ tcp_seq start_seq; /* First TCP Seq assigned */ tcp_seq end_seq; /* If range req last seq */ uint32_t flags; /* Type of request open etc */ uint32_t sbcc_at_s; /* When we allocate what is the sb_cc */ uint32_t hint_maxseg; /* Client hinted maxseg */ + uint32_t playout_ms; /* Client playout ms */ uint32_t hybrid_flags; /* Hybrid flags on this request */ }; @@ -178,7 +182,7 @@ struct tcp_sendfile_track { * snd_una). When the response comes back indicating * that there was data (return value 1), then the caller * can build a sendmap entry based on the range and the - * times. The next query would then be done at the + * times. The next query would then be done at the * newly created sendmap_end. Repeated until sendmap_end == snd_max. * * Flags in sendmap_flags are defined below as well. @@ -193,7 +197,7 @@ struct tcp_sendfile_track { * The rack_times are a misc collection of information that * the old stack might possibly fill in. Of course its possible * that an old stack may not have a piece of information. If so - * then setting that value to zero is advised. Setting any + * then setting that value to zero is advised. Setting any * timestamp passed should only place a zero in it when it * is unfilled. This may mean that a time is off by a micro-second * but this is ok in the grand scheme of things. @@ -201,13 +205,13 @@ struct tcp_sendfile_track { * When switching stacks it is desireable to get as much information * from the old stack to the new stack as possible. Though not always * will the stack be compatible in the types of information. The - * init() function needs to take care when it begins changing + * init() function needs to take care when it begins changing * things such as inp_flags2 and the timer units to position these * changes at a point where it is unlikely they will fail after * making such changes. A stack optionally can have an "undo" - * function + * function * - * To transfer information to the old stack from the new in + * To transfer information to the old stack from the new in * respect to LRO and the inp_flags2, the new stack should set * the inp_flags2 to what it supports. The old stack in its * fini() function should call the tcp_handle_orphaned_packets() @@ -448,7 +452,6 @@ struct tcpcb { tcp_seq gput_seq; /* Outbound measurement seq */ tcp_seq gput_ack; /* Inbound measurement ack */ int32_t t_stats_gput_prev; /* XXXLAS: Prev gput measurement */ - uint32_t t_maxpeakrate; /* max peak rate set by user, bytes/s */ uint32_t t_sndtlppack; /* tail loss probe packets sent */ uint64_t t_sndtlpbyte; /* total tail loss probe bytes sent */ uint64_t t_sndbytes; /* total bytes sent */ @@ -496,10 +499,6 @@ struct tcpcb { uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS]; uint64_t tcp_proc_time[TCP_NUM_CNT_COUNTERS]; #endif -#ifdef TCPPCAP - struct mbufq t_inpkts; /* List of saved input packets. */ - struct mbufq t_outpkts; /* List of saved output packets. */ -#endif }; #endif /* _KERNEL || _WANT_TCPCB */ @@ -529,31 +528,12 @@ typedef enum { /* Minimum map entries limit value, if set */ #define TCP_MIN_MAP_ENTRIES_LIMIT 128 -/* - * TODO: We yet need to brave plowing in - * to tcp_input() and the pru_usrreq() block. - * Right now these go to the old standards which - * are somewhat ok, but in the long term may - * need to be changed. If we do tackle tcp_input() - * then we need to get rid of the tcp_do_segment() - * function below. - */ /* Flags for tcp functions */ #define TCP_FUNC_BEING_REMOVED 0x01 /* Can no longer be referenced */ #define TCP_FUNC_OUTPUT_CANDROP 0x02 /* tfb_tcp_output may ask tcp_drop */ #define TCP_FUNC_DEFAULT_OK 0x04 /* Can be used as default */ /** - * If defining the optional tcp_timers, in the - * tfb_tcp_timer_stop call you must use the - * callout_async_drain() function with the - * tcp_timer_discard callback. You should check - * the return of callout_async_drain() and if 0 - * increment tt_draincnt. Since the timer sub-system - * does not know your callbacks you must provide a - * stop_all function that loops through and calls - * tcp_timer_stop() with each of your defined timers. - * * tfb_tcp_handoff_ok is a mandatory function allowing * to query a stack, if it can take over a tcpcb. * You return 0 to say you can take over and run your stack, @@ -564,13 +544,13 @@ typedef enum { * do is: * a) Make sure that the inp_flags2 is setup correctly * for LRO. There are two flags that the previous - * stack may have set INP_MBUF_ACKCMP and + * stack may have set INP_MBUF_ACKCMP and * INP_SUPPORTS_MBUFQ. If the new stack does not * support these it *should* clear the flags. * b) Make sure that the timers are in the proper * granularity that the stack wants. The stack * should check the t_tmr_granularity field. Currently - * there are two values that it may hold + * there are two values that it may hold * TCP_TMR_GRANULARITY_TICKS and TCP_TMR_GRANULARITY_USEC. * Use the functions tcp_timer_convert(tp, granularity); * to move the timers to the correct format for your stack. @@ -578,14 +558,14 @@ typedef enum { * The new stack may also optionally query the tfb_chg_query * function if the old stack has one. The new stack may ask * for one of three entries and can also state to the old - * stack its support for the INP_MBUF_ACKCMP and + * stack its support for the INP_MBUF_ACKCMP and * INP_SUPPORTS_MBUFQ. This is important since if there are * queued ack's without that statement the old stack will * be forced to discard the queued acks. The requests that * can be made for information by the new stacks are: * * Note also that the tfb_tcp_fb_init() when called can - * determine if a query is needed by looking at the + * determine if a query is needed by looking at the * value passed in the ptr. The ptr is designed to be * set in with any allocated memory, but the address * of the condtion (ptr == &tp->t_fb_ptr) will be @@ -593,17 +573,17 @@ typedef enum { * setup of a tcb (which means no query would be needed). * If, however, the value is not t_fb_ptr, then the caller * is in the middle of a stack switch and is the new stack. - * A query would be appropriate (if the new stack support + * A query would be appropriate (if the new stack support * the query mechanism). * * TCP_QUERY_SENDMAP - Query of outstanding data. * TCP_QUERY_TIMERS_UP - Query about running timers. - * TCP_SUPPORTED_LRO - Declaration in req_param of - * the inp_flags2 supported by + * TCP_SUPPORTED_LRO - Declaration in req_param of + * the inp_flags2 supported by * the new stack. * TCP_QUERY_RACK_TIMES - Enquire about various timestamps * and states the old stack may be in. - * + * * tfb_tcp_fb_fini is changed to add a flag to tell * the old stack if the tcb is being destroyed or * not. A one in the flag means the TCB is being @@ -639,6 +619,8 @@ struct tcp_function_block { void (*tfb_switch_failed)(struct tcpcb *); bool (*tfb_early_wake_check)(struct tcpcb *); int (*tfb_compute_pipe)(struct tcpcb *tp); + int (*tfb_stack_info)(struct tcpcb *tp, struct stack_specific_info *); + void (*tfb_inherit)(struct tcpcb *tp, struct inpcb *h_inp); volatile uint32_t tfb_refcnt; uint32_t tfb_flags; uint8_t tfb_id; @@ -807,7 +789,7 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack) #define TF_TSO 0x01000000 /* TSO enabled on this connection */ #define TF_TOE 0x02000000 /* this connection is offloaded */ #define TF_CLOSED 0x04000000 /* close(2) called on socket */ -#define TF_UNUSED1 0x08000000 /* unused */ +#define TF_SENTSYN 0x08000000 /* At least one syn has been sent */ #define TF_LRD 0x10000000 /* Lost Retransmission Detection */ #define TF_CONGRECOVERY 0x20000000 /* congestion recovery mode */ #define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */ @@ -825,14 +807,6 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack) #define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY) #define EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY) -#if defined(_KERNEL) -#if !defined(TCP_RFC7413) -#define IS_FASTOPEN(t_flags) (false) -#else -#define IS_FASTOPEN(t_flags) (t_flags & TF_FASTOPEN) -#endif -#endif - #define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una) /* @@ -864,6 +838,8 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack) #define TF2_MBUF_QUEUE_READY 0x00020000 /* Inputs can be queued */ #define TF2_DONT_SACK_QUEUE 0x00040000 /* Don't wake on sack */ #define TF2_CANNOT_DO_ECN 0x00080000 /* The stack does not do ECN */ +#define TF2_PROC_SACK_PROHIBIT 0x00100000 /* Due to small MSS size do not process sack's */ +#define TF2_IPSEC_TSO 0x00200000 /* IPSEC + TSO supported */ #define TF2_NO_ISS_CHECK 0x00400000 /* Don't check SEG.ACK against ISS */ /* @@ -902,24 +878,13 @@ struct tcpopt { #define TO_SYN 0x01 /* parse SYN-only options */ struct hc_metrics_lite { /* must stay in sync with hc_metrics */ - uint32_t rmx_mtu; /* MTU for this path */ - uint32_t rmx_ssthresh; /* outbound gateway buffer limit */ - uint32_t rmx_rtt; /* estimated round trip time */ - uint32_t rmx_rttvar; /* estimated rtt variance */ - uint32_t rmx_cwnd; /* congestion window */ - uint32_t rmx_sendpipe; /* outbound delay-bandwidth product */ - uint32_t rmx_recvpipe; /* inbound delay-bandwidth product */ -}; - -/* - * Used by tcp_maxmtu() to communicate interface specific features - * and limits at the time of connection setup. - */ -struct tcp_ifcap { - int ifcap; - u_int tsomax; - u_int tsomaxsegcount; - u_int tsomaxsegsize; + uint32_t hc_mtu; /* MTU for this path */ + uint32_t hc_ssthresh; /* outbound gateway buffer limit */ + uint32_t hc_rtt; /* estimated round trip time */ + uint32_t hc_rttvar; /* estimated rtt variance */ + uint32_t hc_cwnd; /* congestion window */ + uint32_t hc_sendpipe; /* outbound delay-bandwidth product */ + uint32_t hc_recvpipe; /* inbound delay-bandwidth product */ }; #ifndef _NETINET_IN_PCB_H_ @@ -962,9 +927,12 @@ struct in_conninfo; + (tp)->t_rttvar) >> TCP_DELTA_SHIFT) /* - * TCP statistics. - * Many of these should be kept per connection, - * but that's inconvenient at the moment. + * Global (per-VNET) TCP statistics. The below structure represents what we + * export to the userland, but in the kernel we have an array of counter_u64_t + * with as many elements as there are members in the structure. The counters + * shall be increased by TCPSTAT_INC() or KMOD_TCPSTAT_INC(). Adding a new + * counter also requires adding corresponding SDT probes into in_kdtrace.h and + * into in_kdtrace.c. */ struct tcpstat { uint64_t tcps_connattempt; /* connections initiated */ @@ -1050,6 +1018,8 @@ struct tcpstat { uint64_t tcps_sc_zonefail; /* zalloc() failed */ uint64_t tcps_sc_sendcookie; /* SYN cookie sent */ uint64_t tcps_sc_recvcookie; /* SYN cookie received */ + uint64_t tcps_sc_spurcookie; /* SYN cookie spurious, rejected */ + uint64_t tcps_sc_failcookie; /* SYN cookie failed, rejected */ uint64_t tcps_hc_added; /* entry added to hostcache */ uint64_t tcps_hc_bucketoverflow;/* hostcache per bucket limit hit */ @@ -1059,6 +1029,7 @@ struct tcpstat { /* SACK related stats */ uint64_t tcps_sack_recovery_episode; /* SACK recovery episodes */ uint64_t tcps_sack_rexmits; /* SACK rexmit segments */ + uint64_t tcps_sack_rexmits_tso; /* SACK rexmit TSO chunks */ uint64_t tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ uint64_t tcps_sack_rcv_blocks; /* SACK blocks (options) received */ uint64_t tcps_sack_send_blocks; /* SACK blocks (options) sent */ @@ -1120,31 +1091,39 @@ struct tcpstat { uint64_t tcps_rcvghostack; /* received ACK for data never sent */ uint64_t tcps_rcvacktooold; /* received ACK for data too long ago */ - uint64_t _pad[2]; /* 2 TBD placeholder for STABLE */ + + uint64_t _pad[1]; /* 1 TBD placeholder for STABLE */ }; #define tcps_rcvmemdrop tcps_rcvreassfull /* compat */ #ifdef _KERNEL -#define TI_UNLOCKED 1 -#define TI_RLOCKED 2 #include +#include VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */ /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define TCPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)) +#define TCPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(tcp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)); \ + } while (0) #define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1) /* * Kernel module consumers must use this accessor macro. */ void kmod_tcpstat_add(int statnum, int val); -#define KMOD_TCPSTAT_ADD(name, val) \ - kmod_tcpstat_add(offsetof(struct tcpstat, name) / sizeof(uint64_t), val) +#define KMOD_TCPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(tcp, count, name, (val)); \ + kmod_tcpstat_add(offsetof(struct tcpstat, name) / \ + sizeof(uint64_t), \ + val); \ + } while (0) #define KMOD_TCPSTAT_INC(name) KMOD_TCPSTAT_ADD(name, 1) /* @@ -1260,6 +1239,9 @@ struct tcp_function_info { #define TCPCTL_SACK 14 /* Selective Acknowledgement,rfc 2018 */ #define TCPCTL_DROP 15 /* drop tcp connection */ #define TCPCTL_STATES 16 /* connection counts by TCP state */ +#define TCPCTL_KTLSLIST 17 /* connections with active ktls + session */ +#define TCPCTL_KTLSLIST_WKEYS 18 /* KTLSLIST with key data exported */ #ifdef _KERNEL #ifdef SYSCTL_DECL @@ -1283,6 +1265,7 @@ VNET_DECLARE(uint32_t, tcp_ack_war_time_window); VNET_DECLARE(int, tcp_autorcvbuf_max); VNET_DECLARE(int, tcp_autosndbuf_inc); VNET_DECLARE(int, tcp_autosndbuf_max); +VNET_DECLARE(int, tcp_bind_all_fibs); VNET_DECLARE(int, tcp_delack_enabled); VNET_DECLARE(int, tcp_do_autorcvbuf); VNET_DECLARE(int, tcp_do_autosndbuf); @@ -1317,6 +1300,7 @@ VNET_DECLARE(int, tcp_retries); VNET_DECLARE(int, tcp_sack_globalholes); VNET_DECLARE(int, tcp_sack_globalmaxholes); VNET_DECLARE(int, tcp_sack_maxholes); +VNET_DECLARE(int, tcp_sack_tso); VNET_DECLARE(int, tcp_sc_rst_sock_fail); VNET_DECLARE(int, tcp_sendspace); VNET_DECLARE(int, tcp_udp_tunneling_overhead); @@ -1335,6 +1319,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo); #define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max) #define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc) #define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max) +#define V_tcp_bind_all_fibs VNET(tcp_bind_all_fibs) #define V_tcp_delack_enabled VNET(tcp_delack_enabled) #define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf) #define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf) @@ -1366,6 +1351,7 @@ VNET_DECLARE(struct inpcbinfo, tcbinfo); #define V_tcp_sack_globalholes VNET(tcp_sack_globalholes) #define V_tcp_sack_globalmaxholes VNET(tcp_sack_globalmaxholes) #define V_tcp_sack_maxholes VNET(tcp_sack_maxholes) +#define V_tcp_sack_tso VNET(tcp_sack_tso) #define V_tcp_sc_rst_sock_fail VNET(tcp_sc_rst_sock_fail) #define V_tcp_sendspace VNET(tcp_sendspace) #define V_tcp_udp_tunneling_overhead VNET(tcp_udp_tunneling_overhead) @@ -1393,8 +1379,7 @@ int tcp_reass(struct tcpcb *, struct tcphdr *, tcp_seq *, int *, void tcp_reass_global_init(void); void tcp_reass_flush(struct tcpcb *); void tcp_dooptions(struct tcpopt *, u_char *, int, int); -void tcp_dropwithreset(struct mbuf *, struct tcphdr *, - struct tcpcb *, int, int); +void tcp_dropwithreset(struct mbuf *, struct tcphdr *, struct tcpcb *, int); void tcp_pulloutofband(struct socket *, struct tcphdr *, struct mbuf *, int); void tcp_xmit_timer(struct tcpcb *, int); @@ -1447,24 +1432,23 @@ extern counter_u64_t tcp_comp_total; extern counter_u64_t tcp_uncomp_total; extern counter_u64_t tcp_bad_csums; -#ifdef TCP_SAD_DETECTION -/* Various SACK attack thresholds */ -extern int32_t tcp_force_detection; -extern int32_t tcp_sad_limit; -extern int32_t tcp_sack_to_ack_thresh; -extern int32_t tcp_sack_to_move_thresh; -extern int32_t tcp_restoral_thresh; -extern int32_t tcp_sad_decay_val; -extern int32_t tcp_sad_pacing_interval; -extern int32_t tcp_sad_low_pps; -extern int32_t tcp_map_minimum; -extern int32_t tcp_attack_on_turns_on_logging; -#endif extern uint32_t tcp_ack_war_time_window; extern uint32_t tcp_ack_war_cnt; +/* + * Used by tcp_maxmtu() to communicate interface specific features + * and limits at the time of connection setup. + */ +struct tcp_ifcap { + int ifcap; + u_int tsomax; + u_int tsomaxsegcount; + u_int tsomaxsegsize; + bool ipsec_tso; +}; uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *); uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *); + void tcp6_use_min_mtu(struct tcpcb *); u_int tcp_maxseg(const struct tcpcb *); u_int tcp_fixed_maxseg(const struct tcpcb *); @@ -1478,6 +1462,7 @@ int tcp_default_output(struct tcpcb *); void tcp_state_change(struct tcpcb *, int); void tcp_respond(struct tcpcb *, void *, struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, uint16_t); +bool tcp_challenge_ack_check(sbintime_t *, uint32_t *); void tcp_send_challenge_ack(struct tcpcb *, struct tcphdr *, struct mbuf *); bool tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *, struct mbuf *, int); @@ -1497,10 +1482,10 @@ void tcp_hc_init(void); #ifdef VIMAGE void tcp_hc_destroy(void); #endif -void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *); -uint32_t tcp_hc_getmtu(struct in_conninfo *); -void tcp_hc_updatemtu(struct in_conninfo *, uint32_t); -void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *); +void tcp_hc_get(const struct in_conninfo *, struct hc_metrics_lite *); +uint32_t tcp_hc_getmtu(const struct in_conninfo *); +void tcp_hc_updatemtu(const struct in_conninfo *, uint32_t); +void tcp_hc_update(const struct in_conninfo *, struct hc_metrics_lite *); void cc_after_idle(struct tcpcb *tp); extern struct protosw tcp_protosw; /* shared for TOE */ @@ -1513,14 +1498,17 @@ sackstatus_t tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); int tcp_dsack_block_exists(struct tcpcb *); void tcp_update_dsack_list(struct tcpcb *, tcp_seq, tcp_seq); -void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); +void tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, + tcp_seq rcv_lastend); void tcp_clean_dsack_blocks(struct tcpcb *tp); void tcp_clean_sackreport(struct tcpcb *tp); int tcp_sack_adjust(struct tcpcb *tp); struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); -void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *, sackstatus_t); +void tcp_do_prr_ack(struct tcpcb *, struct tcphdr *, struct tcpopt *, + sackstatus_t, u_int *); void tcp_lost_retransmission(struct tcpcb *, struct tcphdr *); -void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); +void tcp_sack_partialack(struct tcpcb *, struct tcphdr *, u_int *); +void tcp_resend_sackholes(struct tcpcb *tp); void tcp_free_sackholes(struct tcpcb *tp); void tcp_sack_lost_retransmission(struct tcpcb *, struct tcphdr *); int tcp_newreno(struct tcpcb *, struct tcphdr *); @@ -1530,6 +1518,8 @@ void tcp_sndbuf_autoscale(struct tcpcb *, struct socket *, uint32_t); int tcp_stats_sample_rollthedice(struct tcpcb *tp, void *seed_bytes, size_t seed_len); int tcp_can_enable_pacing(void); +int tcp_incr_dgp_pacing_cnt(void); +void tcp_dec_dgp_pacing_cnt(void); void tcp_decrement_paced_conn(void); void tcp_change_time_units(struct tcpcb *, int); void tcp_handle_orphaned_packets(struct tcpcb *); @@ -1598,19 +1588,6 @@ tcp_fields_to_net(struct tcphdr *th) th->th_win = htons(th->th_win); th->th_urp = htons(th->th_urp); } - -static inline uint16_t -tcp_get_flags(const struct tcphdr *th) -{ - return (((uint16_t)th->th_x2 << 8) | th->th_flags); -} - -static inline void -tcp_set_flags(struct tcphdr *th, uint16_t flags) -{ - th->th_x2 = (flags >> 8) & 0x0f; - th->th_flags = flags & 0xff; -} #endif /* _KERNEL */ #endif /* _NETINET_TCP_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netinet/tcpip.h b/lib/libc/include/generic-freebsd/netinet/tcpip.h index 118e0cc281198028baaef8e09d4d843f0a50d383..943d6540dc81cf5e7f50d61fc9d8d22e0e4825db 100644 --- a/lib/libc/include/generic-freebsd/netinet/tcpip.h +++ b/lib/libc/include/generic-freebsd/netinet/tcpip.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcpip.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_TCPIP_H_ diff --git a/lib/libc/include/generic-freebsd/netinet/toecore.h b/lib/libc/include/generic-freebsd/netinet/toecore.h index f37983312f1aa50d889a62a2a3d0381a43d127b1..7986dc698e044f2e251b0fee4247df1eb3605e05 100644 --- a/lib/libc/include/generic-freebsd/netinet/toecore.h +++ b/lib/libc/include/generic-freebsd/netinet/toecore.h @@ -36,6 +36,7 @@ #include #include +struct tcpcb; struct tcpopt; struct tcphdr; struct in_conninfo; @@ -65,7 +66,7 @@ struct toedev { void (*tod_input)(struct toedev *, struct tcpcb *, struct mbuf *); /* - * This is called by the kernel during pru_rcvd for an offloaded TCP + * This is called by the kernel during pr_rcvd() for an offloaded TCP * connection and provides an opportunity for the TOE driver to manage * its rx window and credits. */ diff --git a/lib/libc/include/generic-freebsd/netinet/udp.h b/lib/libc/include/generic-freebsd/netinet/udp.h index df34acd49736832995c4b70bc69c86a0166cbf71..1b28518c0a91bfc891b0e4b32b9ef498ad07b29a 100644 --- a/lib/libc/include/generic-freebsd/netinet/udp.h +++ b/lib/libc/include/generic-freebsd/netinet/udp.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)udp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_UDP_H_ @@ -46,7 +44,7 @@ struct udphdr { u_short uh_dport; /* destination port */ u_short uh_ulen; /* udp length */ u_short uh_sum; /* udp checksum */ -}; +} __packed; /* * User-settable options (used with setsockopt). diff --git a/lib/libc/include/generic-freebsd/netinet/udp_var.h b/lib/libc/include/generic-freebsd/netinet/udp_var.h index d97804a02f1c9471628234d226367a52a05fb572..87896e78ad8da7d79dc550168616d44d548dfaac 100644 --- a/lib/libc/include/generic-freebsd/netinet/udp_var.h +++ b/lib/libc/include/generic-freebsd/netinet/udp_var.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_UDP_VAR_H_ @@ -95,6 +93,7 @@ struct udpstat { #ifdef _KERNEL #include #include +#include struct mbuf; typedef bool udp_tun_func_t(struct mbuf *, int, struct inpcb *, @@ -121,7 +120,7 @@ struct udpcb { void *u_tun_ctx; /* Tunneling callback context. */ }; -#define intoudpcb(ip) __containerof((inp), struct udpcb, u_inpcb) +#define intoudpcb(ip) __containerof((ip), struct udpcb, u_inpcb) #define sotoudpcb(so) (intoudpcb(sotoinpcb(so))) VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat); @@ -129,18 +128,26 @@ VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat); * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define UDPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val)) -#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1) +#define UDPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(udp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val)); \ + } while (0) +#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1) /* * Kernel module consumers must use this accessor macro. */ void kmod_udpstat_inc(int statnum); -#define KMOD_UDPSTAT_INC(name) \ - kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(uint64_t)) +#define KMOD_UDPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(udp, count, name, 1); \ + kmod_udpstat_inc( \ + offsetof(struct udpstat, name) / sizeof(uint64_t)); \ + } while (0) SYSCTL_DECL(_net_inet_udp); +SYSCTL_DECL(_net_inet_udplite); VNET_DECLARE(struct inpcbinfo, udbinfo); VNET_DECLARE(struct inpcbinfo, ulitecbinfo); @@ -149,13 +156,15 @@ VNET_DECLARE(struct inpcbinfo, ulitecbinfo); extern u_long udp_sendspace; extern u_long udp_recvspace; -VNET_DECLARE(int, udp_cksum); +VNET_DECLARE(int, udp_bind_all_fibs); VNET_DECLARE(int, udp_blackhole); VNET_DECLARE(bool, udp_blackhole_local); +VNET_DECLARE(int, udp_cksum); VNET_DECLARE(int, udp_log_in_vain); -#define V_udp_cksum VNET(udp_cksum) +#define V_udp_bind_all_fibs VNET(udp_bind_all_fibs) #define V_udp_blackhole VNET(udp_blackhole) #define V_udp_blackhole_local VNET(udp_blackhole_local) +#define V_udp_cksum VNET(udp_cksum) #define V_udp_log_in_vain VNET(udp_log_in_vain) VNET_DECLARE(int, zero_checksum_port); @@ -170,7 +179,7 @@ udp_get_inpcbinfo(int protocol) int udp_ctloutput(struct socket *, struct sockopt *); void udplite_input(struct mbuf *, int); struct inpcb *udp_notify(struct inpcb *inp, int errno); -int udp_shutdown(struct socket *so); +int udp_shutdown(struct socket *, enum shutdown_how); int udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, udp_tun_icmp_t i, void *ctx); diff --git a/lib/libc/include/generic-freebsd/netinet6/in6.h b/lib/libc/include/generic-freebsd/netinet6/in6.h index 3a4c4a9606c66a7d3dec5f6ac7c6b993cc7731f0..81e5c27aeefcb50472588195eed42d11c5b3d80e 100644 --- a/lib/libc/include/generic-freebsd/netinet6/in6.h +++ b/lib/libc/include/generic-freebsd/netinet6/in6.h @@ -58,8 +58,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in.h 8.3 (Berkeley) 1/3/94 */ #ifndef __KAME_NETINET_IN_H_INCLUDED_ @@ -360,11 +358,11 @@ extern const struct in6_addr in6addr_linklocal_allv2routers; #define IFA6_IS_DEPRECATED(a) \ ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \ - (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ + (u_int32_t)((time_uptime - (a)->ia6_updatetime)) >= \ (a)->ia6_lifetime.ia6t_pltime) #define IFA6_IS_INVALID(a) \ ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \ - (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \ + (u_int32_t)((time_uptime - (a)->ia6_updatetime)) >= \ (a)->ia6_lifetime.ia6t_vltime) #endif /* _KERNEL */ @@ -666,6 +664,8 @@ struct ip6_hdr; int in6_cksum(struct mbuf *, uint8_t, uint32_t, uint32_t); int in6_cksum_partial(struct mbuf *, uint8_t, uint32_t, uint32_t, uint32_t); +int in6_cksum_partial_l2(struct mbuf *m, uint8_t nxt, uint32_t off_l3, + uint32_t off_l4, uint32_t len, uint32_t cov); int in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t); int in6_localaddr(struct in6_addr *); @@ -679,11 +679,10 @@ extern void in6_if_up(struct ifnet *); struct sockaddr; void in6_sin6_2_sin(struct sockaddr_in *sin, - struct sockaddr_in6 *sin6); -void in6_sin_2_v4mapsin6(struct sockaddr_in *sin, - struct sockaddr_in6 *sin6); + const struct sockaddr_in6 *sin6); +void in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, + struct sockaddr_in6 *sin6); void in6_sin6_2_sin_in_sock(struct sockaddr *nam); -void in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam); extern void addrsel_policy_init(void); #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) diff --git a/lib/libc/include/generic-freebsd/netinet6/in6_ifattach.h b/lib/libc/include/generic-freebsd/netinet6/in6_ifattach.h index b0f53ce7b1bf18ee66f6e75d2b8cea3e31e2dcff..7fd7255ced564b72e39d5526fa1e56dd9d5188a5 100644 --- a/lib/libc/include/generic-freebsd/netinet6/in6_ifattach.h +++ b/lib/libc/include/generic-freebsd/netinet6/in6_ifattach.h @@ -39,7 +39,6 @@ void in6_ifattach(struct ifnet *, struct ifnet *); void in6_ifattach_destroy(void); void in6_ifdetach(struct ifnet *); void in6_ifdetach_destroy(struct ifnet *); -int in6_get_tmpifid(struct ifnet *, u_int8_t *, const u_int8_t *, int); void in6_tmpaddrtimer(void *); int in6_get_hw_ifid(struct ifnet *, struct in6_addr *); int in6_nigroup(struct ifnet *, const char *, int, struct in6_addr *); diff --git a/lib/libc/include/generic-freebsd/netinet6/in6_pcb.h b/lib/libc/include/generic-freebsd/netinet6/in6_pcb.h index 3d14852ef6a092b47ebf90cecc321a9ca37c2e55..a2b767a3a99f6e390d8ecaa9273c39178f607084 100644 --- a/lib/libc/include/generic-freebsd/netinet6/in6_pcb.h +++ b/lib/libc/include/generic-freebsd/netinet6/in6_pcb.h @@ -58,8 +58,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET6_IN6_PCB_H_ @@ -72,40 +70,30 @@ void in6_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); void in6_losing(struct inpcb *); -int in6_pcbbind(struct inpcb *, struct sockaddr_in6 *, struct ucred *); +int in6_pcbbind(struct inpcb *, struct sockaddr_in6 *, int, struct ucred *); int in6_pcbconnect(struct inpcb *, struct sockaddr_in6 *, struct ucred *, bool); void in6_pcbdisconnect(struct inpcb *); -struct inpcb * - in6_pcblookup_local(struct inpcbinfo *, - struct in6_addr *, u_short, int, - struct ucred *); -struct inpcb * - in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, +struct inpcb *in6_pcblookup_local(struct inpcbinfo *, const struct in6_addr *, + u_short, int, int, struct ucred *); +struct inpcb *in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, const struct in6_addr *faddr, u_int fport_arg, const struct in6_addr *laddr, u_int lport_arg, - int lookupflags, uint8_t); -struct inpcb * - in6_pcblookup(struct inpcbinfo *, struct in6_addr *, - u_int, struct in6_addr *, u_int, int, - struct ifnet *); -struct inpcb * - in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *, - u_int, struct in6_addr *, u_int, int, - struct ifnet *ifp, struct mbuf *); + int lookupflags, uint8_t numa_domain, int fib); +struct inpcb *in6_pcblookup(struct inpcbinfo *, const struct in6_addr *, u_int, + const struct in6_addr *, u_int, int, struct ifnet *); +struct inpcb *in6_pcblookup_mbuf(struct inpcbinfo *, const struct in6_addr *, + u_int, const struct in6_addr *, u_int, int, struct ifnet *ifp, + struct mbuf *); void in6_pcbnotify(struct inpcbinfo *, struct sockaddr_in6 *, u_int, const struct sockaddr_in6 *, u_int, int, void *, struct inpcb *(*)(struct inpcb *, int)); struct inpcb * in6_rtchange(struct inpcb *, int); -struct sockaddr * - in6_sockaddr(in_port_t port, struct in6_addr *addr_p); -struct sockaddr * - in6_v4mapsin6_sockaddr(in_port_t port, struct in_addr *addr_p); -int in6_getpeeraddr(struct socket *so, struct sockaddr **nam); -int in6_getsockaddr(struct socket *so, struct sockaddr **nam); -int in6_mapped_sockaddr(struct socket *so, struct sockaddr **nam); -int in6_mapped_peeraddr(struct socket *so, struct sockaddr **nam); +int in6_getpeeraddr(struct socket *, struct sockaddr *); +int in6_getsockaddr(struct socket *, struct sockaddr *); +int in6_mapped_sockaddr(struct socket *, struct sockaddr *); +int in6_mapped_peeraddr(struct socket *, struct sockaddr *); int in6_selecthlim(struct inpcb *, struct ifnet *); int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct ucred *); void init_sin6(struct sockaddr_in6 *sin6, struct mbuf *m, int); diff --git a/lib/libc/include/generic-freebsd/netinet6/in6_var.h b/lib/libc/include/generic-freebsd/netinet6/in6_var.h index 2740316f1eeb892348cdadb68db59d168389efd3..82e644d1b3262a47762d1622a8366b29e88e673c 100644 --- a/lib/libc/include/generic-freebsd/netinet6/in6_var.h +++ b/lib/libc/include/generic-freebsd/netinet6/in6_var.h @@ -58,8 +58,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)in_var.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET6_IN6_VAR_H_ @@ -117,7 +115,7 @@ struct in6_ifextra { SLIST_HEAD(in6_multi_head, in6_multi); MALLOC_DECLARE(M_IP6MADDR); -struct in6_ifaddr { +struct in6_ifaddr { struct ifaddr ia_ifa; /* protocol-independent info */ #define ia_ifp ia_ifa.ifa_ifp #define ia_flags ia_ifa.ifa_flags @@ -325,8 +323,7 @@ struct in6_prflags { struct prf_ra { u_char onlink : 1; u_char autonomous : 1; - u_char ra_derived: 1; - u_char reserved : 5; + u_char reserved : 6; } prf_ra; u_char prf_reserved1; u_short prf_reserved2; @@ -357,7 +354,6 @@ struct in6_prefixreq { #define ipr_raf_onlink ipr_flags.prf_ra.onlink #define ipr_raf_auto ipr_flags.prf_ra.autonomous -#define ipr_raf_ra_derived ipr_flags.prf_ra.ra_derived #define ipr_statef_onlink ipr_flags.prf_state.onlink @@ -551,9 +547,6 @@ do { \ ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \ offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\ } while (/*CONSTCOND*/ 0) - -VNET_DECLARE(unsigned long, in6_maxmtu); -#define V_in6_maxmtu VNET(in6_maxmtu) #endif /* _KERNEL */ /* @@ -877,7 +870,6 @@ void in6_domifdetach(struct ifnet *, void *); int in6_domifmtu(struct ifnet *); struct rib_head *in6_inithead(uint32_t fibnum); void in6_detachhead(struct rib_head *rh); -void in6_setmaxmtu(void); int in6_if2idlen(struct ifnet *); struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int); struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, const struct in6_addr *); diff --git a/lib/libc/include/generic-freebsd/netinet6/ip6_var.h b/lib/libc/include/generic-freebsd/netinet6/ip6_var.h index 22483ca5c4a3f35d4c03103d3b408c809922bd6e..bca6d8c5cccd8f672caddcdcaf7babd0eda46ee1 100644 --- a/lib/libc/include/generic-freebsd/netinet6/ip6_var.h +++ b/lib/libc/include/generic-freebsd/netinet6/ip6_var.h @@ -58,8 +58,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ip_var.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET6_IP6_VAR_H_ @@ -132,27 +130,26 @@ struct ip6po_nhinfo { #define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop #define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route +/* + * Note that fields with valid data must be flagged in ip6po_valid. + * This is done to reduce cache misses in ip6_output(). Before + * ip6po_valid, ip6_output needed to check all the individual fields + * of ip6_pktopts needed to be checked themselves, and they are spread + * across 4 cachelines. ip6_output() is currently the only consumer of + * these flags, as it is in the critical path of every packet sent. + */ struct ip6_pktopts { - struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ + uint32_t ip6po_valid; +#define IP6PO_VALID_HLIM 0x0001 +#define IP6PO_VALID_PKTINFO 0x0002 +#define IP6PO_VALID_NHINFO 0x0004 +#define IP6PO_VALID_HBH 0x0008 +#define IP6PO_VALID_DEST1 0x0010 +#define IP6PO_VALID_RHINFO 0x0020 +#define IP6PO_VALID_DEST2 0x0040 +#define IP6PO_VALID_TC 0x0080 + int ip6po_hlim; /* Hoplimit for outgoing packets */ - - /* Outgoing IF/address information */ - struct in6_pktinfo *ip6po_pktinfo; - - /* Next-hop address information */ - struct ip6po_nhinfo ip6po_nhinfo; - - struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ - - /* Destination options header (before a routing header) */ - struct ip6_dest *ip6po_dest1; - - /* Routing header related info. */ - struct ip6po_rhinfo ip6po_rhinfo; - - /* Destination options header (after a routing header) */ - struct ip6_dest *ip6po_dest2; - int ip6po_tclass; /* traffic class */ int ip6po_minmtu; /* fragment vs PMTU discovery policy */ @@ -173,6 +170,25 @@ struct ip6_pktopts { #endif #define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */ #define IP6PO_USECOA 0x08 /* use care of address */ + + struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */ + + /* Outgoing IF/address information */ + struct in6_pktinfo *ip6po_pktinfo; + + /* Next-hop address information */ + struct ip6po_nhinfo ip6po_nhinfo; + + struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */ + + /* Destination options header (before a routing header) */ + struct ip6_dest *ip6po_dest1; + + /* Routing header related info. */ + struct ip6po_rhinfo ip6po_rhinfo; + + /* Destination options header (after a routing header) */ + struct ip6_dest *ip6po_dest2; }; /* @@ -247,13 +263,22 @@ struct ip6stat { #ifdef _KERNEL #include +#include VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat); -#define IP6STAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)) -#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val)) +#define IP6STAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ip6, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)); \ + } while (0) +#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val)) #define IP6STAT_INC(name) IP6STAT_ADD(name, 1) -#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1) +#define IP6STAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(ip6, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, 1); \ + } while (0) +#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1) #endif #ifdef _KERNEL @@ -389,7 +414,7 @@ int route6_input(struct mbuf **, int *, int); void frag6_init(void); void frag6_destroy(void); int frag6_input(struct mbuf **, int *, int); -void frag6_drain(void); +void frag6_drain(void *, int); void rip6_init(void); int rip6_ctloutput(struct socket *, struct sockopt *); diff --git a/lib/libc/include/generic-freebsd/netinet6/ip_fw_nat64.h b/lib/libc/include/generic-freebsd/netinet6/ip_fw_nat64.h index c12eee7082cfb605ad79a6d14f1f518ebcbac909..944ac5fc2f8afeb2ed661c6e1c303542353c1259 100644 --- a/lib/libc/include/generic-freebsd/netinet6/ip_fw_nat64.h +++ b/lib/libc/include/generic-freebsd/netinet6/ip_fw_nat64.h @@ -84,9 +84,9 @@ struct ipfw_nat64lsn_stats { uint64_t spgcreated; /* Number of portgroups created */ uint64_t spgdeleted; /* Number of portgroups deleted */ uint64_t hostcount; /* Number of hosts */ - uint64_t tcpchunks; /* Number of TCP chunks */ - uint64_t udpchunks; /* Number of UDP chunks */ - uint64_t icmpchunks; /* Number of ICMP chunks */ + uint64_t tcpchunks; /* Number of TCP portgroups */ + uint64_t udpchunks; /* Number of UDP portgroups */ + uint64_t icmpchunks; /* Number of ICMP portgroups */ uint64_t _reserved[4]; }; @@ -95,6 +95,10 @@ struct ipfw_nat64lsn_stats { #define NAT64_ALLOW_PRIVATE 0x0002 /* Allow private IPv4 address * translation */ +#define NAT64LSN_ALLOW_SWAPCONF 0x0004 /* Allow configuration exchange + * between NAT64LSN instances + * during the sets swapping. + */ typedef struct _ipfw_nat64stl_cfg { char name[64]; /* NAT name */ ipfw_obj_ntlv ntlv6; /* object name tlv */ diff --git a/lib/libc/include/generic-freebsd/netinet6/nd6.h b/lib/libc/include/generic-freebsd/netinet6/nd6.h index 129ef7bbd47feaa2a4e7b34bf994755789ad1afd..316fc6ff4e7734779cf27bcd855390655977eeac 100644 --- a/lib/libc/include/generic-freebsd/netinet6/nd6.h +++ b/lib/libc/include/generic-freebsd/netinet6/nd6.h @@ -184,10 +184,10 @@ struct in6_ndifreq { #define RETRANS_TIMER 1000 /* msec */ #define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */ #define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */ -#define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */ +#define DEF_TEMP_VALID_LIFETIME 172800 /* 2 days */ #define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */ #define TEMPADDR_REGEN_ADVANCE 5 /* sec */ -#define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */ +#define TEMP_MAX_DESYNC_FACTOR_BASE 300 /* 5 min */ #define ND_COMPUTE_RTIME(x) \ (((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \ ((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000) @@ -242,7 +242,6 @@ struct nd_prefix { #define ndpr_raf ndpr_flags #define ndpr_raf_onlink ndpr_flags.onlink #define ndpr_raf_auto ndpr_flags.autonomous -#define ndpr_raf_ra_derived ndpr_flags.ra_derived #define ndpr_raf_router ndpr_flags.router struct nd_pfxrouter { @@ -293,11 +292,13 @@ VNET_DECLARE(struct mtx, nd6_onlink_mtx); /* nd6_rtr.c */ VNET_DECLARE(int, nd6_defifindex); VNET_DECLARE(int, ip6_desync_factor); /* seconds */ +VNET_DECLARE(uint32_t, ip6_temp_max_desync_factor); /* seconds */ VNET_DECLARE(u_int32_t, ip6_temp_preferred_lifetime); /* seconds */ VNET_DECLARE(u_int32_t, ip6_temp_valid_lifetime); /* seconds */ VNET_DECLARE(int, ip6_temp_regen_advance); /* seconds */ #define V_nd6_defifindex VNET(nd6_defifindex) #define V_ip6_desync_factor VNET(ip6_desync_factor) +#define V_ip6_temp_max_desync_factor VNET(ip6_temp_max_desync_factor) #define V_ip6_temp_preferred_lifetime VNET(ip6_temp_preferred_lifetime) #define V_ip6_temp_valid_lifetime VNET(ip6_temp_valid_lifetime) #define V_ip6_temp_regen_advance VNET(ip6_temp_regen_advance) diff --git a/lib/libc/include/generic-freebsd/netinet6/tcp6_var.h b/lib/libc/include/generic-freebsd/netinet6/tcp6_var.h index 5759b7f60f4dbf5e37d02b16b794ee9468f9dfa3..d4262f934a44475d377942e52e875a6f2145f8ac 100644 --- a/lib/libc/include/generic-freebsd/netinet6/tcp6_var.h +++ b/lib/libc/include/generic-freebsd/netinet6/tcp6_var.h @@ -56,8 +56,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 */ #ifndef _NETINET_TCP6_VAR_H_ diff --git a/lib/libc/include/generic-freebsd/netinet6/udp6_var.h b/lib/libc/include/generic-freebsd/netinet6/udp6_var.h index 150e11189522ab10c3fd010a0cdb3ed2e31e452f..e9a76f97ae93f61f7e3091f7aba7c385377915b6 100644 --- a/lib/libc/include/generic-freebsd/netinet6/udp6_var.h +++ b/lib/libc/include/generic-freebsd/netinet6/udp6_var.h @@ -57,8 +57,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET6_UDP6_VAR_H_ diff --git a/lib/libc/include/generic-freebsd/netipsec/ah_var.h b/lib/libc/include/generic-freebsd/netipsec/ah_var.h index 8bba4f40a212b31bef462058a24d62dfe109bbc6..1aea0fb6ab1f307a1e49623e626a46a486bc9723 100644 --- a/lib/libc/include/generic-freebsd/netipsec/ah_var.h +++ b/lib/libc/include/generic-freebsd/netipsec/ah_var.h @@ -71,13 +71,22 @@ struct ahstat { #ifdef _KERNEL #include +#include VNET_DECLARE(int, ah_enable); VNET_DECLARE(int, ah_cleartos); VNET_PCPUSTAT_DECLARE(struct ahstat, ahstat); -#define AHSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name , (val)) +#define AHSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ah, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name, (val)); \ + } while (0) +#define AHSTAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(ah, count, name, 1, (type)); \ + VNET_PCPUSTAT_ADD(struct ahstat, ahstat, name[type], 1); \ + } while (0) #define AHSTAT_INC(name) AHSTAT_ADD(name, 1) #define V_ah_enable VNET(ah_enable) #define V_ah_cleartos VNET(ah_cleartos) diff --git a/lib/libc/include/generic-freebsd/netipsec/esp_var.h b/lib/libc/include/generic-freebsd/netipsec/esp_var.h index cbd27ab35be942dc7ab0dd25429c4bac5c0c8bb5..64115b4ab2c82292e9609c74693a3a13293c05a5 100644 --- a/lib/libc/include/generic-freebsd/netipsec/esp_var.h +++ b/lib/libc/include/generic-freebsd/netipsec/esp_var.h @@ -72,13 +72,25 @@ struct espstat { #ifdef _KERNEL #include +#include VNET_DECLARE(int, esp_enable); +VNET_DECLARE(int, esp_ctr_compatibility); +#define V_esp_ctr_compatibility VNET(esp_ctr_compatibility) VNET_PCPUSTAT_DECLARE(struct espstat, espstat); -#define ESPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val)) +#define ESPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(esp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct espstat, espstat, name, (val)); \ + } while (0) #define ESPSTAT_INC(name) ESPSTAT_ADD(name, 1) +#define ESPSTAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(esp, count, name, 1, (type)); \ + VNET_PCPUSTAT_ADD(struct espstat, espstat, name[type], 1); \ + } while (0) + #define V_esp_enable VNET(esp_enable) #endif /* _KERNEL */ #endif /*_NETIPSEC_ESP_VAR_H_*/ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netipsec/ipcomp_var.h b/lib/libc/include/generic-freebsd/netipsec/ipcomp_var.h index 2b50c3accedb6a312b2dd46b4814011ad9bbd77b..7a4e9c13d2172c4f4f0a5c8f1c309e32bc4669f5 100644 --- a/lib/libc/include/generic-freebsd/netipsec/ipcomp_var.h +++ b/lib/libc/include/generic-freebsd/netipsec/ipcomp_var.h @@ -66,12 +66,22 @@ struct ipcompstat { #ifdef _KERNEL #include +#include VNET_DECLARE(int, ipcomp_enable); VNET_PCPUSTAT_DECLARE(struct ipcompstat, ipcompstat); -#define IPCOMPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name, (val)) +#define IPCOMPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ipcomp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name, (val)); \ + } while (0) +#define IPCOMPSTAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(ipcomp, count, name, 1, (type)); \ + VNET_PCPUSTAT_ADD(struct ipcompstat, ipcompstat, name[type], \ + 1); \ + } while (0) #define IPCOMPSTAT_INC(name) IPCOMPSTAT_ADD(name, 1) #define V_ipcomp_enable VNET(ipcomp_enable) #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netipsec/ipsec.h b/lib/libc/include/generic-freebsd/netipsec/ipsec.h index f6a06466be973baf4b61658f92e3a224958984d8..fbd855756a04cb9980ea9c9412aa0a8f5f1a6571 100644 --- a/lib/libc/include/generic-freebsd/netipsec/ipsec.h +++ b/lib/libc/include/generic-freebsd/netipsec/ipsec.h @@ -46,6 +46,9 @@ #include #include #include +#include + +#include #define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m) @@ -71,6 +74,12 @@ struct ipsecrequest { u_int level; /* IPsec level defined below. */ }; +struct ipsec_accel_adddel_sp_tq { + struct vnet *adddel_vnet; + struct task adddel_task; + int adddel_scheduled; +}; + /* Security Policy Data Base */ struct secpolicy { TAILQ_ENTRY(secpolicy) chain; @@ -93,7 +102,7 @@ struct secpolicy { uint32_t id; /* It's unique number on the system. */ /* * lifetime handler. - * the policy can be used without limitiation if both lifetime and + * the policy can be used without limitation if both lifetime and * validtime are zero. * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime. * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime. @@ -102,6 +111,11 @@ struct secpolicy { time_t lastused; /* updated every when kernel sends a packet */ long lifetime; /* duration of the lifetime of this policy */ long validtime; /* duration this policy is valid without use */ + CK_LIST_HEAD(, ifp_handle_sp) accel_ifps; + struct ipsec_accel_adddel_sp_tq accel_add_tq; + struct ipsec_accel_adddel_sp_tq accel_del_tq; + struct inpcb *ipsec_accel_add_sp_inp; + const char *accel_ifname; }; /* @@ -246,6 +260,7 @@ struct ipsecstat { #define IPSECCTL_DEBUG 12 #define IPSECCTL_ESP_RANDPAD 13 #define IPSECCTL_MIN_PMTU 14 +#define IPSECCTL_RANDOM_ID 15 #ifdef _KERNEL #include @@ -279,12 +294,17 @@ VNET_DECLARE(int, ip4_ah_net_deflev); VNET_DECLARE(int, ip4_ipsec_dfbit); VNET_DECLARE(int, ip4_ipsec_min_pmtu); VNET_DECLARE(int, ip4_ipsec_ecn); +VNET_DECLARE(int, ip4_ipsec_random_id); VNET_DECLARE(int, crypto_support); VNET_DECLARE(int, async_crypto); VNET_DECLARE(int, natt_cksum_policy); -#define IPSECSTAT_INC(name) \ - VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1) +#define IPSECSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(ipsec, count, name, 1); \ + VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1); \ + } while (0) + #define V_ip4_esp_trans_deflev VNET(ip4_esp_trans_deflev) #define V_ip4_esp_net_deflev VNET(ip4_esp_net_deflev) #define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev) @@ -292,6 +312,7 @@ VNET_DECLARE(int, natt_cksum_policy); #define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit) #define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu) #define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn) +#define V_ip4_ipsec_random_id VNET(ip4_ipsec_random_id) #define V_crypto_support VNET(crypto_support) #define V_async_crypto VNET(async_crypto) #define V_natt_cksum_policy VNET(natt_cksum_policy) @@ -307,6 +328,7 @@ VNET_DECLARE(int, natt_cksum_policy); #endif struct inpcb; +struct ip; struct m_tag; struct secasvar; struct sockopt; @@ -318,7 +340,7 @@ int ipsec_if_input(struct mbuf *, struct secasvar *, uint32_t); struct ipsecrequest *ipsec_newisr(void); void ipsec_delisr(struct ipsecrequest *); struct secpolicy *ipsec4_checkpolicy(const struct mbuf *, struct inpcb *, - int *, int); + struct ip *, int *, int); u_int ipsec_get_reqlevel(struct secpolicy *, u_int); @@ -333,27 +355,32 @@ size_t ipsec_hdrsiz_internal(struct secpolicy *); void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int); -void ipsec4_setsockaddrs(const struct mbuf *, union sockaddr_union *, - union sockaddr_union *); +void ipsec4_setsockaddrs(const struct mbuf *, const struct ip *, + union sockaddr_union *, union sockaddr_union *); int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int); -int ipsec4_check_pmtu(struct mbuf *, struct secpolicy *, int); -int ipsec4_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *); +int ipsec4_check_pmtu(struct ifnet *, struct mbuf *, struct ip *ip1, + struct secpolicy *, int); +int ipsec4_process_packet(struct ifnet *, struct mbuf *, struct ip *ip1, + struct secpolicy *, struct inpcb *, u_long); int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *, u_int); -extern void m_checkalignment(const char* where, struct mbuf *m0, - int off, int len); -extern struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off); -extern caddr_t m_pad(struct mbuf *m, int n); -extern int m_striphdr(struct mbuf *m, int skip, int hlen); +void m_checkalignment(const char* where, struct mbuf *m0, + int off, int len); +struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off); +caddr_t m_pad(struct mbuf *m, int n); +int m_striphdr(struct mbuf *m, int skip, int hlen); + +SYSCTL_DECL(_net_inet_ipsec); +SYSCTL_DECL(_net_inet6_ipsec6); #endif /* _KERNEL */ #ifndef _KERNEL -extern caddr_t ipsec_set_policy(char *, int); -extern int ipsec_get_policylen(caddr_t); -extern char *ipsec_dump_policy(caddr_t, char *); -extern const char *ipsec_strerror(void); +caddr_t ipsec_set_policy(const char *, int); +int ipsec_get_policylen(c_caddr_t); +char *ipsec_dump_policy(c_caddr_t, const char *); +const char *ipsec_strerror(void); #endif /* ! KERNEL */ diff --git a/lib/libc/include/generic-freebsd/netipsec/ipsec6.h b/lib/libc/include/generic-freebsd/netipsec/ipsec6.h index 7c507806205baf0358b00ee78eaeac27c1649650..50854251556ad74854ec5f41e9efc0dc6b30804e 100644 --- a/lib/libc/include/generic-freebsd/netipsec/ipsec6.h +++ b/lib/libc/include/generic-freebsd/netipsec/ipsec6.h @@ -66,8 +66,9 @@ struct secpolicy *ipsec6_checkpolicy(const struct mbuf *, void ipsec6_setsockaddrs(const struct mbuf *, union sockaddr_union *, union sockaddr_union *); int ipsec6_common_input_cb(struct mbuf *, struct secasvar *, int, int); -int ipsec6_check_pmtu(struct mbuf *, struct secpolicy *, int); -int ipsec6_process_packet(struct mbuf *, struct secpolicy *, struct inpcb *); +int ipsec6_check_pmtu(struct ifnet *, struct mbuf *, struct secpolicy *, int); +int ipsec6_process_packet(struct ifnet *, struct mbuf *, struct secpolicy *, + struct inpcb *, u_long); int ip6_ipsec_filtertunnel(struct mbuf *); int ip6_ipsec_pcbctl(struct inpcb *, struct sockopt *); diff --git a/lib/libc/include/generic-freebsd/netipsec/ipsec_offload.h b/lib/libc/include/generic-freebsd/netipsec/ipsec_offload.h new file mode 100644 index 0000000000000000000000000000000000000000..cf570a8e63a2827da615f32f24b777b3d9223f19 --- /dev/null +++ b/lib/libc/include/generic-freebsd/netipsec/ipsec_offload.h @@ -0,0 +1,217 @@ +/*- + * Copyright (c) 2021,2022 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _NETIPSEC_IPSEC_OFFLOAD_H_ +#define _NETIPSEC_IPSEC_OFFLOAD_H_ + +#ifdef _KERNEL +#include +#include +#include +#include + +struct secpolicy; +struct secasvar; +struct inpcb; + +struct ipsec_accel_out_tag { + struct m_tag tag; + uint16_t drv_spi; +}; + +struct ipsec_accel_in_tag { + struct m_tag tag; + struct xform_history xh; /* Must be first to mimic IPSEC_IN_DONE */ + uint16_t drv_spi; +}; + +#define IPSEC_ACCEL_DRV_SPI_BYPASS 2 +#define IPSEC_ACCEL_DRV_SPI_MIN 3 +#define IPSEC_ACCEL_DRV_SPI_MAX 0xffff + +extern void (*ipsec_accel_sa_newkey_p)(struct secasvar *sav); +extern void (*ipsec_accel_sa_install_input_p)(struct secasvar *sav, + const union sockaddr_union *dst_address, int sproto, uint32_t spi); +extern void (*ipsec_accel_forget_sav_p)(struct secasvar *sav); +extern void (*ipsec_accel_spdadd_p)(struct secpolicy *sp, struct inpcb *inp); +extern void (*ipsec_accel_spddel_p)(struct secpolicy *sp); +extern int (*ipsec_accel_sa_lifetime_op_p)(struct secasvar *sav, + struct seclifetime *lft_c, if_t ifp, enum IF_SA_CNT_WHICH op, + struct rm_priotracker *sahtree_trackerp); +extern void (*ipsec_accel_sync_p)(void); +extern bool (*ipsec_accel_is_accel_sav_p)(struct secasvar *sav); +extern struct mbuf *(*ipsec_accel_key_setaccelif_p)(struct secasvar *sav); +extern void (*ipsec_accel_on_ifdown_p)(struct ifnet *ifp); +extern void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +extern int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs); +extern bool (*ipsec_accel_fill_xh_p)(if_t ifp, uint32_t drv_spi, + struct xform_history *xh); + +#ifdef IPSEC_OFFLOAD +/* + * Have to use ipsec_accel_sa_install_input_p indirection because + * key.c is unconditionally included into the static kernel. + */ +static inline void +ipsec_accel_sa_newkey(struct secasvar *sav) +{ + void (*p)(struct secasvar *sav); + + p = atomic_load_ptr(&ipsec_accel_sa_newkey_p); + if (p != NULL) + p(sav); +} + +static inline void +ipsec_accel_forget_sav(struct secasvar *sav) +{ + void (*p)(struct secasvar *sav); + + p = atomic_load_ptr(&ipsec_accel_forget_sav_p); + if (p != NULL) + p(sav); +} + +static inline void +ipsec_accel_spdadd(struct secpolicy *sp, struct inpcb *inp) +{ + void (*p)(struct secpolicy *sp, struct inpcb *inp); + + p = atomic_load_ptr(&ipsec_accel_spdadd_p); + if (p != NULL) + p(sp, inp); +} + +static inline void +ipsec_accel_spddel(struct secpolicy *sp) +{ + void (*p)(struct secpolicy *sp); + + p = atomic_load_ptr(&ipsec_accel_spddel_p); + if (p != NULL) + p(sp); +} + +static inline int +ipsec_accel_sa_lifetime_op(struct secasvar *sav, + struct seclifetime *lft_c, if_t ifp, enum IF_SA_CNT_WHICH op, + struct rm_priotracker *sahtree_trackerp) +{ + int (*p)(struct secasvar *sav, struct seclifetime *lft_c, if_t ifp, + enum IF_SA_CNT_WHICH op, struct rm_priotracker *sahtree_trackerp); + + p = atomic_load_ptr(&ipsec_accel_sa_lifetime_op_p); + if (p != NULL) + return (p(sav, lft_c, ifp, op, sahtree_trackerp)); + return (ENOTSUP); +} + +static inline void +ipsec_accel_sync(void) +{ + void (*p)(void); + + p = atomic_load_ptr(&ipsec_accel_sync_p); + if (p != NULL) + p(); +} + +static inline bool +ipsec_accel_is_accel_sav(struct secasvar *sav) +{ + bool (*p)(struct secasvar *sav); + + p = atomic_load_ptr(&ipsec_accel_is_accel_sav_p); + if (p != NULL) + return (p(sav)); + return (false); +} + +static inline struct mbuf * +ipsec_accel_key_setaccelif(struct secasvar *sav) +{ + struct mbuf *(*p)(struct secasvar *sav); + + p = atomic_load_ptr(&ipsec_accel_key_setaccelif_p); + if (p != NULL) + return (p(sav)); + return (NULL); +} + +static inline bool +ipsec_accel_fill_xh(if_t ifp, uint32_t drv_spi, struct xform_history *xh) +{ + bool (*p)(if_t ifp, uint32_t drv_spi, struct xform_history *xh); + + p = atomic_load_ptr(&ipsec_accel_fill_xh_p); + if (p != NULL) + return (p(ifp, drv_spi, xh)); + return (false); +} + +#else +#define ipsec_accel_sa_newkey(a) +#define ipsec_accel_forget_sav(a) +#define ipsec_accel_spdadd(a, b) +#define ipsec_accel_spddel(a) +#define ipsec_accel_sa_lifetime_op(a, b, c, d, e) +#define ipsec_accel_sync() +#define ipsec_accel_is_accel_sav(a) +#define ipsec_accel_key_setaccelif(a) +#define ipsec_accel_fill_xh(a, b, c) (false) +#endif + +void ipsec_accel_forget_sav_impl(struct secasvar *sav); +void ipsec_accel_spdadd_impl(struct secpolicy *sp, struct inpcb *inp); +void ipsec_accel_spddel_impl(struct secpolicy *sp); + +#ifdef IPSEC_OFFLOAD +int ipsec_accel_input(struct mbuf *m, int offset, int proto); +bool ipsec_accel_output(struct ifnet *ifp, struct mbuf *m, + struct inpcb *inp, struct secpolicy *sp, struct secasvar *sav, int af, + int mtu, int *hwassist); +void ipsec_accel_forget_sav(struct secasvar *sav); +struct xform_history; +#else +#define ipsec_accel_input(a, b, c) (ENXIO) +#define ipsec_accel_output(a, b, c, d, e, f, g, h) ({ \ + *h = 0; \ + false; \ +}) +#define ipsec_accel_forget_sav(a) +#endif + +struct ipsec_accel_in_tag *ipsec_accel_input_tag_lookup(const struct mbuf *); +void ipsec_accel_on_ifdown(struct ifnet *ifp); +void ipsec_accel_drv_sa_lifetime_update(struct secasvar *sav, if_t ifp, + u_int drv_spi, uint64_t octets, uint64_t allocs); +int ipsec_accel_drv_sa_lifetime_fetch(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs); + +#endif /* _KERNEL */ + +#endif /* _NETIPSEC_IPSEC_OFFLOAD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netipsec/ipsec_support.h b/lib/libc/include/generic-freebsd/netipsec/ipsec_support.h index 10b3671cdcc91a92ac1bae9d7ab1d9e4581239f6..2b3fc69c8b46109e87f25a6bf36e072028094927 100644 --- a/lib/libc/include/generic-freebsd/netipsec/ipsec_support.h +++ b/lib/libc/include/generic-freebsd/netipsec/ipsec_support.h @@ -29,6 +29,8 @@ #ifdef _KERNEL #if defined(IPSEC) || defined(IPSEC_SUPPORT) +struct ifnet; +struct ip; struct mbuf; struct inpcb; struct tcphdr; @@ -49,14 +51,17 @@ int ipsec_init_pcbpolicy(struct inpcb *); int ipsec_delete_pcbpolicy(struct inpcb *); int ipsec_copy_pcbpolicy(struct inpcb *, struct inpcb *); -#ifdef INET +#if defined(INET) || defined(INET6) int udp_ipsec_input(struct mbuf *, int, int); int udp_ipsec_pcbctl(struct inpcb *, struct sockopt *); +#endif +#ifdef INET int ipsec4_in_reject(const struct mbuf *, struct inpcb *); +int ipsec4_in_reject1(const struct mbuf *m, struct ip *ip1, struct inpcb *inp); int ipsec4_input(struct mbuf *, int, int); int ipsec4_forward(struct mbuf *); int ipsec4_pcbctl(struct inpcb *, struct sockopt *); -int ipsec4_output(struct mbuf *, struct inpcb *); +int ipsec4_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long); int ipsec4_capability(struct mbuf *, u_int); int ipsec4_ctlinput(ipsec_ctlinput_param_t); #endif /* INET */ @@ -66,7 +71,7 @@ int ipsec6_input(struct mbuf *, int, int); int ipsec6_in_reject(const struct mbuf *, struct inpcb *); int ipsec6_forward(struct mbuf *); int ipsec6_pcbctl(struct inpcb *, struct sockopt *); -int ipsec6_output(struct mbuf *, struct inpcb *); +int ipsec6_output(struct ifnet *, struct mbuf *, struct inpcb *, u_long); int ipsec6_capability(struct mbuf *, u_int); int ipsec6_ctlinput(ipsec_ctlinput_param_t); #endif /* INET6 */ @@ -75,7 +80,8 @@ struct ipsec_methods { int (*input)(struct mbuf *, int, int); int (*check_policy)(const struct mbuf *, struct inpcb *); int (*forward)(struct mbuf *); - int (*output)(struct mbuf *, struct inpcb *); + int (*output)(struct ifnet *, struct mbuf *, struct inpcb *, + u_long); int (*pcbctl)(struct inpcb *, struct sockopt *); size_t (*hdrsize)(struct inpcb *); int (*capability)(struct mbuf *, u_int); @@ -164,10 +170,10 @@ extern const struct ipsec_support * const ipv6_ipsec_support; #define IPSEC_CTLINPUT(proto, param) \ (*(proto ## _ipsec_support)->methods->ctlinput)(param) -#define UDPENCAP_INPUT(m, ...) \ - (*ipv4_ipsec_support->methods->udp_input)(m, __VA_ARGS__) -#define UDPENCAP_PCBCTL(inp, sopt) \ - (*ipv4_ipsec_support->methods->udp_pcbctl)(inp, sopt) +#define UDPENCAP_INPUT(proto, m, ...) \ + (*(proto ## _ipsec_support)->methods->udp_input)(m, __VA_ARGS__) +#define UDPENCAP_PCBCTL(proto, inp, sopt) \ + (*(proto ## _ipsec_support)->methods->udp_pcbctl)(inp, sopt) #elif defined(IPSEC_SUPPORT) struct ipsec_support { @@ -185,8 +191,8 @@ int ipsec_kmod_input(struct ipsec_support * const, struct mbuf *, int, int); int ipsec_kmod_check_policy(struct ipsec_support * const, struct mbuf *, struct inpcb *); int ipsec_kmod_forward(struct ipsec_support * const, struct mbuf *); -int ipsec_kmod_output(struct ipsec_support * const, struct mbuf *, - struct inpcb *); +int ipsec_kmod_output(struct ipsec_support * const, struct ifnet *, + struct mbuf *, struct inpcb *, u_long); int ipsec_kmod_pcbctl(struct ipsec_support * const, struct inpcb *, struct sockopt *); int ipsec_kmod_capability(struct ipsec_support * const, struct mbuf *, u_int); @@ -196,10 +202,10 @@ int ipsec_kmod_udp_input(struct ipsec_support * const, struct mbuf *, int, int); int ipsec_kmod_udp_pcbctl(struct ipsec_support * const, struct inpcb *, struct sockopt *); -#define UDPENCAP_INPUT(m, ...) \ - ipsec_kmod_udp_input(ipv4_ipsec_support, m, __VA_ARGS__) -#define UDPENCAP_PCBCTL(inp, sopt) \ - ipsec_kmod_udp_pcbctl(ipv4_ipsec_support, inp, sopt) +#define UDPENCAP_INPUT(proto, m, ...) \ + ipsec_kmod_udp_input(proto ## _ipsec_support, m, __VA_ARGS__) +#define UDPENCAP_PCBCTL(proto, inp, sopt) \ + ipsec_kmod_udp_pcbctl(proto ## _ipsec_support, inp, sopt) #define IPSEC_INPUT(proto, ...) \ ipsec_kmod_input(proto ## _ipsec_support, __VA_ARGS__) diff --git a/lib/libc/include/generic-freebsd/netipsec/key.h b/lib/libc/include/generic-freebsd/netipsec/key.h index 2bd48a5e242b3cfc47776274e76945d3abf771e1..a191f9208a3b16c3fee30b8331a0fa3cee8f867f 100644 --- a/lib/libc/include/generic-freebsd/netipsec/key.h +++ b/lib/libc/include/generic-freebsd/netipsec/key.h @@ -36,6 +36,7 @@ #ifdef _KERNEL +struct mbuf; struct secpolicy; struct secpolicyindex; struct secasvar; @@ -49,6 +50,7 @@ struct xformsw; struct secpolicy *key_newsp(void); struct secpolicy *key_allocsp(struct secpolicyindex *, u_int); +struct secpolicy *key_do_allocsp(struct secpolicyindex *spidx, u_int dir); struct secpolicy *key_msg2sp(struct sadb_x_policy *, size_t, int *); int key_sp2msg(struct secpolicy *, void *, size_t *); void key_addref(struct secpolicy *); @@ -59,6 +61,7 @@ int key_havesp_any(void); void key_bumpspgen(void); uint32_t key_getspgen(void); uint32_t key_newreqid(void); +struct mbuf *key_setaccelif(const char *ifname); struct secasvar *key_allocsa(union sockaddr_union *, uint8_t, uint32_t); struct secasvar *key_allocsa_tunnel(union sockaddr_union *, @@ -84,6 +87,10 @@ extern void key_sa_recordxfer(struct secasvar *, struct mbuf *); uint16_t key_portfromsaddr(struct sockaddr *); void key_porttosaddr(struct sockaddr *, uint16_t port); +struct rm_priotracker; +void ipsec_sahtree_runlock(struct rm_priotracker *); +void ipsec_sahtree_rlock(struct rm_priotracker *); + #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_IPSEC_SA); MALLOC_DECLARE(M_IPSEC_SAH); diff --git a/lib/libc/include/generic-freebsd/netipsec/keydb.h b/lib/libc/include/generic-freebsd/netipsec/keydb.h index b8449a03f43f6eabf936802566f6d8d34d3dc86d..df9e0a0f3aefad949d65852184a6979f72064923 100644 --- a/lib/libc/include/generic-freebsd/netipsec/keydb.h +++ b/lib/libc/include/generic-freebsd/netipsec/keydb.h @@ -36,9 +36,11 @@ #ifdef _KERNEL #include +#include #include #include #include +#include #include #include @@ -125,6 +127,7 @@ struct xformsw; struct enc_xform; struct auth_hash; struct comp_algo; +struct ifp_handle_sav; /* * Security Association @@ -185,8 +188,19 @@ struct secasvar { uint64_t cntr; /* counter for GCM and CTR */ volatile u_int refcnt; /* reference count */ + CK_LIST_HEAD(, ifp_handle_sav) accel_ifps; + uintptr_t accel_forget_tq; + const char *accel_ifname; + uint32_t accel_flags; + counter_u64_t accel_lft_sw; + uint64_t accel_hw_allocs; + uint64_t accel_hw_octets; + uint64_t accel_firstused; }; +#define SADB_KEY_ACCEL_INST 0x00000001 +#define SADB_KEY_ACCEL_DEINST 0x00000002 + #define SECASVAR_RLOCK_TRACKER struct rm_priotracker _secas_tracker #define SECASVAR_RLOCK(_sav) rm_rlock((_sav)->lock, &_secas_tracker) #define SECASVAR_RUNLOCK(_sav) rm_runlock((_sav)->lock, &_secas_tracker) diff --git a/lib/libc/include/generic-freebsd/netlink/ktest_netlink_message_writer.h b/lib/libc/include/generic-freebsd/netlink/ktest_netlink_message_writer.h index 0d4e7018f6cfab35224bf03f4409e2fefc73a3cb..b83287f7d6b5494c3731a06ed0aa2aaa35bc53b8 100644 --- a/lib/libc/include/generic-freebsd/netlink/ktest_netlink_message_writer.h +++ b/lib/libc/include/generic-freebsd/netlink/ktest_netlink_message_writer.h @@ -30,28 +30,14 @@ #if defined(_KERNEL) && defined(INVARIANTS) -bool nlmsg_get_buf_type_wrapper(struct nl_writer *nw, int size, int type, bool waitok); -void nlmsg_set_callback_wrapper(struct nl_writer *nw); -struct mbuf *nl_get_mbuf_chain_wrapper(int len, int malloc_flags); +bool nlmsg_get_buf_wrapper(struct nl_writer *nw, size_t size, bool waitok); #ifndef KTEST_CALLER bool -nlmsg_get_buf_type_wrapper(struct nl_writer *nw, int size, int type, bool waitok) +nlmsg_get_buf_wrapper(struct nl_writer *nw, size_t size, bool waitok) { - return (nlmsg_get_buf_type(nw, size, type, waitok)); -} - -void -nlmsg_set_callback_wrapper(struct nl_writer *nw) -{ - nlmsg_set_callback(nw); -} - -struct mbuf * -nl_get_mbuf_chain_wrapper(int len, int malloc_flags) -{ - return (nl_get_mbuf_chain(len, malloc_flags)); + return (nlmsg_get_buf(nw, size, waitok)); } #endif diff --git a/lib/libc/include/generic-freebsd/netlink/netlink.h b/lib/libc/include/generic-freebsd/netlink/netlink.h index a3c1e5d5a4a85de8c36f272a2c23fb39014e18d9..853bfbea6251fa18a792d5e864a02f8a7a2d6fb3 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink.h @@ -61,7 +61,7 @@ #ifndef _NETLINK_NETLINK_H_ #define _NETLINK_NETLINK_H_ -#include +#include #include struct sockaddr_nl { @@ -194,11 +194,8 @@ enum nlmsginfo_attrs { }; -#ifndef roundup2 -#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ -#endif #define NL_ITEM_ALIGN_SIZE sizeof(uint32_t) -#define NL_ITEM_ALIGN(_len) roundup2(_len, NL_ITEM_ALIGN_SIZE) +#define NL_ITEM_ALIGN(_len) __align_up(_len, NL_ITEM_ALIGN_SIZE) #define NL_ITEM_DATA(_ptr, _off) ((void *)((char *)(_ptr) + _off)) #define NL_ITEM_DATA_CONST(_ptr, _off) ((const void *)((const char *)(_ptr) + _off)) @@ -208,25 +205,24 @@ enum nlmsginfo_attrs { #define NL_ITEM_ITER(_ptr, _len, _LEN_MACRO) \ ((_len) -= _LEN_MACRO(_ptr), NL_ITEM_NEXT(_ptr, _LEN_MACRO)) +/* part of netlink(3) API */ +#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE +#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len) #ifndef _KERNEL /* part of netlink(3) API */ -#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE -#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len) -#define NLMSG_HDRLEN ((int)sizeof(struct nlmsghdr)) -#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN) -#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len)) -#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN) -#define _NLMSG_LEN(_hdr) ((int)(_hdr)->nlmsg_len) +#define NLMSG_HDRLEN (sizeof(struct nlmsghdr)) +#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN) +#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len)) +#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN) +#define _NLMSG_LEN(_hdr) ((_hdr)->nlmsg_len) #define _NLMSG_ALIGNED_LEN(_hdr) NLMSG_ALIGN(_NLMSG_LEN(_hdr)) #define NLMSG_OK(_hdr, _len) NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN) #define NLMSG_PAYLOAD(_hdr,_len) (_NLMSG_LEN(_hdr) - NLMSG_SPACE((_len))) #define NLMSG_NEXT(_hdr, _len) NL_ITEM_ITER(_hdr, _len, _NLMSG_ALIGNED_LEN) #else -#define NLMSG_ALIGNTO 4U -#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1)) -#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#define NLMSG_HDRLEN (NLMSG_ALIGN(sizeof(struct nlmsghdr))) #endif /* diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_ctl.h b/lib/libc/include/generic-freebsd/netlink/netlink_ctl.h index 2c48e26730ccdf9e7575617460015bd71057de9e..c124da742703ff9a2a63f7125c5b42c745bdb276 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_ctl.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_ctl.h @@ -47,8 +47,8 @@ MALLOC_DECLARE(M_NETLINK); #define NLA_ALIGN_SIZE sizeof(uint32_t) #define NLA_ALIGN(_len) _roundup2(_len, NLA_ALIGN_SIZE) -#define NLA_HDRLEN ((int)sizeof(struct nlattr)) -#define NLA_DATA_LEN(_nla) ((int)((_nla)->nla_len - NLA_HDRLEN)) +#define NLA_HDRLEN ((uint16_t)sizeof(struct nlattr)) +#define NLA_DATA_LEN(_nla) ((_nla)->nla_len - NLA_HDRLEN) #define NLA_DATA(_nla) NL_ITEM_DATA(_nla, NLA_HDRLEN) #define NLA_DATA_CONST(_nla) NL_ITEM_DATA_CONST(_nla, NLA_HDRLEN) #define NLA_TYPE(_nla) ((_nla)->nla_type & 0x3FFF) @@ -65,8 +65,6 @@ MALLOC_DECLARE(M_NETLINK); ((char *)NLA_NEXT(_attr) <= (char *)_end); \ _attr = (_len -= NLA_ALIGN(_attr->nla_len), NLA_NEXT(_attr))) -#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0])) - #include #include @@ -79,7 +77,6 @@ bool netlink_register_proto(int proto, const char *proto_name, nl_handler_f hand bool netlink_unregister_proto(int proto); /* Common helpers */ -bool nl_has_listeners(int netlink_family, uint32_t groups_mask); bool nlp_has_priv(struct nlpcb *nlp, int priv); struct ucred *nlp_get_cred(struct nlpcb *nlp); uint32_t nlp_get_pid(const struct nlpcb *nlp); @@ -94,18 +91,16 @@ struct genl_cmd { uint32_t cmd_num; }; -uint32_t genl_register_family(const char *family_name, size_t hdrsize, - int family_version, int max_attr_idx); -bool genl_unregister_family(const char *family_name); -bool genl_register_cmds(const char *family_name, const struct genl_cmd *cmds, - int count); -uint32_t genl_register_group(const char *family_name, const char *group_name); +uint16_t genl_register_family(const char *family_name, size_t hdrsize, + uint16_t family_version, uint16_t max_attr_idx); +void genl_unregister_family(uint16_t family); +bool genl_register_cmds(uint16_t family, const struct genl_cmd *cmds, + u_int count); +uint32_t genl_register_group(uint16_t family, const char *group_name); +void genl_unregister_group(uint16_t family, uint32_t group); -struct genl_family; -const char *genl_get_family_name(const struct genl_family *gf); -uint32_t genl_get_family_id(const struct genl_family *gf); - -typedef void (*genl_family_event_handler_t)(void *arg, const struct genl_family *gf, int action); +typedef void (*genl_family_event_handler_t)(void *arg, const char *family_name, + uint16_t family_id, u_int action); EVENTHANDLER_DECLARE(genl_family_event, genl_family_event_handler_t); struct thread; diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_linux.h b/lib/libc/include/generic-freebsd/netlink/netlink_linux.h index f46ee83dcf0ad100c0fb2dee078f6cbe7d85f691..6461aa086d0c0051e2e028897217834faf1c96ce 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_linux.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_linux.h @@ -27,6 +27,7 @@ #ifndef _NETLINK_LINUX_VAR_H_ #define _NETLINK_LINUX_VAR_H_ +#ifdef _KERNEL /* * The file contains headers for the bridge interface between @@ -34,16 +35,13 @@ */ struct nlpcb; struct nl_pstate; +struct nl_writer; -typedef struct mbuf *mbufs_to_linux_cb_t(int netlink_family, struct mbuf *m, - struct nlpcb *nlp); -typedef struct mbuf *msgs_to_linux_cb_t(int netlink_family, char *buf, int data_length, - struct nlpcb *nlp); -typedef struct nlmsghdr *msg_from_linux_cb_t(int netlink_family, struct nlmsghdr *hdr, +typedef struct nl_buf * msgs_to_linux_cb_t(struct nl_buf *, struct nlpcb *); +typedef int msg_from_linux_cb_t(int netlink_family, struct nlmsghdr **hdr, struct nl_pstate *npt); struct linux_netlink_provider { - mbufs_to_linux_cb_t *mbufs_to_linux; msgs_to_linux_cb_t *msgs_to_linux; msg_from_linux_cb_t *msg_from_linux; @@ -51,4 +49,5 @@ struct linux_netlink_provider { extern struct linux_netlink_provider *linux_netlink_p; +#endif #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_message_parser.h b/lib/libc/include/generic-freebsd/netlink/netlink_message_parser.h index 48832ed6e528a6e391942aa70855186d5bdbc949..9b09087263f188db8c8b74581baeb9bbb258df45 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_message_parser.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_message_parser.h @@ -64,15 +64,15 @@ lb_clear(struct linear_buffer *lb) #define NL_MAX_ERROR_BUF 128 #define SCRATCH_BUFFER_SIZE (1024 + NL_MAX_ERROR_BUF) struct nl_pstate { - struct linear_buffer lb; /* Per-message scratch buffer */ - struct nlpcb *nlp; /* Originator socket */ - struct nl_writer *nw; /* Message writer to use */ - struct nlmsghdr *hdr; /* Current parsed message header */ - uint32_t err_off; /* error offset from hdr start */ - int error; /* last operation error */ - char *err_msg; /* Description of last error */ - struct nlattr *cookie; /* NLA to return to the userspace */ - bool strict; /* Strict parsing required */ + struct linear_buffer lb; /* Per-message scratch buffer */ + struct nlpcb *nlp; /* Originator socket */ + struct nl_writer *nw; /* Message writer to use */ + struct nlmsghdr *hdr; /* Current parsed message header */ + uint32_t err_off; /* error offset from hdr start */ + int error; /* last operation error */ + char *err_msg; /* Description of last error */ + struct nlattr *cookie; /* NLA to return to the userspace */ + bool strict; /* Strict parsing required */ }; static inline void * @@ -80,10 +80,10 @@ npt_alloc(struct nl_pstate *npt, int len) { return (lb_alloc(&npt->lb, len)); } -#define npt_alloc_sockaddr(_npt, _len) ((struct sockaddr *)(npt_alloc(_npt, _len))) +#define npt_alloc_sockaddr(_npt, _len) \ + ((struct sockaddr *)(npt_alloc((_npt), (_len)))) -typedef int parse_field_f(void *hdr, struct nl_pstate *npt, - void *target); +typedef int parse_field_f(void *hdr, struct nl_pstate *npt, void *target); struct nlfield_parser { uint16_t off_in; uint16_t off_out; @@ -98,29 +98,28 @@ int nlf_get_u16(void *src, struct nl_pstate *npt, void *target); int nlf_get_u32(void *src, struct nl_pstate *npt, void *target); int nlf_get_u8_u32(void *src, struct nl_pstate *npt, void *target); - struct nlattr_parser; typedef int parse_attr_f(struct nlattr *attr, struct nl_pstate *npt, const void *arg, void *target); struct nlattr_parser { - uint16_t type; /* Attribute type */ - uint16_t off; /* field offset in the target structure */ - parse_attr_f *cb; /* parser function to call */ - const void *arg; + uint16_t type; /* Attribute type */ + uint16_t off; /* field offset in the target structure */ + parse_attr_f *cb; /* parser function to call */ + const void *arg; }; typedef bool strict_parser_f(void *hdr, struct nl_pstate *npt); typedef bool post_parser_f(void *parsed_attrs, struct nl_pstate *npt); struct nlhdr_parser { - int nl_hdr_off; /* aligned netlink header size */ - int out_hdr_off; /* target header size */ - int fp_size; - int np_size; + u_int nl_hdr_off; /* aligned netlink header size */ + u_int out_hdr_off; /* target header size */ + u_int fp_size; + u_int np_size; const struct nlfield_parser *fp; /* array of header field parsers */ const struct nlattr_parser *np; /* array of attribute parsers */ - strict_parser_f *sp; /* Pre-parse strict validation function */ - post_parser_f *post_parse; + strict_parser_f *sp; /* Pre-parse strict validation function */ + post_parser_f *post_parse; }; #define NL_DECLARE_PARSER_EXT(_name, _t, _sp, _fp, _np, _pp) \ @@ -128,8 +127,8 @@ static const struct nlhdr_parser _name = { \ .nl_hdr_off = sizeof(_t), \ .fp = &((_fp)[0]), \ .np = &((_np)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ - .np_size = NL_ARRAY_LEN(_np), \ + .fp_size = nitems(_fp), \ + .np_size = nitems(_np), \ .sp = _sp, \ .post_parse = _pp, \ } @@ -146,29 +145,37 @@ static const struct nlhdr_parser _name = { \ .out_hdr_off = sizeof(_o), \ .fp = &((_fp)[0]), \ .np = &((_np)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ - .np_size = NL_ARRAY_LEN(_np), \ + .fp_size = nitems(_fp), \ + .np_size = nitems(_np), \ +} + +#define NL_DECLARE_ATTR_PARSER_EXT(_name, _np, _pp) \ +static const struct nlhdr_parser _name = { \ + .np = &((_np)[0]), \ + .np_size = nitems(_np), \ + .post_parse = (_pp) \ } #define NL_DECLARE_ATTR_PARSER(_name, _np) \ -static const struct nlhdr_parser _name = { \ - .np = &((_np)[0]), \ - .np_size = NL_ARRAY_LEN(_np), \ -} + NL_DECLARE_ATTR_PARSER_EXT(_name, _np, NULL) #define NL_ATTR_BMASK_SIZE 128 BITSET_DEFINE(nlattr_bmask, NL_ATTR_BMASK_SIZE); -void nl_get_attrs_bmask_raw(struct nlattr *nla_head, int len, struct nlattr_bmask *bm); -bool nl_has_attr(const struct nlattr_bmask *bm, unsigned int nla_type); +void nl_get_attrs_bmask_raw(struct nlattr *nla_head, uint32_t len, + struct nlattr_bmask *bm); +bool nl_has_attr(const struct nlattr_bmask *bm, uint16_t nla_type); -int nl_parse_attrs_raw(struct nlattr *nla_head, int len, const struct nlattr_parser *ps, - int pslen, struct nl_pstate *npt, void *target); +int nl_parse_attrs_raw(struct nlattr *nla_head, uint16_t len, + const struct nlattr_parser *ps, u_int pslen, struct nl_pstate *npt, + void *target); int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); +int nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt, + const void *arg, void *target); int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt, @@ -187,16 +194,23 @@ int nlattr_get_ifpz(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); +int nlattr_get_chara(struct nlattr *nla, struct nl_pstate *npt, + const void *arg, void *target); int nlattr_get_string(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_stringn(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); +int nlattr_get_bytes(struct nlattr *nla, struct nl_pstate *npt, + const void *arg, void *target); int nlattr_get_nla(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_nested(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); +int nlattr_get_nested_ptr(struct nlattr *nla, struct nl_pstate *npt, + const void *arg, void *target); -bool nlmsg_report_err_msg(struct nl_pstate *npt, const char *fmt, ...); +bool nlmsg_report_err_msg(struct nl_pstate *npt, const char *fmt, ...) + __printflike(2, 3); #define NLMSG_REPORT_ERR_MSG(_npt, _fmt, ...) { \ nlmsg_report_err_msg(_npt, _fmt, ## __VA_ARGS__); \ @@ -213,20 +227,26 @@ void nlmsg_report_cookie_u32(struct nl_pstate *npt, uint32_t val); * the list of direct function calls without iteration. */ static inline int -nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser, +nl_parse_header(void *hdr, uint32_t len, const struct nlhdr_parser *parser, struct nl_pstate *npt, void *target) { int error; if (__predict_false(len < parser->nl_hdr_off)) { + void *tmp_hdr; + if (npt->strict) { - nlmsg_report_err_msg(npt, "header too short: expected %d, got %d", + nlmsg_report_err_msg(npt, + "header too short: expected %d, got %d", parser->nl_hdr_off, len); return (EINVAL); } - /* Compat with older applications: pretend there's a full header */ - void *tmp_hdr = npt_alloc(npt, parser->nl_hdr_off); + /* + * Compatibility with older applications: + * pretend there's a full header. + */ + tmp_hdr = npt_alloc(npt, parser->nl_hdr_off); if (tmp_hdr == NULL) return (EINVAL); memcpy(tmp_hdr, hdr, len); @@ -238,7 +258,7 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser, return (EINVAL); /* Extract fields first */ - for (int i = 0; i < parser->fp_size; i++) { + for (u_int i = 0; i < parser->fp_size; i++) { const struct nlfield_parser *fp = &parser->fp[i]; void *src = (char *)hdr + fp->off_in; void *dst = (char *)target + fp->off_out; @@ -248,9 +268,9 @@ nl_parse_header(void *hdr, int len, const struct nlhdr_parser *parser, return (error); } - struct nlattr *nla_head = (struct nlattr *)((char *)hdr + parser->nl_hdr_off); - error = nl_parse_attrs_raw(nla_head, len - parser->nl_hdr_off, parser->np, - parser->np_size, npt, target); + error = nl_parse_attrs_raw( + (struct nlattr *)((char *)hdr + parser->nl_hdr_off), + len - parser->nl_hdr_off, parser->np, parser->np_size, npt, target); if (parser->post_parse != NULL && error == 0) { if (!parser->post_parse(target, npt)) @@ -264,10 +284,8 @@ static inline int nl_parse_nested(struct nlattr *nla, const struct nlhdr_parser *parser, struct nl_pstate *npt, void *target) { - struct nlattr *nla_head = (struct nlattr *)NLA_DATA(nla); - - return (nl_parse_attrs_raw(nla_head, NLA_DATA_LEN(nla), parser->np, - parser->np_size, npt, target)); + return (nl_parse_attrs_raw((struct nlattr *)NLA_DATA(nla), + NLA_DATA_LEN(nla), parser->np, parser->np_size, npt, target)); } /* @@ -283,30 +301,36 @@ nl_verify_parsers(const struct nlhdr_parser **parser, int count) for (int j = 0; j < p->np_size; j++) { MPASS(p->np[j].type > attr_type); attr_type = p->np[j].type; + + /* Recurse into nested objects. */ + if (p->np[j].cb == nlattr_get_nested || + p->np[j].cb == nlattr_get_nested_ptr) { + const struct nlhdr_parser *np = + (const struct nlhdr_parser *)p->np[j].arg; + nl_verify_parsers(&np, 1); + } } } #endif } void nl_verify_parsers(const struct nlhdr_parser **parser, int count); -#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), NL_ARRAY_LEN(_p)) +#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), nitems(_p)) static inline int nl_parse_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser, struct nl_pstate *npt, void *target) { - return (nl_parse_header(hdr + 1, hdr->nlmsg_len - sizeof(*hdr), parser, npt, target)); + return (nl_parse_header(hdr + 1, hdr->nlmsg_len - sizeof(*hdr), parser, + npt, target)); } static inline void -nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser, - struct nlattr_bmask *bm) +nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr, + const struct nlhdr_parser *parser, struct nlattr_bmask *bm) { - struct nlattr *nla_head; - - nla_head = (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off); - int len = hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off; - - nl_get_attrs_bmask_raw(nla_head, len, bm); + nl_get_attrs_bmask_raw( + (struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off), + hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off, bm); } #endif diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h b/lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h index 1faa47f31601cc9f1e549d88910136c109a26e59..715185469e6328dd588adfc85d3cf6ac88480ca2 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_message_writer.h @@ -37,62 +37,45 @@ * It is not meant to be included directly */ -struct mbuf; +struct nl_buf; struct nl_writer; -typedef bool nl_writer_cb(struct nl_writer *nw, void *buf, int buflen, int cnt); +typedef bool nl_writer_cb(struct nl_writer *nw); struct nl_writer { - int alloc_len; /* allocated buffer length */ - int offset; /* offset from the start of the buffer */ - struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */ - char *data; /* pointer to the contiguous storage */ - void *_storage; /* Underlying storage pointer */ - nl_writer_cb *cb; /* Callback to flush data */ + struct nl_buf *buf; /* Underlying storage pointer */ + struct nlmsghdr *hdr; /* Pointer to the currently-filled msg */ + nl_writer_cb *cb; /* Callback to flush data */ union { - void *ptr; + struct nlpcb *nlp; struct { uint16_t proto; uint16_t id; + int priv; } group; - } arg; - int num_messages; /* Number of messages in the buffer */ - int malloc_flag; /* M_WAITOK or M_NOWAIT */ - uint8_t writer_type; /* NS_WRITER_TYPE_* */ - uint8_t writer_target; /* NS_WRITER_TARGET_* */ - bool ignore_limit; /* If true, ignores RCVBUF limit */ - bool enomem; /* True if ENOMEM occured */ - bool suppress_ack; /* If true, don't send NLMSG_ERR */ + }; + u_int num_messages; /* Number of messages in the buffer */ + int malloc_flag; /* M_WAITOK or M_NOWAIT */ + bool ignore_limit; /* If true, ignores RCVBUF limit */ + bool enomem; /* True if ENOMEM occured */ + bool suppress_ack; /* If true, don't send NLMSG_ERR */ }; -#define NS_WRITER_TARGET_SOCKET 0 -#define NS_WRITER_TARGET_GROUP 1 -#define NS_WRITER_TARGET_CHAIN 2 - -#define NS_WRITER_TYPE_MBUF 0 -#define NS_WRITER_TYPE_BUF 1 -#define NS_WRITER_TYPE_LBUF 2 -#define NS_WRITER_TYPE_MBUFC 3 -#define NS_WRITER_TYPE_STUB 4 - #define NLMSG_SMALL 128 #define NLMSG_LARGE 2048 /* Message and attribute writing */ - -struct nlpcb; - #if defined(NETLINK) || defined(NETLINK_MODULE) /* Provide optimized calls to the functions inside the same linking unit */ -bool _nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp); -bool _nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id); -bool _nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm); +bool _nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *nlp, bool); +bool _nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int, + bool); bool _nlmsg_flush(struct nl_writer *nw); void _nlmsg_ignore_limit(struct nl_writer *nw); -bool _nlmsg_refill_buffer(struct nl_writer *nw, int required_size); -bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type, - uint16_t flags, uint32_t len); +bool _nlmsg_refill_buffer(struct nl_writer *nw, size_t required_len); +bool _nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, + uint16_t type, uint16_t flags, uint32_t len); bool _nlmsg_end(struct nl_writer *nw); void _nlmsg_abort(struct nl_writer *nw); @@ -100,21 +83,17 @@ bool _nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr); static inline bool -nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp) +nl_writer_unicast(struct nl_writer *nw, size_t size, struct nlpcb *nlp, + bool waitok) { - return (_nlmsg_get_unicast_writer(nw, expected_size, nlp)); + return (_nl_writer_unicast(nw, size, nlp, waitok)); } static inline bool -nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id) +nl_writer_group(struct nl_writer *nw, size_t size, uint16_t proto, + uint16_t group_id, int priv, bool waitok) { - return (_nlmsg_get_group_writer(nw, expected_size, proto, group_id)); -} - -static inline bool -nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm) -{ - return (_nlmsg_get_chain_writer(nw, expected_size, pm)); + return (_nl_writer_group(nw, size, proto, group_id, priv, waitok)); } static inline bool @@ -130,7 +109,7 @@ nlmsg_ignore_limit(struct nl_writer *nw) } static inline bool -nlmsg_refill_buffer(struct nl_writer *nw, int required_size) +nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size) { return (_nlmsg_refill_buffer(nw, required_size)); } @@ -163,15 +142,15 @@ nlmsg_end_dump(struct nl_writer *nw, int error, struct nlmsghdr *hdr) #else /* Provide access to the functions via netlink_glue.c */ -bool nlmsg_get_unicast_writer(struct nl_writer *nw, int expected_size, struct nlpcb *nlp); -bool nlmsg_get_group_writer(struct nl_writer *nw, int expected_size, int proto, int group_id); -bool nlmsg_get_chain_writer(struct nl_writer *nw, int expected_size, struct mbuf **pm); +bool nl_writer_unicast(struct nl_writer *, size_t, struct nlpcb *, bool waitok); +bool nl_writer_group(struct nl_writer *, size_t, uint16_t, uint16_t, int, + bool waitok); bool nlmsg_flush(struct nl_writer *nw); void nlmsg_ignore_limit(struct nl_writer *nw); -bool nlmsg_refill_buffer(struct nl_writer *nw, int required_size); -bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type, - uint16_t flags, uint32_t len); +bool nlmsg_refill_buffer(struct nl_writer *nw, size_t required_size); +bool nlmsg_add(struct nl_writer *nw, uint32_t portid, uint32_t seq, + uint16_t type, uint16_t flags, uint32_t len); bool nlmsg_end(struct nl_writer *nw); void nlmsg_abort(struct nl_writer *nw); @@ -186,18 +165,12 @@ nlmsg_reply(struct nl_writer *nw, const struct nlmsghdr *hdr, int payload_len) hdr->nlmsg_flags, payload_len)); } -#define nlmsg_data(_hdr) ((void *)((_hdr) + 1)) - /* * KPI similar to mtodo(): * current (uncompleted) header is guaranteed to be contiguous, * but can be reallocated, thus pointers may need to be readjusted. */ -static inline int -nlattr_save_offset(const struct nl_writer *nw) -{ - return (nw->offset - ((char *)nw->hdr - nw->data)); -} +u_int nlattr_save_offset(const struct nl_writer *nw); static inline void * _nlattr_restore_offset(const struct nl_writer *nw, int off) @@ -213,22 +186,7 @@ nlattr_set_len(const struct nl_writer *nw, int off) nla->nla_len = nlattr_save_offset(nw) - off; } -static inline void * -nlmsg_reserve_data_raw(struct nl_writer *nw, size_t sz) -{ - sz = NETLINK_ALIGN(sz); - - if (__predict_false(nw->offset + sz > nw->alloc_len)) { - if (!nlmsg_refill_buffer(nw, sz)) - return (NULL); - } - - void *data_ptr = &nw->data[nw->offset]; - nw->offset += sz; - bzero(data_ptr, sz); - - return (data_ptr); -} +void *nlmsg_reserve_data_raw(struct nl_writer *nw, size_t sz); #define nlmsg_reserve_object(_ns, _t) ((_t *)nlmsg_reserve_data_raw(_ns, sizeof(_t))) #define nlmsg_reserve_data(_ns, _sz, _t) ((_t *)nlmsg_reserve_data_raw(_ns, _sz)) @@ -258,109 +216,95 @@ _nlmsg_reserve_attr(struct nl_writer *nw, uint16_t nla_type, uint16_t sz) } #define nlmsg_reserve_attr(_ns, _at, _t) ((_t *)_nlmsg_reserve_attr(_ns, _at, NLA_ALIGN(sizeof(_t)))) -static inline bool -nlattr_add(struct nl_writer *nw, int attr_type, int attr_len, const void *data) -{ - int required_len = NLA_ALIGN(attr_len + sizeof(struct nlattr)); - - if (__predict_false(nw->offset + required_len > nw->alloc_len)) { - if (!nlmsg_refill_buffer(nw, required_len)) - return (false); - } - - struct nlattr *nla = (struct nlattr *)(&nw->data[nw->offset]); - - nla->nla_len = attr_len + sizeof(struct nlattr); - nla->nla_type = attr_type; - if (attr_len > 0) { - if ((attr_len % 4) != 0) { - /* clear padding bytes */ - bzero((char *)nla + required_len - 4, 4); - } - memcpy((nla + 1), data, attr_len); - } - nw->offset += required_len; - return (true); -} +bool nlattr_add(struct nl_writer *nw, uint16_t attr_type, uint16_t attr_len, + const void *data); static inline bool nlattr_add_raw(struct nl_writer *nw, const struct nlattr *nla_src) { - int attr_len = nla_src->nla_len - sizeof(struct nlattr); + MPASS(nla_src->nla_len >= sizeof(struct nlattr)); - MPASS(attr_len >= 0); + return (nlattr_add(nw, nla_src->nla_type, + nla_src->nla_len - sizeof(struct nlattr), + (const void *)(nla_src + 1))); +} - return (nlattr_add(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1))); +static inline bool +nlattr_add_bool(struct nl_writer *nw, uint16_t attrtype, bool value) +{ + return (nlattr_add(nw, attrtype, sizeof(bool), &value)); } static inline bool -nlattr_add_u8(struct nl_writer *nw, int attrtype, uint8_t value) +nlattr_add_u8(struct nl_writer *nw, uint16_t attrtype, uint8_t value) { return (nlattr_add(nw, attrtype, sizeof(uint8_t), &value)); } static inline bool -nlattr_add_u16(struct nl_writer *nw, int attrtype, uint16_t value) +nlattr_add_u16(struct nl_writer *nw, uint16_t attrtype, uint16_t value) { return (nlattr_add(nw, attrtype, sizeof(uint16_t), &value)); } static inline bool -nlattr_add_u32(struct nl_writer *nw, int attrtype, uint32_t value) +nlattr_add_u32(struct nl_writer *nw, uint16_t attrtype, uint32_t value) { return (nlattr_add(nw, attrtype, sizeof(uint32_t), &value)); } static inline bool -nlattr_add_u64(struct nl_writer *nw, int attrtype, uint64_t value) +nlattr_add_u64(struct nl_writer *nw, uint16_t attrtype, uint64_t value) { return (nlattr_add(nw, attrtype, sizeof(uint64_t), &value)); } static inline bool -nlattr_add_s8(struct nl_writer *nw, int attrtype, int8_t value) +nlattr_add_s8(struct nl_writer *nw, uint16_t attrtype, int8_t value) { return (nlattr_add(nw, attrtype, sizeof(int8_t), &value)); } static inline bool -nlattr_add_s16(struct nl_writer *nw, int attrtype, int16_t value) +nlattr_add_s16(struct nl_writer *nw, uint16_t attrtype, int16_t value) { return (nlattr_add(nw, attrtype, sizeof(int16_t), &value)); } static inline bool -nlattr_add_s32(struct nl_writer *nw, int attrtype, int32_t value) +nlattr_add_s32(struct nl_writer *nw, uint16_t attrtype, int32_t value) { return (nlattr_add(nw, attrtype, sizeof(int32_t), &value)); } static inline bool -nlattr_add_s64(struct nl_writer *nw, int attrtype, int64_t value) +nlattr_add_s64(struct nl_writer *nw, uint16_t attrtype, int64_t value) { return (nlattr_add(nw, attrtype, sizeof(int64_t), &value)); } static inline bool -nlattr_add_flag(struct nl_writer *nw, int attrtype) +nlattr_add_flag(struct nl_writer *nw, uint16_t attrtype) { return (nlattr_add(nw, attrtype, 0, NULL)); } static inline bool -nlattr_add_string(struct nl_writer *nw, int attrtype, const char *str) +nlattr_add_string(struct nl_writer *nw, uint16_t attrtype, const char *str) { return (nlattr_add(nw, attrtype, strlen(str) + 1, str)); } static inline bool -nlattr_add_in_addr(struct nl_writer *nw, int attrtype, const struct in_addr *in) +nlattr_add_in_addr(struct nl_writer *nw, uint16_t attrtype, + const struct in_addr *in) { return (nlattr_add(nw, attrtype, sizeof(*in), in)); } static inline bool -nlattr_add_in6_addr(struct nl_writer *nw, int attrtype, const struct in6_addr *in6) +nlattr_add_in6_addr(struct nl_writer *nw, uint16_t attrtype, + const struct in6_addr *in6) { return (nlattr_add(nw, attrtype, sizeof(*in6), in6)); } diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_snl.h b/lib/libc/include/generic-freebsd/netlink/netlink_snl.h index 5cb36f60df0e0812424b631f9e884e0e02d5d320..2b104c77b421f97b970382ae8ba2ebbdfbebddcc 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_snl.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_snl.h @@ -31,6 +31,12 @@ * Simple Netlink Library */ +#include +#include + +#include +#include + #include #include #include @@ -41,11 +47,6 @@ #include #include -#include -#include -#include -#include - #define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) #define NETLINK_ALIGN_SIZE sizeof(uint32_t) @@ -68,8 +69,6 @@ ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len)); \ _attr = NLA_NEXT(_attr)) -#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0])) - struct linear_buffer { char *base; /* Base allocated memory pointer */ uint32_t offset; /* Currently used offset */ @@ -133,6 +132,7 @@ struct snl_field_parser { uint16_t off_out; snl_parse_field_f *cb; }; +static const struct snl_field_parser snl_f_p_empty[] = {}; typedef bool snl_parse_attr_f(struct snl_state *ss, struct nlattr *attr, const void *arg, void *target); @@ -166,8 +166,8 @@ static const struct snl_hdr_parser _name = { \ .out_size = _sz_out, \ .fp = &((_fp)[0]), \ .np = &((_np)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ - .np_size = NL_ARRAY_LEN(_np), \ + .fp_size = nitems(_fp), \ + .np_size = nitems(_np), \ .cb_post = _cb, \ } @@ -179,7 +179,7 @@ static const struct snl_hdr_parser _name = { \ .in_hdr_size = _sz_h_in, \ .out_size = _sz_out, \ .fp = &((_fp)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ + .fp_size = nitems(_fp), \ .cb_post = _cb, \ } @@ -190,7 +190,7 @@ static const struct snl_hdr_parser _name = { \ static const struct snl_hdr_parser _name = { \ .out_size = _sz_out, \ .np = &((_np)[0]), \ - .np_size = NL_ARRAY_LEN(_np), \ + .np_size = nitems(_np), \ .cb_post = _cb, \ } @@ -240,14 +240,13 @@ snl_clear_lb(struct snl_state *ss) static void snl_free(struct snl_state *ss) { - if (ss->init_done) { + if (ss->init_done) close(ss->fd); - if (ss->buf != NULL) - free(ss->buf); - if (ss->lb != NULL) { - snl_clear_lb(ss); - lb_free(ss->lb); - } + if (ss->buf != NULL) + free(ss->buf); + if (ss->lb != NULL) { + snl_clear_lb(ss); + lb_free(ss->lb); } } @@ -290,6 +289,16 @@ snl_init(struct snl_state *ss, int netlink_family) return (true); } +static inline bool +snl_clone(struct snl_state *ss, const struct snl_state *orig) +{ + *ss = (struct snl_state){ + .fd = orig->fd, + .init_done = false, + }; + return ((ss->lb = lb_init(SCRATCH_BUFFER_SIZE)) != NULL); +} + static inline bool snl_send(struct snl_state *ss, void *data, int sz) { @@ -418,7 +427,7 @@ snl_verify_parsers(const struct snl_hdr_parser **parser, int count) } } } -#define SNL_VERIFY_PARSERS(_p) snl_verify_parsers((_p), NL_ARRAY_LEN(_p)) +#define SNL_VERIFY_PARSERS(_p) snl_verify_parsers((_p), nitems(_p)) static const struct snl_attr_parser * find_parser(const struct snl_attr_parser *ps, int pslen, int key) @@ -526,6 +535,29 @@ snl_attr_get_flag(struct snl_state *ss __unused, struct nlattr *nla, const void return (false); } +static inline bool +snl_attr_get_bytes(struct snl_state *ss __unused, struct nlattr *nla, const void *arg, + void *target) +{ + if ((size_t)NLA_DATA_LEN(nla) != (size_t)arg) + return (false); + + memcpy(target, NLA_DATA_CONST(nla), (size_t)arg); + + return (true); +} + +static inline bool +snl_attr_get_bool(struct snl_state *ss __unused, struct nlattr *nla, + const void *arg __unused, void *target) +{ + if (NLA_DATA_LEN(nla) == sizeof(bool)) { + *((bool *)target) = *((const bool *)NLA_DATA_CONST(nla)); + return (true); + } + return (false); +} + static inline bool snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla, const void *arg __unused, void *target) @@ -1086,20 +1118,22 @@ snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz) #define snl_reserve_msg_object(_ns, _t) ((_t *)snl_reserve_msg_data_raw(_ns, sizeof(_t))) #define snl_reserve_msg_data(_ns, _sz, _t) ((_t *)snl_reserve_msg_data_raw(_ns, _sz)) -static inline void * -_snl_reserve_msg_attr(struct snl_writer *nw, uint16_t nla_type, uint16_t sz) +static inline struct nlattr * +snl_reserve_msg_attr_raw(struct snl_writer *nw, uint16_t nla_type, uint16_t sz) { + struct nlattr *nla; + sz += sizeof(struct nlattr); - - struct nlattr *nla = snl_reserve_msg_data(nw, sz, struct nlattr); + nla = snl_reserve_msg_data(nw, sz, struct nlattr); if (__predict_false(nla == NULL)) return (NULL); nla->nla_type = nla_type; nla->nla_len = sz; - return ((void *)(nla + 1)); + return (nla); } -#define snl_reserve_msg_attr(_ns, _at, _t) ((_t *)_snl_reserve_msg_attr(_ns, _at, sizeof(_t))) +#define snl_reserve_msg_attr(_ns, _at, _t) \ + ((_t *)(snl_reserve_msg_attr_raw(_ns, _at, sizeof(_t)) + 1)) static inline bool snl_add_msg_attr(struct snl_writer *nw, int attr_type, int attr_len, const void *data) @@ -1136,6 +1170,12 @@ snl_add_msg_attr_raw(struct snl_writer *nw, const struct nlattr *nla_src) return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1))); } +static inline bool +snl_add_msg_attr_bool(struct snl_writer *nw, int attrtype, bool value) +{ + return (snl_add_msg_attr(nw, attrtype, sizeof(bool), &value)); +} + static inline bool snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value) { @@ -1233,9 +1273,13 @@ snl_end_attr_nested(const struct snl_writer *nw, int off) static inline struct nlmsghdr * snl_create_msg_request(struct snl_writer *nw, int nlmsg_type) { + struct nlmsghdr *hdr; + assert(nw->hdr == NULL); - struct nlmsghdr *hdr = snl_reserve_msg_object(nw, struct nlmsghdr); + if (__predict_false((hdr = + snl_reserve_msg_object(nw, struct nlmsghdr)) == NULL)) + return (NULL); hdr->nlmsg_type = nlmsg_type; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; nw->hdr = hdr; @@ -1283,9 +1327,4 @@ snl_send_msgs(struct snl_writer *nw) return (snl_send(nw->ss, nw->base, offset)); } -static const struct snl_hdr_parser *snl_all_core_parsers[] = { - &snl_errmsg_parser, &snl_donemsg_parser, - &_nla_bit_parser, &_nla_bitset_parser, -}; - #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h b/lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h index bb347921d9ff74532520401bb6b7357335d92579..05c7ce1b5a683f23ffb150f3ac65e5a248dcf0a1 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_snl_generic.h @@ -33,16 +33,24 @@ /* Genetlink helpers */ static inline struct nlmsghdr * -snl_create_genl_msg_request(struct snl_writer *nw, int genl_family, uint8_t genl_cmd) +snl_create_genl_msg_request(struct snl_writer *nw, uint16_t genl_family, + uint8_t genl_cmd) { + struct nlmsghdr *hdr; + struct genlmsghdr *ghdr; + assert(nw->hdr == NULL); - struct nlmsghdr *hdr = snl_reserve_msg_object(nw, struct nlmsghdr); + hdr = snl_reserve_msg_object(nw, struct nlmsghdr); + if (__predict_false(hdr == NULL)) + return (NULL); hdr->nlmsg_type = genl_family; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; - nw->hdr = hdr; - struct genlmsghdr *ghdr = snl_reserve_msg_object(nw, struct genlmsghdr); + ghdr = snl_reserve_msg_object(nw, struct genlmsghdr); + if (__predict_false(ghdr == NULL)) + return (NULL); ghdr->cmd = genl_cmd; + nw->hdr = hdr; return (hdr); } @@ -52,37 +60,52 @@ static struct snl_field_parser snl_fp_genl[] = {}; #define SNL_DECLARE_GENL_PARSER(_name, _np) SNL_DECLARE_PARSER(_name,\ struct genlmsghdr, snl_fp_genl, _np) -struct snl_genl_ctrl_mcast_group { +struct _snl_genl_ctrl_mcast_group { uint32_t mcast_grp_id; - char *mcast_grp_name; + const char *mcast_grp_name; }; -struct snl_genl_ctrl_mcast_groups { +struct _snl_genl_ctrl_mcast_groups { uint32_t num_groups; - struct snl_genl_ctrl_mcast_group **groups; + struct _snl_genl_ctrl_mcast_group **groups; }; -#define _OUT(_field) offsetof(struct snl_genl_ctrl_mcast_group, _field) +#define _OUT(_field) offsetof(struct _snl_genl_ctrl_mcast_group, _field) static struct snl_attr_parser _nla_p_getmc[] = { - { .type = CTRL_ATTR_MCAST_GRP_NAME, .off = _OUT(mcast_grp_name), .cb = snl_attr_get_string }, - { .type = CTRL_ATTR_MCAST_GRP_ID, .off = _OUT(mcast_grp_id), .cb = snl_attr_get_uint32 }, + { + .type = CTRL_ATTR_MCAST_GRP_NAME, + .off = _OUT(mcast_grp_name), + .cb = snl_attr_get_string, + }, + { + .type = CTRL_ATTR_MCAST_GRP_ID, + .off = _OUT(mcast_grp_id), + .cb = snl_attr_get_uint32, + }, }; #undef _OUT SNL_DECLARE_ATTR_PARSER_EXT(_genl_ctrl_mc_parser, - sizeof(struct snl_genl_ctrl_mcast_group), - _nla_p_getmc, NULL); + sizeof(struct _snl_genl_ctrl_mcast_group), _nla_p_getmc, NULL); struct _getfamily_attrs { uint16_t family_id; - char *family_name; - struct snl_genl_ctrl_mcast_groups mcast_groups; + const char *family_name; + struct _snl_genl_ctrl_mcast_groups mcast_groups; }; #define _IN(_field) offsetof(struct genlmsghdr, _field) #define _OUT(_field) offsetof(struct _getfamily_attrs, _field) static struct snl_attr_parser _nla_p_getfam[] = { - { .type = CTRL_ATTR_FAMILY_ID , .off = _OUT(family_id), .cb = snl_attr_get_uint16 }, - { .type = CTRL_ATTR_FAMILY_NAME, .off = _OUT(family_name), .cb = snl_attr_get_string }, + { + .type = CTRL_ATTR_FAMILY_ID, + .off = _OUT(family_id), + .cb = snl_attr_get_uint16, + }, + { + .type = CTRL_ATTR_FAMILY_NAME, + .off = _OUT(family_name), + .cb = snl_attr_get_string, + }, { .type = CTRL_ATTR_MCAST_GROUPS, .off = _OUT(mcast_groups), @@ -95,7 +118,7 @@ static struct snl_attr_parser _nla_p_getfam[] = { SNL_DECLARE_GENL_PARSER(_genl_ctrl_getfam_parser, _nla_p_getfam); static bool -snl_get_genl_family_info(struct snl_state *ss, const char *family_name, +_snl_get_genl_family_info(struct snl_state *ss, const char *family_name, struct _getfamily_attrs *attrs) { struct snl_writer nw; @@ -104,7 +127,7 @@ snl_get_genl_family_info(struct snl_state *ss, const char *family_name, memset(attrs, 0, sizeof(*attrs)); snl_init_writer(ss, &nw); - hdr = snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY); + snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY); snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, family_name); if ((hdr = snl_finalize_msg(&nw)) == NULL || !snl_send_message(ss, hdr)) return (false); @@ -123,12 +146,30 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name) { struct _getfamily_attrs attrs = {}; - snl_get_genl_family_info(ss, family_name, &attrs); + if (__predict_false(!_snl_get_genl_family_info(ss, family_name, + &attrs))) + return (0); return (attrs.family_id); } -static const struct snl_hdr_parser *snl_all_genl_parsers[] = { - &_genl_ctrl_getfam_parser, &_genl_ctrl_mc_parser, -}; +static inline uint16_t +snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name, + const char *group_name, uint16_t *family_id) +{ + struct _getfamily_attrs attrs = {}; + + if (__predict_false(!_snl_get_genl_family_info(ss, family_name, + &attrs))) + return (0); + if (attrs.family_id == 0) + return (0); + if (family_id != NULL) + *family_id = attrs.family_id; + for (u_int i = 0; i < attrs.mcast_groups.num_groups; i++) + if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, + group_name) == 0) + return (attrs.mcast_groups.groups[i]->mcast_grp_id); + return (0); +} #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_snl_route_parsers.h b/lib/libc/include/generic-freebsd/netlink/netlink_snl_route_parsers.h index 5499092ffc0de5877aa44c6806bbf0c99fbf0560..dc401d9b63ff15f924ecd93a9ae8b8f24fa88f3f 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_snl_route_parsers.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_snl_route_parsers.h @@ -389,11 +389,4 @@ _cb_p_nh(struct snl_state *ss __unused, void *_target) SNL_DECLARE_PARSER_EXT(snl_nhmsg_parser, sizeof(struct nhmsg), sizeof(struct snl_parsed_nhop), _fp_p_nh, _nla_p_nh, _cb_p_nh); -static const struct snl_hdr_parser *snl_all_route_parsers[] = { - &_metrics_mp_nh_parser, &_mpath_nh_parser, &_metrics_parser, &snl_rtm_route_parser, - &_link_fbsd_parser, &snl_rtm_link_parser, &snl_rtm_link_parser_simple, - &_neigh_fbsd_parser, &snl_rtm_neigh_parser, - &_addr_fbsd_parser, &snl_rtm_addr_parser, &_nh_fbsd_parser, &snl_nhmsg_parser, -}; - #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/netlink/netlink_var.h b/lib/libc/include/generic-freebsd/netlink/netlink_var.h index 2f47cc85222a7ad7e04ef4510254d9e5d979976e..5fc67229b9813dac671ecd3542f1a6c218304359 100644 --- a/lib/libc/include/generic-freebsd/netlink/netlink_var.h +++ b/lib/libc/include/generic-freebsd/netlink/netlink_var.h @@ -43,33 +43,32 @@ struct ucred; -struct nl_io_queue { - STAILQ_HEAD(, mbuf) head; - int length; - int hiwat; +struct nl_buf { + TAILQ_ENTRY(nl_buf) tailq; + u_int buflen; + u_int datalen; + u_int offset; + char data[]; }; #define NLP_MAX_GROUPS 128 +BITSET_DEFINE(nl_groups, NLP_MAX_GROUPS); struct nlpcb { struct socket *nl_socket; - uint64_t nl_groups[NLP_MAX_GROUPS / 64]; + struct nl_groups nl_groups; uint32_t nl_port; uint32_t nl_flags; uint32_t nl_process_id; int nl_proto; - bool nl_active; bool nl_bound; bool nl_task_pending; bool nl_tx_blocked; /* No new requests accepted */ bool nl_linux; /* true if running under compat */ bool nl_unconstrained_vnet; /* true if running under VNET jail (or without jail) */ bool nl_need_thread_setup; - struct nl_io_queue rx_queue; - struct nl_io_queue tx_queue; struct taskqueue *nl_taskqueue; struct task nl_task; - struct ucred *nl_cred; /* Copy of nl_socket->so_cred */ uint64_t nl_dropped_bytes; uint64_t nl_dropped_messages; CK_LIST_ENTRY(nlpcb) nl_next; @@ -96,31 +95,19 @@ struct nlpcb { SYSCTL_DECL(_net_netlink); SYSCTL_DECL(_net_netlink_debug); -struct nl_io { - struct callout callout; - struct mbuf *head; - struct mbuf *last; - int64_t length; -}; - struct nl_control { CK_LIST_HEAD(nl_pid_head, nlpcb) ctl_port_head; CK_LIST_HEAD(nlpcb_head, nlpcb) ctl_pcb_head; CK_LIST_ENTRY(nl_control) ctl_next; - struct nl_io ctl_io; struct rmlock ctl_lock; }; -VNET_DECLARE(struct nl_control *, nl_ctl); +VNET_DECLARE(struct nl_control, nl_ctl); #define V_nl_ctl VNET(nl_ctl) - struct sockaddr_nl; struct sockaddr; struct nlmsghdr; -/* netlink_module.c */ -struct nl_control *vnet_nl_ctl_init(void); - int nl_verify_proto(int proto); const char *nl_get_proto_name(int proto); @@ -133,57 +120,34 @@ struct nl_proto_handler { extern struct nl_proto_handler *nl_handlers; /* netlink_domain.c */ -void nl_send_group(struct mbuf *m, int cnt, int proto, int group_id); +bool nl_send_group(struct nl_writer *); +void nl_clear_group(u_int); void nl_osd_register(void); void nl_osd_unregister(void); void nl_set_thread_nlp(struct thread *td, struct nlpcb *nlp); /* netlink_io.c */ -#define NL_IOF_UNTRANSLATED 0x01 -#define NL_IOF_IGNORE_LIMIT 0x02 -bool nl_send_one(struct mbuf *m, struct nlpcb *nlp, int cnt, int io_flags); +bool nl_send(struct nl_writer *, struct nlpcb *); void nlmsg_ack(struct nlpcb *nlp, int error, struct nlmsghdr *nlmsg, struct nl_pstate *npt); void nl_on_transmit(struct nlpcb *nlp); -void nl_init_io(struct nlpcb *nlp); -void nl_free_io(struct nlpcb *nlp); void nl_taskqueue_handler(void *_arg, int pending); -int nl_receive_async(struct mbuf *m, struct socket *so); +void nl_schedule_taskqueue(struct nlpcb *nlp); void nl_process_receive_locked(struct nlpcb *nlp); void nl_set_source_metadata(struct mbuf *m, int num_messages); -void nl_add_msg_info(struct mbuf *m); - -/* netlink_message_writer.c */ -void nl_init_msg_zone(void); -void nl_destroy_msg_zone(void); - -/* netlink_generic.c */ -struct genl_family { - const char *family_name; - uint16_t family_hdrsize; - uint16_t family_id; - uint16_t family_version; - uint16_t family_attr_max; - uint16_t family_cmd_size; - uint16_t family_num_groups; - struct genl_cmd *family_cmds; -}; - -struct genl_group { - struct genl_family *group_family; - const char *group_name; -}; - -struct genl_family *genl_get_family(uint32_t family_id); -struct genl_group *genl_get_group(uint32_t group_id); +struct nl_buf *nl_buf_alloc(size_t len, int mflag); +void nl_buf_free(struct nl_buf *nb); #define MAX_FAMILIES 20 #define MAX_GROUPS 64 #define MIN_GROUP_NUM 48 +#define CTRL_FAMILY_ID 0 #define CTRL_FAMILY_NAME "nlctrl" +#define CTRL_GROUP_ID 0 +#define CTRL_GROUP_NAME "notify" struct ifnet; struct nl_parsed_link; @@ -194,14 +158,15 @@ struct nl_pstate; struct nl_function_wrapper { bool (*nlmsg_add)(struct nl_writer *nw, uint32_t portid, uint32_t seq, uint16_t type, uint16_t flags, uint32_t len); - bool (*nlmsg_refill_buffer)(struct nl_writer *nw, int required_len); + bool (*nlmsg_refill_buffer)(struct nl_writer *nw, size_t required_len); bool (*nlmsg_flush)(struct nl_writer *nw); bool (*nlmsg_end)(struct nl_writer *nw); void (*nlmsg_abort)(struct nl_writer *nw); void (*nlmsg_ignore_limit)(struct nl_writer *nw); - bool (*nlmsg_get_unicast_writer)(struct nl_writer *nw, int size, struct nlpcb *nlp); - bool (*nlmsg_get_group_writer)(struct nl_writer *nw, int size, int protocol, int group_id); - bool (*nlmsg_get_chain_writer)(struct nl_writer *nw, int size, struct mbuf **pm); + bool (*nl_writer_unicast)(struct nl_writer *nw, size_t size, + struct nlpcb *nlp, bool waitok); + bool (*nl_writer_group)(struct nl_writer *nw, size_t size, + uint16_t protocol, uint16_t group_id, int priv, bool waitok); bool (*nlmsg_end_dump)(struct nl_writer *nw, int error, struct nlmsghdr *hdr); int (*nl_modify_ifp_generic)(struct ifnet *ifp, struct nl_parsed_link *lattrs, const struct nlattr_bmask *bm, struct nl_pstate *npt); diff --git a/lib/libc/include/generic-freebsd/netlink/route/route.h b/lib/libc/include/generic-freebsd/netlink/route/route.h index 9f765853ede58a54a470f5da38dda2e390ba81d0..14bc246d8d9ad1c2553f0f9b648cfa2f61767111 100644 --- a/lib/libc/include/generic-freebsd/netlink/route/route.h +++ b/lib/libc/include/generic-freebsd/netlink/route/route.h @@ -134,9 +134,10 @@ enum rt_scope_t { /* * Routing table identifiers. - * FreeBSD route table numbering starts from 0, where 0 is a valid default routing table. - * Indicating "all tables" via netlink can be done by not including RTA_TABLE attribute - * and keeping rtm_table=0 (compatibility) or setting RTA_TABLE value to RT_TABLE_UNSPEC. + * FreeBSD route table numbering starts from 0, where 0 is a valid default + * routing table. Indicating "all tables" via netlink can be done by not + * including RTA_TABLE attribute and keeping rtm_table=0 (compatibility) or + * setting RTA_TABLE value to RT_TABLE_UNSPEC. */ #define RT_TABLE_MAIN 0 /* RT_DEFAULT_FIB */ #define RT_TABLE_UNSPEC 0xFFFFFFFF /* RT_ALL_FIBS */ diff --git a/lib/libc/include/generic-freebsd/netlink/route/route_var.h b/lib/libc/include/generic-freebsd/netlink/route/route_var.h index bf039b524df79ea56b5568d7c22e7929fb72c1d4..fad06bc5da035bc5a8464ba1031fcc8e31cff10c 100644 --- a/lib/libc/include/generic-freebsd/netlink/route/route_var.h +++ b/lib/libc/include/generic-freebsd/netlink/route/route_var.h @@ -69,6 +69,7 @@ struct nl_parsed_link { char *ifla_cloner; char *ifla_ifalias; struct nlattr *ifla_idata; + struct nlattr *ifla_address; unsigned short ifi_type; int ifi_index; uint32_t ifla_link; diff --git a/lib/libc/include/generic-freebsd/netpfil/pf/pf.h b/lib/libc/include/generic-freebsd/netpfil/pf/pf.h index dcd427e9780b88a04b6c52af7f623785024acef0..da529a5b26e0fa105a02b083b95882ff0d70668a 100644 --- a/lib/libc/include/generic-freebsd/netpfil/pf/pf.h +++ b/lib/libc/include/generic-freebsd/netpfil/pf/pf.h @@ -49,7 +49,7 @@ enum { PF_INOUT, PF_IN, PF_OUT }; enum { PF_PASS, PF_DROP, PF_SCRUB, PF_NOSCRUB, PF_NAT, PF_NONAT, PF_BINAT, PF_NOBINAT, PF_RDR, PF_NORDR, PF_SYNPROXY_DROP, PF_DEFER, - PF_MATCH }; + PF_MATCH, PF_AFRT, PF_RT }; enum { PF_RULESET_SCRUB, PF_RULESET_FILTER, PF_RULESET_NAT, PF_RULESET_BINAT, PF_RULESET_RDR, PF_RULESET_MAX }; enum { PF_OP_NONE, PF_OP_IRG, PF_OP_EQ, PF_OP_NE, PF_OP_LT, @@ -113,29 +113,38 @@ enum { #define PFTM_OTHER_FIRST_PACKET_VAL 60 /* First packet */ #define PFTM_OTHER_SINGLE_VAL 30 /* Unidirectional */ #define PFTM_OTHER_MULTIPLE_VAL 60 /* Bidirectional */ -#define PFTM_FRAG_VAL 30 /* Fragment expire */ +#define PFTM_FRAG_VAL 60 /* Fragment expire */ #define PFTM_INTERVAL_VAL 10 /* Expire interval */ #define PFTM_SRC_NODE_VAL 0 /* Source tracking */ #define PFTM_TS_DIFF_VAL 30 /* Allowed TS diff */ enum { PF_NOPFROUTE, PF_FASTROUTE, PF_ROUTETO, PF_DUPTO, PF_REPLYTO }; enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS, - PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX }; + PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_ANCHORS, PF_LIMIT_ETH_ANCHORS, + PF_LIMIT_MAX }; #define PF_POOL_IDMASK 0x0f enum { PF_POOL_NONE, PF_POOL_BITMASK, PF_POOL_RANDOM, PF_POOL_SRCHASH, PF_POOL_ROUNDROBIN }; enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, PF_ADDR_TABLE, PF_ADDR_URPFFAILED, - PF_ADDR_RANGE }; + PF_ADDR_RANGE, PF_ADDR_NONE }; #define PF_POOL_TYPEMASK 0x0f #define PF_POOL_STICKYADDR 0x20 +#define PF_POOL_ENDPI 0x40 +#define PF_POOL_IPV6NH 0x80 #define PF_WSCALE_FLAG 0x80 #define PF_WSCALE_MASK 0x0f +#define PF_POOL_DYNTYPE(_o) \ + ((((_o) & PF_POOL_TYPEMASK) == PF_POOL_ROUNDROBIN) || \ + (((_o) & PF_POOL_TYPEMASK) == PF_POOL_RANDOM) || \ + (((_o) & PF_POOL_TYPEMASK) == PF_POOL_SRCHASH)) + #define PF_LOG 0x01 #define PF_LOG_ALL 0x02 -#define PF_LOG_SOCKET_LOOKUP 0x04 +#define PF_LOG_USER 0x04 #define PF_LOG_FORCE 0x08 +#define PF_LOG_MATCHES 0x10 /* Reasons code for passing/dropping a packet */ #define PFRES_MATCH 0 /* Explicit match of a rule */ @@ -154,7 +163,8 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, #define PFRES_SRCLIMIT 13 /* Source node/conn limit */ #define PFRES_SYNPROXY 14 /* SYN proxy */ #define PFRES_MAPFAILED 15 /* pf_map_addr() failed */ -#define PFRES_MAX 16 /* total+1 */ +#define PFRES_TRANSLATE 16 /* No translation address available */ +#define PFRES_MAX 17 /* total+1 */ #define PFRES_NAMES { \ "match", \ @@ -173,6 +183,7 @@ enum { PF_ADDR_ADDRMASK, PF_ADDR_NOROUTE, PF_ADDR_DYNIFTL, "src-limit", \ "synproxy", \ "map-failed", \ + "translate", \ NULL \ } @@ -480,6 +491,9 @@ struct pf_osfp_ioctl { }; #define PF_ANCHOR_NAME_SIZE 64 +#define PF_ANCHOR_MAXPATH (MAXPATHLEN - PF_ANCHOR_NAME_SIZE - 1) +#define PF_ANCHOR_HIWAT 512 +#define PF_OPTIMIZER_TABLE_PFX "__automatic_" struct pf_rule { struct pf_rule_addr src; @@ -489,8 +503,8 @@ struct pf_rule { #define PF_SKIP_AF 2 #define PF_SKIP_PROTO 3 #define PF_SKIP_SRC_ADDR 4 -#define PF_SKIP_SRC_PORT 5 -#define PF_SKIP_DST_ADDR 6 +#define PF_SKIP_DST_ADDR 5 +#define PF_SKIP_SRC_PORT 6 #define PF_SKIP_DST_PORT 7 #define PF_SKIP_COUNT 8 union pf_rule_ptr skip[PF_SKIP_COUNT]; @@ -614,6 +628,9 @@ struct pf_rule { #define PFRULE_SET_TOS 0x00002000 #define PFRULE_IFBOUND 0x00010000 /* if-bound */ #define PFRULE_STATESLOPPY 0x00020000 /* sloppy state tracking */ +#define PFRULE_PFLOW 0x00040000 +#define PFRULE_ALLOW_RELATED 0x00080000 +#define PFRULE_AFTO 0x00200000 /* af-to rule */ #ifdef _KERNEL #define PFRULE_REFS 0x0080 /* rule has references */ @@ -626,7 +643,7 @@ struct pf_rule { /* pf_state->state_flags, pf_rule_actions->flags, pf_krule->scrub_flags */ #define PFSTATE_ALLOWOPTS 0x0001 #define PFSTATE_SLOPPY 0x0002 -/* was PFSTATE_PFLOW 0x0004 */ +#define PFSTATE_PFLOW 0x0004 #define PFSTATE_NOSYNC 0x0008 #define PFSTATE_ACK 0x0010 #define PFSTATE_NODF 0x0020 @@ -642,6 +659,12 @@ struct pf_rule { #define PFSTATE_SCRUBMASK (PFSTATE_NODF|PFSTATE_RANDOMID|PFSTATE_SCRUB_TCP) #define PFSTATE_SETMASK (PFSTATE_SETTOS|PFSTATE_SETPRIO) +/* pfctl_state->src_node_flags */ +#define PFSTATE_SRC_NODE_LIMIT 0x01 +#define PFSTATE_SRC_NODE_NAT 0x02 +#define PFSTATE_SRC_NODE_ROUTE 0x04 +#define PFSTATE_SRC_NODE_LIMIT_GLOBAL 0x10 + #define PFSTATE_HIWAT 100000 /* default state table size */ #define PFSTATE_ADAPT_START 60000 /* default adaptive timeout start */ #define PFSTATE_ADAPT_END 120000 /* default adaptive timeout end */ @@ -670,6 +693,7 @@ struct pf_src_node { u_int32_t creation; u_int32_t expire; sa_family_t af; + sa_family_t naf; u_int8_t ruletype; }; diff --git a/lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h b/lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h index 6e1781891616109647f4172eed2bf9b12dcd91e2..a423f89d44e4377e528276f0ba42692b9b050b68 100644 --- a/lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h +++ b/lib/libc/include/generic-freebsd/netpfil/pf/pf_mtag.h @@ -41,7 +41,7 @@ #define PF_MTAG_FLAG_TRANSLATE_LOCALHOST 0x04 #define PF_MTAG_FLAG_PACKET_LOOPED 0x08 #define PF_MTAG_FLAG_FASTFWD_OURS_PRESENT 0x10 -/* 0x20 unused */ +#define PF_MTAG_FLAG_DUMMYNETED 0x20 #define PF_MTAG_FLAG_DUPLICATED 0x40 #define PF_MTAG_FLAG_SYNCOOKIE_RECREATED 0x80 diff --git a/lib/libc/include/generic-freebsd/netpfil/pf/pf_nl.h b/lib/libc/include/generic-freebsd/netpfil/pf/pf_nl.h new file mode 100644 index 0000000000000000000000000000000000000000..8582612ca55667e6e4710867a3172d5dd9ea64b7 --- /dev/null +++ b/lib/libc/include/generic-freebsd/netpfil/pf/pf_nl.h @@ -0,0 +1,492 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Alexander V. Chernikov + * Copyright (c) 2023 Rubicon Communications, LLC (Netgate) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef _NETPFIL_PF_PF_NL_H_ +#define _NETPFIL_PF_PF_NL_H_ + +/* Genetlink family */ +#define PFNL_FAMILY_NAME "pfctl" + +/* available commands */ +enum { + PFNL_CMD_UNSPEC = 0, + PFNL_CMD_GETSTATES = 1, + PFNL_CMD_GETCREATORS = 2, + PFNL_CMD_START = 3, + PFNL_CMD_STOP = 4, + PFNL_CMD_ADDRULE = 5, + PFNL_CMD_GETRULES = 6, + PFNL_CMD_GETRULE = 7, + PFNL_CMD_CLRSTATES = 8, + PFNL_CMD_KILLSTATES = 9, + PFNL_CMD_SET_STATUSIF = 10, + PFNL_CMD_GET_STATUS = 11, + PFNL_CMD_CLEAR_STATUS = 12, + PFNL_CMD_NATLOOK = 13, + PFNL_CMD_SET_DEBUG = 14, + PFNL_CMD_SET_TIMEOUT = 15, + PFNL_CMD_GET_TIMEOUT = 16, + PFNL_CMD_SET_LIMIT = 17, + PFNL_CMD_GET_LIMIT = 18, + PFNL_CMD_BEGIN_ADDRS = 19, + PFNL_CMD_ADD_ADDR = 20, + PFNL_CMD_GET_ADDRS = 21, + PFNL_CMD_GET_ADDR = 22, + PFNL_CMD_GET_RULESETS = 23, + PFNL_CMD_GET_RULESET = 24, + PFNL_CMD_GET_SRCNODES = 25, + PFNL_CMD_CLEAR_TABLES = 26, + PFNL_CMD_ADD_TABLE = 27, + PFNL_CMD_DEL_TABLE = 28, + PFNL_CMD_GET_TSTATS = 29, + PFNL_CMD_CLR_TSTATS = 30, + PFNL_CMD_CLR_ADDRS = 31, + PFNL_CMD_TABLE_ADD_ADDR = 32, + PFNL_CMD_TABLE_DEL_ADDR = 33, + __PFNL_CMD_MAX, +}; +#define PFNL_CMD_MAX (__PFNL_CMD_MAX -1) + +enum pfstate_key_type_t { + PF_STK_UNSPEC, + PF_STK_ADDR0 = 1, /* ip */ + PF_STK_ADDR1 = 2, /* ip */ + PF_STK_PORT0 = 3, /* u16 */ + PF_STK_PORT1 = 4, /* u16 */ + PF_STK_AF = 5, /* u8 */ + PF_STK_PROTO = 6, /* u16 */ +}; + +enum pfstate_peer_type_t { + PF_STP_UNSPEC, + PF_STP_PFSS_FLAGS = 1, /* u16 */ + PF_STP_PFSS_TTL = 2, /* u8 */ + PF_STP_SCRUB_FLAG = 3, /* u8 */ + PF_STP_PFSS_TS_MOD = 4, /* u32 */ + PF_STP_SEQLO = 5, /* u32 */ + PF_STP_SEQHI = 6, /* u32 */ + PF_STP_SEQDIFF = 7, /* u32 */ + PF_STP_MAX_WIN = 8, /* u16 */ + PF_STP_MSS = 9, /* u16 */ + PF_STP_STATE = 10, /* u8 */ + PF_STP_WSCALE = 11, /* u8 */ +}; + +enum pfstate_type_t { + PF_ST_UNSPEC, + PF_ST_ID = 1, /* u32, state id */ + PF_ST_CREATORID = 2, /* u32, */ + PF_ST_IFNAME = 3, /* string */ + PF_ST_ORIG_IFNAME = 4, /* string */ + PF_ST_KEY_WIRE = 5, /* nested, pfstate_key_type_t */ + PF_ST_KEY_STACK = 6, /* nested, pfstate_key_type_t */ + PF_ST_PEER_SRC = 7, /* nested, pfstate_peer_type_t*/ + PF_ST_PEER_DST = 8, /* nested, pfstate_peer_type_t */ + PF_ST_RT_ADDR = 9, /* ip */ + PF_ST_RULE = 10, /* u32 */ + PF_ST_ANCHOR = 11, /* u32 */ + PF_ST_NAT_RULE = 12, /* u32 */ + PF_ST_CREATION = 13, /* u32 */ + PF_ST_EXPIRE = 14, /* u32 */ + PF_ST_PACKETS0 = 15, /* u64 */ + PF_ST_PACKETS1 = 16, /* u64 */ + PF_ST_BYTES0 = 17, /* u64 */ + PF_ST_BYTES1 = 18, /* u64 */ + PF_ST_AF = 19, /* u8 */ + PF_ST_PROTO = 21, /* u8 */ + PF_ST_DIRECTION = 22, /* u8 */ + PF_ST_LOG = 23, /* u8 */ + PF_ST_TIMEOUT = 24, /* u8 */ + PF_ST_STATE_FLAGS = 25, /* u8 */ + PF_ST_SYNC_FLAGS = 26, /* u8 */ + PF_ST_UPDATES = 27, /* u8 */ + PF_ST_VERSION = 28, /* u64 */ + PF_ST_FILTER_ADDR = 29, /* in6_addr */ + PF_ST_FILTER_MASK = 30, /* in6_addr */ + PF_ST_RTABLEID = 31, /* i32 */ + PF_ST_MIN_TTL = 32, /* u8 */ + PF_ST_MAX_MSS = 33, /* u16 */ + PF_ST_DNPIPE = 34, /* u16 */ + PF_ST_DNRPIPE = 35, /* u16 */ + PF_ST_RT = 36, /* u8 */ + PF_ST_RT_IFNAME = 37, /* string */ + PF_ST_SRC_NODE_FLAGS = 38, /* u8 */ + PF_ST_RT_AF = 39, /* u8 */ +}; + +enum pf_addr_type_t { + PF_AT_UNSPEC, + PF_AT_ADDR = 1, /* in6_addr */ + PF_AT_MASK = 2, /* in6_addr */ + PF_AT_IFNAME = 3, /* string */ + PF_AT_TABLENAME = 4, /* string */ + PF_AT_TYPE = 5, /* u8 */ + PF_AT_IFLAGS = 6, /* u8 */ + PF_AT_TBLCNT = 7, /* u32 */ + PF_AT_DYNCNT = 8, /* u32 */ +}; + +enum pfrule_addr_type_t { + PF_RAT_UNSPEC, + PF_RAT_ADDR = 1, /* nested, pf_addr_type_t */ + PF_RAT_SRC_PORT = 2, /* u16 */ + PF_RAT_DST_PORT = 3, /* u16 */ + PF_RAT_NEG = 4, /* u8 */ + PF_RAT_OP = 5, /* u8 */ +}; + +enum pf_labels_type_t { + PF_LT_UNSPEC, + PF_LT_LABEL = 1, /* string */ +}; + +enum pf_mape_portset_type_t +{ + PF_MET_UNSPEC, + PF_MET_OFFSET = 1, /* u8 */ + PF_MET_PSID_LEN = 2, /* u8 */ + PF_MET_PSID = 3, /* u16 */ +}; + +enum pf_rpool_type_t +{ + PF_PT_UNSPEC, + PF_PT_KEY = 1, /* bytes, sizeof(struct pf_poolhashkey) */ + PF_PT_COUNTER = 2, /* in6_addr */ + PF_PT_TBLIDX = 3, /* u32 */ + PF_PT_PROXY_SRC_PORT = 4, /* u16 */ + PF_PT_PROXY_DST_PORT = 5, /* u16 */ + PF_PT_OPTS = 6, /* u8 */ + PF_PT_MAPE = 7, /* nested, pf_mape_portset_type_t */ +}; + +enum pf_timeout_type_t { + PF_TT_UNSPEC, + PF_TT_TIMEOUT = 1, /* u32 */ +}; + +enum pf_rule_uid_type_t { + PF_RUT_UNSPEC, + PF_RUT_UID_LOW = 1, /* u32 */ + PF_RUT_UID_HIGH = 2, /* u32 */ + PF_RUT_OP = 3, /* u8 */ +}; + +enum pf_rule_type_t { + PF_RT_UNSPEC, + PF_RT_SRC = 1, /* nested, pf_rule_addr_type_t */ + PF_RT_DST = 2, /* nested, pf_rule_addr_type_t */ + PF_RT_RIDENTIFIER = 3, /* u32 */ + PF_RT_LABELS = 4, /* nested, pf_labels_type_t */ + PF_RT_IFNAME = 5, /* string */ + PF_RT_QNAME = 6, /* string */ + PF_RT_PQNAME = 7, /* string */ + PF_RT_TAGNAME = 8, /* string */ + PF_RT_MATCH_TAGNAME = 9, /* string */ + PF_RT_OVERLOAD_TBLNAME = 10, /* string */ + PF_RT_RPOOL_RDR = 11, /* nested, pf_rpool_type_t */ + PF_RT_OS_FINGERPRINT = 12, /* u32 */ + PF_RT_RTABLEID = 13, /* u32 */ + PF_RT_TIMEOUT = 14, /* nested, pf_timeout_type_t */ + PF_RT_MAX_STATES = 15, /* u32 */ + PF_RT_MAX_SRC_NODES = 16, /* u32 */ + PF_RT_MAX_SRC_STATES = 17, /* u32 */ + PF_RT_MAX_SRC_CONN_RATE_LIMIT = 18, /* u32 */ + PF_RT_MAX_SRC_CONN_RATE_SECS = 19, /* u32 */ + PF_RT_DNPIPE = 20, /* u16 */ + PF_RT_DNRPIPE = 21, /* u16 */ + PF_RT_DNFLAGS = 22, /* u32 */ + PF_RT_NR = 23, /* u32 */ + PF_RT_PROB = 24, /* u32 */ + PF_RT_CUID = 25, /* u32 */ + PF_RT_CPID = 26, /* u32 */ + PF_RT_RETURN_ICMP = 27, /* u16 */ + PF_RT_RETURN_ICMP6 = 28, /* u16 */ + PF_RT_MAX_MSS = 29, /* u16 */ + PF_RT_SCRUB_FLAGS = 30, /* u16 */ + PF_RT_UID = 31, /* nested, pf_rule_uid_type_t */ + PF_RT_GID = 32, /* nested, pf_rule_uid_type_t */ + PF_RT_RULE_FLAG = 33, /* u32 */ + PF_RT_ACTION = 34, /* u8 */ + PF_RT_DIRECTION = 35, /* u8 */ + PF_RT_LOG = 36, /* u8 */ + PF_RT_LOGIF = 37, /* u8 */ + PF_RT_QUICK = 38, /* u8 */ + PF_RT_IF_NOT = 39, /* u8 */ + PF_RT_MATCH_TAG_NOT = 40, /* u8 */ + PF_RT_NATPASS = 41, /* u8 */ + PF_RT_KEEP_STATE = 42, /* u8 */ + PF_RT_AF = 43, /* u8 */ + PF_RT_PROTO = 44, /* u8 */ + PF_RT_TYPE = 45, /* u8 */ + PF_RT_CODE = 46, /* u8 */ + PF_RT_FLAGS = 47, /* u8 */ + PF_RT_FLAGSET = 48, /* u8 */ + PF_RT_MIN_TTL = 49, /* u8 */ + PF_RT_ALLOW_OPTS = 50, /* u8 */ + PF_RT_RT = 51, /* u8 */ + PF_RT_RETURN_TTL = 52, /* u8 */ + PF_RT_TOS = 53, /* u8 */ + PF_RT_SET_TOS = 54, /* u8 */ + PF_RT_ANCHOR_RELATIVE = 55, /* u8 */ + PF_RT_ANCHOR_WILDCARD = 56, /* u8 */ + PF_RT_FLUSH = 57, /* u8 */ + PF_RT_PRIO = 58, /* u8 */ + PF_RT_SET_PRIO = 59, /* u8 */ + PF_RT_SET_PRIO_REPLY = 60, /* u8 */ + PF_RT_DIVERT_ADDRESS = 61, /* in6_addr */ + PF_RT_DIVERT_PORT = 62, /* u16 */ + PF_RT_PACKETS_IN = 63, /* u64 */ + PF_RT_PACKETS_OUT = 64, /* u64 */ + PF_RT_BYTES_IN = 65, /* u64 */ + PF_RT_BYTES_OUT = 66, /* u64 */ + PF_RT_EVALUATIONS = 67, /* u64 */ + PF_RT_TIMESTAMP = 68, /* u64 */ + PF_RT_STATES_CUR = 69, /* u64 */ + PF_RT_STATES_TOTAL = 70, /* u64 */ + PF_RT_SRC_NODES = 71, /* u64 */ + PF_RT_ANCHOR_CALL = 72, /* string */ + PF_RT_RCV_IFNAME = 73, /* string */ + PF_RT_MAX_SRC_CONN = 74, /* u32 */ + PF_RT_RPOOL_NAT = 75, /* nested, pf_rpool_type_t */ + PF_RT_NAF = 76, /* u8 */ + PF_RT_RPOOL_RT = 77, /* nested, pf_rpool_type_t */ + PF_RT_RCV_IFNOT = 78, /* bool */ + PF_RT_SRC_NODES_LIMIT = 79, /* u64 */ + PF_RT_SRC_NODES_NAT = 80, /* u64 */ + PF_RT_SRC_NODES_ROUTE = 81, /* u64 */ + PF_RT_PKTRATE = 82, /* nested, pf_threshold_type_t */ + PF_RT_MAX_PKT_SIZE = 83, /* u16 */ + PF_RT_TYPE_2 = 84, /* u16 */ + PF_RT_CODE_2 = 85, /* u16 */ +}; + +enum pf_addrule_type_t { + PF_ART_UNSPEC, + PF_ART_TICKET = 1, /* u32 */ + PF_ART_POOL_TICKET = 2, /* u32 */ + PF_ART_ANCHOR = 3, /* string */ + PF_ART_ANCHOR_CALL = 4, /* string */ + PF_ART_RULE = 5, /* nested, pfrule_type_t */ +}; + +enum pf_getrules_type_t { + PF_GR_UNSPEC, + PF_GR_ANCHOR = 1, /* string */ + PF_GR_ACTION = 2, /* u8 */ + PF_GR_NR = 3, /* u32 */ + PF_GR_TICKET = 4, /* u32 */ + PF_GR_CLEAR = 5, /* u8 */ +}; + +enum pf_clear_states_type_t { + PF_CS_UNSPEC, + PF_CS_CMP_ID = 1, /* u64 */ + PF_CS_CMP_CREATORID = 2, /* u32 */ + PF_CS_CMP_DIR = 3, /* u8 */ + PF_CS_AF = 4, /* u8 */ + PF_CS_PROTO = 5, /* u8 */ + PF_CS_SRC = 6, /* nested, pf_addr_wrap */ + PF_CS_DST = 7, /* nested, pf_addr_wrap */ + PF_CS_RT_ADDR = 8, /* nested, pf_addr_wrap */ + PF_CS_IFNAME = 9, /* string */ + PF_CS_LABEL = 10, /* string */ + PF_CS_KILL_MATCH = 11, /* bool */ + PF_CS_NAT = 12, /* bool */ + PF_CS_KILLED = 13, /* u32 */ +}; + +enum pf_set_statusif_types_t { + PF_SS_UNSPEC, + PF_SS_IFNAME = 1, /* string */ +}; + +enum pf_counter_types_t { + PF_C_UNSPEC, + PF_C_COUNTER = 1, /* u64 */ + PF_C_NAME = 2, /* string */ + PF_C_ID = 3, /* u32 */ +}; + +enum pf_get_status_types_t { + PF_GS_UNSPEC, + PF_GS_IFNAME = 1, /* string */ + PF_GS_RUNNING = 2, /* bool */ + PF_GS_SINCE = 3, /* u32 */ + PF_GS_DEBUG = 4, /* u32 */ + PF_GS_HOSTID = 5, /* u32 */ + PF_GS_STATES = 6, /* u32 */ + PF_GS_SRC_NODES = 7, /* u32 */ + PF_GS_REASSEMBLE = 8, /* u32 */ + PF_GS_SYNCOOKIES_ACTIVE = 9, /* bool */ + PF_GS_COUNTERS = 10, /* nested, */ + PF_GS_LCOUNTERS = 11, /* nested, */ + PF_GS_FCOUNTERS = 12, /* nested, */ + PF_GS_SCOUNTERS = 13, /* nested, */ + PF_GS_CHKSUM = 14, /* byte array */ + PF_GS_PCOUNTERS = 15, /* u64 array */ + PF_GS_BCOUNTERS = 16, /* u64 array */ +}; + +enum pf_natlook_types_t { + PF_NL_UNSPEC, + PF_NL_AF = 1, /* u8 */ + PF_NL_DIRECTION = 2, /* u8 */ + PF_NL_PROTO = 3, /* u8 */ + PF_NL_SRC_ADDR = 4, /* in6_addr */ + PF_NL_DST_ADDR = 5, /* in6_addr */ + PF_NL_SRC_PORT = 6, /* u16 */ + PF_NL_DST_PORT = 7, /* u16 */ +}; + +enum pf_set_debug_types_t { + PF_SD_UNSPEC, + PF_SD_LEVEL = 1, /* u32 */ +}; + +enum pf_timeout_types_t { + PF_TO_UNSPEC, + PF_TO_TIMEOUT = 1, /* u32 */ + PF_TO_SECONDS = 2, /* u32 */ +}; + +enum pf_limit_types_t { + PF_LI_UNSPEC, + PF_LI_INDEX = 1, /* u32 */ + PF_LI_LIMIT = 2, /* u32 */ +}; + +enum pf_begin_addrs_types_t { + PF_BA_UNSPEC, + PF_BA_TICKET = 1, /* u32 */ +}; + +enum pf_pool_addr_types_t { + PF_PA_UNSPEC, + PF_PA_ADDR = 1, /* nested, pf_addr_wrap */ + PF_PA_IFNAME = 2, /* string */ +}; + +enum pf_add_addr_types_t { + PF_AA_UNSPEC, + PF_AA_ACTION = 1, /* u32 */ + PF_AA_TICKET = 2, /* u32 */ + PF_AA_NR = 3, /* u32 */ + PF_AA_R_NUM = 4, /* u32 */ + PF_AA_R_ACTION = 5, /* u8 */ + PF_AA_R_LAST = 6, /* u8 */ + PF_AA_AF = 7, /* u8 */ + PF_AA_ANCHOR = 8, /* string */ + PF_AA_ADDR = 9, /* nested, pf_pooladdr */ + PF_AA_WHICH = 10, /* u32 */ +}; + +enum pf_get_rulesets_types_t { + PF_RS_UNSPEC, + PF_RS_PATH = 1, /* string */ + PF_RS_NR = 2, /* u32 */ + PF_RS_NAME = 3, /* string */ +}; + +enum pf_threshold_types_t { + PF_TH_UNSPEC, + PF_TH_LIMIT = 1, /* u32 */ + PF_TH_SECONDS = 2, /* u32 */ + PF_TH_COUNT = 3, /* u32 */ + PF_TH_LAST = 4, /* u32 */ +}; + +enum pf_srcnodes_types_t { + PF_SN_UNSPEC, + PF_SN_ADDR = 1, /* nested, pf_addr */ + PF_SN_RADDR = 2, /* nested, pf_addr */ + PF_SN_RULE_NR = 3, /* u32 */ + PF_SN_BYTES_IN = 4, /* u64 */ + PF_SN_BYTES_OUT = 5, /* u64 */ + PF_SN_PACKETS_IN = 6, /* u64 */ + PF_SN_PACKETS_OUT = 7, /* u64 */ + PF_SN_STATES = 8, /* u32 */ + PF_SN_CONNECTIONS = 9, /* u32 */ + PF_SN_AF = 10, /* u8 */ + PF_SN_RULE_TYPE = 11, /* u8 */ + PF_SN_CREATION = 12, /* u64 */ + PF_SN_EXPIRE = 13, /* u64 */ + PF_SN_CONNECTION_RATE = 14, /* nested, pf_threshold */ + PF_SN_RAF = 15, /* u8 */ + PF_SN_NODE_TYPE = 16, /* u8 */ +}; + +enum pf_tables_t { + PF_T_UNSPEC, + PF_T_ANCHOR = 1, /* string */ + PF_T_NAME = 2, /* string */ + PF_T_TABLE_FLAGS = 3, /* u32 */ + PF_T_FLAGS = 4, /* u32 */ + PF_T_NBR_DELETED = 5, /* u32 */ + PF_T_NBR_ADDED = 6, /* u32 */ +}; + +enum pf_tstats_t { + PF_TS_UNSPEC, + PF_TS_TABLE = 1, /* nested, pfr_table */ + PF_TS_PACKETS = 2, /* u64 array */ + PF_TS_BYTES = 3, /* u64 array */ + PF_TS_MATCH = 4, /* u64 */ + PF_TS_NOMATCH = 5, /* u64 */ + PF_TS_TZERO = 6, /* u64 */ + PF_TS_CNT = 7, /* u64 */ + PF_TS_REFCNT = 8, /* u64 array */ + PF_TS_NZERO = 9, /* u64 */ +}; + +enum pfr_addr_t { + PFR_A_UNSPEC, + PFR_A_AF = 1, /* uint8_t */ + PFR_A_NET = 2, /* uint8_t */ + PFR_A_NOT = 3, /* bool */ + PFR_A_ADDR = 4, /* in6_addr */ +}; + +enum pf_table_addrs_t { + PF_TA_UNSPEC, + PF_TA_TABLE = 1, /* nested, pf_table_t */ + PF_TA_ADDR = 2, /* nested, pfr_addr_t */ + PF_TA_FLAGS = 3, /* u32 */ + PF_TA_NBR_ADDED = 4, /* u32 */ + PF_TA_NBR_DELETED = 5, /* u32 */ +}; + +#ifdef _KERNEL + +void pf_nl_register(void); +void pf_nl_unregister(void); + +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/nfs/nfsdiskless.h b/lib/libc/include/generic-freebsd/nfs/nfsdiskless.h index b98351ef96c75023243f491b176e36b3a53d1f0b..7aecb7b43de89e9d9b6fbf734e2fc463f810ca34 100644 --- a/lib/libc/include/generic-freebsd/nfs/nfsdiskless.h +++ b/lib/libc/include/generic-freebsd/nfs/nfsdiskless.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfsdiskless.h 8.2 (Berkeley) 3/30/95 */ #ifndef _NFSCLIENT_NFSDISKLESS_H_ diff --git a/lib/libc/include/generic-freebsd/nfs/nfsproto.h b/lib/libc/include/generic-freebsd/nfs/nfsproto.h index cfc66b8c6e42f4045522523bcbcfcd0ce0797ba7..936885ed5752816312aa9ffaf74ccb6e821ba3de 100644 --- a/lib/libc/include/generic-freebsd/nfs/nfsproto.h +++ b/lib/libc/include/generic-freebsd/nfs/nfsproto.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95 */ #ifndef _NFS_NFSPROTO_H_ diff --git a/lib/libc/include/generic-freebsd/nfs/xdr_subs.h b/lib/libc/include/generic-freebsd/nfs/xdr_subs.h index d17157c5f9b8225c2a05bff5c702fcb423fb3800..27c5697926a6178b4eb28b6d9cffb08a2b312eda 100644 --- a/lib/libc/include/generic-freebsd/nfs/xdr_subs.h +++ b/lib/libc/include/generic-freebsd/nfs/xdr_subs.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95 */ #ifndef _NFS_XDR_SUBS_H_ diff --git a/lib/libc/include/generic-freebsd/nfsclient/nfs.h b/lib/libc/include/generic-freebsd/nfsclient/nfs.h index 0314c78c4a6deef5c4b4b32a30b118399dae0699..fa917ec4f7ff36380cca0ef903aca5773bb70a13 100644 --- a/lib/libc/include/generic-freebsd/nfsclient/nfs.h +++ b/lib/libc/include/generic-freebsd/nfsclient/nfs.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfs.h 8.4 (Berkeley) 5/1/95 */ #ifndef _NFSCLIENT_NFS_H_ diff --git a/lib/libc/include/generic-freebsd/nfsclient/nfsargs.h b/lib/libc/include/generic-freebsd/nfsclient/nfsargs.h index 3d49d86c3905ec51d188d505cfc60b2f6f3da615..68e2006fe96c7964dc3e8049c93bfc2112184347 100644 --- a/lib/libc/include/generic-freebsd/nfsclient/nfsargs.h +++ b/lib/libc/include/generic-freebsd/nfsclient/nfsargs.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfs.h 8.4 (Berkeley) 5/1/95 */ #ifndef _NFSCLIENT_NFSARGS_H_ diff --git a/lib/libc/include/generic-freebsd/nfsclient/nfsmount.h b/lib/libc/include/generic-freebsd/nfsclient/nfsmount.h index 0d5d87bcabd00cec0e55365de8fc8fa8872cfb5a..9ef05998dda172bf22158c413755bb090f73828a 100644 --- a/lib/libc/include/generic-freebsd/nfsclient/nfsmount.h +++ b/lib/libc/include/generic-freebsd/nfsclient/nfsmount.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfsmount.h 8.3 (Berkeley) 3/30/95 */ #ifndef _NFSCLIENT_NFSMOUNT_H_ diff --git a/lib/libc/include/generic-freebsd/nfsclient/nfsnode.h b/lib/libc/include/generic-freebsd/nfsclient/nfsnode.h index 0f8fa85d02573d89ed9359dbd0c3ba63ce0033f0..9434d8d4ef32d99f758152cb08a701f79de10573 100644 --- a/lib/libc/include/generic-freebsd/nfsclient/nfsnode.h +++ b/lib/libc/include/generic-freebsd/nfsclient/nfsnode.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95 */ #ifndef _NFSCLIENT_NFSNODE_H_ diff --git a/lib/libc/include/generic-freebsd/nfsclient/nfsstats.h b/lib/libc/include/generic-freebsd/nfsclient/nfsstats.h index 0865f513b32b66078e464c7d035297d2c3f94205..246c588b8e299ec870ffcd3bede4886466f83b00 100644 --- a/lib/libc/include/generic-freebsd/nfsclient/nfsstats.h +++ b/lib/libc/include/generic-freebsd/nfsclient/nfsstats.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfs.h 8.4 (Berkeley) 5/1/95 */ #ifndef _NFSCLIENT_NFSSTATS_H_ diff --git a/lib/libc/include/generic-freebsd/nfsserver/nfs.h b/lib/libc/include/generic-freebsd/nfsserver/nfs.h index 2f313551c8b2996ef6a6c8dd9c6f32fbfdbe5a0e..7f186249f7cc08834a89b7d8af416df15f549b40 100644 --- a/lib/libc/include/generic-freebsd/nfsserver/nfs.h +++ b/lib/libc/include/generic-freebsd/nfsserver/nfs.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfs.h 8.4 (Berkeley) 5/1/95 */ #ifndef _NFSSERVER_NFS_H_ diff --git a/lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h b/lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h index adb36b9523325cc9fdb1276cccd6eb183519a43a..564207996bb72da7dc204f025650e6a21aae5b22 100644 --- a/lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h +++ b/lib/libc/include/generic-freebsd/nfsserver/nfsrvstats.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nfs.h 8.4 (Berkeley) 5/1/95 */ #ifndef _NFSSERVER_NFSRVSTATS_H_ diff --git a/lib/libc/include/generic-freebsd/nl_types.h b/lib/libc/include/generic-freebsd/nl_types.h index 68f7d6982225f720f3f683295ee3fc113db6ef19..efea87bc4ef5c65fdd867f6974ef887c4a0f0798 100644 --- a/lib/libc/include/generic-freebsd/nl_types.h +++ b/lib/libc/include/generic-freebsd/nl_types.h @@ -34,7 +34,6 @@ #ifndef _NL_TYPES_H_ #define _NL_TYPES_H_ -#include #include #ifdef _NLS_PRIVATE diff --git a/lib/libc/include/generic-freebsd/nlist.h b/lib/libc/include/generic-freebsd/nlist.h index d075b20871fea254c302a482c3ba12f3ca90550b..a10a5532c3dc164c5b815be88a237fcfd5c985bc 100644 --- a/lib/libc/include/generic-freebsd/nlist.h +++ b/lib/libc/include/generic-freebsd/nlist.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nlist.h 8.2 (Berkeley) 1/21/94 */ #ifndef _NLIST_H_ diff --git a/lib/libc/include/generic-freebsd/osreldate.h b/lib/libc/include/generic-freebsd/osreldate.h index 1cbc95cd36742f91bb3a43e8f8b72ca1980d652b..81afbd301b148fd2978ee22c64067d340f9eb8ca 100644 --- a/lib/libc/include/generic-freebsd/osreldate.h +++ b/lib/libc/include/generic-freebsd/osreldate.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1992-2023 The FreeBSD Project. + * Copyright (c) 1992-2025 The FreeBSD Project. * */ #ifdef _KERNEL diff --git a/lib/libc/include/generic-freebsd/paths.h b/lib/libc/include/generic-freebsd/paths.h index 371deb51d0e2c18e0b391db25996ba8297ed161c..60b3d872bb3868f3508d4038a6c03529fbca1e98 100644 --- a/lib/libc/include/generic-freebsd/paths.h +++ b/lib/libc/include/generic-freebsd/paths.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)paths.h 8.1 (Berkeley) 6/2/93 */ #ifndef _PATHS_H_ @@ -63,7 +61,6 @@ #define _PATH_FIRMWARE "/usr/share/firmware" #define _PATH_FTPUSERS "/etc/ftpusers" #define _PATH_FWMEM "/dev/fwmem" -#define _PATH_GBDE "/sbin/gbde" #define _PATH_GELI "/sbin/geli" #define _PATH_HALT "/sbin/halt" #ifdef COMPAT_libcompat @@ -84,6 +81,7 @@ #define _PATH_MOUNT "/sbin/mount" #define _PATH_NEWFS "/sbin/newfs" #define _PATH_NOLOGIN "/var/run/nologin" +#define _PATH_NOSHUTDOWN "/var/run/noshutdown" #define _PATH_RCP "/bin/rcp" #define _PATH_REBOOT "/sbin/reboot" #define _PATH_RLOGIN "/usr/bin/rlogin" diff --git a/lib/libc/include/generic-freebsd/poll.h b/lib/libc/include/generic-freebsd/poll.h index a731b70329ff5e51ef0a8c0c00dca1445679a1eb..b915f5a37d7efd3ca558e0a3a8d49b31a9a4c601 100644 --- a/lib/libc/include/generic-freebsd/poll.h +++ b/lib/libc/include/generic-freebsd/poll.h @@ -96,7 +96,7 @@ struct pollfd { #ifndef _KERNEL -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 202405 #include #include @@ -109,9 +109,13 @@ typedef __sigset_t sigset_t; #endif +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 202405 int ppoll(struct pollfd _pfd[], nfds_t _nfds, const struct timespec *__restrict _timeout, const sigset_t *__restrict _newsigmask); diff --git a/lib/libc/include/generic-freebsd/protocols/dumprestore.h b/lib/libc/include/generic-freebsd/protocols/dumprestore.h index 37b53648151a6a4d4aab54dab833ecc7c5a4223d..ef3e9e4f1156d44c8f14823318d8477b89bff7c3 100644 --- a/lib/libc/include/generic-freebsd/protocols/dumprestore.h +++ b/lib/libc/include/generic-freebsd/protocols/dumprestore.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94 */ #ifndef _PROTOCOLS_DUMPRESTORE_H_ diff --git a/lib/libc/include/generic-freebsd/protocols/routed.h b/lib/libc/include/generic-freebsd/protocols/routed.h index ba2dc2db56bcb1e9cfa613d14ac8e43ac6b059b1..9d282efcc7bfda185e163025223930b8332237d2 100644 --- a/lib/libc/include/generic-freebsd/protocols/routed.h +++ b/lib/libc/include/generic-freebsd/protocols/routed.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)routed.h 8.1 (Berkeley) 6/2/93 * $Revision: 2.26 $ */ diff --git a/lib/libc/include/generic-freebsd/protocols/rwhod.h b/lib/libc/include/generic-freebsd/protocols/rwhod.h index 793d5d6aba69056339885f6538747957c1285fa5..a995671b864c33748875bf1d46b0d11b67d74906 100644 --- a/lib/libc/include/generic-freebsd/protocols/rwhod.h +++ b/lib/libc/include/generic-freebsd/protocols/rwhod.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)rwhod.h 8.1 (Berkeley) 6/2/93 */ #ifndef _PROTOCOLS_RWHOD_H_ diff --git a/lib/libc/include/generic-freebsd/protocols/talkd.h b/lib/libc/include/generic-freebsd/protocols/talkd.h index 82fe09d452826ecaf05246007d08a6e0b8b2e8c5..116f0ee3e761a1bb946e7c169d33c515800ee8be 100644 --- a/lib/libc/include/generic-freebsd/protocols/talkd.h +++ b/lib/libc/include/generic-freebsd/protocols/talkd.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)talkd.h 8.1 (Berkeley) 6/2/93 */ #ifndef _PROTOCOLS_TALKD_H_ diff --git a/lib/libc/include/generic-freebsd/protocols/timed.h b/lib/libc/include/generic-freebsd/protocols/timed.h index 48618d6f5a1a1dfe4faf4245277922490f2b6d33..18fda3f954d68a4bc97ef86f1ba04ec5698d2768 100644 --- a/lib/libc/include/generic-freebsd/protocols/timed.h +++ b/lib/libc/include/generic-freebsd/protocols/timed.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)timed.h 8.1 (Berkeley) 6/2/93 */ #ifndef _PROTOCOLS_TIMED_H_ diff --git a/lib/libc/include/generic-freebsd/pthread_np.h b/lib/libc/include/generic-freebsd/pthread_np.h index 4453944892755841c2a9e51830f1108babd41ecb..9c4ec917d27d7f6504f8ad0e540e62f2291d2250 100644 --- a/lib/libc/include/generic-freebsd/pthread_np.h +++ b/lib/libc/include/generic-freebsd/pthread_np.h @@ -34,11 +34,6 @@ #include #include -/* - * Non-POSIX type definitions: - */ -typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); - /* * Non-POSIX thread function prototype definitions: */ @@ -64,11 +59,11 @@ int pthread_resume_np(pthread_t); int pthread_peekjoin_np(pthread_t, void **); void pthread_set_name_np(pthread_t, const char *); int pthread_setaffinity_np(pthread_t, size_t, const cpuset_t *); +void pthread_signals_block_np(void); +void pthread_signals_unblock_np(void); int pthread_single_np(void); void pthread_suspend_all_np(void); int pthread_suspend_np(pthread_t); -int pthread_switch_add_np(pthread_switch_routine_t); -int pthread_switch_delete_np(pthread_switch_routine_t); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); __END_DECLS diff --git a/lib/libc/include/generic-freebsd/pwd.h b/lib/libc/include/generic-freebsd/pwd.h index b1834446995ce656668b77118a70007c5f1ebef3..6e5a081c5b28aee0816b70922b413935c0b44a1a 100644 --- a/lib/libc/include/generic-freebsd/pwd.h +++ b/lib/libc/include/generic-freebsd/pwd.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)pwd.h 8.2 (Berkeley) 1/21/94 */ #ifndef _PWD_H_ diff --git a/lib/libc/include/generic-freebsd/ranlib.h b/lib/libc/include/generic-freebsd/ranlib.h index bc8d09fcf8af2ccfacb6e909caac3228d35702c2..0038e3d302a0a75b0024b915ffa85ed118c44f20 100644 --- a/lib/libc/include/generic-freebsd/ranlib.h +++ b/lib/libc/include/generic-freebsd/ranlib.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ranlib.h 8.1 (Berkeley) 6/2/93 */ #ifndef _RANLIB_H_ diff --git a/lib/libc/include/generic-freebsd/regex.h b/lib/libc/include/generic-freebsd/regex.h index 4e6f91d9d2d41539ec426f2557cf059ebadd61f6..ec98c574d7d4f5317a5893cc68244286caa33404 100644 --- a/lib/libc/include/generic-freebsd/regex.h +++ b/lib/libc/include/generic-freebsd/regex.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)regex.h 8.2 (Berkeley) 1/3/94 */ #ifndef _REGEX_H_ diff --git a/lib/libc/include/generic-freebsd/resolv.h b/lib/libc/include/generic-freebsd/resolv.h index 0d871655d98ea9936848a1881131547cac7a8a83..03da1cf95c66624502070e8b1edccec299254c98 100644 --- a/lib/libc/include/generic-freebsd/resolv.h +++ b/lib/libc/include/generic-freebsd/resolv.h @@ -47,7 +47,6 @@ */ /*% - * @(#)resolv.h 8.1 (Berkeley) 6/2/93 * $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $ */ diff --git a/lib/libc/include/generic-freebsd/rpc/auth.h b/lib/libc/include/generic-freebsd/rpc/auth.h index b6d923124b35fb336e0ffafa160629b5cc761463..81b7e496436e258d48e0f1f634728d4a0a170b92 100644 --- a/lib/libc/include/generic-freebsd/rpc/auth.h +++ b/lib/libc/include/generic-freebsd/rpc/auth.h @@ -28,10 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)auth.h 1.17 88/02/08 SMI - * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC - * from: @(#)auth.h 1.43 98/02/02 SMI */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/auth_des.h b/lib/libc/include/generic-freebsd/rpc/auth_des.h index f3ba957d3a2fb2949cc753ec81112735e70970f8..f02b90e064793004f3e5ca061dccf6f6b8961ead 100644 --- a/lib/libc/include/generic-freebsd/rpc/auth_des.h +++ b/lib/libc/include/generic-freebsd/rpc/auth_des.h @@ -1,4 +1,3 @@ -/* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ /*- * SPDX-License-Identifier: BSD-3-Clause * @@ -28,8 +27,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC - * from: @(#)auth_des.h 1.14 94/04/25 SMI */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/auth_unix.h b/lib/libc/include/generic-freebsd/rpc/auth_unix.h index b68956b3b6922e074305702250855c4cc0d03b02..7494012dceb007ac74c1a6a9f82b28dce5a0414a 100644 --- a/lib/libc/include/generic-freebsd/rpc/auth_unix.h +++ b/lib/libc/include/generic-freebsd/rpc/auth_unix.h @@ -26,9 +26,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)auth_unix.h 1.8 88/02/08 SMI - * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/clnt.h b/lib/libc/include/generic-freebsd/rpc/clnt.h index fa44155733519e5bcc23bdf9389ce940d8bf6cef..a3601d47d52c6c074454e70c1e95aca796e9c773 100644 --- a/lib/libc/include/generic-freebsd/rpc/clnt.h +++ b/lib/libc/include/generic-freebsd/rpc/clnt.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)clnt.h 1.31 94/04/29 SMI - * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/clnt_nl.h b/lib/libc/include/generic-freebsd/rpc/clnt_nl.h new file mode 100644 index 0000000000000000000000000000000000000000..224a9c14255b676820fd43744f735cc5b1544c6a --- /dev/null +++ b/lib/libc/include/generic-freebsd/rpc/clnt_nl.h @@ -0,0 +1,42 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Gleb Smirnoff + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RPC_CLNT_NL_H +#define _RPC_CLNT_NL_H + +enum rpcnl_cmds_t { + RPCNL_REQUEST = 1, /* mcast: kernel -> userland */ + RPCNL_REPLY, /* unicast: userland -> kernel */ +}; + +enum rpcnl_attr_t { + RPCNL_REQUEST_GROUP = 1, + RPCNL_REQUEST_BODY, + RPCNL_REPLY_GROUP, + RPCNL_REPLY_BODY, +}; +#endif /* _RPC_CLNT_NL_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/rpc/clnt_stat.h b/lib/libc/include/generic-freebsd/rpc/clnt_stat.h index d63bb895a70690714d9eeded91e05b3dff7ec2d4..6905029fff4644c0aa48d1a3247e0fb5064c722e 100644 --- a/lib/libc/include/generic-freebsd/rpc/clnt_stat.h +++ b/lib/libc/include/generic-freebsd/rpc/clnt_stat.h @@ -11,8 +11,6 @@ #ifndef _RPC_CLNT_STAT_H #define _RPC_CLNT_STAT_H -/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */ - #ifdef __cplusplus extern "C" { #endif diff --git a/lib/libc/include/generic-freebsd/rpc/des.h b/lib/libc/include/generic-freebsd/rpc/des.h index cc51b3bb604f9daf5b8510ad5bb299f5a28d48cc..de1dcdb9ef71b27f0da17776d04b97d15e4632ba 100644 --- a/lib/libc/include/generic-freebsd/rpc/des.h +++ b/lib/libc/include/generic-freebsd/rpc/des.h @@ -1,4 +1,3 @@ -/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ /*- * SPDX-License-Identifier: BSD-3-Clause * @@ -57,26 +56,6 @@ struct desparams { # define des_buf UDES.UDES_buf /* otherwise, pointer to data */ }; -#ifdef notdef - -/* - * These ioctls are only implemented in SunOS. Maybe someday - * if somebody writes a driver for DES hardware that works - * with FreeBSD, we can being that back. - */ - -/* - * Encrypt an arbitrary sized buffer - */ -#define DESIOCBLOCK _IOWR('d', 6, struct desparams) - -/* - * Encrypt of small amount of data, quickly - */ -#define DESIOCQUICK _IOWR('d', 7, struct desparams) - -#endif - /* * Software DES. */ diff --git a/lib/libc/include/generic-freebsd/rpc/des_crypt.h b/lib/libc/include/generic-freebsd/rpc/des_crypt.h index 7028777a01bfe8d9b173c4009b1dbf47d08065b7..c9e20fca6f87bcf222a6895a6009ff26cd60a3ad 100644 --- a/lib/libc/include/generic-freebsd/rpc/des_crypt.h +++ b/lib/libc/include/generic-freebsd/rpc/des_crypt.h @@ -1,5 +1,4 @@ /* - * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI * * des_crypt.h, des library routine interface * Copyright (C) 1986, Sun Microsystems, Inc. diff --git a/lib/libc/include/generic-freebsd/rpc/key_prot.h b/lib/libc/include/generic-freebsd/rpc/key_prot.h index f34d0133dae0ee536914460077273e6c91563df1..4541929b6a0d0de648e571603d13dad32da0d330 100644 --- a/lib/libc/include/generic-freebsd/rpc/key_prot.h +++ b/lib/libc/include/generic-freebsd/rpc/key_prot.h @@ -42,10 +42,6 @@ extern "C" { * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */ -/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -#include - /* * Compiled from key_prot.x using rpcgen. * DO NOT EDIT THIS FILE! diff --git a/lib/libc/include/generic-freebsd/rpc/pmap_clnt.h b/lib/libc/include/generic-freebsd/rpc/pmap_clnt.h index 3ff3ae906b0d8db78565a2c40da55b378c067bef..510e953549610aca2a9290bb05e0d8f8ee0d1f30 100644 --- a/lib/libc/include/generic-freebsd/rpc/pmap_clnt.h +++ b/lib/libc/include/generic-freebsd/rpc/pmap_clnt.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI - * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/pmap_prot.h b/lib/libc/include/generic-freebsd/rpc/pmap_prot.h index 704a6c71b70e457dce1ff0c16df9f48c956613b9..8ea0df569fff6f3c0a416e2b7316b3ca18a4c806 100644 --- a/lib/libc/include/generic-freebsd/rpc/pmap_prot.h +++ b/lib/libc/include/generic-freebsd/rpc/pmap_prot.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_prot.h 1.14 88/02/08 SMI - * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/pmap_rmt.h b/lib/libc/include/generic-freebsd/rpc/pmap_rmt.h index 8be6811decdef6cc43b06f1b96ea721684fb8df1..02c5e0939f5dcb7ff8cb9d6d17b255d2035dca20 100644 --- a/lib/libc/include/generic-freebsd/rpc/pmap_rmt.h +++ b/lib/libc/include/generic-freebsd/rpc/pmap_rmt.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI - * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/raw.h b/lib/libc/include/generic-freebsd/rpc/raw.h index d0b54abf8dbf955df41eef7e42c0834039d2343c..afa739e1255e0594c92fb6401f7b518088bf3cda 100644 --- a/lib/libc/include/generic-freebsd/rpc/raw.h +++ b/lib/libc/include/generic-freebsd/rpc/raw.h @@ -36,9 +36,6 @@ #ifndef _RPC_RAW_H #define _RPC_RAW_H -/* from: @(#)raw.h 1.11 94/04/25 SMI */ -/* from: @(#)raw.h 1.2 88/10/25 SMI */ - #ifdef __cplusplus extern "C" { #endif diff --git a/lib/libc/include/generic-freebsd/rpc/rpc.h b/lib/libc/include/generic-freebsd/rpc/rpc.h index e4c1302c7bf2329adbd9fe48ce20e34d46f5c55b..8832c23d5622530f2b5be5b27be77260175a498f 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpc.h +++ b/lib/libc/include/generic-freebsd/rpc/rpc.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)rpc.h 1.9 88/02/08 SMI - * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/rpc_com.h b/lib/libc/include/generic-freebsd/rpc/rpc_com.h index f435e163c3af5a25b3778ad5401394105f7c2bef..1beb67a707798e54c1701733b3125562962c9b9c 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpc_com.h +++ b/lib/libc/include/generic-freebsd/rpc/rpc_com.h @@ -44,8 +44,6 @@ #include -/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ - /* * The max size of the transport, if the size cannot be determined * by other means. diff --git a/lib/libc/include/generic-freebsd/rpc/rpc_msg.h b/lib/libc/include/generic-freebsd/rpc/rpc_msg.h index 92fa4276a26216b2c7678ce241482597b7a7aa5c..f76f82c1b19fce4762a1c9744a5115176cc1fbde 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpc_msg.h +++ b/lib/libc/include/generic-freebsd/rpc/rpc_msg.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)rpc_msg.h 1.7 86/07/16 SMI - * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h b/lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h index 8aead1af0d16fdcee6e06a0c3bdbec51ea9be43b..2b47110d763f812246496052b87e098afbec33c1 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h +++ b/lib/libc/include/generic-freebsd/rpc/rpcb_clnt.h @@ -55,7 +55,6 @@ #ifndef _RPC_RPCB_CLNT_H #define _RPC_RPCB_CLNT_H -/* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */ /* rpcb_clnt.h 1.3 88/12/05 SMI */ #include diff --git a/lib/libc/include/generic-freebsd/rpc/rpcb_prot.h b/lib/libc/include/generic-freebsd/rpc/rpcb_prot.h index 35b4c450635730e1b9f38e47068828643f523888..bb33f29e64141bedad8c64f96377adfd7e49177e 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpcb_prot.h +++ b/lib/libc/include/generic-freebsd/rpc/rpcb_prot.h @@ -44,8 +44,6 @@ extern "C" { */ /* from rpcb_prot.x */ -/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ - #ifndef _KERNEL diff --git a/lib/libc/include/generic-freebsd/rpc/rpcb_prot.x b/lib/libc/include/generic-freebsd/rpc/rpcb_prot.x index 7feee8aeae8e98d6e024587828b6e84eef0c13a9..8a6027d971b8de9e048551968f8b7239f45b9e12 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpcb_prot.x +++ b/lib/libc/include/generic-freebsd/rpc/rpcb_prot.x @@ -33,8 +33,6 @@ #ifdef RPC_HDR % -%/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ -% %#ifndef _KERNEL % #endif diff --git a/lib/libc/include/generic-freebsd/rpc/rpcent.h b/lib/libc/include/generic-freebsd/rpc/rpcent.h index 1e6415c2b2e22a3105859688d34fa729f2f9e74e..4bd144450717ee474b2f622bf0ec37ccaae3704c 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpcent.h +++ b/lib/libc/include/generic-freebsd/rpc/rpcent.h @@ -42,10 +42,6 @@ #ifndef _RPC_RPCENT_H #define _RPC_RPCENT_H -/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ -/* @(#)rpcent.h 1.1 88/12/06 SMI */ - - struct rpcent { char *r_name; /* name of server for this rpc program */ char **r_aliases; /* alias list */ diff --git a/lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h b/lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h index fade49c1ef7d7ab64fdb4fec7ac23300b40c59c2..0ec985e383ca2699f6dbc47f925a0bb175faa29d 100644 --- a/lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h +++ b/lib/libc/include/generic-freebsd/rpc/rpcsec_tls.h @@ -28,20 +28,8 @@ #ifndef _RPC_RPCSEC_TLS_H_ #define _RPC_RPCSEC_TLS_H_ -/* Operation values for rpctls syscall. */ -#define RPCTLS_SYSC_CLSETPATH 1 -#define RPCTLS_SYSC_CLSOCKET 2 -#define RPCTLS_SYSC_CLSHUTDOWN 3 -#define RPCTLS_SYSC_SRVSETPATH 4 -#define RPCTLS_SYSC_SRVSOCKET 5 -#define RPCTLS_SYSC_SRVSHUTDOWN 6 -#define RPCTLS_SYSC_SRVSTARTUP 7 - -/* Max nprocs for SRV startup */ -#define RPCTLS_SRV_MAXNPROCS 16 - -/* System call used by the rpctlscd, rpctlssd daemons. */ -int rpctls_syscall(int, const char *); +/* System call used by the rpc.tlsclntd(8), rpc.tlsservd(8) daemons. */ +int rpctls_syscall(uint64_t); /* Flag bits to indicate certificate results. */ #define RPCTLS_FLAGS_HANDSHAKE 0x01 @@ -61,15 +49,11 @@ int rpctls_syscall(int, const char *); #ifdef _KERNEL /* Functions that perform upcalls to the rpctlsd daemon. */ enum clnt_stat rpctls_connect(CLIENT *newclient, char *certname, - struct socket *so, uint64_t *sslp, uint32_t *reterr); -enum clnt_stat rpctls_cl_handlerecord(uint64_t sec, uint64_t usec, - uint64_t ssl, uint32_t *reterr); -enum clnt_stat rpctls_srv_handlerecord(uint64_t sec, uint64_t usec, - uint64_t ssl, int procpos, uint32_t *reterr); -enum clnt_stat rpctls_cl_disconnect(uint64_t sec, uint64_t usec, - uint64_t ssl, uint32_t *reterr); -enum clnt_stat rpctls_srv_disconnect(uint64_t sec, uint64_t usec, - uint64_t ssl, int procpos, uint32_t *reterr); + struct socket *so, uint32_t *reterr); +enum clnt_stat rpctls_cl_handlerecord(void *socookie, uint32_t *reterr); +enum clnt_stat rpctls_srv_handlerecord(void *socookie, uint32_t *reterr); +enum clnt_stat rpctls_cl_disconnect(void *socookie, uint32_t *reterr); +enum clnt_stat rpctls_srv_disconnect(void *socookie, uint32_t *reterr); /* Initialization function for rpcsec_tls. */ int rpctls_init(void); @@ -81,9 +65,6 @@ bool rpctls_getinfo(u_int *maxlen, bool rpctlscd_run, /* String for AUTH_TLS reply verifier. */ #define RPCTLS_START_STRING "STARTTLS" -/* ssl refno value to indicate TLS handshake being done. */ -#define RPCTLS_REFNO_HANDSHAKE 0xFFFFFFFFFFFFFFFFULL - /* Macros for VIMAGE. */ /* Just define the KRPC_VNETxxx() macros as VNETxxx() macros. */ #define KRPC_VNET_NAME(n) VNET_NAME(n) diff --git a/lib/libc/include/generic-freebsd/rpc/svc.h b/lib/libc/include/generic-freebsd/rpc/svc.h index a1bc765bea8ce90b587b728cccffb9198adc9f79..860c0927b95583ee004a04c5c0e57b627179422c 100644 --- a/lib/libc/include/generic-freebsd/rpc/svc.h +++ b/lib/libc/include/generic-freebsd/rpc/svc.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)svc.h 1.35 88/12/17 SMI - * from: @(#)svc.h 1.27 94/04/25 SMI */ /* @@ -458,6 +455,19 @@ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); */ extern SVCXPRT *svcunixfd_create(int, u_int, u_int); +/* + * netlink(4) server creation. To be used to service requests that + * originate from an in-kernel client. + */ +extern SVCXPRT *svc_nl_create(const char *); + +/* + * Arguments to SVC_CONTROL(svc_nl) + */ +enum { + SVCNL_GET_XIDKEY = 1, /* obtain pthread specific key for xid */ +}; + /* * Memory based rpc (for speed check and testing) */ diff --git a/lib/libc/include/generic-freebsd/rpc/svc_auth.h b/lib/libc/include/generic-freebsd/rpc/svc_auth.h index 6f035780510eb1315549333bdd2c90cfb09d6ee2..4e206823638f8d68f83530a610eb1c947a265a54 100644 --- a/lib/libc/include/generic-freebsd/rpc/svc_auth.h +++ b/lib/libc/include/generic-freebsd/rpc/svc_auth.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)svc_auth.h 1.6 86/07/16 SMI - * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/svc_soc.h b/lib/libc/include/generic-freebsd/rpc/svc_soc.h index 36d1defe920671adb6573fec19a9f0706641049f..8513e48042e08fda8e13db0150c7c75d3e2d74a1 100644 --- a/lib/libc/include/generic-freebsd/rpc/svc_soc.h +++ b/lib/libc/include/generic-freebsd/rpc/svc_soc.h @@ -41,7 +41,6 @@ #define _RPC_SVC_SOC_H #include -/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ /* svc_soc.h 1.8 89/05/01 SMI */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/types.h b/lib/libc/include/generic-freebsd/rpc/types.h index 0a99cedb2577803526990f25362fac6214379435..691feec8da55f9b8c63b2046f55c00658ef2a261 100644 --- a/lib/libc/include/generic-freebsd/rpc/types.h +++ b/lib/libc/include/generic-freebsd/rpc/types.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)types.h 1.18 87/07/24 SMI - * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpc/xdr.h b/lib/libc/include/generic-freebsd/rpc/xdr.h index 4fa2b95d864171307af3a676353bf6e4e542c152..d614b6dcbd5d30739c543ac2ee92d82e301961df 100644 --- a/lib/libc/include/generic-freebsd/rpc/xdr.h +++ b/lib/libc/include/generic-freebsd/rpc/xdr.h @@ -28,9 +28,6 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)xdr.h 1.19 87/04/22 SMI - * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC */ /* diff --git a/lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x index 418bd5e9714a079af22249fabdca8103ec06ff65..30f2fd8112266c23ef51808717d4d0a185eb649b 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/bootparam_prot.x @@ -45,12 +45,6 @@ %#include %#include %#include -#else -%#ifndef lint -%/*static char sccsid[] = "from: @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include #endif const MAX_MACHINE_NAME = 255; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/crypt.x b/lib/libc/include/generic-freebsd/rpcsvc/crypt.x index 1eddfa8783b36757ce08f7967a1bb5402242d4d1..e3e14429d79fdb405ba9c2dde05be398a86c405d 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/crypt.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/crypt.x @@ -30,10 +30,6 @@ * SUCH DAMAGE. */ -#ifndef RPC_HDR -%#include -#endif - /* * This protocol definition exists because of the U.S. government and * its stupid export laws. We can't export DES code from the United diff --git a/lib/libc/include/generic-freebsd/rpcsvc/key_prot.h b/lib/libc/include/generic-freebsd/rpcsvc/key_prot.h index f34d0133dae0ee536914460077273e6c91563df1..4541929b6a0d0de648e571603d13dad32da0d330 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/key_prot.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/key_prot.h @@ -42,10 +42,6 @@ extern "C" { * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */ -/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -#include - /* * Compiled from key_prot.x using rpcgen. * DO NOT EDIT THIS FILE! diff --git a/lib/libc/include/generic-freebsd/rpcsvc/key_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/key_prot.x index d7f1d11f3bd14090835af65843b20fa414d8da6c..4d4d1f1341226441afed3a2d2484ccc08bf7bad9 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/key_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/key_prot.x @@ -45,10 +45,6 @@ * requirements. */ -%/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */ -%/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -%#include -% %/* % * Compiled from key_prot.x using rpcgen. % * DO NOT EDIT THIS FILE! diff --git a/lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x index 4a25d1d4557276260ec4318992e77e8fa906a28b..5dd5873743bd6d2eab165ef29dad54aa8ea8ca02 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/klm_prot.x @@ -38,14 +38,6 @@ * above the kernel. */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const LM_MAXSTRLEN = 1024; /* diff --git a/lib/libc/include/generic-freebsd/rpcsvc/mount.x b/lib/libc/include/generic-freebsd/rpcsvc/mount.x index 5d65c3ce676ecd2d4e414f35cadc3055ae7a89fa..9f6fa6384294d79f096877a362b71d9d1306de23 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/mount.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/mount.x @@ -33,14 +33,6 @@ * Protocol description for the mount program */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)mount.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ const MNTNAMLEN = 255; /* maximum bytes in a name argument */ const FHSIZE = 32; /* size in bytes of a file handle */ diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x index 3057bd31d5febdc541328f5009f76e4bb9f63489..13d65a3dc4c41a9da71e87afceecd53f934fbf39 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nfs_prot.x @@ -29,14 +29,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)nfs_prot.x 1.2 87/10/12 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const NFS_PORT = 2049; const NFS_MAXDATA = 8192; const NFS_MAXPATHLEN = 1024; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis.x b/lib/libc/include/generic-freebsd/rpcsvc/nis.x index e6d151cd5e7f57c7e7b8037d2f36179dd5e6b95b..80788f7ea6de69b878258ee5036ab0b2a36f0a0b 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis.x @@ -29,12 +29,7 @@ % * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % */ -#ifndef RPC_HDR -%#include -#endif - /* - * From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems * * RPC Language Protocol description file for NIS Plus * This version : 1.61 diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x b/lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x index e169ca9f26c6b2d32504084f86b68566c40ef4d1..cc41c616b159130abca6e8ff840294085fc8db50 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis_cache.x @@ -35,12 +35,6 @@ * All Rights Reserved. */ -/* From: %#pragma ident "@(#)nis_cache.x 1.11 94/05/03 SMI" */ - -#ifndef RPC_HDR -%#include -#endif - #ifdef RPC_HDR %#include %#include diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x b/lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x index ed53c0d7950b3505756c924867e76792003e0c78..13228a2782a15a5ff9688dbfdc5d34097da047ed 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis_callback.x @@ -36,14 +36,7 @@ * All Rights Reserved. */ -/* From: %#pragma ident "@(#)nis_callback.x 1.7 94/05/03 SMI" */ - -#ifndef RPC_HDR -%#include -#endif - /* - * "@(#)zns_cback.x 1.2 90/09/10 Copyr 1990 Sun Micro" * * RPCL description of the Callback Service. */ diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis_db.h b/lib/libc/include/generic-freebsd/rpcsvc/nis_db.h index 0442f910337085e0181ee74fe42736acc4fe7577..d89b6120b626fbe95d3731d9e7327b8c84f9734e 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis_db.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis_db.h @@ -42,8 +42,6 @@ #define _RPCSVC_NIS_DB_H -/* From: #pragma ident "@(#)nis_db.h 1.8 94/05/03 SMI" */ - /* * Note: although the version of shipped with Solaris * 2.5/2.5.x is actually older than this one (according to the ident diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis_object.x b/lib/libc/include/generic-freebsd/rpcsvc/nis_object.x index cb0f1c9f50d7d64d1e43067118384010ad585373..e09154b18e7aade6d47e214f90ac7cf83de1574e 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis_object.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis_object.x @@ -36,8 +36,6 @@ * All Rights Reserved. */ -/* From: %#pragma ident "@(#)nis_object.x 1.10 94/05/03 SMI" */ - #if RPC_HDR % %#ifndef __nis_object_h diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h b/lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h index 34a7301a6a9ce4c0d8ebd69c245c6424f2e1a928..011ecf8ded9ce9236614f1aec0f4c55efdf4bbd0 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/nis_tags.h @@ -45,7 +45,6 @@ #ifndef _RPCSVC_NIS_TAGS_H #define _RPCSVC_NIS_TAGS_H -/* From: #pragma ident "@(#)nis_tags.h 1.10 94/05/03 SMI" */ /* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */ #ifdef __cplusplus diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nislib.h b/lib/libc/include/generic-freebsd/rpcsvc/nislib.h index 38557bf9ebe1352ebe1e3e6011a08c9cc813c6b1..8b84056f61323e390ee7141908a94c5024bb8050 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nislib.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/nislib.h @@ -39,8 +39,6 @@ #ifndef _RPCSVC_NISLIB_H #define _RPCSVC_NISLIB_H -/* From: #pragma ident "@(#)nislib.h 1.16 94/05/03 SMI" */ - #ifdef __cplusplus extern "C" { #endif diff --git a/lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x index 7c11e427df1068316177dd0912fad5e03d82f5f9..f809d31d505919c21b47715a66937c3c76a8e2bf 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/nlm_prot.x @@ -8,14 +8,8 @@ #ifdef RPC_HDR %#define LM_MAXSTRLEN 1024 %#define MAXNAMELEN LM_MAXSTRLEN+1 -#else -%#include -%#ifndef lint -%/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $"); -%#endif /* not lint */ #endif +/* $NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $ */ /* * status of a call to the lock manager diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rex.x b/lib/libc/include/generic-freebsd/rpcsvc/rex.x index 1554d863870e6a0168946e23520d38bf1b6179d1..d8256467fa4e15b898893055ddeb6a2e754273c2 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rex.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/rex.x @@ -33,14 +33,6 @@ * Remote execution (rex) protocol specification */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rex.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const STRINGSIZE = 1024; typedef string rexstring<1024>; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rnusers.x b/lib/libc/include/generic-freebsd/rpcsvc/rnusers.x index 5f34fcb959f7fe93174df019da163578ce3c6e04..8ab76635eb2a688a2610e06f144f5038f267fa89 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rnusers.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/rnusers.x @@ -33,14 +33,6 @@ * Find out about remote users */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const MAXUSERS = 100; const MAXUTLEN = 256; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rquota.x b/lib/libc/include/generic-freebsd/rpcsvc/rquota.x index cc14494332f8061e9a6a85c50781f6cb72af7131..cb4c7d47abb53d64f16ea5e5008e483d6b188593 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rquota.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/rquota.x @@ -1,15 +1,8 @@ -/* @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */ - /* * Remote quota protocol * Requires unix authentication */ -#ifndef RPC_HDR -%#include -#endif - const RQ_PATHLEN = 1024; struct sq_dqblk { diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rstat.x b/lib/libc/include/generic-freebsd/rpcsvc/rstat.x index 3c3049b9de0e531b046db5f17c95789b939ce2e2..d1e8f2438e4be3313c7c43f41e2aa864b102d9ee 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rstat.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/rstat.x @@ -44,13 +44,6 @@ % %#endif /* ndef FSCALE */ -#else - -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include #endif /* def RPC_HDR */ const RSTAT_CPUSTATES = 4; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rwall.h b/lib/libc/include/generic-freebsd/rpcsvc/rwall.h index 58d95e31659e842f28320ddc67f32099467b2f70..cd1aa710dd29e843656d90603c70f855b6975389 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rwall.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/rwall.h @@ -45,8 +45,6 @@ extern "C" { * Copyright (c) 1984, 1990 by Sun Microsystems, Inc. */ -/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */ - #ifndef _rpcsvc_rwall_h #define _rpcsvc_rwall_h diff --git a/lib/libc/include/generic-freebsd/rpcsvc/rwall.x b/lib/libc/include/generic-freebsd/rpcsvc/rwall.x index 3bfbae8682428e5e0e856449cce44dce3eb24625..67e600a54ecf7d90b5cd670524dbaaf5fb4029c5 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/rwall.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/rwall.x @@ -31,8 +31,6 @@ %/* % * Copyright (c) 1984, 1990 by Sun Microsystems, Inc. % */ -% -%/* from @(#)rwall.x 1.6 91/03/11 TIRPC 1.0 */ #ifdef RPC_HDR % diff --git a/lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x b/lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x index 5565947e5ad63b6e456878181ead151544e338d4..b7ff3c17c8fd47fbf71bda36e1bd61f555f5d955 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/sm_inter.x @@ -1,6 +1,3 @@ -/* @(#)sm_inter.x 2.2 88/08/01 4.0 RPCSRC */ -/* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */ - /*- * Copyright (c) 2010, Oracle America, Inc. * @@ -38,10 +35,6 @@ * */ -#ifndef RPC_HDR -%#include -#endif - program SM_PROG { version SM_VERS { /* res_stat = stat_succ if status monitor agrees to monitor */ diff --git a/lib/libc/include/generic-freebsd/rpcsvc/spray.x b/lib/libc/include/generic-freebsd/rpcsvc/spray.x index 2fe910fe33f8070dee51daa302cef8c185acdf2f..c8d9ba33c1ef7697deafed0758fb1628f30ab25c 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/spray.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/spray.x @@ -34,14 +34,6 @@ * Useful for testing flakiness of network interfaces */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)spray.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - const SPRAYMAX = 8845; /* max amount can spray */ /* diff --git a/lib/libc/include/generic-freebsd/rpcsvc/yp.x b/lib/libc/include/generic-freebsd/rpcsvc/yp.x index 2234810d35b70612bbd37f2edba74b39199e9219..8af521cf38aefbdf6708a6b75f090995fa726f56 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/yp.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/yp.x @@ -1,5 +1,3 @@ -/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */ - /*- * Copyright (c) 2010, Oracle America, Inc. * @@ -35,10 +33,6 @@ * Protocol description file for the Yellow Pages Service */ -#ifndef RPC_HDR -%#include -#endif - const YPMAXRECORD = 16777216; const YPMAXDOMAIN = 64; const YPMAXMAP = 64; diff --git a/lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h b/lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h index dcc0a37f19167d7467fc0103291e4b85060031d9..f7c7935e6b2d15fc312cda8a49e32630d79aae56 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/yp_prot.h @@ -271,7 +271,7 @@ struct ypbind_setdom { * * Sun says: * "Protocol between clients (ypxfr, only) and yppush - * yppush speaks a protocol in the transient range, which + * speaks a protocol in the transient range, which * is supplied to ypxfr as a command-line parameter when it * is activated by ypserv." * diff --git a/lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x b/lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x index 7d2efba53fb2dde3dea98fefc4356b323521765d..0f2cfba00cc21fb708eb033a474b653f7a07270b 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/yppasswd.x @@ -34,14 +34,6 @@ * Requires unix authentication */ -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC";*/ -%#endif /* not lint */ -%#include -#endif - program YPPASSWDPROG { version YPPASSWDVERS { /* diff --git a/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h b/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h index dca7d59bfd6477c830b377a95a7aafab0c99d8ec..44609b8488b14b35ce57e5e6139f4eaf3f366773 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h +++ b/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.h @@ -45,7 +45,6 @@ extern "C" { * Copyright (c) 1986, 1990 by Sun Microsystems, Inc. */ -/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */ /* * Compiled from ypupdate_prot.x using rpcgen diff --git a/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x b/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x index edca0da832683b8e1f62c490d181219a0940be0c..8bee4e0ce981ec3074ecd4074666ebdf76a67d90 100644 --- a/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x +++ b/lib/libc/include/generic-freebsd/rpcsvc/ypupdate_prot.x @@ -32,7 +32,6 @@ % * Copyright (c) 1986, 1990 by Sun Microsystems, Inc. % */ % -%/* from @(#)ypupdate_prot.x 1.3 91/03/11 TIRPC 1.0 */ #ifndef RPC_HDR %#include #endif diff --git a/lib/libc/include/generic-freebsd/runetype.h b/lib/libc/include/generic-freebsd/runetype.h index 88601f7232af31c6c7f819306cc7044df87a7021..cb344862a53db645aa9ffaf2a3c10ee3c20e92c3 100644 --- a/lib/libc/include/generic-freebsd/runetype.h +++ b/lib/libc/include/generic-freebsd/runetype.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)runetype.h 8.1 (Berkeley) 6/2/93 */ #ifndef _RUNETYPE_H_ diff --git a/lib/libc/include/generic-freebsd/sched.h b/lib/libc/include/generic-freebsd/sched.h index ce0dc8983afc6854eb3ed26d0d0b4c06517bd905..7413acd0bbb68a16c3bd6c96e2cf23a56d3005bf 100644 --- a/lib/libc/include/generic-freebsd/sched.h +++ b/lib/libc/include/generic-freebsd/sched.h @@ -29,7 +29,6 @@ #ifndef __SCHED_H__ #define __SCHED_H__ -#include #include #include #if __BSD_VISIBLE diff --git a/lib/libc/include/generic-freebsd/security/audit/audit.h b/lib/libc/include/generic-freebsd/security/audit/audit.h index abdacf6b1754095d54e91aad0febe3aaa1d03e11..642b74b03f0bc9603f43dd53d3ed2e32dbe8f543 100644 --- a/lib/libc/include/generic-freebsd/security/audit/audit.h +++ b/lib/libc/include/generic-freebsd/security/audit/audit.h @@ -1,19 +1,18 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2005-2009 Apple Inc. - * Copyright (c) 2016 Robert N. M. Watson + * Copyright (c) 1999-2005 Apple Inc. + * Copyright (c) 2016-2018 Robert N. M. Watson * All rights reserved. * - * Portions of this software were developed by BAE Systems, the University of - * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL - * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent - * Computing (TC) research program. + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -23,323 +22,460 @@ * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _BSM_AUDIT_H -#define _BSM_AUDIT_H - -#include -#include - -#define AUDIT_RECORD_MAGIC 0x828a0f1b -#define MAX_AUDIT_RECORDS 20 -#define MAXAUDITDATA (0x8000 - 1) -#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA -#define MIN_AUDIT_FILE_SIZE (512 * 1024) - -/* - * Minimum noumber of free blocks on the filesystem containing the audit - * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0 - * as the kernel does an unsigned compare, plus we want to leave a few blocks - * free so userspace can terminate the log, etc. - */ -#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4 - -/* - * Triggers for the audit daemon. - */ -#define AUDIT_TRIGGER_MIN 1 -#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */ -#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */ -#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */ -#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */ -#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */ -#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */ -#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */ -#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */ -#define AUDIT_TRIGGER_MAX 8 - -/* - * The special device filename (FreeBSD). - */ -#define AUDITDEV_FILENAME "audit" -#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME) - -/* - * Pre-defined audit IDs - */ -#define AU_DEFAUDITID (uid_t)(-1) -#define AU_DEFAUDITSID 0 -#define AU_ASSIGN_ASID -1 - -/* - * IPC types. - */ -#define AT_IPC_MSG ((u_char)1) /* Message IPC id. */ -#define AT_IPC_SEM ((u_char)2) /* Semaphore IPC id. */ -#define AT_IPC_SHM ((u_char)3) /* Shared mem IPC id. */ - /* - * Audit conditions. + * This header includes function prototypes and type definitions that are + * necessary for the kernel as a whole to interact with the audit subsystem. */ -#define AUC_UNSET 0 -#define AUC_AUDITING 1 -#define AUC_NOAUDIT 2 -#define AUC_DISABLED -1 -/* - * auditon(2) commands. - */ -#define A_OLDGETPOLICY 2 -#define A_OLDSETPOLICY 3 -#define A_GETKMASK 4 -#define A_SETKMASK 5 -#define A_OLDGETQCTRL 6 -#define A_OLDSETQCTRL 7 -#define A_GETCWD 8 -#define A_GETCAR 9 -#define A_GETSTAT 12 -#define A_SETSTAT 13 -#define A_SETUMASK 14 -#define A_SETSMASK 15 -#define A_OLDGETCOND 20 -#define A_OLDSETCOND 21 -#define A_GETCLASS 22 -#define A_SETCLASS 23 -#define A_GETPINFO 24 -#define A_SETPMASK 25 -#define A_SETFSIZE 26 -#define A_GETFSIZE 27 -#define A_GETPINFO_ADDR 28 -#define A_GETKAUDIT 29 -#define A_SETKAUDIT 30 -#define A_SENDTRIGGER 31 -#define A_GETSINFO_ADDR 32 -#define A_GETPOLICY 33 -#define A_SETPOLICY 34 -#define A_GETQCTRL 35 -#define A_SETQCTRL 36 -#define A_GETCOND 37 -#define A_SETCOND 38 -#define A_GETEVENT 39 /* Get audit event-to-name mapping. */ -#define A_SETEVENT 40 /* Set audit event-to-name mapping. */ - -/* - * Audit policy controls. - */ -#define AUDIT_CNT 0x0001 -#define AUDIT_AHLT 0x0002 -#define AUDIT_ARGV 0x0004 -#define AUDIT_ARGE 0x0008 -#define AUDIT_SEQ 0x0010 -#define AUDIT_WINDATA 0x0020 -#define AUDIT_USER 0x0040 -#define AUDIT_GROUP 0x0080 -#define AUDIT_TRAIL 0x0100 -#define AUDIT_PATH 0x0200 -#define AUDIT_SCNT 0x0400 -#define AUDIT_PUBLIC 0x0800 -#define AUDIT_ZONENAME 0x1000 -#define AUDIT_PERZONE 0x2000 +#ifndef _SECURITY_AUDIT_KERNEL_H_ +#define _SECURITY_AUDIT_KERNEL_H_ -/* - * Default audit queue control parameters. - */ -#define AQ_HIWATER 100 -#define AQ_MAXHIGH 10000 -#define AQ_LOWATER 10 -#define AQ_BUFSZ MAXAUDITDATA -#define AQ_MAXBUFSZ 1048576 - -/* - * Default minimum percentage free space on file system. - */ -#define AU_FS_MINFREE 20 +#ifndef _KERNEL +#error "no user-serviceable parts inside" +#endif -/* - * Type definitions used indicating the length of variable length addresses - * in tokens containing addresses, such as header fields. - */ -#define AU_IPv4 4 -#define AU_IPv6 16 - -__BEGIN_DECLS - -typedef uid_t au_id_t; -typedef pid_t au_asid_t; -typedef u_int16_t au_event_t; -typedef u_int16_t au_emod_t; -typedef u_int32_t au_class_t; -typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8))); - -struct au_tid { - u_int32_t port; /* XXX dev_t compatibility */ - u_int32_t machine; -}; -typedef struct au_tid au_tid_t; - -struct au_tid_addr { - u_int32_t at_port; /* XXX dev_t compatibility */ - u_int32_t at_type; - u_int32_t at_addr[4]; -}; -typedef struct au_tid_addr au_tid_addr_t; - -struct au_mask { - unsigned int am_success; /* Success bits. */ - unsigned int am_failure; /* Failure bits. */ -}; -typedef struct au_mask au_mask_t; - -struct auditinfo { - au_id_t ai_auid; /* Audit user ID. */ - au_mask_t ai_mask; /* Audit masks. */ - au_tid_t ai_termid; /* Terminal ID. */ - au_asid_t ai_asid; /* Audit session ID. */ -}; -typedef struct auditinfo auditinfo_t; - -struct auditinfo_addr { - au_id_t ai_auid; /* Audit user ID. */ - au_mask_t ai_mask; /* Audit masks. */ - au_tid_addr_t ai_termid; /* Terminal ID. */ - au_asid_t ai_asid; /* Audit session ID. */ - au_asflgs_t ai_flags; /* Audit session flags. */ -}; -typedef struct auditinfo_addr auditinfo_addr_t; - -struct auditpinfo { - pid_t ap_pid; /* ID of target process. */ - au_id_t ap_auid; /* Audit user ID. */ - au_mask_t ap_mask; /* Audit masks. */ - au_tid_t ap_termid; /* Terminal ID. */ - au_asid_t ap_asid; /* Audit session ID. */ -}; -typedef struct auditpinfo auditpinfo_t; - -struct auditpinfo_addr { - pid_t ap_pid; /* ID of target process. */ - au_id_t ap_auid; /* Audit user ID. */ - au_mask_t ap_mask; /* Audit masks. */ - au_tid_addr_t ap_termid; /* Terminal ID. */ - au_asid_t ap_asid; /* Audit session ID. */ - au_asflgs_t ap_flags; /* Audit session flags. */ -}; -typedef struct auditpinfo_addr auditpinfo_addr_t; - -struct au_session { - auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */ - au_mask_t as_mask; /* Process Audit Masks. */ -}; -typedef struct au_session au_session_t; +#include -/* - * Contents of token_t are opaque outside of libbsm. - */ -typedef struct au_token token_t; +#include +#include /* - * Kernel audit queue control parameters: - * Default: Maximum: - * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000) - * aq_lowater: AQ_LOWATER (10) td_pflags & TDP_AUDITREC)) + +#define AUDIT_ARG_ADDR(addr) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_addr((addr)); \ +} while (0) + +#define AUDIT_ARG_ARGV(argv, argc, length) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_argv((argv), (argc), (length)); \ +} while (0) + +#define AUDIT_ARG_ATFD1(atfd) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_atfd1((atfd)); \ +} while (0) + +#define AUDIT_ARG_ATFD2(atfd) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_atfd2((atfd)); \ +} while (0) + +#define AUDIT_ARG_AUDITON(udata) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_auditon((udata)); \ +} while (0) + +#define AUDIT_ARG_CMD(cmd) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_cmd((cmd)); \ +} while (0) + +#define AUDIT_ARG_DEV(dev) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_dev((dev)); \ +} while (0) + +#define AUDIT_ARG_EGID(egid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_egid((egid)); \ +} while (0) + +#define AUDIT_ARG_ENVV(envv, envc, length) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_envv((envv), (envc), (length)); \ +} while (0) + +#define AUDIT_ARG_EXIT(status, retval) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_exit((status), (retval)); \ +} while (0) + +#define AUDIT_ARG_EUID(euid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_euid((euid)); \ +} while (0) + +#define AUDIT_ARG_FD(fd) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_fd((fd)); \ +} while (0) + +#define AUDIT_ARG_FILE(p, fp) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_file((p), (fp)); \ +} while (0) + +#define AUDIT_ARG_FFLAGS(fflags) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_fflags((fflags)); \ +} while (0) + +#define AUDIT_ARG_GID(gid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_gid((gid)); \ +} while (0) + +#define AUDIT_ARG_GROUPSET(gidset, gidset_size) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_groupset((gidset), (gidset_size)); \ +} while (0) + +#define AUDIT_ARG_LOGIN(login) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_login((login)); \ +} while (0) + +#define AUDIT_ARG_MODE(mode) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_mode((mode)); \ +} while (0) + +#define AUDIT_ARG_OWNER(uid, gid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_owner((uid), (gid)); \ +} while (0) + +#define AUDIT_ARG_PID(pid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_pid((pid)); \ +} while (0) + +#define AUDIT_ARG_POSIX_IPC_PERM(uid, gid, mode) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_posix_ipc_perm((uid), (gid), (mod)); \ +} while (0) + +#define AUDIT_ARG_PROCESS(p) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_process((p)); \ +} while (0) + +#define AUDIT_ARG_RGID(rgid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_rgid((rgid)); \ +} while (0) + +#define AUDIT_ARG_RIGHTS(rights) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_rights((rights)); \ +} while (0) + +#define AUDIT_ARG_FCNTL_RIGHTS(fcntlrights) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_fcntl_rights((fcntlrights)); \ +} while (0) + +#define AUDIT_ARG_RUID(ruid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_ruid((ruid)); \ +} while (0) + +#define AUDIT_ARG_SIGNUM(signum) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_signum((signum)); \ +} while (0) + +#define AUDIT_ARG_SGID(sgid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_sgid((sgid)); \ +} while (0) + +#define AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_socket((sodomain), (sotype), (soprotocol)); \ +} while (0) + +#define AUDIT_ARG_SOCKADDR(td, dirfd, sa) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_sockaddr((td), (dirfd), (sa)); \ +} while (0) + +#define AUDIT_ARG_SUID(suid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_suid((suid)); \ +} while (0) + +#define AUDIT_ARG_SVIPC_CMD(cmd) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_svipc_cmd((cmd)); \ +} while (0) + +#define AUDIT_ARG_SVIPC_PERM(perm) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_svipc_perm((perm)); \ +} while (0) + +#define AUDIT_ARG_SVIPC_ID(id) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_svipc_id((id)); \ +} while (0) + +#define AUDIT_ARG_SVIPC_ADDR(addr) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_svipc_addr((addr)); \ +} while (0) + +#define AUDIT_ARG_SVIPC_WHICH(which) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_svipc_which((which)); \ +} while (0) + +#define AUDIT_ARG_TEXT(text) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_text((text)); \ +} while (0) + +#define AUDIT_ARG_UID(uid) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_uid((uid)); \ +} while (0) + +#define AUDIT_ARG_UPATH1(td, dirfd, upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath1((td), (dirfd), (upath)); \ +} while (0) + +#define AUDIT_ARG_UPATH1_CANON(upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath1_canon((upath)); \ +} while (0) + +#define AUDIT_ARG_UPATH2(td, dirfd, upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath2((td), (dirfd), (upath)); \ +} while (0) + +#define AUDIT_ARG_UPATH2_CANON(upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath2_canon((upath)); \ +} while (0) + +#define AUDIT_ARG_UPATH1_VP(td, rdir, cdir, upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath1_vp((td), (rdir), (cdir), (upath)); \ +} while (0) + +#define AUDIT_ARG_UPATH2_VP(td, rdir, cdir, upath) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_upath2_vp((td), (rdir), (cdir), (upath)); \ +} while (0) + +#define AUDIT_ARG_VALUE(value) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_value((value)); \ +} while (0) + +#define AUDIT_ARG_VNODE1(vp) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_vnode1((vp)); \ +} while (0) + +#define AUDIT_ARG_VNODE2(vp) do { \ + if (AUDITING_TD(curthread)) \ + audit_arg_vnode2((vp)); \ +} while (0) + +#define AUDIT_SYSCALL_ENABLED() audit_syscalls_enabled + +#define AUDIT_SYSCALL_ENTER(code, td) ({ \ + bool _audit_entered = false; \ + if (audit_syscalls_enabled) { \ + audit_syscall_enter(code, td); \ + _audit_entered = true; \ + } \ + _audit_entered; \ +}) /* - * Event-to-name mapping. + * Wrap the audit_syscall_exit() function so that it is called only when + * we have a audit record on the thread. Audit records can persist after + * auditing is disabled, so we don't just check audit_syscalls_enabled here. */ -#define EVNAMEMAP_NAME_SIZE 64 -struct au_evname_map { - au_event_t en_number; - char en_name[EVNAMEMAP_NAME_SIZE]; -}; -typedef struct au_evname_map au_evname_map_t; +#define AUDIT_SYSCALL_EXIT(error, td) do { \ + if (AUDITING_TD(td)) \ + audit_syscall_exit(error, td); \ +} while (0) /* - * Audit system calls. + * A Macro to wrap the audit_sysclose() function. */ -#if !defined(_KERNEL) && !defined(KERNEL) -int audit(const void *, int); -int auditon(int, void *, int); -int auditctl(const char *); -int getauid(au_id_t *); -int setauid(const au_id_t *); -int getaudit(struct auditinfo *); -int setaudit(const struct auditinfo *); -int getaudit_addr(struct auditinfo_addr *, int); -int setaudit_addr(const struct auditinfo_addr *, int); - -#ifdef __APPLE_API_PRIVATE -#include -mach_port_name_t audit_session_self(void); -au_asid_t audit_session_join(mach_port_name_t port); -#endif /* __APPLE_API_PRIVATE */ - -#endif /* defined(_KERNEL) || defined(KERNEL) */ - -__END_DECLS - -#endif /* !_BSM_AUDIT_H */ \ No newline at end of file +#define AUDIT_SYSCLOSE(td, fd) do { \ + if (AUDITING_TD(td)) \ + audit_sysclose(td, fd); \ +} while (0) + +#else /* !AUDIT */ + +#define AUDIT_ARG_ADDR(addr) +#define AUDIT_ARG_ARGV(argv, argc, length) +#define AUDIT_ARG_ATFD1(atfd) +#define AUDIT_ARG_ATFD2(atfd) +#define AUDIT_ARG_AUDITON(udata) +#define AUDIT_ARG_CMD(cmd) +#define AUDIT_ARG_DEV(dev) +#define AUDIT_ARG_EGID(egid) +#define AUDIT_ARG_ENVV(envv, envc, length) +#define AUDIT_ARG_EXIT(status, retval) +#define AUDIT_ARG_EUID(euid) +#define AUDIT_ARG_FD(fd) +#define AUDIT_ARG_FILE(p, fp) +#define AUDIT_ARG_FFLAGS(fflags) +#define AUDIT_ARG_GID(gid) +#define AUDIT_ARG_GROUPSET(gidset, gidset_size) +#define AUDIT_ARG_LOGIN(login) +#define AUDIT_ARG_MODE(mode) +#define AUDIT_ARG_OWNER(uid, gid) +#define AUDIT_ARG_PID(pid) +#define AUDIT_ARG_POSIX_IPC_PERM(uid, gid, mode) +#define AUDIT_ARG_PROCESS(p) +#define AUDIT_ARG_RGID(rgid) +#define AUDIT_ARG_RIGHTS(rights) +#define AUDIT_ARG_FCNTL_RIGHTS(fcntlrights) +#define AUDIT_ARG_RUID(ruid) +#define AUDIT_ARG_SIGNUM(signum) +#define AUDIT_ARG_SGID(sgid) +#define AUDIT_ARG_SOCKET(sodomain, sotype, soprotocol) +#define AUDIT_ARG_SOCKADDR(td, dirfd, sa) +#define AUDIT_ARG_SUID(suid) +#define AUDIT_ARG_SVIPC_CMD(cmd) +#define AUDIT_ARG_SVIPC_PERM(perm) +#define AUDIT_ARG_SVIPC_ID(id) +#define AUDIT_ARG_SVIPC_ADDR(addr) +#define AUDIT_ARG_SVIPC_WHICH(which) +#define AUDIT_ARG_TEXT(text) +#define AUDIT_ARG_UID(uid) +#define AUDIT_ARG_UPATH1(td, dirfd, upath) +#define AUDIT_ARG_UPATH1_CANON(upath) +#define AUDIT_ARG_UPATH2(td, dirfd, upath) +#define AUDIT_ARG_UPATH2_CANON(upath) +#define AUDIT_ARG_UPATH1_VP(td, rdir, cdir, upath) +#define AUDIT_ARG_UPATH2_VP(td, rdir, cdir, upath) +#define AUDIT_ARG_VALUE(value) +#define AUDIT_ARG_VNODE1(vp) +#define AUDIT_ARG_VNODE2(vp) + +#define AUDITING_TD(td) 0 + +#define AUDIT_SYSCALL_ENABLED() 0 +#define AUDIT_SYSCALL_ENTER(code, td) 0 +#define AUDIT_SYSCALL_EXIT(error, td) + +#define AUDIT_SYSCLOSE(p, fd) + +#endif /* AUDIT */ + +#endif /* !_SECURITY_AUDIT_KERNEL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/security/mac_grantbylabel/mac_grantbylabel.h b/lib/libc/include/generic-freebsd/security/mac_grantbylabel/mac_grantbylabel.h new file mode 100644 index 0000000000000000000000000000000000000000..2cfaee3baaf840a48d59a9b034cc26a454087109 --- /dev/null +++ b/lib/libc/include/generic-freebsd/security/mac_grantbylabel/mac_grantbylabel.h @@ -0,0 +1,63 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2018-2023, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SECURITY_MAC_GRANTBYLABEL_H +#define _SECURITY_MAC_GRANTBYLABEL_H + +#include + +#define MAC_GRANTBYLABEL_NAME "mac_grantbylabel" + +/* the bits we use to represent tokens */ +#define GBL_EMPTY (1<<0) +#define GBL_BIND (1<<1) +#define GBL_IPC (1<<2) +#define GBL_NET (1<<3) +#define GBL_PROC (1<<4) +#define GBL_RTSOCK (1<<5) +#define GBL_SYSCTL (1<<6) +#define GBL_VACCESS (1<<7) +#define GBL_VERIEXEC (1<<8) +#define GBL_KMEM (1<<9) +#define GBL_MAX 9 + +/* this should suffice for now */ +typedef uint32_t gbl_label_t; + +#define MAC_GRANTBYLABEL_FETCH_GBL 1 +#define MAC_GRANTBYLABEL_FETCH_PID_GBL 2 + +struct mac_grantbylabel_fetch_gbl_args { + union { + int fd; + pid_t pid; + } u; + gbl_label_t gbl; +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/setjmp.h b/lib/libc/include/generic-freebsd/setjmp.h index 9e3b6741976af3def0ecd721162b2466b022f68e..7f79230b67743a5610a28dfd7f7ee1979d4a8e14 100644 --- a/lib/libc/include/generic-freebsd/setjmp.h +++ b/lib/libc/include/generic-freebsd/setjmp.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)setjmp.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SETJMP_H_ diff --git a/lib/libc/include/generic-freebsd/signal.h b/lib/libc/include/generic-freebsd/signal.h index e6f599b0291df8a69f95263ccb344f65445ce5db..5f213b97020bcaa93b71624b12d6281458ac44e9 100644 --- a/lib/libc/include/generic-freebsd/signal.h +++ b/lib/libc/include/generic-freebsd/signal.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.3 (Berkeley) 3/30/94 */ #ifndef _SIGNAL_H_ @@ -42,6 +40,10 @@ #include #endif +#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE +#define SIG2STR_MAX 32 /* size of buffer required for sig2str() */ +#endif + __NULLABILITY_PRAGMA_PUSH #if __BSD_VISIBLE @@ -70,6 +72,10 @@ typedef __pthread_t pthread_t; #endif #endif /* __POSIX_VISIBLE || __XSI_VISIBLE */ +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS int raise(int); @@ -117,9 +123,15 @@ int siginterrupt(int, int); #endif #if __POSIX_VISIBLE >= 200809 +void psiginfo(const siginfo_t *, const char *); void psignal(int, const char *); #endif +#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE +int sig2str(int, char *); +int str2sig(const char * __restrict, int * __restrict); +#endif + #if __BSD_VISIBLE int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right); int sigblock(int); diff --git a/lib/libc/include/generic-freebsd/ssp/poll.h b/lib/libc/include/generic-freebsd/ssp/poll.h new file mode 100644 index 0000000000000000000000000000000000000000..6db5bcd102a3494632589c45ad4ae66bc5bf539b --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/poll.h @@ -0,0 +1,60 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_POLL_H_ +#define _SSP_POLL_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +__BEGIN_DECLS + +__ssp_redirect_raw_impl(int, poll, poll, + (struct pollfd fds[], nfds_t nfds, int timeout)) +{ + if (__ssp_bos(fds) / sizeof(fds[0]) < nfds) + __chk_fail(); + + return (__ssp_real(poll)(fds, nfds, timeout)); +} + +#if __POSIX_VISIBLE >= 202405 +__ssp_redirect_raw_impl(int, ppoll, ppoll, + (struct pollfd fds[], nfds_t nfds, + const struct timespec *__restrict timeout, + const sigset_t *__restrict newsigmask)) +{ + if (__ssp_bos(fds) / sizeof(fds[0]) < nfds) + __chk_fail(); + + return (__ssp_real(ppoll)(fds, nfds, timeout, newsigmask)); +} +#endif /* __POSIX_VISIBLE >= 202405 */ +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_POLL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/random.h b/lib/libc/include/generic-freebsd/ssp/random.h new file mode 100644 index 0000000000000000000000000000000000000000..83d1b33f1dd73f21e596f91ae991887af21b39e9 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/random.h @@ -0,0 +1,42 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_RANDOM_H_ +#define _SSP_RANDOM_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +__BEGIN_DECLS + +__ssp_redirect(ssize_t, getrandom, (void *__buf, size_t __len, + unsigned int __flags), (__buf, __len, __flags)); + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_RANDOM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/signal.h b/lib/libc/include/generic-freebsd/ssp/signal.h new file mode 100644 index 0000000000000000000000000000000000000000..f37940750e054588b16bb89e42c7745c754b54cf --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/signal.h @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025, Ricardo Branco + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_SIGNAL_H_ +#define _SSP_SIGNAL_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#include + +__BEGIN_DECLS + +#if __POSIX_VISIBLE >= 202405 || __BSD_VISIBLE +__ssp_redirect_raw_impl(int, sig2str, sig2str, + (int signum, char *__restrict str)) +{ + if (__ssp_bos(str) < SIG2STR_MAX) + __chk_fail(); + + return (__ssp_real(sig2str)(signum, str)); +} +#endif + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/socket.h b/lib/libc/include/generic-freebsd/ssp/socket.h new file mode 100644 index 0000000000000000000000000000000000000000..e8abe21e769cfc4d691ef0fae30268f43c26f80f --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/socket.h @@ -0,0 +1,120 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_SOCKET_H_ +#define _SSP_SOCKET_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#include + +__BEGIN_DECLS + +__ssp_inline void +__ssp_check_msghdr(struct msghdr *hdr) +{ + if (__ssp_bos(hdr->msg_name) < hdr->msg_namelen) + __chk_fail(); + + __ssp_check_iovec(hdr->msg_iov, hdr->msg_iovlen); + + if (__ssp_bos(hdr->msg_control) < hdr->msg_controllen) + __chk_fail(); +} + +__ssp_redirect_raw_impl(int, getpeername, getpeername, + (int fdes, struct sockaddr *__restrict name, socklen_t *__restrict namelen)) +{ + size_t namesz = __ssp_bos(name); + + if (namesz != (size_t)-1 && namesz < *namelen) + __chk_fail(); + + return (__ssp_real(getpeername)(fdes, name, namelen)); +} + +__ssp_redirect_raw_impl(int, getsockname, getsockname, + (int fdes, struct sockaddr *__restrict name, + socklen_t *__restrict namelen)) +{ + size_t namesz = __ssp_bos(name); + + if (namesz != (size_t)-1 && namesz < *namelen) + __chk_fail(); + + return (__ssp_real(getsockname)(fdes, name, namelen)); +} + +__ssp_redirect(ssize_t, recv, (int __sock, void *__buf, size_t __len, + int __flags), (__sock, __buf, __len, __flags)); + +__ssp_redirect_raw_impl(ssize_t, recvfrom, recvfrom, + (int s, void *buf, size_t len, int flags, + struct sockaddr *__restrict from, + socklen_t *__restrict fromlen)) +{ + if (__ssp_bos(buf) < len) + __chk_fail(); + if (from != NULL && __ssp_bos(from) < *fromlen) + __chk_fail(); + + return (__ssp_real(recvfrom)(s, buf, len, flags, from, fromlen)); +} + +__ssp_redirect_raw_impl(ssize_t, recvmsg, recvmsg, + (int s, struct msghdr *hdr, int flags)) +{ + __ssp_check_msghdr(hdr); + return (__ssp_real(recvmsg)(s, hdr, flags)); +} + +#if __BSD_VISIBLE +struct timespec; + +__ssp_redirect_raw_impl(ssize_t, recvmmsg, recvmmsg, + (int s, struct mmsghdr *__restrict hdrvec, size_t vlen, int flags, + const struct timespec *__restrict timeout)) +{ + const size_t vecsz = __ssp_bos(hdrvec); + size_t i; + + if (vecsz != (size_t)-1 && vecsz / sizeof(*hdrvec) < vlen) + __chk_fail(); + + for (i = 0; i < vlen; i++) { + __ssp_check_msghdr(&hdrvec[i].msg_hdr); + } + + return (__ssp_real(recvmmsg)(s, hdrvec, vlen, flags, timeout)); +} +#endif + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_SOCKET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/ssp.h b/lib/libc/include/generic-freebsd/ssp/ssp.h new file mode 100644 index 0000000000000000000000000000000000000000..9dce2d40139300c854796e00a1e04c870af9503f --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/ssp.h @@ -0,0 +1,127 @@ +/* $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 plunky Exp $ */ + +/*- + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_SSP_H_ +#define _SSP_SSP_H_ + +#include + +#if !defined(__cplusplus) +# if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && \ + (__OPTIMIZE__ > 0 || defined(__clang__)) +# if _FORTIFY_SOURCE > 1 +# define __SSP_FORTIFY_LEVEL 2 +# else +# define __SSP_FORTIFY_LEVEL 1 +# endif +# else +# define __SSP_FORTIFY_LEVEL 0 +# endif +#else +# define __SSP_FORTIFY_LEVEL 0 +#endif + +#define __ssp_var(type) __CONCAT(__ssp_ ## type, __COUNTER__) + +/* __ssp_real is used by the implementation in libc */ +#if __SSP_FORTIFY_LEVEL == 0 +#define __ssp_real_(fun) fun +#else +#define __ssp_real_(fun) __ssp_real_ ## fun +#endif +#define __ssp_real(fun) __ssp_real_(fun) + +#define __ssp_inline static __inline __attribute__((__always_inline__)) + +#define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1) +#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0) + +#define __ssp_check(buf, len, bos) \ + if (bos(buf) != (size_t)-1 && (size_t)len > bos(buf)) \ + __chk_fail() + +#define __ssp_redirect_raw_impl(rtype, fun, symbol, args) \ +rtype __ssp_real_(fun) args __RENAME(symbol); \ +__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \ +__ssp_inline rtype fun args + +#define __ssp_redirect_raw(rtype, fun, symbol, args, call, cond, bos, len) \ +__ssp_redirect_raw_impl(rtype, fun, symbol, args) { \ + if (cond) \ + __ssp_check(__buf, len, bos); \ + return __ssp_real_(fun) call; \ +} + +#define __ssp_redirect(rtype, fun, args, call) \ + __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos, __len) +#define __ssp_redirect0(rtype, fun, args, call) \ + __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0, __len) + +#include +#include + +__ssp_inline int +__ssp_overlap(const void *leftp, const void *rightp, __size_t sz) +{ + __uintptr_t left = (__uintptr_t)leftp; + __uintptr_t right = (__uintptr_t)rightp; + + if (left <= right) + return (__SIZE_T_MAX - sz < left || right < left + sz); + + return (__SIZE_T_MAX - sz < right || left < right + sz); +} + +#include + +__BEGIN_DECLS +void __stack_chk_fail(void) __dead2; +void __chk_fail(void) __dead2; +__END_DECLS + +__ssp_inline void +__ssp_check_iovec(const struct iovec *iov, int iovcnt) +{ + const size_t iovsz = __ssp_bos(iov); + int i; + + if (iovsz != (size_t)-1 && iovsz / sizeof(*iov) < (size_t)iovcnt) + __chk_fail(); + + for (i = 0; i < iovcnt; i++) { + if (__ssp_bos(iov[i].iov_base) < iov[i].iov_len) + __chk_fail(); + } +} + +#endif /* _SSP_SSP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/stdio.h b/lib/libc/include/generic-freebsd/ssp/stdio.h new file mode 100644 index 0000000000000000000000000000000000000000..76bc897573a124069a77100f1b84229f842aa742 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/stdio.h @@ -0,0 +1,107 @@ +/* $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $ */ + +/*- + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_STDIO_H_ +#define _SSP_STDIO_H_ + +#include + +__BEGIN_DECLS +#if __SSP_FORTIFY_LEVEL > 0 +#if __POSIX_VISIBLE +__ssp_redirect_raw(char *, ctermid, ctermid, (char *__buf), (__buf), + __buf != NULL, __ssp_bos, L_ctermid); +#if __BSD_VISIBLE +__ssp_redirect_raw(char *, ctermid_r, ctermid_r, (char *__buf), (__buf), + __buf != NULL, __ssp_bos, L_ctermid); +#endif /* __BSD_VISIBLE */ +#endif /* __POSIX_VISIBLE */ +__ssp_redirect(size_t, fread, (void *__restrict __buf, size_t __len, + size_t __nmemb, FILE *__restrict __fp), (__buf, __len, __nmemb, __fp)); +__ssp_redirect(size_t, fread_unlocked, (void *__restrict __buf, size_t __len, + size_t __nmemb, FILE *__restrict __fp), (__buf, __len, __nmemb, __fp)); +#if __EXT1_VISIBLE +__ssp_redirect(char *, gets_s, (char *__buf, rsize_t __len), (__buf, __len)); +#endif /* __EXT1_VISIBLE */ +__ssp_redirect_raw(char *, tmpnam, tmpnam, (char *__buf), (__buf), 1, + __ssp_bos, L_tmpnam); +#endif + +int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...) + __printflike(4, 5); +int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict, + __va_list) + __printflike(4, 0); +int __snprintf_chk(char *__restrict, size_t, int, size_t, + const char *__restrict, ...) + __printflike(5, 6); +int __vsnprintf_chk(char *__restrict, size_t, int, size_t, + const char *__restrict, __va_list) + __printflike(5, 0); +char *__fgets_chk(char *, int, size_t, FILE *); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + +#define sprintf(str, ...) __extension__ ({ \ + char *_ssp_str = (str); \ + __builtin___sprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str), \ + __VA_ARGS__); \ +}) + +#define vsprintf(str, fmt, ap) __extension__ ({ \ + char *_ssp_str = (str); \ + __builtin___vsprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str), fmt, \ + ap); \ +}) + +#define snprintf(str, len, ...) __extension__ ({ \ + char *_ssp_str = (str); \ + __builtin___snprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str), \ + __VA_ARGS__); \ +}) + +#define vsnprintf(str, len, fmt, ap) __extension__ ({ \ + char *_ssp_str = (str); \ + __builtin___vsnprintf_chk(_ssp_str, len, 0, __ssp_bos(_ssp_str), \ + fmt, ap); \ +}) + +#define fgets(str, len, fp) __extension__ ({ \ + char *_ssp_str = (str); \ + __fgets_chk(_ssp_str, len, __ssp_bos(_ssp_str), fp); \ +}) + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ + +#endif /* _SSP_STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/stdlib.h b/lib/libc/include/generic-freebsd/ssp/stdlib.h new file mode 100644 index 0000000000000000000000000000000000000000..c41fd7c2029fea94722833b413ab8f3b36837f74 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/stdlib.h @@ -0,0 +1,57 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_STDLIB_H_ +#define _SSP_STDLIB_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#include + +__BEGIN_DECLS + +__ssp_redirect(void, arc4random_buf, (void *__buf, size_t __len), + (__buf, __len)); + +__ssp_redirect(int, getenv_r, + (const char *name, char * _Nonnull __buf, size_t __len), + (name, __buf, __len)); + +__ssp_redirect_raw_impl(char *, realpath, realpath, + (const char *__restrict path, char *__restrict buf)) +{ + if (__ssp_bos(buf) < PATH_MAX) + __chk_fail(); + + return (__ssp_real(realpath)(path, buf)); +} + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STDLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/string.h b/lib/libc/include/generic-freebsd/ssp/string.h new file mode 100644 index 0000000000000000000000000000000000000000..8e50a74174c0cc551ee373d8231c442326aad7b2 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/string.h @@ -0,0 +1,141 @@ +/* $NetBSD: string.h,v 1.14 2020/09/05 13:37:59 mrg Exp $ */ + +/*- + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_STRING_H_ +#define _SSP_STRING_H_ + +#include + +__BEGIN_DECLS +void *__memcpy_chk(void *, const void *, size_t, size_t); +void *__memmove_chk(void *, const void *, size_t, size_t); +void *__memset_chk(void *, int, size_t, size_t); +char *__stpcpy_chk(char *, const char *, size_t); +char *__stpncpy_chk(char *, const char *, size_t, size_t); +char *__strcat_chk(char *, const char *, size_t); +char *__strcpy_chk(char *, const char *, size_t); +char *__strncat_chk(char *, const char *, size_t, size_t); +size_t __strlcat_chk(char *, const char *, size_t, size_t); +char *__strncpy_chk(char *, const char *, size_t, size_t); +size_t __strlcpy_chk(char *, const char *, size_t, size_t); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + +#define __ssp_bos_check3_typed_var(fun, dsttype, dsrvar, dst, srctype, srcvar, \ + src, lenvar, len) __extension__ ({ \ + srctype srcvar = (src); \ + dsttype dstvar = (dst); \ + size_t lenvar = (len); \ + ((__ssp_bos0(dstvar) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dstvar, srcvar, lenvar, \ + __ssp_bos0(dstvar)) : \ + __ ## fun ## _ichk(dstvar, srcvar, lenvar)); \ +}) + +#define __ssp_bos_check3_typed(fun, dsttype, dst, srctype, src, len) \ + __ssp_bos_check3_typed_var(fun, dsttype, __ssp_var(dstv), dst, \ + srctype, __ssp_var(srcv), src, __ssp_var(lenv), len) + +#define __ssp_bos_check3(fun, dst, src, len) \ + __ssp_bos_check3_typed_var(fun, void *, __ssp_var(dstv), dst, \ + const void *, __ssp_var(srcv), src, __ssp_var(lenv), len) + +#define __ssp_bos_check2_var(fun, dstvar, dst, srcvar, src) __extension__ ({ \ + const void *srcvar = (src); \ + void *dstvar = (dst); \ + ((__ssp_bos0(dstvar) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dstvar, srcvar, \ + __ssp_bos0(dstvar)) : \ + __ ## fun ## _ichk(dstvar, srcvar)); \ +}) + +#define __ssp_bos_check2(fun, dst, src) \ + __ssp_bos_check2_var(fun, __ssp_var(dstv), dst, __ssp_var(srcv), src) + +#define __ssp_bos_icheck3_restrict(fun, type1, type2) \ +static __inline type1 __ ## fun ## _ichk(type1 __restrict, type2 __restrict, size_t); \ +static __inline __attribute__((__always_inline__)) type1 \ +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src, size_t len) { \ + return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \ +} + +#define __ssp_bos_icheck3(fun, type1, type2) \ +static __inline type1 __ ## fun ## _ichk(type1, type2, size_t); \ +static __inline __attribute__((__always_inline__)) type1 \ +__ ## fun ## _ichk(type1 dst, type2 src, size_t len) { \ + return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \ +} + +#define __ssp_bos_icheck2_restrict(fun, type1, type2) \ +static __inline type1 __ ## fun ## _ichk(type1, type2); \ +static __inline __attribute__((__always_inline__)) type1 \ +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src) { \ + return __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)); \ +} + +__BEGIN_DECLS +__ssp_bos_icheck3_restrict(memcpy, void *, const void *) +__ssp_bos_icheck3_restrict(mempcpy, void *, const void *) +__ssp_bos_icheck3(memmove, void *, const void *) +__ssp_bos_icheck3(memset, void *, int) +__ssp_redirect(void *, memset_explicit, (void *__buf, int __ch, size_t __len), + (__buf, __ch, __len)); +__ssp_bos_icheck2_restrict(stpcpy, char *, const char *) +__ssp_bos_icheck3_restrict(stpncpy, char *, const char *) +__ssp_bos_icheck2_restrict(strcpy, char *, const char *) +__ssp_bos_icheck2_restrict(strcat, char *, const char *) +__ssp_redirect0(int, strerror_r, (int __errnum, char *__buf, size_t __len), + (__errnum, __buf, __len)); +__ssp_bos_icheck3_restrict(strncpy, char *, const char *) +__ssp_bos_icheck3_restrict(strncat, char *, const char *) +__END_DECLS + +#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len) +#define mempcpy(dst, src, len) __ssp_bos_check3(mempcpy, dst, src, len) +#define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len) +#define memset(dst, val, len) \ + __ssp_bos_check3_typed(memset, void *, dst, int, val, len) +#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src) +#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, dst, src, len) +#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src) +#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src) +#define strlcpy(dst, src, dstlen) \ + __strlcpy_chk(dst, src, dstlen, __ssp_bos(dst)) +#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len) +#define strlcat(dst, src, dstlen) \ + __strlcat_chk(dst, src, dstlen, __ssp_bos(dst)) +#define strncat(dst, src, len) __ssp_bos_check3(strncat, dst, src, len) + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/strings.h b/lib/libc/include/generic-freebsd/ssp/strings.h new file mode 100644 index 0000000000000000000000000000000000000000..fc3b14062efcf7fbfbad4e13d94d65485c19ba09 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/strings.h @@ -0,0 +1,72 @@ +/* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_STRINGS_H_ +#define _SSP_STRINGS_H_ + +#include +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#define _ssp_bcopy(srcvar, src, dstvar, dst, lenvar, len) __extension__ ({ \ + const void *srcvar = (src); \ + void *dstvar = (dst); \ + size_t lenvar = (len); \ + ((__ssp_bos0(dstvar) != (size_t)-1) ? \ + __builtin___memmove_chk(dstvar, srcvar, lenvar, \ + __ssp_bos0(dstvar)) : \ + __memmove_ichk(dstvar, srcvar, lenvar)); \ +}) + +#define bcopy(src, dst, len) \ + _ssp_bcopy(__ssp_var(srcv), src, __ssp_var(dstv), dst, __ssp_var(lenv), len) + +#define _ssp_bzero(dstvar, dst, lenvar, len) __extension__ ({ \ + void *dstvar = (dst); \ + size_t lenvar = (len); \ + ((__ssp_bos0(dstvar) != (size_t)-1) ? \ + __builtin___memset_chk(dstvar, 0, lenvar, \ + __ssp_bos0(dstvar)) : \ + __memset_ichk(dstvar, 0, lenvar)); \ +}) + +#define bzero(dst, len) _ssp_bzero(__ssp_var(dstv), dst, __ssp_var(lenv), len) + +__BEGIN_DECLS +__ssp_redirect(void, explicit_bzero, (void *__buf, size_t __len), + (__buf, __len)); +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRINGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/uio.h b/lib/libc/include/generic-freebsd/ssp/uio.h new file mode 100644 index 0000000000000000000000000000000000000000..cd513db6aac96a2c1a22a83ebbbe1d1e0a795922 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/uio.h @@ -0,0 +1,53 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_UIO_H_ +#define _SSP_UIO_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +__BEGIN_DECLS + +__ssp_redirect_raw_impl(ssize_t, readv, readv, + (int fd, const struct iovec *iov, int iovcnt)) +{ + __ssp_check_iovec(iov, iovcnt); + return (__ssp_real(readv)(fd, iov, iovcnt)); +} + +__ssp_redirect_raw_impl(ssize_t, preadv, preadv, + (int fd, const struct iovec *iov, int iovcnt, off_t offset)) +{ + __ssp_check_iovec(iov, iovcnt); + return (__ssp_real(preadv)(fd, iov, iovcnt, offset)); +} + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_UIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/unistd.h b/lib/libc/include/generic-freebsd/ssp/unistd.h new file mode 100644 index 0000000000000000000000000000000000000000..fc7a17da37034fd88ef062aa016f2513a5bda488 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/unistd.h @@ -0,0 +1,90 @@ +/* $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $ */ + +/*- + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_UNISTD_H_ +#define _SSP_UNISTD_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 +__BEGIN_DECLS + +#ifndef _FORTIFY_SOURCE_read +#define _FORTIFY_SOURCE_read read +#endif + +__ssp_inline size_t +__ssp_gid_bos(const void *ptr) +{ + size_t ptrsize = __ssp_bos(ptr); + + if (ptrsize == (size_t)-1) + return (ptrsize); + + return (ptrsize / sizeof(gid_t)); +} + +__ssp_redirect_raw(int, getgrouplist, getgrouplist, + (const char *__name, gid_t __base, gid_t *__buf, int *__lenp), + (__name, __base, __buf, __lenp), 1, __ssp_gid_bos, *__lenp); + +__ssp_redirect_raw(int, getgroups, getgroups, (int __len, gid_t *__buf), + (__len, __buf), 1, __ssp_gid_bos, __len); + +__ssp_redirect(int, getloginclass, (char *__buf, size_t __len), + (__buf, __len)); + +__ssp_redirect(ssize_t, _FORTIFY_SOURCE_read, (int __fd, void *__buf, + size_t __len), (__fd, __buf, __len)); +__ssp_redirect(ssize_t, pread, (int __fd, void *__buf, size_t __len, + off_t __offset), (__fd, __buf, __len, __offset)); + +__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \ + char *__restrict __buf, size_t __len), (__path, __buf, __len)); +__ssp_redirect(ssize_t, readlinkat, (int __fd, const char *__restrict __path, + char *__restrict __buf, size_t __len), (__fd, __path, __buf, __len)); + +__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len), + (__buf, __len), __buf != 0, __ssp_bos, __len); + +__ssp_redirect(int, getdomainname, (char *__buf, int __len), (__buf, __len)); +__ssp_redirect(int, getentropy, (void *__buf, size_t __len), (__buf, __len)); +__ssp_redirect(int, gethostname, (char *__buf, size_t __len), (__buf, __len)); +__ssp_redirect(int, getlogin_r, (char *__buf, size_t __len), (__buf, __len)); +__ssp_redirect(int, ttyname_r, (int __fd, char *__buf, size_t __len), + (__fd, __buf, __len)); + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ssp/wchar.h b/lib/libc/include/generic-freebsd/ssp/wchar.h new file mode 100644 index 0000000000000000000000000000000000000000..4b22b755b1629e00eae7495ff464cd98f8115390 --- /dev/null +++ b/lib/libc/include/generic-freebsd/ssp/wchar.h @@ -0,0 +1,229 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SSP_WCHAR_H_ +#define _SSP_WCHAR_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +__ssp_inline int +__ssp_wchar_overlap(const void *leftp, const void *rightp, size_t len) +{ + + if (len > __SIZE_T_MAX / sizeof(wchar_t)) + return (1); + return (__ssp_overlap(leftp, rightp, len * sizeof(wchar_t))); +} + +/* + * __ssp_wbos for w*() calls where the size parameters are in sizeof(wchar_t) + * units, so the result needs to be scaled appropriately. + */ +__ssp_inline size_t +__ssp_wbos(void *ptr) +{ + const size_t ptrsize = __ssp_bos(ptr); + + if (ptrsize == (size_t)-1) + return (ptrsize); + + return (ptrsize / sizeof(wchar_t)); +} + +__BEGIN_DECLS +__ssp_redirect_raw_impl(wchar_t *, wmemcpy, wmemcpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(src, buf, len)) + __chk_fail(); + + return (__ssp_real(wmemcpy)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wmempcpy, wmempcpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(src, buf, len)) + __chk_fail(); + + return (__ssp_real(wmempcpy)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wmemmove, wmemmove, + (wchar_t *buf, const wchar_t *src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + + return (__ssp_real(wmemmove)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wmemset, wmemset, + (wchar_t *buf, wchar_t c, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + return (__ssp_real(wmemset)(buf, c, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wcpcpy, wcpcpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src)) +{ + const size_t slen = __ssp_wbos(buf); + const size_t len = wcslen(src); + + if (len >= slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + (void)__ssp_real(wmemcpy)(buf, src, len + 1); + return (buf + len); +} + +__ssp_redirect_raw_impl(wchar_t *, wcpncpy, wcpncpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wcpncpy)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wcscat, wcscat, + (wchar_t *__restrict buf, const wchar_t *__restrict src)) +{ + size_t slen = __ssp_wbos(buf); + wchar_t *cp; + + cp = buf; + while (*cp != L'\0') { + cp++; + if (slen-- == 0) + __chk_fail(); + } + + while (*src != L'\0') { + if (slen-- == 0) + __chk_fail(); + *cp++ = *src++; + } + + if (slen-- == 0) + __chk_fail(); + *cp = '\0'; + return (buf); +} + +__ssp_redirect_raw_impl(wchar_t *, wcscpy, wcscpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src)) +{ + const size_t slen = __ssp_wbos(buf); + size_t len = wcslen(src) + 1; + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wmemcpy)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wcsncat, wcsncat, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len == 0) + return (buf); + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wcsncat)(buf, src, len)); +} + +__ssp_redirect_raw_impl(size_t, wcslcat, wcslcat, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wcslcat)(buf, src, len)); +} + +__ssp_redirect_raw_impl(wchar_t *, wcsncpy, wcsncpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wcsncpy)(buf, src, len)); +} + +__ssp_redirect_raw_impl(size_t, wcslcpy, wcslcpy, + (wchar_t *__restrict buf, const wchar_t *__restrict src, size_t len)) +{ + const size_t slen = __ssp_wbos(buf); + + if (len > slen) + __chk_fail(); + if (__ssp_wchar_overlap(buf, src, len)) + __chk_fail(); + + return (__ssp_real(wcslcpy)(buf, src, len)); +} +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_WCHAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/stab.h b/lib/libc/include/generic-freebsd/stab.h index 4696c7a984441d53b70da65864f84948a0971017..9d8933e8fbe603175ccf8c82878b65c9ec4b0635 100644 --- a/lib/libc/include/generic-freebsd/stab.h +++ b/lib/libc/include/generic-freebsd/stab.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)stab.h 8.1 (Berkeley) 6/2/93 */ #ifndef _STAB_H_ diff --git a/lib/libc/include/generic-freebsd/stdarg.h b/lib/libc/include/generic-freebsd/stdarg.h index d613817c6b08c881f94f8e4a470adebd1a23ba07..aebbb7c4d564e7ca6aff879858881e7a5937aaec 100644 --- a/lib/libc/include/generic-freebsd/stdarg.h +++ b/lib/libc/include/generic-freebsd/stdarg.h @@ -1,37 +1,6 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2017 Poul-Henning Kamp. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_STDARG_H_ -#define _MACHINE_STDARG_H_ +#ifndef __SYS_STDARG_H__ +#define __SYS_STDARG_H__ #include -#ifndef va_start - #error this file needs to be ported to your compiler -#endif - -#endif /* !_MACHINE_STDARG_H_ */ \ No newline at end of file +#endif /* __SYS_STDARG_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/stdatomic.h b/lib/libc/include/generic-freebsd/stdatomic.h index ae0516be1c8f88b3a2d13d28d0df6ae063bed363..e2ff73bcfb89fdb7e98668630279ffd4862ecd5c 100644 --- a/lib/libc/include/generic-freebsd/stdatomic.h +++ b/lib/libc/include/generic-freebsd/stdatomic.h @@ -33,7 +33,8 @@ #include #include -#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#if (__has_extension(c_atomic) || __has_extension(cxx_atomic)) && \ + defined(__clang__) #define __CLANG_ATOMICS #elif __GNUC_PREREQ__(4, 7) #define __GNUC_ATOMICS diff --git a/lib/libc/include/generic-freebsd/stdckdint.h b/lib/libc/include/generic-freebsd/stdckdint.h index 5a0adc0c714f7dcf631b99fdf2a1037975f0ffcc..9375673c04ea7b39c3a04236225e6b6746e43c5f 100644 --- a/lib/libc/include/generic-freebsd/stdckdint.h +++ b/lib/libc/include/generic-freebsd/stdckdint.h @@ -13,7 +13,7 @@ #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow) #define ckd_add(result, a, b) \ - (_Bool)__builtin_add_overflow((a), (b), (result)) + __builtin_add_overflow((a), (b), (result)) #else #define ckd_add(result, a, b) \ _Static_assert(0, "checked addition not supported") @@ -21,7 +21,7 @@ #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow) #define ckd_sub(result, a, b) \ - (_Bool)__builtin_sub_overflow((a), (b), (result)) + __builtin_sub_overflow((a), (b), (result)) #else #define ckd_sub(result, a, b) \ _Static_assert(0, "checked subtraction not supported") @@ -29,7 +29,7 @@ #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow) #define ckd_mul(result, a, b) \ - (_Bool)__builtin_mul_overflow((a), (b), (result)) + __builtin_mul_overflow((a), (b), (result)) #else #define ckd_mul(result, a, b) \ _Static_assert(0, "checked multiplication not supported") diff --git a/lib/libc/include/generic-freebsd/stddef.h b/lib/libc/include/generic-freebsd/stddef.h index 302e8f9d8c535ec059cd2e72c5c48d5d4abc8c06..108c3385a1b28363b1f2177a4dd430e708f061a9 100644 --- a/lib/libc/include/generic-freebsd/stddef.h +++ b/lib/libc/include/generic-freebsd/stddef.h @@ -27,29 +27,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)stddef.h 8.1 (Berkeley) 6/2/93 */ #ifndef _STDDEF_H_ #define _STDDEF_H_ -#include #include #include +#include #ifndef _PTRDIFF_T_DECLARED typedef __ptrdiff_t ptrdiff_t; #define _PTRDIFF_T_DECLARED #endif -#if __BSD_VISIBLE -#ifndef _RUNE_T_DECLARED -typedef __rune_t rune_t; -#define _RUNE_T_DECLARED -#endif -#endif - #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED @@ -70,7 +61,9 @@ typedef __max_align_t max_align_t; #endif #endif -#define offsetof(type, field) __offsetof(type, field) +#ifndef offsetof +#define offsetof(type, field) __builtin_offsetof(type, field) +#endif #if __EXT1_VISIBLE /* ISO/IEC 9899:2011 K.3.3.2 */ diff --git a/lib/libc/include/generic-freebsd/stdio.h b/lib/libc/include/generic-freebsd/stdio.h index 41ce3df9dc073aaa6e2050bae0355cc27caff8eb..e9119c81f59da504efa6b39fd6c43f8a7a4ac8dd 100644 --- a/lib/libc/include/generic-freebsd/stdio.h +++ b/lib/libc/include/generic-freebsd/stdio.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)stdio.h 8.5 (Berkeley) 4/29/95 */ #ifndef _STDIO_H_ @@ -50,10 +48,13 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#if __EXT1_VISIBLE +/* ISO/IEC 9899:2011 K.3.3.2 */ #ifndef _RSIZE_T_DEFINED #define _RSIZE_T_DEFINED typedef size_t rsize_t; #endif +#endif /* __EXT1_VISIBLE */ #if __POSIX_VISIBLE >= 200809 #ifndef _OFF_T_DECLARED @@ -73,7 +74,7 @@ typedef __off64_t off64_t; #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE #ifndef _VA_LIST_DECLARED -typedef __va_list va_list; +typedef __builtin_va_list va_list; #define _VA_LIST_DECLARED #endif #endif @@ -240,6 +241,21 @@ __END_DECLS #define stdout __stdoutp #define stderr __stderrp +/* + * Functions defined in all versions of POSIX 1003.1. + */ +#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506) +#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */ +#endif + +#if __POSIX_VISIBLE +#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */ +#endif /* __POSIX_VISIBLE */ + +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS #ifdef _XLOCALE_H_ #include @@ -254,7 +270,7 @@ int ferror(FILE *); int fflush(FILE *); int fgetc(FILE *); int fgetpos(FILE * __restrict, fpos_t * __restrict); -char *fgets(char * __restrict, int, FILE * __restrict); +char *(fgets)(char * __restrict, int, FILE * __restrict); FILE *fopen(const char * __restrict, const char * __restrict); int fprintf(FILE * __restrict, const char * __restrict, ...); int fputc(int, FILE *); @@ -282,7 +298,7 @@ void rewind(FILE *); int scanf(const char * __restrict, ...); void setbuf(FILE * __restrict, char * __restrict); int setvbuf(FILE * __restrict, char * __restrict, int, size_t); -int sprintf(char * __restrict, const char * __restrict, ...); +int (sprintf)(char * __restrict, const char * __restrict, ...); int sscanf(const char * __restrict, const char * __restrict, ...); FILE *tmpfile(void); char *tmpnam(char *); @@ -290,13 +306,13 @@ int ungetc(int, FILE *); int vfprintf(FILE * __restrict, const char * __restrict, __va_list); int vprintf(const char * __restrict, __va_list); -int vsprintf(char * __restrict, const char * __restrict, +int (vsprintf)(char * __restrict, const char * __restrict, __va_list); #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 199506 -int snprintf(char * __restrict, size_t, const char * __restrict, +int (snprintf)(char * __restrict, size_t, const char * __restrict, ...) __printflike(3, 4); -int vsnprintf(char * __restrict, size_t, const char * __restrict, +int (vsnprintf)(char * __restrict, size_t, const char * __restrict, __va_list) __printflike(3, 0); #endif #if __ISO_C_VISIBLE >= 1999 @@ -307,16 +323,7 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list) __scanflike(2, 0); #endif -/* - * Functions defined in all versions of POSIX 1003.1. - */ -#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506) -#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */ -#endif - #if __POSIX_VISIBLE -#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */ - char *ctermid(char *); FILE *fdopen(int, const char *); int fileno(FILE *); @@ -415,6 +422,7 @@ FILE *funopen(const void *, #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#if __BSD_VISIBLE typedef __ssize_t cookie_read_function_t(void *, char *, size_t); typedef __ssize_t cookie_write_function_t(void *, const char *, size_t); typedef int cookie_seek_function_t(void *, off64_t *, int); @@ -426,6 +434,7 @@ typedef struct { cookie_close_function_t *close; } cookie_io_functions_t; FILE *fopencookie(void *, const char *, cookie_io_functions_t); +#endif /* * Portability hacks. See . @@ -497,10 +506,6 @@ extern int __isthreaded; #define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) #define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) -#if __POSIX_VISIBLE -#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) -#endif - #define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) #define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) diff --git a/lib/libc/include/generic-freebsd/stdlib.h b/lib/libc/include/generic-freebsd/stdlib.h index ab7cac8768cc9ae240ff1ec40807d3f504270ca3..c2522b9d649971c25cdce8f8f9439b03dd27749c 100644 --- a/lib/libc/include/generic-freebsd/stdlib.h +++ b/lib/libc/include/generic-freebsd/stdlib.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 */ #ifndef _STDLIB_H_ @@ -40,13 +38,6 @@ __NULLABILITY_PRAGMA_PUSH -#if __BSD_VISIBLE -#ifndef _RUNE_T_DECLARED -typedef __rune_t rune_t; -#define _RUNE_T_DECLARED -#endif -#endif - #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED @@ -78,6 +69,10 @@ typedef struct { */ #define RAND_MAX 0x7fffffff +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS #ifdef _XLOCALE_H_ #include @@ -86,9 +81,9 @@ extern int __mb_cur_max; extern int ___mb_cur_max(void); #define MB_CUR_MAX ((size_t)___mb_cur_max()) -_Noreturn void abort(void); +_Noreturn void abort(void) __noexcept; int abs(int) __pure2; -int atexit(void (* _Nonnull)(void)); +int atexit(void (* _Nonnull)(void)) __noexcept; double atof(const char *); int atoi(const char *); long atol(const char *); @@ -100,6 +95,9 @@ div_t div(int, int) __pure2; _Noreturn void exit(int); void free(void *); char *getenv(const char *); +#if __BSD_VISIBLE +int getenv_r(const char *, char * _Nonnull, size_t); +#endif long labs(long) __pure2; ldiv_t ldiv(long, long) __pure2; void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1); @@ -156,7 +154,7 @@ unsigned long long strtoull(const char * __restrict, char ** __restrict, int); #endif /* __LONG_LONG_SUPPORTED */ -_Noreturn void _Exit(int); +_Noreturn void _Exit(int) __noexcept; #endif /* __ISO_C_VISIBLE >= 1999 */ /* @@ -165,9 +163,9 @@ _Noreturn void _Exit(int); #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1) __alloc_size(2); -int at_quick_exit(void (*)(void)); +int at_quick_exit(void (*)(void)) __noexcept; _Noreturn void - quick_exit(int); + quick_exit(int) /* __noexcept -- not ready ABI issues? */; #endif /* __ISO_C_VISIBLE >= 2011 */ /* * Extensions made by POSIX relative to C. @@ -339,23 +337,26 @@ __uint64_t * parameter, and both are different from the ones expected by the historical * FreeBSD qsort_r() interface. * - * Apply a workaround where we explicitly link against the historical - * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with - * the last parameter with a function pointer that exactly matches the - * historical FreeBSD qsort_r() comparator signature, so applications - * written for the historical interface can continue to work without - * modification. + * Apply a workaround where we explicitly link against the historical interface, + * qsort_r@FBSD_1.0, in case when qsort_r() is called with the last parameter + * with a function pointer that exactly matches the historical FreeBSD qsort_r() + * comparator signature, so applications written for the historical interface + * can continue to work without modification. Toolchains that don't support + * symbol versioning don't define __sym_compat, so only provide this symbol in + * supported environments. */ +#ifdef __sym_compat #if defined(__generic) || defined(__cplusplus) void __qsort_r_compat(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); __sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0); #endif +#endif #if defined(__generic) && !defined(__cplusplus) #define qsort_r(base, nel, width, arg4, arg5) \ __generic(arg5, int (*)(void *, const void *, const void *), \ __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5) -#elif defined(__cplusplus) +#elif defined(__cplusplus) && defined(__sym_compat) __END_DECLS extern "C++" { static inline void qsort_r(void *base, size_t nmemb, size_t size, diff --git a/lib/libc/include/generic-freebsd/string.h b/lib/libc/include/generic-freebsd/string.h index a51dc0fefbe744df4ff3ee3f5cf879385e321b4d..48bdd01cf03b4c7435bcc5d5af912f0f58f13beb 100644 --- a/lib/libc/include/generic-freebsd/string.h +++ b/lib/libc/include/generic-freebsd/string.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)string.h 8.1 (Berkeley) 6/2/93 */ #ifndef _STRING_H_ @@ -51,8 +49,12 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS -#if __XSI_VISIBLE >= 600 +#if __XSI_VISIBLE >= 600 || __ISO_C_VISIBLE >= 2023 void *memccpy(void * __restrict, const void * __restrict, int, size_t); #endif void *memchr(const void *, int, size_t) __pure; @@ -60,23 +62,26 @@ void *memchr(const void *, int, size_t) __pure; void *memrchr(const void *, int, size_t) __pure; #endif int memcmp(const void *, const void *, size_t) __pure; -void *memcpy(void * __restrict, const void * __restrict, size_t); +void *(memcpy)(void * __restrict, const void * __restrict, size_t); #if __BSD_VISIBLE void *memmem(const void *, size_t, const void *, size_t) __pure; #endif -void *memmove(void *, const void *, size_t); +void *(memmove)(void *, const void *, size_t); #if __BSD_VISIBLE -void *mempcpy(void * __restrict, const void * __restrict, size_t); +void *(mempcpy)(void * __restrict, const void * __restrict, size_t); +#endif +void *(memset)(void *, int, size_t); +#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 2023 +void *memset_explicit(void *, int, size_t); #endif -void *memset(void *, int, size_t); #if __POSIX_VISIBLE >= 200809 -char *stpcpy(char * __restrict, const char * __restrict); -char *stpncpy(char * __restrict, const char * __restrict, size_t); +char *(stpcpy)(char * __restrict, const char * __restrict); +char *(stpncpy)(char * __restrict, const char * __restrict, size_t); #endif #if __BSD_VISIBLE char *strcasestr(const char *, const char *) __pure; #endif -char *strcat(char * __restrict, const char * __restrict); +char *(strcat)(char * __restrict, const char * __restrict); char *strchr(const char *, int) __pure; #if __BSD_VISIBLE char *strchrnul(const char*, int) __pure; @@ -84,9 +89,9 @@ int strverscmp(const char *, const char *) __pure; #endif int strcmp(const char *, const char *) __pure; int strcoll(const char *, const char *); -char *strcpy(char * __restrict, const char * __restrict); +char *(strcpy)(char * __restrict, const char * __restrict); size_t strcspn(const char *, const char *) __pure; -#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE +#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE || __ISO_C_VISIBLE >= 2023 char *strdup(const char *) __malloc_like; #endif char *strerror(int); @@ -94,8 +99,8 @@ char *strerror(int); int strerror_r(int, char *, size_t); #endif #if __BSD_VISIBLE -size_t strlcat(char * __restrict, const char * __restrict, size_t); -size_t strlcpy(char * __restrict, const char * __restrict, size_t); +size_t (strlcat)(char * __restrict, const char * __restrict, size_t); +size_t (strlcpy)(char * __restrict, const char * __restrict, size_t); #endif size_t strlen(const char *) __pure; #if __BSD_VISIBLE @@ -107,11 +112,13 @@ typedef __mode_t mode_t; void strmode(mode_t, char *); #endif -char *strncat(char * __restrict, const char * __restrict, size_t); +char *(strncat)(char * __restrict, const char * __restrict, size_t); int strncmp(const char *, const char *, size_t) __pure; -char *strncpy(char * __restrict, const char * __restrict, size_t); -#if __POSIX_VISIBLE >= 200809 +char *(strncpy)(char * __restrict, const char * __restrict, size_t); +#if __POSIX_VISIBLE >= 200809 || __ISO_C_VISIBLE >= 2023 char *strndup(const char *, size_t) __malloc_like; +#endif +#if __POSIX_VISIBLE >= 200809 size_t strnlen(const char *, size_t) __pure; #endif #if __BSD_VISIBLE diff --git a/lib/libc/include/generic-freebsd/stringlist.h b/lib/libc/include/generic-freebsd/stringlist.h index 326b16e1cc2b4c8884673c6cf524a4b5595d4221..56aa350188e33d0b9187019bb12c785ea74ce4a0 100644 --- a/lib/libc/include/generic-freebsd/stringlist.h +++ b/lib/libc/include/generic-freebsd/stringlist.h @@ -30,7 +30,7 @@ #ifndef _STRINGLIST_H #define _STRINGLIST_H -#include + #include /* diff --git a/lib/libc/include/generic-freebsd/strings.h b/lib/libc/include/generic-freebsd/strings.h index 6373e6af041ab2b63091e647b066a7972c2ee5f5..38e05ff63704e75f09233f90f63eff3623579b81 100644 --- a/lib/libc/include/generic-freebsd/strings.h +++ b/lib/libc/include/generic-freebsd/strings.h @@ -37,11 +37,15 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS #if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112 int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */ -void bcopy(const void *, void *, size_t); /* LEGACY */ -void bzero(void *, size_t); /* LEGACY */ +void (bcopy)(const void *, void *, size_t); /* LEGACY */ +void (bzero)(void *, size_t); /* LEGACY */ #endif #if __BSD_VISIBLE void explicit_bzero(void *, size_t); diff --git a/lib/libc/include/generic-freebsd/sys/_atomic64e.h b/lib/libc/include/generic-freebsd/sys/_atomic64e.h index 0b06a7e856b6714a69271bb39081da79b8732fdc..772e2f2635cff65ccd6e7b93fe94f40bcbb4b28d 100644 --- a/lib/libc/include/generic-freebsd/sys/_atomic64e.h +++ b/lib/libc/include/generic-freebsd/sys/_atomic64e.h @@ -55,7 +55,7 @@ int atomic_fcmpset_64(volatile u_int64_t *, u_int64_t *, u_int64_t); u_int64_t atomic_fetchadd_64(volatile u_int64_t *, u_int64_t); -u_int64_t atomic_load_64(volatile u_int64_t *); +u_int64_t atomic_load_64(const volatile u_int64_t *); #define atomic_load_acq_64 atomic_load_64 void atomic_readandclear_64(volatile u_int64_t *); diff --git a/lib/libc/include/generic-freebsd/sys/_atomic_subword.h b/lib/libc/include/generic-freebsd/sys/_atomic_subword.h index 9982e4242ec8bb1592ab35fccb94a8df2694a05b..b96b83b6683eaec8da7e81689fee92bb50395e65 100644 --- a/lib/libc/include/generic-freebsd/sys/_atomic_subword.h +++ b/lib/libc/include/generic-freebsd/sys/_atomic_subword.h @@ -176,7 +176,7 @@ atomic_fcmpset_16(__volatile uint16_t *addr, uint16_t *old, uint16_t val) #ifndef atomic_load_acq_8 static __inline uint8_t -atomic_load_acq_8(volatile uint8_t *p) +atomic_load_acq_8(const volatile uint8_t *p) { int shift; uint8_t ret; @@ -189,7 +189,7 @@ atomic_load_acq_8(volatile uint8_t *p) #ifndef atomic_load_acq_16 static __inline uint16_t -atomic_load_acq_16(volatile uint16_t *p) +atomic_load_acq_16(const volatile uint16_t *p) { int shift; uint16_t ret; @@ -205,67 +205,31 @@ atomic_load_acq_16(volatile uint16_t *p) #undef _ATOMIC_BYTE_SHIFT #undef _ATOMIC_HWORD_SHIFT -/* - * Provide generic testandset_long implementation based on fcmpset long - * primitive. It may not be ideal for any given arch, so machine/atomic.h - * should define the macro atomic_testandset_long to override with an - * MD-specific version. - * - * (Organizationally, this isn't really subword atomics. But atomic_common is - * included too early in machine/atomic.h, so it isn't a good place for derived - * primitives like this.) - */ -#ifndef atomic_testandset_acq_long -static __inline int -atomic_testandset_acq_long(volatile u_long *p, u_int v) +#ifndef atomic_set_16 +static __inline void +atomic_set_16(volatile uint16_t *p, uint16_t bit) { - u_long bit, old; - bool ret; + uint16_t v; - bit = (1ul << (v % (sizeof(*p) * NBBY))); - - old = atomic_load_acq_long(p); - ret = false; - while (!ret && (old & bit) == 0) - ret = atomic_fcmpset_acq_long(p, &old, old | bit); - - return (!ret); + v = atomic_load_16(p); + for (;;) { + if (atomic_fcmpset_16(p, &v, v | bit)) + break; + } } #endif -#ifndef atomic_testandset_long -static __inline int -atomic_testandset_long(volatile u_long *p, u_int v) +#ifndef atomic_clear_16 +static __inline void +atomic_clear_16(volatile uint16_t *p, uint16_t bit) { - u_long bit, old; - bool ret; - - bit = (1ul << (v % (sizeof(*p) * NBBY))); - - old = atomic_load_long(p); - ret = false; - while (!ret && (old & bit) == 0) - ret = atomic_fcmpset_long(p, &old, old | bit); - - return (!ret); -} -#endif - -#ifndef atomic_testandclear_long -static __inline int -atomic_testandclear_long(volatile u_long *p, u_int v) -{ - u_long bit, old; - bool ret; - - bit = (1ul << (v % (sizeof(*p) * NBBY))); - - old = atomic_load_long(p); - ret = false; - while (!ret && (old & bit) != 0) - ret = atomic_fcmpset_long(p, &old, old & ~bit); + uint16_t v; - return (ret); + v = atomic_load_16(p); + for (;;) { + if (atomic_fcmpset_16(p, &v, v & ~bit)) + break; + } } #endif diff --git a/lib/libc/include/generic-freebsd/sys/_bitset.h b/lib/libc/include/generic-freebsd/sys/_bitset.h index 35df39987667092c1c83a8c34afed1b57fc5c8f7..0d37757a7444a938de06c29f3cbcb19106362316 100644 --- a/lib/libc/include/generic-freebsd/sys/_bitset.h +++ b/lib/libc/include/generic-freebsd/sys/_bitset.h @@ -36,7 +36,7 @@ * Macros addressing word and bit within it, tuned to make compiler * optimize cases when SETSIZE fits into single machine word. */ -#define _BITSET_BITS (sizeof(long) * 8) +#define _BITSET_BITS (sizeof(unsigned long) * 8) #define __howmany(x, y) (((x) + ((y) - 1)) / (y)) @@ -44,7 +44,7 @@ #define __BITSET_DEFINE(_t, _s) \ struct _t { \ - long __bits[__bitset_words((_s))]; \ + unsigned long __bits[__bitset_words((_s))]; \ } /* diff --git a/lib/libc/include/generic-freebsd/sys/_callout.h b/lib/libc/include/generic-freebsd/sys/_callout.h index 32c21b70260a8b8d452ed7054f18910dd556a242..b45662894cb329c3da0520892d163cdb5efba9b6 100644 --- a/lib/libc/include/generic-freebsd/sys/_callout.h +++ b/lib/libc/include/generic-freebsd/sys/_callout.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)callout.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SYS__CALLOUT_H diff --git a/lib/libc/include/generic-freebsd/sys/_clock_id.h b/lib/libc/include/generic-freebsd/sys/_clock_id.h index 8719871c000c1a4a3834885d1b8e3bbb24a7a3be..50769db5d85e1452dc1cab526e3ceb81b194f003 100644 --- a/lib/libc/include/generic-freebsd/sys/_clock_id.h +++ b/lib/libc/include/generic-freebsd/sys/_clock_id.h @@ -74,11 +74,15 @@ #define CLOCK_PROCESS_CPUTIME_ID 15 #endif /* __POSIX_VISIBLE >= 199309 */ +#ifdef __BSD_VISIBLE +#define CLOCK_TAI 16 +#endif + /* * Linux compatible names. */ #if __BSD_VISIBLE -#define CLOCK_BOOTTIME CLOCK_UPTIME +#define CLOCK_BOOTTIME CLOCK_MONOTONIC #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST #endif diff --git a/lib/libc/include/generic-freebsd/sys/_cpuset.h b/lib/libc/include/generic-freebsd/sys/_cpuset.h index aaec383b979506f434f4e785a4bc63d6db255d30..9939e6306bb628754fa5cb1b76954232d8f793c5 100644 --- a/lib/libc/include/generic-freebsd/sys/_cpuset.h +++ b/lib/libc/include/generic-freebsd/sys/_cpuset.h @@ -35,6 +35,8 @@ #include #ifdef _KERNEL +#include + #define CPU_SETSIZE MAXCPU #endif diff --git a/lib/libc/include/generic-freebsd/sys/_domainset.h b/lib/libc/include/generic-freebsd/sys/_domainset.h index 73efbe97184a3cba6f7d13981ab4f238bd6ae8cb..19f2b037f44933284220a965c7e103323055b6df 100644 --- a/lib/libc/include/generic-freebsd/sys/_domainset.h +++ b/lib/libc/include/generic-freebsd/sys/_domainset.h @@ -32,6 +32,8 @@ #include #ifdef _KERNEL +#include + #define DOMAINSET_SETSIZE MAXMEMDOM #endif diff --git a/lib/libc/include/generic-freebsd/sys/_endian.h b/lib/libc/include/generic-freebsd/sys/_endian.h index fb506e6a5bef57557ddd0050faa5a09aa85fe9dc..eff27d0c3248c1e1b89391c2148cfd33a0603551 100644 --- a/lib/libc/include/generic-freebsd/sys/_endian.h +++ b/lib/libc/include/generic-freebsd/sys/_endian.h @@ -69,8 +69,10 @@ /* * POSIX Issue 8 will require these for endian.h. Define them there and in the - * traditional BSD compilation environment. Since issue 8 doesn't yet have an - * assigned date, use strictly greater than issue 7's date. + * traditional BSD compilation environment. PDP_ENDIAN isn't strictly in Issue + * 8, but is allowed as implementations can define any *_ENDIAN symbol. Since + * issue 8 doesn't yet have an assigned date, use strictly greater than issue + * 7's date. */ #if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809 #define LITTLE_ENDIAN _LITTLE_ENDIAN diff --git a/lib/libc/include/generic-freebsd/sys/_exterr.h b/lib/libc/include/generic-freebsd/sys/_exterr.h new file mode 100644 index 0000000000000000000000000000000000000000..e141c37672519f60b01a843db63526e8e84b1ce4 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_exterr.h @@ -0,0 +1,25 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * All rights reserved. + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#ifndef _SYS__EXTERR_H_ +#define _SYS__EXTERR_H_ + +#include + +struct kexterr { + int error; + const char *msg; + __uint64_t p1; + __uint64_t p2; + unsigned cat; + unsigned src_line; +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_iovec.h b/lib/libc/include/generic-freebsd/sys/_iovec.h index 0f113de6d694d5977e59d1cb17592898543d8322..e7c02ecf2953b3757eb5be785fe0b045a6a519c3 100644 --- a/lib/libc/include/generic-freebsd/sys/_iovec.h +++ b/lib/libc/include/generic-freebsd/sys/_iovec.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)uio.h 8.5 (Berkeley) 2/22/94 */ #ifndef _SYS__IOVEC_H_ @@ -46,4 +44,28 @@ struct iovec { size_t iov_len; /* Length. */ }; +#ifdef _KERNEL +#define IOVEC_INIT(iovp, base, len) \ + *(iovp) = (struct iovec){ .iov_base = (base), .iov_len = (len) } + +/* String with length including NUL terminator */ +#define IOVEC_INIT_CSTR(iovp, str) do { \ + void *__str = (str); \ + IOVEC_INIT(iovp, __str, strlen(__str) + 1); \ +} while(0) + +/* Object with size from sizeof() */ +#define IOVEC_INIT_OBJ(iovp, obj) \ + IOVEC_INIT(iovp, &(obj), sizeof(obj)) + +#define IOVEC_ADVANCE(iovp, amt) do { \ + struct iovec *__iovp = (iovp); \ + size_t __amt = (amt); \ + KASSERT(__amt <= __iovp->iov_len, ("%s: amount %zu > iov_len \ + %zu", __func__, __amt, __iovp->iov_len)); \ + __iovp->iov_len -= __amt; \ + __iovp->iov_base = (char *)__iovp->iov_base + __amt; \ +} while(0) +#endif /* _KERNEL */ + #endif /* !_SYS__IOVEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_lock.h b/lib/libc/include/generic-freebsd/sys/_lock.h index 3945f7ffc10ca775afe3a8ccce04fe1c9faccc15..017fedbde8f40ea2b61e716131b6a32d2c96341a 100644 --- a/lib/libc/include/generic-freebsd/sys/_lock.h +++ b/lib/libc/include/generic-freebsd/sys/_lock.h @@ -33,8 +33,8 @@ struct lock_object { const char *lo_name; /* Individual lock name. */ - u_int lo_flags; - u_int lo_data; /* General class specific data. */ + unsigned int lo_flags; + unsigned int lo_data; /* General class specific data. */ struct witness *lo_witness; /* Data for witness. */ }; diff --git a/lib/libc/include/generic-freebsd/sys/_maxphys.h b/lib/libc/include/generic-freebsd/sys/_maxphys.h new file mode 100644 index 0000000000000000000000000000000000000000..4a52368fdbad71536860b1c97b7d31e3ae64ead4 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_maxphys.h @@ -0,0 +1,10 @@ +/*- + * This file is in the public domain. + */ +#ifndef MAXPHYS +#ifdef __ILP32__ +#define MAXPHYS (128 * 1024) +#else +#define MAXPHYS (1024 * 1024) +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_mutex.h b/lib/libc/include/generic-freebsd/sys/_mutex.h index 3d5137963a64d2afb95958054b43117dd1c045d8..6a5e1b1b6b06779f4da41185396e3837002d0262 100644 --- a/lib/libc/include/generic-freebsd/sys/_mutex.h +++ b/lib/libc/include/generic-freebsd/sys/_mutex.h @@ -31,6 +31,8 @@ #ifndef _SYS__MUTEX_H_ #define _SYS__MUTEX_H_ +#include +#include #include /* @@ -44,7 +46,7 @@ */ struct mtx { struct lock_object lock_object; /* Common lock properties. */ - volatile uintptr_t mtx_lock; /* Owner and flags. */ + volatile __uintptr_t mtx_lock; /* Owner and flags. */ }; /* @@ -58,7 +60,7 @@ struct mtx { */ struct mtx_padalign { struct lock_object lock_object; /* Common lock properties. */ - volatile uintptr_t mtx_lock; /* Owner and flags. */ + volatile __uintptr_t mtx_lock; /* Owner and flags. */ } __aligned(CACHE_LINE_SIZE); #endif /* !_SYS__MUTEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_null.h b/lib/libc/include/generic-freebsd/sys/_null.h index 0f16678d74de3e542f2657cbb6ab41613497b0b2..372724897dbe032bc331eae6caba4659f51c174b 100644 --- a/lib/libc/include/generic-freebsd/sys/_null.h +++ b/lib/libc/include/generic-freebsd/sys/_null.h @@ -31,9 +31,7 @@ #if !defined(__cplusplus) #define NULL ((void *)0) #else -#if __cplusplus >= 201103L -#define NULL nullptr -#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 +#if defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 #define NULL __null #else #if defined(__LP64__) diff --git a/lib/libc/include/generic-freebsd/sys/_nv.h b/lib/libc/include/generic-freebsd/sys/_nv.h new file mode 100644 index 0000000000000000000000000000000000000000..517928714660894b1757512464ac5208f0ab7c4f --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_nv.h @@ -0,0 +1,45 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2009-2013 The FreeBSD Foundation + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __NV_H_ +#define __NV_H_ + +#ifndef _KERNEL +#include +#endif + +#ifndef _NVLIST_T_DECLARED +#define _NVLIST_T_DECLARED +struct nvlist; + +typedef struct nvlist nvlist_t; +#endif + +#endif /* !__NV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_param.h b/lib/libc/include/generic-freebsd/sys/_param.h new file mode 100644 index 0000000000000000000000000000000000000000..bf99ac0b8ebe43d15173fdaacd7e3c7584c9d4fa --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_param.h @@ -0,0 +1,28 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + */ + +#ifndef _SYS__PARAM_H_ +#define _SYS__PARAM_H_ + +#define NBBY 8 /* number of bits in a byte */ +#define NBPW sizeof(int) /* number of bytes per word (integer) */ + +/* + * Macros for counting and rounding. + */ +#define nitems(x) (sizeof((x)) / sizeof((x)[0])) +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif +#define rounddown(x, y) (((x)/(y))*(y)) +#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */ +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ +#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */ +#define powerof2(x) ((((x)-1)&(x))==0) + +#endif /* _SYS__PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_rmlock.h b/lib/libc/include/generic-freebsd/sys/_rmlock.h index e7659e45823ad4dfc360876bcdfe9f0bff2afe52..b17cca8cf1ac0c82ccf29bfc69bf91d37c8e7108 100644 --- a/lib/libc/include/generic-freebsd/sys/_rmlock.h +++ b/lib/libc/include/generic-freebsd/sys/_rmlock.h @@ -32,6 +32,14 @@ #ifndef _SYS__RMLOCK_H_ #define _SYS__RMLOCK_H_ +#include +#include +#include +#include +#include + +struct thread; + /* * Mostly reader/occasional writer lock. */ @@ -66,8 +74,6 @@ struct rm_priotracker { LIST_ENTRY(rm_priotracker) rmp_qentry; }; -#include - struct rmslock_pcpu; struct rmslock { diff --git a/lib/libc/include/generic-freebsd/sys/_rwlock.h b/lib/libc/include/generic-freebsd/sys/_rwlock.h index 0b8f93b16edfdc5176d8832057e537f3c601eb25..1c73c35023f99a0fcc8f50020c2e8bfe78d395c0 100644 --- a/lib/libc/include/generic-freebsd/sys/_rwlock.h +++ b/lib/libc/include/generic-freebsd/sys/_rwlock.h @@ -28,6 +28,8 @@ #ifndef _SYS__RWLOCK_H_ #define _SYS__RWLOCK_H_ +#include +#include #include /* @@ -41,7 +43,7 @@ */ struct rwlock { struct lock_object lock_object; - volatile uintptr_t rw_lock; + volatile __uintptr_t rw_lock; }; /* @@ -55,7 +57,7 @@ struct rwlock { */ struct rwlock_padalign { struct lock_object lock_object; - volatile uintptr_t rw_lock; + volatile __uintptr_t rw_lock; } __aligned(CACHE_LINE_SIZE); #endif /* !_SYS__RWLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_sigaltstack.h b/lib/libc/include/generic-freebsd/sys/_sigaltstack.h new file mode 100644 index 0000000000000000000000000000000000000000..be4522e0b852acba50e4a9401b9ce12455f642df --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_sigaltstack.h @@ -0,0 +1,65 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1982, 1986, 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS__SIGALTSTACK_H_ +#define _SYS__SIGALTSTACK_H_ + +#include + +#if __XSI_VISIBLE +#if __BSD_VISIBLE +#define __stack_t sigaltstack +#endif +typedef struct __stack_t stack_t; + +#define SS_ONSTACK 0x0001 /* take signal on alternate stack */ +#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ +#define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */ +#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ +#endif + +/* + * Structure used in sigaltstack call. Its definition is always + * needed for __ucontext. If __BSD_VISIBLE is defined, the structure + * tag is actually sigaltstack. + */ +struct __stack_t { + void *ss_sp; /* signal stack base */ + __size_t ss_size; /* signal stack length */ + int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ +}; + +#endif /* !_SYS__SIGALTSTACK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_sigset.h b/lib/libc/include/generic-freebsd/sys/_sigset.h index 340288d82c19049d94c31c96e3825a7b2f6c339c..951168089683b99767915a322d7ef2de72507336 100644 --- a/lib/libc/include/generic-freebsd/sys/_sigset.h +++ b/lib/libc/include/generic-freebsd/sys/_sigset.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.4 (Berkeley) 5/4/95 */ #ifndef _SYS__SIGSET_H_ diff --git a/lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h b/lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h index 8719fc22f22137f8332fe0c4c5688e856508a3e0..3a9a65481f01ee71d9f39305ce1020244f19e2db 100644 --- a/lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h +++ b/lib/libc/include/generic-freebsd/sys/_sockaddr_storage.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)socket.h 8.4 (Berkeley) 2/21/94 */ #ifndef _SYS__SOCKADDR_STORAGE_H_ diff --git a/lib/libc/include/generic-freebsd/sys/_stdarg.h b/lib/libc/include/generic-freebsd/sys/_stdarg.h index bd662fd512bbbf3bb9c7df53183e05376d16dbaf..040f8ae9dfc572806df2ffac97308b0ce8abf8d4 100644 --- a/lib/libc/include/generic-freebsd/sys/_stdarg.h +++ b/lib/libc/include/generic-freebsd/sys/_stdarg.h @@ -31,12 +31,11 @@ #ifndef _SYS__STDARG_H_ #define _SYS__STDARG_H_ -#include -#include +#include #ifndef _VA_LIST_DECLARED - #define _VA_LIST_DECLARED - typedef __va_list va_list; +#define _VA_LIST_DECLARED +typedef __builtin_va_list va_list; #endif #define va_start(ap, last) __builtin_va_start((ap), (last)) diff --git a/lib/libc/include/generic-freebsd/sys/_sx.h b/lib/libc/include/generic-freebsd/sys/_sx.h index 41ab002625ebac39ccd9803072116600bb5ff6c7..6e00a132025277cbb4b3eb15b3912e9a96cb7a75 100644 --- a/lib/libc/include/generic-freebsd/sys/_sx.h +++ b/lib/libc/include/generic-freebsd/sys/_sx.h @@ -31,12 +31,15 @@ #ifndef _SYS__SX_H_ #define _SYS__SX_H_ +#include +#include + /* * Shared/exclusive lock main structure definition. */ struct sx { struct lock_object lock_object; - volatile uintptr_t sx_lock; + volatile __uintptr_t sx_lock; }; #endif /* !_SYS__SX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_termios.h b/lib/libc/include/generic-freebsd/sys/_termios.h index f54d4163f9c3419141b5f64d6022c4e86d74ac26..056e5549cb38085834120720ce5dae9e2b5e2d30 100644 --- a/lib/libc/include/generic-freebsd/sys/_termios.h +++ b/lib/libc/include/generic-freebsd/sys/_termios.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)termios.h 8.3 (Berkeley) 3/28/94 */ #ifndef _SYS__TERMIOS_H_ diff --git a/lib/libc/include/generic-freebsd/sys/_timespec.h b/lib/libc/include/generic-freebsd/sys/_timespec.h index 63891fb4bcc6e5a65f5e63952acd53b6d31e9a9b..1663dc3a73b695e0bf359d04e14cddc3a98a6802 100644 --- a/lib/libc/include/generic-freebsd/sys/_timespec.h +++ b/lib/libc/include/generic-freebsd/sys/_timespec.h @@ -27,9 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)time.h 8.5 (Berkeley) 5/4/95 - * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp */ #ifndef _SYS__TIMESPEC_H_ diff --git a/lib/libc/include/generic-freebsd/sys/_tls_variant_i.h b/lib/libc/include/generic-freebsd/sys/_tls_variant_i.h index de16f3e4be2be1b0d01c35ec902df8244659a8a8..ed8910a767865fe65ba9e926b88c4334e2850965 100644 --- a/lib/libc/include/generic-freebsd/sys/_tls_variant_i.h +++ b/lib/libc/include/generic-freebsd/sys/_tls_variant_i.h @@ -37,8 +37,18 @@ struct pthread; +struct dtv_slot { + char *dtvs_tls; +}; + +struct dtv { + uintptr_t dtv_gen; + uintptr_t dtv_size; + struct dtv_slot dtv_slots[]; +}; + struct tcb { - uintptr_t *tcb_dtv; /* required by rtld */ + struct dtv *tcb_dtv; /* required by rtld */ struct pthread *tcb_thread; }; diff --git a/lib/libc/include/generic-freebsd/sys/_types.h b/lib/libc/include/generic-freebsd/sys/_types.h index de93e2389f75d3258689dd23403c7a77df534e18..fb5b14162cc32be55852de466a4e097d322b578d 100644 --- a/lib/libc/include/generic-freebsd/sys/_types.h +++ b/lib/libc/include/generic-freebsd/sys/_types.h @@ -29,8 +29,6 @@ #ifndef _SYS__TYPES_H_ #define _SYS__TYPES_H_ -#include - /* * Basic types upon which most other types are built. * @@ -181,12 +179,23 @@ typedef __uint_least32_t __char32_t; #endif typedef struct { - long long __max_align1 __aligned(_Alignof(long long)); + long long __max_align1 + __attribute__((__aligned__(__alignof__(long long)))); #ifndef _STANDALONE - long double __max_align2 __aligned(_Alignof(long double)); + long double __max_align2 + __attribute__((__aligned__(__alignof__(long long)))); #endif } __max_align_t; +/* Types for sys/acl.h */ +typedef __uint32_t __acl_tag_t; +typedef __uint32_t __acl_perm_t; +typedef __uint16_t __acl_entry_type_t; +typedef __uint16_t __acl_flag_t; +typedef __uint32_t __acl_type_t; +typedef __uint32_t *__acl_permset_t; +typedef __uint16_t *__acl_flagset_t; + typedef __uint64_t __dev_t; /* device number */ typedef __uint32_t __fixpt_t; /* fixed point number */ diff --git a/lib/libc/include/generic-freebsd/sys/_uexterror.h b/lib/libc/include/generic-freebsd/sys/_uexterror.h new file mode 100644 index 0000000000000000000000000000000000000000..e428715a856737d8b8be481d414212e18817bfbe --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_uexterror.h @@ -0,0 +1,29 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * All rights reserved. + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#ifndef _SYS__UEXTERROR_H_ +#define _SYS__UEXTERROR_H_ + +#include + +struct uexterror { + __uint32_t ver; + __uint32_t error; + __uint32_t cat; + __uint32_t src_line; + __uint32_t flags; + __uint32_t rsrv0; + __uint64_t p1; + __uint64_t p2; + __uint64_t rsrv1[4]; + char msg[128]; +}; + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_uio.h b/lib/libc/include/generic-freebsd/sys/_uio.h index e530d1df0ccf99e3fa6130783f67c81e61dfb238..959e683f6cbd80379c13b4fd842f6efa439f3e0b 100644 --- a/lib/libc/include/generic-freebsd/sys/_uio.h +++ b/lib/libc/include/generic-freebsd/sys/_uio.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)uio.h 8.5 (Berkeley) 2/22/94 */ #ifndef _SYS__UIO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/_visible.h b/lib/libc/include/generic-freebsd/sys/_visible.h new file mode 100644 index 0000000000000000000000000000000000000000..91a58159bab394c2a39705ea8e84ef881b18e150 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/_visible.h @@ -0,0 +1,223 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS__VISIBLE_H_ +#define _SYS__VISIBLE_H_ + +/*- + * The following definitions are an extension of the behavior originally + * implemented in , but with a different level of granularity. + * POSIX.1 requires that the macros we test be defined before any standard + * header file is included. + * + * Here's a quick run-down of the versions (and some informal names) + * defined(_POSIX_SOURCE) 1003.1-1988 + * encoded as 198808 below + * _POSIX_C_SOURCE == 1 1003.1-1990 + * encoded as 199009 below + * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option + * encoded as 199209 below + * _POSIX_C_SOURCE == 199309 1003.1b-1993 + * (1003.1 Issue 4, Single Unix Spec v1, Unix 93) + * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + * (1003.1 Issue 5, Single Unix Spec v2, Unix 95) + * _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03) + * with _XOPEN_SOURCE=600 + * _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7) + * IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is + * 1003.1-2008 with two TCs applied and + * _XOPEN_SOURCE=700 + * _POSIX_C_SOURCE == 202405 1003.1-2004 (1003.1 Issue 8), IEEE Std 1003.1-2024 + * with _XOPEN_SOURCE=800 + * + * In addition, the X/Open Portability Guide, which is now the Single UNIX + * Specification, defines a feature-test macro which indicates the version of + * that specification, and which subsumes _POSIX_C_SOURCE. + * + * Our macros begin with two underscores to avoid namespace screwage. + */ + +/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 +#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ +#define _POSIX_C_SOURCE 199009 +#endif + +/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199209 +#endif + +/* + * Deal with various X/Open Portability Guides and Single UNIX Spec. We use the + * '- 0' construct so software that defines _XOPEN_SOURCE to nothing doesn't + * cause errors. X/Open CAE Specification, August 1994, System Interfaces and + * Headers, Issue 4, Version 2 section 2.2 states an empty definition means the + * same thing as _POSIX_C_SOURCE == 2. This broadly mirrors "System V Interface + * Definition, Fourth Edition", but earlier editions suggest some ambiguity. + * However, FreeBSD has histoically implemented this as a NOP, so we just + * document what it should be for now to not break ports gratuitously. + */ +#ifdef _XOPEN_SOURCE +#if _XOPEN_SOURCE - 0 >= 800 +#define __XSI_VISIBLE 800 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 202405 +#elif _XOPEN_SOURCE - 0 >= 700 +#define __XSI_VISIBLE 700 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809 +#elif _XOPEN_SOURCE - 0 >= 600 +#define __XSI_VISIBLE 600 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112 +#elif _XOPEN_SOURCE - 0 >= 500 +#define __XSI_VISIBLE 500 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506 +#else +/* #define _POSIX_C_SOURCE 199209 */ +#endif +#endif + +/* + * Deal with all versions of POSIX. The ordering relative to the tests above is + * important. + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 198808 +#endif +#ifdef _POSIX_C_SOURCE +#if _POSIX_C_SOURCE >= 202405 +#define __POSIX_VISIBLE 202405 +#define __ISO_C_VISIBLE 2017 +#elif _POSIX_C_SOURCE >= 200809 +#define __POSIX_VISIBLE 200809 +#define __ISO_C_VISIBLE 1999 +#elif _POSIX_C_SOURCE >= 200112 +#define __POSIX_VISIBLE 200112 +#define __ISO_C_VISIBLE 1999 +#elif _POSIX_C_SOURCE >= 199506 +#define __POSIX_VISIBLE 199506 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199309 +#define __POSIX_VISIBLE 199309 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199209 +#define __POSIX_VISIBLE 199209 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199009 +#define __POSIX_VISIBLE 199009 +#define __ISO_C_VISIBLE 1990 +#else +#define __POSIX_VISIBLE 198808 +#define __ISO_C_VISIBLE 0 +#endif /* _POSIX_C_SOURCE */ + +/* + * When we've explicitly asked for a newer C version, make the C variable + * visible by default. Also honor the glibc _ISOC{11,23}_SOURCE macros + * extensions. Both glibc and OpenBSD do this, even when a more strict + * _POSIX_C_SOURCE has been requested, and it makes good sense (especially for + * pre POSIX 2024, since C11 is much nicer than the old C99 base). Continue the + * practice with C23, though don't do older standards. Also, GLIBC doesn't have + * a _ISOC17_SOURCE, so it's not implemented here. glibc has earlier ISOCxx defines, + * but we don't implement those as they are not relevant enough. + */ +#if _ISOC23_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +#undef __ISO_C_VISIBLE +#define __ISO_C_VISIBLE 2023 +#elif _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +#undef __ISO_C_VISIBLE +#define __ISO_C_VISIBLE 2011 +#endif +#else /* _POSIX_C_SOURCE */ +/*- + * Deal with _ANSI_SOURCE: + * If it is defined, and no other compilation environment is explicitly + * requested, then define our internal feature-test macros to zero. This + * makes no difference to the preprocessor (undefined symbols in preprocessing + * expressions are defined to have value zero), but makes it more convenient for + * a test program to print out the values. + * + * If a program mistakenly defines _ANSI_SOURCE and some other macro such as + * _POSIX_C_SOURCE, we will assume that it wants the broader compilation + * environment (and in fact we will never get here). + */ +#if defined(_ANSI_SOURCE) /* Hide almost everything. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 1990 +#define __EXT1_VISIBLE 0 +#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 1999 +#define __EXT1_VISIBLE 0 +#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 2011 +#define __EXT1_VISIBLE 0 +#elif defined(_C23_SOURCE) /* Localism to specify strict C23 env. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 2023 +#define __EXT1_VISIBLE 0 +#else /* Default environment: show everything. */ +#define __POSIX_VISIBLE 202405 +#define __XSI_VISIBLE 800 +#define __BSD_VISIBLE 1 +#define __ISO_C_VISIBLE 2023 +#define __EXT1_VISIBLE 1 +#endif +#endif /* _POSIX_C_SOURCE */ + +/* User override __EXT1_VISIBLE */ +#if defined(__STDC_WANT_LIB_EXT1__) +#undef __EXT1_VISIBLE +#if __STDC_WANT_LIB_EXT1__ +#define __EXT1_VISIBLE 1 +#else +#define __EXT1_VISIBLE 0 +#endif +#endif /* __STDC_WANT_LIB_EXT1__ */ + +#endif /* !_SYS__VISIBLE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/_winsize.h b/lib/libc/include/generic-freebsd/sys/_winsize.h index 035db068a7d4de0338d7bbf356793721705397e3..c4f9d4562509effceddcc20fb793ae97410e9d53 100644 --- a/lib/libc/include/generic-freebsd/sys/_winsize.h +++ b/lib/libc/include/generic-freebsd/sys/_winsize.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 */ #ifndef _SYS__WINSIZE_H_ diff --git a/lib/libc/include/generic-freebsd/sys/acct.h b/lib/libc/include/generic-freebsd/sys/acct.h index fd68325c0fc8b501aaee18aff8b70e733db4105b..9b994de4176f84486746407edef9874bb6231c1b 100644 --- a/lib/libc/include/generic-freebsd/sys/acct.h +++ b/lib/libc/include/generic-freebsd/sys/acct.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)acct.h 8.4 (Berkeley) 1/9/95 */ #ifndef _SYS_ACCT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/acl.h b/lib/libc/include/generic-freebsd/sys/acl.h index 059b65f0e84d40cd0d873f530d981b1654a18b38..508e3d5d3328b777dd81a4540a8fe6c8bae6a45d 100644 --- a/lib/libc/include/generic-freebsd/sys/acl.h +++ b/lib/libc/include/generic-freebsd/sys/acl.h @@ -36,21 +36,23 @@ #ifndef _SYS_ACL_H_ #define _SYS_ACL_H_ -#include -#include -#include +#include +#include +#ifdef _KERNEL +#include +#endif /* * POSIX.1e and NFSv4 ACL types and related constants. */ -typedef uint32_t acl_tag_t; -typedef uint32_t acl_perm_t; -typedef uint16_t acl_entry_type_t; -typedef uint16_t acl_flag_t; -typedef int acl_type_t; -typedef int *acl_permset_t; -typedef uint16_t *acl_flagset_t; +typedef __acl_tag_t acl_tag_t; +typedef __acl_perm_t acl_perm_t; +typedef __acl_entry_type_t acl_entry_type_t; +typedef __acl_flag_t acl_flag_t; +typedef __acl_type_t acl_type_t; +typedef __acl_permset_t acl_permset_t; +typedef __acl_flagset_t acl_flagset_t; /* * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big. diff --git a/lib/libc/include/generic-freebsd/sys/aio.h b/lib/libc/include/generic-freebsd/sys/aio.h index c27e766737bf473a57df004112dd1eb2655fe4cd..6aa067394811343a98747b0c61b2a578f6b55406 100644 --- a/lib/libc/include/generic-freebsd/sys/aio.h +++ b/lib/libc/include/generic-freebsd/sys/aio.h @@ -97,7 +97,7 @@ struct __aiocb_private { long status; long error; - void *kernelinfo; + void *spare; }; /* diff --git a/lib/libc/include/generic-freebsd/sys/asan.h b/lib/libc/include/generic-freebsd/sys/asan.h index fc6b826f40df9399c7a2ef01c9d038fe026bc864..1cd2e4d702d7b960e80439808d9342ae2183d802 100644 --- a/lib/libc/include/generic-freebsd/sys/asan.h +++ b/lib/libc/include/generic-freebsd/sys/asan.h @@ -53,14 +53,18 @@ #define KASAN_KSTACK_FREED 0xFE #define KASAN_EXEC_ARGS_FREED 0xFF +struct thread; + void kasan_init(void); void kasan_init_early(vm_offset_t, size_t); void kasan_shadow_map(vm_offset_t, size_t); void kasan_mark(const void *, size_t, size_t, uint8_t); +void kasan_thread_alloc(struct thread *); #else /* KASAN */ #define kasan_init() #define kasan_shadow_map(a, s) #define kasan_mark(p, s, l, c) +#define kasan_thread_alloc(t) #endif /* !KASAN */ #endif /* !_SYS_ASAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/atomic_common.h b/lib/libc/include/generic-freebsd/sys/atomic_common.h index b33543ebdbfa401df212cd5b0fe46ef1e08f384d..bb005ec34b0634020355e17dfc38e382944ba912 100644 --- a/lib/libc/include/generic-freebsd/sys/atomic_common.h +++ b/lib/libc/include/generic-freebsd/sys/atomic_common.h @@ -36,18 +36,18 @@ #include -#define __atomic_load_bool_relaxed(p) (*(volatile _Bool *)(p)) +#define __atomic_load_bool_relaxed(p) (*(const volatile _Bool *)(p)) #define __atomic_store_bool_relaxed(p, v) \ (*(volatile _Bool *)(p) = (_Bool)(v)) -#define __atomic_load_char_relaxed(p) (*(volatile u_char *)(p)) -#define __atomic_load_short_relaxed(p) (*(volatile u_short *)(p)) -#define __atomic_load_int_relaxed(p) (*(volatile u_int *)(p)) -#define __atomic_load_long_relaxed(p) (*(volatile u_long *)(p)) -#define __atomic_load_8_relaxed(p) (*(volatile uint8_t *)(p)) -#define __atomic_load_16_relaxed(p) (*(volatile uint16_t *)(p)) -#define __atomic_load_32_relaxed(p) (*(volatile uint32_t *)(p)) -#define __atomic_load_64_relaxed(p) (*(volatile uint64_t *)(p)) +#define __atomic_load_char_relaxed(p) (*(const volatile u_char *)(p)) +#define __atomic_load_short_relaxed(p) (*(const volatile u_short *)(p)) +#define __atomic_load_int_relaxed(p) (*(const volatile u_int *)(p)) +#define __atomic_load_long_relaxed(p) (*(const volatile u_long *)(p)) +#define __atomic_load_8_relaxed(p) (*(const volatile uint8_t *)(p)) +#define __atomic_load_16_relaxed(p) (*(const volatile uint16_t *)(p)) +#define __atomic_load_32_relaxed(p) (*(const volatile uint32_t *)(p)) +#define __atomic_load_64_relaxed(p) (*(const volatile uint64_t *)(p)) #define __atomic_store_char_relaxed(p, v) \ (*(volatile u_char *)(p) = (u_char)(v)) @@ -124,7 +124,7 @@ __atomic_store_generic(p, v, int64_t, uint64_t, 64) #endif -#define atomic_load_ptr(p) (*(volatile __typeof(*p) *)(p)) +#define atomic_load_ptr(p) (*(const volatile __typeof(*p) *)(p)) #define atomic_store_ptr(p, v) (*(volatile __typeof(*p) *)(p) = (v)) /* @@ -133,7 +133,7 @@ * openly resorting to the stronger acquire fence, to be sorted out. */ #define atomic_load_consume_ptr(p) \ - ((__typeof(*p)) atomic_load_acq_ptr((uintptr_t *)p)) + ((__typeof(*p)) atomic_load_acq_ptr((const volatile uintptr_t *)p)) #define atomic_interrupt_fence() __compiler_membar() diff --git a/lib/libc/include/generic-freebsd/sys/atomic_san.h b/lib/libc/include/generic-freebsd/sys/atomic_san.h index 6c308ba40611c1d585ae61e58c3c263517366992..b9c76185766cd1922fd3b94ed396d48fb2c9d1f7 100644 --- a/lib/libc/include/generic-freebsd/sys/atomic_san.h +++ b/lib/libc/include/generic-freebsd/sys/atomic_san.h @@ -65,10 +65,10 @@ type sp##_atomic_readandclear_##name(volatile type *) #define ATOMIC_SAN_LOAD(sp, name, type) \ - type sp##_atomic_load_##name(volatile type *) + type sp##_atomic_load_##name(const volatile type *) #define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \ - type sp##_atomic_load_acq_##name(volatile type *) + type sp##_atomic_load_acq_##name(const volatile type *) #define ATOMIC_SAN_STORE(sp, name, type) \ void sp##_atomic_store_##name(volatile type *, type) @@ -266,11 +266,10 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX); #define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr) #define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr) #define atomic_load_ptr(x) \ - ((__typeof(*x))ATOMIC_SAN(load_ptr)( \ - __DECONST(volatile uintptr_t *, (x)))) + ((__typeof(*x))ATOMIC_SAN(load_ptr)((const volatile uintptr_t *)(x))) #define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr) #define atomic_load_consume_ptr(x) \ - ((__typeof(*x))atomic_load_acq_ptr((volatile uintptr_t *)(x))) + ((__typeof(*x))atomic_load_acq_ptr((const volatile uintptr_t *)(x))) #define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr) #define atomic_set_ptr ATOMIC_SAN(set_ptr) #define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr) diff --git a/lib/libc/include/generic-freebsd/sys/bio.h b/lib/libc/include/generic-freebsd/sys/bio.h index dbde610f8c05abb22291261e734a3def62308ef8..bcd955d17e3c9efe8b2403e9a44a89cc697e7d45 100644 --- a/lib/libc/include/generic-freebsd/sys/bio.h +++ b/lib/libc/include/generic-freebsd/sys/bio.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)buf.h 8.9 (Berkeley) 3/30/95 */ #ifndef _SYS_BIO_H_ @@ -77,7 +75,6 @@ #ifdef _KERNEL struct disk; struct bio; -struct vm_map; typedef void bio_task_t(void *); @@ -146,7 +143,6 @@ struct bio_queue_head { int batched; }; -extern struct vm_map *bio_transient_map; extern int bio_transient_maxcnt; void biodone(struct bio *bp); diff --git a/lib/libc/include/generic-freebsd/sys/bitcount.h b/lib/libc/include/generic-freebsd/sys/bitcount.h index 4153d8b8e6cc65f22338afd36b092d520c57b847..0f7fdeaf89176647be8cc4a256054523f511c93d 100644 --- a/lib/libc/include/generic-freebsd/sys/bitcount.h +++ b/lib/libc/include/generic-freebsd/sys/bitcount.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)types.h 8.6 (Berkeley) 2/19/95 */ #ifndef _SYS_BITCOUNT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/buf.h b/lib/libc/include/generic-freebsd/sys/buf.h index 4a1338d2cb87f34fd1b223ac145791b80b46ed16..beafe9d9c577114353344fa0519d3f4583fd1973 100644 --- a/lib/libc/include/generic-freebsd/sys/buf.h +++ b/lib/libc/include/generic-freebsd/sys/buf.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)buf.h 8.9 (Berkeley) 3/30/95 */ #ifndef _SYS_BUF_H_ @@ -298,7 +296,7 @@ struct buf { * Initialize a lock. */ #define BUF_LOCKINIT(bp, wmesg) \ - lockinit(&(bp)->b_lock, PRIBIO + 4, wmesg, 0, LK_NEW) + lockinit(&(bp)->b_lock, PVFS, wmesg, 0, LK_NEW) /* * * Get a lock sleeping non-interruptably until it becomes available. @@ -313,7 +311,7 @@ struct buf { */ #define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \ _lockmgr_args_rw(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \ - (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \ + (interlock), (wmesg), PVFS | (catch), (timo), \ LOCK_FILE, LOCK_LINE) /* @@ -343,6 +341,13 @@ struct buf { */ #define BUF_ISLOCKED(bp) \ lockstatus(&(bp)->b_lock) + +/* + * Check if a buffer lock is currently held by LK_KERNPROC. + */ +#define BUF_DISOWNED(bp) \ + lockmgr_disowned(&(bp)->b_lock) + /* * Free a buffer lock. */ @@ -514,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */ extern u_long maxswzone; /* Max KVA for swap structures */ extern u_long maxbcache; /* Max KVA for buffer cache */ extern int maxbcachebuf; /* Max buffer cache block size */ -extern long runningbufspace; extern long hibufspace; extern int dirtybufthresh; extern int bdwriteskip; @@ -531,6 +535,7 @@ buf_mapped(struct buf *bp) return (bp->b_data != unmapped_buf); } +long runningbufclaim(struct buf *, int); void runningbufwakeup(struct buf *); void waitrunningbufspace(void); caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est); @@ -598,7 +603,7 @@ void vfs_unbusy_pages(struct buf *); int vmapbuf(struct buf *, void *, size_t, int); void vunmapbuf(struct buf *); void brelvp(struct buf *); -void bgetvp(struct vnode *, struct buf *); +int bgetvp(struct vnode *, struct buf *) __result_use_check; void pbgetbo(struct bufobj *bo, struct buf *bp); void pbgetvp(struct vnode *, struct buf *); void pbrelbo(struct buf *); diff --git a/lib/libc/include/generic-freebsd/sys/buf_ring.h b/lib/libc/include/generic-freebsd/sys/buf_ring.h index b97a4bd51b8a1ece3f3aa47af1ab9e8ce0c006f4..5e48d6612869e1698d2ca221f85980692c0aea3d 100644 --- a/lib/libc/include/generic-freebsd/sys/buf_ring.h +++ b/lib/libc/include/generic-freebsd/sys/buf_ring.h @@ -51,13 +51,13 @@ * */ struct buf_ring { - volatile uint32_t br_prod_head; - volatile uint32_t br_prod_tail; + uint32_t br_prod_head; + uint32_t br_prod_tail; int br_prod_size; int br_prod_mask; uint64_t br_drops; - volatile uint32_t br_cons_head __aligned(CACHE_LINE_SIZE); - volatile uint32_t br_cons_tail; + uint32_t br_cons_head __aligned(CACHE_LINE_SIZE); + uint32_t br_cons_tail; int br_cons_size; int br_cons_mask; #if defined(DEBUG_BUFRING) && defined(_KERNEL) @@ -83,10 +83,12 @@ buf_ring_enqueue(struct buf_ring *br, void *buf) * via drbr_peek(), and then re-added via drbr_putback() and * trigger a spurious panic. */ - for (uint32_t i = br->br_cons_head; i != br->br_prod_head; i++) + for (uint32_t i = atomic_load_32(&br->br_cons_head); + i != atomic_load_32(&br->br_prod_head); i++) if (br->br_ring[i & mask] == buf) panic("buf=%p already enqueue at %d prod=%d cons=%d", - buf, i, br->br_prod_tail, br->br_cons_tail); + buf, i, atomic_load_32(&br->br_prod_tail), + atomic_load_32(&br->br_cons_tail)); #endif critical_enter(); do { @@ -105,16 +107,15 @@ buf_ring_enqueue(struct buf_ring *br, void *buf) cons_tail = atomic_load_acq_32(&br->br_cons_tail); if ((int32_t)(cons_tail + br->br_prod_size - prod_next) < 1) { - rmb(); - if (prod_head == br->br_prod_head && - cons_tail == br->br_cons_tail) { + if (prod_head == atomic_load_32(&br->br_prod_head) && + cons_tail == atomic_load_32(&br->br_cons_tail)) { br->br_drops++; critical_exit(); return (ENOBUFS); } continue; } - } while (!atomic_cmpset_acq_32(&br->br_prod_head, prod_head, prod_next)); + } while (!atomic_cmpset_32(&br->br_prod_head, prod_head, prod_next)); prod_idx = prod_head & mask; #ifdef DEBUG_BUFRING if (br->br_ring[prod_idx] != NULL) @@ -127,7 +128,7 @@ buf_ring_enqueue(struct buf_ring *br, void *buf) * that preceded us, we need to wait for them * to complete */ - while (br->br_prod_tail != prod_head) + while (atomic_load_32(&br->br_prod_tail) != prod_head) cpu_spinwait(); atomic_store_rel_32(&br->br_prod_tail, prod_next); critical_exit(); @@ -161,7 +162,7 @@ buf_ring_dequeue_mc(struct buf_ring *br) critical_exit(); return (NULL); } - } while (!atomic_cmpset_acq_32(&br->br_cons_head, cons_head, cons_next)); + } while (!atomic_cmpset_32(&br->br_cons_head, cons_head, cons_next)); cons_idx = cons_head & mask; buf = br->br_ring[cons_idx]; @@ -173,7 +174,7 @@ buf_ring_dequeue_mc(struct buf_ring *br) * that preceded us, we need to wait for them * to complete */ - while (br->br_cons_tail != cons_head) + while (atomic_load_32(&br->br_cons_tail) != cons_head) cpu_spinwait(); atomic_store_rel_32(&br->br_cons_tail, cons_next); @@ -195,7 +196,7 @@ buf_ring_dequeue_sc(struct buf_ring *br) void *buf; mask = br->br_cons_mask; - cons_head = br->br_cons_head; + cons_head = atomic_load_32(&br->br_cons_head); prod_tail = atomic_load_acq_32(&br->br_prod_tail); cons_next = cons_head + 1; @@ -204,7 +205,7 @@ buf_ring_dequeue_sc(struct buf_ring *br) return (NULL); cons_idx = cons_head & mask; - br->br_cons_head = cons_next; + atomic_store_32(&br->br_cons_head, cons_next); buf = br->br_ring[cons_idx]; #ifdef DEBUG_BUFRING @@ -213,9 +214,9 @@ buf_ring_dequeue_sc(struct buf_ring *br) if (!mtx_owned(br->br_lock)) panic("lock not held on single consumer dequeue"); #endif - if (br->br_cons_tail != cons_head) + if (atomic_load_32(&br->br_cons_tail) != cons_head) panic("inconsistent list cons_tail=%d cons_head=%d", - br->br_cons_tail, cons_head); + atomic_load_32(&br->br_cons_tail), cons_head); #endif atomic_store_rel_32(&br->br_cons_tail, cons_next); return (buf); @@ -235,13 +236,13 @@ buf_ring_advance_sc(struct buf_ring *br) mask = br->br_cons_mask; #endif - cons_head = br->br_cons_head; - prod_tail = br->br_prod_tail; + cons_head = atomic_load_32(&br->br_cons_head); + prod_tail = atomic_load_32(&br->br_prod_tail); cons_next = cons_head + 1; if (cons_head == prod_tail) return; - br->br_cons_head = cons_next; + atomic_store_32(&br->br_cons_head, cons_next); #ifdef DEBUG_BUFRING br->br_ring[cons_head & mask] = NULL; #endif @@ -267,12 +268,13 @@ buf_ring_advance_sc(struct buf_ring *br) static __inline void buf_ring_putback_sc(struct buf_ring *br, void *new) { - uint32_t mask; + uint32_t cons_idx, mask; mask = br->br_cons_mask; - KASSERT((br->br_cons_head & mask) != (br->br_prod_tail & mask), + cons_idx = atomic_load_32(&br->br_cons_head) & mask; + KASSERT(cons_idx != (atomic_load_32(&br->br_prod_tail) & mask), ("Buf-Ring has none in putback")) ; - br->br_ring[br->br_cons_head & mask] = new; + br->br_ring[cons_idx] = new; } /* @@ -291,7 +293,7 @@ buf_ring_peek(struct buf_ring *br) #endif mask = br->br_cons_mask; prod_tail = atomic_load_acq_32(&br->br_prod_tail); - cons_head = br->br_cons_head; + cons_head = atomic_load_32(&br->br_cons_head); if (cons_head == prod_tail) return (NULL); @@ -312,7 +314,7 @@ buf_ring_peek_clear_sc(struct buf_ring *br) mask = br->br_cons_mask; prod_tail = atomic_load_acq_32(&br->br_prod_tail); - cons_head = br->br_cons_head; + cons_head = atomic_load_32(&br->br_cons_head); if (cons_head == prod_tail) return (NULL); @@ -332,22 +334,26 @@ static __inline int buf_ring_full(struct buf_ring *br) { - return (br->br_prod_head == br->br_cons_tail + br->br_cons_size - 1); + return (atomic_load_32(&br->br_prod_head) == + atomic_load_32(&br->br_cons_tail) + br->br_cons_size - 1); } static __inline int buf_ring_empty(struct buf_ring *br) { - return (br->br_cons_head == br->br_prod_tail); + return (atomic_load_32(&br->br_cons_head) == + atomic_load_32(&br->br_prod_tail)); } static __inline int buf_ring_count(struct buf_ring *br) { + uint32_t cons_tail, prod_tail; - return ((br->br_prod_size + br->br_prod_tail - br->br_cons_tail) - & br->br_prod_mask); + cons_tail = atomic_load_32(&br->br_cons_tail); + prod_tail = atomic_load_32(&br->br_prod_tail); + return ((br->br_prod_size + prod_tail - cons_tail) & br->br_prod_mask); } #ifdef _KERNEL diff --git a/lib/libc/include/generic-freebsd/sys/bufobj.h b/lib/libc/include/generic-freebsd/sys/bufobj.h index ca2b25d85ef74a62363719202af60e5d38512f96..8d9b52231ff0fe53708dd2ccb913056c45cb342e 100644 --- a/lib/libc/include/generic-freebsd/sys/bufobj.h +++ b/lib/libc/include/generic-freebsd/sys/bufobj.h @@ -33,7 +33,7 @@ * cache. * * This used to be vnodes, but we need non-vnode code to be able - * to use the buffer cache as well, specifically geom classes like gbde, + * to use the buffer cache as well, specifically geom classes like * raid3 and raid5. * * All vnodes will contain a bufobj initially, but down the road we may @@ -116,6 +116,7 @@ struct bufobj { #define BO_WWAIT (1 << 1) /* Wait for output to complete */ #define BO_DEAD (1 << 2) /* Dead; only with INVARIANTS */ #define BO_NOBUFS (1 << 3) /* No bufs allowed */ +#define BO_NONSTERILE (1 << 4) /* Ever called reassignbuf() */ #define BO_LOCKPTR(bo) (&(bo)->bo_lock) #define BO_LOCK(bo) rw_wlock(BO_LOCKPTR((bo))) diff --git a/lib/libc/include/generic-freebsd/sys/bus.h b/lib/libc/include/generic-freebsd/sys/bus.h index 272518bd97ad0439b278b05610258ed26ab6ef54..a884a4fc07c490ee4491d943a55035f9f21541f2 100644 --- a/lib/libc/include/generic-freebsd/sys/bus.h +++ b/lib/libc/include/generic-freebsd/sys/bus.h @@ -159,6 +159,7 @@ struct devreq { /* Flags for DEV_RESET */ #define DEVF_RESET_DETACH 0x0000001 /* Detach drivers vs suspend device */ +#define DEVICE_UNIT_ANY (-1) #ifdef _KERNEL @@ -276,6 +277,7 @@ enum intr_type { INTR_EXCL = 256, /* exclusive interrupt */ INTR_MPSAFE = 512, /* this interrupt is SMP safe */ INTR_ENTROPY = 1024, /* this interrupt provides entropy */ + INTR_SLEEPABLE = 2048, /* this interrupt handler can sleep */ INTR_MD1 = 4096, /* flag reserved for MD use */ INTR_MD2 = 8192, /* flag reserved for MD use */ INTR_MD3 = 16384, /* flag reserved for MD use */ @@ -305,18 +307,6 @@ enum cpu_sets { INTR_CPUS }; -typedef int (*devop_t)(void); - -/** - * @brief This structure is deprecated. - * - * Use the kobj(9) macro DEFINE_CLASS to - * declare classes which implement device drivers. - */ -struct driver { - KOBJ_CLASS_FIELDS; -}; - struct resource; /** @@ -396,7 +386,7 @@ struct resource * rman_res_t count, u_int flags); int resource_list_release(struct resource_list *rl, device_t bus, device_t child, - int type, int rid, struct resource *res); + struct resource *res); int resource_list_release_active(struct resource_list *rl, device_t bus, device_t child, int type); @@ -427,12 +417,12 @@ void root_bus_configure(void); struct _cpuset; -int bus_generic_activate_resource(device_t dev, device_t child, int type, - int rid, struct resource *r); +int bus_generic_activate_resource(device_t dev, device_t child, + struct resource *r); device_t bus_generic_add_child(device_t dev, u_int order, const char *name, int unit); -int bus_generic_adjust_resource(device_t bus, device_t child, int type, +int bus_generic_adjust_resource(device_t bus, device_t child, struct resource *r, rman_res_t start, rman_res_t end); struct resource * @@ -441,7 +431,8 @@ struct resource * rman_res_t count, u_int flags); int bus_generic_translate_resource(device_t dev, int type, rman_res_t start, rman_res_t *newstart); -int bus_generic_attach(device_t dev); +int bus_generic_attach(device_t dev) + __deprecated1("Use bus_attach_children instead"); int bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu); int bus_generic_child_location(device_t dev, device_t child, struct sbuf *sb); @@ -452,8 +443,8 @@ int bus_generic_config_intr(device_t, int, enum intr_trigger, int bus_generic_describe_intr(device_t dev, device_t child, struct resource *irq, void *cookie, const char *descr); -int bus_generic_deactivate_resource(device_t dev, device_t child, int type, - int rid, struct resource *r); +int bus_generic_deactivate_resource(device_t dev, device_t child, + struct resource *r); int bus_generic_detach(device_t dev); void bus_generic_driver_added(device_t dev, driver_t *driver); int bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op, @@ -466,9 +457,7 @@ int bus_generic_get_domain(device_t dev, device_t child, int *domain); ssize_t bus_generic_get_property(device_t dev, device_t child, const char *propname, void *propvalue, size_t size, device_property_type_t type); -struct resource_list * - bus_generic_get_resource_list(device_t, device_t); -int bus_generic_map_resource(device_t dev, device_t child, int type, +int bus_generic_map_resource(device_t dev, device_t child, struct resource *r, struct resource_map_request *args, struct resource_map *map); @@ -477,11 +466,12 @@ int bus_print_child_header(device_t dev, device_t child); int bus_print_child_domain(device_t dev, device_t child); int bus_print_child_footer(device_t dev, device_t child); int bus_generic_print_child(device_t dev, device_t child); -int bus_generic_probe(device_t dev); +int bus_generic_probe(device_t dev) + __deprecated1("Use bus_identify_children instead"); int bus_generic_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); int bus_generic_release_resource(device_t bus, device_t child, - int type, int rid, struct resource *r); + struct resource *r); int bus_generic_resume(device_t dev); int bus_generic_resume_child(device_t dev, device_t child); int bus_generic_setup_intr(device_t dev, device_t child, @@ -497,24 +487,20 @@ int bus_generic_rl_get_resource (device_t, device_t, int, int, rman_res_t *, rman_res_t *); int bus_generic_rl_set_resource (device_t, device_t, int, int, rman_res_t, rman_res_t); -int bus_generic_rl_release_resource (device_t, device_t, int, int, - struct resource *); +int bus_generic_rl_release_resource (device_t, device_t, struct resource *); struct resource * bus_generic_rman_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int bus_generic_rman_adjust_resource(device_t dev, device_t child, int type, +int bus_generic_rman_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end); int bus_generic_rman_release_resource(device_t dev, device_t child, - int type, int rid, struct resource *r); int bus_generic_rman_activate_resource(device_t dev, device_t child, - int type, int rid, struct resource *r); int bus_generic_rman_deactivate_resource(device_t dev, device_t child, - int type, int rid, struct resource *r); int bus_generic_shutdown(device_t dev); @@ -526,7 +512,7 @@ int bus_generic_suspend_intr(device_t dev, device_t child, struct resource *irq); int bus_generic_resume_intr(device_t dev, device_t child, struct resource *irq); -int bus_generic_unmap_resource(device_t dev, device_t child, int type, +int bus_generic_unmap_resource(device_t dev, device_t child, struct resource *r, struct resource_map *map); int bus_generic_write_ivar(device_t dev, device_t child, int which, @@ -554,29 +540,26 @@ int bus_alloc_resources(device_t dev, struct resource_spec *rs, void bus_release_resources(device_t dev, const struct resource_spec *rs, struct resource **res); -int bus_adjust_resource(device_t child, int type, struct resource *r, +int bus_adjust_resource(device_t child, struct resource *r, rman_res_t start, rman_res_t end); int bus_translate_resource(device_t child, int type, rman_res_t start, rman_res_t *newstart); struct resource *bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int bus_activate_resource(device_t dev, int type, int rid, - struct resource *r); -int bus_deactivate_resource(device_t dev, int type, int rid, - struct resource *r); -int bus_map_resource(device_t dev, int type, struct resource *r, +int bus_activate_resource(device_t dev, struct resource *r); +int bus_deactivate_resource(device_t dev, struct resource *r); +int bus_map_resource(device_t dev, struct resource *r, struct resource_map_request *args, struct resource_map *map); -int bus_unmap_resource(device_t dev, int type, struct resource *r, +int bus_unmap_resource(device_t dev, struct resource *r, struct resource_map *map); int bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize, struct _cpuset *cpuset); bus_dma_tag_t bus_get_dma_tag(device_t dev); bus_space_tag_t bus_get_bus_tag(device_t dev); int bus_get_domain(device_t dev, int *domain); -int bus_release_resource(device_t dev, int type, int rid, - struct resource *r); +int bus_release_resource(device_t dev, struct resource *r); int bus_free_resource(device_t dev, int type, struct resource *r); int bus_setup_intr(device_t dev, struct resource *r, int flags, driver_filter_t filter, driver_intr_t handler, @@ -597,8 +580,12 @@ void bus_delete_resource(device_t dev, int type, int rid); int bus_child_present(device_t child); int bus_child_pnpinfo(device_t child, struct sbuf *sb); int bus_child_location(device_t child, struct sbuf *sb); + +void bus_attach_children(device_t dev); +void bus_delayed_attach_children(device_t bus); +int bus_detach_children(device_t dev); void bus_enumerate_hinted_children(device_t bus); -int bus_delayed_attach_children(device_t bus); +void bus_identify_children(device_t dev); static __inline struct resource * bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) @@ -613,6 +600,47 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid, return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags)); } +/* Compat shims for simpler bus resource API. */ +int bus_adjust_resource_old(device_t child, int type, struct resource *r, + rman_res_t start, rman_res_t end); +int bus_activate_resource_old(device_t dev, int type, int rid, + struct resource *r); +int bus_deactivate_resource_old(device_t dev, int type, int rid, + struct resource *r); +int bus_map_resource_old(device_t dev, int type, struct resource *r, + struct resource_map_request *args, + struct resource_map *map); +int bus_unmap_resource_old(device_t dev, int type, struct resource *r, + struct resource_map *map); +int bus_release_resource_old(device_t dev, int type, int rid, + struct resource *r); + +#define _BUS_API_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME + +#define bus_adjust_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, bus_adjust_resource_old, \ + bus_adjust_resource)(__VA_ARGS__) + +#define bus_activate_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_activate_resource_old, \ + INVALID, bus_activate_resource)(__VA_ARGS__) + +#define bus_deactivate_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_deactivate_resource_old, \ + INVALID, bus_deactivate_resource)(__VA_ARGS__) + +#define bus_map_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, bus_map_resource_old, \ + bus_map_resource)(__VA_ARGS__) + +#define bus_unmap_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_unmap_resource_old, \ + bus_unmap_resource)(__VA_ARGS__) + +#define bus_release_resource(...) \ + _BUS_API_MACRO(__VA_ARGS__, INVALID, bus_release_resource_old, \ + INVALID, bus_release_resource)(__VA_ARGS__) + /* * Access functions for device. */ @@ -783,9 +811,7 @@ void bus_data_generation_update(void); #define BUS_LOCATOR_UEFI "UEFI" #define BUS_LOCATOR_OFW "OFW" -extern int bus_current_pass; - -void bus_set_pass(int pass); +int bus_get_pass(void); /** * Routines to lock / unlock the newbus lock. @@ -824,24 +850,25 @@ struct driver_module_data { int dmd_pass; }; -#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \ +#define EARLY_DRIVER_MODULE_ORDERED(_name, busname, driver, evh, arg, \ order, pass) \ \ -static struct driver_module_data name##_##busname##_driver_mod = { \ - evh, arg, \ - #busname, \ - (kobj_class_t) &driver, \ - NULL, \ - pass \ +static struct driver_module_data _name##_##busname##_driver_mod = { \ + .dmd_chainevh = evh, \ + .dmd_chainarg = arg, \ + .dmd_busname = #busname, \ + .dmd_driver = (kobj_class_t)&driver, \ + .dmd_devclass = NULL, \ + .dmd_pass = pass, \ }; \ \ -static moduledata_t name##_##busname##_mod = { \ - #busname "/" #name, \ - driver_module_handler, \ - &name##_##busname##_driver_mod \ +static moduledata_t _name##_##busname##_mod = { \ + .name = #busname "/" #_name , \ + .evhand = driver_module_handler, \ + .priv = &_name##_##busname##_driver_mod, \ }; \ -DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ - SI_SUB_DRIVERS, order) +DECLARE_MODULE(_name##_##busname, _name##_##busname##_mod, \ + SI_SUB_DRIVERS, order) #define EARLY_DRIVER_MODULE(name, busname, driver, evh, arg, pass) \ EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, evh, arg, \ diff --git a/lib/libc/include/generic-freebsd/sys/bus_dma.h b/lib/libc/include/generic-freebsd/sys/bus_dma.h index edf3d7bd9a98f0d6d513fd96b489cba6edc09db2..5c6b2be705c111edb22b2084a9fd72137e84dbfb 100644 --- a/lib/libc/include/generic-freebsd/sys/bus_dma.h +++ b/lib/libc/include/generic-freebsd/sys/bus_dma.h @@ -161,11 +161,8 @@ void _busdma_dflt_lock(void *arg, bus_dma_lock_op_t op); * boundary: Boundary that segments cannot cross. * lowaddr: Low restricted address that cannot appear in a mapping. * highaddr: High restricted address that cannot appear in a mapping. - * filtfunc: An optional function to further test if an address - * within the range of lowaddr and highaddr cannot appear - * in a mapping. - * filtfuncarg: An argument that will be passed to filtfunc in addition - * to the address to test. + * filtfunc: (deprecated, must be NULL) + * filtfuncarg: (deprecated, must be NULL) * maxsize: Maximum mapping size supported by this tag. * nsegments: Number of discontinuities allowed in maps. * maxsegsz: Maximum size of a segment in the map. diff --git a/lib/libc/include/generic-freebsd/sys/callout.h b/lib/libc/include/generic-freebsd/sys/callout.h index c18df73207e41ece3a9611462f80d0ca9ddd8813..d95e056954700b501017737f2a6a4390e9298cf6 100644 --- a/lib/libc/include/generic-freebsd/sys/callout.h +++ b/lib/libc/include/generic-freebsd/sys/callout.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)callout.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SYS_CALLOUT_H_ @@ -41,7 +39,7 @@ #include -#define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */ +#define CALLOUT_TRYLOCK 0x0001 /* try semantic in softclock_call_cc */ #define CALLOUT_ACTIVE 0x0002 /* callout is currently active */ #define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ #define CALLOUT_MPSAFE 0x0008 /* deprecated */ @@ -83,18 +81,15 @@ */ #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) -#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN, NULL) +#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN) void callout_init(struct callout *, int); void _callout_init_lock(struct callout *, struct lock_object *, int); #define callout_init_mtx(c, mtx, flags) \ - _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \ - NULL, (flags)) + _callout_init_lock((c), &(mtx)->lock_object, (flags)) #define callout_init_rm(c, rm, flags) \ - _callout_init_lock((c), ((rm) != NULL) ? &(rm)->lock_object : \ - NULL, (flags)) + _callout_init_lock((c), &(rm)->lock_object, (flags)) #define callout_init_rw(c, rw, flags) \ - _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ - NULL, (flags)) + _callout_init_lock((c), &(rw)->lock_object, (flags)) #define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING) int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t, void (*)(void *), void *, int, int); @@ -121,11 +116,9 @@ int callout_schedule(struct callout *, int); int callout_schedule_on(struct callout *, int, int); #define callout_schedule_curcpu(c, on_tick) \ callout_schedule_on((c), (on_tick), PCPU_GET(cpuid)) -#define callout_stop(c) _callout_stop_safe(c, 0, NULL) -int _callout_stop_safe(struct callout *, int, void (*)(void *)); +#define callout_stop(c) _callout_stop_safe(c, 0) +int _callout_stop_safe(struct callout *, int); void callout_process(sbintime_t now); -#define callout_async_drain(c, d) \ - _callout_stop_safe(c, 0, d) void callout_when(sbintime_t sbt, sbintime_t precision, int flags, sbintime_t *sbt_res, sbintime_t *prec_res); #endif diff --git a/lib/libc/include/generic-freebsd/sys/caprights.h b/lib/libc/include/generic-freebsd/sys/caprights.h index 26eb80db7fd15086c5eab204b83a11de9ae8266b..3c06e9433b66b16e530e27af655e26a54b318aee 100644 --- a/lib/libc/include/generic-freebsd/sys/caprights.h +++ b/lib/libc/include/generic-freebsd/sys/caprights.h @@ -58,51 +58,54 @@ typedef struct cap_rights cap_rights_t; #endif #ifdef _KERNEL -extern cap_rights_t cap_accept_rights; -extern cap_rights_t cap_bind_rights; -extern cap_rights_t cap_connect_rights; -extern cap_rights_t cap_event_rights; -extern cap_rights_t cap_fchdir_rights; -extern cap_rights_t cap_fchflags_rights; -extern cap_rights_t cap_fchmod_rights; -extern cap_rights_t cap_fchown_rights; -extern cap_rights_t cap_fcntl_rights; -extern cap_rights_t cap_fexecve_rights; -extern cap_rights_t cap_flock_rights; -extern cap_rights_t cap_fpathconf_rights; -extern cap_rights_t cap_fstat_rights; -extern cap_rights_t cap_fstatfs_rights; -extern cap_rights_t cap_fsync_rights; -extern cap_rights_t cap_ftruncate_rights; -extern cap_rights_t cap_futimes_rights; -extern cap_rights_t cap_getpeername_rights; -extern cap_rights_t cap_getsockopt_rights; -extern cap_rights_t cap_getsockname_rights; -extern cap_rights_t cap_ioctl_rights; -extern cap_rights_t cap_linkat_source_rights; -extern cap_rights_t cap_linkat_target_rights; -extern cap_rights_t cap_listen_rights; -extern cap_rights_t cap_mkdirat_rights; -extern cap_rights_t cap_mkfifoat_rights; -extern cap_rights_t cap_mknodat_rights; -extern cap_rights_t cap_mmap_rights; -extern cap_rights_t cap_no_rights; -extern cap_rights_t cap_pdgetpid_rights; -extern cap_rights_t cap_pdkill_rights; -extern cap_rights_t cap_pread_rights; -extern cap_rights_t cap_pwrite_rights; -extern cap_rights_t cap_read_rights; -extern cap_rights_t cap_recv_rights; -extern cap_rights_t cap_renameat_source_rights; -extern cap_rights_t cap_renameat_target_rights; -extern cap_rights_t cap_seek_rights; -extern cap_rights_t cap_send_rights; -extern cap_rights_t cap_send_connect_rights; -extern cap_rights_t cap_setsockopt_rights; -extern cap_rights_t cap_shutdown_rights; -extern cap_rights_t cap_symlinkat_rights; -extern cap_rights_t cap_unlinkat_rights; -extern cap_rights_t cap_write_rights; +extern const cap_rights_t cap_accept_rights; +extern const cap_rights_t cap_bind_rights; +extern const cap_rights_t cap_connect_rights; +extern const cap_rights_t cap_event_rights; +extern const cap_rights_t cap_fchdir_rights; +extern const cap_rights_t cap_fchflags_rights; +extern const cap_rights_t cap_fchmod_rights; +extern const cap_rights_t cap_fchown_rights; +extern const cap_rights_t cap_fchroot_rights; +extern const cap_rights_t cap_fcntl_rights; +extern const cap_rights_t cap_fexecve_rights; +extern const cap_rights_t cap_flock_rights; +extern const cap_rights_t cap_fpathconf_rights; +extern const cap_rights_t cap_fstat_rights; +extern const cap_rights_t cap_fstatfs_rights; +extern const cap_rights_t cap_fsync_rights; +extern const cap_rights_t cap_ftruncate_rights; +extern const cap_rights_t cap_futimes_rights; +extern const cap_rights_t cap_getpeername_rights; +extern const cap_rights_t cap_getsockopt_rights; +extern const cap_rights_t cap_getsockname_rights; +extern const cap_rights_t cap_inotify_add_rights; +extern const cap_rights_t cap_inotify_rm_rights; +extern const cap_rights_t cap_ioctl_rights; +extern const cap_rights_t cap_linkat_source_rights; +extern const cap_rights_t cap_linkat_target_rights; +extern const cap_rights_t cap_listen_rights; +extern const cap_rights_t cap_mkdirat_rights; +extern const cap_rights_t cap_mkfifoat_rights; +extern const cap_rights_t cap_mknodat_rights; +extern const cap_rights_t cap_mmap_rights; +extern const cap_rights_t cap_no_rights; +extern const cap_rights_t cap_pdgetpid_rights; +extern const cap_rights_t cap_pdkill_rights; +extern const cap_rights_t cap_pread_rights; +extern const cap_rights_t cap_pwrite_rights; +extern const cap_rights_t cap_read_rights; +extern const cap_rights_t cap_recv_rights; +extern const cap_rights_t cap_renameat_source_rights; +extern const cap_rights_t cap_renameat_target_rights; +extern const cap_rights_t cap_seek_rights; +extern const cap_rights_t cap_send_rights; +extern const cap_rights_t cap_send_connect_rights; +extern const cap_rights_t cap_setsockopt_rights; +extern const cap_rights_t cap_shutdown_rights; +extern const cap_rights_t cap_symlinkat_rights; +extern const cap_rights_t cap_unlinkat_rights; +extern const cap_rights_t cap_write_rights; #endif #endif /* !_SYS_CAPRIGHTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/capsicum.h b/lib/libc/include/generic-freebsd/sys/capsicum.h index cf1faa52a020a7e4202307460c49e9bd79b1c6bc..bc5e6ca8e4b9dd4e81c5cbba8e52e008598c0fe8 100644 --- a/lib/libc/include/generic-freebsd/sys/capsicum.h +++ b/lib/libc/include/generic-freebsd/sys/capsicum.h @@ -39,7 +39,6 @@ #ifndef _SYS_CAPSICUM_H_ #define _SYS_CAPSICUM_H_ -#include #include #include @@ -202,6 +201,9 @@ /* Allows for renameat(2) (target directory descriptor). */ #define CAP_RENAMEAT_TARGET (CAP_LOOKUP | 0x0000040000000000ULL) +/* Allows for fchroot(2). */ +#define CAP_FCHROOT CAPRIGHT(0, 0x0000080000000000ULL) + #define CAP_SOCK_CLIENT \ (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \ CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN) @@ -211,11 +213,9 @@ CAP_SETSOCKOPT | CAP_SHUTDOWN) /* All used bits for index 0. */ -#define CAP_ALL0 CAPRIGHT(0, 0x000007FFFFFFFFFFULL) +#define CAP_ALL0 CAPRIGHT(0, 0x00000FFFFFFFFFFFULL) /* Available bits for index 0. */ -#define CAP_UNUSED0_44 CAPRIGHT(0, 0x0000080000000000ULL) -/* ... */ #define CAP_UNUSED0_57 CAPRIGHT(0, 0x0100000000000000ULL) /* INDEX 1 */ @@ -279,11 +279,15 @@ #define CAP_KQUEUE (CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE) +/* Allows operations on inotify descriptors. */ +#define CAP_INOTIFY_ADD CAPRIGHT(1, 0x0000000000200000ULL) +#define CAP_INOTIFY_RM CAPRIGHT(1, 0x0000000000400000ULL) + /* All used bits for index 1. */ -#define CAP_ALL1 CAPRIGHT(1, 0x00000000001FFFFFULL) +#define CAP_ALL1 CAPRIGHT(1, 0x00000000007FFFFFULL) /* Available bits for index 1. */ -#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000200000ULL) +#define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000800000ULL) /* ... */ #define CAP_UNUSED1_57 CAPRIGHT(1, 0x0100000000000000ULL) @@ -371,6 +375,24 @@ _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00, _r; \ }) +#define _CAP_RIGHTS_WORD_INITIALIZER(i, r) \ + (CAPIDXBIT(r) == (i) + 1 ? (r) : 0ULL) + +/* + * Define a set of up to two rights at compile time. + */ +#define CAP_RIGHTS_INITIALIZER2(r1, r2) ((struct cap_rights){ \ + .cr_rights = { \ + [0] = ((uint64_t)CAP_RIGHTS_VERSION << 62) | \ + _CAP_RIGHTS_WORD_INITIALIZER(0, r1) | \ + _CAP_RIGHTS_WORD_INITIALIZER(0, r2), \ + [1] = _CAP_RIGHTS_WORD_INITIALIZER(1, r1) | \ + _CAP_RIGHTS_WORD_INITIALIZER(1, r2), \ + }, \ +}) +#define CAP_RIGHTS_INITIALIZER(r) \ + CAP_RIGHTS_INITIALIZER2(r, 0ULL) + /* * Allow checking caps which are possibly getting modified at the same time. * The caller is expected to determine whether the result is legitimate via diff --git a/lib/libc/include/generic-freebsd/sys/cdefs.h b/lib/libc/include/generic-freebsd/sys/cdefs.h index ebdedf90235316478f8e564d1cb69dcec52d308e..695f9919aaf20454e539a2fa80ce55e34c3b15ba 100644 --- a/lib/libc/include/generic-freebsd/sys/cdefs.h +++ b/lib/libc/include/generic-freebsd/sys/cdefs.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 */ #ifndef _SYS_CDEFS_H_ @@ -42,7 +40,10 @@ #endif /* - * Testing against Clang-specific extensions. + * Provide clang-compatible testing macros. All supported versions of gcc (10+) + * provide all of these except has_feature and has_extension which are new in + * gcc 14. Keep the older ifndefs, though, for non-gcc compilers that may lack + * them like tcc and pcc. */ #ifndef __has_attribute #define __has_attribute(x) 0 @@ -74,53 +75,6 @@ * having a compiler-agnostic source tree. */ -#if defined(__GNUC__) - -#if __GNUC__ >= 3 -#define __GNUCLIKE_ASM 3 -#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS -#else -#define __GNUCLIKE_ASM 2 -#endif -#define __GNUCLIKE___TYPEOF 1 -#define __GNUCLIKE___SECTION 1 - -#define __GNUCLIKE_CTOR_SECTION_HANDLING 1 - -#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 - -#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) -#define __GNUCLIKE_BUILTIN_VARARGS 1 -#define __GNUCLIKE_BUILTIN_STDARG 1 -#define __GNUCLIKE_BUILTIN_VAALIST 1 -#endif - -#define __GNUC_VA_LIST_COMPATIBILITY 1 - -/* - * Compiler memory barriers, specific to gcc and clang. - */ -#define __compiler_membar() __asm __volatile(" " : : : "memory") - -#define __GNUCLIKE_BUILTIN_NEXT_ARG 1 -#define __GNUCLIKE_MATH_BUILTIN_RELOPS - -#define __GNUCLIKE_BUILTIN_MEMCPY 1 - -/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ -#define __CC_SUPPORTS_INLINE 1 -#define __CC_SUPPORTS___INLINE 1 -#define __CC_SUPPORTS___INLINE__ 1 - -#define __CC_SUPPORTS___FUNC__ 1 -#define __CC_SUPPORTS_WARNING 1 - -#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ - -#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 - -#endif /* __GNUC__ */ - /* * Macro to test if we're using a specific version of gcc or later. */ @@ -131,6 +85,26 @@ #define __GNUC_PREREQ__(ma, mi) 0 #endif +#if defined(__GNUC__) + +/* + * Compiler memory barriers, specific to gcc and clang. + */ +#define __compiler_membar() __asm __volatile(" " : : : "memory") + +#define __CC_SUPPORTS___INLINE 1 +#define __CC_SUPPORTS_SYMVER 1 + +#endif /* __GNUC__ */ + +/* + * TinyC pretends to be gcc 9.3. This is generally good enough to support + * everything FreeBSD... except for the .symver assembler directive. + */ +#ifdef __TINYC__ +#undef __CC_SUPPORTS_SYMVER +#endif + /* * The __CONCAT macro is used to concatenate parts of symbol names, e.g. * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. @@ -150,8 +124,6 @@ #define __STRING(x) #x /* stringify without expanding x */ #define __XSTRING(x) __STRING(x) /* expand x, then stringify */ -#define __const const /* define reserved names to standard */ -#define __signed signed #define __volatile volatile #if defined(__cplusplus) #define __inline inline /* convert to C++ keyword */ @@ -165,76 +137,32 @@ #define __P(protos) () /* traditional C preprocessor */ #define __CONCAT(x,y) x/**/y #define __STRING(x) "x" - #if !defined(__CC_SUPPORTS___INLINE) -#define __const /* delete pseudo-ANSI C keywords */ +/* Just delete these in a K&R environment */ #define __inline -#define __signed #define __volatile -/* - * In non-ANSI C environments, new programs will want ANSI-only C keywords - * deleted from the program and old programs will want them left alone. - * When using a compiler other than gcc, programs using the ANSI C keywords - * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. - * When using "gcc -traditional", we assume that this is the intent; if - * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. - */ -#ifndef NO_ANSI_KEYWORDS -#define const /* delete ANSI C keywords */ -#define inline -#define signed -#define volatile -#endif /* !NO_ANSI_KEYWORDS */ #endif /* !__CC_SUPPORTS___INLINE */ #endif /* !(__STDC__ || __cplusplus) */ /* - * Compiler-dependent macros to help declare dead (non-returning) and - * pure (no side effects) functions, and unused variables. They are - * null except for versions of gcc that are known to support the features - * properly (old versions of gcc-2 supported the dead and pure features - * in a different (wrong) way). If we do not provide an implementation - * for a given compiler, let the compile fail if it is told to use - * a feature that we cannot live without. + * Compiler-dependent macros to help declare dead (non-returning) and pure (no + * side effects) functions, and unused variables. These attributes are supported + * by all current compilers, even pcc. */ #define __weak_symbol __attribute__((__weak__)) -#if !__GNUC_PREREQ__(2, 5) -#define __dead2 -#define __pure2 -#define __unused -#endif -#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 -#define __dead2 __attribute__((__noreturn__)) -#define __pure2 __attribute__((__const__)) -#define __unused -/* XXX Find out what to do for __packed, __aligned and __section */ -#endif -#if __GNUC_PREREQ__(2, 7) #define __dead2 __attribute__((__noreturn__)) #define __pure2 __attribute__((__const__)) #define __unused __attribute__((__unused__)) #define __used __attribute__((__used__)) +#define __deprecated __attribute__((__deprecated__)) +#define __deprecated1(msg) __attribute__((__deprecated__(msg))) #define __packed __attribute__((__packed__)) #define __aligned(x) __attribute__((__aligned__(x))) #define __section(x) __attribute__((__section__(x))) -#endif #define __writeonly __unused -#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) #define __alloc_size(x) __attribute__((__alloc_size__(x))) #define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x))) -#else -#define __alloc_size(x) -#define __alloc_size2(n, x) -#endif -#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__) #define __alloc_align(x) __attribute__((__alloc_align__(x))) -#else -#define __alloc_align(x) -#endif - -#if !__GNUC_PREREQ__(2, 95) -#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) -#endif /* * Keywords added in C11. @@ -258,15 +186,6 @@ #define _Alignof(x) __alignof(x) #endif -#if !defined(__cplusplus) && !__has_extension(c_atomic) && \ - !__has_extension(cxx_atomic) && !__GNUC_PREREQ__(4, 7) -/* - * No native support for _Atomic(). Place object in structure to prevent - * most forms of direct non-atomic access. - */ -#define _Atomic(T) struct { T volatile __val; } -#endif - #if defined(__cplusplus) && __cplusplus >= 201103L #define _Noreturn [[noreturn]] #else @@ -281,12 +200,7 @@ #endif #if !__has_extension(c_thread_local) -/* - * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode - * without actually supporting the thread_local keyword. Don't check for - * the presence of C++11 when defining _Thread_local. - */ -#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ +#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ __has_extension(cxx_thread_local) #define _Thread_local thread_local #else @@ -312,10 +226,10 @@ __has_extension(c_generic_selections) #define __generic(expr, t, yes, no) \ _Generic(expr, t: yes, default: no) -#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) +#elif !defined(__cplusplus) #define __generic(expr, t, yes, no) \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(__typeof((0, (expr))), t), yes, no) + __builtin_choose_expr(__builtin_types_compatible_p( \ + __typeof(((void)0, (expr))), t), yes, no) #endif /* @@ -326,59 +240,24 @@ * void bar(int myArray[__min_size(10)]); */ #if !defined(__cplusplus) && \ - (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \ (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901)) #define __min_size(x) static (x) #else #define __min_size(x) (x) #endif -#if __GNUC_PREREQ__(2, 96) #define __malloc_like __attribute__((__malloc__)) #define __pure __attribute__((__pure__)) -#else -#define __malloc_like -#define __pure -#endif -#if __GNUC_PREREQ__(3, 1) -#define __always_inline __attribute__((__always_inline__)) -#else -#define __always_inline -#endif - -#if __GNUC_PREREQ__(3, 1) +#define __always_inline __inline __attribute__((__always_inline__)) #define __noinline __attribute__ ((__noinline__)) -#else -#define __noinline -#endif - -#if __GNUC_PREREQ__(3, 4) #define __fastcall __attribute__((__fastcall__)) #define __result_use_check __attribute__((__warn_unused_result__)) -#else -#define __fastcall -#define __result_use_check -#endif - -#if __GNUC_PREREQ__(4, 1) #define __returns_twice __attribute__((__returns_twice__)) -#else -#define __returns_twice -#endif -#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable) #define __unreachable() __builtin_unreachable() -#else -#define __unreachable() ((void)0) -#endif -/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ -#if !__GNUC_PREREQ__(2, 7) -#define __func__ NULL -#endif - -#if (defined(__GNUC__) && __GNUC__ >= 2) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 #define __LONG_LONG_SUPPORTED #endif @@ -393,6 +272,55 @@ #endif #endif +/* + * noexcept keyword added in C++11. + */ +#if defined(__cplusplus) && __cplusplus >= 201103L +#define __noexcept noexcept +#define __noexcept_if(__c) noexcept(__c) +#else +#define __noexcept +#define __noexcept_if(__c) +#endif + +/* + * nodiscard attribute added in C++17 and C23, but supported by both LLVM and + * GCC in earlier language versions, so we use __has_c{,pp}_attribute to test + * for it. + * + * __nodiscard may be used on a function: + * __nodiscard int f(); + * + * or on a struct, union or enum: + * struct __nodiscard S{}; + * struct S f(); + * + * or in C++, on an object constructor. + */ + +#if defined(__cplusplus) && defined(__has_cpp_attribute) +#if __has_cpp_attribute(nodiscard) +#define __nodiscard [[nodiscard]] +#endif +#elif defined(__STDC_VERSION__) && defined(__has_c_attribute) +#if __has_c_attribute(__nodiscard__) +#define __nodiscard [[__nodiscard__]] +#endif +#endif + +#ifndef __nodiscard +/* + * LLVM 16 and earlier don't support [[nodiscard]] in C, but they do support + * __warn_unused_result__ with the same semantics, so fall back to that. + * We can't do this for GCC because the semantics are different. + */ +#ifdef __clang__ +#define __nodiscard __attribute__((__warn_unused_result__)) +#else +#define __nodiscard +#endif +#endif + /* * We use `__restrict' as a way to define the `restrict' type qualifier * without disturbing older software that is unaware of C99 keywords. @@ -401,73 +329,27 @@ */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901 #define __restrict restrict -#elif !__GNUC_PREREQ__(2, 95) -#define __restrict #endif /* - * GNU C version 2.96 adds explicit branch prediction so that - * the CPU back-end can hint the processor and also so that - * code blocks can be reordered such that the predicted path - * sees a more linear flow, thus improving cache behavior, etc. - * - * The following two macros provide us with a way to utilize this - * compiler feature. Use __predict_true() if you expect the expression - * to evaluate to true, and __predict_false() if you expect the - * expression to evaluate to false. - * - * A few notes about usage: - * - * * Generally, __predict_false() error condition checks (unless - * you have some _strong_ reason to do otherwise, in which case - * document it), and/or __predict_true() `no-error' condition - * checks, assuming you want to optimize for the no-error case. - * - * * Other than that, if you don't know the likelihood of a test - * succeeding from empirical or other `hard' evidence, don't - * make predictions. - * - * * These are meant to be used in places that are run `a lot'. - * It is wasteful to make predictions in code that is run - * seldomly (e.g. at subsystem initialization time) as the - * basic block reordering that this affects can often generate - * larger code. + * All modern compilers have explicit branch prediction so that the CPU back-end + * can hint to the processor and also so that code blocks can be reordered such + * that the predicted path sees a more linear flow, thus improving cache + * behavior, etc. Use sparingly, except in performance critical code where + * they make things measurably faster. */ -#if __GNUC_PREREQ__(2, 96) #define __predict_true(exp) __builtin_expect((exp), 1) #define __predict_false(exp) __builtin_expect((exp), 0) -#else -#define __predict_true(exp) (exp) -#define __predict_false(exp) (exp) -#endif -#if __GNUC_PREREQ__(4, 0) #define __null_sentinel __attribute__((__sentinel__)) #define __exported __attribute__((__visibility__("default"))) #define __hidden __attribute__((__visibility__("hidden"))) -#else -#define __null_sentinel -#define __exported -#define __hidden -#endif /* * We define this here since , , and * require it. */ -#if __GNUC_PREREQ__(4, 1) #define __offsetof(type, field) __builtin_offsetof(type, field) -#else -#ifndef __cplusplus -#define __offsetof(type, field) \ - ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) -#else -#define __offsetof(type, field) \ - (__offsetof__ (reinterpret_cast <__size_t> \ - (&reinterpret_cast \ - (static_cast (0)->field)))) -#endif -#endif #define __rangeof(type, start, end) \ (__offsetof(type, end) - __offsetof(type, start)) @@ -477,29 +359,15 @@ * assign pointer x to a local variable, to check that its type is * compatible with member m. */ -#if __GNUC_PREREQ__(3, 1) #define __containerof(x, s, m) ({ \ const volatile __typeof(((s *)0)->m) *__x = (x); \ __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ }) -#else -#define __containerof(x, s, m) \ - __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) -#endif /* * Compiler-dependent macros to declare that functions take printf-like - * or scanf-like arguments. They are null except for versions of gcc - * that are known to support the features properly (old versions of gcc-2 - * didn't permit keeping the keywords out of the application namespace). + * or scanf-like arguments. */ -#if !__GNUC_PREREQ__(2, 7) -#define __printflike(fmtarg, firstvararg) -#define __scanflike(fmtarg, firstvararg) -#define __format_arg(fmtarg) -#define __strfmonlike(fmtarg, firstvararg) -#define __strftimelike(fmtarg, firstvararg) -#else #define __printflike(fmtarg, firstvararg) \ __attribute__((__format__ (__printf__, fmtarg, firstvararg))) #define __scanflike(fmtarg, firstvararg) \ @@ -509,18 +377,23 @@ __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) #define __strftimelike(fmtarg, firstvararg) \ __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) -#endif -/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ -#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ - defined(__GNUC__) +/* + * Like __printflike, but allows fmtarg to be NULL. FreeBSD invented 'printf0' + * for this because older versions of gcc issued warnings for NULL first args. + * Clang has always had printf and printf0 as aliases. gcc 11.0 now follows + * clang. So now this is an alias for __printflike, or nothing. In the future + * _Nullable or _Nonnull will replace this. + * XXX Except that doesn't work, so for now revert to printf0 for clang and + * the FreeBSD gcc until I can work this out. + */ +#if defined(__clang__) || (defined(__GNUC__) && defined (__FreeBSD_cc_version)) #define __printf0like(fmtarg, firstvararg) \ __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) #else #define __printf0like(fmtarg, firstvararg) #endif -#if defined(__GNUC__) #define __strong_reference(sym,aliassym) \ extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) #ifdef __STDC__ @@ -531,10 +404,12 @@ __asm__(".section .gnu.warning." #sym); \ __asm__(".asciz \"" msg "\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@" #verid) #define __sym_default(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@@@" #verid) +#endif #else #define __weak_reference(sym,alias) \ __asm__(".weak alias"); \ @@ -543,27 +418,18 @@ __asm__(".section .gnu.warning.sym"); \ __asm__(".asciz \"msg\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver impl, sym@verid") #define __sym_default(impl,sym,verid) \ __asm__(".symver impl, sym@@@verid") +#endif #endif /* __STDC__ */ -#endif /* __GNUC__ */ #define __GLOBL(sym) __asm__(".globl " __XSTRING(sym)) #define __WEAK(sym) __asm__(".weak " __XSTRING(sym)) -#if defined(__GNUC__) #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") -#else -/* - * The following definition might not work well if used in header files, - * but it should be better than nothing. If you want a "do nothing" - * version, then it should generate some harmless declaration, such as: - * #define __IDSTRING(name,string) struct __hack - */ -#define __IDSTRING(name,string) static const char name[] __unused = string -#endif /* * Embed the rcs id of a source file in the resulting library. Note that in @@ -622,164 +488,13 @@ #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #endif -/*- - * The following definitions are an extension of the behavior originally - * implemented in , but with a different level of granularity. - * POSIX.1 requires that the macros we test be defined before any standard - * header file is included. - * - * Here's a quick run-down of the versions (and some informal names) - * defined(_POSIX_SOURCE) 1003.1-1988 - * encoded as 198808 below - * _POSIX_C_SOURCE == 1 1003.1-1990 - * encoded as 199009 below - * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option - * encoded as 199209 below - * _POSIX_C_SOURCE == 199309 1003.1b-1993 - * (1003.1 Issue 4, Single Unix Spec v1, Unix 93) - * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, - * and the omnibus ISO/IEC 9945-1: 1996 - * (1003.1 Issue 5, Single Unix Spec v2, Unix 95) - * _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03) - * _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7) - * IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is - * 1003.1-2008 with two TCs applied with - * _POSIX_C_SOURCE=200809 and _XOPEN_SOURCE=700 - * - * In addition, the X/Open Portability Guide, which is now the Single UNIX - * Specification, defines a feature-test macro which indicates the version of - * that specification, and which subsumes _POSIX_C_SOURCE. - * - * Our macros begin with two underscores to avoid namespace screwage. - */ - -/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 -#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ -#define _POSIX_C_SOURCE 199009 -#endif - -/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199209 -#endif - -/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ -#ifdef _XOPEN_SOURCE -#if _XOPEN_SOURCE - 0 >= 700 -#define __XSI_VISIBLE 700 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809 -#elif _XOPEN_SOURCE - 0 >= 600 -#define __XSI_VISIBLE 600 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112 -#elif _XOPEN_SOURCE - 0 >= 500 -#define __XSI_VISIBLE 500 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199506 -#endif -#endif - -/* - * Deal with all versions of POSIX. The ordering relative to the tests above is - * important. - */ -#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) -#define _POSIX_C_SOURCE 198808 -#endif -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 200809 -#define __POSIX_VISIBLE 200809 -#define __ISO_C_VISIBLE 1999 -#elif _POSIX_C_SOURCE >= 200112 -#define __POSIX_VISIBLE 200112 -#define __ISO_C_VISIBLE 1999 -#elif _POSIX_C_SOURCE >= 199506 -#define __POSIX_VISIBLE 199506 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199309 -#define __POSIX_VISIBLE 199309 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199209 -#define __POSIX_VISIBLE 199209 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199009 -#define __POSIX_VISIBLE 199009 -#define __ISO_C_VISIBLE 1990 -#else -#define __POSIX_VISIBLE 198808 -#define __ISO_C_VISIBLE 0 -#endif /* _POSIX_C_SOURCE */ -/* - * Both glibc and OpenBSD enable c11 features when _ISOC11_SOURCE is defined, or - * when compiling with -stdc=c11. A strict reading of the standard would suggest - * doing it only for the former. However, a strict reading also requires C99 - * mode only, so building with C11 is already undefined. Follow glibc's and - * OpenBSD's lead for this non-standard configuration for maximum compatibility. - */ -#if _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) -#undef __ISO_C_VISIBLE -#define __ISO_C_VISIBLE 2011 -#endif -#else -/*- - * Deal with _ANSI_SOURCE: - * If it is defined, and no other compilation environment is explicitly - * requested, then define our internal feature-test macros to zero. This - * makes no difference to the preprocessor (undefined symbols in preprocessing - * expressions are defined to have value zero), but makes it more convenient for - * a test program to print out the values. - * - * If a program mistakenly defines _ANSI_SOURCE and some other macro such as - * _POSIX_C_SOURCE, we will assume that it wants the broader compilation - * environment (and in fact we will never get here). - */ -#if defined(_ANSI_SOURCE) /* Hide almost everything. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 1990 -#define __EXT1_VISIBLE 0 -#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 1999 -#define __EXT1_VISIBLE 0 -#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 2011 -#define __EXT1_VISIBLE 0 -#else /* Default environment: show everything. */ -#define __POSIX_VISIBLE 200809 -#define __XSI_VISIBLE 700 -#define __BSD_VISIBLE 1 -#define __ISO_C_VISIBLE 2011 -#define __EXT1_VISIBLE 1 -#endif +#if !defined(_STANDALONE) && !defined(_KERNEL) +#define __RENAME(x) __asm(__STRING(x)) +#else /* _STANDALONE || _KERNEL */ +#define __RENAME(x) no renaming in kernel/standalone environment #endif -/* User override __EXT1_VISIBLE */ -#if defined(__STDC_WANT_LIB_EXT1__) -#undef __EXT1_VISIBLE -#if __STDC_WANT_LIB_EXT1__ -#define __EXT1_VISIBLE 1 -#else -#define __EXT1_VISIBLE 0 -#endif -#endif /* __STDC_WANT_LIB_EXT1__ */ - -/* - * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h - * translates them to __ARM_ARCH and the modern feature symbols defined by ARM. - */ -#if defined(__arm__) && !defined(__ARM_ARCH) -#include -#endif +#include /* * Nullability qualifiers: currently only supported by Clang. diff --git a/lib/libc/include/generic-freebsd/sys/cnv.h b/lib/libc/include/generic-freebsd/sys/cnv.h index 848ba6aee0b8e49a0d25cc9d3fc757054a6ec108..ec506bc758d0c0df79fd4da5acdb8eaf4da6967b 100644 --- a/lib/libc/include/generic-freebsd/sys/cnv.h +++ b/lib/libc/include/generic-freebsd/sys/cnv.h @@ -30,6 +30,7 @@ #define _CNV_H_ #include +#include #ifndef _KERNEL #include @@ -39,13 +40,6 @@ #include #endif -#ifndef _NVLIST_T_DECLARED -#define _NVLIST_T_DECLARED -struct nvlist; - -typedef struct nvlist nvlist_t; -#endif - __BEGIN_DECLS /* diff --git a/lib/libc/include/generic-freebsd/sys/compressor.h b/lib/libc/include/generic-freebsd/sys/compressor.h index 6055be70952127a0396e7df1439e1936523c61dd..3672d644fca11741ffa76b669f3e4f1c778b6041 100644 --- a/lib/libc/include/generic-freebsd/sys/compressor.h +++ b/lib/libc/include/generic-freebsd/sys/compressor.h @@ -42,6 +42,7 @@ struct compressor; bool compressor_avail(int format); struct compressor *compressor_init(compressor_cb_t cb, int format, size_t maxiosize, int level, void *arg); +int compressor_format(const struct compressor *stream); void compressor_reset(struct compressor *stream); int compressor_write(struct compressor *stream, void *data, size_t len); diff --git a/lib/libc/include/generic-freebsd/sys/conf.h b/lib/libc/include/generic-freebsd/sys/conf.h index 6b5d407e6d1c400b3bbbcb460ba4391032f7e7d0..419b8ea2cec5b9790ed748d6844fb36a9976f95b 100644 --- a/lib/libc/include/generic-freebsd/sys/conf.h +++ b/lib/libc/include/generic-freebsd/sys/conf.h @@ -34,8 +34,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)conf.h 8.5 (Berkeley) 1/9/95 */ #ifndef _SYS_CONF_H_ @@ -46,6 +44,7 @@ #else #include #endif +#include struct snapdata; struct devfs_dirent; @@ -160,6 +159,7 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh); #define GID_RT_PRIO 47 #define GID_ID_PRIO 48 #define GID_DIALER 68 +#define GID_U2F 116 #define GID_NOGROUP 65533 #define GID_NOBODY 65534 @@ -278,6 +278,7 @@ void destroy_dev(struct cdev *_dev); int destroy_dev_sched(struct cdev *dev); int destroy_dev_sched_cb(struct cdev *dev, void (*cb)(void *), void *arg); void destroy_dev_drain(struct cdevsw *csw); +void dev_copyname(struct cdev *dev, char *path, size_t len); struct cdevsw *dev_refthread(struct cdev *_dev, int *_ref); struct cdevsw *devvn_refthread(struct vnode *vp, struct cdev **devp, int *_ref); void dev_relthread(struct cdev *_dev, int _ref); @@ -360,6 +361,7 @@ struct dumperinfo { }; extern int dumping; /* system is dumping */ +extern bool dumped_core; /* system successfully dumped kernel core */ /* * Save registers for later extraction from a kernel dump. diff --git a/lib/libc/include/generic-freebsd/sys/cons.h b/lib/libc/include/generic-freebsd/sys/cons.h index 0f9e15cb6c25515f4668e4b51ebb323f96c2b60f..a6f81371c9eeafafbc087f005ca2ae38aae7a82a 100644 --- a/lib/libc/include/generic-freebsd/sys/cons.h +++ b/lib/libc/include/generic-freebsd/sys/cons.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 */ #ifndef _MACHINE_CONS_H_ @@ -96,6 +94,8 @@ struct consdev { #ifdef _KERNEL +extern int cn_mute; + extern struct msgbuf consmsgbuf; /* Message buffer for constty. */ extern struct tty *constty; /* Temporary virtual console. */ diff --git a/lib/libc/include/generic-freebsd/sys/copyright.h b/lib/libc/include/generic-freebsd/sys/copyright.h index e6fad408baa1d911ccf45f948ee6e80d6b7749f2..024b0417564f2e32e1e36759b381f3f503461829 100644 --- a/lib/libc/include/generic-freebsd/sys/copyright.h +++ b/lib/libc/include/generic-freebsd/sys/copyright.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 1992-2023 The FreeBSD Project. All rights reserved. + * Copyright (C) 1992-2025 The FreeBSD Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,7 +35,7 @@ /* FreeBSD */ #define COPYRIGHT_FreeBSD \ - "Copyright (c) 1992-2023 The FreeBSD Project.\n" + "Copyright (c) 1992-2025 The FreeBSD Project.\n" /* Foundation */ #define TRADEMARK_Foundation \ diff --git a/lib/libc/include/generic-freebsd/sys/counter.h b/lib/libc/include/generic-freebsd/sys/counter.h index 12521036a2f053f0f6e2322fab6ea0866479bba2..9fa5f85bf637c545ce3e797f61fa18003993a196 100644 --- a/lib/libc/include/generic-freebsd/sys/counter.h +++ b/lib/libc/include/generic-freebsd/sys/counter.h @@ -60,17 +60,12 @@ uint64_t counter_u64_fetch(counter_u64_t); counter_u64_zero((a)[_i]); \ } while (0) -/* - * counter(9) based rate checking. - */ -struct counter_rate { - counter_u64_t cr_rate; /* Events since last second */ - volatile int cr_lock; /* Lock to clean the struct */ - int cr_ticks; /* Ticks on last clean */ - int cr_over; /* Over limit since cr_ticks? */ -}; +struct counter_rate; +struct counter_rate *counter_rate_alloc(int flags, int period); +void counter_rate_free(struct counter_rate *); int64_t counter_ratecheck(struct counter_rate *, int64_t); +uint64_t counter_rate_get(struct counter_rate *); #define COUNTER_U64_SYSINIT(c) \ SYSINIT(c##_counter_sysinit, SI_SUB_COUNTER, \ diff --git a/lib/libc/include/generic-freebsd/sys/cpuset.h b/lib/libc/include/generic-freebsd/sys/cpuset.h index d78fe502679ea08aa0b9b9d188b237dcd0651c9f..f91e224ac5679d5cc55d9c3a9721704b3f6c67f8 100644 --- a/lib/libc/include/generic-freebsd/sys/cpuset.h +++ b/lib/libc/include/generic-freebsd/sys/cpuset.h @@ -61,8 +61,10 @@ #define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2) #define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2) #define CPU_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(CPU_SETSIZE, n, p) +#define CPU_TEST_CLR_ATOMIC(n, p) __BIT_TEST_CLR_ATOMIC(CPU_SETSIZE, n, p) #define CPU_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(CPU_SETSIZE, n, p) #define CPU_SET_ATOMIC_ACQ(n, p) __BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p) +#define CPU_TEST_SET_ATOMIC(n, p) __BIT_TEST_SET_ATOMIC(CPU_SETSIZE, n, p) #define CPU_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(CPU_SETSIZE, n, p) #define CPU_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #define CPU_COPY_STORE_REL(f, t) __BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) diff --git a/lib/libc/include/generic-freebsd/sys/devicestat.h b/lib/libc/include/generic-freebsd/sys/devicestat.h index 6800b78a278664d6eb42323c3d3525092fc99227..3432e2e07840a0d7158d0470071db0c46fb43dc9 100644 --- a/lib/libc/include/generic-freebsd/sys/devicestat.h +++ b/lib/libc/include/generic-freebsd/sys/devicestat.h @@ -125,6 +125,7 @@ typedef enum { DEVSTAT_TYPE_IF_SCSI = 0x010, DEVSTAT_TYPE_IF_IDE = 0x020, DEVSTAT_TYPE_IF_OTHER = 0x030, + DEVSTAT_TYPE_IF_NVME = 0x040, DEVSTAT_TYPE_IF_MASK = 0x0f0, DEVSTAT_TYPE_PASS = 0x100 } devstat_type_flags; diff --git a/lib/libc/include/generic-freebsd/sys/devmap.h b/lib/libc/include/generic-freebsd/sys/devmap.h index 16352124de49dc7e3d90abccd627a73cf5e643ce..e8c59b9e2b74ac06d82f9ac9bea044abc85c370f 100644 --- a/lib/libc/include/generic-freebsd/sys/devmap.h +++ b/lib/libc/include/generic-freebsd/sys/devmap.h @@ -33,6 +33,7 @@ #error "no user-serviceable parts inside" #endif +#ifdef __HAVE_STATIC_DEVMAP /* * This structure is used by MD code to describe static mappings of devices * which are established as part of bringing up the MMU early in the boot. @@ -71,27 +72,13 @@ void devmap_register_table(const struct devmap_entry * _table); * Establish mappings for all the entries in the table. This is called * automatically from the common platform-specific init function in * /machdep.c, and also from the custom platform-specific init routines - * in older code. If the table pointer is NULL, this will use the table - * installed previously by devmap_register_table(). + * in older code. This function only has an effect when a table was installed + * previously by devmap_register_table(). */ -void devmap_bootstrap(vm_offset_t _l1pt, - const struct devmap_entry *_table); - -/* - * Translate between virtual and physical addresses within a region that is - * static-mapped by the devmap code. If the given address range isn't - * static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND. - * The latter implies that you can't vtop just the last byte of physical address - * space. This is not as limiting as it might sound, because even if a device - * occupies the end of the physical address space, you're only prevented from - * doing vtop for that single byte. If you vtop a size bigger than 1 it works. - */ -#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1)) - -void * devmap_ptov(vm_paddr_t _pa, vm_size_t _sz); -vm_paddr_t devmap_vtop(void * _va, vm_size_t _sz); +void devmap_bootstrap(void); /* Print the static mapping table; used for bootverbose output. */ void devmap_print_table(void); +#endif #endif /* !_SYS_DEVMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/dirent.h b/lib/libc/include/generic-freebsd/sys/dirent.h index 17bf89cf85547cc98eff63936a2439eb94bac75e..036b5f802b5b54b0874094d5f6a688191e300a5f 100644 --- a/lib/libc/include/generic-freebsd/sys/dirent.h +++ b/lib/libc/include/generic-freebsd/sys/dirent.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dirent.h 8.3 (Berkeley) 8/10/94 */ #ifndef _SYS_DIRENT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/disk.h b/lib/libc/include/generic-freebsd/sys/disk.h index 2a129d2d5b4e54a63835729666e15bfc5990e3b3..e6f1fd5d1d232f612a722cbeb26d4d7132070717 100644 --- a/lib/libc/include/generic-freebsd/sys/disk.h +++ b/lib/libc/include/generic-freebsd/sys/disk.h @@ -78,7 +78,7 @@ void disk_err(struct bio *bp, const char *what, int blkdone, int nl); * only if they point at exactly the same physical storage, this is * the case for multipathing for example, * - GEOM classes that consumes single providers and provide single - * providers, like geli, gbde, should just attach class name to the + * providers, like geli, should just attach class name to the * ident of the underlying provider, * - ident is an ASCII string (is printable), * - ident is optional and applications can't relay on its presence. diff --git a/lib/libc/include/generic-freebsd/sys/disk/bsd.h b/lib/libc/include/generic-freebsd/sys/disk/bsd.h index 13261bee65ae1e9d3606ba622fedb3aeb472e4dc..6bb186b35e88eb4db0238f5efb81c6f38517d13b 100644 --- a/lib/libc/include/generic-freebsd/sys/disk/bsd.h +++ b/lib/libc/include/generic-freebsd/sys/disk/bsd.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_DISK_BSD_H_ diff --git a/lib/libc/include/generic-freebsd/sys/disk/gpt.h b/lib/libc/include/generic-freebsd/sys/disk/gpt.h index a11256e08cf280c6fabbf5c416a0ab333f26637a..ae886b1a789e47539ccf03d9f98ecf2e369b04dd 100644 --- a/lib/libc/include/generic-freebsd/sys/disk/gpt.h +++ b/lib/libc/include/generic-freebsd/sys/disk/gpt.h @@ -259,6 +259,9 @@ CTASSERT(sizeof(struct gpt_ent) == 128); #define GPT_ENT_TYPE_HIFIVE_BBL \ {0x2e54b353,0x1271,0x4842,0x80,0x6f,{0xe4,0x36,0xd6,0xaf,0x69,0x85}} +#define GPT_ENT_TYPE_U_BOOT_ENV \ + {0x3de21764,0x95bd,0x54bd,0xa5,0xc3,{0x4a,0xbe,0x78,0x6f,0x38,0xa8}} + /* * Boot partition used by GRUB 2. */ diff --git a/lib/libc/include/generic-freebsd/sys/disk/mbr.h b/lib/libc/include/generic-freebsd/sys/disk/mbr.h index a2ba2262c9f4bf84f19cf5b84432fcafe457dbd7..735744eaba90b07159ecf44b2ae0b26d694ea7e1 100644 --- a/lib/libc/include/generic-freebsd/sys/disk/mbr.h +++ b/lib/libc/include/generic-freebsd/sys/disk/mbr.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_DISK_MBR_H_ diff --git a/lib/libc/include/generic-freebsd/sys/disklabel.h b/lib/libc/include/generic-freebsd/sys/disklabel.h index 0a0917975ca86a6667469ccef015d9142526ddd2..72a9c7334f0026ca4d15c949d0426c480b416ca2 100644 --- a/lib/libc/include/generic-freebsd/sys/disklabel.h +++ b/lib/libc/include/generic-freebsd/sys/disklabel.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_DISKLABEL_H_ diff --git a/lib/libc/include/generic-freebsd/sys/diskmbr.h b/lib/libc/include/generic-freebsd/sys/diskmbr.h index 770ee2ef3c94597556f3afa13d2105a8b4f14d1a..37e25bf83c8e47be5feec8d181c588b5e6f87df5 100644 --- a/lib/libc/include/generic-freebsd/sys/diskmbr.h +++ b/lib/libc/include/generic-freebsd/sys/diskmbr.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_DISKMBR_H_ diff --git a/lib/libc/include/generic-freebsd/sys/dkstat.h b/lib/libc/include/generic-freebsd/sys/dkstat.h index 502de1a66c126a6e7d00afb9e8adbb083f178259..2a494e5c517da675f095f89fc588d26a33350784 100644 --- a/lib/libc/include/generic-freebsd/sys/dkstat.h +++ b/lib/libc/include/generic-freebsd/sys/dkstat.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dkstat.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SYS_DKSTAT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/dnv.h b/lib/libc/include/generic-freebsd/sys/dnv.h index 07541306e103dd7faa38ecc6096d2c360c5a1e9f..4b40f9b8d4c87beec531b923e384ec7a25d31310 100644 --- a/lib/libc/include/generic-freebsd/sys/dnv.h +++ b/lib/libc/include/generic-freebsd/sys/dnv.h @@ -32,6 +32,7 @@ #define _DNV_H_ #include +#include #ifndef _KERNEL #include @@ -41,13 +42,6 @@ #include #endif -#ifndef _NVLIST_T_DECLARED -#define _NVLIST_T_DECLARED -struct nvlist; - -typedef struct nvlist nvlist_t; -#endif - __BEGIN_DECLS /* diff --git a/lib/libc/include/generic-freebsd/sys/domain.h b/lib/libc/include/generic-freebsd/sys/domain.h index e9e15b91c65f35375874b029176daee16ea100f6..e1ef0ba3ccbfa2bd58778ee17ab432b2760b25c8 100644 --- a/lib/libc/include/generic-freebsd/sys/domain.h +++ b/lib/libc/include/generic-freebsd/sys/domain.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)domain.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_DOMAIN_H_ @@ -54,10 +52,6 @@ struct domain { char *dom_name; int dom_flags; int (*dom_probe)(void); /* check for support (optional) */ - int (*dom_externalize) /* externalize access rights */ - (struct mbuf *, struct mbuf **, int); - void (*dom_dispose) /* dispose of internalized rights */ - (struct socket *); struct rib_head *(*dom_rtattach) /* initialize routing table */ (uint32_t); void (*dom_rtdetach) /* clean up routing table */ diff --git a/lib/libc/include/generic-freebsd/sys/domainset.h b/lib/libc/include/generic-freebsd/sys/domainset.h index 71ba4310e92d10c8528b2ac78e51943cbaaa735e..24675195c1906002783b6108a0ed990f0bdd5f80 100644 --- a/lib/libc/include/generic-freebsd/sys/domainset.h +++ b/lib/libc/include/generic-freebsd/sys/domainset.h @@ -113,6 +113,20 @@ void domainset_zero(void); * returned value will not match the key pointer. */ struct domainset *domainset_create(const struct domainset *); + +/* + * Remove empty domains from a given domainset. + * Returns 'false' if the domainset consists entirely of empty domains. + */ +bool domainset_empty_vm(struct domainset *domain); + +/* + * Validate and populate a domainset structure according to the specified + * policy and mask. + */ +int domainset_populate(struct domainset *domain, const domainset_t *mask, int policy, + size_t mask_size); + #ifdef _SYS_SYSCTL_H_ int sysctl_handle_domainset(SYSCTL_HANDLER_ARGS); #endif diff --git a/lib/libc/include/generic-freebsd/sys/efi.h b/lib/libc/include/generic-freebsd/sys/efi.h index 6f2f327f52732fda095042bae77d7f6f55d66c7c..33b6cb28f9945af404cb22c9b141a97c2de39536 100644 --- a/lib/libc/include/generic-freebsd/sys/efi.h +++ b/lib/libc/include/generic-freebsd/sys/efi.h @@ -35,15 +35,17 @@ #define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1) #define EFI_TABLE_SMBIOS \ - {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}} + {0xeb9d2d31,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}} #define EFI_TABLE_SMBIOS3 \ - {0xf2fd1544,0x9794,0x4a2c,0x99,0x2e,{0xe5,0xbb,0xcf,0x20,0xe3,0x94}} + {0xf2fd1544,0x9794,0x4a2c,{0x99,0x2e,0xe5,0xbb,0xcf,0x20,0xe3,0x94}} #define EFI_TABLE_ESRT \ - {0xb122a263,0x3661,0x4f68,0x99,0x29,{0x78,0xf8,0xb0,0xd6,0x21,0x80}} + {0xb122a263,0x3661,0x4f68,{0x99,0x29,0x78,0xf8,0xb0,0xd6,0x21,0x80}} #define EFI_PROPERTIES_TABLE \ - {0x880aaca3,0x4adc,0x4a04,0x90,0x79,{0xb7,0x47,0x34,0x08,0x25,0xe5}} + {0x880aaca3,0x4adc,0x4a04,{0x90,0x79,0xb7,0x47,0x34,0x08,0x25,0xe5}} +#define EFI_MEMORY_ATTRIBUTES_TABLE \ + {0xdcfa911d,0x26eb,0x469f,{0xa2,0x20,0x38,0xb7,0xdc,0x46,0x12,0x20}} #define LINUX_EFI_MEMRESERVE_TABLE \ - {0x888eb0c6,0x8ede,0x4ff5,0xa8,0xf0,{0x9a,0xee,0x5c,0xb9,0x77,0xc2}} + {0x888eb0c6,0x8ede,0x4ff5,{0xa8,0xf0,0x9a,0xee,0x5c,0xb9,0x77,0xc2}} enum efi_reset { EFI_RESET_COLD = 0, @@ -54,8 +56,20 @@ enum efi_reset { typedef uint16_t efi_char; typedef unsigned long efi_status; +/* + * This type-puns to a struct uuid, but all the EDK2 headers use this variation, + * and we use it in the loader to specify GUIDs. We define it here so that we + * can use EDK2 definitions both places. + */ +typedef struct efi_guid { + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} efi_guid_t; /* Type puns with GUID and EFI_GUID */ + struct efi_cfgtbl { - struct uuid ct_uuid; + efi_guid_t ct_guid; void *ct_data; }; @@ -139,7 +153,7 @@ struct efi_esrt_table { }; struct efi_esrt_entry_v1 { - struct uuid fw_class; + efi_guid_t fw_class; uint32_t fw_type; uint32_t fw_version; uint32_t lowest_supported_fw_version; @@ -154,6 +168,22 @@ struct efi_prop_table { uint64_t memory_protection_attribute; }; +struct efi_memory_descriptor { + uint32_t type; + caddr_t phy_addr; + caddr_t virt_addr; + uint64_t pages; + uint64_t attrs; +}; + +struct efi_memory_attribute_table { + uint32_t version; + uint32_t num_ents; + uint32_t descriptor_size; + uint32_t flags; + struct efi_memory_descriptor tables[]; +}; + #ifdef _KERNEL #ifdef EFIABI_ATTR @@ -169,11 +199,11 @@ struct efi_rt { efi_status (*rt_setvirtual)(u_long, u_long, uint32_t, struct efi_md *) EFIABI_ATTR; efi_status (*rt_cvtptr)(u_long, void **) EFIABI_ATTR; - efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *, + efi_status (*rt_getvar)(efi_char *, efi_guid_t *, uint32_t *, u_long *, void *) EFIABI_ATTR; - efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *) + efi_status (*rt_scanvar)(u_long *, efi_char *, efi_guid_t *) EFIABI_ATTR; - efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t, + efi_status (*rt_setvar)(efi_char *, efi_guid_t *, uint32_t, u_long, void *) EFIABI_ATTR; efi_status (*rt_gethicnt)(uint32_t *) EFIABI_ATTR; efi_status (*rt_reset)(enum efi_reset, efi_status, u_long, @@ -246,8 +276,8 @@ struct efi_ops { * access them. */ int (*rt_ok)(void); - int (*get_table)(struct uuid *, void **); - int (*copy_table)(struct uuid *, void **, size_t, size_t *); + int (*get_table)(efi_guid_t *, void **); + int (*copy_table)(efi_guid_t *, void **, size_t, size_t *); int (*get_time)(struct efi_tm *); int (*get_time_capabilities)(struct efi_tmcap *); int (*reset_system)(enum efi_reset); @@ -255,10 +285,10 @@ struct efi_ops { int (*get_waketime)(uint8_t *enabled, uint8_t *pending, struct efi_tm *tm); int (*set_waketime)(uint8_t enable, struct efi_tm *tm); - int (*var_get)(uint16_t *, struct uuid *, uint32_t *, size_t *, + int (*var_get)(uint16_t *, efi_guid_t *, uint32_t *, size_t *, void *); - int (*var_nextname)(size_t *, uint16_t *, struct uuid *); - int (*var_set)(uint16_t *, struct uuid *, uint32_t, size_t, void *); + int (*var_nextname)(size_t *, uint16_t *, efi_guid_t *); + int (*var_set)(uint16_t *, efi_guid_t *, uint32_t, size_t, void *); }; extern const struct efi_ops *active_efi_ops; @@ -271,21 +301,21 @@ static inline int efi_rt_ok(void) return (active_efi_ops->rt_ok()); } -static inline int efi_get_table(struct uuid *uuid, void **ptr) +static inline int efi_get_table(efi_guid_t *guid, void **ptr) { if (active_efi_ops->get_table == NULL) return (ENXIO); - return (active_efi_ops->get_table(uuid, ptr)); + return (active_efi_ops->get_table(guid, ptr)); } -static inline int efi_copy_table(struct uuid *uuid, void **buf, +static inline int efi_copy_table(efi_guid_t *guid, void **buf, size_t buf_len, size_t *table_len) { if (active_efi_ops->copy_table == NULL) return (ENXIO); - return (active_efi_ops->copy_table(uuid, buf, buf_len, table_len)); + return (active_efi_ops->copy_table(guid, buf, buf_len, table_len)); } static inline int efi_get_time(struct efi_tm *tm) @@ -335,7 +365,7 @@ static inline int efi_set_waketime(uint8_t enable, struct efi_tm *tm) return (active_efi_ops->set_waketime(enable, tm)); } -static inline int efi_var_get(uint16_t *name, struct uuid *vendor, +static inline int efi_var_get(uint16_t *name, efi_guid_t *vendor, uint32_t *attrib, size_t *datasize, void *data) { @@ -345,7 +375,7 @@ static inline int efi_var_get(uint16_t *name, struct uuid *vendor, } static inline int efi_var_nextname(size_t *namesize, uint16_t *name, - struct uuid *vendor) + efi_guid_t *vendor) { if (active_efi_ops->var_nextname == NULL) @@ -353,7 +383,7 @@ static inline int efi_var_nextname(size_t *namesize, uint16_t *name, return (active_efi_ops->var_nextname(namesize, name, vendor)); } -static inline int efi_var_set(uint16_t *name, struct uuid *vendor, +static inline int efi_var_set(uint16_t *name, efi_guid_t *vendor, uint32_t attrib, size_t datasize, void *data) { diff --git a/lib/libc/include/generic-freebsd/sys/efi_map.h b/lib/libc/include/generic-freebsd/sys/efi_map.h new file mode 100644 index 0000000000000000000000000000000000000000..aec3b697a1bbcebb5f18e06a4de271b57c8eac5a --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/efi_map.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2018 Andrew Turner + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef _SYS_EFI_MAP_H_ +#define _SYS_EFI_MAP_H_ + +#include +#include + +struct efi_map_header; + +typedef void (*efi_map_entry_cb)(struct efi_md *, void *argp); + +void efi_map_foreach_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb, + void *argp); + +void efi_map_add_entries(struct efi_map_header *efihdr); +void efi_map_exclude_entries(struct efi_map_header *efihdr); +void efi_map_print_entries(struct efi_map_header *efihdr); + +#endif /* !_SYS_EFI_MAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/efiio.h b/lib/libc/include/generic-freebsd/sys/efiio.h index 5790238c84df03f8df4e418febc6b79607f327bc..474827ee12a387a93002f431f09ab3b15736f048 100644 --- a/lib/libc/include/generic-freebsd/sys/efiio.h +++ b/lib/libc/include/generic-freebsd/sys/efiio.h @@ -30,38 +30,79 @@ #include #include -struct efi_get_table_ioc +/* + * The EFI world chose not to use the typical uuid_t defines for its global + * universal identifiers. But the textual representation is the same, and we can + * use the uuid_* routines to parse and print them. However, all EFI interfaces + * for this need to be efi_guid_t so we can share code with EDK2, so the *_ioc + * structures in this file are converted to _ioctl structure to transition to + * this new requirement. This library is little used outside of FreeBSD and they + * will be dropped in 16. + */ +_Static_assert(sizeof(struct uuid) == sizeof(efi_guid_t), + "uuid_t and efi_guid_t are same bytes, but different elements"); +#if __FreeBSD_version < 1600000 && !defined(_KERNEL) +#define _WANT_EFI_IOC +#endif + +struct efi_get_table_ioctl { void *buf; /* Pointer to userspace buffer */ - struct uuid uuid; /* UUID to look up */ + efi_guid_t guid; /* GUID to look up */ size_t table_len; /* Table size */ size_t buf_len; /* Size of the buffer */ }; -struct efi_var_ioc +struct efi_var_ioctl { efi_char *name; /* User pointer to name, in wide chars */ size_t namesize; /* Number of wide characters in name */ - struct uuid vendor; /* Vendor's UUID for variable */ + efi_guid_t vendor; /* Vendor's GUID for variable */ uint32_t attrib; /* Attributes */ void *data; /* User pointer to the data */ size_t datasize; /* Number of *bytes* in the data */ }; -struct efi_waketime_ioc +struct efi_waketime_ioctl { struct efi_tm waketime; uint8_t enabled; uint8_t pending; }; -#define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioc) +#define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioctl) #define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm) #define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm) -#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioc) -#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioc) -#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioc) -#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioc) -#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioc) +#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioctl) +#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioctl) +#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioctl) +#define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioctl) +#define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioctl) + +#ifdef _WANT_EFI_IOC +struct efi_get_table_ioc +{ + void *buf; /* Pointer to userspace buffer */ + struct uuid uuid; /* GUID to look up */ + size_t table_len; /* Table size */ + size_t buf_len; /* Size of the buffer */ +}; + +struct efi_var_ioc +{ + efi_char *name; /* User pointer to name, in wide chars */ + size_t namesize; /* Number of wide characters in name */ + struct uuid vendor; /* Vendor's GUID for variable */ + uint32_t attrib; /* Attributes */ + void *data; /* User pointer to the data */ + size_t datasize; /* Number of *bytes* in the data */ +}; + +_Static_assert(sizeof(struct efi_get_table_ioc) == sizeof(struct efi_get_table_ioctl), + "Old and new struct table defines must be the same size"); +_Static_assert(sizeof(struct efi_var_ioc) == sizeof(struct efi_var_ioctl), + "Old and new struct var defines must be the same size"); +#define efi_waketime_ioc efi_waketime_ioctl +#endif #endif /* _SYS_EFIIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/elf_common.h b/lib/libc/include/generic-freebsd/sys/elf_common.h index 272ecf80ff328ded6d471bc6292c25442c559e3d..0583ea2b80250aede0b775739457ab9320e0d5a0 100644 --- a/lib/libc/include/generic-freebsd/sys/elf_common.h +++ b/lib/libc/include/generic-freebsd/sys/elf_common.h @@ -306,6 +306,7 @@ typedef struct { and MPRC of Peking University */ #define EM_AARCH64 183 /* AArch64 (64-bit ARM) */ #define EM_RISCV 243 /* RISC-V */ +#define EM_LOONGARCH 258 /* Loongson LoongArch */ /* Non-standard or deprecated. */ #define EM_486 6 /* Intel i486. */ @@ -382,6 +383,25 @@ typedef struct { #define EF_RISCV_RVE 0x00000008 #define EF_RISCV_TSO 0x00000010 +/* + * Loongson LoongArch Specific e_flags + * + * Definitions from LoongArch ELF psABI v2.01. + * Reference: https://github.com/loongson/LoongArch-Documentation + * (commit hash 296de4def055c871809068e0816325a4ac04eb12) + */ + +/* LoongArch Base ABI Modifiers */ +#define EF_LOONGARCH_ABI_SOFT_FLOAT 0x00000001 +#define EF_LOONGARCH_ABI_SINGLE_FLOAT 0x00000002 +#define EF_LOONGARCH_ABI_DOUBLE_FLOAT 0x00000003 +#define EF_LOONGARCH_ABI_MODIFIER_MASK 0x00000007 + +/* LoongArch Object file ABI versions */ +#define EF_LOONGARCH_OBJABI_V0 0x00000000 +#define EF_LOONGARCH_OBJABI_V1 0x00000040 +#define EF_LOONGARCH_OBJABI_MASK 0x000000C0 + #define EF_SPARC_EXT_MASK 0x00ffff00 #define EF_SPARC_32PLUS 0x00000100 #define EF_SPARC_SUN_US1 0x00000200 @@ -450,12 +470,12 @@ typedef struct { #define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ #define SHT_LOPROC 0x70000000 /* reserved range for processor */ #define SHT_X86_64_UNWIND 0x70000001 /* unwind information */ -#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND +#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND #define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */ -#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking +#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking pre-emption map. */ -#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility +#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attributes. */ #define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */ #define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */ @@ -534,8 +554,8 @@ typedef struct { #define PT_GNU_EH_FRAME 0x6474e550 #define PT_GNU_STACK 0x6474e551 #define PT_GNU_RELRO 0x6474e552 -#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps - (currently arm). */ +#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for arm and amd64 kernel + dumps */ #define PT_LOSUNW 0x6ffffffa #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ #define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ @@ -770,7 +790,8 @@ typedef struct { #define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ #define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ #define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ -#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +#define DF_1_INITFIRST 0x00000020 /* Initialize DSO first at runtime */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ #define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ #define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */ #define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ @@ -804,6 +825,7 @@ typedef struct { #define NT_FREEBSD_FCTL_WXNEEDED 0x00000008 #define NT_FREEBSD_FCTL_LA48 0x00000010 /* was ASG_DISABLE, do not reuse 0x00000020 */ +#define NT_FREEBSD_FCTL_LA57 0x00000040 /* Values for n_type. Used in core files. */ #define NT_PRSTATUS 1 /* Process status. */ @@ -820,6 +842,7 @@ typedef struct { #define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ #define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ #define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */ +#define NT_PROCSTAT_KQUEUES 18 /* Procstat kqueues events. */ #define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ #define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ #define NT_X86_SEGBASES 0x200 /* x86 FS/GS base addresses. */ @@ -885,7 +908,7 @@ typedef struct { #define STV_ELIMINATE 0x6 /* Architecture specific data - st_other */ -#define STO_AARCH64_VARIANT_PCS 0x80 +#define STO_AARCH64_VARIANT_PCS 0x80 /* Special symbol table indexes. */ #define STN_UNDEF 0 /* Undefined symbol index. */ @@ -991,8 +1014,11 @@ typedef struct { #define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */ #define AT_USRSTACKBASE 35 /* Top of user stack */ #define AT_USRSTACKLIM 36 /* Grow limit of user stack */ +#define AT_CHERI_STATS 37 /* Reserved */ +#define AT_HWCAP3 38 /* CPU feature flags 3. */ +#define AT_HWCAP4 39 /* CPU feature flags 4. */ -#define AT_COUNT 37 /* Count of defined aux entry types. */ +#define AT_COUNT 40 /* Count of defined aux entry types. */ /* * Relocation types. @@ -1058,11 +1084,11 @@ typedef struct { #define R_AARCH64_COPY 1024 /* Copy data from shared object */ #define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */ #define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */ -#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */ +#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */ #define R_AARCH64_TLS_DTPREL64 1028 #define R_AARCH64_TLS_DTPMOD64 1029 -#define R_AARCH64_TLS_TPREL64 1030 -#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */ +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */ #define R_AARCH64_IRELATIVE 1032 #define R_ARM_NONE 0 /* No relocation. */ @@ -1205,8 +1231,8 @@ typedef struct { #define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */ #define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */ #define R_MIPS_SUB 24 -#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ -#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ +#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ +#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ #define R_MIPS_JALR 37 #define R_MIPS_TLS_GD 42 #define R_MIPS_COPY 126 @@ -1326,7 +1352,6 @@ typedef struct { * RISC-V relocation types. */ -/* Relocation types used by the dynamic linker. */ #define R_RISCV_NONE 0 #define R_RISCV_32 1 #define R_RISCV_64 2 @@ -1339,8 +1364,7 @@ typedef struct { #define R_RISCV_TLS_DTPREL64 9 #define R_RISCV_TLS_TPREL32 10 #define R_RISCV_TLS_TPREL64 11 - -/* Relocation types not used by the dynamic linker. */ +#define R_RISCV_TLSDESC 12 #define R_RISCV_BRANCH 16 #define R_RISCV_JAL 17 #define R_RISCV_CALL 18 @@ -1366,10 +1390,10 @@ typedef struct { #define R_RISCV_SUB16 38 #define R_RISCV_SUB32 39 #define R_RISCV_SUB64 40 +#define R_RISCV_GOT32_PCREL 41 #define R_RISCV_ALIGN 43 #define R_RISCV_RVC_BRANCH 44 #define R_RISCV_RVC_JUMP 45 -#define R_RISCV_RVC_LUI 46 #define R_RISCV_RELAX 51 #define R_RISCV_SUB6 52 #define R_RISCV_SET6 53 @@ -1378,6 +1402,170 @@ typedef struct { #define R_RISCV_SET32 56 #define R_RISCV_32_PCREL 57 #define R_RISCV_IRELATIVE 58 +#define R_RISCV_PLT32 59 +#define R_RISCV_SET_ULEB128 60 +#define R_RISCV_SUB_ULEB128 61 +#define R_RISCV_TLSDESC_HI20 62 +#define R_RISCV_TLSDESC_LOAD_LO12 63 +#define R_RISCV_TLSDESC_ADD_LO12 64 +#define R_RISCV_TLSDESC_CALL 65 +#define R_RISCV_VENDOR 191 + +/* + * Loongson LoongArch relocation types. + * + * LoongArch ELF psABI: https://github.com/loongson/LoongArch-Documentation + * (commit hash 9b3bd9f4a497115913c22f1a2a47863798fbc02a) + */ + +/* Relocation types used by the dynamic linker */ +#define R_LARCH_NONE 0 +#define R_LARCH_32 1 +#define R_LARCH_64 2 +#define R_LARCH_RELATIVE 3 +#define R_LARCH_COPY 4 +#define R_LARCH_JUMP_SLOT 5 +#define R_LARCH_TLS_DTPMOD32 6 +#define R_LARCH_TLS_DTPMOD64 7 +#define R_LARCH_TLS_DTPREL32 8 +#define R_LARCH_TLS_DTPREL64 9 +#define R_LARCH_TLS_TPREL32 10 +#define R_LARCH_TLS_TPREL64 11 +#define R_LARCH_IRELATIVE 12 +#define R_LARCH_MARK_LA 20 +#define R_LARCH_MARK_PCREL 21 +#define R_LARCH_SOP_PUSH_PCREL 22 +#define R_LARCH_SOP_PUSH_ABSOLUTE 23 +#define R_LARCH_SOP_PUSH_DUP 24 +#define R_LARCH_SOP_PUSH_GPREL 25 +#define R_LARCH_SOP_PUSH_TLS_TPREL 26 +#define R_LARCH_SOP_PUSH_TLS_GOT 27 +#define R_LARCH_SOP_PUSH_TLS_GD 28 +#define R_LARCH_SOP_PUSH_PLT_PCREL 29 +#define R_LARCH_SOP_ASSERT 30 +#define R_LARCH_SOP_NOT 31 +#define R_LARCH_SOP_SUB 32 +#define R_LARCH_SOP_SL 33 +#define R_LARCH_SOP_SR 34 +#define R_LARCH_SOP_ADD 35 +#define R_LARCH_SOP_AND 36 +#define R_LARCH_SOP_IF_ELSE 37 +#define R_LARCH_SOP_POP_32_S_10_5 38 +#define R_LARCH_SOP_POP_32_U_10_12 39 +#define R_LARCH_SOP_POP_32_S_10_12 40 +#define R_LARCH_SOP_POP_32_S_10_16 41 +#define R_LARCH_SOP_POP_32_S_10_16_S2 42 +#define R_LARCH_SOP_POP_32_S_5_20 43 +#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2 44 +#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2 45 +#define R_LARCH_SOP_POP_32_U 46 +#define R_LARCH_ADD8 47 +#define R_LARCH_ADD16 48 +#define R_LARCH_ADD24 49 +#define R_LARCH_ADD32 50 +#define R_LARCH_ADD64 51 +#define R_LARCH_SUB8 52 +#define R_LARCH_SUB16 53 +#define R_LARCH_SUB24 54 +#define R_LARCH_SUB32 55 +#define R_LARCH_SUB64 56 +#define R_LARCH_GNU_VTINHERIT 57 +#define R_LARCH_GNU_VTENTRY 58 + +/* + * Relocs whose processing do not require a stack machine. + * + * Spec addition: https://github.com/loongson/LoongArch-Documentation/pull/57 + */ +#define R_LARCH_B16 64 +#define R_LARCH_B21 65 +#define R_LARCH_B26 66 +#define R_LARCH_ABS_HI20 67 +#define R_LARCH_ABS_LO12 68 +#define R_LARCH_ABS64_LO20 69 +#define R_LARCH_ABS64_HI12 70 +#define R_LARCH_PCALA_HI20 71 +#define R_LARCH_PCALA_LO12 72 +#define R_LARCH_PCALA64_LO20 73 +#define R_LARCH_PCALA64_HI12 74 +#define R_LARCH_GOT_PC_HI20 75 +#define R_LARCH_GOT_PC_LO12 76 +#define R_LARCH_GOT64_PC_LO20 77 +#define R_LARCH_GOT64_PC_HI12 78 +#define R_LARCH_GOT_HI20 79 +#define R_LARCH_GOT_LO12 80 +#define R_LARCH_GOT64_LO20 81 +#define R_LARCH_GOT64_HI12 82 +#define R_LARCH_TLS_LE_HI20 83 +#define R_LARCH_TLS_LE_LO12 84 +#define R_LARCH_TLS_LE64_LO20 85 +#define R_LARCH_TLS_LE64_HI12 86 +#define R_LARCH_TLS_IE_PC_HI20 87 +#define R_LARCH_TLS_IE_PC_LO12 88 +#define R_LARCH_TLS_IE64_PC_LO20 89 +#define R_LARCH_TLS_IE64_PC_HI12 90 +#define R_LARCH_TLS_IE_HI20 91 +#define R_LARCH_TLS_IE_LO12 92 +#define R_LARCH_TLS_IE64_LO20 93 +#define R_LARCH_TLS_IE64_HI12 94 +#define R_LARCH_TLS_LD_PC_HI20 95 +#define R_LARCH_TLS_LD_HI20 96 +#define R_LARCH_TLS_GD_PC_HI20 97 +#define R_LARCH_TLS_GD_HI20 98 +#define R_LARCH_32_PCREL 99 +#define R_LARCH_RELAX 100 + +/* + * Relocs added in ELF for the LoongArch™ Architecture v20230519, part of the + * v2.10 LoongArch ABI specs. + * + * Spec addition: https://github.com/loongson/la-abi-specs/pull/1 + * + * Note that the 101 and 104 relocation numbers are defined as R_LARCH_DELETE + * and R_LARCH_CFA respectively in psABI 2.10. But they are marked as reserved + * in psABI v2.20 because they were proved not necessary to be exposed outside + * of the linker. + */ +#define R_LARCH_ALIGN 102 +#define R_LARCH_PCREL20_S2 103 +#define R_LARCH_ADD6 105 +#define R_LARCH_SUB6 106 +#define R_LARCH_ADD_ULEB128 107 +#define R_LARCH_SUB_ULEB128 108 +#define R_LARCH_64_PCREL 109 + +/* + * Relocs added in ELF for the LoongArch™ Architecture v20231102, part of the + * v2.20 LoongArch ABI specs. + * + * Spec addition: https://github.com/loongson/la-abi-specs/pull/4 + */ +#define R_LARCH_CALL36 110 + +/* + * Relocs added in ELF for the LoongArch™ Architecture v20231219, part of the + * v2.30 LoongArch ABI specs. + * + * Spec addition: https://github.com/loongson/la-abi-specs/pull/5 + */ +#define R_LARCH_TLS_DESC32 13 +#define R_LARCH_TLS_DESC64 14 +#define R_LARCH_TLS_DESC_PC_HI20 111 +#define R_LARCH_TLS_DESC_PC_LO12 112 +#define R_LARCH_TLS_DESC64_PC_LO20 113 +#define R_LARCH_TLS_DESC64_PC_HI12 114 +#define R_LARCH_TLS_DESC_HI20 115 +#define R_LARCH_TLS_DESC_LO12 116 +#define R_LARCH_TLS_DESC64_LO20 117 +#define R_LARCH_TLS_DESC64_HI12 118 +#define R_LARCH_TLS_DESC_LD 119 +#define R_LARCH_TLS_DESC_CALL 120 +#define R_LARCH_TLS_LE_HI20_R 121 +#define R_LARCH_TLS_LE_ADD_R 122 +#define R_LARCH_TLS_LE_LO12_R 123 +#define R_LARCH_TLS_LD_PCREL20_S2 124 +#define R_LARCH_TLS_GD_PCREL20_S2 125 +#define R_LARCH_TLS_DESC_PCREL20_S2 126 #define R_SPARC_NONE 0 #define R_SPARC_8 1 diff --git a/lib/libc/include/generic-freebsd/sys/endian.h b/lib/libc/include/generic-freebsd/sys/endian.h index ab0dd7038c0eeb8a9dedaf58e312418989e97b6a..b5050abe39865aa6f2b87b7411886d735d1b1ffc 100644 --- a/lib/libc/include/generic-freebsd/sys/endian.h +++ b/lib/libc/include/generic-freebsd/sys/endian.h @@ -56,7 +56,9 @@ typedef __uint64_t uint64_t; /* * Note: While tempting to try to avoid namespace pollution from this file, * several software packages assume these marcos are defined, even when it - * defines _POSIX_C_SOURCE to request an unpolluted namespace. + * defines _POSIX_C_SOURCE to request an unpolluted namespace. + * is not defined by any version of POSIX.1, so we don't have to be + * careful. No POSIX.1 defined header file includes on FreeBSD. */ /* diff --git a/lib/libc/include/generic-freebsd/sys/errno.h b/lib/libc/include/generic-freebsd/sys/errno.h index cdeb8fbcadc4bd52a0a94df763f9abdff88e51a7..6238ec73d92dec43090a299febee944658eea60d 100644 --- a/lib/libc/include/generic-freebsd/sys/errno.h +++ b/lib/libc/include/generic-freebsd/sys/errno.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)errno.h 8.5 (Berkeley) 1/21/94 */ #ifndef _SYS_ERRNO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/event.h b/lib/libc/include/generic-freebsd/sys/event.h index a206671c083d76cc2b500f320c6d253270364030..139f934c0028bf1c7b916d65bc245fa33b463bbe 100644 --- a/lib/libc/include/generic-freebsd/sys/event.h +++ b/lib/libc/include/generic-freebsd/sys/event.h @@ -45,7 +45,9 @@ #define EVFILT_USER (-11) /* User events */ #define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ #define EVFILT_EMPTY (-13) /* empty send socket buf */ -#define EVFILT_SYSCOUNT 13 +#define EVFILT_JAIL (-14) /* attached to struct prison */ +#define EVFILT_JAILDESC (-15) /* attached to jail descriptors */ +#define EVFILT_SYSCOUNT 15 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define EV_SET(kevp_, a, b, c, d, e, f) do { \ @@ -101,7 +103,7 @@ struct freebsd11_kevent { }; #endif -#if defined(_WANT_KEVENT32) || (defined(_KERNEL) && defined(__LP64__)) +#if defined(_WANT_KEVENT32) || defined(_KERNEL) struct kevent32 { __uint32_t ident; /* identifier for this event */ short filter; /* filter for event */ @@ -205,10 +207,18 @@ struct freebsd11_kevent32 { #define NOTE_PDATAMASK 0x000fffff /* mask for pid */ /* additional flags for EVFILT_PROC */ -#define NOTE_TRACK 0x00000001 /* follow across forks */ +#define NOTE_TRACK 0x00000001 /* follow across fork/create */ #define NOTE_TRACKERR 0x00000002 /* could not track child */ #define NOTE_CHILD 0x00000004 /* am a child process */ +/* data/hint flags for EVFILT_JAIL and EVFILT_JAILDESC */ +#define NOTE_JAIL_CHILD 0x80000000 /* child jail was created */ +#define NOTE_JAIL_SET 0x40000000 /* jail was modified */ +#define NOTE_JAIL_ATTACH 0x20000000 /* jail was attached to */ +#define NOTE_JAIL_REMOVE 0x10000000 /* jail was removed */ +#define NOTE_JAIL_MULTI 0x08000000 /* multiple child or attach */ +#define NOTE_JAIL_CTRLMASK 0xf0000000 /* mask for hint bits */ + /* additional flags for EVFILT_TIMER */ #define NOTE_SECONDS 0x00000001 /* data is seconds */ #define NOTE_MSECONDS 0x00000002 /* data is milliseconds */ @@ -262,12 +272,17 @@ struct knlist { #define EVENT_REGISTER 1 #define EVENT_PROCESS 2 +struct kinfo_knote; +struct proc; + struct filterops { int f_isfd; /* true if ident == filedescriptor */ int (*f_attach)(struct knote *kn); void (*f_detach)(struct knote *kn); int (*f_event)(struct knote *kn, long hint); void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type); + int (*f_userdump)(struct proc *p, struct knote *kn, + struct kinfo_knote *kin); }; /* @@ -304,6 +319,7 @@ struct knote { struct proc *p_proc; /* proc pointer */ struct kaiocb *p_aio; /* AIO job pointer */ struct aioliojob *p_lio; /* LIO job pointer */ + struct prison *p_prison; /* prison pointer */ void *p_v; /* generic other pointer */ } kn_ptr; const struct filterops *kn_fop; diff --git a/lib/libc/include/generic-freebsd/sys/eventhandler.h b/lib/libc/include/generic-freebsd/sys/eventhandler.h index 476524d8d116415807e4f71f82df8e17fd591306..1523bbe78db59f890600c6650757fe47ae83bc63 100644 --- a/lib/libc/include/generic-freebsd/sys/eventhandler.h +++ b/lib/libc/include/generic-freebsd/sys/eventhandler.h @@ -326,4 +326,9 @@ struct ifaddr; typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int); EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn); +/* Kernel environment variable change event */ +typedef void (*env_change_fn)(void *, const char *); +EVENTHANDLER_DECLARE(setenv, env_change_fn); +EVENTHANDLER_DECLARE(unsetenv, env_change_fn); + #endif /* _SYS_EVENTHANDLER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/exec.h b/lib/libc/include/generic-freebsd/sys/exec.h index e85907d5bef071b87d9da4b633bf8e9d7985b57e..38ec61df1965c53ec63f3525e7d8f73a6ccfd78b 100644 --- a/lib/libc/include/generic-freebsd/sys/exec.h +++ b/lib/libc/include/generic-freebsd/sys/exec.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)exec.h 8.3 (Berkeley) 1/21/94 */ #ifndef _SYS_EXEC_H_ @@ -59,16 +57,6 @@ struct ps_strings { unsigned int ps_nenvstr; /* the number of environment strings */ }; -/* Coredump output parameters. */ -struct coredump_params { - off_t offset; - struct ucred *active_cred; - struct ucred *file_cred; - struct thread *td; - struct vnode *vp; - struct compressor *comp; -}; - struct image_params; struct execsw { @@ -107,16 +95,6 @@ int exec_unregister(const struct execsw *); enum uio_seg; -#define CORE_BUF_SIZE (16 * 1024) - -int core_write(struct coredump_params *, const void *, size_t, off_t, - enum uio_seg, size_t *); -int core_output(char *, size_t, off_t, struct coredump_params *, void *); -int sbuf_drain_core_output(void *, const char *, int); - -extern int coredump_pack_fileinfo; -extern int coredump_pack_vmmapinfo; - /* * note: name##_mod cannot be const storage because the * linker_file_sysinit() function modifies _file in the diff --git a/lib/libc/include/generic-freebsd/sys/exterr_cat.h b/lib/libc/include/generic-freebsd/sys/exterr_cat.h new file mode 100644 index 0000000000000000000000000000000000000000..ddc427370bb4af29e47bcb6fb19af72a242f4456 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/exterr_cat.h @@ -0,0 +1,25 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * All rights reserved. + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#ifndef _SYS_EXTERR_CAT_H_ +#define _SYS_EXTERR_CAT_H_ + +#define EXTERR_CAT_MMAP 1 +#define EXTERR_CAT_FILEDESC 2 +#define EXTERR_KTRACE 3 /* To allow inclusion of this + file into kern_ktrace.c */ +#define EXTERR_CAT_FUSE 4 +#define EXTERR_CAT_INOTIFY 5 +#define EXTERR_CAT_GENIO 6 +#define EXTERR_CAT_BRIDGE 7 +#define EXTERR_CAT_SWAP 8 +#define EXTERR_CAT_VFSSYSCALL 9 + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/exterrvar.h b/lib/libc/include/generic-freebsd/sys/exterrvar.h new file mode 100644 index 0000000000000000000000000000000000000000..fd76510792fcea92321fed0df2735c623ad379ff --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/exterrvar.h @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * All rights reserved. + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#ifndef _SYS_EXTERRVAR_H_ +#define _SYS_EXTERRVAR_H_ + +#include +#include +#include + +#define UEXTERROR_MAXLEN 256 + +#define UEXTERROR_VER 0x10010002 + +#define EXTERRCTL_ENABLE 1 +#define EXTERRCTL_DISABLE 2 +#define EXTERRCTL_UD 3 + +#define EXTERRCTLF_FORCE 0x00000001 + +#ifdef _KERNEL + +#ifndef EXTERR_CATEGORY +#error "Specify error category before including sys/exterrvar.h" +#endif + +#ifdef EXTERR_STRINGS +#define SET_ERROR_MSG(mmsg) (mmsg) +#else +#define SET_ERROR_MSG(mmsg) NULL +#endif + +#define _SET_ERROR2(eerror, mmsg, pp1, pp2) \ + exterr_set(eerror, EXTERR_CATEGORY, SET_ERROR_MSG(mmsg), \ + (uintptr_t)(pp1), (uintptr_t)(pp2), __LINE__) +#define _SET_ERROR0(eerror, mmsg) _SET_ERROR2(eerror, mmsg, 0, 0) +#define _SET_ERROR1(eerror, mmsg, pp1) _SET_ERROR2(eerror, mmsg, pp1, 0) + +#define _EXTERROR_MACRO(eerror, mmsg, _1, _2, NAME, ...) \ + NAME +#define EXTERROR(...) \ + _EXTERROR_MACRO(__VA_ARGS__, _SET_ERROR2, _SET_ERROR1, \ + _SET_ERROR0)(__VA_ARGS__) + +int exterr_set(int eerror, int category, const char *mmsg, uintptr_t pp1, + uintptr_t pp2, int line); +int exterr_to_ue(struct thread *td, struct uexterror *ue); +void ktrexterr(struct thread *td); + +#else /* _KERNEL */ + +#include + +__BEGIN_DECLS +int exterrctl(u_int op, u_int flags, void *ptr); +__END_DECLS + +#endif /* _KERNEL */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/fbio.h b/lib/libc/include/generic-freebsd/sys/fbio.h index d3fb0c39f2b37a6b6663203b989a7e7b51c066aa..30672d2360727e75183d57e9b4f14b8e4f278dbd 100644 --- a/lib/libc/include/generic-freebsd/sys/fbio.h +++ b/lib/libc/include/generic-freebsd/sys/fbio.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fbio.h 8.2 (Berkeley) 10/30/93 */ #ifndef _SYS_FBIO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/fcntl.h b/lib/libc/include/generic-freebsd/sys/fcntl.h index d0d93108b5e9d7794f314221deac746d5b85f774..0120afe643a11b791a17396bf157888545fb32df 100644 --- a/lib/libc/include/generic-freebsd/sys/fcntl.h +++ b/lib/libc/include/generic-freebsd/sys/fcntl.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 */ #ifndef _SYS_FCNTL_H_ @@ -142,8 +140,24 @@ typedef __pid_t pid_t; #define O_DSYNC 0x01000000 /* POSIX data sync */ #if __BSD_VISIBLE #define O_EMPTY_PATH 0x02000000 +#define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */ +#define O_XATTR O_NAMEDATTR /* Solaris compatibility */ #endif +#if __POSIX_VISIBLE >= 202405 +#define O_CLOFORK 0x08000000 +#endif + +/* + * !!! DANGER !!! + * + * There are very few bits left for O_* flags. Every bit we consume for + * local features is one bit we can't use for future source compatibility + * with other operating systems. + * + * All additions should be coordinated with srcmgr@. + */ + /* * XXX missing O_RSYNC. */ @@ -270,6 +284,16 @@ typedef __pid_t pid_t; #define F_GET_SEALS 20 #define F_ISUNIONSTACK 21 /* Kludge for libc, don't use it. */ #define F_KINFO 22 /* Return kinfo_file for this fd */ +#endif /* __BSD_VISIBLE */ + +#if __POSIX_VISIBLE >= 202405 +#define F_DUPFD_CLOFORK 23 /* Like F_DUPFD, but FD_CLOFORK is set */ +#endif + +#if __BSD_VISIBLE +#define F_DUP3FD 24 /* Used with dup3() */ + +#define F_DUP3FD_SHIFT 16 /* Shift used for F_DUP3FD */ /* Seals (F_ADD_SEALS, F_GET_SEALS). */ #define F_SEAL_SEAL 0x0001 /* Prevent adding sealings */ @@ -280,6 +304,11 @@ typedef __pid_t pid_t; /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ +#define FD_RESOLVE_BENEATH 2 /* all lookups relative to fd have + O_RESOLVE_BENEATH semantics */ +#if __POSIX_VISIBLE >= 202405 +#define FD_CLOFORK 4 /* close-on-fork flag */ +#endif /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ #define F_RDLCK 1 /* shared or read lock */ diff --git a/lib/libc/include/generic-freebsd/sys/file.h b/lib/libc/include/generic-freebsd/sys/file.h index 1a84d5b062ea2623f65994d5e9811811a4c8576c..138c4cd33dcec510a3bb03f05f0b3c0a1655502a 100644 --- a/lib/libc/include/generic-freebsd/sys/file.h +++ b/lib/libc/include/generic-freebsd/sys/file.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)file.h 8.3 (Berkeley) 1/9/95 */ #ifndef _SYS_FILE_H_ @@ -39,13 +37,16 @@ #include #include #else -#include -#include +#include #include #include +#include +#include +#include #include struct filedesc; +struct proc; struct stat; struct thread; struct uio; @@ -70,6 +71,8 @@ struct nameidata; #define DTYPE_PROCDESC 12 /* process descriptor */ #define DTYPE_EVENTFD 13 /* eventfd */ #define DTYPE_TIMERFD 14 /* timerfd */ +#define DTYPE_INOTIFY 15 /* inotify descriptor */ +#define DTYPE_JAILDESC 16 /* jail descriptor */ #ifdef _KERNEL @@ -85,6 +88,8 @@ struct ucred; #define FOF_NEXTOFF_W 0x08 /* Also update f_nextoff[UIO_WRITE] */ #define FOF_NOUPDATE 0x10 /* Do not update f_offset */ off_t foffset_lock(struct file *fp, int flags); +void foffset_lock_pair(struct file *fp1, off_t *off1p, struct file *fp2, + off_t *off2p, int flags); void foffset_lock_uio(struct file *fp, struct uio *uio, int flags); void foffset_unlock(struct file *fp, off_t val, int flags); void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags); @@ -156,7 +161,7 @@ struct fileops { fo_fallocate_t *fo_fallocate; fo_fspacectl_t *fo_fspacectl; fo_cmp_t *fo_cmp; - fo_spare_t *fo_spares[7]; /* Spare slots */ + fo_spare_t *fo_spares[8]; /* Spare slots */ fo_flags_t fo_flags; /* DFLAG_* below */ }; @@ -188,11 +193,11 @@ struct file { volatile u_int f_flag; /* see fcntl.h */ volatile u_int f_count; /* reference count */ void *f_data; /* file descriptor specific data */ - struct fileops *f_ops; /* File operations */ + const struct fileops *f_ops; /* File operations */ struct vnode *f_vnode; /* NULL or applicable vnode */ struct ucred *f_cred; /* associated credentials. */ short f_type; /* descriptor type */ - short f_vnread_flags; /* (f) Sleep lock for f_offset */ + short f_vflags; /* (f) Sleep lock flags for members */ /* * DTYPE_VNODE specific fields. */ @@ -215,8 +220,8 @@ struct file { #define f_cdevpriv f_vnun.fvn_cdevpriv #define f_advice f_vnun.fvn_advice -#define FOFFSET_LOCKED 0x1 -#define FOFFSET_LOCK_WAITING 0x2 +#define FILE_V_FOFFSET_LOCKED 0x0001 +#define FILE_V_FOFFSET_LOCK_WAITING 0x0002 #endif /* __BSD_VISIBLE */ #endif /* _KERNEL || _WANT_FILE */ @@ -248,24 +253,27 @@ struct xfile { #ifdef _KERNEL -extern struct fileops vnops; -extern struct fileops badfileops; -extern struct fileops path_fileops; -extern struct fileops socketops; +extern const struct fileops vnops; +extern const struct fileops badfileops; +extern const struct fileops path_fileops; +extern const struct fileops socketops; extern int maxfiles; /* kernel limit on number of open files */ extern int maxfilesperproc; /* per process limit on number of open files */ -int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp); -int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, +int fget(struct thread *td, int fd, const cap_rights_t *rightsp, + struct file **fpp); +int fget_mmap(struct thread *td, int fd, const cap_rights_t *rightsp, vm_prot_t *maxprotp, struct file **fpp); -int fget_read(struct thread *td, int fd, cap_rights_t *rightsp, +int fget_read(struct thread *td, int fd, const cap_rights_t *rightsp, struct file **fpp); -int fget_write(struct thread *td, int fd, cap_rights_t *rightsp, +int fget_write(struct thread *td, int fd, const cap_rights_t *rightsp, struct file **fpp); -int fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp, +int fget_fcntl(struct thread *td, int fd, const cap_rights_t *rightsp, int needfcntl, struct file **fpp); int _fdrop(struct file *fp, struct thread *td); int fget_remote(struct thread *td, struct proc *p, int fd, struct file **fpp); +int fget_remote_foreach(struct thread *td, struct proc *p, + int (*fn)(struct proc *, int, struct file *, void *), void *arg); fo_rdwr_t invfo_rdwr; fo_truncate_t invfo_truncate; @@ -283,19 +291,19 @@ fo_kqfilter_t vn_kqfilter_opath; int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif); int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td); -void finit(struct file *, u_int, short, void *, struct fileops *); -void finit_vnode(struct file *, u_int, void *, struct fileops *); -int fgetvp(struct thread *td, int fd, cap_rights_t *rightsp, +void finit(struct file *, u_int, short, void *, const struct fileops *); +void finit_vnode(struct file *, u_int, void *, const struct fileops *); +int fgetvp(struct thread *td, int fd, const cap_rights_t *rightsp, struct vnode **vpp); -int fgetvp_exec(struct thread *td, int fd, cap_rights_t *rightsp, +int fgetvp_exec(struct thread *td, int fd, const cap_rights_t *rightsp, struct vnode **vpp); -int fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp, +int fgetvp_rights(struct thread *td, int fd, const cap_rights_t *needrightsp, struct filecaps *havecaps, struct vnode **vpp); -int fgetvp_read(struct thread *td, int fd, cap_rights_t *rightsp, +int fgetvp_read(struct thread *td, int fd, const cap_rights_t *rightsp, struct vnode **vpp); -int fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp, +int fgetvp_write(struct thread *td, int fd, const cap_rights_t *rightsp, struct vnode **vpp); -int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch); +int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, int *flagsp); int fgetvp_lookup(struct nameidata *ndp, struct vnode **vpp); static __inline __result_use_check bool diff --git a/lib/libc/include/generic-freebsd/sys/filedesc.h b/lib/libc/include/generic-freebsd/sys/filedesc.h index 865cba6ad4185d461bbb9438f9365ced739507c1..6e9f4faf98d52fd5fbe97438a3cad73dcf504e4d 100644 --- a/lib/libc/include/generic-freebsd/sys/filedesc.h +++ b/lib/libc/include/generic-freebsd/sys/filedesc.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_FILEDESC_H_ @@ -150,6 +148,8 @@ struct filedesc_to_leader { * Per-process open flags. */ #define UF_EXCLOSE 0x01 /* auto-close on exec */ +#define UF_RESOLVE_BENEATH 0x02 /* lookups must be beneath this dir */ +#define UF_FOCLOSE 0x04 /* auto-close on fork */ #ifdef _KERNEL @@ -222,6 +222,7 @@ enum { /* Flags for kern_dup(). */ #define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */ +#define FDDUP_FLAG_CLOFORK 0x2 /* Atomically set UF_FOCLOSE. */ /* For backward compatibility. */ #define falloc(td, resultfp, resultfd, flags) \ @@ -277,22 +278,26 @@ struct filedesc_to_leader * struct filedesc_to_leader * filedesc_to_leader_share(struct filedesc_to_leader *fdtol, struct filedesc *fdp); -int getvnode(struct thread *td, int fd, cap_rights_t *rightsp, - struct file **fpp); -int getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp, +int getvnode(struct thread *td, int fd, const cap_rights_t *rightsp, struct file **fpp); +int getvnode_path(struct thread *td, int fd, const cap_rights_t *rightsp, + uint8_t *flagsp, struct file **fpp); void mountcheckdirs(struct vnode *olddp, struct vnode *newdp); -int fget_cap_noref(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, - struct file **fpp, struct filecaps *havecapsp); -int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, - struct file **fpp, struct filecaps *havecapsp); +int fget_cap_noref(struct filedesc *fdp, int fd, + const cap_rights_t *needrightsp, struct file **fpp, + struct filecaps *havecapsp); +int fget_cap(struct thread *td, int fd, const cap_rights_t *needrightsp, + uint8_t *flagsp, struct file **fpp, struct filecaps *havecapsp); /* Return a referenced file from an unlocked descriptor. */ -int fget_unlocked(struct thread *td, int fd, cap_rights_t *needrightsp, +int fget_unlocked(struct thread *td, int fd, + const cap_rights_t *needrightsp, struct file **fpp); +int fget_unlocked_flags(struct thread *td, int fd, + const cap_rights_t *needrightsp, uint8_t *flagsp, struct file **fpp); /* Return a file pointer without a ref. FILEDESC_IS_ONLY_USER must be true. */ -int fget_only_user(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, - struct file **fpp); +int fget_only_user(struct filedesc *fdp, int fd, + const cap_rights_t *needrightsp, struct file **fpp); #define fput_only_user(fdp, fp) ({ \ MPASS(FILEDESC_IS_ONLY_USER(fdp)); \ MPASS(refcount_load(&fp->f_count) > 0); \ diff --git a/lib/libc/include/generic-freebsd/sys/filio.h b/lib/libc/include/generic-freebsd/sys/filio.h index 1f4024a0cfa15940f44cb57d10a495c07ccd5e16..f65959c1c9618444ddf7e0a6b422eb96031b632d 100644 --- a/lib/libc/include/generic-freebsd/sys/filio.h +++ b/lib/libc/include/generic-freebsd/sys/filio.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)filio.h 8.1 (Berkeley) 3/28/94 */ #ifndef _SYS_FILIO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/gmon.h b/lib/libc/include/generic-freebsd/sys/gmon.h index 31d45b4d735fc7120ce4cfe70b766f46308d84ba..86f39b683213bd0f073b23c8e9683e5373757c0f 100644 --- a/lib/libc/include/generic-freebsd/sys/gmon.h +++ b/lib/libc/include/generic-freebsd/sys/gmon.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)gmon.h 8.2 (Berkeley) 1/4/94 */ #ifndef _SYS_GMON_H_ diff --git a/lib/libc/include/generic-freebsd/sys/hwt.h b/lib/libc/include/generic-freebsd/sys/hwt.h new file mode 100644 index 0000000000000000000000000000000000000000..1e711aa308dc4fe658a73b93e0420661a01c7da7 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/hwt.h @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2023-2025 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* User-visible header. */ + +#include +#include +#include +#include + +#ifndef _SYS_HWT_H_ +#define _SYS_HWT_H_ + +#define HWT_MAGIC 0x42 +#define HWT_IOC_ALLOC _IOW(HWT_MAGIC, 0x00, struct hwt_alloc) +#define HWT_IOC_START _IOW(HWT_MAGIC, 0x01, struct hwt_start) +#define HWT_IOC_STOP _IOW(HWT_MAGIC, 0x02, struct hwt_stop) +#define HWT_IOC_RECORD_GET _IOW(HWT_MAGIC, 0x03, struct hwt_record_get) +#define HWT_IOC_BUFPTR_GET _IOW(HWT_MAGIC, 0x04, struct hwt_bufptr_get) +#define HWT_IOC_SET_CONFIG _IOW(HWT_MAGIC, 0x05, struct hwt_set_config) +#define HWT_IOC_WAKEUP _IOW(HWT_MAGIC, 0x06, struct hwt_wakeup) +#define HWT_IOC_SVC_BUF _IOW(HWT_MAGIC, 0x07, struct hwt_svc_buf) + +#define HWT_BACKEND_MAXNAMELEN 256 + +#define HWT_MODE_THREAD 1 +#define HWT_MODE_CPU 2 + +struct hwt_alloc { + size_t bufsize; + int mode; + pid_t pid; /* thread mode */ + cpuset_t *cpu_map; /* cpu mode only */ + size_t cpusetsize; + const char *backend_name; + int *ident; + int kqueue_fd; +} __aligned(16); + +struct hwt_start { + int reserved; +} __aligned(16); + +struct hwt_stop { + int reserved; +} __aligned(16); + +struct hwt_wakeup { + int reserved; +} __aligned(16); + +struct hwt_record_user_entry { + enum hwt_record_type record_type; + union { + /* + * Used for MMAP, EXECUTABLE, INTERP, + * and KERNEL records. + */ + struct { + char fullpath[MAXPATHLEN]; + uintptr_t addr; + uintptr_t baseaddr; + }; + /* Used for BUFFER records. */ + struct { + int buf_id; + int curpage; + vm_offset_t offset; + }; + /* Used for THREAD_* records. */ + int thread_id; + }; +} __aligned(16); + +struct hwt_record_get { + struct hwt_record_user_entry *records; + int *nentries; + int wait; +} __aligned(16); + +struct hwt_bufptr_get { + int *ident; + vm_offset_t *offset; + uint64_t *data; +} __aligned(16); + +struct hwt_set_config { + /* Configuration of ctx. */ + int pause_on_mmap; + + /* The following passed to backend as is. */ + void *config; + size_t config_size; + int config_version; +} __aligned(16); + +struct hwt_svc_buf { + /* The following passed to backend as is. */ + void *data; + size_t data_size; + int data_version; +} __aligned(16); + +#endif /* !_SYS_HWT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/hwt_record.h b/lib/libc/include/generic-freebsd/sys/hwt_record.h new file mode 100644 index 0000000000000000000000000000000000000000..a3dc7181dea7caea01e81a9e807b1915518e190a --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/hwt_record.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2023-2025 Ruslan Bukin + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* User-visible header. */ + +#ifndef _SYS_HWT_RECORD_H_ +#define _SYS_HWT_RECORD_H_ + +enum hwt_record_type { + HWT_RECORD_MMAP, + HWT_RECORD_MUNMAP, + HWT_RECORD_EXECUTABLE, + HWT_RECORD_KERNEL, + HWT_RECORD_THREAD_CREATE, + HWT_RECORD_THREAD_SET_NAME, + HWT_RECORD_BUFFER +}; + +#ifdef _KERNEL +struct hwt_record_entry { + TAILQ_ENTRY(hwt_record_entry) next; + enum hwt_record_type record_type; + union { + /* + * Used for MMAP, EXECUTABLE, INTERP, + * and KERNEL records. + */ + struct { + char *fullpath; + uintptr_t addr; + uintptr_t baseaddr; + }; + /* Used for BUFFER records. */ + struct { + int buf_id; + int curpage; + vm_offset_t offset; + }; + /* Used for THREAD_* records. */ + int thread_id; + }; +}; +#endif + +#endif /* !_SYS_HWT_RECORD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/imgact.h b/lib/libc/include/generic-freebsd/sys/imgact.h index 853e2e7682b7eb2efb064242ae84aeebf3fabbfd..54e669d240996056648e4600e1762fe6982e2e4b 100644 --- a/lib/libc/include/generic-freebsd/sys/imgact.h +++ b/lib/libc/include/generic-freebsd/sys/imgact.h @@ -119,8 +119,7 @@ int exec_map_stack(struct image_params *); int exec_new_vmspace(struct image_params *, struct sysentvec *); void exec_setregs(struct thread *, struct image_params *, uintptr_t); int exec_shell_imgact(struct image_params *); -int exec_copyin_args(struct image_args *, const char *, enum uio_seg, - char **, char **); +int exec_copyin_args(struct image_args *, const char *, char **, char **); int pre_execve(struct thread *td, struct vmspace **oldvmspace); void post_execve(struct thread *td, int error, struct vmspace *oldvmspace); #endif diff --git a/lib/libc/include/generic-freebsd/sys/imgact_aout.h b/lib/libc/include/generic-freebsd/sys/imgact_aout.h index 07f49bf80cff46581a40208d25ea79dac70bac51..61b420743f2bcc2ffc8a97d8abf6613cd9ee0fa8 100644 --- a/lib/libc/include/generic-freebsd/sys/imgact_aout.h +++ b/lib/libc/include/generic-freebsd/sys/imgact_aout.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)exec.h 8.1 (Berkeley) 6/11/93 */ #ifndef _IMGACT_AOUT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/imgact_elf.h b/lib/libc/include/generic-freebsd/sys/imgact_elf.h index f60851e2bf247d8101abb94822566f22d17211fb..2d19cb603d95f91a374a1d64b369e0aaf5948060 100644 --- a/lib/libc/include/generic-freebsd/sys/imgact_elf.h +++ b/lib/libc/include/generic-freebsd/sys/imgact_elf.h @@ -45,6 +45,7 @@ {(pos)->a_type = (id); (pos)->a_un.a_ptr = (ptr); (pos)++;} #endif +struct coredump_writer; struct image_params; struct thread; struct vnode; @@ -86,8 +87,8 @@ typedef struct { const char *interp_newpath; int flags; Elf_Brandnote *brand_note; - bool (*header_supported)(struct image_params *, - int32_t *, uint32_t *); + bool (*header_supported)(const struct image_params *, + const int32_t *, const uint32_t *); /* High 8 bits of flags is private to the ABI */ #define BI_CAN_EXEC_DYN 0x0001 #define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */ @@ -114,7 +115,7 @@ bool __elfN(brand_inuse)(Elf_Brandinfo *entry); int __elfN(insert_brand_entry)(Elf_Brandinfo *entry); int __elfN(remove_brand_entry)(Elf_Brandinfo *entry); int __elfN(freebsd_fixup)(uintptr_t *, struct image_params *); -int __elfN(coredump)(struct thread *, struct vnode *, off_t, int); +int __elfN(coredump)(struct thread *, struct coredump_writer *, off_t, int); size_t __elfN(populate_note)(int, void *, void *, size_t, void **); int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t); void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int); @@ -123,9 +124,9 @@ void __elfN(prepare_notes)(struct thread *, struct note_info_list *, void __elfN(size_segments)(struct thread *, struct sseg_closure *, int); size_t __elfN(register_note)(struct thread *, struct note_info_list *, int, outfunc_t, void *); -bool __elfN(parse_notes)(struct image_params *, Elf_Note *, const char *, - const Elf_Phdr *, bool (*)(const Elf_Note *, void *, bool *), - void *); +bool __elfN(parse_notes)(const struct image_params *, const Elf_Note *, + const char *, const Elf_Phdr *, + bool (*)(const Elf_Note *, void *, bool *), void *); /* Machine specific function to dump per-thread information. */ void __elfN(dump_thread)(struct thread *, void *, size_t *); diff --git a/lib/libc/include/generic-freebsd/sys/inotify.h b/lib/libc/include/generic-freebsd/sys/inotify.h new file mode 100644 index 0000000000000000000000000000000000000000..b3bd0da8748b236586125f47d99687e040749974 --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/inotify.h @@ -0,0 +1,158 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Klara, Inc. + */ + +#ifndef _INOTIFY_H_ +#define _INOTIFY_H_ + +#include + +/* Flags for inotify_init1(). */ +#define IN_NONBLOCK 0x00000004 /* O_NONBLOCK */ +#define IN_CLOEXEC 0x00100000 /* O_CLOEXEC */ + +struct inotify_event { + int wd; + __uint32_t mask; + __uint32_t cookie; + __uint32_t len; + char name[0]; +}; + +/* Events, set in the mask field. */ +#define IN_ACCESS 0x00000001 +#define IN_MODIFY 0x00000002 +#define IN_ATTRIB 0x00000004 +#define IN_CLOSE_WRITE 0x00000008 +#define IN_CLOSE_NOWRITE 0x00000010 +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) +#define IN_OPEN 0x00000020 +#define IN_MOVED_FROM 0x00000040 +#define IN_MOVED_TO 0x00000080 +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) +#define IN_CREATE 0x00000100 +#define IN_DELETE 0x00000200 +#define IN_DELETE_SELF 0x00000400 +#define IN_MOVE_SELF 0x00000800 +#define IN_ALL_EVENTS 0x00000fff + +/* Events report only for entries in a watched dir, not the dir itself. */ +#define _IN_DIR_EVENTS (IN_CLOSE_WRITE | IN_DELETE | IN_MODIFY | \ + IN_MOVED_FROM | IN_MOVED_TO) + +#ifdef _KERNEL +/* + * An unlink that's done as part of a rename only records IN_DELETE if the + * unlinked vnode itself is watched, and not when the containing directory is + * watched. + */ +#define _IN_MOVE_DELETE 0x40000000 +/* + * Inode link count changes only trigger IN_ATTRIB events if the inode itself is + * watched, and not when the containing directory is watched. + */ +#define _IN_ATTRIB_LINKCOUNT 0x80000000 +#endif + +/* Flags, set in the mask field. */ +#define IN_ONLYDIR 0x01000000 +#define IN_DONT_FOLLOW 0x02000000 +#define IN_EXCL_UNLINK 0x04000000 +#define IN_MASK_CREATE 0x10000000 +#define IN_MASK_ADD 0x20000000 +#define IN_ONESHOT 0x80000000 +#define _IN_ALL_FLAGS (IN_ONLYDIR | IN_DONT_FOLLOW | \ + IN_EXCL_UNLINK | IN_MASK_CREATE | \ + IN_MASK_ADD | IN_ONESHOT) + +/* Flags returned by the kernel. */ +#define IN_UNMOUNT 0x00002000 +#define IN_Q_OVERFLOW 0x00004000 +#define IN_IGNORED 0x00008000 +#define IN_ISDIR 0x40000000 +#define _IN_ALL_RETFLAGS (IN_Q_OVERFLOW | IN_UNMOUNT | IN_IGNORED | \ + IN_ISDIR) + +#define _IN_ALIGN _Alignof(struct inotify_event) +#define _IN_NAMESIZE(namelen) \ + ((namelen) == 0 ? 0 : __align_up((namelen) + 1, _IN_ALIGN)) + +#ifdef _KERNEL +struct componentname; +struct file; +struct inotify_softc; +struct thread; +struct vnode; + +int inotify_create_file(struct thread *, struct file *, int, int *); +void inotify_log(struct vnode *, const char *, size_t, int, __uint32_t); + +int kern_inotify_rm_watch(int, uint32_t, struct thread *); +int kern_inotify_add_watch(int, int, const char *, uint32_t, + struct thread *); + +void vn_inotify(struct vnode *, struct vnode *, struct componentname *, int, + uint32_t); +int vn_inotify_add_watch(struct vnode *, struct inotify_softc *, + __uint32_t, __uint32_t *, struct thread *); +void vn_inotify_revoke(struct vnode *); + +/* Log an inotify event. */ +#define INOTIFY(vp, ev) do { \ + if (__predict_false((vn_irflag_read(vp) & (VIRF_INOTIFY | \ + VIRF_INOTIFY_PARENT)) != 0)) \ + VOP_INOTIFY((vp), NULL, NULL, (ev), 0); \ +} while (0) + +/* Log an inotify event using a specific name for the vnode. */ +#define INOTIFY_NAME_LOCK(vp, dvp, cnp, ev, lock) do { \ + if (__predict_false((vn_irflag_read(vp) & VIRF_INOTIFY) != 0 || \ + (vn_irflag_read(dvp) & VIRF_INOTIFY) != 0)) { \ + if (lock) \ + vn_lock((vp), LK_SHARED | LK_RETRY); \ + VOP_INOTIFY((vp), (dvp), (cnp), (ev), 0); \ + if (lock) \ + VOP_UNLOCK(vp); \ + } \ +} while (0) +#define INOTIFY_NAME(vp, dvp, cnp, ev) \ + INOTIFY_NAME_LOCK((vp), (dvp), (cnp), (ev), false) + +extern __uint32_t inotify_rename_cookie; + +#define INOTIFY_MOVE(vp, fdvp, fcnp, tvp, tdvp, tcnp) do { \ + if (__predict_false((vn_irflag_read(fdvp) & VIRF_INOTIFY) != 0 || \ + (vn_irflag_read(tdvp) & VIRF_INOTIFY) != 0 || \ + (vn_irflag_read(vp) & VIRF_INOTIFY) != 0)) { \ + __uint32_t cookie; \ + \ + cookie = atomic_fetchadd_32(&inotify_rename_cookie, 1); \ + VOP_INOTIFY((vp), (fdvp), (fcnp), IN_MOVED_FROM, cookie); \ + VOP_INOTIFY((vp), (tdvp), (tcnp), IN_MOVED_TO, cookie); \ + } \ + if ((tvp) != NULL) \ + INOTIFY_NAME_LOCK((tvp), (tdvp), (tcnp), \ + _IN_MOVE_DELETE, true); \ +} while (0) + +#define INOTIFY_REVOKE(vp) do { \ + if (__predict_false((vn_irflag_read(vp) & VIRF_INOTIFY) != 0)) \ + vn_inotify_revoke((vp)); \ +} while (0) + +#else +#include + +__BEGIN_DECLS +int inotify_init(void); +int inotify_init1(int flags); +int inotify_add_watch(int fd, const char *pathname, __uint32_t mask); +int inotify_add_watch_at(int fd, int dfd, const char *pathname, + __uint32_t mask); +int inotify_rm_watch(int fd, int wd); +__END_DECLS +#endif /* !_KERNEL */ + +#endif /* !_INOTIFY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/interrupt.h b/lib/libc/include/generic-freebsd/sys/interrupt.h index 60cd6119201cc244cce65245cfad0e8ccd09935b..8126df6a3980377969bd761a6ab32263aacf8e17 100644 --- a/lib/libc/include/generic-freebsd/sys/interrupt.h +++ b/lib/libc/include/generic-freebsd/sys/interrupt.h @@ -121,7 +121,7 @@ struct intr_event { int ie_count; /* Loop counter. */ int ie_warncnt; /* Rate-check interrupt storm warns. */ struct timeval ie_warntm; - int ie_irq; /* Physical irq number if !SOFT. */ + u_int ie_irq; /* Physical irq number if !SOFT. */ int ie_cpu; /* CPU this event is bound to. */ volatile int ie_phase; /* Switched to establish a barrier. */ volatile int ie_active[2]; /* Filters in ISR context. */ @@ -129,6 +129,7 @@ struct intr_event { /* Interrupt event flags kept in ie_flags. */ #define IE_SOFT 0x000001 /* Software interrupt. */ +#define IE_SLEEPABLE 0x000002 /* Sleepable ithread */ #define IE_ADDING_THREAD 0x000004 /* Currently building an ithread. */ /* Flags to pass to swi_sched. */ @@ -175,7 +176,7 @@ struct _cpuset; int intr_event_bind_ithread_cpuset(struct intr_event *ie, struct _cpuset *mask); int intr_event_create(struct intr_event **event, void *source, - int flags, int irq, void (*pre_ithread)(void *), + int flags, u_int irq, void (*pre_ithread)(void *), void (*post_ithread)(void *), void (*post_filter)(void *), int (*assign_cpu)(void *, int), const char *fmt, ...) __printflike(9, 10); @@ -188,7 +189,7 @@ int intr_event_suspend_handler(void *cookie); int intr_event_resume_handler(void *cookie); int intr_getaffinity(int irq, int mode, void *mask); void *intr_handler_source(void *cookie); -int intr_setaffinity(int irq, int mode, void *mask); +int intr_setaffinity(int irq, int mode, const void *mask); void _intr_drain(int irq); /* LinuxKPI only. */ int swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler, void *arg, int pri, enum intr_type flags, diff --git a/lib/libc/include/generic-freebsd/sys/intr.h b/lib/libc/include/generic-freebsd/sys/intr.h index 665d96e5445b23f518909eb184c7818f6082dfd9..9680dbe0bad49e7f35ab502012e590ec82ed2dca 100644 --- a/lib/libc/include/generic-freebsd/sys/intr.h +++ b/lib/libc/include/generic-freebsd/sys/intr.h @@ -33,10 +33,12 @@ #error Need INTRNG for this file #endif -#include +#include #define INTR_IRQ_INVALID 0xFFFFFFFF +#ifndef LOCORE + enum intr_map_data_type { INTR_MAP_DATA_ACPI = 0, INTR_MAP_DATA_FDT, @@ -110,12 +112,13 @@ u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask); struct intr_pic *intr_pic_register(device_t, intptr_t); int intr_pic_deregister(device_t, intptr_t); -int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *); +int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, + uint32_t); int intr_pic_add_handler(device_t, struct intr_pic *, intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t); bool intr_is_per_cpu(struct resource *); -extern device_t intr_irq_root_dev; +device_t intr_irq_root_device(uint32_t); /* Intr interface for BUS. */ @@ -163,4 +166,9 @@ void intr_ipi_send(cpuset_t cpus, u_int ipi); void intr_ipi_dispatch(u_int ipi); #endif +/* Main interrupt handler called from asm on most archs except riscv. */ +void intr_irq_handler(struct trapframe *tf, uint32_t rootnum); + +#endif /* !LOCORE */ + #endif /* _SYS_INTR_H */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/ioccom.h b/lib/libc/include/generic-freebsd/sys/ioccom.h index 6beecbd3d1cc84134eb5fb5c3fb203bbe422ec35..c5c7497a473f79d9b3ae6a19a03880c3a9fc5552 100644 --- a/lib/libc/include/generic-freebsd/sys/ioccom.h +++ b/lib/libc/include/generic-freebsd/sys/ioccom.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ioccom.h 8.3 (Berkeley) 1/9/95 */ #ifndef _SYS_IOCCOM_H_ diff --git a/lib/libc/include/generic-freebsd/sys/ioctl.h b/lib/libc/include/generic-freebsd/sys/ioctl.h index f023f930a02feb4ba5ccea1380ee3a35d8597544..8f729647742fb93ae8095c5780ee4409e1f2ffad 100644 --- a/lib/libc/include/generic-freebsd/sys/ioctl.h +++ b/lib/libc/include/generic-freebsd/sys/ioctl.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ioctl.h 8.6 (Berkeley) 3/28/94 */ #ifndef _SYS_IOCTL_H_ diff --git a/lib/libc/include/generic-freebsd/sys/ioctl_compat.h b/lib/libc/include/generic-freebsd/sys/ioctl_compat.h index 2f8562ad7719b0819736038f48b834e3254cbe02..e552744ff08484248d984be56ac996bb271de0e0 100644 --- a/lib/libc/include/generic-freebsd/sys/ioctl_compat.h +++ b/lib/libc/include/generic-freebsd/sys/ioctl_compat.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ioctl_compat.h 8.4 (Berkeley) 1/21/94 */ #ifndef _SYS_IOCTL_COMPAT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/ipc.h b/lib/libc/include/generic-freebsd/sys/ipc.h index a1052d2a9bcf4aeba0b6da86d01fc4a00beb8042..b16820710277b758d055f59230b469d17bdaf6da 100644 --- a/lib/libc/include/generic-freebsd/sys/ipc.h +++ b/lib/libc/include/generic-freebsd/sys/ipc.h @@ -37,8 +37,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ipc.h 8.4 (Berkeley) 2/19/95 */ /* diff --git a/lib/libc/include/generic-freebsd/sys/jail.h b/lib/libc/include/generic-freebsd/sys/jail.h index 9aff4f33bebf19187579de8826db0294929e34a5..a96c08ab82fa44825d9f34eedeea5296be9ac8e7 100644 --- a/lib/libc/include/generic-freebsd/sys/jail.h +++ b/lib/libc/include/generic-freebsd/sys/jail.h @@ -99,8 +99,12 @@ enum prison_state { #define JAIL_UPDATE 0x02 /* Update parameters of existing jail */ #define JAIL_ATTACH 0x04 /* Attach to jail upon creation */ #define JAIL_DYING 0x08 /* Allow getting a dying jail */ -#define JAIL_SET_MASK 0x0f -#define JAIL_GET_MASK 0x08 +#define JAIL_USE_DESC 0x10 /* Get/set jail in descriptor */ +#define JAIL_AT_DESC 0x20 /* Find/add jail under descriptor */ +#define JAIL_GET_DESC 0x40 /* Return a new jail descriptor */ +#define JAIL_OWN_DESC 0x80 /* Return a new owning jail descriptor */ +#define JAIL_SET_MASK 0xff /* JAIL_DYING is deprecated/ignored here */ +#define JAIL_GET_MASK 0xf8 #define JAIL_SYS_DISABLE 0 #define JAIL_SYS_NEW 1 @@ -115,7 +119,9 @@ int jail(struct jail *); int jail_set(struct iovec *, unsigned int, int); int jail_get(struct iovec *, unsigned int, int); int jail_attach(int); +int jail_attach_jd(int); int jail_remove(int); +int jail_remove_jd(int); __END_DECLS #else /* _KERNEL */ @@ -141,6 +147,11 @@ MALLOC_DECLARE(M_PRISON); #define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000" #define OSRELEASELEN 32 +#define JAIL_META_PRIVATE "meta" +#define JAIL_META_SHARED "env" + +struct jaildesc; +struct knlist; struct racct; struct prison_racct; @@ -186,7 +197,9 @@ struct prison { struct vnode *pr_root; /* (c) vnode to rdir */ struct prison_ip *pr_addrs[PR_FAMILY_MAX]; /* (p,n) IPs of jail */ struct prison_racct *pr_prison_racct; /* (c) racct jail proxy */ - void *pr_sparep[3]; + struct knlist *pr_klist; /* (m) attached knotes */ + LIST_HEAD(, jaildesc) pr_descs; /* (a) attached descriptors */ + void *pr_sparep; int pr_childcount; /* (a) number of child jails */ int pr_childmax; /* (p) maximum child jails */ unsigned pr_allow; /* (p) PR_ALLOW_* flags */ @@ -253,13 +266,29 @@ struct prison_racct { #define PR_ALLOW_RESERVED_PORTS 0x00008000 #define PR_ALLOW_KMEM_ACCESS 0x00010000 /* reserved, not used yet */ #define PR_ALLOW_NFSD 0x00020000 -#define PR_ALLOW_ALL_STATIC 0x000387ff +#define PR_ALLOW_EXTATTR 0x00040000 +#define PR_ALLOW_ADJTIME 0x00080000 +#define PR_ALLOW_SETTIME 0x00100000 +#define PR_ALLOW_ROUTING 0x00200000 +#define PR_ALLOW_UNPRIV_PARENT_TAMPER 0x00400000 +#define PR_ALLOW_SETAUDIT 0x00800000 + +/* + * PR_ALLOW_PRISON0 are the allow flags that we apply by default to prison0, + * while PR_ALLOW_ALL_STATIC are all of the allow bits that we have allocated at + * build time. PR_ALLOW_ALL_STATIC should contain any bit above that we expect + * to be used on the system, while PR_ALLOW_PRISON0 will be some subset of that. + */ +#define PR_ALLOW_ALL_STATIC 0x00ff87ff +#define PR_ALLOW_PRISON0 \ + (PR_ALLOW_ALL_STATIC & ~(PR_ALLOW_UNPRIV_PARENT_TAMPER)) /* * PR_ALLOW_DIFFERENCES determines which flags are able to be * different between the parent and child jail upon creation. */ -#define PR_ALLOW_DIFFERENCES (PR_ALLOW_UNPRIV_DEBUG) +#define PR_ALLOW_DIFFERENCES \ + (PR_ALLOW_UNPRIV_DEBUG | PR_ALLOW_UNPRIV_PARENT_TAMPER) /* * OSD methods @@ -373,37 +402,45 @@ extern struct sx allprison_lock; /* * Sysctls to describe jail parameters. */ +SYSCTL_DECL(_security_jail); SYSCTL_DECL(_security_jail_param); +#define SYSCTL_JAIL_PARAM_DECL(name) \ + SYSCTL_DECL(_security_jail_param_##name) #define SYSCTL_JAIL_PARAM(module, param, type, fmt, descr) \ - SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ - (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr) + SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ + (type) | CTLFLAG_MPSAFE, NULL, 0, sysctl_jail_param, fmt, descr) #define SYSCTL_JAIL_PARAM_STRING(module, param, access, len, descr) \ - SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ - CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \ - sysctl_jail_param, "A", descr) -#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr)\ - SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ - CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \ - sysctl_jail_param, fmt, descr) + SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ + CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), NULL, len, \ + sysctl_jail_param, "A", descr) +#define SYSCTL_JAIL_PARAM_STRUCT(module, param, access, len, fmt, descr) \ + SYSCTL_PROC(_security_jail_param ## module, OID_AUTO, param, \ + CTLTYPE_STRUCT | CTLFLAG_MPSAFE | (access), NULL, len, \ + sysctl_jail_param, fmt, descr) #define SYSCTL_JAIL_PARAM_NODE(module, descr) \ - SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \ - 0, descr) + SYSCTL_NODE(_security_jail_param, OID_AUTO, module, CTLFLAG_MPSAFE, \ + 0, descr) #define SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr) \ - SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \ - CTLFLAG_MPSAFE, 0, descr) + SYSCTL_NODE(_security_jail_param_##parent, OID_AUTO, module, \ + CTLFLAG_MPSAFE, 0, descr) #define SYSCTL_JAIL_PARAM_SYS_NODE(module, access, descr) \ - SYSCTL_JAIL_PARAM_NODE(module, descr); \ - SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \ - descr) + SYSCTL_JAIL_PARAM_NODE(module, descr); \ + SYSCTL_JAIL_PARAM(_##module, , CTLTYPE_INT | (access), "E,jailsys", \ + descr) +#define SYSCTL_JAIL_PARAM_SYS_SUBNODE(parent, module, access, descr) \ + SYSCTL_JAIL_PARAM_SUBNODE(parent, module, descr); \ + SYSCTL_JAIL_PARAM(_##parent##_##module, , CTLTYPE_INT | (access), \ + "E,jailsys", descr) /* * Kernel support functions for jail(). */ -struct ucred; +struct knote; struct mount; struct sockaddr; struct statfs; +struct ucred; struct vfsconf; /* @@ -421,7 +458,7 @@ void prison0_init(void); bool prison_allow(struct ucred *, unsigned); int prison_check(struct ucred *cred1, struct ucred *cred2); bool prison_check_nfsd(struct ucred *cred); -bool prison_owns_vnet(struct ucred *); +bool prison_owns_vnet(struct prison *pr); int prison_canseemount(struct ucred *cred, struct mount *mp); void prison_enforce_statfs(struct ucred *cred, struct mount *mp, struct statfs *sp); @@ -438,6 +475,7 @@ void prison_proc_free(struct prison *); void prison_proc_link(struct prison *, struct proc *); void prison_proc_unlink(struct prison *, struct proc *); void prison_proc_iterate(struct prison *, void (*)(struct proc *, void *), void *); +void prison_remove(struct prison *); void prison_set_allow(struct ucred *cred, unsigned flag, int enable); bool prison_ischild(struct prison *, struct prison *); bool prison_isalive(const struct prison *); diff --git a/lib/libc/include/generic-freebsd/sys/jaildesc.h b/lib/libc/include/generic-freebsd/sys/jaildesc.h new file mode 100644 index 0000000000000000000000000000000000000000..31559478dcc9239b128c0635b54f402d4ef94c7f --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/jaildesc.h @@ -0,0 +1,87 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 James Gritton. + * All rights reserved. + * + * This software was developed at the University of Cambridge Computer + * Laboratory with support from a grant from Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS_JAILDESC_H_ +#define _SYS_JAILDESC_H_ + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +struct prison; + +/*- + * struct jaildesc describes a jail descriptor, which points to a struct + * prison. struct prison in turn has a linked list of struct jaildesc. + * + * Locking key: + * (c) set on creation, remains unchanged + * (d) jd_lock + * (p) jd_prison->pr_mtx + */ +struct jaildesc { + LIST_ENTRY(jaildesc) jd_list; /* (d,p) this prison's descs */ + struct prison *jd_prison; /* (d) the prison */ + struct mtx jd_lock; + struct selinfo jd_selinfo; /* (d) event notification */ + unsigned jd_flags; /* (d) JDF_* flags */ +}; + +/* + * Locking macros for the jaildesc. + */ +#define JAILDESC_LOCK_DESTROY(jd) mtx_destroy(&(jd)->jd_lock) +#define JAILDESC_LOCK_INIT(jd) mtx_init(&(jd)->jd_lock, "jaildesc", \ + NULL, MTX_DEF) +#define JAILDESC_LOCK(jd) mtx_lock(&(jd)->jd_lock) +#define JAILDESC_UNLOCK(jd) mtx_unlock(&(jd)->jd_lock) + +/* + * Flags for the jd_flags field + */ +#define JDF_SELECTED 0x00000001 /* issue selwakeup() */ +#define JDF_REMOVED 0x00000002 /* jail was removed */ +#define JDF_OWNING 0x00000004 /* closing descriptor removes jail */ + +int jaildesc_find(struct thread *td, int fd, struct prison **prp, + struct ucred **ucredp); +int jaildesc_alloc(struct thread *td, struct file **fpp, int *fdp, int owning); +void jaildesc_set_prison(struct file *jd, struct prison *pr); +void jaildesc_prison_cleanup(struct prison *pr); +void jaildesc_knote(struct prison *pr, long hint); + +#endif /* _KERNEL */ + +#endif /* !_SYS_JAILDESC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/kassert.h b/lib/libc/include/generic-freebsd/sys/kassert.h index 5524b5acb19f37b76cbe8dfce92d8500d1826170..d3f7655f9edf31a1dfc240984de51a24d98794bd 100644 --- a/lib/libc/include/generic-freebsd/sys/kassert.h +++ b/lib/libc/include/generic-freebsd/sys/kassert.h @@ -31,12 +31,37 @@ #ifndef _SYS_KASSERT_H_ #define _SYS_KASSERT_H_ +#include #include #ifdef _KERNEL extern const char *panicstr; /* panic message */ -extern bool panicked; -#define KERNEL_PANICKED() __predict_false(panicked) +#define KERNEL_PANICKED() __predict_false(panicstr != NULL) + +/* + * Trap accesses going through a pointer. + * + * Sample usage: you have a struct with numerous fields and by API contract + * only some of them get populated, even if the implementation temporary writes + * to them. You can use DEBUG_POISON_POINTER so that the consumer which should + * no be looking at the field gets caught. + * + * DEBUG_POISON_POINTER(obj->ptr); + * .... + * if (obj->ptr->field) // traps + */ +#ifdef INVARIANTS + +extern void *poisoned_buf; +#define DEBUG_POISON_POINTER_VALUE poisoned_buf + +#define DEBUG_POISON_POINTER(x) ({ \ + x = (DEBUG_POISON_POINTER_VALUE); \ +}) + +#else +#define DEBUG_POISON_POINTER(x) +#endif #ifdef INVARIANTS /* The option is always available */ #define VNASSERT(exp, vp, msg) do { \ diff --git a/lib/libc/include/generic-freebsd/sys/kernel.h b/lib/libc/include/generic-freebsd/sys/kernel.h index 11a8383c310bb75a1890d08d6003d8bec91dd020..1415d4af070cbbc274b7279bba50454ed29ce1e7 100644 --- a/lib/libc/include/generic-freebsd/sys/kernel.h +++ b/lib/libc/include/generic-freebsd/sys/kernel.h @@ -39,8 +39,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)kernel.h 8.3 (Berkeley) 1/21/94 */ #ifndef _SYS_KERNEL_H_ @@ -67,7 +65,16 @@ extern int psratio; /* ratio: prof / stat */ extern int stathz; /* statistics clock's frequency */ extern int profhz; /* profiling clock's frequency */ extern int profprocs; /* number of process's profiling */ + +/* + * The ticks and ticksl symbols overlap, giving a 64-bit tick counter on 64-bit + * platforms while still maintaining compatibility with the legacy 32-bit + * counter. Either value can be used, but rollover must be handled; at 1000Hz, + * ticks (and ticksl on 32-bit platforms) roll over roughly every 25 days. On + * 64-bit platforms, ticksl will not roll over in the foreseeable future. + */ extern volatile int ticks; +extern volatile long ticksl; #endif /* _KERNEL */ @@ -86,16 +93,15 @@ extern volatile int ticks; * The SI_SUB_LAST value must have the highest lexical value. */ enum sysinit_sub_id { - SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/ - SI_SUB_DONE = 0x0000001, /* processed*/ + SI_SUB_DUMMY = 0x0000000, /* not executed; for linker */ SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */ - SI_SUB_COPYRIGHT = 0x0800001, /* first use of console*/ + SI_SUB_COPYRIGHT = 0x0800001, /* first use of console */ SI_SUB_VM = 0x1000000, /* virtual memory system init */ SI_SUB_COUNTER = 0x1100000, /* counter(9) is initialized */ - SI_SUB_KMEM = 0x1800000, /* kernel memory*/ + SI_SUB_KMEM = 0x1800000, /* kernel memory */ SI_SUB_HYPERVISOR = 0x1A40000, /* * Hypervisor detection and - * virtualization support + * virtualization support * setup. */ SI_SUB_WITNESS = 0x1A80000, /* witness initialization */ @@ -105,7 +111,7 @@ enum sysinit_sub_id { SI_SUB_VNET_PRELINK = 0x1E00000, /* vnet init before modules */ SI_SUB_KLD = 0x2000000, /* KLD and module setup */ SI_SUB_KHELP = 0x2080000, /* khelp modules */ - SI_SUB_CPU = 0x2100000, /* CPU resource(s)*/ + SI_SUB_CPU = 0x2100000, /* CPU resource(s) */ SI_SUB_RACCT = 0x2110000, /* resource accounting */ SI_SUB_KDTRACE = 0x2140000, /* Kernel dtrace hooks */ SI_SUB_RANDOM = 0x2160000, /* random number generator */ @@ -113,21 +119,21 @@ enum sysinit_sub_id { SI_SUB_MAC_POLICY = 0x21C0000, /* TrustedBSD MAC policies */ SI_SUB_MAC_LATE = 0x21D0000, /* TrustedBSD MAC subsystem */ SI_SUB_VNET = 0x21E0000, /* vnet 0 */ - SI_SUB_INTRINSIC = 0x2200000, /* proc 0*/ - SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits*/ + SI_SUB_INTRINSIC = 0x2200000, /* proc 0 */ + SI_SUB_VM_CONF = 0x2300000, /* config VM, set limits */ SI_SUB_DDB_SERVICES = 0x2380000, /* capture, scripting, etc. */ - SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue*/ + SI_SUB_RUN_QUEUE = 0x2400000, /* set up run queue */ SI_SUB_KTRACE = 0x2480000, /* ktrace */ SI_SUB_OPENSOLARIS = 0x2490000, /* OpenSolaris compatibility */ SI_SUB_AUDIT = 0x24C0000, /* audit */ - SI_SUB_CREATE_INIT = 0x2500000, /* create init process*/ + SI_SUB_CREATE_INIT = 0x2500000, /* create init process */ SI_SUB_SCHED_IDLE = 0x2600000, /* required idle procs */ SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ SI_SUB_TASKQ = 0x2880000, /* task queues */ SI_SUB_EPOCH = 0x2888000, /* epoch subsystem */ #ifdef EARLY_AP_STARTUP - SI_SUB_SMP = 0x2900000, /* start the APs*/ + SI_SUB_SMP = 0x2900000, /* start the APs */ #endif SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */ SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ @@ -138,40 +144,40 @@ enum sysinit_sub_id { SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */ SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ - SI_SUB_VFS = 0x4000000, /* virtual filesystem*/ - SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks*/ - SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory*/ - SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores*/ - SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues*/ + SI_SUB_VFS = 0x4000000, /* virtual filesystem */ + SI_SUB_CLOCKS = 0x4800000, /* real time and stat clocks */ + SI_SUB_SYSV_SHM = 0x6400000, /* System V shared memory */ + SI_SUB_SYSV_SEM = 0x6800000, /* System V semaphores */ + SI_SUB_SYSV_MSG = 0x6C00000, /* System V message queues */ SI_SUB_P1003_1B = 0x6E00000, /* P1003.1B realtime */ - SI_SUB_PSEUDO = 0x7000000, /* pseudo devices*/ + SI_SUB_PSEUDO = 0x7000000, /* pseudo devices */ SI_SUB_EXEC = 0x7400000, /* execve() handlers */ SI_SUB_PROTO_BEGIN = 0x8000000, /* VNET initialization */ SI_SUB_PROTO_PFIL = 0x8100000, /* Initialize pfil before FWs */ - SI_SUB_PROTO_IF = 0x8400000, /* interfaces*/ + SI_SUB_PROTO_IF = 0x8400000, /* interfaces */ SI_SUB_PROTO_DOMAININIT = 0x8600000, /* domain registration system */ SI_SUB_PROTO_MC = 0x8700000, /* Multicast */ - SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?)*/ + SI_SUB_PROTO_DOMAIN = 0x8800000, /* domains (address families?) */ SI_SUB_PROTO_FIREWALL = 0x8806000, /* Firewalls */ SI_SUB_PROTO_IFATTACHDOMAIN = 0x8808000,/* domain dependent data init */ SI_SUB_PROTO_END = 0x8ffffff, /* VNET helper functions */ - SI_SUB_KPROF = 0x9000000, /* kernel profiling*/ - SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/ + SI_SUB_KPROF = 0x9000000, /* kernel profiling */ + SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events */ SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */ SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */ - SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/ + SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup */ SI_SUB_SYSCALLS = 0xd800000, /* register system calls */ SI_SUB_VNET_DONE = 0xdc00000, /* vnet registration complete */ - SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/ - SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/ - SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/ - SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon*/ - SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon*/ - SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs*/ + SI_SUB_KTHREAD_INIT = 0xe000000, /* init process */ + SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon */ + SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon */ + SI_SUB_KTHREAD_BUF = 0xea00000, /* buffer daemon */ + SI_SUB_KTHREAD_UPDATE = 0xec00000, /* update daemon */ + SI_SUB_KTHREAD_IDLE = 0xee00000, /* idle procs */ #ifndef EARLY_AP_STARTUP - SI_SUB_SMP = 0xf000000, /* start the APs*/ -#endif - SI_SUB_RACCTD = 0xf100000, /* start racctd*/ + SI_SUB_SMP = 0xf000000, /* start the APs */ +#endif + SI_SUB_RACCTD = 0xf100000, /* start racctd */ SI_SUB_LAST = 0xfffffff /* final initialization */ }; @@ -179,16 +185,16 @@ enum sysinit_sub_id { * Some enumerated orders; "ANY" sorts last. */ enum sysinit_elem_order { - SI_ORDER_FIRST = 0x0000000, /* first*/ - SI_ORDER_SECOND = 0x0000001, /* second*/ - SI_ORDER_THIRD = 0x0000002, /* third*/ - SI_ORDER_FOURTH = 0x0000003, /* fourth*/ - SI_ORDER_FIFTH = 0x0000004, /* fifth*/ - SI_ORDER_SIXTH = 0x0000005, /* sixth*/ - SI_ORDER_SEVENTH = 0x0000006, /* seventh*/ - SI_ORDER_EIGHTH = 0x0000007, /* eighth*/ + SI_ORDER_FIRST = 0x0000000, /* first */ + SI_ORDER_SECOND = 0x0000001, /* second */ + SI_ORDER_THIRD = 0x0000002, /* third */ + SI_ORDER_FOURTH = 0x0000003, /* fourth */ + SI_ORDER_FIFTH = 0x0000004, /* fifth */ + SI_ORDER_SIXTH = 0x0000005, /* sixth */ + SI_ORDER_SEVENTH = 0x0000006, /* seventh */ + SI_ORDER_EIGHTH = 0x0000007, /* eighth */ SI_ORDER_MIDDLE = 0x1000000, /* somewhere in the middle */ - SI_ORDER_ANY = 0xfffffff /* last*/ + SI_ORDER_ANY = 0xfffffff /* last */ }; /* @@ -218,10 +224,10 @@ typedef void (*sysinit_nfunc_t)(void *); typedef void (*sysinit_cfunc_t)(const void *); struct sysinit { - enum sysinit_sub_id subsystem; /* subsystem identifier*/ - enum sysinit_elem_order order; /* init order within subsystem*/ + enum sysinit_sub_id subsystem; /* subsystem identifier */ + enum sysinit_elem_order order; /* init order within subsystem */ STAILQ_ENTRY(sysinit) next; /* singly-linked list */ - sysinit_cfunc_t func; /* function */ + sysinit_cfunc_t func; /* function */ const void *udata; /* multiplexer/argument */ }; @@ -240,18 +246,11 @@ struct sysinit { #ifdef TSLOG struct sysinit_tslog { sysinit_cfunc_t func; - const void * data; - const char * name; + const void *data; + const char *name; }; -static inline void -sysinit_tslog_shim(const void * data) -{ - const struct sysinit_tslog * x = data; +void sysinit_tslog_shim(const void *); - TSRAW(curthread, TS_ENTER, "SYSINIT", x->name); - (x->func)(x->data); - TSRAW(curthread, TS_EXIT, "SYSINIT", x->name); -} #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ static struct sysinit_tslog uniquifier ## _sys_init_tslog = { \ func, \ @@ -265,7 +264,7 @@ sysinit_tslog_shim(const void * data) sysinit_tslog_shim, \ &uniquifier ## _sys_init_tslog \ }; \ - DATA_WSET(sysinit_set,uniquifier ## _sys_init) + DATA_WSET(sysinit_set, uniquifier ## _sys_init) #else #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ static struct sysinit uniquifier ## _sys_init = { \ @@ -275,7 +274,7 @@ sysinit_tslog_shim(const void * data) func, \ (ident) \ }; \ - DATA_WSET(sysinit_set,uniquifier ## _sys_init) + DATA_WSET(sysinit_set, uniquifier ## _sys_init) #endif #define SYSINIT(uniquifier, subsystem, order, func, ident) \ @@ -293,7 +292,7 @@ sysinit_tslog_shim(const void * data) func, \ (ident) \ }; \ - DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit) + DATA_WSET(sysuninit_set, uniquifier ## _sys_uninit) #define SYSUNINIT(uniquifier, subsystem, order, func, ident) \ C_SYSUNINIT(uniquifier, subsystem, order, \ @@ -316,7 +315,7 @@ void sysinit_add(struct sysinit **set, struct sysinit **set_end); * int * please avoid using for new tunables! */ -extern void tunable_int_init(void *); +extern void tunable_int_init(const void *); struct tunable_int { const char *path; int *var; @@ -335,7 +334,7 @@ struct tunable_int { /* * long */ -extern void tunable_long_init(void *); +extern void tunable_long_init(const void *); struct tunable_long { const char *path; long *var; @@ -354,7 +353,7 @@ struct tunable_long { /* * unsigned long */ -extern void tunable_ulong_init(void *); +extern void tunable_ulong_init(const void *); struct tunable_ulong { const char *path; unsigned long *var; @@ -373,7 +372,7 @@ struct tunable_ulong { /* * int64_t */ -extern void tunable_int64_init(void *); +extern void tunable_int64_init(const void *); struct tunable_int64 { const char *path; int64_t *var; @@ -392,7 +391,7 @@ struct tunable_int64 { /* * uint64_t */ -extern void tunable_uint64_init(void *); +extern void tunable_uint64_init(const void *); struct tunable_uint64 { const char *path; uint64_t *var; @@ -411,7 +410,7 @@ struct tunable_uint64 { /* * quad */ -extern void tunable_quad_init(void *); +extern void tunable_quad_init(const void *); struct tunable_quad { const char *path; quad_t *var; @@ -430,7 +429,7 @@ struct tunable_quad { /* * bool */ -extern void tunable_bool_init(void *); +extern void tunable_bool_init(const void *); struct tunable_bool { const char *path; bool *var; @@ -446,7 +445,7 @@ struct tunable_bool { #define TUNABLE_BOOL_FETCH(path, var) getenv_bool((path), (var)) -extern void tunable_str_init(void *); +extern void tunable_str_init(const void *); struct tunable_str { const char *path; char *var; diff --git a/lib/libc/include/generic-freebsd/sys/kerneldump.h b/lib/libc/include/generic-freebsd/sys/kerneldump.h index 2408d1e824d7069e7048e9538a481df88b8d3bd6..10d8dd17964beafc0ca09a74f46e940db1015df8 100644 --- a/lib/libc/include/generic-freebsd/sys/kerneldump.h +++ b/lib/libc/include/generic-freebsd/sys/kerneldump.h @@ -161,6 +161,7 @@ void dumpsys_pb_progress(size_t); extern int do_minidump; int livedump_start(int, int, uint8_t); +int livedump_start_vnode(struct vnode *, int, uint8_t); /* Live minidump events */ typedef void (*livedump_start_fn)(void *arg, int *errorp); diff --git a/lib/libc/include/generic-freebsd/sys/ktls.h b/lib/libc/include/generic-freebsd/sys/ktls.h index 2ee0e354732aeefd23cc2c0ee52f8d4b46dc5337..62ce2ba82ed3efaa694ea9e188bb1c184f4c91a8 100644 --- a/lib/libc/include/generic-freebsd/sys/ktls.h +++ b/lib/libc/include/generic-freebsd/sys/ktls.h @@ -28,8 +28,11 @@ #define _SYS_KTLS_H_ #ifdef _KERNEL +#include #include #include + +#include #endif struct tls_record_layer { @@ -142,6 +145,28 @@ struct tls_get_record { uint16_t tls_length; }; +#define XKTLS_SESSION_IV_BUF_LEN 32 +struct xktls_session_onedir { + uint64_t gen; + uint64_t rsrv1[8]; + uint32_t rsrv2[8]; + uint8_t iv[XKTLS_SESSION_IV_BUF_LEN]; + int cipher_algorithm; + int auth_algorithm; + uint16_t cipher_key_len; + uint16_t iv_len; + uint16_t auth_key_len; + uint16_t max_frame_len; + uint8_t tls_vmajor; + uint8_t tls_vminor; + uint8_t tls_hlen; + uint8_t tls_tlen; + uint8_t tls_bs; + uint8_t flags; + uint16_t drv_st_len; + char ifnet[16]; /* IFNAMSIZ */ +}; + #ifdef _KERNEL struct tls_session_params { @@ -174,6 +199,7 @@ struct m_snd_tag; struct mbuf; struct sockbuf; struct socket; +struct sockopt; struct ktls_session { struct ktls_ocf_session *ocf_session; @@ -202,6 +228,8 @@ struct ktls_session { /* Used to destroy any kTLS session */ struct task destroy_task; + + uint64_t gen; } __aligned(CACHE_LINE_SIZE); extern unsigned int ktls_ifnet_max_rexmit_pct; @@ -213,27 +241,29 @@ typedef enum { } ktls_mbuf_crypto_st_t; void ktls_check_rx(struct sockbuf *sb); -ktls_mbuf_crypto_st_t ktls_mbuf_crypto_state(struct mbuf *mb, int offset, int len); +void ktls_cleanup_tls_enable(struct tls_enable *tls); +int ktls_copyin_tls_enable(struct sockopt *sopt, struct tls_enable *tls); void ktls_disable_ifnet(void *arg); int ktls_enable_rx(struct socket *so, struct tls_enable *en); int ktls_enable_tx(struct socket *so, struct tls_enable *en); +void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count); +void ktls_enqueue_to_free(struct mbuf *m); void ktls_destroy(struct ktls_session *tls); void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt, uint8_t record_type); -bool ktls_permit_empty_frames(struct ktls_session *tls); -void ktls_seq(struct sockbuf *sb, struct mbuf *m); -void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count); -void ktls_enqueue_to_free(struct mbuf *m); int ktls_get_rx_mode(struct socket *so, int *modep); -int ktls_set_tx_mode(struct socket *so, int mode); int ktls_get_tx_mode(struct socket *so, int *modep); int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq); void ktls_input_ifp_mismatch(struct sockbuf *sb, struct ifnet *ifp); -int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls); +ktls_mbuf_crypto_st_t ktls_mbuf_crypto_state(struct mbuf *mb, int offset, int len); #ifdef RATELIMIT int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate); #endif +int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls); bool ktls_pending_rx_info(struct sockbuf *sb, uint64_t *seqnop, size_t *residp); +bool ktls_permit_empty_frames(struct ktls_session *tls); +void ktls_seq(struct sockbuf *sb, struct mbuf *m); +int ktls_set_tx_mode(struct socket *so, int mode); static inline struct ktls_session * ktls_hold(struct ktls_session *tls) @@ -252,5 +282,10 @@ ktls_free(struct ktls_session *tls) ktls_destroy(tls); } +void ktls_session_to_xktls_onedir(const struct ktls_session *ks, + bool export_keys, struct xktls_session_onedir *xktls_od); +void ktls_session_copy_keys(const struct ktls_session *ktls, + uint8_t *data, size_t *sz); + #endif /* !_KERNEL */ #endif /* !_SYS_KTLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/ktrace.h b/lib/libc/include/generic-freebsd/sys/ktrace.h index 8f57b9007cc6357a7ec0c8b203a0ea880a2162b2..e4596a212ddf6d41c756d05f129179398a913733 100644 --- a/lib/libc/include/generic-freebsd/sys/ktrace.h +++ b/lib/libc/include/generic-freebsd/sys/ktrace.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ktrace.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_KTRACE_H_ @@ -38,6 +36,7 @@ #include #include #include +#include #include /* @@ -89,10 +88,9 @@ struct ktr_header { * is the public interface. */ #define KTRCHECK(td, type) ((td)->td_proc->p_traceflag & (1 << type)) -#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type)))) -#define KTRCHECKDRAIN(td) (!(STAILQ_EMPTY(&(td)->td_proc->p_ktr))) +#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type)))) #define KTRUSERRET(td) do { \ - if (__predict_false(KTRCHECKDRAIN(td))) \ + if (__predict_false(!STAILQ_EMPTY_ATOMIC(&(td)->td_proc->p_ktr))) \ ktruserret(td); \ } while (0) @@ -265,6 +263,24 @@ struct ktr_struct_array { */ }; +/* + * KTR_ARGS - arguments of execve() + */ +#define KTR_ARGS 16 + +/* + * KTR_ENVS - environment variables of execve() + */ +#define KTR_ENVS 17 + +/* + * KTR_EXTERR - extended error reported + */ +#define KTR_EXTERR 18 +struct ktr_exterr { + struct uexterror ue; +}; + /* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. @@ -297,6 +313,9 @@ struct ktr_struct_array { #define KTRFAC_FAULT (1< #include #ifdef _KERNEL #include #endif +#include #ifndef LIBKERN_INLINE #define LIBKERN_INLINE static __inline @@ -189,6 +187,49 @@ flsll(long long mask) 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask)); } +static __inline __pure2 int +ilog2_int(int n) +{ + + KASSERT(n != 0, ("ilog argument must be nonzero")); + return (8 * sizeof(n) - 1 - __builtin_clz((u_int)n)); +} + +static __inline __pure2 int +ilog2_long(long n) +{ + + KASSERT(n != 0, ("ilog argument must be nonzero")); + return (8 * sizeof(n) - 1 - __builtin_clzl((u_long)n)); +} + +static __inline __pure2 int +ilog2_long_long(long long n) +{ + + KASSERT(n != 0, ("ilog argument must be nonzero")); + return (8 * sizeof(n) - 1 - + __builtin_clzll((unsigned long long)n)); +} + +#define ilog2_var(n) \ + _Generic((n), \ + default: ilog2_int, \ + long: ilog2_long, \ + unsigned long: ilog2_long, \ + long long: ilog2_long_long, \ + unsigned long long: ilog2_long_long \ + )(n) + +#define ilog2_const(n) \ + (8 * (int)sizeof(unsigned long long) - 1 - \ + __builtin_clzll(n)) + +#define ilog2(n) (__builtin_constant_p(n) ? ilog2_const(n) : ilog2_var(n)) +#define rounddown_pow_of_two(n) ((__typeof(n))1 << ilog2(n)) +#define order_base_2(n) ilog2(2*(n)-1) +#define roundup_pow_of_two(n) ((__typeof(n))1 << order_base_2(n)) + #define bitcount64(x) __bitcount64((uint64_t)(x)) #define bitcount32(x) __bitcount32((uint32_t)(x)) #define bitcount16(x) __bitcount16((uint16_t)(x)) @@ -293,4 +334,10 @@ signed_extend32(uint32_t bitmap, int lsb, int width) #define FNM_IGNORECASE FNM_CASEFOLD #define FNM_FILE_NAME FNM_PATHNAME +#if !defined(_KERNEL) && __has_include() +#include /* __ssp_real */ +#else +#define __ssp_real(fun) fun +#endif + #endif /* !_SYS_LIBKERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/link_elf.h b/lib/libc/include/generic-freebsd/sys/link_elf.h index fc66b1dd5fc42c8a57310fd3ca282ff22afea18c..531e56504b771d2a0d00b83365e7f7a8bea40fc6 100644 --- a/lib/libc/include/generic-freebsd/sys/link_elf.h +++ b/lib/libc/include/generic-freebsd/sys/link_elf.h @@ -93,10 +93,12 @@ struct dl_phdr_info __BEGIN_DECLS typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *); -extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *); +int dl_iterate_phdr(__dl_iterate_hdr_callback, void *); int _rtld_addr_phdr(const void *, struct dl_phdr_info *); int _rtld_get_stack_prot(void); int _rtld_is_dlopened(void *); +const char *rtld_get_var(const char *name); +int rtld_set_var(const char *name, const char *val); #ifdef __ARM_EABI__ void * dl_unwind_find_exidx(const void *, int *); diff --git a/lib/libc/include/generic-freebsd/sys/linker.h b/lib/libc/include/generic-freebsd/sys/linker.h index 526ac3765c364e8b3e7b337b480956118ecb3309..ba68128470ef2ac52a687d96aa9cf345945cb00f 100644 --- a/lib/libc/include/generic-freebsd/sys/linker.h +++ b/lib/libc/include/generic-freebsd/sys/linker.h @@ -29,6 +29,8 @@ #ifndef _SYS_LINKER_H_ #define _SYS_LINKER_H_ +#include + #ifdef _KERNEL #include @@ -130,6 +132,12 @@ typedef int linker_predicate_t(linker_file_t, void *); */ extern linker_file_t linker_kernel_file; +/* + * Special symbol which will be replaced by a reference to the linker_file_t + * of the module it is used in. + */ +extern linker_file_t __this_linker_file; + /* * Obtain a reference to a module, loading it if required. */ @@ -212,6 +220,14 @@ void linker_kldload_unbusy(int flags); #endif /* _KERNEL */ +/* + * ELF file types + */ +#define KERNTYPE_MB "elf multiboot kernel" +#define KERNTYPE "elf kernel" +#define MODTYPE_OBJ "elf obj module" +#define MODTYPE "elf module" + /* * Module information subtypes */ @@ -264,7 +280,10 @@ void linker_kldload_unbusy(int flags); * Module lookup */ extern vm_offset_t preload_addr_relocate; -extern caddr_t preload_metadata; +extern caddr_t preload_metadata, preload_kmdp; +extern const char preload_modtype[]; +extern const char preload_kerntype[]; +extern const char preload_modtype_obj[]; extern void * preload_fetch_addr(caddr_t _mod); extern size_t preload_fetch_size(caddr_t _mod); @@ -272,6 +291,7 @@ extern caddr_t preload_search_by_name(const char *_name); extern caddr_t preload_search_by_type(const char *_type); extern caddr_t preload_search_next_name(caddr_t _base); extern caddr_t preload_search_info(caddr_t _mod, int _inf); +extern void preload_initkmdp(bool _fatal); extern void preload_delete_name(const char *_name); extern void preload_bootstrap_relocate(vm_offset_t _offset); extern void preload_dump(void); @@ -304,7 +324,7 @@ int elf_reloc_local(linker_file_t _lf, Elf_Addr base, const void *_rel, Elf_Addr elf_relocaddr(linker_file_t _lf, Elf_Addr addr); const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Size _symidx); const char *elf_get_symname(linker_file_t _lf, Elf_Size _symidx); -void link_elf_ireloc(caddr_t kmdp); +void link_elf_ireloc(void); #if defined(__aarch64__) || defined(__amd64__) int elf_reloc_late(linker_file_t _lf, Elf_Addr base, const void *_rel, @@ -325,6 +345,9 @@ typedef struct linker_ctf { } linker_ctf_t; int linker_ctf_get(linker_file_t, linker_ctf_t *); +int linker_ctf_lookup_sym_ddb(const char *symname, c_linker_sym_t *sym, + linker_ctf_t *lc); +int linker_ctf_lookup_typename_ddb(linker_ctf_t *lc, const char *typename); int elf_cpu_load_file(linker_file_t); int elf_cpu_unload_file(linker_file_t); diff --git a/lib/libc/include/generic-freebsd/sys/lock.h b/lib/libc/include/generic-freebsd/sys/lock.h index 2c153b0132cac83010abeb2fe7bc6f977812fded..c6f38c3463964493c14b600c06f4ae9bcf60e9a7 100644 --- a/lib/libc/include/generic-freebsd/sys/lock.h +++ b/lib/libc/include/generic-freebsd/sys/lock.h @@ -66,6 +66,7 @@ struct lock_class { int (*lc_owner)(const struct lock_object *lock, struct thread **owner); uintptr_t (*lc_unlock)(struct lock_object *lock); + int (*lc_trylock)(struct lock_object *lock, uintptr_t how); }; #define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ diff --git a/lib/libc/include/generic-freebsd/sys/lockf.h b/lib/libc/include/generic-freebsd/sys/lockf.h index 035099886ebb1afbebd91bf5dc928ea5f1271ef0..58e197bffb376845e2aab66f417af8e27ac71755 100644 --- a/lib/libc/include/generic-freebsd/sys/lockf.h +++ b/lib/libc/include/generic-freebsd/sys/lockf.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)lockf.h 8.1 (Berkeley) 6/11/93 */ #ifndef _SYS_LOCKF_H_ diff --git a/lib/libc/include/generic-freebsd/sys/lockmgr.h b/lib/libc/include/generic-freebsd/sys/lockmgr.h index 76f18a80bebee43a5f8e50324dd431e28ff5c2f5..cbed90ce98cc3bbd86c6a3f66d7897d7a0fe3bc1 100644 --- a/lib/libc/include/generic-freebsd/sys/lockmgr.h +++ b/lib/libc/include/generic-freebsd/sys/lockmgr.h @@ -130,6 +130,10 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk, LOCK_FILE, LOCK_LINE) #define lockmgr_disown(lk) \ _lockmgr_disown((lk), LOCK_FILE, LOCK_LINE) +#define lockmgr_disowned_v(v) \ + (LK_HOLDER((v)) == LK_KERNPROC) +#define lockmgr_disowned(lk) \ + lockmgr_disowned_v(lockmgr_read_value((lk))) #define lockmgr_recursed_v(v) \ (v & LK_WRITER_RECURSED) #define lockmgr_recursed(lk) \ diff --git a/lib/libc/include/generic-freebsd/sys/mac.h b/lib/libc/include/generic-freebsd/sys/mac.h index 8dedb9f17dff1eafe52b937aa826223336d6d035..11c38b55668e3db045fbd6decf84f8665b784166 100644 --- a/lib/libc/include/generic-freebsd/sys/mac.h +++ b/lib/libc/include/generic-freebsd/sys/mac.h @@ -47,6 +47,13 @@ #ifndef _SYS_MAC_H_ #define _SYS_MAC_H_ +#include + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + #ifndef _POSIX_MAC #define _POSIX_MAC #endif @@ -72,6 +79,13 @@ typedef struct mac *mac_t; #ifndef _KERNEL +#include /* For __BEGIN_DECLS and __END_DECLS. */ + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; /* process id */ +#define _PID_T_DECLARED +#endif + /* * Location of the userland MAC framework configuration file. mac.conf * set defaults for MAC-aware applications. diff --git a/lib/libc/include/generic-freebsd/sys/malloc.h b/lib/libc/include/generic-freebsd/sys/malloc.h index ec13eb3d2ca0925146936744f84c2ccd74e20db0..ee47ef204162d514588e095a7ea5ffee9bfe71cf 100644 --- a/lib/libc/include/generic-freebsd/sys/malloc.h +++ b/lib/libc/include/generic-freebsd/sys/malloc.h @@ -29,8 +29,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)malloc.h 8.5 (Berkeley) 5/3/95 */ #ifndef _SYS_MALLOC_H_ @@ -62,8 +60,9 @@ #define M_BESTFIT 0x2000 /* only for vmem, low fragmentation */ #define M_EXEC 0x4000 /* allocate executable space */ #define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */ +#define M_NEVERFREED 0x10000 /* chunk will never get freed */ -#define M_VERSION 2020110501 +#define M_VERSION 2024073001 /* * Two malloc type structures are present: malloc_type, which is used by a @@ -159,6 +158,9 @@ struct malloc_type_header { MALLOC_DECLARE(M_CACHE); MALLOC_DECLARE(M_DEVBUF); +MALLOC_DECLARE(M_PARGS); +MALLOC_DECLARE(M_SESSION); +MALLOC_DECLARE(M_SUBPROC); MALLOC_DECLARE(M_TEMP); /* @@ -176,7 +178,8 @@ extern struct mtx malloc_mtx; */ typedef void malloc_type_list_func_t(struct malloc_type *, void *); -void contigfree(void *addr, unsigned long size, struct malloc_type *type); +/* contigfree(9) is deprecated. */ +void contigfree(void *addr, unsigned long, struct malloc_type *type); void *contigmalloc(unsigned long size, struct malloc_type *type, int flags, vm_paddr_t low, vm_paddr_t high, unsigned long alignment, vm_paddr_t boundary) __malloc_like __result_use_check diff --git a/lib/libc/include/generic-freebsd/sys/mbuf.h b/lib/libc/include/generic-freebsd/sys/mbuf.h index 50ad174d57f66c2db86b4a2da1df63fdd8b77b7b..2fff2e53e9e681b27566ec5c27c4b65851330a18 100644 --- a/lib/libc/include/generic-freebsd/sys/mbuf.h +++ b/lib/libc/include/generic-freebsd/sys/mbuf.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 */ #ifndef _SYS_MBUF_H_ @@ -596,6 +594,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ #define EXT_MBUF 7 /* external mbuf reference */ #define EXT_RXRING 8 /* data in NIC receive ring */ +#define EXT_CTL 9 /* buffer from a ctl(4) backend */ #define EXT_VENDOR1 224 /* for vendor-internal use */ #define EXT_VENDOR2 225 /* for vendor-internal use */ @@ -642,16 +641,15 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) /* * Flags indicating checksum, segmentation and other offload work to be - * done, or already done, by hardware or lower layers. It is split into - * separate inbound and outbound flags. + * done, or already done, by hardware or lower layers. * - * Outbound flags that are set by upper protocol layers requesting lower + * Flags that are set by upper protocol layers requesting lower * layers, or ideally the hardware, to perform these offloading tasks. - * For outbound packets this field and its flags can be directly tested - * against ifnet if_hwassist. Note that the outbound and the inbound flags do - * not collide right now but they could be allowed to (as long as the flags are - * scrubbed appropriately when the direction of an mbuf changes). CSUM_BITS - * would also have to split into CSUM_BITS_TX and CSUM_BITS_RX. + * Before passing packets to a network interface this field and its flags can + * be directly tested against ifnet if_hwassist. Note that the flags + * CSUM_IP_SCTP, CSUM_IP_TCP, and CSUM_IP_UDP can appear on input processing + * of SCTP, TCP, and UDP. In such a case the checksum will not be computed or + * validated by SCTP, TCP, or TCP, since the packet has not been on the wire. * * CSUM_INNER_ is the same as CSUM_ but it applies to the inner frame. * The CSUM_ENCAP_ bits identify the outer encapsulation. @@ -680,7 +678,7 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) #define CSUM_ENCAP_VXLAN 0x00040000 /* VXLAN outer encapsulation */ #define CSUM_ENCAP_RSVD1 0x00080000 -/* Inbound checksum support where the checksum was verified by hardware. */ +/* Flags used to indicate that the checksum was verified by hardware. */ #define CSUM_INNER_L3_CALC 0x00100000 #define CSUM_INNER_L3_VALID 0x00200000 #define CSUM_INNER_L4_CALC 0x00400000 @@ -809,12 +807,12 @@ void mb_dupcl(struct mbuf *, struct mbuf *); void mb_free_ext(struct mbuf *); void mb_free_extpg(struct mbuf *); void mb_free_mext_pgs(struct mbuf *); -struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t); +struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t, int); struct mbuf *mb_alloc_ext_plus_pages(int, int); struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int, struct mbuf **); int mb_unmapped_compress(struct mbuf *m); -struct mbuf *mb_unmapped_to_ext(struct mbuf *m); +int mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres); void mb_free_notready(struct mbuf *m, int count); void m_adj(struct mbuf *, int); void m_adj_decap(struct mbuf *, int); @@ -886,9 +884,11 @@ m_gettype(int size) case MCLBYTES: type = EXT_CLUSTER; break; +#if MJUMPAGESIZE != MCLBYTES case MJUMPAGESIZE: type = EXT_JUMBOP; break; +#endif case MJUM9BYTES: type = EXT_JUMBO9; break; @@ -934,9 +934,11 @@ m_getzone(int size) case MCLBYTES: zone = zone_clust; break; +#if MJUMPAGESIZE != MCLBYTES case MJUMPAGESIZE: zone = zone_jumbop; break; +#endif case MJUM9BYTES: zone = zone_jumbo9; break; @@ -1056,9 +1058,11 @@ m_cljset(struct mbuf *m, void *cl, int type) case EXT_CLUSTER: size = MCLBYTES; break; +#if MJUMPAGESIZE != MCLBYTES case EXT_JUMBOP: size = MJUMPAGESIZE; break; +#endif case EXT_JUMBO9: size = MJUM9BYTES; break; @@ -1110,7 +1114,7 @@ static inline u_int m_extrefcnt(struct mbuf *m) { - KASSERT(m->m_flags & M_EXT, ("%s: M_EXT missing", __func__)); + KASSERT(m->m_flags & M_EXT, ("%s: M_EXT missing for %p", __func__, m)); return ((m->m_ext.ext_flags & EXT_FLAG_EMBREF) ? m->m_ext.ext_count : *m->m_ext.ext_cnt); @@ -1142,13 +1146,13 @@ m_extrefcnt(struct mbuf *m) /* Check if the supplied mbuf has a packet header, or else panic. */ #define M_ASSERTPKTHDR(m) \ KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \ - ("%s: no mbuf packet header!", __func__)) + ("%s: no mbuf %p packet header!", __func__, (m))) /* Check if the supplied mbuf has no send tag, or else panic. */ #define M_ASSERT_NO_SND_TAG(m) \ KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR && \ ((m)->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0, \ - ("%s: receive mbuf has send tag!", __func__)) + ("%s: receive mbuf %p has send tag!", __func__, (m))) /* Check if mbuf is multipage. */ #define M_ASSERTEXTPG(m) \ @@ -1162,7 +1166,7 @@ m_extrefcnt(struct mbuf *m) */ #define M_ASSERTVALID(m) \ KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \ - ("%s: attempted use of a free mbuf!", __func__)) + ("%s: attempted use of a free mbuf %p!", __func__, (m))) /* Check whether any mbuf in the chain is unmapped. */ #ifdef INVARIANTS @@ -1207,12 +1211,9 @@ m_extrefcnt(struct mbuf *m) static __inline void m_align(struct mbuf *m, int len) { -#ifdef INVARIANTS - const char *msg = "%s: not a virgin mbuf"; -#endif int adjust; - - KASSERT(m->m_data == M_START(m), (msg, __func__)); + KASSERT(m->m_data == M_START(m), + ("%s: not a virgin mbuf %p", __func__, m)); adjust = M_SIZE(m) - len; m->m_data += adjust &~ (sizeof(long)-1); @@ -1387,6 +1388,9 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ #define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */ #define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */ #define PACKET_TAG_PF_REASSEMBLED 31 +#define PACKET_TAG_IPSEC_ACCEL_OUT 32 /* IPSEC accel out */ +#define PACKET_TAG_IPSEC_ACCEL_IN 33 /* IPSEC accel in */ +#define PACKET_TAG_OVPN 34 /* if_ovpn */ /* Specific cookies and tags. */ @@ -1530,14 +1534,16 @@ m_free(struct mbuf *m) static __inline int rt_m_getfib(struct mbuf *m) { - KASSERT(m->m_flags & M_PKTHDR , ("Attempt to get FIB from non header mbuf.")); + KASSERT(m->m_flags & M_PKTHDR, + ("%s: Attempt to get FIB from non header mbuf %p", __func__, m)); return (m->m_pkthdr.fibnum); } #define M_GETFIB(_m) rt_m_getfib(_m) #define M_SETFIB(_m, _fib) do { \ - KASSERT((_m)->m_flags & M_PKTHDR, ("Attempt to set FIB on non header mbuf.")); \ + KASSERT((_m)->m_flags & M_PKTHDR, \ + ("%s: Attempt to set FIB on non header mbuf %p", __func__, (_m))); \ ((_m)->m_pkthdr.fibnum) = (_fib); \ } while (0) @@ -1559,6 +1565,10 @@ uint32_t m_infiniband_tcpip_hash(const uint32_t, const struct mbuf *, uint32_t); #define M_PROFILE(m) #endif +/* + * Structure describing a packet queue: mbufs linked by m_stailqpkt. + * Does accounting of number of packets and has a cap. + */ struct mbufq { STAILQ_HEAD(, mbuf) mq_head; int mq_len; @@ -1676,14 +1686,137 @@ mbufq_concat(struct mbufq *mq_dst, struct mbufq *mq_src) mq_src->mq_len = 0; } +/* + * Structure describing a chain of mbufs linked by m_stailq, also tracking + * the pointer to the last. Also does accounting of data length and memory + * usage. + * To be used as an argument to mbuf chain allocation and manipulation KPIs, + * and can be allocated on the stack of a caller. Kernel facilities may use + * it internally as a most simple implementation of a stream data buffer. + */ +struct mchain { + STAILQ_HEAD(, mbuf) mc_q; + u_int mc_len; + u_int mc_mlen; +}; + +#define MCHAIN_INITIALIZER(mc) \ + (struct mchain){ .mc_q = STAILQ_HEAD_INITIALIZER((mc)->mc_q) } + +static inline struct mbuf * +mc_first(struct mchain *mc) +{ + return (STAILQ_FIRST(&mc->mc_q)); +} + +static inline struct mbuf * +mc_last(struct mchain *mc) +{ + return (STAILQ_LAST(&mc->mc_q, mbuf, m_stailq)); +} + +static inline bool +mc_empty(struct mchain *mc) +{ + return (STAILQ_EMPTY(&mc->mc_q)); +} + +/* Account addition of m to mc. */ +static inline void +mc_inc(struct mchain *mc, struct mbuf *m) +{ + mc->mc_len += m->m_len; + mc->mc_mlen += MSIZE; + if (m->m_flags & M_EXT) + mc->mc_mlen += m->m_ext.ext_size; +} + +/* Account removal of m from mc. */ +static inline void +mc_dec(struct mchain *mc, struct mbuf *m) +{ + MPASS(mc->mc_len >= m->m_len); + mc->mc_len -= m->m_len; + MPASS(mc->mc_mlen >= MSIZE); + mc->mc_mlen -= MSIZE; + if (m->m_flags & M_EXT) { + MPASS(mc->mc_mlen >= m->m_ext.ext_size); + mc->mc_mlen -= m->m_ext.ext_size; + } +} + +/* + * Get mchain from a classic mbuf chain linked by m_next. Two hacks here: + * we use the fact that m_next is alias to m_stailq, we use internal queue(3) + * fields. + */ +static inline void +mc_init_m(struct mchain *mc, struct mbuf *m) +{ + struct mbuf *last; + + STAILQ_FIRST(&mc->mc_q) = m; + mc->mc_len = mc->mc_mlen = 0; + STAILQ_FOREACH(m, &mc->mc_q, m_stailq) { + mc_inc(mc, m); + last = m; + } + mc->mc_q.stqh_last = &STAILQ_NEXT(last, m_stailq); +} + +static inline void +mc_freem(struct mchain *mc) +{ + if (!mc_empty(mc)) + m_freem(mc_first(mc)); +} + +static inline void +mc_prepend(struct mchain *mc, struct mbuf *m) +{ + STAILQ_INSERT_HEAD(&mc->mc_q, m, m_stailq); + mc_inc(mc, m); +} + +static inline void +mc_append(struct mchain *mc, struct mbuf *m) +{ + STAILQ_INSERT_TAIL(&mc->mc_q, m, m_stailq); + mc_inc(mc, m); +} + +static inline void +mc_concat(struct mchain *head, struct mchain *tail) +{ + STAILQ_CONCAT(&head->mc_q, &tail->mc_q); + head->mc_len += tail->mc_len; + head->mc_mlen += tail->mc_mlen; + tail->mc_len = tail->mc_mlen = 0; +} + +/* + * Note: STAILQ_REMOVE() is expensive. mc_remove_after() needs to be provided + * as long as there consumers that would benefit from it. + */ +static inline void +mc_remove(struct mchain *mc, struct mbuf *m) +{ + STAILQ_REMOVE(&mc->mc_q, m, mbuf, m_stailq); + mc_dec(mc, m); +} + +int mc_get(struct mchain *, u_int, int, short, int); +int mc_split(struct mchain *, struct mchain *, u_int, int); +int mc_uiotomc(struct mchain *, struct uio *, u_int, u_int, int, int); + #ifdef _SYS_TIMESPEC_H_ static inline void mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts) { - KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); + M_ASSERTPKTHDR(m); KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, - ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + ("%s: mbuf %p no M_TSTMP or M_TSTMP_LRO", __func__, m)); ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000; } @@ -1693,9 +1826,9 @@ static inline void mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv) { - KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m)); + M_ASSERTPKTHDR(m); KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, - ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m)); + ("%s: mbuf %p no M_TSTMP or M_TSTMP_LRO", __func__, m)); tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000; tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000; } diff --git a/lib/libc/include/generic-freebsd/sys/md4.h b/lib/libc/include/generic-freebsd/sys/md4.h index 3173070ad25ba83363e0eeaa9ebd7cf9611f995b..d42a52780ac8011a7bdf3506ee3336d39d3d3375 100644 --- a/lib/libc/include/generic-freebsd/sys/md4.h +++ b/lib/libc/include/generic-freebsd/sys/md4.h @@ -25,8 +25,8 @@ documentation and/or software. */ -#ifndef _MD4_H_ -#define _MD4_H_ +#ifndef _SYS_MD4_H_ +#define _SYS_MD4_H_ /* MD4 context. */ typedef struct MD4Context { u_int32_t state[4]; /* state (ABCD) */ @@ -36,6 +36,43 @@ typedef struct MD4Context { #include +#ifndef _KERNEL + +/* Ensure libmd symbols do not clash with libcrypto */ + +#ifndef MD4Init +#define MD4Init _libmd_MD4Init +#endif +#ifndef MD4Update +#define MD4Update _libmd_MD4Update +#endif +#ifndef MD4Pad +#define MD4Pad _libmd_MD4Pad +#endif +#ifndef MD4Final +#define MD4Final _libmd_MD4Final +#endif +#ifndef MD4End +#define MD4End _libmd_MD4End +#endif +#ifndef MD4Fd +#define MD4Fd _libmd_MD4Fd +#endif +#ifndef MD4FdChunk +#define MD4FdChunk _libmd_MD4FdChunk +#endif +#ifndef MD4File +#define MD4File _libmd_MD4File +#endif +#ifndef MD4FileChunk +#define MD4FileChunk _libmd_MD4FileChunk +#endif +#ifndef MD4Data +#define MD4Data _libmd_MD4Data +#endif + +#endif + __BEGIN_DECLS void MD4Init(MD4_CTX *); void MD4Update(MD4_CTX *, const unsigned char *, unsigned int); @@ -43,9 +80,12 @@ void MD4Pad(MD4_CTX *); void MD4Final(unsigned char [__min_size(16)], MD4_CTX *); #ifndef _KERNEL char * MD4End(MD4_CTX *, char *); +char * MD4Fd(int, char *); +char * MD4FdChunk(int, char *, off_t, off_t); char * MD4File(const char *, char *); -char * MD4Data(const unsigned char *, unsigned int, char *); +char * MD4FileChunk(const char *, char *, off_t, off_t); +char * MD4Data(const void *, unsigned int, char *); #endif __END_DECLS -#endif /* _MD4_H_ */ \ No newline at end of file +#endif /* _SYS_MD4_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/md5.h b/lib/libc/include/generic-freebsd/sys/md5.h index 303719c8334225c493906a337bdf67fcf57fdd33..fa83112a01b2ea5f0ba0e830aef218abbcd07561 100644 --- a/lib/libc/include/generic-freebsd/sys/md5.h +++ b/lib/libc/include/generic-freebsd/sys/md5.h @@ -29,6 +29,8 @@ documentation and/or software. #ifndef _SYS_MD5_H_ #define _SYS_MD5_H_ +#include + #define MD5_BLOCK_LENGTH 64 #define MD5_DIGEST_LENGTH 16 #define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1) @@ -40,6 +42,46 @@ typedef struct MD5Context { unsigned char buffer[64]; /* input buffer */ } MD5_CTX; +#ifndef _KERNEL + +/* Ensure libmd symbols do not clash with libcrypto */ + +#ifndef MD5Init +#define MD5Init _libmd_MD5Init +#endif +#ifndef MD5Update +#define MD5Update _libmd_MD5Update +#endif +#ifndef MD5Pad +#define MD5Pad _libmd_MD5Pad +#endif +#ifndef MD5Final +#define MD5Final _libmd_MD5Final +#endif +#ifndef MD5Transform +#define MD5Transform _libmd_MD5Transform +#endif +#ifndef MD5End +#define MD5End _libmd_MD5End +#endif +#ifndef MD5Fd +#define MD5Fd _libmd_MD5Fd +#endif +#ifndef MD5FdChunk +#define MD5FdChunk _libmd_MD5FdChunk +#endif +#ifndef MD5File +#define MD5File _libmd_MD5File +#endif +#ifndef MD5FileChunk +#define MD5FileChunk _libmd_MD5FileChunk +#endif +#ifndef MD5Data +#define MD5Data _libmd_MD5Data +#endif + +#endif + #include __BEGIN_DECLS diff --git a/lib/libc/include/generic-freebsd/sys/mdioctl.h b/lib/libc/include/generic-freebsd/sys/mdioctl.h index 68e4b29b9b3449b3468fc48c40aa345ba120f5e2..1783748f73608b5283558a039e16f69e50874f55 100644 --- a/lib/libc/include/generic-freebsd/sys/mdioctl.h +++ b/lib/libc/include/generic-freebsd/sys/mdioctl.h @@ -34,10 +34,6 @@ * SUCH DAMAGE. * * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$ - * - * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 - * - * From: src/sys/sys/vnioctl.h,v 1.4 */ #ifndef _SYS_MDIOCTL_H_ diff --git a/lib/libc/include/generic-freebsd/sys/memdesc.h b/lib/libc/include/generic-freebsd/sys/memdesc.h index 69fdd50c911de63bf21d2f529248e0eb1ba38783..8d591367a4b8467fe0bfadb0c34d0bee2c74d3d9 100644 --- a/lib/libc/include/generic-freebsd/sys/memdesc.h +++ b/lib/libc/include/generic-freebsd/sys/memdesc.h @@ -163,4 +163,40 @@ void memdesc_copyback(struct memdesc *mem, int off, int size, const void *src); void memdesc_copydata(struct memdesc *mem, int off, int size, void *dst); +/* + * This routine constructs a chain of M_EXT mbufs backed by a data + * buffer described by a memory descriptor. Some buffers may require + * multiple mbufs. For memory descriptors using unmapped storage + * (e.g. memdesc_vmpages), M_EXTPG mbufs are used. + * + * Since memory descriptors are not an actual buffer, just a + * description of the buffer, the caller is required to supply a + * couple of helper routines to manage allocation of the raw mbufs and + * associate them with a reference to the underlying buffer. + * + * The memdesc_alloc_ext_mbuf_t callback is passed the callback + * argument as its first argument, the how flag as its second + * argument, and the pointer and length of a KVA buffer. This + * callback should allocate an mbuf for the KVA buffer, either by + * making a copy of the data or using m_extaddref(). + * + * The memdesc_alloc_extpg_mbuf_t callback is passed the callback + * argument as its first argument and the how flag as its second + * argument. It should return an empty mbuf allocated by + * mb_alloc_ext_pgs. + * + * If either of the callbacks returns NULL, any partially allocated + * chain is freed and this routine returns NULL. + * + * If can_truncate is true, then this function might return a short + * chain to avoid gratuitously splitting up a page. + */ +typedef struct mbuf *memdesc_alloc_ext_mbuf_t(void *, int, void *, size_t); +typedef struct mbuf *memdesc_alloc_extpg_mbuf_t(void *, int); + +struct mbuf *memdesc_alloc_ext_mbufs(struct memdesc *mem, + memdesc_alloc_ext_mbuf_t *ext_alloc, + memdesc_alloc_extpg_mbuf_t *extpg_alloc, void *cb_arg, int how, + size_t offset, size_t len, size_t *actual_len, bool can_truncate); + #endif /* _SYS_MEMDESC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/mman.h b/lib/libc/include/generic-freebsd/sys/mman.h index 9b2c0a0dc98d12f2fd7772f864bde19c104449e6..d64691cd6e38c85d3232235ea362e7a2aca0a309 100644 --- a/lib/libc/include/generic-freebsd/sys/mman.h +++ b/lib/libc/include/generic-freebsd/sys/mman.h @@ -27,12 +27,10 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mman.h 8.2 (Berkeley) 1/9/95 */ #ifndef _SYS_MMAN_H_ -#define _SYS_MMAN_H_ +#define _SYS_MMAN_H_ #include #include @@ -41,10 +39,10 @@ /* * Inheritance for minherit() */ -#define INHERIT_SHARE 0 -#define INHERIT_COPY 1 -#define INHERIT_NONE 2 -#define INHERIT_ZERO 3 +#define INHERIT_SHARE 0 +#define INHERIT_COPY 1 +#define INHERIT_NONE 2 +#define INHERIT_ZERO 3 #endif /* @@ -55,6 +53,8 @@ #define PROT_WRITE 0x02 /* pages can be written */ #define PROT_EXEC 0x04 /* pages can be executed */ #if __BSD_VISIBLE +#define PROT_CHERI0 0x08 +#define PROT_CHERI1 0x10 #define _PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC) #define PROT_EXTRACT(prot) ((prot) & _PROT_ALL) @@ -120,9 +120,9 @@ * Flags provided to shm_rename */ /* Don't overwrite dest, if it exists */ -#define SHM_RENAME_NOREPLACE (1 << 0) +#define SHM_RENAME_NOREPLACE (1 << 0) /* Atomically swap src and dest */ -#define SHM_RENAME_EXCHANGE (1 << 1) +#define SHM_RENAME_EXCHANGE (1 << 1) #endif /* __BSD_VISIBLE */ @@ -130,21 +130,21 @@ /* * Process memory locking */ -#define MCL_CURRENT 0x0001 /* Lock only current memory */ -#define MCL_FUTURE 0x0002 /* Lock all future memory as well */ +#define MCL_CURRENT 0x0001 /* Lock only current memory */ +#define MCL_FUTURE 0x0002 /* Lock all future memory as well */ #endif /* * Error return from mmap() */ -#define MAP_FAILED ((void *)-1) +#define MAP_FAILED ((void *)-1) /* * msync() flags */ #define MS_SYNC 0x0000 /* msync synchronously */ -#define MS_ASYNC 0x0001 /* return immediately */ -#define MS_INVALIDATE 0x0002 /* invalidate all cached data */ +#define MS_ASYNC 0x0001 /* return immediately */ +#define MS_INVALIDATE 0x0002 /* invalidate all cached data */ /* * Advice to madvise @@ -177,7 +177,9 @@ #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ #define MINCORE_SUPER 0x60 /* Page is a "super" page */ -#define MINCORE_PSIND(i) (((i) << 5) & MINCORE_SUPER) /* Page size */ +#define MINCORE_PSIND_SHIFT 5 +#define MINCORE_PSIND(i) (((i) << MINCORE_PSIND_SHIFT) & MINCORE_SUPER) + /* Page size */ /* * Anonymous object constant for shm_open(). @@ -312,7 +314,7 @@ bool shm_largepage(struct shmfd *shmfd); void shm_remove_prison(struct prison *pr); int shm_get_path(struct vm_object *obj, char *path, size_t sz); -extern struct fileops shm_ops; +extern const struct fileops shm_ops; #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) diff --git a/lib/libc/include/generic-freebsd/sys/mount.h b/lib/libc/include/generic-freebsd/sys/mount.h index 325f05c895aa7cf6728af6932a8015692cb0011c..de92bfee36107167ed0a2125faa733f1a88a20d0 100644 --- a/lib/libc/include/generic-freebsd/sys/mount.h +++ b/lib/libc/include/generic-freebsd/sys/mount.h @@ -27,22 +27,24 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mount.h 8.21 (Berkeley) 5/20/95 */ #ifndef _SYS_MOUNT_H_ #define _SYS_MOUNT_H_ +#include #include #include #ifdef _KERNEL -#include #include #include #include #include #include +#elif defined(_WANT_MOUNT) +#include +#include +#include #endif /* @@ -265,6 +267,7 @@ struct mount { int mnt_lazyvnodelistsize; /* (l) # of lazy vnodes */ int mnt_upper_pending; /* (i) # of pending ops on mnt_uppers */ struct lock mnt_explock; /* vfs_export walkers lock */ + struct lock mnt_renamelock; /* renames and O_RESOLVE_BENEATH */ TAILQ_HEAD(, mount_upper_node) mnt_uppers; /* (i) upper mounts over us */ TAILQ_HEAD(, mount_upper_node) mnt_notify; /* (i) upper mounts for notification */ STAILQ_ENTRY(mount) mnt_taskqueue_link; /* (d) our place in deferred unmount list */ @@ -367,6 +370,7 @@ struct mntoptnames { { MNT_RELOAD, "reload" }, \ { MNT_FORCE, "force" }, \ { MNT_SNAPSHOT, "snapshot" }, \ + { MNT_NAMEDATTR, "named attributes" }, \ { 0, NULL } #endif @@ -392,6 +396,7 @@ struct mntoptnames { #define MNT_SUJ 0x0000000100000000ULL /* using journaled soft updates */ #define MNT_AUTOMOUNTED 0x0000000200000000ULL /* mounted by automountd(8) */ #define MNT_UNTRUSTED 0x0000000800000000ULL /* filesys metadata untrusted */ +#define MNT_NAMEDATTR 0x0000020000000000ULL /* named attributes enabled */ /* * NFS export related mount flags. @@ -431,7 +436,7 @@ struct mntoptnames { MNT_IGNORE | MNT_EXPUBLIC | MNT_NOSYMFOLLOW | \ MNT_GJOURNAL | MNT_MULTILABEL | MNT_ACLS | \ MNT_NFS4ACLS | MNT_AUTOMOUNTED | MNT_VERIFIED | \ - MNT_UNTRUSTED) + MNT_UNTRUSTED | MNT_NAMEDATTR) /* Mask of flags that can be updated. */ #define MNT_UPDATEMASK (MNT_NOSUID | MNT_NOEXEC | \ @@ -687,6 +692,8 @@ struct ovfsconf { #define VFCF_SBDRY 0x01000000 /* Stop at Boundary: defer stop requests to kernel->user (AST) transition */ #define VFCF_FILEMOUNT 0x02000000 /* allow mounting files */ +#define VFCF_FILEREVINC 0x04000000 /* va_filerev is incr. by one */ +#define VFCF_FILEREVCT 0x08000000 /* va_filerev is set to ctime */ typedef uint32_t fsctlop_t; @@ -1000,6 +1007,7 @@ struct mntarg *mount_argsu(struct mntarg *ma, const char *name, const void *val, void statfs_scale_blocks(struct statfs *sf, long max_size); struct vfsconf *vfs_byname(const char *); struct vfsconf *vfs_byname_kld(const char *, struct thread *td, int *); +void vfs_unref_vfsconf(struct vfsconf *vfsp); void vfs_mount_destroy(struct mount *); void vfs_event_signal(fsid_t *, u_int32_t, intptr_t); void vfs_freeopts(struct vfsoptlist *opts); diff --git a/lib/libc/include/generic-freebsd/sys/msg.h b/lib/libc/include/generic-freebsd/sys/msg.h index 95c5f376b50dc3bdec5af16f41cb39715c3d084b..db8928fcae5c518b88d25fd64a768257de226856 100644 --- a/lib/libc/include/generic-freebsd/sys/msg.h +++ b/lib/libc/include/generic-freebsd/sys/msg.h @@ -162,9 +162,6 @@ int msgctl(int, int, struct msqid_ds *); int msgget(key_t, int); ssize_t msgrcv(int, void *, size_t, long, int); int msgsnd(int, const void *, size_t, int); -#if __BSD_VISIBLE -int msgsys(int, ...); -#endif __END_DECLS #endif /* !_KERNEL */ diff --git a/lib/libc/include/generic-freebsd/sys/msgbuf.h b/lib/libc/include/generic-freebsd/sys/msgbuf.h index 30d1c17a615c64ca8f2ec3464b1d2e00b523ecda..315b66d7cd5f92e78463dcb8d0798a1b44a9f72a 100644 --- a/lib/libc/include/generic-freebsd/sys/msgbuf.h +++ b/lib/libc/include/generic-freebsd/sys/msgbuf.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_MSGBUF_H_ diff --git a/lib/libc/include/generic-freebsd/sys/mtio.h b/lib/libc/include/generic-freebsd/sys/mtio.h index ec1e61a9fd3521fffeca52b8f7c09a50a5b931a6..9fd6046b6d135f511a24dfc749a6697414fea33a 100644 --- a/lib/libc/include/generic-freebsd/sys/mtio.h +++ b/lib/libc/include/generic-freebsd/sys/mtio.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mtio.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_MTIO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/mutex.h b/lib/libc/include/generic-freebsd/sys/mutex.h index feee6a5d983de5aaf2a6f1b51f3083e821c33920..0fa9cfe14ac3955ae381d8f46574e38697d110b0 100644 --- a/lib/libc/include/generic-freebsd/sys/mutex.h +++ b/lib/libc/include/generic-freebsd/sys/mutex.h @@ -91,7 +91,7 @@ void _mtx_init(volatile uintptr_t *c, const char *name, const char *type, int opts); void _mtx_destroy(volatile uintptr_t *c); -void mtx_sysinit(void *arg); +void mtx_sysinit(const void *arg); int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF); int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line); diff --git a/lib/libc/include/generic-freebsd/sys/namei.h b/lib/libc/include/generic-freebsd/sys/namei.h index 40100bd9256ce3f0914b7b1049fc829e195e39d6..d14b51354f38bf5b53fe62fe95d602d6d8cfb3a2 100644 --- a/lib/libc/include/generic-freebsd/sys/namei.h +++ b/lib/libc/include/generic-freebsd/sys/namei.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)namei.h 8.5 (Berkeley) 1/9/95 */ #ifndef _SYS_NAMEI_H_ @@ -40,6 +38,8 @@ #include #include +#include + enum nameiop { LOOKUP, CREATE, DELETE, RENAME }; struct componentname { @@ -70,7 +70,7 @@ struct nameidata { */ const char *ni_dirp; /* pathname pointer */ enum uio_seg ni_segflg; /* location of pathname */ - cap_rights_t *ni_rightsneeded; /* rights required to look up vnode */ + const cap_rights_t *ni_rightsneeded; /* rights needed to look up vnode */ /* * Arguments to lookup. */ @@ -108,7 +108,12 @@ struct nameidata { * through the VOP interface. */ struct componentname ni_cnd; + + /* Serving RBENEATH. */ struct nameicap_tracker_head ni_cap_tracker; + struct vnode *ni_rbeneath_dpp; + struct mount *ni_nctrack_mnt; + /* * Private helper data for UFS, must be at the end. See * NDINIT_PREFILL(). @@ -152,6 +157,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, #define LOCKSHARED 0x0100 /* Shared lock leaf */ #define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */ #define RBENEATH 0x100000000ULL /* No escape, even tmp, from start dir */ +#define NAMEILOOKUP 0x200000000ULL /* cnp is embedded in nameidata */ #define MODMASK 0xf000001ffULL /* mask of operational modifiers */ /* @@ -159,7 +165,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, */ #define RDONLY 0x00000200 /* lookup with read-only semantics */ #define ISRESTARTED 0x00000400 /* restarted namei */ -/* UNUSED 0x00000800 */ +#define IGNOREWHITEOUT 0x00000800 /* ignore whiteouts, e.g. when checking if a dir is empty */ #define ISWHITEOUT 0x00001000 /* found whiteout */ #define DOWHITEOUT 0x00002000 /* do whiteouts */ #define WILLBEDIR 0x00004000 /* new files will be dirs; allow trailing / */ @@ -172,14 +178,15 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, #define OPENREAD 0x00200000 /* open for reading */ #define OPENWRITE 0x00400000 /* open for writing */ #define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */ -/* UNUSED 0x01000000 */ +#define OPENNAMED 0x01000000 /* opening a named attribute (dir) */ #define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */ #define MAKEENTRY 0x04000000 /* entry is to be added to name cache */ #define ISSYMLINK 0x08000000 /* symlink needs interpretation */ #define ISLASTCN 0x10000000 /* this is last component of pathname */ #define ISDOTDOT 0x20000000 /* current component name is .. */ #define TRAILINGSLASH 0x40000000 /* path ended in a slash */ -#define PARAMASK 0x7ffffe00 /* mask of parameter descriptors */ +#define CREATENAMED 0x80000000 /* create a named attribute dir */ +#define PARAMASK 0xfffffe00 /* mask of parameter descriptors */ /* * Flags which must not be passed in by callers. @@ -194,6 +201,7 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, #define NIRES_ABS 0x00000001 /* Path was absolute */ #define NIRES_STRICTREL 0x00000002 /* Restricted lookup result */ #define NIRES_EMPTYPATH 0x00000004 /* EMPTYPATH used */ +#define NIRES_BENEATH 0x00000008 /* O_RESOLVE_BENEATH is to be inherited */ /* * Flags in ni_lcf, valid for the duration of the namei call. @@ -232,6 +240,10 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, panic("namei data not inited"); \ if (((arg)->ni_debugflags & NAMEI_DBG_HADSTARTDIR) != 0) \ panic("NDREINIT on namei data with NAMEI_DBG_HADSTARTDIR"); \ + if ((arg)->ni_nctrack_mnt != NULL) \ + panic("NDREINIT on namei data with leaked ni_nctrack_mnt"); \ + if (!TAILQ_EMPTY(&(arg)->ni_cap_tracker)) \ + panic("NDREINIT on namei data with leaked ni_cap_tracker"); \ (arg)->ni_debugflags = NAMEI_DBG_INITED; \ } #else @@ -243,12 +255,12 @@ int cache_fplookup(struct nameidata *ndp, enum cache_fpl_status *status, #define NDINIT_ALL(ndp, op, flags, segflg, namep, dirfd, startdir, rightsp) \ do { \ struct nameidata *_ndp = (ndp); \ - cap_rights_t *_rightsp = (rightsp); \ + const cap_rights_t *_rightsp = (rightsp); \ MPASS(_rightsp != NULL); \ NDINIT_PREFILL(_ndp); \ NDINIT_DBG(_ndp); \ _ndp->ni_cnd.cn_nameiop = op; \ - _ndp->ni_cnd.cn_flags = flags; \ + _ndp->ni_cnd.cn_flags = (flags) | NAMEILOOKUP; \ _ndp->ni_segflg = segflg; \ _ndp->ni_dirp = namep; \ _ndp->ni_dirfd = dirfd; \ @@ -256,6 +268,9 @@ do { \ _ndp->ni_resflags = 0; \ filecaps_init(&_ndp->ni_filecaps); \ _ndp->ni_rightsneeded = _rightsp; \ + _ndp->ni_rbeneath_dpp = NULL; \ + _ndp->ni_nctrack_mnt = NULL; \ + TAILQ_INIT(&_ndp->ni_cap_tracker); \ } while (0) #define NDREINIT(ndp) do { \ @@ -264,6 +279,7 @@ do { \ filecaps_free(&_ndp->ni_filecaps); \ _ndp->ni_resflags = 0; \ _ndp->ni_startdir = NULL; \ + _ndp->ni_cnd.cn_flags &= ~NAMEI_INTERNAL_FLAGS; \ } while (0) #define NDPREINIT(ndp) do { \ @@ -285,6 +301,8 @@ do { \ int namei(struct nameidata *ndp); int vfs_lookup(struct nameidata *ndp); +bool vfs_lookup_isroot(struct nameidata *ndp, struct vnode *dvp); +struct nameidata *vfs_lookup_nameidata(struct componentname *cnp); int vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, bool refstart); diff --git a/lib/libc/include/generic-freebsd/sys/nlist_aout.h b/lib/libc/include/generic-freebsd/sys/nlist_aout.h index fe5320429f02aafccb30a5b5cdc7a50d5575cb9c..da507cede8646a32a524edddd6c8b079af70c56f 100644 --- a/lib/libc/include/generic-freebsd/sys/nlist_aout.h +++ b/lib/libc/include/generic-freebsd/sys/nlist_aout.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)nlist.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SYS_NLIST_AOUT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/nv.h b/lib/libc/include/generic-freebsd/sys/nv.h index 20f401a9fdd4daa0e7577c87175616c0c6271f94..0a8b9c5be21673d0b7c480b4c90b34d8831bcdd2 100644 --- a/lib/libc/include/generic-freebsd/sys/nv.h +++ b/lib/libc/include/generic-freebsd/sys/nv.h @@ -34,6 +34,7 @@ #define _NV_H_ #include +#include #ifndef _KERNEL #include @@ -43,13 +44,6 @@ #include #endif -#ifndef _NVLIST_T_DECLARED -#define _NVLIST_T_DECLARED -struct nvlist; - -typedef struct nvlist nvlist_t; -#endif - #define NV_NAME_MAX 2048 #define NV_TYPE_NONE 0 diff --git a/lib/libc/include/generic-freebsd/sys/nvpair.h b/lib/libc/include/generic-freebsd/sys/nvpair.h index 98b1b1d54a4244e27c14463f324ca8e640eee800..f19d629f05495d4ee2ee9301ce78528a0b838b90 100644 --- a/lib/libc/include/generic-freebsd/sys/nvpair.h +++ b/lib/libc/include/generic-freebsd/sys/nvpair.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: CDDL-1.0 /* * CDDL HEADER START * @@ -266,6 +267,8 @@ _SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *, double *); #endif +_SYS_NVPAIR_H int nvlist_snprintf(char *, size_t, nvlist_t *, int); + _SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **); _SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, nvpair_t **, int *, const char **); diff --git a/lib/libc/include/generic-freebsd/sys/osd.h b/lib/libc/include/generic-freebsd/sys/osd.h index e3b35702fdfaf8cfd8a495ea5428e17996b0c53c..d76a20b95984e3febc1e4ba4d9b2d5ff6d495313 100644 --- a/lib/libc/include/generic-freebsd/sys/osd.h +++ b/lib/libc/include/generic-freebsd/sys/osd.h @@ -55,7 +55,7 @@ typedef void (*osd_destructor_t)(void *value); typedef int (*osd_method_t)(void *obj, void *data); int osd_register(u_int type, osd_destructor_t destructor, - osd_method_t *methods); + const osd_method_t *methods); void osd_deregister(u_int type, u_int slot); int osd_set(u_int type, struct osd *osd, u_int slot, void *value); @@ -64,6 +64,7 @@ int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv, void *value); void osd_free_reserved(void **rsv); void *osd_get(u_int type, struct osd *osd, u_int slot); +void *osd_get_unlocked(u_int type, struct osd *osd, u_int slot); void osd_del(u_int type, struct osd *osd, u_int slot); int osd_call(u_int type, u_int method, void *obj, void *data); @@ -79,6 +80,8 @@ void osd_exit(u_int type, struct osd *osd); osd_set_reserved(OSD_THREAD, &(td)->td_osd, (slot), (rsv), (value)) #define osd_thread_get(td, slot) \ osd_get(OSD_THREAD, &(td)->td_osd, (slot)) +#define osd_thread_get_unlocked(td, slot) \ + osd_get_unlocked(OSD_THREAD, &(td)->td_osd, (slot)) #define osd_thread_del(td, slot) do { \ KASSERT((td) == curthread, ("Not curthread.")); \ osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \ @@ -98,6 +101,8 @@ void osd_exit(u_int type, struct osd *osd); osd_set_reserved(OSD_JAIL, &(pr)->pr_osd, (slot), (rsv), (value)) #define osd_jail_get(pr, slot) \ osd_get(OSD_JAIL, &(pr)->pr_osd, (slot)) +#define osd_jail_get_unlocked(pr, slot) \ + osd_get_unlocked(OSD_JAIL, &(pr)->pr_osd, (slot)) #define osd_jail_del(pr, slot) \ osd_del(OSD_JAIL, &(pr)->pr_osd, (slot)) #define osd_jail_call(pr, method, data) \ diff --git a/lib/libc/include/generic-freebsd/sys/param.h b/lib/libc/include/generic-freebsd/sys/param.h index cf7e24e88c0c2f7e2fbbdb33e5af451857cd9a28..b97dca187c156678fafe1829cc7b0f5a950d797b 100644 --- a/lib/libc/include/generic-freebsd/sys/param.h +++ b/lib/libc/include/generic-freebsd/sys/param.h @@ -32,14 +32,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)param.h 8.3 (Berkeley) 4/4/95 */ #ifndef _SYS_PARAM_H_ #define _SYS_PARAM_H_ #include +#include #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 @@ -107,6 +106,8 @@ #define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070 #define P_OSREL_TIDPID 1400079 #define P_OSREL_ARM64_SPSR 1400084 +#define P_OSREL_TLSBASE 1500044 +#define P_OSREL_EXTERRCTL 1500045 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif @@ -151,17 +152,16 @@ #endif #endif -#ifndef _KERNEL -#ifndef LOCORE +#if !defined(_KERNEL) && !defined(_STANDALONE) && !defined(LOCORE) /* Signals. */ #include #endif -#endif /* Machine type dependent parameters. */ #include #ifndef _KERNEL #include +#include #endif #ifndef DEV_BSHIFT @@ -175,13 +175,6 @@ #ifndef DFLTPHYS #define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ #endif -#ifndef MAXPHYS /* max raw I/O transfer size */ -#ifdef __ILP32__ -#define MAXPHYS (128 * 1024) -#else -#define MAXPHYS (1024 * 1024) -#endif -#endif #ifndef MAXDUMPPGS #define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) #endif @@ -209,6 +202,17 @@ #define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */ #define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */ +/* + * Mach derived conversion macros + */ +#define round_page(x) roundup2(x, PAGE_SIZE) +#define trunc_page(x) rounddown2(x, PAGE_SIZE) + +#define atop(x) ((x) >> PAGE_SHIFT) +#define ptoa(x) ((x) << PAGE_SHIFT) + +#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) + /* * Some macros for units conversion */ @@ -249,9 +253,6 @@ #define NZERO 0 /* default "nice" */ -#define NBBY 8 /* number of bits in a byte */ -#define NBPW sizeof(int) /* number of bytes per word (integer) */ - #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ #define NODEV (dev_t)(-1) /* non-existent device */ @@ -315,16 +316,7 @@ #define isclr(a,i) \ ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) -/* Macros for counting and rounding. */ -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif -#define nitems(x) (sizeof((x)) / sizeof((x)[0])) -#define rounddown(x, y) (((x)/(y))*(y)) -#define rounddown2(x, y) __align_down(x, y) /* if y is power of two */ -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ -#define roundup2(x, y) __align_up(x, y) /* if y is powers of two */ -#define powerof2(x) ((((x)-1)&(x))==0) +/* Macros for counting and rounding provided by . */ /* Macros for min/max. */ #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -387,4 +379,4 @@ __END_DECLS */ #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) -#endif /* _SYS_PARAM_H_ */ +#endif /* _SYS_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/pciio.h b/lib/libc/include/generic-freebsd/sys/pciio.h index dffd559965f1a36c0e83d4219cdcf688eb0f270c..9298c944ca08349e6a73447e1397e2f19c25ff08 100644 --- a/lib/libc/include/generic-freebsd/sys/pciio.h +++ b/lib/libc/include/generic-freebsd/sys/pciio.h @@ -66,10 +66,10 @@ struct pci_conf { struct pcisel pc_sel; /* domain+bus+slot+function */ u_int8_t pc_hdr; /* PCI header type */ u_int16_t pc_subvendor; /* card vendor ID */ - u_int16_t pc_subdevice; /* card device ID, assigned by + u_int16_t pc_subdevice; /* card device ID, assigned by card vendor */ u_int16_t pc_vendor; /* chip vendor ID */ - u_int16_t pc_device; /* chip device ID, assigned by + u_int16_t pc_device; /* chip device ID, assigned by chip vendor */ u_int8_t pc_class; /* chip PCI class */ u_int8_t pc_subclass; /* chip PCI subclass */ @@ -77,6 +77,9 @@ struct pci_conf { u_int8_t pc_revid; /* chip revision ID */ char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ u_long pd_unit; /* device unit number */ + int pd_numa_domain; /* device NUMA domain */ + size_t pc_reported_len;/* length of PCI data reported */ + char pc_spare[64]; /* space for future fields */ }; struct pci_match_conf { @@ -165,7 +168,6 @@ struct pci_bar_ioreq { #define PCIIO_BAR_MMAP_RW 0x04 #define PCIIO_BAR_MMAP_ACTIVATE 0x08 -#define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io) #define PCIOCREAD _IOWR('p', 2, struct pci_io) #define PCIOCWRITE _IOWR('p', 3, struct pci_io) #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) @@ -173,5 +175,6 @@ struct pci_bar_ioreq { #define PCIOCLISTVPD _IOWR('p', 7, struct pci_list_vpd_io) #define PCIOCBARMMAP _IOWR('p', 8, struct pci_bar_mmap) #define PCIOCBARIO _IOWR('p', 9, struct pci_bar_ioreq) +#define PCIOCGETCONF _IOWR('p', 10, struct pci_conf_io) #endif /* !_SYS_PCIIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/pctrie.h b/lib/libc/include/generic-freebsd/sys/pctrie.h index f00e4fbda98153c361400c4d539bab7e78ecb7ef..54c770a385df680fe2571b924bd0a70094ed8ce5 100644 --- a/lib/libc/include/generic-freebsd/sys/pctrie.h +++ b/lib/libc/include/generic-freebsd/sys/pctrie.h @@ -34,8 +34,45 @@ #include #include +struct pctrie_iter { + struct pctrie *ptree; + struct pctrie_node *node; + uint64_t index; + uint64_t limit; +}; + +static __inline void +pctrie_iter_reset(struct pctrie_iter *it) +{ + it->node = NULL; +} + +static __inline bool +pctrie_iter_is_reset(struct pctrie_iter *it) +{ + return (it->node == NULL); +} + +static __inline void +pctrie_iter_init(struct pctrie_iter *it, struct pctrie *ptree) +{ + it->ptree = ptree; + it->node = NULL; + it->limit = 0; +} + +static __inline void +pctrie_iter_limit_init(struct pctrie_iter *it, struct pctrie *ptree, + uint64_t limit) +{ + pctrie_iter_init(it, ptree); + it->limit = limit; +} + #ifdef _KERNEL +typedef void (*pctrie_cb_t)(void *ptr, void *arg); + #define PCTRIE_DEFINE_SMR(name, type, field, allocfn, freefn, smr) \ PCTRIE_DEFINE(name, type, field, allocfn, freefn) \ \ @@ -46,6 +83,19 @@ name##_PCTRIE_LOOKUP_UNLOCKED(struct pctrie *ptree, uint64_t key) \ return name##_PCTRIE_VAL2PTR(pctrie_lookup_unlocked(ptree, \ key, (smr))); \ } \ + \ +static __inline __unused int \ +name##_PCTRIE_LOOKUP_RANGE_UNLOCKED(struct pctrie *ptree, uint64_t key, \ + struct type *value[], int count) \ +{ \ + uint64_t **data = (uint64_t **)value; \ + \ + count = pctrie_lookup_range_unlocked(ptree, key, data, count, \ + (smr)); \ + for (int i = 0; i < count; i++) \ + value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \ + return (count); \ +} \ #define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \ \ @@ -57,15 +107,20 @@ CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \ CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \ \ static __inline struct type * \ -name##_PCTRIE_VAL2PTR(uint64_t *val) \ +name##_PCTRIE_NZVAL2PTR(uint64_t *val) \ { \ - \ - if (val == NULL) \ - return (NULL); \ return (struct type *) \ ((uintptr_t)val - __offsetof(struct type, field)); \ } \ \ +static __inline struct type * \ +name##_PCTRIE_VAL2PTR(uint64_t *val) \ +{ \ + if (val == NULL) \ + return (NULL); \ + return (name##_PCTRIE_NZVAL2PTR(val)); \ +} \ + \ static __inline uint64_t * \ name##_PCTRIE_PTR2VAL(struct type *ptr) \ { \ @@ -73,23 +128,87 @@ name##_PCTRIE_PTR2VAL(struct type *ptr) \ return &ptr->field; \ } \ \ -static __inline int \ +static __inline __unused int \ +name##_PCTRIE_INSERT_BASE(struct pctrie *ptree, uint64_t *val, \ + struct pctrie_node **parent, void *parentp, \ + uint64_t *found, struct type **found_out) \ +{ \ + struct pctrie_node *child; \ + \ + if (__predict_false(found != NULL)) { \ + *found_out = name##_PCTRIE_VAL2PTR(found); \ + return (EEXIST); \ + } \ + if (parentp != NULL) { \ + child = allocfn(ptree); \ + if (__predict_false(child == NULL)) { \ + if (found_out != NULL) \ + *found_out = NULL; \ + return (ENOMEM); \ + } \ + pctrie_insert_node(val, *parent, parentp, child); \ + *parent = child; \ + } \ + return (0); \ +} \ + \ +static __inline __unused int \ name##_PCTRIE_INSERT(struct pctrie *ptree, struct type *ptr) \ +{ \ + void *parentp; \ + struct pctrie_node *parent; \ + uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \ + \ + parentp = pctrie_insert_lookup_strict(ptree, val, &parent); \ + return (name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \ + NULL, NULL)); \ +} \ + \ +static __inline __unused int \ +name##_PCTRIE_FIND_OR_INSERT(struct pctrie *ptree, struct type *ptr, \ + struct type **found_out_opt) \ +{ \ + void *parentp; \ + struct pctrie_node *parent; \ + uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \ + uint64_t *found; \ + \ + parentp = pctrie_insert_lookup(ptree, val, &parent, &found); \ + return (name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \ + found, found_out_opt)); \ +} \ + \ +static __inline __unused int \ +name##_PCTRIE_INSERT_LOOKUP_LE(struct pctrie *ptree, struct type *ptr, \ + struct type **found_out) \ { \ struct pctrie_node *parent; \ void *parentp; \ uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \ + uint64_t *found; \ + int retval; \ \ - parentp = pctrie_insert_lookup(ptree, val); \ - if (parentp == NULL) \ - return (0); \ - parent = allocfn(ptree); \ - if (parent == NULL) \ - return (ENOMEM); \ - pctrie_insert_node(parentp, parent, val); \ + parentp = pctrie_insert_lookup(ptree, val, &parent, &found); \ + retval = name##_PCTRIE_INSERT_BASE(ptree, val, &parent, parentp, \ + found, found_out); \ + if (retval != 0) \ + return (retval); \ + found = pctrie_subtree_lookup_lt(ptree, parent, *val); \ + *found_out = name##_PCTRIE_VAL2PTR(found); \ return (0); \ } \ \ +static __inline __unused int \ +name##_PCTRIE_ITER_INSERT(struct pctrie_iter *it, struct type *ptr) \ +{ \ + void *parentp; \ + uint64_t *val = name##_PCTRIE_PTR2VAL(ptr); \ + \ + parentp = pctrie_iter_insert_lookup(it, val); \ + return (name##_PCTRIE_INSERT_BASE(it->ptree, val, &it->node, \ + parentp, NULL, NULL)); \ +} \ + \ static __inline __unused struct type * \ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \ { \ @@ -97,6 +216,30 @@ name##_PCTRIE_LOOKUP(struct pctrie *ptree, uint64_t key) \ return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \ } \ \ +static __inline __unused int \ +name##_PCTRIE_LOOKUP_RANGE(struct pctrie *ptree, uint64_t key, \ + struct type *value[], int count) \ +{ \ + uint64_t **data = (uint64_t **)value; \ + \ + count = pctrie_lookup_range(ptree, key, data, count); \ + for (int i = 0; i < count; i++) \ + value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \ + return (count); \ +} \ + \ +static __inline __unused int \ +name##_PCTRIE_ITER_LOOKUP_RANGE(struct pctrie_iter *it, uint64_t key, \ + struct type *value[], int count) \ +{ \ + uint64_t **data = (uint64_t **)value; \ + \ + count = pctrie_iter_lookup_range(it, key, data, count); \ + for (int i = 0; i < count; i++) \ + value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \ + return (count); \ +} \ + \ static __inline __unused struct type * \ name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \ { \ @@ -122,6 +265,108 @@ name##_PCTRIE_RECLAIM(struct pctrie *ptree) \ freefn(ptree, freenode); \ } \ \ +/* \ + * While reclaiming all internal trie nodes, invoke callback(leaf, arg) \ + * on every leaf in the trie, in order. \ + */ \ +static __inline __unused void \ +name##_PCTRIE_RECLAIM_CALLBACK(struct pctrie *ptree, \ + void (*typed_cb)(struct type *, void *), void *arg) \ +{ \ + struct pctrie_node *freenode, *node; \ + pctrie_cb_t callback = (pctrie_cb_t)typed_cb; \ + \ + for (freenode = pctrie_reclaim_begin_cb(&node, ptree, \ + callback, __offsetof(struct type, field), arg); \ + freenode != NULL; \ + freenode = pctrie_reclaim_resume_cb(&node, \ + callback, __offsetof(struct type, field), arg)) \ + freefn(ptree, freenode); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_LOOKUP(struct pctrie_iter *it, uint64_t index) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup(it, index)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_STRIDE(struct pctrie_iter *it, int stride) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_stride(it, stride)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_NEXT(struct pctrie_iter *it) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_next(it)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_PREV(struct pctrie_iter *it) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_prev(it)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_VALUE(struct pctrie_iter *it) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_value(it)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_LOOKUP_GE(struct pctrie_iter *it, uint64_t index) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup_ge(it, index)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_JUMP_GE(struct pctrie_iter *it, int64_t jump) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_ge(it, jump)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_STEP_GE(struct pctrie_iter *it) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_ge(it, 1)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_LOOKUP_LE(struct pctrie_iter *it, uint64_t index) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_lookup_le(it, index)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_JUMP_LE(struct pctrie_iter *it, int64_t jump) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_le(it, jump)); \ +} \ + \ +static __inline __unused struct type * \ +name##_PCTRIE_ITER_STEP_LE(struct pctrie_iter *it) \ +{ \ + return name##_PCTRIE_VAL2PTR(pctrie_iter_jump_le(it, 1)); \ +} \ + \ +static __inline __unused void \ +name##_PCTRIE_REMOVE_BASE(struct pctrie *ptree, \ + struct pctrie_node *freenode) \ +{ \ + if (freenode != NULL) \ + freefn(ptree, freenode); \ +} \ + \ +static __inline __unused void \ +name##_PCTRIE_ITER_REMOVE(struct pctrie_iter *it) \ +{ \ + struct pctrie_node *freenode; \ + \ + pctrie_iter_remove(it, &freenode); \ + name##_PCTRIE_REMOVE_BASE(it->ptree, freenode); \ +} \ + \ static __inline __unused struct type * \ name##_PCTRIE_REPLACE(struct pctrie *ptree, struct type *ptr) \ { \ @@ -139,8 +384,7 @@ name##_PCTRIE_REMOVE(struct pctrie *ptree, uint64_t key) \ val = pctrie_remove_lookup(ptree, key, &freenode); \ if (val == NULL) \ panic("%s: key not found", __func__); \ - if (freenode != NULL) \ - freefn(ptree, freenode); \ + name##_PCTRIE_REMOVE_BASE(ptree, freenode); \ } \ \ static __inline __unused struct type * \ @@ -150,24 +394,53 @@ name##_PCTRIE_REMOVE_LOOKUP(struct pctrie *ptree, uint64_t key) \ struct pctrie_node *freenode; \ \ val = pctrie_remove_lookup(ptree, key, &freenode); \ - if (freenode != NULL) \ - freefn(ptree, freenode); \ + name##_PCTRIE_REMOVE_BASE(ptree, freenode); \ return name##_PCTRIE_VAL2PTR(val); \ } -void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val); -void pctrie_insert_node(void *parentp, - struct pctrie_node *parent, uint64_t *val); +struct pctrie_iter; +void *pctrie_insert_lookup(struct pctrie *ptree, uint64_t *val, + struct pctrie_node **parent_out, uint64_t **found_out); +void *pctrie_insert_lookup_strict(struct pctrie *ptree, uint64_t *val, + struct pctrie_node **parent_out); +void pctrie_insert_node(uint64_t *val, struct pctrie_node *parent, + void *parentp, struct pctrie_node *child); uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key); -uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key); -uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key); uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key, smr_t smr); +int pctrie_lookup_range(struct pctrie *ptree, + uint64_t index, uint64_t *value[], int count); +int pctrie_lookup_range_unlocked(struct pctrie *ptree, + uint64_t index, uint64_t *value[], int count, smr_t smr); +int pctrie_iter_lookup_range(struct pctrie_iter *it, uint64_t index, + uint64_t *value[], int count); +uint64_t *pctrie_iter_lookup(struct pctrie_iter *it, uint64_t index); +uint64_t *pctrie_iter_stride(struct pctrie_iter *it, int stride); +uint64_t *pctrie_iter_next(struct pctrie_iter *it); +uint64_t *pctrie_iter_prev(struct pctrie_iter *it); +void *pctrie_iter_insert_lookup(struct pctrie_iter *it, + uint64_t *val); +uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key); +uint64_t *pctrie_iter_lookup_ge(struct pctrie_iter *it, uint64_t index); +uint64_t *pctrie_iter_jump_ge(struct pctrie_iter *it, int64_t jump); +uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key); +uint64_t *pctrie_subtree_lookup_lt(struct pctrie *ptree, + struct pctrie_node *node, uint64_t key); +uint64_t *pctrie_iter_lookup_le(struct pctrie_iter *it, uint64_t index); +uint64_t *pctrie_iter_jump_le(struct pctrie_iter *it, int64_t jump); struct pctrie_node *pctrie_reclaim_begin(struct pctrie_node **pnode, struct pctrie *ptree); struct pctrie_node *pctrie_reclaim_resume(struct pctrie_node **pnode); +struct pctrie_node *pctrie_reclaim_begin_cb(struct pctrie_node **pnode, + struct pctrie *ptree, + pctrie_cb_t callback, int keyoff, void *arg); +struct pctrie_node *pctrie_reclaim_resume_cb(struct pctrie_node **pnode, + pctrie_cb_t callback, int keyoff, void *arg); uint64_t *pctrie_remove_lookup(struct pctrie *ptree, uint64_t index, struct pctrie_node **killnode); +void pctrie_iter_remove(struct pctrie_iter *it, + struct pctrie_node **freenode); +uint64_t *pctrie_iter_value(struct pctrie_iter *it); uint64_t *pctrie_replace(struct pctrie *ptree, uint64_t *newval); size_t pctrie_node_size(void); int pctrie_zone_init(void *mem, int size, int flags); diff --git a/lib/libc/include/generic-freebsd/sys/pipe.h b/lib/libc/include/generic-freebsd/sys/pipe.h index 352c83d4e54032b32575c682daf29e44badc6189..56a8490fb58cd2dd4bdcfd2125d74c8b77accd70 100644 --- a/lib/libc/include/generic-freebsd/sys/pipe.h +++ b/lib/libc/include/generic-freebsd/sys/pipe.h @@ -52,7 +52,7 @@ * See sys_pipe.c for info on what these limits mean. */ extern long maxpipekva; -extern struct fileops pipeops; +extern const struct fileops pipeops; #endif /* diff --git a/lib/libc/include/generic-freebsd/sys/pmc.h b/lib/libc/include/generic-freebsd/sys/pmc.h index 0d8e7f3e320c65b20c96ed3aefa9bdddb047bbe0..6377d6d073188619f3a09e38d5825acb09265fb9 100644 --- a/lib/libc/include/generic-freebsd/sys/pmc.h +++ b/lib/libc/include/generic-freebsd/sys/pmc.h @@ -81,7 +81,6 @@ extern char pmc_cpuid[PMC_CPUID_LEN]; * Please keep the pmc(3) manual page in sync with this list. */ #define __PMC_CPUS() \ - __PMC_CPU(AMD_K7, 0x00, "AMD K7") \ __PMC_CPU(AMD_K8, 0x01, "AMD K8") \ __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \ __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \ @@ -130,7 +129,7 @@ enum pmc_cputype { __PMC_CPUS() }; -#define PMC_CPU_FIRST PMC_CPU_AMD_K7 +#define PMC_CPU_FIRST PMC_CPU_AMD_K8 #define PMC_CPU_LAST PMC_CPU_ARMV8_CORTEX_A76 /* @@ -138,7 +137,6 @@ enum pmc_cputype { */ #define __PMC_CLASSES() \ __PMC_CLASS(TSC, 0x00, "CPU Timestamp counter") \ - __PMC_CLASS(K7, 0x01, "AMD K7 performance counters") \ __PMC_CLASS(K8, 0x02, "AMD K8 performance counters") \ __PMC_CLASS(IAF, 0x06, "Intel Core2/Atom, fixed function") \ __PMC_CLASS(IAP, 0x07, "Intel Core...Atom, programmable") \ diff --git a/lib/libc/include/generic-freebsd/sys/poll.h b/lib/libc/include/generic-freebsd/sys/poll.h index a731b70329ff5e51ef0a8c0c00dca1445679a1eb..b915f5a37d7efd3ca558e0a3a8d49b31a9a4c601 100644 --- a/lib/libc/include/generic-freebsd/sys/poll.h +++ b/lib/libc/include/generic-freebsd/sys/poll.h @@ -96,7 +96,7 @@ struct pollfd { #ifndef _KERNEL -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 202405 #include #include @@ -109,9 +109,13 @@ typedef __sigset_t sigset_t; #endif +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 202405 int ppoll(struct pollfd _pfd[], nfds_t _nfds, const struct timespec *__restrict _timeout, const sigset_t *__restrict _newsigmask); diff --git a/lib/libc/include/generic-freebsd/sys/priority.h b/lib/libc/include/generic-freebsd/sys/priority.h index 6ea8666803aa4bbb6b273c820fee0003e41e7fa9..1a05ab3648f6fc6c5aca69c5204ae5e8a46bc2c4 100644 --- a/lib/libc/include/generic-freebsd/sys/priority.h +++ b/lib/libc/include/generic-freebsd/sys/priority.h @@ -64,17 +64,23 @@ */ /* - * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) - * are insignificant. Ranges are as follows: + * Priorities range from 0 to 255. Ranges are as follows: * - * Interrupt threads: 0 - 15 - * Realtime user threads: 16 - 47 - * Top half kernel threads: 48 - 87 - * Time sharing user threads: 88 - 223 + * Interrupt threads: 0 - 7 + * Realtime user threads: 8 - 39 + * Top half kernel threads: 40 - 55 + * Time sharing user threads: 56 - 223 * Idle user threads: 224 - 255 * - * XXX If/When the specific interrupt thread and top half thread ranges - * disappear, a larger range can be used for user processes. + * Priority levels of rtprio(2)'s RTP_PRIO_FIFO and RTP_PRIO_REALTIME and + * POSIX's SCHED_FIFO and SCHED_RR are directly mapped to the internal realtime + * range mentioned above by a simple translation. This range's length + * consequently cannot be changed without impacts on the scheduling priority + * code, and in any case must never be smaller than 32 for POSIX compliance and + * rtprio(2) backwards compatibility. Similarly, priority levels of rtprio(2)'s + * RTP_PRIO_IDLE are directly mapped to the internal idle range above (and, + * soon, those of the to-be-introduced SCHED_IDLE policy as well), so changing + * that range is subject to the same caveats and restrictions. */ #define PRI_MIN (0) /* Highest priority. */ @@ -88,34 +94,34 @@ * decay to lower priorities if they run for full time slices. */ #define PI_REALTIME (PRI_MIN_ITHD + 0) -#define PI_INTR (PRI_MIN_ITHD + 4) +#define PI_INTR (PRI_MIN_ITHD + 1) #define PI_AV PI_INTR #define PI_NET PI_INTR #define PI_DISK PI_INTR #define PI_TTY PI_INTR #define PI_DULL PI_INTR -#define PI_SOFT (PRI_MIN_ITHD + 8) +#define PI_SOFT (PRI_MIN_ITHD + 2) #define PI_SOFTCLOCK PI_SOFT #define PI_SWI(x) PI_SOFT -#define PRI_MIN_REALTIME (16) +#define PRI_MIN_REALTIME (8) #define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) -#define PRI_MIN_KERN (48) +#define PRI_MIN_KERN (40) #define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) #define PSWP (PRI_MIN_KERN + 0) -#define PVM (PRI_MIN_KERN + 4) -#define PINOD (PRI_MIN_KERN + 8) -#define PRIBIO (PRI_MIN_KERN + 12) -#define PVFS (PRI_MIN_KERN + 16) -#define PZERO (PRI_MIN_KERN + 20) -#define PSOCK (PRI_MIN_KERN + 24) -#define PWAIT (PRI_MIN_KERN + 28) -#define PLOCK (PRI_MIN_KERN + 32) -#define PPAUSE (PRI_MIN_KERN + 36) +#define PVM (PRI_MIN_KERN + 1) +#define PINOD (PRI_MIN_KERN + 2) +#define PRIBIO (PRI_MIN_KERN + 3) +#define PVFS (PRI_MIN_KERN + 4) +#define PZERO (PRI_MIN_KERN + 5) +#define PSOCK (PRI_MIN_KERN + 6) +#define PWAIT (PRI_MIN_KERN + 7) +#define PLOCK (PRI_MIN_KERN + 8) +#define PPAUSE (PRI_MIN_KERN + 9) -#define PRI_MIN_TIMESHARE (88) +#define PRI_MIN_TIMESHARE (56) #define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) #define PUSER (PRI_MIN_TIMESHARE) diff --git a/lib/libc/include/generic-freebsd/sys/priv.h b/lib/libc/include/generic-freebsd/sys/priv.h index b659da09f5bc813b8cd49e39a6ea608f4d69f3de..7ad062fda99fd7c4de60b48dbb6c3865f63eee25 100644 --- a/lib/libc/include/generic-freebsd/sys/priv.h +++ b/lib/libc/include/generic-freebsd/sys/priv.h @@ -105,7 +105,8 @@ #define PRIV_CRED_SETRESGID 58 /* setresgid. */ #define PRIV_SEEOTHERGIDS 59 /* Exempt bsd.seeothergids. */ #define PRIV_SEEOTHERUIDS 60 /* Exempt bsd.seeotheruids. */ -#define PRIV_SEEJAILPROC 61 /* Exempt from bsd.see_jail_proc. */ +#define PRIV_SEEJAILPROC 61 /* Exempt from bsd.see_jail_proc. */ +#define PRIV_CRED_SETCRED 62 /* setcred. */ /* * Debugging privileges. @@ -114,6 +115,7 @@ #define PRIV_DEBUG_SUGID 81 /* Exempt debugging setuid proc. */ #define PRIV_DEBUG_UNPRIV 82 /* Exempt unprivileged debug limit. */ #define PRIV_DEBUG_DENIED 83 /* Exempt P2_NOTRACE. */ +#define PRIV_DEBUG_DIFFJAIL 84 /* Exempt debugging other jails. */ /* * Dtrace privileges. @@ -192,6 +194,7 @@ #define PRIV_SCHED_CPUSET 206 /* Can manipulate cpusets. */ #define PRIV_SCHED_CPUSET_INTR 207 /* Can adjust IRQ to CPU binding. */ #define PRIV_SCHED_IDPRIO 208 /* Can set idle time scheduling. */ +#define PRIV_SCHED_DIFFJAIL 209 /* Exempt scheduling other jails. */ /* * POSIX semaphore privileges. @@ -203,6 +206,7 @@ */ #define PRIV_SIGNAL_DIFFCRED 230 /* Exempt signalling other users. */ #define PRIV_SIGNAL_SUGID 231 /* Non-conserv signal setuid proc. */ +#define PRIV_SIGNAL_DIFFJAIL 232 /* Exempt signalling other jails. */ /* * Sysctl privileges. @@ -210,6 +214,7 @@ #define PRIV_SYSCTL_DEBUG 240 /* Can invoke sysctl.debug. */ #define PRIV_SYSCTL_WRITE 241 /* Can write sysctls. */ #define PRIV_SYSCTL_WRITEJAIL 242 /* Can write sysctls, jail permitted. */ +#define PRIV_SYSCTL_MEMLOCK 243 /* Large requests are not serialized. */ /* * TTY privileges. @@ -404,6 +409,7 @@ #define PRIV_NETINET_SETHDROPTS 505 /* Set certain IPv4/6 header options. */ #define PRIV_NETINET_BINDANY 506 /* Allow bind to any address. */ #define PRIV_NETINET_HASHKEY 507 /* Get and set hash keys for IPv4/6. */ +#define PRIV_NETINET_KTLSKEYS 508 /* Read ktls session keys. */ /* * Placeholders for IPX/SPX privileges, not supported any more. @@ -515,6 +521,7 @@ */ #define PRIV_KMEM_READ 680 /* Open mem/kmem for reading. */ #define PRIV_KMEM_WRITE 681 /* Open mem/kmem for writing. */ +#define PRIV_PROC_MEM_WRITE 682 /* Writes via proc_rwmem */ /* * Kernel debugger privileges. diff --git a/lib/libc/include/generic-freebsd/sys/proc.h b/lib/libc/include/generic-freebsd/sys/proc.h index 9a96b377f79996df98e726041891d4499d4cd6c1..dc092f82540936d4a9015f0c158b8e0527e52f2c 100644 --- a/lib/libc/include/generic-freebsd/sys/proc.h +++ b/lib/libc/include/generic-freebsd/sys/proc.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)proc.h 8.15 (Berkeley) 5/19/95 */ #ifndef _SYS_PROC_H_ @@ -44,6 +42,7 @@ #ifdef _KERNEL #include #endif +#include #include #ifndef _KERNEL #include @@ -55,7 +54,6 @@ #include #include #include /* XXX. */ -#include #include #include #include @@ -249,7 +247,7 @@ struct thread { struct seltd *td_sel; /* Select queue/channel. */ struct sleepqueue *td_sleepqueue; /* (k) Associated sleep queue. */ struct turnstile *td_turnstile; /* (k) Associated turnstile. */ - struct rl_q_entry *td_rlqe; /* (k) Associated range lock entry. */ + void *td_pad1; /* Available */ struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */ lwpid_t td_tid; /* (b) Thread ID. */ sigqueue_t td_sigqueue; /* (c) Sigs arrived, not delivered. */ @@ -272,11 +270,12 @@ struct thread { const char *td_wmesg; /* (t) Reason for sleep. */ volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ - u_char td_stopsched; /* (k) Scheduler stopped. */ + u_char _td_pad0[2]; /* Available. */ int td_locks; /* (k) Debug: count of non-spin locks */ int td_rw_rlocks; /* (k) Count of rwlock read locks. */ int td_sx_slocks; /* (k) Count of sx shared locks. */ int td_lk_slocks; /* (k) Count of lockmgr shared locks. */ + struct lock_object *td_wantedlock; /* (k) Lock we are contending on */ struct turnstile *td_blocked; /* (t) Lock thread is blocked on. */ const char *td_lockname; /* (t) Name of lock blocked on. */ LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */ @@ -314,8 +313,8 @@ struct thread { struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ pid_t td_dbg_forked; /* (c) Child pid for debugger. */ - struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */ u_int td_no_sleeping; /* (k) Sleeping disabled count. */ + struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */ void *td_su; /* (k) FFS SU private */ sbintime_t td_sleeptimo; /* (t) Sleep timeout. */ int td_rtcgen; /* (s) rtc_generation of abs. sleep */ @@ -323,6 +322,7 @@ struct thread { size_t td_vslock_sz; /* (k) amount of vslock-ed space */ struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */ long td_ucredref; /* (k) references on td_realucred */ + struct kexterr td_kexterr; #define td_endzero td_sigmask /* Copied during fork1(), thread_create(), or kthread_add(). */ @@ -342,6 +342,7 @@ struct thread { void *td_sigblock_ptr; /* (k) uptr for fast sigblock. */ uint32_t td_sigblock_val; /* (k) fast sigblock value read at td_sigblock_ptr on kern entry */ + void *td_exterr_ptr; #define td_endcopy td_pcb /* @@ -367,7 +368,8 @@ struct thread { struct callout td_slpcallout; /* (h) Callout for sleep. */ struct trapframe *td_frame; /* (k) */ vm_offset_t td_kstack; /* (a) Kernel VA of kstack. */ - int td_kstack_pages; /* (a) Size of the kstack. */ + u_short td_kstack_pages; /* (a) Size of the kstack. */ + u_short td_kstack_domain; /* (a) Domain backing kstack KVA. */ volatile u_int td_critnest; /* (k*) Critical section nest level. */ struct mdthread td_md; /* (k) Any machine-dependent fields. */ struct kaudit_record *td_ar; /* (k) Active audit record, if any. */ @@ -430,7 +432,7 @@ do { \ #define TD_LOCKS_INC(td) ((td)->td_locks++) #define TD_LOCKS_DEC(td) do { \ - KASSERT(SCHEDULER_STOPPED_TD(td) || (td)->td_locks > 0, \ + KASSERT(SCHEDULER_STOPPED() || (td)->td_locks > 0, \ ("Thread %p owns no locks", (td))); \ (td)->td_locks--; \ } while (0) @@ -452,7 +454,7 @@ do { \ #define TDF_SINTR 0x00000008 /* Sleep is interruptible. */ #define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */ #define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */ -#define TDF_CANSWAP 0x00000040 /* Thread can be swapped. */ +#define TDF_UNUSED11 0x00000040 /* Available */ #define TDF_SIGWAIT 0x00000080 /* Ignore ignored signals */ #define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */ #define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */ @@ -468,7 +470,7 @@ do { \ #define TDF_SERESTART 0x00080000 /* ERESTART on stop attempts. */ #define TDF_THRWAKEUP 0x00100000 /* Libthr thread must not suspend itself. */ #define TDF_SEINTR 0x00200000 /* EINTR on stop attempts. */ -#define TDF_SWAPINREQ 0x00400000 /* Swapin request due to wakeup. */ +#define TDF_UNUSED12 0x00400000 /* Available */ #define TDF_UNUSED6 0x00800000 /* Available */ #define TDF_SCHED0 0x01000000 /* Reserved for scheduler private use */ #define TDF_SCHED1 0x02000000 /* Reserved for scheduler private use */ @@ -493,13 +495,14 @@ enum { TDA_KQUEUE, TDA_RACCT, TDA_MOD1, /* For third party use, before signals are */ - TAD_MOD2, /* processed .. */ + TDA_MOD2, /* processed .. */ + TDA_PSELECT, /* For discarding temporary signal mask */ TDA_SIG, TDA_KTRACE, TDA_SUSPEND, TDA_SIGSUSPEND, TDA_MOD3, /* .. and after */ - TAD_MOD4, + TDA_MOD4, TDA_MAX, }; #define TDAI(tda) (1U << (tda)) @@ -560,13 +563,16 @@ enum { #define TDP_RESETSPUR 0x04000000 /* Reset spurious page fault history. */ #define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */ #define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */ -#define TDP_INTCPCALLOUT 0x20000000 /* used by netinet/tcp_timer.c */ +#define TDP_EFIRT 0x20000000 /* In firmware (EFI RT) call */ #define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */ #define TDP_SIGFASTPENDING 0x80000000 /* Pending signal due to sigfastblock */ #define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */ #define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */ #define TDP2_ACCT 0x00000004 /* Doing accounting */ +#define TDP2_SAN_QUIET 0x00000008 /* Disable warnings from K(A|M)SAN */ +#define TDP2_EXTERR 0x00000010 /* Kernel reported ext error */ +#define TDP2_UEXTERR 0x00000020 /* User set ext error reporting ptr */ /* * Reasons that the current thread can not be run yet. @@ -574,14 +580,12 @@ enum { */ #define TDI_SUSPENDED 0x0001 /* On suspension queue. */ #define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */ -#define TDI_SWAPPED 0x0004 /* Stack not in mem. Bad juju if run. */ #define TDI_LOCK 0x0008 /* Stopped on a lock. */ #define TDI_IWAIT 0x0010 /* Awaiting interrupt. */ #define TD_IS_SLEEPING(td) ((td)->td_inhibitors & TDI_SLEEPING) #define TD_ON_SLEEPQ(td) ((td)->td_wchan != NULL) #define TD_IS_SUSPENDED(td) ((td)->td_inhibitors & TDI_SUSPENDED) -#define TD_IS_SWAPPED(td) ((td)->td_inhibitors & TDI_SWAPPED) #define TD_ON_LOCK(td) ((td)->td_inhibitors & TDI_LOCK) #define TD_AWAITING_INTR(td) ((td)->td_inhibitors & TDI_IWAIT) #ifdef _KERNEL @@ -602,7 +606,6 @@ enum { #define KTDSTATE(td) \ (((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \ ((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \ - ((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \ ((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \ ((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding") @@ -618,14 +621,12 @@ enum { } while (0) #define TD_SET_SLEEPING(td) TD_SET_INHIB((td), TDI_SLEEPING) -#define TD_SET_SWAPPED(td) TD_SET_INHIB((td), TDI_SWAPPED) #define TD_SET_LOCK(td) TD_SET_INHIB((td), TDI_LOCK) #define TD_SET_SUSPENDED(td) TD_SET_INHIB((td), TDI_SUSPENDED) #define TD_SET_IWAIT(td) TD_SET_INHIB((td), TDI_IWAIT) #define TD_SET_EXITING(td) TD_SET_INHIB((td), TDI_EXITING) #define TD_CLR_SLEEPING(td) TD_CLR_INHIB((td), TDI_SLEEPING) -#define TD_CLR_SWAPPED(td) TD_CLR_INHIB((td), TDI_SWAPPED) #define TD_CLR_LOCK(td) TD_CLR_INHIB((td), TDI_LOCK) #define TD_CLR_SUSPENDED(td) TD_CLR_INHIB((td), TDI_SUSPENDED) #define TD_CLR_IWAIT(td) TD_CLR_INHIB((td), TDI_IWAIT) @@ -704,7 +705,7 @@ struct proc { struct vnode *p_textvp; /* (b) Vnode of executable. */ struct vnode *p_textdvp; /* (b) Dir containing textvp. */ char *p_binname; /* (b) Binary hardlink name. */ - u_int p_lock; /* (c) Proclock (prevent swap) count. */ + u_int p_lock; /* (c) Prevent exit. */ struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ int p_sigparent; /* (c) Signal to parent on exit. */ int p_sig; /* (n) For core dump/debugger XXX. */ @@ -714,7 +715,7 @@ struct proc { int p_suspcount; /* (j) Num threads in suspended mode. */ struct thread *p_xthread; /* (c) Trap thread */ int p_boundary_count;/* (j) Num threads at user boundary */ - int p_pendingcnt; /* how many signals are pending */ + int p_pendingcnt; /* (c) how many signals are pending */ struct itimers *p_itimers; /* (c) POSIX interval timers. */ struct procdesc *p_procdesc; /* (e) Process descriptor, if any. */ u_int p_treeflag; /* (e) P_TREE flags */ @@ -762,7 +763,6 @@ struct proc { LIST_HEAD(, mqueue_notifier) p_mqnotifier; /* (c) mqueue notifiers.*/ struct kdtrace_proc *p_dtrace; /* (*) DTrace-specific data. */ struct cv p_pwait; /* (*) wait cv for exit/exec. */ - uint64_t p_prev_runtime; /* (c) Resource usage accounting. */ struct racct *p_racct; /* (b) Resource accounting. */ int p_throttled; /* (c) Flag for racct pcpu throttling */ /* @@ -806,7 +806,7 @@ struct proc { lock. */ #define P_CONTROLT 0x00000002 /* Has a controlling terminal. */ #define P_KPROC 0x00000004 /* Kernel process. */ -#define P_UNUSED3 0x00000008 /* --available-- */ +#define P_IDLEPROC 0x00000008 /* Container for system idle threads. */ #define P_PPWAIT 0x00000010 /* Parent is waiting for child to exec/exit. */ #define P_PROFIL 0x00000020 /* Has started profiling. */ @@ -816,8 +816,7 @@ struct proc { shortcuts) */ #define P_SUGID 0x00000100 /* Had set id privileges since last exec. */ -#define P_SYSTEM 0x00000200 /* System proc: no sigs, stats or - swapping. */ +#define P_SYSTEM 0x00000200 /* System proc: no sigs or stats. */ #define P_SINGLE_EXIT 0x00000400 /* Threads suspending should exit, not wait. */ #define P_TRACED 0x00000800 /* Debugged process being traced. */ @@ -841,9 +840,9 @@ struct proc { #define P_TOTAL_STOP 0x02000000 /* Stopped in stop_all_proc. */ #define P_INEXEC 0x04000000 /* Process is in execve(). */ #define P_STATCHILD 0x08000000 /* Child process stopped or exited. */ -#define P_INMEM 0x10000000 /* Loaded into memory. */ -#define P_SWAPPINGOUT 0x20000000 /* Process is being swapped out. */ -#define P_SWAPPINGIN 0x40000000 /* Process is being swapped in. */ +#define P_INMEM 0x10000000 /* Loaded into memory, always set. */ +#define P_UNUSED1 0x20000000 /* --available-- */ +#define P_UNUSED2 0x40000000 /* --available-- */ #define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */ #define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE) @@ -874,7 +873,7 @@ struct proc { MAP_STACK */ #define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled after exec */ -#define P2_ITSTOPPED 0x00002000 +#define P2_ITSTOPPED 0x00002000 /* itimers stopped */ #define P2_PTRACEREQ 0x00004000 /* Active ptrace req */ #define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */ #define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */ @@ -882,7 +881,7 @@ struct proc { #define P2_WEXIT 0x00040000 /* exit just started, no external thread_single() is permitted */ -#define P2_REAPKILLED 0x00080000 +#define P2_REAPKILLED 0x00080000 /* REAP_KILL pass touched me */ #define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited registered */ #define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited @@ -890,6 +889,11 @@ struct proc { #define P2_MEMBAR_GLOBE 0x00400000 /* membar global expedited registered */ +#define P2_LOGSIGEXIT_ENABLE 0x00800000 /* Disable logging on sigexit */ +#define P2_LOGSIGEXIT_CTL 0x01000000 /* Override kern.logsigexit */ + +#define P2_HWT 0x02000000 /* Process is using HWT. */ + /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ #define P_TREE_FIRST_ORPHAN 0x00000002 /* First element of orphan @@ -938,12 +942,6 @@ struct proc { #define SINGLE_BOUNDARY 2 #define SINGLE_ALLPROC 3 -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_PARGS); -MALLOC_DECLARE(M_SESSION); -MALLOC_DECLARE(M_SUBPROC); -#endif - #define FOREACH_PROC_IN_SYSTEM(p) \ LIST_FOREACH((p), &allproc, p_list) #define FOREACH_THREAD_IN_PROC(p, td) \ @@ -956,7 +954,7 @@ MALLOC_DECLARE(M_SUBPROC); * in a pid_t, as it is used to represent "no process group". */ #define PID_MAX 99999 -#define NO_PID 100000 +#define NO_PID (PID_MAX + 1) #define THREAD0_TID NO_PID extern pid_t pid_max; @@ -992,18 +990,12 @@ extern pid_t pid_max; #define SESS_LOCK_ASSERT(s, type) mtx_assert(&(s)->s_mtx, (type)) /* - * Non-zero p_lock ensures that: - * - exit1() is not performed until p_lock reaches zero; - * - the process' threads stack are not swapped out if they are currently - * not (P_INMEM). + * A non-zero p_lock prevents the process from exiting; it will sleep in exit1() + * until the count reaches zero. * * PHOLD() asserts that the process (except the current process) is - * not exiting, increments p_lock and swaps threads stacks into memory, - * if needed. + * not exiting and increments p_lock. * _PHOLD() is same as PHOLD(), it takes the process locked. - * _PHOLD_LITE() also takes the process locked, but comparing with - * _PHOLD(), it only guarantees that exit1() is not executed, - * faultin() is not called. */ #define PHOLD(p) do { \ PROC_LOCK(p); \ @@ -1015,14 +1007,6 @@ extern pid_t pid_max; KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ ("PHOLD of exiting process %p", p)); \ (p)->p_lock++; \ - if (((p)->p_flag & P_INMEM) == 0) \ - faultin((p)); \ -} while (0) -#define _PHOLD_LITE(p) do { \ - PROC_LOCK_ASSERT((p), MA_OWNED); \ - KASSERT(!((p)->p_flag & P_WEXIT) || (p) == curproc, \ - ("PHOLD of exiting process %p", p)); \ - (p)->p_lock++; \ } while (0) #define PROC_ASSERT_HELD(p) do { \ KASSERT((p)->p_lock > 0, ("process %p not held", p)); \ @@ -1058,9 +1042,6 @@ extern pid_t pid_max; _p->p_cowgen - _td->td_cowgen; \ }) -/* Check whether a thread is safe to be swapped out. */ -#define thread_safetoswapout(td) ((td)->td_flags & TDF_CANSWAP) - /* Control whether or not it is safe for curthread to sleep. */ #define THREAD_NO_SLEEPING() do { \ curthread->td_no_sleeping++; \ @@ -1074,6 +1055,16 @@ extern pid_t pid_max; #define THREAD_CAN_SLEEP() ((curthread)->td_no_sleeping == 0) +#define THREAD_CONTENDS_ON_LOCK(lo) do { \ + MPASS(curthread->td_wantedlock == NULL); \ + curthread->td_wantedlock = lo; \ +} while (0) + +#define THREAD_CONTENTION_DONE(lo) do { \ + MPASS(curthread->td_wantedlock == lo); \ + curthread->td_wantedlock = NULL; \ +} while (0) + #define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash]) #define PIDHASHLOCK(pid) (&pidhashtbl_lock[((pid) & pidhashlock)]) extern LIST_HEAD(pidhashhead, proc) *pidhashtbl; @@ -1170,7 +1161,6 @@ int cr_cansignal(struct ucred *cred, struct proc *proc, int signum); int enterpgrp(struct proc *p, pid_t pgid, struct pgrp *pgrp, struct session *sess); int enterthispgrp(struct proc *p, struct pgrp *pgrp); -void faultin(struct proc *p); int fork1(struct thread *, struct fork_req *); void fork_exit(void (*)(void *, struct trapframe *), void *, struct trapframe *); @@ -1181,7 +1171,6 @@ void kqtimer_proc_continue(struct proc *p); void kern_proc_vmmap_resident(struct vm_map *map, struct vm_map_entry *entry, int *resident_count, bool *super); void kern_yield(int); -void kick_proc0(void); void killjobc(void); int leavepgrp(struct proc *p); int maybe_preempt(struct thread *td); @@ -1195,6 +1184,7 @@ int p_canwait(struct thread *td, struct proc *p); struct pargs *pargs_alloc(int len); void pargs_drop(struct pargs *pa); void pargs_hold(struct pargs *pa); +int pgrp_calc_jobc(struct pgrp *pgrp); void proc_add_orphan(struct proc *child, struct proc *parent); int proc_get_binpath(struct proc *p, char *binname, char **fullpath, char **freepath); @@ -1220,7 +1210,7 @@ int securelevel_ge(struct ucred *cr, int level); int securelevel_gt(struct ucred *cr, int level); void sess_hold(struct session *); void sess_release(struct session *); -int setrunnable(struct thread *, int); +void setrunnable(struct thread *, int); void setsugid(struct proc *p); bool should_yield(void); int sigonstack(size_t sp); @@ -1235,6 +1225,7 @@ extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */ void cpu_switch(struct thread *, struct thread *, struct mtx *); void cpu_sync_core(void); void cpu_throw(struct thread *, struct thread *) __dead2; +void cpu_update_pcb(struct thread *); bool curproc_sigkilled(void); void userret(struct thread *, struct trapframe *); @@ -1250,15 +1241,12 @@ int cpu_procctl(struct thread *td, int idtype, id_t id, int com, void cpu_set_syscall_retval(struct thread *, int); int cpu_set_upcall(struct thread *, void (*)(void *), void *, stack_t *); -int cpu_set_user_tls(struct thread *, void *tls_base); +int cpu_set_user_tls(struct thread *, void *tls_base, int flags); void cpu_thread_alloc(struct thread *); void cpu_thread_clean(struct thread *); void cpu_thread_exit(struct thread *); void cpu_thread_free(struct thread *); -void cpu_thread_swapin(struct thread *); -void cpu_thread_swapout(struct thread *); struct thread *thread_alloc(int pages); -int thread_alloc_stack(struct thread *, int pages); int thread_check_susp(struct thread *td, bool sleep); void thread_cow_get_proc(struct thread *newtd, struct proc *p); void thread_cow_get(struct thread *newtd, struct thread *td); @@ -1271,6 +1259,7 @@ void thread_exit(void) __dead2; void thread_free(struct thread *td); void thread_link(struct thread *td, struct proc *p); void thread_reap_barrier(void); +int thread_recycle(struct thread *, int pages); int thread_single(struct proc *p, int how); void thread_single_end(struct proc *p, int how); void thread_stash(struct thread *td); diff --git a/lib/libc/include/generic-freebsd/sys/procctl.h b/lib/libc/include/generic-freebsd/sys/procctl.h index f3df637319980fe9015ad29bcdbeffb86e8ad93d..ac7abfacca751bd2ee34af6d490d3d822795c457 100644 --- a/lib/libc/include/generic-freebsd/sys/procctl.h +++ b/lib/libc/include/generic-freebsd/sys/procctl.h @@ -65,6 +65,8 @@ #define PROC_NO_NEW_PRIVS_STATUS 20 /* query suid/sgid disabled status */ #define PROC_WXMAP_CTL 21 /* control W^X */ #define PROC_WXMAP_STATUS 22 /* query W^X */ +#define PROC_LOGSIGEXIT_CTL 23 /* en/dis logging on sigexit */ +#define PROC_LOGSIGEXIT_STATUS 24 /* query logging on sigexit */ /* Operations for PROC_SPROTECT (passed in integer arg). */ #define PPROT_OP(x) ((x) & 0xf) @@ -153,6 +155,10 @@ struct procctl_reaper_kill { #define PROC_WX_MAPPINGS_DISALLOW_EXEC 0x0002 #define PROC_WXORX_ENFORCE 0x80000000 +#define PROC_LOGSIGEXIT_CTL_NOFORCE 1 +#define PROC_LOGSIGEXIT_CTL_FORCE_ENABLE 2 +#define PROC_LOGSIGEXIT_CTL_FORCE_DISABLE 3 + #ifndef _KERNEL __BEGIN_DECLS int procctl(idtype_t, id_t, int, void *); diff --git a/lib/libc/include/generic-freebsd/sys/procdesc.h b/lib/libc/include/generic-freebsd/sys/procdesc.h index a257b1e2054349e25fd47eed72bf83da89fb9fcc..21e0ea9f84a91ce389547f046f07115108bd3a51 100644 --- a/lib/libc/include/generic-freebsd/sys/procdesc.h +++ b/lib/libc/include/generic-freebsd/sys/procdesc.h @@ -94,8 +94,10 @@ struct procdesc { * In-kernel interfaces to process descriptors. */ int procdesc_exit(struct proc *); -int procdesc_find(struct thread *, int fd, cap_rights_t *, struct proc **); -int kern_pdgetpid(struct thread *, int fd, cap_rights_t *, pid_t *pidp); +int procdesc_find(struct thread *, int fd, const cap_rights_t *, + struct proc **); +int kern_pdgetpid(struct thread *, int fd, const cap_rights_t *, + pid_t *pidp); void procdesc_new(struct proc *, int); void procdesc_finit(struct procdesc *, struct file *); pid_t procdesc_pid(struct file *); @@ -106,6 +108,7 @@ int procdesc_falloc(struct thread *, struct file **, int *, int, #else /* !_KERNEL */ +#include #include #ifndef _PID_T_DECLARED diff --git a/lib/libc/include/generic-freebsd/sys/protosw.h b/lib/libc/include/generic-freebsd/sys/protosw.h index 912810237975c4e925e49cc2e11060baabf30042..3fc387f2b3607d571e31bec266418b51a8c7ae7b 100644 --- a/lib/libc/include/generic-freebsd/sys/protosw.h +++ b/lib/libc/include/generic-freebsd/sys/protosw.h @@ -27,24 +27,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)protosw.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_PROTOSW_H_ #define _SYS_PROTOSW_H_ - -#include - -/* Forward declare these structures referenced from prototypes below. */ -struct kaiocb; -struct mbuf; -struct thread; -struct sockaddr; -struct socket; -struct sockopt; - -/*#ifdef _KERNEL*/ +#if defined(_KERNEL) || defined(_WANT_PROTOSW) /* * Protocol switch table. * @@ -54,16 +41,24 @@ struct sockopt; * In retrospect, it would be a lot nicer to use an interface * similar to the vnode VOP interface. */ +struct socket; +struct sockopt; +struct thread; +struct sockaddr; struct ifnet; +struct mbuf; struct stat; struct ucred; struct uio; +struct kaiocb; +struct knote; +enum shutdown_how; /* USE THESE FOR YOUR PROTOTYPES ! */ typedef int pr_ctloutput_t(struct socket *, struct sockopt *); typedef int pr_setsbopt_t(struct socket *, struct sockopt *); typedef void pr_abort_t(struct socket *); -typedef int pr_accept_t(struct socket *, struct sockaddr **); +typedef int pr_accept_t(struct socket *, struct sockaddr *); typedef int pr_attach_t(struct socket *, int, struct thread *); typedef int pr_bind_t(struct socket *, struct sockaddr *, struct thread *); typedef int pr_connect_t(struct socket *, struct sockaddr *, @@ -74,7 +69,7 @@ typedef int pr_control_t(struct socket *, unsigned long, void *, typedef void pr_detach_t(struct socket *); typedef int pr_disconnect_t(struct socket *); typedef int pr_listen_t(struct socket *, int, struct thread *); -typedef int pr_peeraddr_t(struct socket *, struct sockaddr **); +typedef int pr_peeraddr_t(struct socket *, struct sockaddr *); typedef int pr_rcvd_t(struct socket *, int); typedef int pr_rcvoob_t(struct socket *, struct mbuf *, int); typedef enum { @@ -86,17 +81,17 @@ typedef enum { } pr_send_flags_t; typedef int pr_send_t(struct socket *, int, struct mbuf *, struct sockaddr *, struct mbuf *, struct thread *); +typedef int pr_sendfile_wait_t(struct socket *, off_t, int *); typedef int pr_ready_t(struct socket *, struct mbuf *, int); typedef int pr_sense_t(struct socket *, struct stat *); -typedef int pr_shutdown_t(struct socket *); -typedef int pr_flush_t(struct socket *, int); -typedef int pr_sockaddr_t(struct socket *, struct sockaddr **); +typedef int pr_shutdown_t(struct socket *, enum shutdown_how); +typedef int pr_sockaddr_t(struct socket *, struct sockaddr *); typedef int pr_sosend_t(struct socket *, struct sockaddr *, struct uio *, struct mbuf *, struct mbuf *, int, struct thread *); typedef int pr_soreceive_t(struct socket *, struct sockaddr **, struct uio *, struct mbuf **, struct mbuf **, int *); -typedef int pr_sopoll_t(struct socket *, int, struct ucred *, - struct thread *); +typedef int pr_sopoll_t(struct socket *, int, struct thread *); +typedef int pr_kqfilter_t(struct socket *, struct knote *); typedef void pr_sosetlabel_t(struct socket *); typedef void pr_close_t(struct socket *); typedef int pr_bindat_t(int, struct socket *, struct sockaddr *, @@ -104,6 +99,8 @@ typedef int pr_bindat_t(int, struct socket *, struct sockaddr *, typedef int pr_connectat_t(int, struct socket *, struct sockaddr *, struct thread *); typedef int pr_aio_queue_t(struct socket *, struct kaiocb *); +typedef int pr_chmod_t(struct socket *, __mode_t, struct ucred *, + struct thread *); struct protosw { short pr_type; /* socket type used for */ @@ -113,9 +110,9 @@ struct protosw { struct domain *pr_domain; /* domain protocol a member of */ pr_soreceive_t *pr_soreceive; /* recv(2) */ - pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */ pr_sosend_t *pr_sosend; /* send(2) */ pr_send_t *pr_send; /* send(2) via sosend_generic() */ + pr_sendfile_wait_t *pr_sendfile_wait; /* sendfile helper */ pr_ready_t *pr_ready; /* sendfile/ktls readyness */ pr_sopoll_t *pr_sopoll; /* poll(2) */ /* Cache line #2 */ @@ -125,7 +122,7 @@ struct protosw { pr_disconnect_t *pr_disconnect; /* sodisconnect() */ pr_close_t *pr_close; /* close(2) */ pr_shutdown_t *pr_shutdown; /* shutdown(2) */ - pr_abort_t *pr_abort; /* abrupt tear down: soabort() */ + pr_rcvd_t *pr_rcvd; /* soreceive_generic() if PR_WANTRCVD */ pr_aio_queue_t *pr_aio_queue; /* aio(9) */ /* Cache line #3 */ pr_bind_t *pr_bind; /* bind(2) */ @@ -137,15 +134,18 @@ struct protosw { pr_control_t *pr_control; /* ioctl(2) */ pr_rcvoob_t *pr_rcvoob; /* soreceive_rcvoob() */ /* Cache line #4 */ + pr_abort_t *pr_abort; /* abrupt tear down: soabort() */ pr_ctloutput_t *pr_ctloutput; /* control output (from above) */ pr_peeraddr_t *pr_peeraddr; /* getpeername(2) */ pr_sockaddr_t *pr_sockaddr; /* getsockname(2) */ pr_sense_t *pr_sense; /* stat(2) */ - pr_flush_t *pr_flush; /* XXXGL: merge with pr_shutdown_t! */ pr_sosetlabel_t *pr_sosetlabel; /* MAC, XXXGL: remove */ pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */ + pr_chmod_t *pr_chmod; /* fchmod(2) */ + pr_kqfilter_t *pr_kqfilter; /* kevent(2) */ }; -/*#endif*/ +#endif /* defined(_KERNEL) || defined(_WANT_PROTOSW) */ +#ifdef _KERNEL /* * Values for pr_flags. @@ -162,37 +162,12 @@ struct protosw { #define PR_ADDR 0x02 /* addresses given with messages */ #define PR_CONNREQUIRED 0x04 /* connection required by protocol */ #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ -#define PR_RIGHTS 0x10 /* passes capabilities */ +/* was PR_RIGHTS 0x10 passes capabilities */ #define PR_IMPLOPCL 0x20 /* implied open/close */ /* was PR_LASTHDR 0x40 enforce ipsec policy; last header */ #define PR_CAPATTACH 0x80 /* socket can attach in cap mode */ #define PR_SOCKBUF 0x100 /* private implementation of buffers */ -/* - * The arguments to ctloutput are: - * (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p); - * req is one of the actions listed below, so is a (struct socket *), - * level is an indication of which protocol layer the option is intended. - * optname is a protocol dependent socket option request, - * optval is a pointer to a mbuf-chain pointer, for value-return results. - * The protocol is responsible for disposal of the mbuf chain *optval - * if supplied, - * the caller is responsible for any space held by *optval, when returned. - * A non-zero return from ctloutput gives an - * UNIX error number which should be passed to higher level software. - */ -#define PRCO_GETOPT 0 -#define PRCO_SETOPT 1 - -#define PRCO_NCMDS 2 - -#ifdef PRCOREQUESTS -char *prcorequests[] = { - "GETOPT", "SETOPT", -}; -#endif - -#ifdef _KERNEL struct domain *pffinddomain(int family); struct protosw *pffindproto(int family, int type, int proto); int protosw_register(struct domain *, struct protosw *); @@ -202,5 +177,4 @@ int protosw_unregister(struct protosw *); extern struct domain inetdomain; extern struct domain inet6domain; #endif - #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/ptrace.h b/lib/libc/include/generic-freebsd/sys/ptrace.h index 1d1d4db0d32c4c3266796344e6536952f563a6c8..e621c0b689af3e4c25668d7f5aa0adbd56f4a7b9 100644 --- a/lib/libc/include/generic-freebsd/sys/ptrace.h +++ b/lib/libc/include/generic-freebsd/sys/ptrace.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 */ #ifndef _SYS_PTRACE_H_ @@ -89,8 +87,16 @@ #define PT_SC_REMOTE 44 /* Execute a syscall */ #define PT_FIRSTMACH 64 /* for machine-specific requests */ +#define PT_LASTMACH 127 #include /* machine-specific requests, if any */ +#ifdef _KERNEL +/* Space for ptrace commands not exposed directly to userspace. */ +#define PTINTERNAL_FIRST 128 +#define PTINTERNAL_LAST 191 +#define PTLINUX_GET_SC_ARGS (PTINTERNAL_FIRST + 0) +#endif + /* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */ #define PTRACE_EXEC 0x0001 #define PTRACE_SCE 0x0002 @@ -152,7 +158,7 @@ struct ptrace_lwpinfo32 { int pl_flags; /* LWP flags. */ sigset_t pl_sigmask; /* LWP signal mask */ sigset_t pl_siglist; /* LWP pending signal */ - struct siginfo32 pl_siginfo; /* siginfo for signal */ + struct __siginfo32 pl_siginfo; /* siginfo for signal */ char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */ pid_t pl_child_pid; /* New child pid */ u_int pl_syscall_code; diff --git a/lib/libc/include/generic-freebsd/sys/qmath.h b/lib/libc/include/generic-freebsd/sys/qmath.h index cc388623d3c02f57f3a41785f1328cca6e6eeeb2..6c469e7d9cb95a9a9632c62b9df2fca29c36dbee 100644 --- a/lib/libc/include/generic-freebsd/sys/qmath.h +++ b/lib/libc/include/generic-freebsd/sys/qmath.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2018 Netflix, Inc. + * Copyright (c) 2018-2024 Netflix, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -378,15 +378,18 @@ typedef u64q_t umaxq_t; #define Q_QMINQ(a, b) (Q_LT(a, b) ? (a) : (b)) /* - * Test if 'a' can be represented by 'b' with full accuracy (T) or not (F). - * The type casting has to be done to a's type so that any truncation caused by - * the casts will not affect the logic. + * Test if 'a' can be represented by 'b' with full accuracy (0) or not + * (EOVERFLOW). If 'b' has fewer integer and/or fractional bits than 'a', + * the integer and fractional values stored in 'a' must fit in the available + * number of integer and fractional bits in 'b'. */ -#define Q_QCANREPQ(a, b) \ - ((((Q_LTZ(a) && Q_SIGNED(b)) || !Q_LTZ(a)) && \ - Q_GIABSVAL(a) <= Q_TC(a, Q_IMAXVAL(b)) && \ - Q_GFABSVAL(a) <= Q_TC(a, Q_FMAXVAL(b))) ? \ - 0 : EOVERFLOW) +#define Q_QCANREPQ(a, b) (( \ + (!Q_LTZ(a) || Q_SIGNED(b)) \ + && ( Q_NIBITS(a) <= Q_NIBITS(b) \ + || 0 == (Q_GIABSVAL(a) & (~Q_TC(a, 0) << Q_NIBITS(b)))) \ + && ( Q_NFBITS(a) <= Q_NFBITS(b) \ + || 0 == (Q_GFABSVAL(a) & ~(~Q_TC(a, 0) << (Q_NFBITS(a) - Q_NFBITS(b))))) \ + ) ? 0 : EOVERFLOW) /* Test if raw integer value 'i' can be represented by 'q' (T) or not (F). */ #define Q_QCANREPI(q, i) \ diff --git a/lib/libc/include/generic-freebsd/sys/queue.h b/lib/libc/include/generic-freebsd/sys/queue.h index 2a8c6942003b396783529712f4100499b8aaf8c4..15d07559fb8beef91e9cf24b4816b741772c21d8 100644 --- a/lib/libc/include/generic-freebsd/sys/queue.h +++ b/lib/libc/include/generic-freebsd/sys/queue.h @@ -27,12 +27,10 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 */ #ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ #include @@ -113,15 +111,15 @@ * _REMOVE_HEAD + + + + * _REMOVE s + s + * _REPLACE - + - + + * _SPLIT_AFTER + + + + * _SWAP + + + + * */ #ifdef QUEUE_MACRO_DEBUG -#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH -#define QUEUE_MACRO_DEBUG_TRACE -#define QUEUE_MACRO_DEBUG_TRASH +#warn Use QUEUE_MACRO_DEBUG_xxx instead (TRACE, TRASH and/or ASSERTIONS) +#define QUEUE_MACRO_DEBUG_TRACE +#define QUEUE_MACRO_DEBUG_TRASH #endif - #ifdef QUEUE_MACRO_DEBUG_TRACE /* Store the last 2 places the queue element or head was altered */ struct qm_trace { @@ -131,17 +129,17 @@ struct qm_trace { const char *prevfile; }; -#define TRACEBUF struct qm_trace trace; -#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } , +#define TRACEBUF struct qm_trace trace; +#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } , -#define QMD_TRACE_HEAD(head) do { \ +#define QMD_TRACE_HEAD(head) do { \ (head)->trace.prevline = (head)->trace.lastline; \ (head)->trace.prevfile = (head)->trace.lastfile; \ (head)->trace.lastline = __LINE__; \ (head)->trace.lastfile = __FILE__; \ } while (0) -#define QMD_TRACE_ELEM(elem) do { \ +#define QMD_TRACE_ELEM(elem) do { \ (elem)->trace.prevline = (elem)->trace.lastline; \ (elem)->trace.prevfile = (elem)->trace.lastfile; \ (elem)->trace.lastline = __LINE__; \ @@ -149,53 +147,110 @@ struct qm_trace { } while (0) #else /* !QUEUE_MACRO_DEBUG_TRACE */ -#define QMD_TRACE_ELEM(elem) -#define QMD_TRACE_HEAD(head) -#define TRACEBUF -#define TRACEBUF_INITIALIZER +#define QMD_TRACE_ELEM(elem) +#define QMD_TRACE_HEAD(head) +#define TRACEBUF +#define TRACEBUF_INITIALIZER #endif /* QUEUE_MACRO_DEBUG_TRACE */ #ifdef QUEUE_MACRO_DEBUG_TRASH -#define QMD_SAVELINK(name, link) void **name = (void *)&(link) -#define TRASHIT(x) do {(x) = (void *)-1;} while (0) -#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1) +#define QMD_SAVELINK(name, link) void **name = (void *)&(link) +#define TRASHIT(x) do {(x) = (void *)-1;} while (0) +#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1) #else /* !QUEUE_MACRO_DEBUG_TRASH */ -#define QMD_SAVELINK(name, link) -#define TRASHIT(x) -#define QMD_IS_TRASHED(x) 0 +#define QMD_SAVELINK(name, link) +#define TRASHIT(x) +#define QMD_IS_TRASHED(x) 0 #endif /* QUEUE_MACRO_DEBUG_TRASH */ +#if defined(QUEUE_MACRO_DEBUG_ASSERTIONS) && \ + defined(QUEUE_MACRO_NO_DEBUG_ASSERTIONS) +#error Both QUEUE_MACRO_DEBUG_ASSERTIONS and QUEUE_MACRO_NO_DEBUG_ASSERTIONS defined +#endif + +/* + * Automatically define QUEUE_MACRO_DEBUG_ASSERTIONS when compiling the kernel + * with INVARIANTS, if not already defined and not prevented by presence of + * QUEUE_MACRO_NO_DEBUG_ASSERTIONS. + */ +#if !defined(QUEUE_MACRO_DEBUG_ASSERTIONS) && \ + !defined(QUEUE_MACRO_NO_DEBUG_ASSERTIONS) && \ + (defined(_KERNEL) && defined(INVARIANTS)) +#define QUEUE_MACRO_DEBUG_ASSERTIONS +#endif + +/* + * If queue assertions are enabled, provide default definitions for QMD_PANIC() + * and QMD_ASSERT() if undefined. + */ +#ifdef QUEUE_MACRO_DEBUG_ASSERTIONS +#ifndef QMD_PANIC +#if defined(_KERNEL) || defined(_STANDALONE) +/* + * On _STANDALONE, either or the headers using provide + * a declaration or macro for panic(). + */ +#ifdef _KERNEL +#include +#endif +#define QMD_PANIC(fmt, ...) do { \ + panic(fmt, ##__VA_ARGS__); \ +} while (0) +#else /* !(_KERNEL || _STANDALONE) */ +#include +#include +#define QMD_PANIC(fmt, ...) do { \ + fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ + abort(); \ +} while (0) +#endif /* _KERNEL || _STANDALONE */ +#endif /* !QMD_PANIC */ + +#ifndef QMD_ASSERT +#define QMD_ASSERT(expression, fmt, ...) do { \ + if (__predict_false(!(expression))) \ + QMD_PANIC("%s:%u: %s: " fmt, \ + __FILE__, __LINE__, __func__, ##__VA_ARGS__); \ +} while (0) +#endif /* !QMD_ASSERT */ +#else /* !QUEUE_MACRO_DEBUG_ASSERTIONS */ +#undef QMD_ASSERT +#define QMD_ASSERT(test, fmt, ...) do {} while (0) +#endif /* QUEUE_MACRO_DEBUG_ASSERTIONS */ + + #ifdef __cplusplus /* * In C++ there can be structure lists and class lists: */ -#define QUEUE_TYPEOF(type) type +#define QUEUE_TYPEOF(type) type #else -#define QUEUE_TYPEOF(type) struct type +#define QUEUE_TYPEOF(type) struct type #endif /* * Singly-linked List declarations. */ -#define SLIST_HEAD(name, type) \ + +#define SLIST_HEAD(name, type) \ struct name { \ struct type *slh_first; /* first element */ \ } -#define SLIST_CLASS_HEAD(name, type) \ +#define SLIST_CLASS_HEAD(name, type) \ struct name { \ class type *slh_first; /* first element */ \ } -#define SLIST_HEAD_INITIALIZER(head) \ +#define SLIST_HEAD_INITIALIZER(head) \ { NULL } -#define SLIST_ENTRY(type) \ +#define SLIST_ENTRY(type) \ struct { \ struct type *sle_next; /* next element */ \ } -#define SLIST_CLASS_ENTRY(type) \ +#define SLIST_CLASS_ENTRY(type) \ struct { \ class type *sle_next; /* next element */ \ } @@ -203,137 +258,151 @@ struct { \ /* * Singly-linked List functions. */ -#if (defined(_KERNEL) && defined(INVARIANTS)) -#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \ - if (*(prevp) != (elm)) \ - panic("Bad prevptr *(%p) == %p != %p", \ - (prevp), *(prevp), (elm)); \ -} while (0) -#else -#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) -#endif + +#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) \ + QMD_ASSERT(*(prevp) == (elm), \ + "Bad prevptr *(%p) == %p != %p", \ + (prevp), *(prevp), (elm)) + +#define SLIST_ASSERT_EMPTY(head) \ + QMD_ASSERT(SLIST_EMPTY((head)), \ + "slist %p is not empty", (head)) + +#define SLIST_ASSERT_NONEMPTY(head) \ + QMD_ASSERT(!SLIST_EMPTY((head)), \ + "slist %p is empty", (head)) #define SLIST_CONCAT(head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ - if (curelm == NULL) { \ + QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head1); \ + if (_Curelm == NULL) { \ if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ SLIST_INIT(head2); \ } else if (SLIST_FIRST(head2) != NULL) { \ - while (SLIST_NEXT(curelm, field) != NULL) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ + while (SLIST_NEXT(_Curelm, field) != NULL) \ + _Curelm = SLIST_NEXT(_Curelm, field); \ + SLIST_NEXT(_Curelm, field) = SLIST_FIRST(head2); \ SLIST_INIT(head2); \ } \ } while (0) -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_EMPTY_ATOMIC(head) \ + (atomic_load_ptr(&(head)->slh_first) == NULL) -#define SLIST_FOREACH(var, head, field) \ +#define SLIST_FIRST(head) ((head)->slh_first) + +#define SLIST_FOREACH(var, head, field) \ for ((var) = SLIST_FIRST((head)); \ (var); \ (var) = SLIST_NEXT((var), field)) -#define SLIST_FOREACH_FROM(var, head, field) \ +#define SLIST_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ (var); \ (var) = SLIST_NEXT((var), field)) -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = SLIST_FIRST((head)); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) = (tvar)) -#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ +#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) = (tvar)) -#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ +#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ for ((varp) = &SLIST_FIRST((head)); \ ((var) = *(varp)) != NULL; \ (varp) = &SLIST_NEXT((var), field)) -#define SLIST_INIT(head) do { \ +#define SLIST_INIT(head) do { \ SLIST_FIRST((head)) = NULL; \ } while (0) -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ SLIST_NEXT((slistelm), field) = (elm); \ } while (0) -#define SLIST_INSERT_HEAD(head, elm, field) do { \ +#define SLIST_INSERT_HEAD(head, elm, field) do { \ SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ SLIST_FIRST((head)) = (elm); \ } while (0) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) -#define SLIST_REMOVE(head, elm, type, field) do { \ +#define SLIST_REMOVE(head, elm, type, field) do { \ if (SLIST_FIRST((head)) == (elm)) { \ SLIST_REMOVE_HEAD((head), field); \ } \ else { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ + QUEUE_TYPEOF(type) *_Curelm = SLIST_FIRST(head); \ + while (SLIST_NEXT(_Curelm, field) != (elm)) \ + _Curelm = SLIST_NEXT(_Curelm, field); \ + SLIST_REMOVE_AFTER(_Curelm, field); \ } \ } while (0) #define SLIST_REMOVE_AFTER(elm, field) do { \ - QMD_SAVELINK(oldnext, SLIST_NEXT(elm, field)->field.sle_next); \ + QMD_SAVELINK(_Oldnext, SLIST_NEXT(elm, field)->field.sle_next); \ SLIST_NEXT(elm, field) = \ SLIST_NEXT(SLIST_NEXT(elm, field), field); \ - TRASHIT(*oldnext); \ + TRASHIT(*_Oldnext); \ } while (0) -#define SLIST_REMOVE_HEAD(head, field) do { \ - QMD_SAVELINK(oldnext, SLIST_FIRST(head)->field.sle_next); \ +#define SLIST_REMOVE_HEAD(head, field) do { \ + QMD_SAVELINK(_Oldnext, SLIST_FIRST(head)->field.sle_next); \ SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ - TRASHIT(*oldnext); \ + TRASHIT(*_Oldnext); \ } while (0) -#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \ +#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \ QMD_SLIST_CHECK_PREVPTR(prevp, elm); \ *(prevp) = SLIST_NEXT(elm, field); \ TRASHIT((elm)->field.sle_next); \ } while (0) +#define SLIST_SPLIT_AFTER(head, elm, rest, field) do { \ + SLIST_ASSERT_NONEMPTY((head)); \ + SLIST_FIRST((rest)) = SLIST_NEXT((elm), field); \ + SLIST_NEXT((elm), field) = NULL; \ +} while (0) + #define SLIST_SWAP(head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ + QUEUE_TYPEOF(type) *_Swap_first = SLIST_FIRST(head1); \ SLIST_FIRST(head1) = SLIST_FIRST(head2); \ - SLIST_FIRST(head2) = swap_first; \ + SLIST_FIRST(head2) = _Swap_first; \ } while (0) -#define SLIST_END(head) NULL +#define SLIST_END(head) NULL /* * Singly-linked Tail queue declarations. */ -#define STAILQ_HEAD(name, type) \ + +#define STAILQ_HEAD(name, type) \ struct name { \ struct type *stqh_first;/* first element */ \ struct type **stqh_last;/* addr of last next element */ \ } -#define STAILQ_CLASS_HEAD(name, type) \ +#define STAILQ_CLASS_HEAD(name, type) \ struct name { \ class type *stqh_first; /* first element */ \ class type **stqh_last; /* addr of last next element */ \ } -#define STAILQ_HEAD_INITIALIZER(head) \ +#define STAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).stqh_first } -#define STAILQ_ENTRY(type) \ +#define STAILQ_ENTRY(type) \ struct { \ struct type *stqe_next; /* next element */ \ } -#define STAILQ_CLASS_ENTRY(type) \ +#define STAILQ_CLASS_ENTRY(type) \ struct { \ class type *stqe_next; /* next element */ \ } @@ -341,7 +410,38 @@ struct { \ /* * Singly-linked Tail queue functions. */ -#define STAILQ_CONCAT(head1, head2) do { \ + +/* + * QMD_STAILQ_CHECK_EMPTY(STAILQ_HEAD *head) + * + * Validates that the stailq head's pointer to the last element's next pointer + * actually points to the head's first element pointer field. + */ +#define QMD_STAILQ_CHECK_EMPTY(head) \ + QMD_ASSERT((head)->stqh_last == &(head)->stqh_first, \ + "Empty stailq %p->stqh_last is %p, " \ + "not head's first field address", \ + (head), (head)->stqh_last) + +/* + * QMD_STAILQ_CHECK_TAIL(STAILQ_HEAD *head) + * + * Validates that the stailq's last element's next pointer is NULL. + */ +#define QMD_STAILQ_CHECK_TAIL(head) \ + QMD_ASSERT(*(head)->stqh_last == NULL, \ + "Stailq %p last element's next pointer is " \ + "%p, not NULL", (head), *(head)->stqh_last) + +#define STAILQ_ASSERT_EMPTY(head) \ + QMD_ASSERT(STAILQ_EMPTY((head)), \ + "stailq %p is not empty", (head)) + +#define STAILQ_ASSERT_NONEMPTY(head) \ + QMD_ASSERT(!STAILQ_EMPTY((head)), \ + "stailq %p is empty", (head)) + +#define STAILQ_CONCAT(head1, head2) do { \ if (!STAILQ_EMPTY((head2))) { \ *(head1)->stqh_last = (head2)->stqh_first; \ (head1)->stqh_last = (head2)->stqh_last; \ @@ -349,72 +449,80 @@ struct { \ } \ } while (0) -#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) +#define STAILQ_EMPTY(head) ({ \ + if (STAILQ_FIRST(head) == NULL) \ + QMD_STAILQ_CHECK_EMPTY(head); \ + STAILQ_FIRST(head) == NULL; \ +}) -#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_EMPTY_ATOMIC(head) \ + (atomic_load_ptr(&(head)->stqh_first) == NULL) -#define STAILQ_FOREACH(var, head, field) \ +#define STAILQ_FIRST(head) ((head)->stqh_first) + +#define STAILQ_FOREACH(var, head, field) \ for((var) = STAILQ_FIRST((head)); \ (var); \ (var) = STAILQ_NEXT((var), field)) -#define STAILQ_FOREACH_FROM(var, head, field) \ +#define STAILQ_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ (var); \ (var) = STAILQ_NEXT((var), field)) -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = STAILQ_FIRST((head)); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) = (tvar)) -#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ +#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) = (tvar)) -#define STAILQ_INIT(head) do { \ +#define STAILQ_INIT(head) do { \ STAILQ_FIRST((head)) = NULL; \ (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ +#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ STAILQ_NEXT((tqelm), field) = (elm); \ } while (0) -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ STAILQ_FIRST((head)) = (elm); \ } while (0) -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + QMD_STAILQ_CHECK_TAIL(head); \ STAILQ_NEXT((elm), field) = NULL; \ *(head)->stqh_last = (elm); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) -#define STAILQ_LAST(head, type, field) \ +#define STAILQ_LAST(head, type, field) \ (STAILQ_EMPTY((head)) ? NULL : \ __containerof((head)->stqh_last, \ QUEUE_TYPEOF(type), field.stqe_next)) -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) -#define STAILQ_REMOVE(head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ +#define STAILQ_REMOVE(head, elm, type, field) do { \ + QMD_SAVELINK(_Oldnext, (elm)->field.stqe_next); \ if (STAILQ_FIRST((head)) == (elm)) { \ STAILQ_REMOVE_HEAD((head), field); \ } \ else { \ - QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ + QUEUE_TYPEOF(type) *_Curelm = STAILQ_FIRST(head); \ + while (STAILQ_NEXT(_Curelm, field) != (elm)) \ + _Curelm = STAILQ_NEXT(_Curelm, field); \ + STAILQ_REMOVE_AFTER(head, _Curelm, field); \ } \ - TRASHIT(*oldnext); \ + TRASHIT(*_Oldnext); \ } while (0) #define STAILQ_REMOVE_AFTER(head, elm, field) do { \ @@ -423,51 +531,81 @@ struct { \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) -#define STAILQ_REMOVE_HEAD(head, field) do { \ +#define STAILQ_REMOVE_HEAD(head, field) do { \ if ((STAILQ_FIRST((head)) = \ STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) +#define STAILQ_SPLIT_AFTER(head, elm, rest, field) do { \ + STAILQ_ASSERT_NONEMPTY((head)); \ + QMD_STAILQ_CHECK_TAIL((head)); \ + if (STAILQ_NEXT((elm), field) == NULL) \ + /* 'elm' is the last element in 'head'. */ \ + STAILQ_INIT((rest)); \ + else { \ + STAILQ_FIRST((rest)) = STAILQ_NEXT((elm), field); \ + (rest)->stqh_last = (head)->stqh_last; \ + STAILQ_NEXT((elm), field) = NULL; \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + } \ +} while (0) + #define STAILQ_SWAP(head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ - QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ + QUEUE_TYPEOF(type) *_Swap_first = STAILQ_FIRST(head1); \ + QUEUE_TYPEOF(type) **_Swap_last = (head1)->stqh_last; \ STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_FIRST(head2) = swap_first; \ - (head2)->stqh_last = swap_last; \ - if (STAILQ_EMPTY(head1)) \ + STAILQ_FIRST(head2) = _Swap_first; \ + (head2)->stqh_last = _Swap_last; \ + if (STAILQ_FIRST(head1) == NULL) \ (head1)->stqh_last = &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ + if (STAILQ_FIRST(head2) == NULL) \ (head2)->stqh_last = &STAILQ_FIRST(head2); \ } while (0) -#define STAILQ_END(head) NULL +#define STAILQ_REVERSE(head, type, field) do { \ + if (STAILQ_EMPTY(head)) \ + break; \ + QUEUE_TYPEOF(type) *_Var, *_Varp, *_Varn; \ + for (_Var = STAILQ_FIRST(head), _Varp = NULL; \ + _Var != NULL;) { \ + _Varn = STAILQ_NEXT(_Var, field); \ + STAILQ_NEXT(_Var, field) = _Varp; \ + _Varp = _Var; \ + _Var = _Varn; \ + } \ + (head)->stqh_last = &STAILQ_NEXT(STAILQ_FIRST(head), field); \ + (head)->stqh_first = _Varp; \ +} while (0) + +#define STAILQ_END(head) NULL /* * List declarations. */ -#define LIST_HEAD(name, type) \ + +#define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } -#define LIST_CLASS_HEAD(name, type) \ +#define LIST_CLASS_HEAD(name, type) \ struct name { \ class type *lh_first; /* first element */ \ } -#define LIST_HEAD_INITIALIZER(head) \ +#define LIST_HEAD_INITIALIZER(head) \ { NULL } -#define LIST_ENTRY(type) \ +#define LIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } -#define LIST_CLASS_ENTRY(type) \ +#define LIST_CLASS_ENTRY(type) \ struct { \ class type *le_next; /* next element */ \ class type **le_prev; /* address of previous next element */ \ @@ -477,19 +615,18 @@ struct { \ * List functions. */ -#if (defined(_KERNEL) && defined(INVARIANTS)) /* * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) * * If the list is non-empty, validates that the first element of the list * points back at 'head.' */ -#define QMD_LIST_CHECK_HEAD(head, field) do { \ - if (LIST_FIRST((head)) != NULL && \ - LIST_FIRST((head))->field.le_prev != \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev != head", (head)); \ -} while (0) +#define QMD_LIST_CHECK_HEAD(head, field) \ + QMD_ASSERT(LIST_FIRST((head)) == NULL || \ + LIST_FIRST((head))->field.le_prev == \ + &LIST_FIRST((head)), \ + "Bad list head %p first->prev != head", \ + (head)) /* * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) @@ -497,74 +634,78 @@ struct { \ * If an element follows 'elm' in the list, validates that the next element * points back at 'elm.' */ -#define QMD_LIST_CHECK_NEXT(elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL && \ - LIST_NEXT((elm), field)->field.le_prev != \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) +#define QMD_LIST_CHECK_NEXT(elm, field) \ + QMD_ASSERT(LIST_NEXT((elm), field) == NULL || \ + LIST_NEXT((elm), field)->field.le_prev == \ + &((elm)->field.le_next), \ + "Bad link elm %p next->prev != elm", (elm)) /* * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) * * Validates that the previous element (or head of the list) points to 'elm.' */ -#define QMD_LIST_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.le_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD(head, field) -#define QMD_LIST_CHECK_NEXT(elm, field) -#define QMD_LIST_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ +#define QMD_LIST_CHECK_PREV(elm, field) \ + QMD_ASSERT(*(elm)->field.le_prev == (elm), \ + "Bad link elm %p prev->next != elm", (elm)) + +#define LIST_ASSERT_EMPTY(head) \ + QMD_ASSERT(LIST_EMPTY((head)), \ + "list %p is not empty", (head)) + +#define LIST_ASSERT_NONEMPTY(head) \ + QMD_ASSERT(!LIST_EMPTY((head)), \ + "list %p is empty", (head)) #define LIST_CONCAT(head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ - if (curelm == NULL) { \ + QUEUE_TYPEOF(type) *_Curelm = LIST_FIRST(head1); \ + if (_Curelm == NULL) { \ if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ LIST_FIRST(head2)->field.le_prev = \ &LIST_FIRST((head1)); \ LIST_INIT(head2); \ } \ } else if (LIST_FIRST(head2) != NULL) { \ - while (LIST_NEXT(curelm, field) != NULL) \ - curelm = LIST_NEXT(curelm, field); \ - LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ - LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field);\ + while (LIST_NEXT(_Curelm, field) != NULL) \ + _Curelm = LIST_NEXT(_Curelm, field); \ + LIST_NEXT(_Curelm, field) = LIST_FIRST(head2); \ + LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(_Curelm, field);\ LIST_INIT(head2); \ } \ } while (0) -#define LIST_EMPTY(head) ((head)->lh_first == NULL) +#define LIST_EMPTY(head) ((head)->lh_first == NULL) -#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_EMPTY_ATOMIC(head) \ + (atomic_load_ptr(&(head)->lh_first) == NULL) -#define LIST_FOREACH(var, head, field) \ +#define LIST_FIRST(head) ((head)->lh_first) + +#define LIST_FOREACH(var, head, field) \ for ((var) = LIST_FIRST((head)); \ (var); \ (var) = LIST_NEXT((var), field)) -#define LIST_FOREACH_FROM(var, head, field) \ +#define LIST_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ (var); \ (var) = LIST_NEXT((var), field)) -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = LIST_FIRST((head)); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) = (tvar)) -#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ +#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) = (tvar)) -#define LIST_INIT(head) do { \ +#define LIST_INIT(head) do { \ LIST_FIRST((head)) = NULL; \ } while (0) -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ QMD_LIST_CHECK_NEXT(listelm, field); \ if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ LIST_NEXT((listelm), field)->field.le_prev = \ @@ -573,7 +714,7 @@ struct { \ (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ } while (0) -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ QMD_LIST_CHECK_PREV(listelm, field); \ (elm)->field.le_prev = (listelm)->field.le_prev; \ LIST_NEXT((elm), field) = (listelm); \ @@ -581,7 +722,7 @@ struct { \ (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ } while (0) -#define LIST_INSERT_HEAD(head, elm, field) do { \ +#define LIST_INSERT_HEAD(head, elm, field) do { \ QMD_LIST_CHECK_HEAD((head), field); \ if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ @@ -589,9 +730,9 @@ struct { \ (elm)->field.le_prev = &LIST_FIRST((head)); \ } while (0) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) -#define LIST_PREV(elm, head, type, field) \ +#define LIST_PREV(elm, head, type, field) \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ __containerof((elm)->field.le_prev, \ QUEUE_TYPEOF(type), field.le_next)) @@ -599,22 +740,22 @@ struct { \ #define LIST_REMOVE_HEAD(head, field) \ LIST_REMOVE(LIST_FIRST(head), field) -#define LIST_REMOVE(elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ +#define LIST_REMOVE(elm, field) do { \ + QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \ + QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \ QMD_LIST_CHECK_NEXT(elm, field); \ QMD_LIST_CHECK_PREV(elm, field); \ if (LIST_NEXT((elm), field) != NULL) \ LIST_NEXT((elm), field)->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ + TRASHIT(*_Oldnext); \ + TRASHIT(*_Oldprev); \ } while (0) #define LIST_REPLACE(elm, elm2, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ + QMD_SAVELINK(_Oldnext, (elm)->field.le_next); \ + QMD_SAVELINK(_Oldprev, (elm)->field.le_prev); \ QMD_LIST_CHECK_NEXT(elm, field); \ QMD_LIST_CHECK_PREV(elm, field); \ LIST_NEXT((elm2), field) = LIST_NEXT((elm), field); \ @@ -623,8 +764,21 @@ struct { \ &(elm2)->field.le_next; \ (elm2)->field.le_prev = (elm)->field.le_prev; \ *(elm2)->field.le_prev = (elm2); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ + TRASHIT(*_Oldnext); \ + TRASHIT(*_Oldprev); \ +} while (0) + +#define LIST_SPLIT_AFTER(head, elm, rest, field) do { \ + LIST_ASSERT_NONEMPTY((head)); \ + if (LIST_NEXT((elm), field) == NULL) \ + /* 'elm' is the last element in 'head'. */ \ + LIST_INIT((rest)); \ + else { \ + LIST_FIRST((rest)) = LIST_NEXT((elm), field); \ + LIST_NEXT((elm), field)->field.le_prev = \ + &LIST_FIRST((rest)); \ + LIST_NEXT((elm), field) = NULL; \ + } \ } while (0) #define LIST_SWAP(head1, head2, type, field) do { \ @@ -637,36 +791,37 @@ struct { \ swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ } while (0) -#define LIST_END(head) NULL +#define LIST_END(head) NULL /* * Tail queue declarations. */ -#define TAILQ_HEAD(name, type) \ + +#define TAILQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; /* first element */ \ struct type **tqh_last; /* addr of last next element */ \ TRACEBUF \ } -#define TAILQ_CLASS_HEAD(name, type) \ +#define TAILQ_CLASS_HEAD(name, type) \ struct name { \ class type *tqh_first; /* first element */ \ class type **tqh_last; /* addr of last next element */ \ TRACEBUF \ } -#define TAILQ_HEAD_INITIALIZER(head) \ +#define TAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } -#define TAILQ_ENTRY(type) \ +#define TAILQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ struct type **tqe_prev; /* address of previous next element */ \ TRACEBUF \ } -#define TAILQ_CLASS_ENTRY(type) \ +#define TAILQ_CLASS_ENTRY(type) \ struct { \ class type *tqe_next; /* next element */ \ class type **tqe_prev; /* address of previous next element */ \ @@ -676,29 +831,29 @@ struct { \ /* * Tail queue functions. */ -#if (defined(_KERNEL) && defined(INVARIANTS)) + /* * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) * * If the tailq is non-empty, validates that the first element of the tailq * points back at 'head.' */ -#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev != \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev != head", (head)); \ -} while (0) +#define QMD_TAILQ_CHECK_HEAD(head, field) \ + QMD_ASSERT(TAILQ_EMPTY(head) || \ + TAILQ_FIRST((head))->field.tqe_prev == \ + &TAILQ_FIRST((head)), \ + "Bad tailq head %p first->prev != head", \ + (head)) /* * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) * * Validates that the tail of the tailq is a pointer to pointer to NULL. */ -#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ - if (*(head)->tqh_last != NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ -} while (0) +#define QMD_TAILQ_CHECK_TAIL(head, field) \ + QMD_ASSERT(*(head)->tqh_last == NULL, \ + "Bad tailq NEXT(%p->tqh_last) != NULL", \ + (head)) /* * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) @@ -706,30 +861,30 @@ struct { \ * If an element follows 'elm' in the tailq, validates that the next element * points back at 'elm.' */ -#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ - if (TAILQ_NEXT((elm), field) != NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev != \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) +#define QMD_TAILQ_CHECK_NEXT(elm, field) \ + QMD_ASSERT(TAILQ_NEXT((elm), field) == NULL || \ + TAILQ_NEXT((elm), field)->field.tqe_prev == \ + &((elm)->field.tqe_next), \ + "Bad link elm %p next->prev != elm", (elm)) /* * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) * * Validates that the previous element (or head of the tailq) points to 'elm.' */ -#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.tqe_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_TAILQ_CHECK_HEAD(head, field) -#define QMD_TAILQ_CHECK_TAIL(head, headname) -#define QMD_TAILQ_CHECK_NEXT(elm, field) -#define QMD_TAILQ_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ +#define QMD_TAILQ_CHECK_PREV(elm, field) \ + QMD_ASSERT(*(elm)->field.tqe_prev == (elm), \ + "Bad link elm %p prev->next != elm", (elm)) -#define TAILQ_CONCAT(head1, head2, field) do { \ +#define TAILQ_ASSERT_EMPTY(head) \ + QMD_ASSERT(TAILQ_EMPTY((head)), \ + "tailq %p is not empty", (head)) + +#define TAILQ_ASSERT_NONEMPTY(head) \ + QMD_ASSERT(!TAILQ_EMPTY((head)), \ + "tailq %p is empty", (head)) + +#define TAILQ_CONCAT(head1, head2, field) do { \ if (!TAILQ_EMPTY(head2)) { \ *(head1)->tqh_last = (head2)->tqh_first; \ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ @@ -740,57 +895,60 @@ struct { \ } \ } while (0) -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_EMPTY_ATOMIC(head) \ + (atomic_load_ptr(&(head)->tqh_first) == NULL) -#define TAILQ_FOREACH(var, head, field) \ +#define TAILQ_FIRST(head) ((head)->tqh_first) + +#define TAILQ_FOREACH(var, head, field) \ for ((var) = TAILQ_FIRST((head)); \ (var); \ (var) = TAILQ_NEXT((var), field)) -#define TAILQ_FOREACH_FROM(var, head, field) \ +#define TAILQ_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ (var); \ (var) = TAILQ_NEXT((var), field)) -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = TAILQ_FIRST((head)); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) = (tvar)) -#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ +#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) = (tvar)) -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = TAILQ_LAST((head), headname); \ (var); \ (var) = TAILQ_PREV((var), headname, field)) -#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ +#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ (var); \ (var) = TAILQ_PREV((var), headname, field)) -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ for ((var) = TAILQ_LAST((head), headname); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) = (tvar)) -#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\ +#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar)\ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) = (tvar)) -#define TAILQ_INIT(head) do { \ +#define TAILQ_INIT(head) do { \ TAILQ_FIRST((head)) = NULL; \ (head)->tqh_last = &TAILQ_FIRST((head)); \ QMD_TRACE_HEAD(head); \ } while (0) -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ QMD_TAILQ_CHECK_NEXT(listelm, field); \ if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ TAILQ_NEXT((elm), field)->field.tqe_prev = \ @@ -805,7 +963,7 @@ struct { \ QMD_TRACE_ELEM(&(listelm)->field); \ } while (0) -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ QMD_TAILQ_CHECK_PREV(listelm, field); \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ TAILQ_NEXT((elm), field) = (listelm); \ @@ -815,7 +973,7 @@ struct { \ QMD_TRACE_ELEM(&(listelm)->field); \ } while (0) -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ QMD_TAILQ_CHECK_HEAD(head, field); \ if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ TAILQ_FIRST((head))->field.tqe_prev = \ @@ -828,7 +986,7 @@ struct { \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ QMD_TAILQ_CHECK_TAIL(head, field); \ TAILQ_NEXT((elm), field) = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ @@ -838,7 +996,7 @@ struct { \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) -#define TAILQ_LAST(head, headname) \ +#define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) /* @@ -848,24 +1006,24 @@ struct { \ * the previous element. FAST is very useful for instances when * you may want to prefetch the last data element. */ -#define TAILQ_LAST_FAST(head, type, field) \ +#define TAILQ_LAST_FAST(head, type, field) \ (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_PREV(elm, headname, field) \ +#define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_PREV_FAST(elm, head, type, field) \ +#define TAILQ_PREV_FAST(elm, head, type, field) \ ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) #define TAILQ_REMOVE_HEAD(head, field) \ TAILQ_REMOVE(head, TAILQ_FIRST(head), field) -#define TAILQ_REMOVE(head, elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ - QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ +#define TAILQ_REMOVE(head, elm, field) do { \ + QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \ + QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \ QMD_TAILQ_CHECK_NEXT(elm, field); \ QMD_TAILQ_CHECK_PREV(elm, field); \ if ((TAILQ_NEXT((elm), field)) != NULL) \ @@ -876,14 +1034,14 @@ struct { \ QMD_TRACE_HEAD(head); \ } \ *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ + TRASHIT(*_Oldnext); \ + TRASHIT(*_Oldprev); \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) #define TAILQ_REPLACE(head, elm, elm2, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ - QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ + QMD_SAVELINK(_Oldnext, (elm)->field.tqe_next); \ + QMD_SAVELINK(_Oldprev, (elm)->field.tqe_prev); \ QMD_TAILQ_CHECK_NEXT(elm, field); \ QMD_TAILQ_CHECK_PREV(elm, field); \ TAILQ_NEXT((elm2), field) = TAILQ_NEXT((elm), field); \ @@ -894,11 +1052,28 @@ struct { \ (head)->tqh_last = &(elm2)->field.tqe_next; \ (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ *(elm2)->field.tqe_prev = (elm2); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ + TRASHIT(*_Oldnext); \ + TRASHIT(*_Oldprev); \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) +#define TAILQ_SPLIT_AFTER(head, elm, rest, field) do { \ + TAILQ_ASSERT_NONEMPTY((head)); \ + QMD_TAILQ_CHECK_TAIL((head), field); \ + if (TAILQ_NEXT((elm), field) == NULL) \ + /* 'elm' is the last element in 'head'. */ \ + TAILQ_INIT((rest)); \ + else { \ + TAILQ_FIRST((rest)) = TAILQ_NEXT((elm), field); \ + (rest)->tqh_last = (head)->tqh_last; \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + &TAILQ_FIRST((rest)); \ + \ + TAILQ_NEXT((elm), field) = NULL; \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + } \ +} while (0) + #define TAILQ_SWAP(head1, head2, type, field) do { \ QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \ QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ @@ -916,6 +1091,6 @@ struct { \ (head2)->tqh_last = &(head2)->tqh_first; \ } while (0) -#define TAILQ_END(head) NULL +#define TAILQ_END(head) NULL #endif /* !_SYS_QUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/racct.h b/lib/libc/include/generic-freebsd/sys/racct.h index 66f97e4756366796d3455be87cc65be279d152e0..31141adb8c35d082a7c0b13325f64ac07a2e4695 100644 --- a/lib/libc/include/generic-freebsd/sys/racct.h +++ b/lib/libc/include/generic-freebsd/sys/racct.h @@ -35,7 +35,6 @@ #ifndef _RACCT_H_ #define _RACCT_H_ -#include #include #include #include @@ -142,13 +141,17 @@ extern bool racct_enable; /* * The 'racct' structure defines resource consumption for a particular - * subject, such as process or jail. + * subject, such as process or jail. It also contains the total + * cpu time and real time of the subject, recorded at the most recent + * time that RACCT_PCPU was updated. * * This structure must be filled with zeroes initially. */ struct racct { int64_t r_resources[RACCT_MAX + 1]; LIST_HEAD(, rctl_rule_link) r_rule_links; + uint64_t r_runtime; + struct timeval r_time; }; SYSCTL_DECL(_kern_racct); diff --git a/lib/libc/include/generic-freebsd/sys/random.h b/lib/libc/include/generic-freebsd/sys/random.h index c7e6e4c4275e573135d623c0cf9c92cd8b0c1eb1..7b9af981dfd1cd368900ab809e855486549eb7c9 100644 --- a/lib/libc/include/generic-freebsd/sys/random.h +++ b/lib/libc/include/generic-freebsd/sys/random.h @@ -85,24 +85,26 @@ enum random_entropy_source { RANDOM_FS_ATIME, RANDOM_UMA, /* Special!! UMA/SLAB Allocator */ RANDOM_CALLOUT, - RANDOM_ENVIRONMENTAL_END = RANDOM_CALLOUT, + RANDOM_RANDOMDEV, + RANDOM_ENVIRONMENTAL_END = RANDOM_RANDOMDEV, /* Fast hardware random-number sources from here on. */ RANDOM_PURE_START, - RANDOM_PURE_OCTEON = RANDOM_PURE_START, - RANDOM_PURE_SAFE, - RANDOM_PURE_GLXSB, - RANDOM_PURE_HIFN, + RANDOM_PURE_TPM = RANDOM_PURE_START, RANDOM_PURE_RDRAND, + RANDOM_PURE_RDSEED, RANDOM_PURE_NEHEMIAH, RANDOM_PURE_RNDTEST, RANDOM_PURE_VIRTIO, RANDOM_PURE_BROADCOM, RANDOM_PURE_CCP, RANDOM_PURE_DARN, - RANDOM_PURE_TPM, RANDOM_PURE_VMGENID, RANDOM_PURE_QUALCOMM, RANDOM_PURE_ARMV8, + RANDOM_PURE_ARM_TRNG, + RANDOM_PURE_SAFE, + RANDOM_PURE_GLXSB, + RANDOM_PURE_HIFN, ENTROPYSOURCE }; _Static_assert(ENTROPYSOURCE <= 32, @@ -140,9 +142,6 @@ random_harvest_direct(const void *entropy, u_int size, enum random_entropy_sourc random_harvest_direct_(entropy, size, origin); } -void random_harvest_register_source(enum random_entropy_source); -void random_harvest_deregister_source(enum random_entropy_source); - #if defined(RANDOM_ENABLE_UMA) #define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c) #else /* !defined(RANDOM_ENABLE_UMA) */ @@ -155,6 +154,12 @@ void random_harvest_deregister_source(enum random_entropy_source); #define random_harvest_queue_ether(a, b) do {} while (0) #endif /* defined(RANDOM_ENABLE_ETHER) */ +#else /* !_KERNEL */ + +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + #endif /* _KERNEL */ #define GRND_NONBLOCK 0x1 diff --git a/lib/libc/include/generic-freebsd/sys/rangelock.h b/lib/libc/include/generic-freebsd/sys/rangelock.h index b379e4d7334ed12992cc906a2569fee10bada499..b392d6bc5038524b398ba9b01f47aacc20d27c83 100644 --- a/lib/libc/include/generic-freebsd/sys/rangelock.h +++ b/lib/libc/include/generic-freebsd/sys/rangelock.h @@ -29,12 +29,14 @@ #ifndef _SYS_RANGELOCK_H #define _SYS_RANGELOCK_H -#include +#include +#ifndef _KERNEL +#include +#endif #define RL_LOCK_READ 0x0001 #define RL_LOCK_WRITE 0x0002 #define RL_LOCK_TYPE_MASK 0x0003 -#define RL_LOCK_GRANTED 0x0004 struct rl_q_entry; @@ -44,42 +46,26 @@ struct rl_q_entry; * all existing lock owners are compatible with the request. Two lock * owners are compatible if their ranges do not overlap, or both * owners are for read. - * - * Access to the structure itself is synchronized with the externally - * supplied mutex. - * - * rl_waiters is the queue containing in order (a) granted write lock - * requests, (b) granted read lock requests, and (c) in order of arrival, - * lock requests which cannot be granted yet. - * - * rl_currdep is the first lock request that cannot be granted now due - * to the preceding requests conflicting with it (i.e., it points to - * position (c) in the list above). */ struct rangelock { - TAILQ_HEAD(, rl_q_entry) rl_waiters; - struct rl_q_entry *rl_currdep; + uintptr_t head; + bool sleepers; }; #ifdef _KERNEL -struct mtx; - void rangelock_init(struct rangelock *lock); void rangelock_destroy(struct rangelock *lock); -void rangelock_unlock(struct rangelock *lock, void *cookie, - struct mtx *ilk); -void *rangelock_unlock_range(struct rangelock *lock, void *cookie, - off_t start, off_t end, struct mtx *ilk); -void *rangelock_rlock(struct rangelock *lock, off_t start, off_t end, - struct mtx *ilk); -void *rangelock_tryrlock(struct rangelock *lock, off_t start, off_t end, - struct mtx *ilk); -void *rangelock_wlock(struct rangelock *lock, off_t start, off_t end, - struct mtx *ilk); -void *rangelock_trywlock(struct rangelock *lock, off_t start, off_t end, - struct mtx *ilk); -void rlqentry_free(struct rl_q_entry *rlqe); +void rangelock_unlock(struct rangelock *lock, void *cookie); +void *rangelock_rlock(struct rangelock *lock, vm_ooffset_t start, + vm_ooffset_t end); +void *rangelock_tryrlock(struct rangelock *lock, vm_ooffset_t start, + vm_ooffset_t end); +void *rangelock_wlock(struct rangelock *lock, vm_ooffset_t start, + vm_ooffset_t end); +void *rangelock_trywlock(struct rangelock *lock, vm_ooffset_t start, + vm_ooffset_t end); +void rangelock_may_recurse(struct rangelock *lock); #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) void _rangelock_cookie_assert(void *cookie, int what, const char *file, int line); diff --git a/lib/libc/include/generic-freebsd/sys/rangeset.h b/lib/libc/include/generic-freebsd/sys/rangeset.h index 8e716f7b30739cc19aa6b7653e4cdf1d576674d6..007c9f8110349f77a05737f53fc9fb5fc3f7bac5 100644 --- a/lib/libc/include/generic-freebsd/sys/rangeset.h +++ b/lib/libc/include/generic-freebsd/sys/rangeset.h @@ -69,10 +69,19 @@ int rangeset_remove_pred(struct rangeset *rs, uint64_t start, uint64_t end, rs_pred_t pred); /* - * Really returns the pointer to the data with struct rs_el embedded - * at the beginning. + * Finds the range that contains place, if any. */ -void *rangeset_lookup(struct rangeset *rs, uint64_t place); +void *rangeset_containing(struct rangeset *rs, uint64_t place); + +/* + * Report whether no range begins between start and end. + */ +bool rangeset_empty(struct rangeset *rs, uint64_t start, uint64_t end); + +/* + * Finds the range that begins at place, if any. + */ +void *rangeset_beginning(struct rangeset *rs, uint64_t place); /* * Copies src_rs entries into dst_rs. dst_rs must be empty. diff --git a/lib/libc/include/generic-freebsd/sys/reboot.h b/lib/libc/include/generic-freebsd/sys/reboot.h index 33594130322b8cb9876228eb988813eeef40932d..76a7eca075bab53b19b37c414af2683d8071d276 100644 --- a/lib/libc/include/generic-freebsd/sys/reboot.h +++ b/lib/libc/include/generic-freebsd/sys/reboot.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)reboot.h 8.3 (Berkeley) 12/13/94 */ #ifndef _SYS_REBOOT_H_ @@ -62,6 +60,7 @@ #define RB_PAUSE 0x100000 /* pause after each output line during probe */ #define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */ #define RB_POWERCYCLE 0x400000 /* Power cycle if possible */ +#define RB_MUTEMSGS 0x800000 /* start up with console muted after banner */ #define RB_PROBE 0x10000000 /* Probe multiple consoles */ #define RB_MULTIPLE 0x20000000 /* use multiple consoles */ diff --git a/lib/libc/include/generic-freebsd/sys/refcount.h b/lib/libc/include/generic-freebsd/sys/refcount.h index ef49d96d39383d1d868d382ce3d7b9871b0ae57f..41f919e08edfa6d10cef9a544e7a1b1dbe784d81 100644 --- a/lib/libc/include/generic-freebsd/sys/refcount.h +++ b/lib/libc/include/generic-freebsd/sys/refcount.h @@ -28,15 +28,14 @@ #ifndef __SYS_REFCOUNT_H__ #define __SYS_REFCOUNT_H__ -#include - -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#else +#include +#include +#if !defined(_KERNEL) && !defined(_STANDALONE) #include -#define KASSERT(exp, msg) /* */ #endif +#include + #define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0) #define REFCOUNT_SATURATION_VALUE (3U << 30) @@ -65,7 +64,7 @@ refcount_init(volatile u_int *count, u_int value) } static __inline u_int -refcount_load(volatile u_int *count) +refcount_load(volatile const u_int *count) { return (atomic_load_int(count)); } diff --git a/lib/libc/include/generic-freebsd/sys/resource.h b/lib/libc/include/generic-freebsd/sys/resource.h index 76c4b59e4ffcaa0305324fb11902a3a7b3b9321b..05b28b5037f9971a94b35b18cdce824d052e7de2 100644 --- a/lib/libc/include/generic-freebsd/sys/resource.h +++ b/lib/libc/include/generic-freebsd/sys/resource.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)resource.h 8.4 (Berkeley) 1/9/95 */ #ifndef _SYS_RESOURCE_H_ diff --git a/lib/libc/include/generic-freebsd/sys/resourcevar.h b/lib/libc/include/generic-freebsd/sys/resourcevar.h index 32c7fbb8cc292b67b3a970f622b9d37deb60f439..90cab55431cfc33f8a94f8015168163a0d9c3823 100644 --- a/lib/libc/include/generic-freebsd/sys/resourcevar.h +++ b/lib/libc/include/generic-freebsd/sys/resourcevar.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)resourcevar.h 8.4 (Berkeley) 1/9/95 */ #ifndef _SYS_RESOURCEVAR_H_ @@ -124,6 +122,8 @@ struct uidinfo { long ui_kqcnt; /* (b) number of kqueues */ long ui_umtxcnt; /* (b) number of shared umtxs */ long ui_pipecnt; /* (b) consumption of pipe buffers */ + long ui_inotifycnt; /* (b) number of inotify descriptors */ + long ui_inotifywatchcnt; /* (b) number of inotify watches */ uid_t ui_uid; /* (a) uid */ u_int ui_ref; /* (b) reference count */ #ifdef RACCT @@ -146,6 +146,8 @@ int chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to, int chgptscnt(struct uidinfo *uip, int diff, rlim_t maxval); int chgumtxcnt(struct uidinfo *uip, int diff, rlim_t maxval); int chgpipecnt(struct uidinfo *uip, int diff, rlim_t max); +int chginotifycnt(struct uidinfo *uip, int diff, rlim_t maxval); +int chginotifywatchcnt(struct uidinfo *uip, int diff, rlim_t maxval); int kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which, struct rlimit *limp); struct plimit diff --git a/lib/libc/include/generic-freebsd/sys/rman.h b/lib/libc/include/generic-freebsd/sys/rman.h index 8437c898be8904f8066b524d7c056c423bb67e78..78e63888788a54d62cbf46a6348d8ea83b51daee 100644 --- a/lib/libc/include/generic-freebsd/sys/rman.h +++ b/lib/libc/include/generic-freebsd/sys/rman.h @@ -124,17 +124,18 @@ TAILQ_HEAD(rman_head, rman); int rman_activate_resource(struct resource *r); int rman_adjust_resource(struct resource *r, rman_res_t start, rman_res_t end); int rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end); -bus_space_handle_t rman_get_bushandle(struct resource *); -bus_space_tag_t rman_get_bustag(struct resource *); -rman_res_t rman_get_end(struct resource *); -device_t rman_get_device(struct resource *); -u_int rman_get_flags(struct resource *); -void *rman_get_irq_cookie(struct resource *); -void rman_get_mapping(struct resource *, struct resource_map *); -int rman_get_rid(struct resource *); -rman_res_t rman_get_size(struct resource *); -rman_res_t rman_get_start(struct resource *); -void *rman_get_virtual(struct resource *); +bus_space_handle_t rman_get_bushandle(const struct resource *); +bus_space_tag_t rman_get_bustag(const struct resource *); +rman_res_t rman_get_end(const struct resource *); +device_t rman_get_device(const struct resource *); +u_int rman_get_flags(const struct resource *); +void *rman_get_irq_cookie(const struct resource *); +void rman_get_mapping(const struct resource *, struct resource_map *); +int rman_get_rid(const struct resource *); +rman_res_t rman_get_size(const struct resource *); +rman_res_t rman_get_start(const struct resource *); +int rman_get_type(const struct resource *); +void *rman_get_virtual(const struct resource *); int rman_deactivate_resource(struct resource *r); int rman_fini(struct rman *rm); int rman_init(struct rman *rm); @@ -142,22 +143,18 @@ int rman_init_from_resource(struct rman *rm, struct resource *r); int rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end); uint32_t rman_make_alignment_flags(uint32_t size); int rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end); -int rman_is_region_manager(struct resource *r, struct rman *rm); +int rman_is_region_manager(const struct resource *r, const struct rman *rm); int rman_release_resource(struct resource *r); struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags, device_t dev); -struct resource *rman_reserve_resource_bound(struct rman *rm, rman_res_t start, - rman_res_t end, rman_res_t count, rman_res_t bound, - u_int flags, device_t dev); void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h); void rman_set_bustag(struct resource *_r, bus_space_tag_t _t); void rman_set_device(struct resource *_r, device_t _dev); -void rman_set_end(struct resource *_r, rman_res_t _end); void rman_set_irq_cookie(struct resource *_r, void *_c); void rman_set_mapping(struct resource *, struct resource_map *); void rman_set_rid(struct resource *_r, int _rid); -void rman_set_start(struct resource *_r, rman_res_t _start); +void rman_set_type(struct resource *_r, int _type); void rman_set_virtual(struct resource *_r, void *_v); extern struct rman_head rman_head; diff --git a/lib/libc/include/generic-freebsd/sys/rmlock.h b/lib/libc/include/generic-freebsd/sys/rmlock.h index 075cf60223ae8ca5b38a9e659eaf09aa4efcec53..8d797886675024a7be9f4b1f21f2e6d749d0c2b8 100644 --- a/lib/libc/include/generic-freebsd/sys/rmlock.h +++ b/lib/libc/include/generic-freebsd/sys/rmlock.h @@ -52,7 +52,7 @@ void rm_init(struct rmlock *rm, const char *name); void rm_init_flags(struct rmlock *rm, const char *name, int opts); void rm_destroy(struct rmlock *rm); int rm_wowned(const struct rmlock *rm); -void rm_sysinit(void *arg); +void rm_sysinit(const void *arg); void _rm_wlock_debug(struct rmlock *rm, const char *file, int line); void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line); diff --git a/lib/libc/include/generic-freebsd/sys/runq.h b/lib/libc/include/generic-freebsd/sys/runq.h index 7776786913bc2a8416c85642f0a6fad1ff942fff..588178c541c6887c6abc8150da7ab822f027ef1a 100644 --- a/lib/libc/include/generic-freebsd/sys/runq.h +++ b/lib/libc/include/generic-freebsd/sys/runq.h @@ -3,6 +3,11 @@ * * Copyright (c) 2001 Jake Burkholder * All rights reserved. + * Copyright (c) 2024 The FreeBSD Foundation + * + * Portions of this software were developed by Olivier Certner + * at Kumacom SARL under sponsorship from the FreeBSD + * Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +34,14 @@ #ifndef _RUNQ_H_ #define _RUNQ_H_ -#include +#ifndef _KERNEL +#error "no user-serviceable parts inside" +#endif + +#include /* For bool. */ +#include +#include +#include struct thread; @@ -37,20 +49,46 @@ struct thread; * Run queue parameters. */ -#define RQ_NQS (64) /* Number of run queues. */ -#define RQ_PPQ (4) /* Priorities per queue. */ +#define RQ_MAX_PRIO (255) /* Maximum priority (minimum is 0). */ +#define RQ_PPQ (1) /* Priorities per queue. */ /* - * Head of run queues. + * Deduced from the above parameters and machine ones. */ -TAILQ_HEAD(rqhead, thread); +#define RQ_NQS (howmany(RQ_MAX_PRIO + 1, RQ_PPQ)) /* Number of run queues. */ +#define RQ_PRI_TO_QUEUE_IDX(pri) ((pri) / RQ_PPQ) /* Priority to queue index. */ + +typedef unsigned long rqsw_t; /* runq's status words type. */ +#define RQSW_BPW (sizeof(rqsw_t) * NBBY) /* Bits per runq word. */ +#define RQSW_PRI "%#lx" /* printf() directive. */ + +/* Number of status words to cover RQ_NQS queues. */ +#define RQSW_NB (howmany(RQ_NQS, RQSW_BPW)) +#define RQSW_IDX(idx) ((idx) / RQSW_BPW) +#define RQSW_BIT_IDX(idx) ((idx) % RQSW_BPW) +#define RQSW_BIT(idx) (1ul << RQSW_BIT_IDX(idx)) +#define RQSW_BSF(word) __extension__ ({ \ + int _res = ffsl((long)(word)); /* Assumes two-complement. */ \ + MPASS(_res > 0); \ + _res - 1; \ +}) +#define RQSW_TO_QUEUE_IDX(word_idx, bit_idx) \ + (((word_idx) * RQSW_BPW) + (bit_idx)) +#define RQSW_FIRST_QUEUE_IDX(word_idx, word) \ + RQSW_TO_QUEUE_IDX(word_idx, RQSW_BSF(word)) + + +/* + * The queue for a given index as a list of threads. + */ +TAILQ_HEAD(rq_queue, thread); /* * Bit array which maintains the status of a run queue. When a queue is * non-empty the bit corresponding to the queue number will be set. */ -struct rqbits { - rqb_word_t rqb_bits[RQB_LEN]; +struct rq_status { + rqsw_t rq_sw[RQSW_NB]; }; /* @@ -58,18 +96,29 @@ struct rqbits { * are placed, and a structure to maintain the status of each queue. */ struct runq { - struct rqbits rq_status; - struct rqhead rq_queues[RQ_NQS]; + struct rq_status rq_status; + struct rq_queue rq_queues[RQ_NQS]; }; -void runq_add(struct runq *, struct thread *, int); -void runq_add_pri(struct runq *, struct thread *, u_char, int); -int runq_check(struct runq *); -struct thread *runq_choose(struct runq *); -struct thread *runq_choose_from(struct runq *, u_char); -struct thread *runq_choose_fuzz(struct runq *, int); void runq_init(struct runq *); -void runq_remove(struct runq *, struct thread *); -void runq_remove_idx(struct runq *, struct thread *, u_char *); +bool runq_is_queue_empty(struct runq *, int _idx); +void runq_add(struct runq *, struct thread *, int _flags); +void runq_add_idx(struct runq *, struct thread *, int _idx, int _flags); +bool runq_remove(struct runq *, struct thread *); + +/* + * Implementation helpers for common and scheduler-specific runq_choose*() + * functions. + */ +typedef bool runq_pred_t(int _idx, struct rq_queue *, void *_data); +int runq_findq(struct runq *const rq, const int lvl_min, + const int lvl_max, + runq_pred_t *const pred, void *const pred_data); +struct thread *runq_first_thread_range(struct runq *const rq, + const int lvl_min, const int lvl_max); + +bool runq_not_empty(struct runq *); +struct thread *runq_choose(struct runq *); +struct thread *runq_choose_fuzz(struct runq *, int _fuzz); #endif \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/rwlock.h b/lib/libc/include/generic-freebsd/sys/rwlock.h index b0f21fb8d81bcf02bb4ac2e5901a83d1be05cf3b..3042661b460a08ebfade60e8b17ef08d3b876b05 100644 --- a/lib/libc/include/generic-freebsd/sys/rwlock.h +++ b/lib/libc/include/generic-freebsd/sys/rwlock.h @@ -128,7 +128,7 @@ */ void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts); void _rw_destroy(volatile uintptr_t *c); -void rw_sysinit(void *arg); +void rw_sysinit(const void *arg); int _rw_wowned(const volatile uintptr_t *c); void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line); int __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF); diff --git a/lib/libc/include/generic-freebsd/sys/sched.h b/lib/libc/include/generic-freebsd/sys/sched.h index a3165c3651fdfb0dfad1b2721ae07c055f2e80cf..25220eedb0ab521b511b360a7d021ed16de61bef 100644 --- a/lib/libc/include/generic-freebsd/sys/sched.h +++ b/lib/libc/include/generic-freebsd/sys/sched.h @@ -63,6 +63,15 @@ #define _SCHED_H_ #ifdef _KERNEL + +#include +#ifdef SCHED_STATS +#include +#endif + +struct proc; +struct thread; + /* * General scheduling info. * @@ -74,7 +83,7 @@ */ int sched_load(void); int sched_rr_interval(void); -int sched_runnable(void); +bool sched_runnable(void); /* * Proc related scheduling hooks. @@ -214,7 +223,7 @@ SYSINIT(name, SI_SUB_LAST, SI_ORDER_MIDDLE, name ## _add_proc, NULL); SCHED_STAT_DEFINE_VAR(name, &DPCPU_NAME(name), descr) /* * Sched stats are always incremented in critical sections so no atomic - * is necesssary to increment them. + * is necessary to increment them. */ #define SCHED_STAT_INC(var) DPCPU_GET(var)++; #else diff --git a/lib/libc/include/generic-freebsd/sys/sdt.h b/lib/libc/include/generic-freebsd/sys/sdt.h index f951b33dd0160c466791d23c983f8898b5cfee4e..d33795f4e586b233ce505ee0c521b10be214e851 100644 --- a/lib/libc/include/generic-freebsd/sys/sdt.h +++ b/lib/libc/include/generic-freebsd/sys/sdt.h @@ -77,8 +77,8 @@ #else /* _KERNEL */ -#include #include +#include extern volatile bool sdt_probes_enabled; @@ -102,8 +102,6 @@ extern volatile bool sdt_probes_enabled; #define SDT_PROBE_DEFINE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) #define SDT_PROBE_DEFINE6(prov, mod, func, name, arg0, arg1, arg2, \ arg3, arg4, arg5) -#define SDT_PROBE_DEFINE7(prov, mod, func, name, arg0, arg1, arg2, \ - arg3, arg4, arg5, arg6) #define SDT_PROBE0(prov, mod, func, name) #define SDT_PROBE1(prov, mod, func, name, arg0) @@ -112,8 +110,9 @@ extern volatile bool sdt_probes_enabled; #define SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3) #define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) #define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) -#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \ - arg6) + +#define MIB_SDT_PROBE1(...) +#define MIB_SDT_PROBE2(...) #define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) #define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0) @@ -127,9 +126,6 @@ extern volatile bool sdt_probes_enabled; arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4) #define SDT_PROBE_DEFINE6_XLATE(prov, mod, func, name, arg0, xarg0, \ arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5) -#define SDT_PROBE_DEFINE7_XLATE(prov, mod, func, name, arg0, xarg0, \ - arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6, \ - xarg6) #define DTRACE_PROBE(name) #define DTRACE_PROBE1(name, type0, arg0) @@ -141,6 +137,18 @@ extern volatile bool sdt_probes_enabled; #else +void sdt_probe(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, + uintptr_t); +void sdt_probe6(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, + uintptr_t, uintptr_t); + +#define _SDT_TRACEPOINT_SET sdt_tracepoint_set +#define _SDT_TRACEPOINT_SECTION "set_sdt_tracepoint_set" + +bool sdt_tracepoint_valid(uintptr_t patchpoint, uintptr_t target); +void sdt_tracepoint_patch(uintptr_t patchpoint, uintptr_t target); +void sdt_tracepoint_restore(uintptr_t patchpoint); + #define __sdt_used SET_DECLARE(sdt_providers_set, struct sdt_provider); @@ -153,39 +161,81 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); sdt_provider_##prov #define SDT_PROVIDER_DEFINE(_prov) \ - struct sdt_provider _SDT_PROVIDER_NAME(_prov)[1] = { \ - [0] = { .name = #_prov }, \ + struct sdt_provider _SDT_PROVIDER_NAME(_prov) = { \ + .name = #_prov, \ }; \ DATA_SET(sdt_providers_set, _SDT_PROVIDER_NAME(_prov)) #define SDT_PROVIDER_DECLARE(prov) \ - extern struct sdt_provider _SDT_PROVIDER_NAME(prov)[1] + extern struct sdt_provider _SDT_PROVIDER_NAME(prov) #define SDT_PROBE_DEFINE(_prov, _mod, _func, _name) \ - struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name)[1] = { \ - [0] = { \ - .version = sizeof(struct sdt_probe), \ - .prov = _SDT_PROVIDER_NAME(_prov), \ - .mod = #_mod, \ - .func = #_func, \ - .name = #_name, \ - }, \ + struct sdt_probe _SDT_PROBE_NAME(_prov, _mod, _func, _name) = { \ + .version = sizeof(struct sdt_probe), \ + .prov = &_SDT_PROVIDER_NAME(_prov), \ + .mod = #_mod, \ + .func = #_func, \ + .name = #_name, \ }; \ DATA_SET(sdt_probes_set, _SDT_PROBE_NAME(_prov, _mod, _func, _name)) #define SDT_PROBE_DECLARE(prov, mod, func, name) \ - extern struct sdt_probe _SDT_PROBE_NAME(prov, mod, func, name)[1] + extern struct sdt_probe _SDT_PROBE_NAME(prov, mod, func, name) #define SDT_PROBES_ENABLED() __predict_false(sdt_probes_enabled) -#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \ - if (SDT_PROBES_ENABLED()) { \ - if (__predict_false(_SDT_PROBE_NAME(prov, mod, func, name)->id)) \ - (*sdt_probe_func)(_SDT_PROBE_NAME(prov, mod, func, name)->id, \ - (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \ - (uintptr_t) arg3, (uintptr_t) arg4); \ - } \ +#ifdef _ILP32 +#define _SDT_ASM_WORD ".long" +#else +#define _SDT_ASM_WORD ".quad" +#endif + +#ifndef _SDT_ASM_PROBE_CONSTRAINT +#define _SDT_ASM_PROBE_CONSTRAINT "i" +#endif +#ifndef _SDT_ASM_PROBE_OPERAND +#define _SDT_ASM_PROBE_OPERAND "c" +#endif + +/* + * The asm below generates records corresponding to the structure's layout, so + * the two must be kept in sync. + */ +struct sdt_tracepoint { + struct sdt_probe *probe; + uintptr_t patchpoint; + uintptr_t target; + STAILQ_ENTRY(sdt_tracepoint) tracepoint_entry; +}; + +#define __SDT_PROBE(prov, mod, func, name, uniq, f, ...) do { \ + __WEAK(__CONCAT(__start_set_, _SDT_TRACEPOINT_SET)); \ + __WEAK(__CONCAT(__stop_set_, _SDT_TRACEPOINT_SET)); \ + asm goto( \ + "0:\n" \ + _SDT_ASM_PATCH_INSTR "\n" \ + ".pushsection " _SDT_TRACEPOINT_SECTION ", \"aw\"\n" \ + _SDT_ASM_WORD " %" _SDT_ASM_PROBE_OPERAND "0\n" \ + _SDT_ASM_WORD " 0b\n" \ + _SDT_ASM_WORD " %l1\n" \ + _SDT_ASM_WORD " 0\n" \ + ".popsection\n" \ + : \ + : _SDT_ASM_PROBE_CONSTRAINT (&_SDT_PROBE_NAME(prov, mod, \ + func, name)) \ + : \ + : __sdt_probe##uniq); \ + if (0) { \ +__sdt_probe##uniq:; \ + f(_SDT_PROBE_NAME(prov, mod, func, name).id, __VA_ARGS__); \ + } \ } while (0) +#define _SDT_PROBE(prov, mod, func, name, uniq, f, ...) \ + __SDT_PROBE(prov, mod, func, name, uniq, f, __VA_ARGS__) +#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ + _SDT_PROBE(prov, mod, func, name, __COUNTER__, sdt_probe, \ + (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \ + (uintptr_t)arg3, (uintptr_t)arg4) #define SDT_PROBE_ARGTYPE(_prov, _mod, _func, _name, _num, _type, _xtype) \ static struct sdt_argtype \ @@ -194,7 +244,7 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); .ndx = _num, \ .type = _type, \ .xtype = _xtype, \ - .probe = _SDT_PROBE_NAME(_prov, _mod, _func, _name), \ + .probe = &_SDT_PROBE_NAME(_prov, _mod, _func, _name), \ }, \ }; \ DATA_SET(sdt_argtypes_set, \ @@ -243,17 +293,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, NULL) -#define SDT_PROBE_DEFINE7(prov, mod, func, name, arg0, arg1, arg2, arg3,\ - arg4, arg5, arg6) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, NULL); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 6, arg6, NULL) - #define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) \ SDT_PROBE_DEFINE(prov, mod, func, name) @@ -301,18 +340,6 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \ SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, xarg5) -#define SDT_PROBE_DEFINE7_XLATE(prov, mod, func, name, arg0, xarg0, \ - arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6, \ - xarg6) \ - SDT_PROBE_DEFINE(prov, mod, func, name); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0, xarg0); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1, xarg1); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2, xarg2); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3, xarg3); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4, xarg4); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5, xarg5); \ - SDT_PROBE_ARGTYPE(prov, mod, func, name, 6, arg6, xarg6) - #define SDT_PROBE0(prov, mod, func, name) \ SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0) #define SDT_PROBE1(prov, mod, func, name, arg0) \ @@ -325,27 +352,18 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0) #define SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) -#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \ - do { \ - if (_SDT_PROBE_NAME(prov, mod, func, name)->id) \ - (*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \ - uintptr_t, uintptr_t, uintptr_t))sdt_probe_func)( \ - _SDT_PROBE_NAME(prov, mod, func, name)->id, \ - (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \ - (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5);\ - } while (0) -#define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \ - arg6) \ - do { \ - if (_SDT_PROBE_NAME(prov, mod, func, name)->id) \ - (*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \ - uintptr_t, uintptr_t, uintptr_t, uintptr_t)) \ - sdt_probe_func)( \ - _SDT_PROBE_NAME(prov, mod, func, name)->id, \ - (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \ - (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5, \ - (uintptr_t)arg6); \ - } while (0) +#define SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5) \ + _SDT_PROBE(prov, mod, func, name, __COUNTER__, sdt_probe6, \ + (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \ + (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5) + +#ifdef KDTRACE_MIB_SDT +#define MIB_SDT_PROBE1(...) SDT_PROBE1(mib, __VA_ARGS__) +#define MIB_SDT_PROBE2(...) SDT_PROBE2(mib, __VA_ARGS__) +#else +#define MIB_SDT_PROBE1(...) +#define MIB_SDT_PROBE2(...) +#endif #define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \ static SDT_PROBE_DEFINE(sdt, , , name); \ @@ -399,12 +417,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype); * way to avoid having to rely on CDDL code. */ typedef void (*sdt_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1, - uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); + uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5); /* * The 'sdt' provider will set it to dtrace_probe when it loads. */ -extern sdt_probe_func_t sdt_probe_func; +extern sdt_probe_func_t sdt_probe_func; struct sdt_probe; struct sdt_provider; @@ -425,6 +443,7 @@ struct sdt_probe { TAILQ_ENTRY(sdt_probe) probe_entry; /* SDT probe list entry. */ TAILQ_HEAD(, sdt_argtype) argtype_list; + STAILQ_HEAD(, sdt_tracepoint) tracepoint_list; const char *mod; const char *func; const char *name; @@ -442,7 +461,7 @@ struct sdt_provider { }; void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, - uintptr_t); + uintptr_t, uintptr_t); SDT_PROVIDER_DECLARE(sdt); diff --git a/lib/libc/include/generic-freebsd/sys/select.h b/lib/libc/include/generic-freebsd/sys/select.h index 790c2d045fedf9d84741bab7011ecc12f8dde270..dd75cacf0af56588ce6bd2eac5e3f374d27158ca 100644 --- a/lib/libc/include/generic-freebsd/sys/select.h +++ b/lib/libc/include/generic-freebsd/sys/select.h @@ -49,6 +49,12 @@ typedef __fd_mask fd_mask; typedef __sigset_t sigset_t; #endif +#if !defined(_KERNEL) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#else +#define __SSP_FORTIFY_LEVEL 0 +#endif + /* * Select uses bit masks of file descriptors in longs. These macros * manipulate such bit fields (the filesystem macros use chars). @@ -75,13 +81,33 @@ typedef struct fd_set { #define fds_bits __fds_bits #endif +#define __fdset_idx_(p, n) ((n) / _NFDBITS) +#if __SSP_FORTIFY_LEVEL == 0 +#define __fdset_idx(p, n) __fdset_idx_(p, n) +#else +__ssp_inline unsigned long +__fdset_idx(const fd_set *p, unsigned long idx) +{ + __size_t psz = __ssp_bos0(p); + unsigned long sidx = __fdset_idx_(p, idx); + + if (idx >= FD_SETSIZE) + __chk_fail(); + if (psz / sizeof(__fd_mask) < (sidx + 1)) + __chk_fail(); + + return (sidx); +} +#endif + #define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) -#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) +#define FD_CLR(n, p) ((p)->__fds_bits[__fdset_idx(p, n)] &= ~__fdset_mask(n)) #if __BSD_VISIBLE #define FD_COPY(f, t) (void)(*(t) = *(f)) #endif -#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) -#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) +#define FD_ISSET(n, p) \ + (((p)->__fds_bits[__fdset_idx(p, n)] & __fdset_mask(n)) != 0) +#define FD_SET(n, p) ((p)->__fds_bits[__fdset_idx(p, n)] |= __fdset_mask(n)) #define FD_ZERO(p) do { \ fd_set *_p; \ __size_t _n; \ diff --git a/lib/libc/include/generic-freebsd/sys/selinfo.h b/lib/libc/include/generic-freebsd/sys/selinfo.h index 565236d3a89d2c4cb4c771a1b7ce62a7826f1ddd..6c82a54f15ad33aec8bf6e1ef89378f0a85b23f1 100644 --- a/lib/libc/include/generic-freebsd/sys/selinfo.h +++ b/lib/libc/include/generic-freebsd/sys/selinfo.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)select.h 8.2 (Berkeley) 1/4/94 */ #ifndef _SYS_SELINFO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/sem.h b/lib/libc/include/generic-freebsd/sys/sem.h index 79b15ab5e6cf21176b675f1ce60d9c4fc8b69cf6..15fcc9e17099a49c897b3e39cf65df53a0d17e67 100644 --- a/lib/libc/include/generic-freebsd/sys/sem.h +++ b/lib/libc/include/generic-freebsd/sys/sem.h @@ -148,9 +148,6 @@ int kern_get_sema(struct thread *td, struct semid_kernel **res, #else /* !_KERNEL */ __BEGIN_DECLS -#if __BSD_VISIBLE -int semsys(int, ...); -#endif int semctl(int, int, int, ...); int semget(key_t, int, int); int semop(int, struct sembuf *, size_t); diff --git a/lib/libc/include/generic-freebsd/sys/seqc.h b/lib/libc/include/generic-freebsd/sys/seqc.h index a2bdc86658a318f7372991e32a10e025cd12e7bf..727ec1a251b362c755b0fde8335815cae5bd3649 100644 --- a/lib/libc/include/generic-freebsd/sys/seqc.h +++ b/lib/libc/include/generic-freebsd/sys/seqc.h @@ -78,14 +78,14 @@ static __inline seqc_t seqc_read_any(const seqc_t *seqcp) { - return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp))); + return (atomic_load_acq_int(seqcp)); } static __inline seqc_t seqc_read_notmodify(const seqc_t *seqcp) { - return (atomic_load_acq_int(__DECONST(seqc_t *, seqcp)) & ~SEQC_MOD); + return (atomic_load_acq_int(seqcp) & ~SEQC_MOD); } static __inline seqc_t diff --git a/lib/libc/include/generic-freebsd/sys/sglist.h b/lib/libc/include/generic-freebsd/sys/sglist.h index 5a1701744c5e8026081840dea6c31c9818b4ca96..64e4b786d569442efc3ecb0a9eedf0664143b2a4 100644 --- a/lib/libc/include/generic-freebsd/sys/sglist.h +++ b/lib/libc/include/generic-freebsd/sys/sglist.h @@ -55,6 +55,7 @@ struct sglist { struct bio; struct mbuf; +struct thread; struct uio; static __inline void diff --git a/lib/libc/include/generic-freebsd/sys/shm.h b/lib/libc/include/generic-freebsd/sys/shm.h index a31adc49e9db80163a7245ab6ece1402205b0677..1d2344bb020905acadf93bcd342d1dd410e583bc 100644 --- a/lib/libc/include/generic-freebsd/sys/shm.h +++ b/lib/libc/include/generic-freebsd/sys/shm.h @@ -51,7 +51,7 @@ #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */ #define SHM_RND 020000 /* Round attach address to SHMLBA */ -#define SHM_REMAP 030000 /* Unmap before mapping */ +#define SHM_REMAP 040000 /* Unmap before mapping */ #define SHMLBA PAGE_SIZE /* Segment low boundary address multiple */ /* "official" access mode definitions; somewhat braindead since you have @@ -173,9 +173,6 @@ typedef __size_t size_t; #endif __BEGIN_DECLS -#if __BSD_VISIBLE -int shmsys(int, ...); -#endif void *shmat(int, const void *, int); int shmget(key_t, size_t, int); int shmctl(int, int, struct shmid_ds *); diff --git a/lib/libc/include/generic-freebsd/sys/sigio.h b/lib/libc/include/generic-freebsd/sys/sigio.h index 5cf831b407635b7f6ef3f9bf58af808947c2f4fe..7b560271d77a56fd744497045a6f7dc8ed3035f8 100644 --- a/lib/libc/include/generic-freebsd/sys/sigio.h +++ b/lib/libc/include/generic-freebsd/sys/sigio.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)filedesc.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_SIGIO_H_ diff --git a/lib/libc/include/generic-freebsd/sys/signal.h b/lib/libc/include/generic-freebsd/sys/signal.h index 0859eaf578ed13e71b8ab291ca937ddc41c51781..90565ec5f6911d9eba8791b93636bb393f8f6545 100644 --- a/lib/libc/include/generic-freebsd/sys/signal.h +++ b/lib/libc/include/generic-freebsd/sys/signal.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.4 (Berkeley) 5/4/95 */ #ifndef _SYS_SIGNAL_H_ @@ -42,6 +40,7 @@ #include #include #include +#include #include #include /* __MINSIGSTKSZ */ @@ -255,7 +254,7 @@ typedef struct __siginfo { #define si_syscall _reason._capsicum._syscall #if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__)) -struct siginfo32 { +struct __siginfo32 { int si_signo; /* signal number */ int si_errno; /* errno association */ int si_code; /* signal code */ @@ -373,7 +372,7 @@ struct sigaction { #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ #endif /* __POSIX_VISIBLE || __XSI_VISIBLE */ -#if __XSI_VISIBLE +#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809 #define SA_ONSTACK 0x0001 /* take signal on signal stack */ #define SA_RESTART 0x0002 /* restart system call on signal return */ #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ @@ -408,29 +407,6 @@ typedef __sighandler_t *sig_t; /* type of pointer to a signal function */ typedef void __siginfohandler_t(int, struct __siginfo *, void *); #endif -#if __XSI_VISIBLE -#if __BSD_VISIBLE -#define __stack_t sigaltstack -#endif -typedef struct __stack_t stack_t; - -#define SS_ONSTACK 0x0001 /* take signal on alternate stack */ -#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ -#define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */ -#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ -#endif - -/* - * Structure used in sigaltstack call. Its definition is always - * needed for __ucontext. If __BSD_VISIBLE is defined, the structure - * tag is actually sigaltstack. - */ -struct __stack_t { - void *ss_sp; /* signal stack base */ - __size_t ss_size; /* signal stack length */ - int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ -}; - #if __BSD_VISIBLE /* * 4.3 compatibility: diff --git a/lib/libc/include/generic-freebsd/sys/signalvar.h b/lib/libc/include/generic-freebsd/sys/signalvar.h index 6f618dffa33822251a72064fb387abdb81f4a17d..433d148b13a861e9a6cde2cd9b1a7b308eb7cd89 100644 --- a/lib/libc/include/generic-freebsd/sys/signalvar.h +++ b/lib/libc/include/generic-freebsd/sys/signalvar.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 */ #ifndef _SYS_SIGNALVAR_H_ @@ -272,6 +270,7 @@ int __sys_sigfastblock(int cmd, void *ptr); #ifdef _KERNEL extern bool sigfastblock_fetch_always; +extern bool pt_attach_transparent; /* Return nonzero if process p has an unmasked pending signal. */ #define SIGPENDING(td) \ @@ -404,6 +403,7 @@ int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **); void sigfastblock_clear(struct thread *td); void sigfastblock_fetch(struct thread *td); int sig_intr(void); +bool sig_do_core(int); void siginit(struct proc *p); void signotify(struct thread *td); void sigqueue_delete(struct sigqueue *queue, int sig); diff --git a/lib/libc/include/generic-freebsd/sys/sleepqueue.h b/lib/libc/include/generic-freebsd/sys/sleepqueue.h index be825205eb513e4e5504faa941ea7b54370c8717..f164e3ff780170fad4da1df16553e7bc91f694f6 100644 --- a/lib/libc/include/generic-freebsd/sys/sleepqueue.h +++ b/lib/libc/include/generic-freebsd/sys/sleepqueue.h @@ -86,21 +86,21 @@ struct thread; #define SLEEPQ_DROP 0x400 /* Return without lock held. */ void init_sleepqueues(void); -int sleepq_abort(struct thread *td, int intrval); +void sleepq_abort(struct thread *td, int intrval); void sleepq_add(const void *wchan, struct lock_object *lock, const char *wmesg, int flags, int queue); struct sleepqueue *sleepq_alloc(void); -int sleepq_broadcast(const void *wchan, int flags, int pri, int queue); +void sleepq_broadcast(const void *wchan, int flags, int pri, int queue); void sleepq_chains_remove_matching(bool (*matches)(struct thread *)); void sleepq_free(struct sleepqueue *sq); void sleepq_lock(const void *wchan); struct sleepqueue *sleepq_lookup(const void *wchan); void sleepq_release(const void *wchan); void sleepq_remove(struct thread *td, const void *wchan); -int sleepq_remove_matching(struct sleepqueue *sq, int queue, +void sleepq_remove_matching(struct sleepqueue *sq, int queue, bool (*matches)(struct thread *), int pri); void sleepq_remove_nested(struct thread *td); -int sleepq_signal(const void *wchan, int flags, int pri, int queue); +void sleepq_signal(const void *wchan, int flags, int pri, int queue); void sleepq_set_timeout_sbt(const void *wchan, sbintime_t sbt, sbintime_t pr, int flags); #define sleepq_set_timeout(wchan, timo) \ diff --git a/lib/libc/include/generic-freebsd/sys/smr_types.h b/lib/libc/include/generic-freebsd/sys/smr_types.h index 4016023fcc1b4af4094f71fc51f83a19ab759f0a..1b81a65a5de41997b338728c797a8ff4c2b5e597 100644 --- a/lib/libc/include/generic-freebsd/sys/smr_types.h +++ b/lib/libc/include/generic-freebsd/sys/smr_types.h @@ -60,7 +60,8 @@ struct { \ */ #define smr_entered_load(p, smr) ({ \ SMR_ASSERT(SMR_ENTERED((smr)), "smr_entered_load"); \ - (__typeof((p)->__ptr))atomic_load_acq_ptr((uintptr_t *)&(p)->__ptr); \ + (__typeof((p)->__ptr))atomic_load_acq_ptr( \ + (const uintptr_t *)&(p)->__ptr); \ }) /* @@ -70,7 +71,8 @@ struct { \ */ #define smr_serialized_load(p, ex) ({ \ SMR_ASSERT(ex, "smr_serialized_load"); \ - (__typeof((p)->__ptr))atomic_load_ptr(&(p)->__ptr); \ + (__typeof((p)->__ptr))atomic_load_ptr( \ + (const uintptr_t *)&(p)->__ptr); \ }) /* diff --git a/lib/libc/include/generic-freebsd/sys/sndstat.h b/lib/libc/include/generic-freebsd/sys/sndstat.h index ed4fa2493a62962e55b044c06e6fb4896d40d4c2..c80580ba07ebe5496a91846eb63eac61651e8704 100644 --- a/lib/libc/include/generic-freebsd/sys/sndstat.h +++ b/lib/libc/include/generic-freebsd/sys/sndstat.h @@ -94,12 +94,14 @@ struct sndstioc_nv_arg { #define SNDST_DSPS_SOUND4_CHAN_LEFTVOL "left_volume" #define SNDST_DSPS_SOUND4_CHAN_RIGHTVOL "right_volume" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_FORMAT "hwbuf_format" +#define SNDST_DSPS_SOUND4_CHAN_HWBUF_RATE "hwbuf_rate" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_SIZE "hwbuf_size" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKSZ "hwbuf_blksz" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_BLKCNT "hwbuf_blkcnt" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_FREE "hwbuf_free" #define SNDST_DSPS_SOUND4_CHAN_HWBUF_READY "hwbuf_ready" #define SNDST_DSPS_SOUND4_CHAN_SWBUF_FORMAT "swbuf_format" +#define SNDST_DSPS_SOUND4_CHAN_SWBUF_RATE "swbuf_rate" #define SNDST_DSPS_SOUND4_CHAN_SWBUF_SIZE "swbuf_size" #define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKSZ "swbuf_blksz" #define SNDST_DSPS_SOUND4_CHAN_SWBUF_BLKCNT "swbuf_blkcnt" diff --git a/lib/libc/include/generic-freebsd/sys/sockbuf.h b/lib/libc/include/generic-freebsd/sys/sockbuf.h index bb6e9d6d8073bdc4e4b5dc562a7501afe7c92f57..240afbe3827f16ba7ff98ca9bb9824dcfc9cfb84 100644 --- a/lib/libc/include/generic-freebsd/sys/sockbuf.h +++ b/lib/libc/include/generic-freebsd/sys/sockbuf.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 */ #ifndef _SYS_SOCKBUF_H_ #define _SYS_SOCKBUF_H_ @@ -42,13 +40,13 @@ #define SB_SEL 0x08 /* someone is selecting */ #define SB_ASYNC 0x10 /* ASYNC I/O, need signals */ #define SB_UPCALL 0x20 /* someone wants an upcall */ -#define SB_NOINTR 0x40 /* operations not interruptible */ +#define SB_AUTOLOWAT 0x40 /* sendfile(2) may autotune sb_lowat */ #define SB_AIO 0x80 /* AIO operations queued */ #define SB_KNOTE 0x100 /* kernel note attached */ #define SB_NOCOALESCE 0x200 /* don't coalesce new data into existing mbufs */ #define SB_IN_TOE 0x400 /* socket buffer is in the middle of an operation */ #define SB_AUTOSIZE 0x800 /* automatically size socket buffer */ -#define SB_STOP 0x1000 /* backpressure indicator */ +/* was SB_STOP 0x1000 */ #define SB_AIO_RUNNING 0x2000 /* AIO operation running */ #define SB_SPLICED 0x4000 /* socket buffer is spliced; previously used for SB_TLS_IFNET */ @@ -64,7 +62,7 @@ #include #include -#define SB_MAX (2*1024*1024) /* default for max chars in sockbuf */ +#define SB_MAX (8*1024*1024) /* default for max chars in sockbuf */ struct ktls_session; struct mbuf; @@ -134,6 +132,18 @@ struct sockbuf { /* TLS state, locked by sockbuf and sock I/O mutexes. */ struct ktls_session *sb_tls_info; }; + /* + * PF_UNIX/SOCK_STREAM and PF_UNIX/SOCK_SEQPACKET + * A simple stream buffer with not ready data pointer. + */ + struct { + STAILQ_HEAD(, mbuf) uxst_mbq; + struct mbuf *uxst_fnrdy; + struct socket *uxst_peer; + u_int uxst_flags; +#define UXST_PEER_AIO 0x1 +#define UXST_PEER_SEL 0x2 + }; /* * PF_UNIX/SOCK_DGRAM * @@ -167,6 +177,12 @@ struct sockbuf { u_int uxdg_ctl; u_int uxdg_mbcnt; }; + /* + * Netlink socket. + */ + struct { + TAILQ_HEAD(, nl_buf) nl_queue; + }; }; }; @@ -194,8 +210,6 @@ typedef enum { SO_RCV, SO_SND } sb_which; * Socket buffer private mbuf(9) flags. */ #define M_NOTREADY M_PROTO1 /* m_data not populated yet */ -#define M_BLOCKED M_PROTO2 /* M_NOTREADY in front of m */ -#define M_NOTAVAIL (M_NOTREADY | M_BLOCKED) void sbappend(struct sockbuf *sb, struct mbuf *m, int flags); void sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags); @@ -287,9 +301,6 @@ sbspace(struct sockbuf *sb) SOCKBUF_LOCK_ASSERT(sb); #endif - if (sb->sb_flags & SB_STOP) - return(0); - bleft = sb->sb_hiwat - sb->sb_ccc; mleft = sb->sb_mbmax - sb->sb_mbcnt; diff --git a/lib/libc/include/generic-freebsd/sys/socket.h b/lib/libc/include/generic-freebsd/sys/socket.h index 4029971164554ae45a87198b80963a337294c88e..aea4284303de80c808e57a0235e92a0c9cbf7a89 100644 --- a/lib/libc/include/generic-freebsd/sys/socket.h +++ b/lib/libc/include/generic-freebsd/sys/socket.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)socket.h 8.4 (Berkeley) 2/21/94 */ #ifndef _SYS_SOCKET_H_ @@ -113,10 +111,11 @@ typedef __uintptr_t uintptr_t; */ #define SOCK_CLOEXEC 0x10000000 #define SOCK_NONBLOCK 0x20000000 +#define SOCK_CLOFORK 0x40000000 #ifdef _KERNEL /* * Flags for accept1(), kern_accept4() and solisten_dequeue, in addition - * to SOCK_CLOEXEC and SOCK_NONBLOCK. + * to SOCK_CLOEXEC, SOCK_CLOFORK and SOCK_NONBLOCK. */ #define ACCEPT4_INHERIT 0x1 #define ACCEPT4_COMPAT 0x2 @@ -166,17 +165,18 @@ typedef __uintptr_t uintptr_t; #define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ #define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ #define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ -#define SO_SETFIB 0x1014 /* use this FIB to route */ +#define SO_FIB 0x1014 /* get or set socket FIB */ +#define SO_SETFIB SO_FIB /* backward compat alias */ #define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */ #define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */ #define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */ #define SO_TS_CLOCK 0x1017 /* clock type used for SO_TIMESTAMP */ #define SO_MAX_PACING_RATE 0x1018 /* socket's max TX pacing rate (Linux name) */ #define SO_DOMAIN 0x1019 /* get socket domain */ -#endif - -#if __BSD_VISIBLE #define SO_SPLICE 0x1023 /* splice data to other socket */ +#endif + +#if __BSD_VISIBLE #define SO_TS_REALTIME_MICRO 0 /* microsecond resolution, realtime */ #define SO_TS_BINTIME 1 /* sub-nanosecond resolution, realtime */ #define SO_TS_REALTIME 2 /* nanosecond resolution, realtime */ @@ -270,7 +270,8 @@ struct accept_filter_arg { #define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */ #define AF_HYPERV 43 /* HyperV sockets */ #define AF_DIVERT 44 /* divert(4) */ -#define AF_MAX 44 +#define AF_IPFWLOG 46 +#define AF_MAX 46 /* * When allocating a new AF_ constant, please only allocate * even numbered constants for FreeBSD until 134 as odd numbered AF_ @@ -396,6 +397,7 @@ struct sockproto { #define PF_INET_SDP AF_INET_SDP #define PF_INET6_SDP AF_INET6_SDP #define PF_DIVERT AF_DIVERT +#define PF_IPFWLOG AF_IPFWLOG #define PF_MAX AF_MAX @@ -477,6 +479,9 @@ struct msghdr { #define MSG_MORETOCOME 0x00100000 /* additional data pending */ #define MSG_TLSAPPDATA 0x00200000 /* do not soreceive() alert rec. (TLS) */ #endif +#if __BSD_VISIBLE +#define MSG_CMSG_CLOFORK 0x00400000 /* make received fds close-on-fork */ +#endif /* * Header for ancillary data objects in msg_control buffer. @@ -631,17 +636,14 @@ struct omsghdr { /* * howto arguments for shutdown(2), specified by Posix.1g. */ -#define SHUT_RD 0 /* shut down the reading side */ -#define SHUT_WR 1 /* shut down the writing side */ -#define SHUT_RDWR 2 /* shut down both sides */ - -#if __BSD_VISIBLE -/* for SCTP */ -/* we cheat and use the SHUT_XX defines for these */ -#define PRU_FLUSH_RD SHUT_RD -#define PRU_FLUSH_WR SHUT_WR -#define PRU_FLUSH_RDWR SHUT_RDWR -#endif +enum shutdown_how { + SHUT_RD = 0, /* shut down the reading side */ +#define SHUT_RD SHUT_RD + SHUT_WR, /* shut down the writing side */ +#define SHUT_WR SHUT_WR + SHUT_RDWR /* shut down both sides */ +#define SHUT_RDWR SHUT_RDWR +}; #if __BSD_VISIBLE /* @@ -689,6 +691,10 @@ struct splice { #ifndef _KERNEL +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + #include __BEGIN_DECLS @@ -733,33 +739,10 @@ __END_DECLS #ifdef _KERNEL struct socket; -struct inpcb *so_sotoinpcb(struct socket *so); -struct sockbuf *so_sockbuf_snd(struct socket *); -struct sockbuf *so_sockbuf_rcv(struct socket *); - -int so_state_get(const struct socket *); -void so_state_set(struct socket *, int); - int so_options_get(const struct socket *); void so_options_set(struct socket *, int); int so_error_get(const struct socket *); void so_error_set(struct socket *, int); - -int so_linger_get(const struct socket *); -void so_linger_set(struct socket *, int); - -struct protosw *so_protosw_get(const struct socket *); -void so_protosw_set(struct socket *, struct protosw *); - -void so_sorwakeup_locked(struct socket *so); -void so_sowwakeup_locked(struct socket *so); - -void so_sorwakeup(struct socket *so); -void so_sowwakeup(struct socket *so); - -void so_lock(struct socket *so); -void so_unlock(struct socket *so); - #endif /* _KERNEL */ #endif /* !_SYS_SOCKET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/socketvar.h b/lib/libc/include/generic-freebsd/sys/socketvar.h index 5b686e218913d2b04c9329669db338d30185854d..4d135960a22f3a4352fde06f2073ff2b448ee349 100644 --- a/lib/libc/include/generic-freebsd/sys/socketvar.h +++ b/lib/libc/include/generic-freebsd/sys/socketvar.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 */ #ifndef _SYS_SOCKETVAR_H_ @@ -82,6 +80,7 @@ struct so_splice { struct mtx mtx; unsigned int wq_index; enum so_splice_state { + SPLICE_INIT, /* embryonic state, don't queue work yet */ SPLICE_IDLE, /* waiting for work to arrive */ SPLICE_QUEUED, /* a wakeup has queued some work */ SPLICE_RUNNING, /* currently transferring data */ @@ -239,7 +238,7 @@ struct socket { #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */ #define SS_NBIO 0x0100 /* non-blocking ops */ #define SS_ASYNC 0x0200 /* async i/o notify */ -#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */ +/* was SS_ISCONFIRMING 0x0400 */ #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ #ifdef _KERNEL @@ -343,16 +342,14 @@ soeventmtx(struct socket *so, const sb_which which) soiolock((so), &(so)->so_snd_sx, (flags)) #define SOCK_IO_SEND_UNLOCK(so) \ soiounlock(&(so)->so_snd_sx) -#define SOCK_IO_SEND_OWNED(so) sx_xlocked(&(so)->so_snd_sx) #define SOCK_IO_SEND_ASSERT_LOCKED(so) \ - sx_assert(&(so)->so_snd_sx, SA_XLOCKED) + sx_assert(&(so)->so_snd_sx, SA_LOCKED) #define SOCK_IO_RECV_LOCK(so, flags) \ soiolock((so), &(so)->so_rcv_sx, (flags)) #define SOCK_IO_RECV_UNLOCK(so) \ soiounlock(&(so)->so_rcv_sx) -#define SOCK_IO_RECV_OWNED(so) sx_xlocked(&(so)->so_rcv_sx) #define SOCK_IO_RECV_ASSERT_LOCKED(so) \ - sx_assert(&(so)->so_rcv_sx, SA_XLOCKED) + sx_assert(&(so)->so_rcv_sx, SA_LOCKED) /* do we have to send all at once on a socket? */ #define sosendallatonce(so) \ @@ -459,7 +456,8 @@ MALLOC_DECLARE(M_SONAME); #define HHOOK_FILT_SOREAD 4 #define HHOOK_FILT_SOWRITE 5 #define HHOOK_SOCKET_CLOSE 6 -#define HHOOK_SOCKET_LAST HHOOK_SOCKET_CLOSE +#define HHOOK_SOCKET_NEWCONN 7 +#define HHOOK_SOCKET_LAST HHOOK_SOCKET_NEWCONN struct socket_hhook_data { struct socket *so; @@ -479,6 +477,7 @@ struct mbuf; struct sockaddr; struct ucred; struct uio; +enum shutdown_how; /* Return values for socket upcalls. */ #define SU_OK 0 @@ -489,12 +488,14 @@ struct uio; */ int getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len); -int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp, +int getsock_cap(struct thread *td, int fd, const cap_rights_t *rightsp, struct file **fpp, struct filecaps *havecaps); -int getsock(struct thread *td, int fd, cap_rights_t *rightsp, +int getsock(struct thread *td, int fd, const cap_rights_t *rightsp, struct file **fpp); void soabort(struct socket *so); -int soaccept(struct socket *so, struct sockaddr **nam); +int soaccept(struct socket *so, struct sockaddr *sa); +int sopeeraddr(struct socket *so, struct sockaddr *sa); +int sosockaddr(struct socket *so, struct sockaddr *sa); void soaio_enqueue(struct task *task); void soaio_rcv(void *context, int pending); void soaio_snd(void *context, int pending); @@ -525,10 +526,9 @@ struct socket * sonewconn(struct socket *head, int connstatus); struct socket * sopeeloff(struct socket *); -int sopoll(struct socket *so, int events, struct ucred *active_cred, - struct thread *td); -int sopoll_generic(struct socket *so, int events, - struct ucred *active_cred, struct thread *td); +int sopoll_generic(struct socket *so, int events, struct thread *td); +int sokqfilter_generic(struct socket *so, struct knote *kn); +int soaio_queue_generic(struct socket *so, struct kaiocb *job); int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp); int soreceive_stream(struct socket *so, struct sockaddr **paddr, @@ -555,7 +555,9 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr, int sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); -int soshutdown(struct socket *so, int how); +int sendfile_wait_generic(struct socket *so, off_t need, int *space); +int sosetfib(struct socket *so, int fibnum); +int soshutdown(struct socket *so, enum shutdown_how); void soupcall_clear(struct socket *, sb_which); void soupcall_set(struct socket *, sb_which, so_upcall_t, void *); void solisten_upcall_set(struct socket *, so_upcall_t, void *); @@ -596,6 +598,8 @@ SYSCTL_DECL(_net_inet_accf); int accept_filt_generic_mod_event(module_t mod, int event, void *data); #endif +int pr_listen_notsupp(struct socket *so, int backlog, struct thread *td); + #endif /* _KERNEL */ /* @@ -615,7 +619,8 @@ struct xsocket { uint32_t so_qlimit; pid_t so_pgid; uid_t so_uid; - int32_t so_spare32[8]; + int32_t so_fibnum; + int32_t so_spare32[7]; int16_t so_type; int16_t so_options; int16_t so_linger; diff --git a/lib/libc/include/generic-freebsd/sys/sockio.h b/lib/libc/include/generic-freebsd/sys/sockio.h index 87d96f12435c8c108ef80c183c71c5b9b40307cf..fc3b2087ae96de259055af5a6c0184bceec96098 100644 --- a/lib/libc/include/generic-freebsd/sys/sockio.h +++ b/lib/libc/include/generic-freebsd/sys/sockio.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)sockio.h 8.1 (Berkeley) 3/28/94 */ #ifndef _SYS_SOCKIO_H_ @@ -149,4 +147,8 @@ #define SIOCSIFCAPNV _IOW('i', 155, struct ifreq) /* set IF features */ #define SIOCGIFCAPNV _IOWR('i', 156, struct ifreq) /* get IF features */ +#define SIOCGUMBINFO _IOWR('i', 157, struct ifreq) /* get MBIM info */ +#define SIOCSUMBPARAM _IOW('i', 158, struct ifreq) /* set MBIM param */ +#define SIOCGUMBPARAM _IOWR('i', 159, struct ifreq) /* get MBIM param */ + #endif /* !_SYS_SOCKIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/sockopt.h b/lib/libc/include/generic-freebsd/sys/sockopt.h index 95d4cc40a12f79188245586f96cb070a674d7a15..b1d92465793b3dcf9be4bb39f3275dfe76b35630 100644 --- a/lib/libc/include/generic-freebsd/sys/sockopt.h +++ b/lib/libc/include/generic-freebsd/sys/sockopt.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 */ #ifndef _SYS_SOCKOPT_H_ #define _SYS_SOCKOPT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/soundcard.h b/lib/libc/include/generic-freebsd/sys/soundcard.h index e55e8b3c72d2bb307e371cde560e49fc4856f66f..4c285eff2853182493e1182ec4971b016afc53d0 100644 --- a/lib/libc/include/generic-freebsd/sys/soundcard.h +++ b/lib/libc/include/generic-freebsd/sys/soundcard.h @@ -184,6 +184,8 @@ struct snd_size { #define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */ #define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */ #define AFMT_U24_BE 0x00080000 /* Big endian unsigned 24-bit */ +#define AFMT_F32_LE 0x10000000 /* Little endian 32-bit floating point */ +#define AFMT_F32_BE 0x20000000 /* Big endian 32-bit floating point */ /* Machine dependent AFMT_* definitions. */ #if BYTE_ORDER == LITTLE_ENDIAN @@ -199,6 +201,8 @@ struct snd_size { #define AFMT_U16_OE AFMT_U16_BE #define AFMT_U24_OE AFMT_U24_BE #define AFMT_U32_OE AFMT_U32_BE +#define AFMT_F32_NE AFMT_F32_LE +#define AFMT_F32_OE AFMT_F32_BE #else #define AFMT_S16_OE AFMT_S16_LE #define AFMT_S24_OE AFMT_S24_LE @@ -212,8 +216,12 @@ struct snd_size { #define AFMT_U16_NE AFMT_U16_BE #define AFMT_U24_NE AFMT_U24_BE #define AFMT_U32_NE AFMT_U32_BE +#define AFMT_F32_NE AFMT_F32_BE +#define AFMT_F32_OE AFMT_F32_LE #endif +#define AFMT_FLOAT AFMT_F32_NE /* compatibility alias */ + #define AFMT_STEREO 0x10000000 /* can do/want stereo */ /* @@ -1400,8 +1408,9 @@ void seqbuf_dump(void); /* This function must be provided by programs */ int i, l=(len); if (l>6)l=6;\ _SEQ_NEEDBUF(8);\ _seqbuf[_seqbufptr] = EV_SYSEX;\ - for(i=0;i + +#endif /* __SYS_STDARG_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/stdatomic.h b/lib/libc/include/generic-freebsd/sys/stdatomic.h index ae0516be1c8f88b3a2d13d28d0df6ae063bed363..e2ff73bcfb89fdb7e98668630279ffd4862ecd5c 100644 --- a/lib/libc/include/generic-freebsd/sys/stdatomic.h +++ b/lib/libc/include/generic-freebsd/sys/stdatomic.h @@ -33,7 +33,8 @@ #include #include -#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#if (__has_extension(c_atomic) || __has_extension(cxx_atomic)) && \ + defined(__clang__) #define __CLANG_ATOMICS #elif __GNUC_PREREQ__(4, 7) #define __GNUC_ATOMICS diff --git a/lib/libc/include/generic-freebsd/sys/sx.h b/lib/libc/include/generic-freebsd/sys/sx.h index d6756fbc1dff93dbcec62276f39e46ca278de27d..c40bd9c9c7a9731a93c07cf8e21c45ea8be129ed 100644 --- a/lib/libc/include/generic-freebsd/sys/sx.h +++ b/lib/libc/include/generic-freebsd/sys/sx.h @@ -99,7 +99,7 @@ * Function prototipes. Routines that start with an underscore are not part * of the public interface and are wrappered with a macro. */ -void sx_sysinit(void *arg); +void sx_sysinit(const void *arg); #define sx_init(sx, desc) sx_init_flags((sx), (desc), 0) void sx_init_flags(struct sx *sx, const char *description, int opts); void sx_destroy(struct sx *sx); @@ -301,12 +301,12 @@ __sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) #ifdef _STANDALONE /* since we have no threads in the boot loader, trivially implement no-op version */ -#define sx_xlock(s) (1) -#define sx_try_xlock(s) (1) -#define sx_xunlock(s) (1) -#define SX_DUPOK 0 -#define SX_NEW 0 -#define SX_NOWITNESS 0 +#define sx_xlock(s) do {} while (0) +#define sx_try_xlock(s) (1) +#define sx_xunlock(s) do {} while (0) +#define SX_DUPOK 0 +#define SX_NEW 0 +#define SX_NOWITNESS 0 static __inline void sx_init_flags(struct sx *sx, const char *description, int opts) diff --git a/lib/libc/include/generic-freebsd/sys/syscall.h b/lib/libc/include/generic-freebsd/sys/syscall.h index 0cec5b059aa2a885ada23753f200f99ddcc92896..1333b48c7ff6333f07cfebf8d2ab2d2ce4c93f98 100644 --- a/lib/libc/include/generic-freebsd/sys/syscall.h +++ b/lib/libc/include/generic-freebsd/sys/syscall.h @@ -4,8 +4,10 @@ * DO NOT EDIT-- this file is automatically @generated. */ +#define SYS_exit SYS__exit + #define SYS_syscall 0 -#define SYS_exit 1 +#define SYS__exit 1 #define SYS_fork 2 #define SYS_read 3 #define SYS_write 4 @@ -73,8 +75,8 @@ #define SYS_vfork 66 /* 67 is obsolete vread */ /* 68 is obsolete vwrite */ -#define SYS_sbrk 69 -#define SYS_sstk 70 + /* 69 is obsolete sbrk */ + /* 70 is obsolete sstk */ /* 71 is old mmap */ #define SYS_freebsd11_vadvise 72 #define SYS_munmap 73 @@ -83,8 +85,8 @@ /* 76 is obsolete vhangup */ /* 77 is obsolete vlimit */ #define SYS_mincore 78 -#define SYS_getgroups 79 -#define SYS_setgroups 80 +#define SYS_freebsd14_getgroups 79 +#define SYS_freebsd14_setgroups 80 #define SYS_getpgrp 81 #define SYS_setpgid 82 #define SYS_setitimer 83 @@ -442,7 +444,7 @@ #define SYS_symlinkat 502 #define SYS_unlinkat 503 #define SYS_posix_openpt 504 -#define SYS_gssd_syscall 505 + /* 505 is obsolete kgssapi */ #define SYS_jail_get 506 #define SYS_jail_set 507 #define SYS_jail_remove 508 @@ -526,4 +528,13 @@ #define SYS_timerfd_settime 587 #define SYS_kcmp 588 #define SYS_getrlimitusage 589 -#define SYS_MAXSYSCALL 590 \ No newline at end of file +#define SYS_fchroot 590 +#define SYS_setcred 591 +#define SYS_exterrctl 592 +#define SYS_inotify_add_watch_at 593 +#define SYS_inotify_rm_watch 594 +#define SYS_getgroups 595 +#define SYS_setgroups 596 +#define SYS_jail_attach_jd 597 +#define SYS_jail_remove_jd 598 +#define SYS_MAXSYSCALL 599 \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/syscallsubr.h b/lib/libc/include/generic-freebsd/sys/syscallsubr.h index 219a3a8eb819e59fc4b746c0161e2cd31b7191f7..ebd4cb5618c530e98c5801c91c2d1943b4369635 100644 --- a/lib/libc/include/generic-freebsd/sys/syscallsubr.h +++ b/lib/libc/include/generic-freebsd/sys/syscallsubr.h @@ -28,13 +28,14 @@ #ifndef _SYS_SYSCALLSUBR_H_ #define _SYS_SYSCALLSUBR_H_ -#include -#include -#include -#include +#include #include #include #include +#include +#include +#include +#include struct __wrusage; struct cpuset_copy_cb; @@ -49,6 +50,7 @@ struct kevent_copyops; struct kld_file_stat; struct ksiginfo; struct mbuf; +struct mq_attr; struct msghdr; struct msqid_ds; struct pollfd; @@ -58,6 +60,7 @@ struct rusage; struct sched_param; struct sembuf; union semun; +struct shmfd; struct sockaddr; struct spacectl_range; struct stat; @@ -84,10 +87,10 @@ int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, size_t buflen, size_t path_max); int kern_abort2(struct thread *td, const char *why, int nargs, void **uargs); -int kern_accept(struct thread *td, int s, struct sockaddr **name, - socklen_t *namelen, struct file **fp); -int kern_accept4(struct thread *td, int s, struct sockaddr **name, - socklen_t *namelen, int flags, struct file **fp); +int kern_accept(struct thread *td, int s, struct sockaddr *sa, + struct file **fp); +int kern_accept4(struct thread *td, int s, struct sockaddr *sa, + int flags, struct file **fp); int kern_accessat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int flags, int mode); int kern_adjtime(struct thread *td, struct timeval *delta, @@ -164,7 +167,7 @@ int kern_fchmodat(struct thread *td, int fd, const char *path, int kern_fchownat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int uid, int gid, int flag); int kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg); -int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg); +int kern_fcntl_freebsd(struct thread *td, int fd, int cmd, intptr_t arg); int kern_fhopen(struct thread *td, const struct fhandle *u_fhp, int flags); int kern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf); int kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf); @@ -187,13 +190,11 @@ int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, size_t *countp, enum uio_seg bufseg, int mode); int kern_getitimer(struct thread *, u_int, struct itimerval *); int kern_getppid(struct thread *); -int kern_getpeername(struct thread *td, int fd, struct sockaddr **sa, - socklen_t *alen); +int kern_getpeername(struct thread *td, int fd, struct sockaddr *sa); int kern_getpriority(struct thread *td, int which, int who); int kern_getrusage(struct thread *td, int who, struct rusage *rup); int kern_getsid(struct thread *td, pid_t pid); -int kern_getsockname(struct thread *td, int fd, struct sockaddr **sa, - socklen_t *alen); +int kern_getsockname(struct thread *td, int fd, struct sockaddr *sa); int kern_getsockopt(struct thread *td, int s, int level, int name, void *optval, enum uio_seg valseg, socklen_t *valsize); int kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data); @@ -214,6 +215,15 @@ int kern_kqueue(struct thread *td, int flags, struct filecaps *fcaps); int kern_kldload(struct thread *td, const char *file, int *fileid); int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); int kern_kldunload(struct thread *td, int fileid, int flags); +int kern_kmq_notify(struct thread *, int, struct sigevent *); +int kern_kmq_open(struct thread *, const char *, int, mode_t, + const struct mq_attr *); +int kern_kmq_setattr(struct thread *, int, const struct mq_attr *, + struct mq_attr *); +int kern_kmq_timedreceive(struct thread *, int, char *, + size_t, unsigned int *, const struct timespec *); +int kern_kmq_timedsend(struct thread *td, int, const char *, + size_t, unsigned int, const struct timespec *); int kern_linkat(struct thread *td, int fd1, int fd2, const char *path1, const char *path2, enum uio_seg segflg, int flag); int kern_listen(struct thread *td, int s, int backlog); @@ -248,6 +258,7 @@ int kern_munlock(struct thread *td, uintptr_t addr, size_t size); int kern_munmap(struct thread *td, uintptr_t addr, size_t size); int kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt); +int kern_nosys(struct thread *td, int dummy); int kern_ntp_adjtime(struct thread *td, struct timex *ntv, int *retvalp); int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, long *ploff); @@ -312,7 +323,9 @@ int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou, fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits); int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags, struct mbuf *control, enum uio_seg segflg); -int kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups); +int kern_setcred(struct thread *const td, const u_int flags, + struct setcred *const wcred, gid_t *preallocated_groups); +int kern_setgroups(struct thread *td, int *ngrpp, gid_t *groups); int kern_setitimer(struct thread *, u_int, struct itimerval *, struct itimerval *); int kern_setpriority(struct thread *td, int which, int who, int prio); @@ -325,7 +338,7 @@ int kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode, struct filecaps *fcaps); int kern_shm_open2(struct thread *td, const char *path, int flags, mode_t mode, int shmflags, struct filecaps *fcaps, - const char *name); + const char *name, struct shmfd *shmfd); int kern_shmat(struct thread *td, int shmid, const void *shmaddr, int shmflg); int kern_shmctl(struct thread *td, int shmid, int cmd, void *buf, diff --git a/lib/libc/include/generic-freebsd/sys/sysctl.h b/lib/libc/include/generic-freebsd/sys/sysctl.h index 6550ca0630463a0428fd34c772b078acd9784a29..059a0998606dbf7f0be7cd828ea2c2fe24b5a7dc 100644 --- a/lib/libc/include/generic-freebsd/sys/sysctl.h +++ b/lib/libc/include/generic-freebsd/sys/sysctl.h @@ -30,14 +30,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_SYSCTL_H_ #define _SYS_SYSCTL_H_ #ifdef _KERNEL +#include #include #include #endif @@ -866,7 +865,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); /* OID expressing a sbintime_t as microseconds */ #define SYSCTL_SBINTIME_USEC(parent, nbr, name, access, ptr, descr) \ SYSCTL_OID(parent, nbr, name, \ - CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ + CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ (ptr), 0, sysctl_usec_to_sbintime, "Q", descr); \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) @@ -876,7 +875,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ sysctl_add_oid(ctx, parent, nbr, name, \ - CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ + CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ __ptr, 0, sysctl_usec_to_sbintime, "Q", __DESCR(descr), \ NULL); \ }) @@ -884,7 +883,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); /* OID expressing a sbintime_t as milliseconds */ #define SYSCTL_SBINTIME_MSEC(parent, nbr, name, access, ptr, descr) \ SYSCTL_OID(parent, nbr, name, \ - CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ + CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ (ptr), 0, sysctl_msec_to_sbintime, "Q", descr); \ CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) @@ -894,7 +893,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTASSERT(((access) & CTLTYPE) == 0 || \ ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ sysctl_add_oid(ctx, parent, nbr, name, \ - CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ + CTLTYPE_S64 | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ __ptr, 0, sysctl_msec_to_sbintime, "Q", __DESCR(descr), \ NULL); \ }) @@ -934,6 +933,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); CTLFLAG_RD | CTLFLAG_CAPRD | CTLTYPE_INT | CTLFLAG_MPSAFE, \ NULL, 1, sysctl_handle_int, "I", desc, "feature"); +/* + * Adding new leaves to the 'debug.sizeof' MIB tree for ad-hoc reasons is + * discouraged, and in particular for reporting to developers the size of some + * kernel structures, which can be obtained by the following alternative means: + * 1. In GDB, load a full kernel image and use 'print(sizeof(struct XXX))'. + * Alternatively, use 'ptype/o struct XXX' to additionally get the offsets + * and size of all structure's fields. + * 2. If the structure is allocated from UMA, then 'vmstat -z' reports its size + * (the mapping between structure types and zones is usually + * straightforward). + */ +/* Generates a read-only sysctl reporting the size of an object/structure. */ +#define SYSCTL_SIZEOF(name, expr) \ + SYSCTL_INT(_debug_sizeof, OID_AUTO, name, CTLFLAG_RD, \ + SYSCTL_NULL_INT_PTR, sizeof(expr), \ + "sizeof(" __STRING(expr) ")"); +/* Same, specialized for structures. */ +#define SYSCTL_SIZEOF_STRUCT(struct_name) \ + SYSCTL_SIZEOF(struct_name, struct struct_name) + #endif /* _KERNEL */ /* @@ -1043,6 +1062,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define KERN_PROC_SIGFASTBLK 44 /* address of fastsigblk magic word */ #define KERN_PROC_VM_LAYOUT 45 /* virtual address space layout info */ #define KERN_PROC_RLIMIT_USAGE 46 /* array of rlim_t */ +#define KERN_PROC_KQUEUE 47 /* array of struct kinfo_knote */ /* * KERN_IPC identifiers diff --git a/lib/libc/include/generic-freebsd/sys/sysent.h b/lib/libc/include/generic-freebsd/sys/sysent.h index 537130a4623372c1f1dd5d16b238c19974a37e7f..24a5b17dbca5f78979a995fcc9b449bae14fcfd2 100644 --- a/lib/libc/include/generic-freebsd/sys/sysent.h +++ b/lib/libc/include/generic-freebsd/sys/sysent.h @@ -79,11 +79,10 @@ struct sysent { /* system call table */ */ #define SYF_CAPENABLED 0x00000001 -#define SY_THR_FLAGMASK 0x7 -#define SY_THR_STATIC 0x1 -#define SY_THR_DRAINING 0x2 -#define SY_THR_ABSENT 0x4 -#define SY_THR_INCR 0x8 +#define SY_THR_STATIC 0x01 +#define SY_THR_DRAINING 0x02 +#define SY_THR_ABSENT 0x04 +#define SY_THR_INCR 0x08 #ifdef KLD_MODULE #define SY_THR_STATIC_KLD 0 @@ -91,6 +90,7 @@ struct sysent { /* system call table */ #define SY_THR_STATIC_KLD SY_THR_STATIC #endif +struct coredump_writer; struct image_params; struct proc; struct __sigset; @@ -109,7 +109,8 @@ struct sysentvec { int *sv_szsigcode; /* size of sigtramp code */ int sv_sigcodeoff; char *sv_name; /* name of binary type */ - int (*sv_coredump)(struct thread *, struct vnode *, off_t, int); + int (*sv_coredump)(struct thread *, struct coredump_writer *, + off_t, int); /* function to dump core, or NULL */ int sv_elf_core_osabi; const char *sv_elf_core_abi_vendor; @@ -145,10 +146,13 @@ struct sysentvec { int (*sv_trap)(struct thread *); u_long *sv_hwcap; /* Value passed in AT_HWCAP. */ u_long *sv_hwcap2; /* Value passed in AT_HWCAP2. */ + u_long *sv_hwcap3; /* Value passed in AT_HWCAP3. */ + u_long *sv_hwcap4; /* Value passed in AT_HWCAP4. */ const char *(*sv_machine_arch)(struct proc *); vm_offset_t sv_fxrng_gen_offset; void (*sv_onexec_old)(struct thread *td); int (*sv_onexec)(struct proc *, struct image_params *); + void (*sv_protect)(struct image_params *, int); void (*sv_onexit)(struct proc *); void (*sv_ontdexit)(struct thread *td); int (*sv_setid_allowed)(struct thread *td, @@ -161,7 +165,7 @@ struct sysentvec { #define SV_ILP32 0x000100 /* 32-bit executable. */ #define SV_LP64 0x000200 /* 64-bit executable. */ -#define SV_IA32 0x004000 /* Intel 32-bit executable. */ +#define SV_RESERVED0 0x004000 /* Formerly SV_IA32 */ #define SV_AOUT 0x008000 /* a.out executable. */ #define SV_SHP 0x010000 /* Shared page. */ #define SV_SIGSYS 0x020000 /* SIGSYS for non-existing syscall */ @@ -187,6 +191,10 @@ struct sysentvec { #define SVC_NOCOMPRESS 0x00000002 /* disable compression. */ #define SVC_ALL 0x00000004 /* dump everything */ +/* sv_protect flags */ +#define SVP_IMAGE 0x00000001 +#define SVP_INTERP 0x00000002 + #ifdef _KERNEL extern struct sysentvec aout_sysvec; extern struct sysent sysent[]; diff --git a/lib/libc/include/generic-freebsd/sys/syslimits.h b/lib/libc/include/generic-freebsd/sys/syslimits.h index 3d06dc0b294d30f81521edabbf3209a1d5569edc..546c143f5040d3a3146b9697e7f141438b407ff2 100644 --- a/lib/libc/include/generic-freebsd/sys/syslimits.h +++ b/lib/libc/include/generic-freebsd/sys/syslimits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_SYSLIMITS_H_ diff --git a/lib/libc/include/generic-freebsd/sys/syslog.h b/lib/libc/include/generic-freebsd/sys/syslog.h index b6528a384113a6da21c86d56553cf04bcadae873..3c822d795d52a1c0b8d146703882ffdeacecc56f 100644 --- a/lib/libc/include/generic-freebsd/sys/syslog.h +++ b/lib/libc/include/generic-freebsd/sys/syslog.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)syslog.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_SYSLOG_H_ diff --git a/lib/libc/include/generic-freebsd/sys/sysproto.h b/lib/libc/include/generic-freebsd/sys/sysproto.h index 69f63c8daeb7675aae1204f8556b509bb8d0360a..0672feb70d1090665480f8309249c05faaf6ba6f 100644 --- a/lib/libc/include/generic-freebsd/sys/sysproto.h +++ b/lib/libc/include/generic-freebsd/sys/sysproto.h @@ -7,8 +7,8 @@ #ifndef _SYS_SYSPROTO_H_ #define _SYS_SYSPROTO_H_ +#include #include -#include #include #include #include @@ -33,7 +33,7 @@ struct thread; #define PADR_(t) 0 #endif -struct exit_args { +struct _exit_args { char rval_l_[PADL_(int)]; int rval; char rval_r_[PADR_(int)]; }; struct fork_args { @@ -254,12 +254,6 @@ struct msync_args { struct vfork_args { syscallarg_t dummy; }; -struct sbrk_args { - char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)]; -}; -struct sstk_args { - char incr_l_[PADL_(int)]; int incr; char incr_r_[PADR_(int)]; -}; struct munmap_args { char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; @@ -279,14 +273,6 @@ struct mincore_args { char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; char vec_l_[PADL_(char *)]; char * vec; char vec_r_[PADR_(char *)]; }; -struct getgroups_args { - char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; - char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)]; -}; -struct setgroups_args { - char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; - char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)]; -}; struct getpgrp_args { syscallarg_t dummy; }; @@ -319,7 +305,7 @@ struct dup2_args { struct fcntl_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char arg_l_[PADL_(long)]; long arg; char arg_r_[PADR_(long)]; + char arg_l_[PADL_(intptr_t)]; intptr_t arg; char arg_r_[PADR_(intptr_t)]; }; struct select_args { char nd_l_[PADL_(int)]; int nd; char nd_r_[PADR_(int)]; @@ -383,12 +369,12 @@ struct getsockopt_args { }; struct readv_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)]; + char iovp_l_[PADL_(const struct iovec *)]; const struct iovec * iovp; char iovp_r_[PADR_(const struct iovec *)]; char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)]; }; struct writev_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)]; + char iovp_l_[PADL_(const struct iovec *)]; const struct iovec * iovp; char iovp_r_[PADR_(const struct iovec *)]; char iovcnt_l_[PADL_(u_int)]; u_int iovcnt; char iovcnt_r_[PADR_(u_int)]; }; struct settimeofday_args { @@ -552,7 +538,7 @@ struct setrlimit_args { char rlp_l_[PADL_(struct rlimit *)]; struct rlimit * rlp; char rlp_r_[PADR_(struct rlimit *)]; }; struct __sysctl_args { - char name_l_[PADL_(int *)]; int * name; char name_r_[PADR_(int *)]; + char name_l_[PADL_(const int *)]; const int * name; char name_r_[PADR_(const int *)]; char namelen_l_[PADL_(u_int)]; u_int namelen; char namelen_r_[PADR_(u_int)]; char old_l_[PADL_(void *)]; void * old; char old_r_[PADR_(void *)]; char oldlenp_l_[PADL_(size_t *)]; size_t * oldlenp; char oldlenp_r_[PADR_(size_t *)]; @@ -783,7 +769,7 @@ struct aio_return_args { char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)]; }; struct aio_suspend_args { - char aiocbp_l_[PADL_(struct aiocb * const *)]; struct aiocb * const * aiocbp; char aiocbp_r_[PADR_(struct aiocb * const *)]; + char aiocbp_l_[PADL_(const struct aiocb * const *)]; const struct aiocb * const * aiocbp; char aiocbp_r_[PADR_(const struct aiocb * const *)]; char nent_l_[PADL_(int)]; int nent; char nent_r_[PADR_(int)]; char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)]; }; @@ -868,49 +854,49 @@ struct sigpending_args { }; struct sigtimedwait_args { char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)]; - char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)]; + char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)]; char timeout_l_[PADL_(const struct timespec *)]; const struct timespec * timeout; char timeout_r_[PADR_(const struct timespec *)]; }; struct sigwaitinfo_args { char set_l_[PADL_(const sigset_t *)]; const sigset_t * set; char set_r_[PADR_(const sigset_t *)]; - char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)]; + char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)]; }; struct __acl_get_file_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_set_file_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_get_fd_args { char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_set_fd_args { char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_delete_file_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; }; struct __acl_delete_fd_args { char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; }; struct __acl_aclcheck_file_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_aclcheck_fd_args { char filedes_l_[PADL_(int)]; int filedes; char filedes_r_[PADR_(int)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct extattrctl_args { @@ -1136,21 +1122,21 @@ struct swapcontext_args { }; struct __acl_get_link_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_set_link_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct __acl_delete_link_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; }; struct __acl_aclcheck_link_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char type_l_[PADL_(acl_type_t)]; acl_type_t type; char type_r_[PADR_(acl_type_t)]; + char type_l_[PADL_(__acl_type_t)]; __acl_type_t type; char type_r_[PADR_(__acl_type_t)]; char aclp_l_[PADL_(struct acl *)]; struct acl * aclp; char aclp_r_[PADR_(struct acl *)]; }; struct sigwait_args { @@ -1482,9 +1468,6 @@ struct unlinkat_args { struct posix_openpt_args { char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; }; -struct gssd_syscall_args { - char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; -}; struct jail_get_args { char iovp_l_[PADL_(struct iovec *)]; struct iovec * iovp; char iovp_r_[PADR_(struct iovec *)]; char iovcnt_l_[PADL_(unsigned int)]; unsigned int iovcnt; char iovcnt_r_[PADR_(unsigned int)]; @@ -1603,7 +1586,7 @@ struct wait6_args { char status_l_[PADL_(int *)]; int * status; char status_r_[PADR_(int *)]; char options_l_[PADL_(int)]; int options; char options_r_[PADR_(int)]; char wrusage_l_[PADL_(struct __wrusage *)]; struct __wrusage * wrusage; char wrusage_r_[PADR_(struct __wrusage *)]; - char info_l_[PADL_(struct siginfo *)]; struct siginfo * info; char info_r_[PADR_(struct siginfo *)]; + char info_l_[PADL_(struct __siginfo *)]; struct __siginfo * info; char info_r_[PADR_(struct __siginfo *)]; }; struct cap_rights_limit_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; @@ -1811,7 +1794,7 @@ struct shm_rename_args { }; struct sigfastblock_args { char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char ptr_l_[PADL_(uint32_t *)]; uint32_t * ptr; char ptr_r_[PADR_(uint32_t *)]; + char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)]; }; struct __realpathat_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; @@ -1826,8 +1809,7 @@ struct close_range_args { char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; }; struct rpctls_syscall_args { - char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)]; - char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char socookie_l_[PADL_(uint64_t)]; uint64_t socookie; char socookie_r_[PADR_(uint64_t)]; }; struct __specialfd_args { char type_l_[PADL_(int)]; int type; char type_r_[PADR_(int)]; @@ -1888,7 +1870,44 @@ struct getrlimitusage_args { char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; char res_l_[PADL_(rlim_t *)]; rlim_t * res; char res_r_[PADR_(rlim_t *)]; }; -int sys_exit(struct thread *, struct exit_args *); +struct fchroot_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; +}; +struct setcred_args { + char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)]; + char wcred_l_[PADL_(const struct setcred *)]; const struct setcred * wcred; char wcred_r_[PADR_(const struct setcred *)]; + char size_l_[PADL_(size_t)]; size_t size; char size_r_[PADR_(size_t)]; +}; +struct exterrctl_args { + char op_l_[PADL_(u_int)]; u_int op; char op_r_[PADR_(u_int)]; + char flags_l_[PADL_(u_int)]; u_int flags; char flags_r_[PADR_(u_int)]; + char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)]; +}; +struct inotify_add_watch_at_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char dfd_l_[PADL_(int)]; int dfd; char dfd_r_[PADR_(int)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char mask_l_[PADL_(uint32_t)]; uint32_t mask; char mask_r_[PADR_(uint32_t)]; +}; +struct inotify_rm_watch_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char wd_l_[PADL_(int)]; int wd; char wd_r_[PADR_(int)]; +}; +struct getgroups_args { + char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; + char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)]; +}; +struct setgroups_args { + char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; + char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)]; +}; +struct jail_attach_jd_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; +}; +struct jail_remove_jd_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; +}; +int sys__exit(struct thread *, struct _exit_args *); int sys_fork(struct thread *, struct fork_args *); int sys_read(struct thread *, struct read_args *); int sys_write(struct thread *, struct write_args *); @@ -1940,14 +1959,10 @@ int sys_umask(struct thread *, struct umask_args *); int sys_chroot(struct thread *, struct chroot_args *); int sys_msync(struct thread *, struct msync_args *); int sys_vfork(struct thread *, struct vfork_args *); -int sys_sbrk(struct thread *, struct sbrk_args *); -int sys_sstk(struct thread *, struct sstk_args *); int sys_munmap(struct thread *, struct munmap_args *); int sys_mprotect(struct thread *, struct mprotect_args *); int sys_madvise(struct thread *, struct madvise_args *); int sys_mincore(struct thread *, struct mincore_args *); -int sys_getgroups(struct thread *, struct getgroups_args *); -int sys_setgroups(struct thread *, struct setgroups_args *); int sys_getpgrp(struct thread *, struct getpgrp_args *); int sys_setpgid(struct thread *, struct setpgid_args *); int sys_setitimer(struct thread *, struct setitimer_args *); @@ -2210,7 +2225,6 @@ int sys_renameat(struct thread *, struct renameat_args *); int sys_symlinkat(struct thread *, struct symlinkat_args *); int sys_unlinkat(struct thread *, struct unlinkat_args *); int sys_posix_openpt(struct thread *, struct posix_openpt_args *); -int sys_gssd_syscall(struct thread *, struct gssd_syscall_args *); int sys_jail_get(struct thread *, struct jail_get_args *); int sys_jail_set(struct thread *, struct jail_set_args *); int sys_jail_remove(struct thread *, struct jail_remove_args *); @@ -2290,6 +2304,15 @@ int sys_timerfd_gettime(struct thread *, struct timerfd_gettime_args *); int sys_timerfd_settime(struct thread *, struct timerfd_settime_args *); int sys_kcmp(struct thread *, struct kcmp_args *); int sys_getrlimitusage(struct thread *, struct getrlimitusage_args *); +int sys_fchroot(struct thread *, struct fchroot_args *); +int sys_setcred(struct thread *, struct setcred_args *); +int sys_exterrctl(struct thread *, struct exterrctl_args *); +int sys_inotify_add_watch_at(struct thread *, struct inotify_add_watch_at_args *); +int sys_inotify_rm_watch(struct thread *, struct inotify_rm_watch_args *); +int sys_getgroups(struct thread *, struct getgroups_args *); +int sys_setgroups(struct thread *, struct setgroups_args *); +int sys_jail_attach_jd(struct thread *, struct jail_attach_jd_args *); +int sys_jail_remove_jd(struct thread *, struct jail_remove_jd_args *); #ifdef COMPAT_43 @@ -2781,7 +2804,23 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *); #endif /* COMPAT_FREEBSD13 */ -#define SYS_AUE_exit AUE_EXIT + +#ifdef COMPAT_FREEBSD14 + +struct freebsd14_getgroups_args { + char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; + char gidset_l_[PADL_(gid_t *)]; gid_t * gidset; char gidset_r_[PADR_(gid_t *)]; +}; +struct freebsd14_setgroups_args { + char gidsetsize_l_[PADL_(int)]; int gidsetsize; char gidsetsize_r_[PADR_(int)]; + char gidset_l_[PADL_(const gid_t *)]; const gid_t * gidset; char gidset_r_[PADR_(const gid_t *)]; +}; +int freebsd14_getgroups(struct thread *, struct freebsd14_getgroups_args *); +int freebsd14_setgroups(struct thread *, struct freebsd14_setgroups_args *); + +#endif /* COMPAT_FREEBSD14 */ + +#define SYS_AUE__exit AUE_EXIT #define SYS_AUE_fork AUE_FORK #define SYS_AUE_read AUE_READ #define SYS_AUE_write AUE_WRITE @@ -2846,16 +2885,14 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *); #define SYS_AUE_ogetpagesize AUE_NULL #define SYS_AUE_msync AUE_MSYNC #define SYS_AUE_vfork AUE_VFORK -#define SYS_AUE_sbrk AUE_SBRK -#define SYS_AUE_sstk AUE_SSTK #define SYS_AUE_ommap AUE_MMAP #define SYS_AUE_freebsd11_vadvise AUE_O_VADVISE #define SYS_AUE_munmap AUE_MUNMAP #define SYS_AUE_mprotect AUE_MPROTECT #define SYS_AUE_madvise AUE_MADVISE #define SYS_AUE_mincore AUE_MINCORE -#define SYS_AUE_getgroups AUE_GETGROUPS -#define SYS_AUE_setgroups AUE_SETGROUPS +#define SYS_AUE_freebsd14_getgroups AUE_GETGROUPS +#define SYS_AUE_freebsd14_setgroups AUE_SETGROUPS #define SYS_AUE_getpgrp AUE_GETPGRP #define SYS_AUE_setpgid AUE_SETPGRP #define SYS_AUE_setitimer AUE_SETITIMER @@ -3185,7 +3222,6 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *); #define SYS_AUE_symlinkat AUE_SYMLINKAT #define SYS_AUE_unlinkat AUE_UNLINKAT #define SYS_AUE_posix_openpt AUE_POSIX_OPENPT -#define SYS_AUE_gssd_syscall AUE_NULL #define SYS_AUE_jail_get AUE_JAIL_GET #define SYS_AUE_jail_set AUE_JAIL_SET #define SYS_AUE_jail_remove AUE_JAIL_REMOVE @@ -3266,6 +3302,15 @@ int freebsd13_swapoff(struct thread *, struct freebsd13_swapoff_args *); #define SYS_AUE_timerfd_settime AUE_TIMERFD #define SYS_AUE_kcmp AUE_NULL #define SYS_AUE_getrlimitusage AUE_NULL +#define SYS_AUE_fchroot AUE_NULL +#define SYS_AUE_setcred AUE_SETCRED +#define SYS_AUE_exterrctl AUE_NULL +#define SYS_AUE_inotify_add_watch_at AUE_INOTIFY +#define SYS_AUE_inotify_rm_watch AUE_INOTIFY +#define SYS_AUE_getgroups AUE_GETGROUPS +#define SYS_AUE_setgroups AUE_SETGROUPS +#define SYS_AUE_jail_attach_jd AUE_JAIL_ATTACH +#define SYS_AUE_jail_remove_jd AUE_JAIL_REMOVE #undef PAD_ #undef PADL_ diff --git a/lib/libc/include/generic-freebsd/sys/systm.h b/lib/libc/include/generic-freebsd/sys/systm.h index 354a239efc4b3d8fd9dfb12f5d2135aa4809d6b2..0ac452fc13dbfe86553daa47e450887a7701b78f 100644 --- a/lib/libc/include/generic-freebsd/sys/systm.h +++ b/lib/libc/include/generic-freebsd/sys/systm.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)systm.h 8.7 (Berkeley) 3/29/95 */ #ifndef _SYS_SYSTM_H_ @@ -81,7 +79,7 @@ extern u_long maxphys; /* max raw I/O transfer size */ */ enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_GUEST_VBOX, - VM_GUEST_PARALLELS, VM_GUEST_NVMM, VM_LAST }; + VM_GUEST_PARALLELS, VM_GUEST_NVMM, VM_GUEST_LAST }; #endif /* KERNEL */ @@ -101,17 +99,15 @@ struct ucred; #include /* curthread */ #include +extern bool scheduler_stopped; + /* * If we have already panic'd and this is the thread that called * panic(), then don't block on any mutexes but silently succeed. * Otherwise, the kernel will deadlock since the scheduler isn't * going to run the thread that holds any lock we need. */ -#define SCHEDULER_STOPPED_TD(td) ({ \ - MPASS((td) == curthread); \ - __predict_false((td)->td_stopsched); \ -}) -#define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread) +#define SCHEDULER_STOPPED() __predict_false(scheduler_stopped) extern const int osreldate; @@ -212,6 +208,16 @@ critical_exit(void) #ifdef EARLY_PRINTF typedef void early_putc_t(int ch); extern early_putc_t *early_putc; +#define CHECK_EARLY_PRINTF(x) \ + __CONCAT(early_printf_, EARLY_PRINTF) == __CONCAT(early_printf_, x) +#define early_printf_1 1 +#define early_printf_mvebu 2 +#define early_printf_ns8250 3 +#define early_printf_pl011 4 +#define early_printf_snps 5 +#define early_printf_sbi 6 +#else +#define CHECK_EARLY_PRINTF(x) 0 #endif int kvprintf(char const *, void (*)(int, void*), void *, int, __va_list) __printflike(1, 0); @@ -296,17 +302,18 @@ void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n); ((__r >= __len) ? ENAMETOOLONG : 0); \ }) -int copyinstr(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len, - size_t * __restrict lencopied); -int copyin(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len); -int copyin_nofault(const void * __restrict udaddr, - void * _Nonnull __restrict kaddr, size_t len); -int copyout(const void * _Nonnull __restrict kaddr, - void * __restrict udaddr, size_t len); -int copyout_nofault(const void * _Nonnull __restrict kaddr, - void * __restrict udaddr, size_t len); +int __result_use_check copyinstr(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len, + size_t * __restrict lencopied); +int __result_use_check copyin(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len); +int __result_use_check copyin_nofault(const void * __restrict udaddr, + void * _Nonnull __restrict kaddr, size_t len); +__nodiscard int copyout(const void * _Nonnull __restrict kaddr, + void * __restrict udaddr, size_t len); +__nodiscard int copyout_nofault( + const void * _Nonnull __restrict kaddr, void * __restrict udaddr, + size_t len); #ifdef SAN_NEEDS_INTERCEPTORS int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t); @@ -324,14 +331,14 @@ long fuword(volatile const void *base); int fuword16(volatile const void *base); int32_t fuword32(volatile const void *base); int64_t fuword64(volatile const void *base); -int fueword(volatile const void *base, long *val); -int fueword32(volatile const void *base, int32_t *val); -int fueword64(volatile const void *base, int64_t *val); -int subyte(volatile void *base, int byte); -int suword(volatile void *base, long word); -int suword16(volatile void *base, int word); -int suword32(volatile void *base, int32_t word); -int suword64(volatile void *base, int64_t word); +int __result_use_check fueword(volatile const void *base, long *val); +int __result_use_check fueword32(volatile const void *base, int32_t *val); +int __result_use_check fueword64(volatile const void *base, int64_t *val); +__nodiscard int subyte(volatile void *base, int byte); +__nodiscard int suword(volatile void *base, long word); +__nodiscard int suword16(volatile void *base, int word); +__nodiscard int suword32(volatile void *base, int32_t word); +__nodiscard int suword64(volatile void *base, int64_t word); uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); u_long casuword(volatile u_long *p, u_long oldval, u_long newval); int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, @@ -559,17 +566,32 @@ void counted_warning(unsigned *counter, const char *msg); /* * APIs to manage deprecation and obsolescence. */ -void _gone_in(int major, const char *msg); -void _gone_in_dev(device_t dev, int major, const char *msg); +void _gone_in(int major, const char *msg, ...) __printflike(2, 3); +void _gone_in_dev(device_t dev, int major, const char *msg, ...) + __printflike(3, 4); #ifdef NO_OBSOLETE_CODE #define __gone_ok(m, msg) \ _Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \ - "Obsolete code: " msg); + "Obsolete code: " msg) #else #define __gone_ok(m, msg) #endif -#define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg) -#define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg) +#define gone_in(major, msg, ...) do { \ + static bool __read_mostly __gone_in_ ## __LINE__ = true; \ + __gone_ok(major, msg); \ + if (__predict_false(__gone_in_ ## __LINE__)) { \ + __gone_in_ ## __LINE__ = false; \ + _gone_in(major, msg __VA_OPT__(,) __VA_ARGS__); \ + } \ +} while (0) +#define gone_in_dev(dev, major, msg, ...) do { \ + static bool __read_mostly __gone_in_ ## __LINE__ = true; \ + __gone_ok(major, msg); \ + if (__predict_false(__gone_in_ ## __LINE__)) { \ + __gone_in_ ## __LINE__ = false; \ + _gone_in_dev(dev, major, msg __VA_OPT__(,) __VA_ARGS__);\ + } \ +} while (0) #ifdef INVARIANTS #define __diagused diff --git a/lib/libc/include/generic-freebsd/sys/taskqueue.h b/lib/libc/include/generic-freebsd/sys/taskqueue.h index 3e755a538460301065e971091d9305fec7ee43bc..e578a1c71d5b401c696b839fe156dd4a800f5684 100644 --- a/lib/libc/include/generic-freebsd/sys/taskqueue.h +++ b/lib/libc/include/generic-freebsd/sys/taskqueue.h @@ -215,4 +215,10 @@ struct taskqueue *taskqueue_create_fast(const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context); +/* + * This queue is used to process asynchronous device events such as + * hot plug insertion and removal of devices. + */ +TASKQUEUE_DECLARE(bus); + #endif /* !_SYS_TASKQUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/thr.h b/lib/libc/include/generic-freebsd/sys/thr.h index b72762846c90687567e6e78a77a631e4f40304a2..bb754209994ec6d66a2b3ae53110f481ba260d4b 100644 --- a/lib/libc/include/generic-freebsd/sys/thr.h +++ b/lib/libc/include/generic-freebsd/sys/thr.h @@ -43,6 +43,7 @@ typedef __size_t size_t; #define THR_SUSPENDED 0x0001 /* Create the system scope thread. */ #define THR_SYSTEM_SCOPE 0x0002 +#define THR_C_RUNTIME 0x0004 struct thr_param { void (*start_func)(void *); /* thread entry function. */ diff --git a/lib/libc/include/generic-freebsd/sys/time.h b/lib/libc/include/generic-freebsd/sys/time.h index a8acb68862427cf40dfe18ff91872c7a7a8996b6..db2e17b0e33ae1b92a44b219369185a7809fd4fb 100644 --- a/lib/libc/include/generic-freebsd/sys/time.h +++ b/lib/libc/include/generic-freebsd/sys/time.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)time.h 8.5 (Berkeley) 5/4/95 */ #ifndef _SYS_TIME_H_ @@ -613,7 +611,9 @@ int tvtohz(struct timeval *tv); #include #include +#ifndef _STANDALONE #include +#endif __BEGIN_DECLS int setitimer(int, const struct itimerval *, struct itimerval *); diff --git a/lib/libc/include/generic-freebsd/sys/timeb.h b/lib/libc/include/generic-freebsd/sys/timeb.h index 53a6b23677c9df4e2f82235d60a1adf07f28c6ee..9cbe49dd12ebe4dd100862314f8757163e637d81 100644 --- a/lib/libc/include/generic-freebsd/sys/timeb.h +++ b/lib/libc/include/generic-freebsd/sys/timeb.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)timeb.h 8.2 (Berkeley) 1/21/94 */ #ifndef _SYS_TIMEB_H_ diff --git a/lib/libc/include/generic-freebsd/sys/timeffc.h b/lib/libc/include/generic-freebsd/sys/timeffc.h index 42243cce639d1e0387aacc7b9afeddde5448989a..ed633138be271208a3a25e10fb2f4e4f75951f75 100644 --- a/lib/libc/include/generic-freebsd/sys/timeffc.h +++ b/lib/libc/include/generic-freebsd/sys/timeffc.h @@ -89,7 +89,7 @@ extern int sysclock_active; * of the kernel tick timer (1/hz [s]). * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee * monotonic time. - * FFCLOCK_LEAPSEC: Include leap seconds. + * {FB|FF}CLOCK_LEAPSEC: Include leap seconds. * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch. */ #define FFCLOCK_FAST 0x00000001 @@ -100,6 +100,7 @@ extern int sysclock_active; #define FBCLOCK_FAST 0x00010000 /* Currently unused. */ #define FBCLOCK_UPTIME 0x00020000 +#define FBCLOCK_LEAPSEC 0x00040000 #define FBCLOCK_MASK 0xffff0000 /* @@ -111,6 +112,7 @@ struct fbclock_info { struct bintime error; struct bintime tick_time; uint64_t th_scale; + long th_tai_offset; int status; }; diff --git a/lib/libc/include/generic-freebsd/sys/times.h b/lib/libc/include/generic-freebsd/sys/times.h index 20617c6f6fb50a64195fcb743a0ece921326216b..eb3ff9b876e64552b84482b90497c1be682058cd 100644 --- a/lib/libc/include/generic-freebsd/sys/times.h +++ b/lib/libc/include/generic-freebsd/sys/times.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)times.h 8.4 (Berkeley) 1/21/94 */ #ifndef _SYS_TIMES_H_ diff --git a/lib/libc/include/generic-freebsd/sys/timespec.h b/lib/libc/include/generic-freebsd/sys/timespec.h index 513c4a96943624b332b1325bb2933862e28a0846..109ee08d2ab7e958681edbf6e47172d55ad1d4f9 100644 --- a/lib/libc/include/generic-freebsd/sys/timespec.h +++ b/lib/libc/include/generic-freebsd/sys/timespec.h @@ -27,9 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)time.h 8.5 (Berkeley) 5/4/95 - * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp */ #ifndef _SYS_TIMESPEC_H_ diff --git a/lib/libc/include/generic-freebsd/sys/timetc.h b/lib/libc/include/generic-freebsd/sys/timetc.h index 7526d680a3ef49f853262530b7d2964d18353184..a9b351af3b9658eeda1f12fee3a5a9eb5fe1975a 100644 --- a/lib/libc/include/generic-freebsd/sys/timetc.h +++ b/lib/libc/include/generic-freebsd/sys/timetc.h @@ -49,7 +49,7 @@ struct timecounter { * This function is optional. It will be called whenever the * timecounter is rewound, and is intended to check for PPS * events. Normal hardware does not need it but timecounters - * which latch PPS in hardware (like sys/pci/xrpu.c) do. + * which latch PPS in hardware do. */ u_int tc_counter_mask; /* This mask should mask off any unimplemented bits. */ @@ -87,7 +87,7 @@ extern int tc_min_ticktock_freq; /* u_int64_t tc_getfrequency(void); void tc_init(struct timecounter *tc); void tc_setclock(struct timespec *ts); -void tc_ticktock(int cnt); +void tc_ticktock(long cnt); void cpu_tick_calibration(void); #ifdef SYSCTL_DECL diff --git a/lib/libc/include/generic-freebsd/sys/timex.h b/lib/libc/include/generic-freebsd/sys/timex.h index 8faa7d724e17d79e405996ca32abe813638910db..82a124cb9050add03f625faa985f47e7b5346338 100644 --- a/lib/libc/include/generic-freebsd/sys/timex.h +++ b/lib/libc/include/generic-freebsd/sys/timex.h @@ -154,7 +154,7 @@ struct timex { #ifdef __FreeBSD__ #ifdef _KERNEL -void ntp_update_second(int64_t *adjustment, time_t *newsec); +void ntp_update_second(int64_t *adjustment, time_t *newsec, long *tai_off); #else /* !_KERNEL */ #include diff --git a/lib/libc/include/generic-freebsd/sys/ttycom.h b/lib/libc/include/generic-freebsd/sys/ttycom.h index fdb07522cc057eb39a9476a9741c8e8d9a0dcb12..bded540a9133d0703635dd17c91aa0826feb1211 100644 --- a/lib/libc/include/generic-freebsd/sys/ttycom.h +++ b/lib/libc/include/generic-freebsd/sys/ttycom.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttycom.h 8.1 (Berkeley) 3/28/94 */ #ifndef _SYS_TTYCOM_H_ @@ -71,8 +69,8 @@ /* 89-91 conflicts: tun and tap */ #define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* enable/get timestamp * of last input event */ -#define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */ -#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */ +/* TIOCMGDTRWAIT _IOR('t', 90, int) * was modem: get wait on close */ +/* TIOCMSDTRWAIT _IOW('t', 91, int) * was modem: set wait on close */ /* 92-93 tun and tap */ /* 94-97 conflicts: tun and tap */ #define TIOCDRAIN _IO('t', 94) /* wait till output drained */ diff --git a/lib/libc/include/generic-freebsd/sys/ttydefaults.h b/lib/libc/include/generic-freebsd/sys/ttydefaults.h index b0124d5fc48da90a9b8f08ab0b0a2b0cd8bc052e..32796d98f3221209ee9ff515e254d160bac34b8d 100644 --- a/lib/libc/include/generic-freebsd/sys/ttydefaults.h +++ b/lib/libc/include/generic-freebsd/sys/ttydefaults.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 */ /* diff --git a/lib/libc/include/generic-freebsd/sys/types.h b/lib/libc/include/generic-freebsd/sys/types.h index 6b1108bbb87962c6ed4afe70a85eea8667866f98..ecdae1410e4b0889a535e613f0c949e4b2cb25e3 100644 --- a/lib/libc/include/generic-freebsd/sys/types.h +++ b/lib/libc/include/generic-freebsd/sys/types.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)types.h 8.6 (Berkeley) 2/19/95 */ #ifndef _SYS_TYPES_H_ @@ -299,9 +297,11 @@ typedef struct vm_page *vm_page_t; #if defined(_KERNEL) || defined(_STANDALONE) #if !defined(__bool_true_false_are_defined) && !defined(__cplusplus) #define __bool_true_false_are_defined 1 +#if __STDC_VERSION__ < 202311L #define false 0 #define true 1 typedef _Bool bool; +#endif /* __STDC_VERSION__ < 202311L */ #endif /* !__bool_true_false_are_defined && !__cplusplus */ #endif /* KERNEL || _STANDALONE */ @@ -313,7 +313,9 @@ typedef _Bool bool; #if __BSD_VISIBLE +#ifndef _STANDALONE #include +#endif /* * The major and minor numbers are encoded in dev_t as MMMmmmMm (where diff --git a/lib/libc/include/generic-freebsd/sys/ucoredump.h b/lib/libc/include/generic-freebsd/sys/ucoredump.h new file mode 100644 index 0000000000000000000000000000000000000000..e6038c8241d1dc9cd846b601557da6d579e2d54c --- /dev/null +++ b/lib/libc/include/generic-freebsd/sys/ucoredump.h @@ -0,0 +1,99 @@ +/* + * + * Copyright (c) 2015 Mark Johnston + * Copyright (c) 2025 Kyle Evans + * + * SPDX-License-Identifier: BSD-2-Clause + * + */ + +#ifndef _SYS_UCOREDUMP_H_ +#define _SYS_UCOREDUMP_H_ + +#ifdef _KERNEL + +#include +#include +#include + +/* Coredump output parameters. */ +struct coredump_params; +struct coredump_writer; +struct thread; +struct ucred; + +typedef int coredump_init_fn(const struct coredump_writer *, + const struct coredump_params *); +typedef int coredump_write_fn(const struct coredump_writer *, const void *, size_t, + off_t, enum uio_seg, struct ucred *, size_t *, struct thread *); +typedef int coredump_extend_fn(const struct coredump_writer *, off_t, + struct ucred *); + +struct coredump_vnode_ctx { + struct vnode *vp; + struct ucred *fcred; +}; + +coredump_write_fn core_vn_write; +coredump_extend_fn core_vn_extend; + +struct coredump_writer { + void *ctx; + coredump_init_fn *init_fn; + coredump_write_fn *write_fn; + coredump_extend_fn *extend_fn; +}; + +struct coredump_params { + off_t offset; + struct ucred *active_cred; + struct thread *td; + const struct coredump_writer *cdw; + struct compressor *comp; +}; + +#define CORE_BUF_SIZE (16 * 1024) + +int core_write(struct coredump_params *, const void *, size_t, off_t, + enum uio_seg, size_t *); +int core_output(char *, size_t, off_t, struct coredump_params *, void *); +int sbuf_drain_core_output(void *, const char *, int); + +extern int coredump_pack_fileinfo; +extern int coredump_pack_vmmapinfo; + +extern int compress_user_cores; +extern int compress_user_cores_level; + +typedef int coredumper_probe_fn(struct thread *); + +/* + * Some arbitrary values for coredumper probes to return. The highest priority + * we can find wins. It's somewhat expected that a coredumper may want to bid + * differently based on the process in question. Note that probe functions will + * be called with the proc lock held, so they must not sleep. + */ +#define COREDUMPER_NOMATCH (-1) /* Decline to touch it */ +#define COREDUMPER_GENERIC (0) /* I handle coredumps */ +#define COREDUMPER_SPECIAL (50) /* Special handler */ +#define COREDUMPER_HIGH_PRIORITY (100) /* High-priority handler */ + +/* + * The handle functions will be called with the proc lock held, and should + * return with the proc lock dropped. + */ +typedef int coredumper_handle_fn(struct thread *, off_t); + +struct coredumper { + SLIST_ENTRY(coredumper) cd_entry; + const char *cd_name; + coredumper_probe_fn *cd_probe; + coredumper_handle_fn *cd_handle; + blockcount_t cd_refcount; +}; + +void coredumper_register(struct coredumper *); +void coredumper_unregister(struct coredumper *); + +#endif /* _KERNEL */ +#endif /* _SYS_UCOREDUMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/ucred.h b/lib/libc/include/generic-freebsd/sys/ucred.h index 0f62d2f0bc91d3654c64e63e649d997475e215b7..c8f77d703832883a2adb3e5caa6956aaac7ef290 100644 --- a/lib/libc/include/generic-freebsd/sys/ucred.h +++ b/lib/libc/include/generic-freebsd/sys/ucred.h @@ -27,22 +27,36 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ucred.h 8.4 (Berkeley) 1/9/95 */ #ifndef _SYS_UCRED_H_ #define _SYS_UCRED_H_ +#include #if defined(_KERNEL) || defined(_WANT_UCRED) #include #include #endif #include +#if defined(_KERNEL) || defined(_WANT_UCRED) +/* + * Flags for cr_flags. + */ +#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */ +#define CRED_FLAG_GROUPSET 0x00000002 /* Groups have been set. */ + +/* + * Number of groups inlined in 'struct ucred'. It must stay reasonably low as + * it is also used by some functions to allocate an array of this size on the + * stack. + */ +#define CRED_SMALLGROUPS_NB 16 + +struct label; struct loginclass; - -#define XU_NGROUPS 16 +struct prison; +struct uidinfo; /* * Credentials. @@ -57,39 +71,37 @@ struct loginclass; * * See "Credential management" comment in kern_prot.c for more information. */ -#if defined(_KERNEL) || defined(_WANT_UCRED) struct ucred { struct mtx cr_mtx; long cr_ref; /* (c) reference count */ u_int cr_users; /* (c) proc + thread using this cred */ u_int cr_flags; /* credential flags */ struct auditinfo_addr cr_audit; /* Audit properties. */ + int cr_ngroups; /* number of supplementary groups */ #define cr_startcopy cr_uid uid_t cr_uid; /* effective user id */ uid_t cr_ruid; /* real user id */ uid_t cr_svuid; /* saved user id */ - int cr_ngroups; /* number of groups */ + gid_t cr_gid; /* effective group id */ gid_t cr_rgid; /* real group id */ gid_t cr_svgid; /* saved group id */ struct uidinfo *cr_uidinfo; /* per euid resource consumption */ struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */ struct prison *cr_prison; /* jail(2) */ struct loginclass *cr_loginclass; /* login class */ - void *cr_pspare2[2]; /* general use 2 */ + void *cr_pspare2[2]; /* general use 2 */ #define cr_endcopy cr_label struct label *cr_label; /* MAC label */ gid_t *cr_groups; /* groups */ int cr_agroups; /* Available groups */ - gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ + /* storage for small groups */ + gid_t cr_smallgroups[CRED_SMALLGROUPS_NB]; }; #define NOCRED ((struct ucred *)0) /* no credential available */ #define FSCRED ((struct ucred *)-1) /* filesystem credential */ #endif /* _KERNEL || _WANT_UCRED */ -/* - * Flags for cr_flags. - */ -#define CRED_FLAG_CAPMODE 0x00000001 /* In capability mode. */ +#define XU_NGROUPS 16 /* * This is the external representation of struct ucred. @@ -97,8 +109,26 @@ struct ucred { struct xucred { u_int cr_version; /* structure layout version */ uid_t cr_uid; /* effective user id */ - short cr_ngroups; /* number of groups */ - gid_t cr_groups[XU_NGROUPS]; /* groups */ + short cr_ngroups; /* number of groups (incl. cr_gid). */ + union { + /* + * The effective GID has been the first element of cr_groups[] + * for historical reasons. It should be accessed using the + * 'cr_gid' identifier. Supplementary groups should be accessed + * using cr_sgroups[]. Note that 'cr_ngroups' currently + * includes the effective GID. + * + * XXXOC: On the next API change (requires versioning), please + * replace this union with a true unaliased field 'cr_gid' and + * make sure that cr_groups[]/'cr_ngroups' only account for + * supplementary groups. + */ + struct { + gid_t cr_gid; /* effective group id */ + gid_t cr_sgroups[XU_NGROUPS - 1]; + }; + gid_t cr_groups[XU_NGROUPS]; /* groups */ + }; union { void *_cr_unused1; /* compatibility with old ucred */ pid_t cr_pid; @@ -106,17 +136,77 @@ struct xucred { }; #define XUCRED_VERSION 0 -/* This can be used for both ucred and xucred structures. */ -#define cr_gid cr_groups[0] +struct mac; +/* + * Structure to pass as an argument to the setcred() system call. + */ +struct setcred { + uid_t sc_uid; /* effective user id */ + uid_t sc_ruid; /* real user id */ + uid_t sc_svuid; /* saved user id */ + gid_t sc_gid; /* effective group id */ + gid_t sc_rgid; /* real group id */ + gid_t sc_svgid; /* saved group id */ + u_int sc_pad; /* see 32-bit compat structure */ + u_int sc_supp_groups_nb; /* number of supplementary groups */ + gid_t *sc_supp_groups; /* supplementary groups */ + struct mac *sc_label; /* MAC label */ +}; +/* + * Initializer for 'struct setcred' variables. + */ +#define SETCRED_INITIALIZER { -1, -1, -1, -1, -1, -1, 0, 0, NULL, NULL } + +/* + * Flags to setcred(). + */ +#define SETCREDF_UID (1u << 0) +#define SETCREDF_RUID (1u << 1) +#define SETCREDF_SVUID (1u << 2) +#define SETCREDF_GID (1u << 3) +#define SETCREDF_RGID (1u << 4) +#define SETCREDF_SVGID (1u << 5) +#define SETCREDF_SUPP_GROUPS (1u << 6) +#define SETCREDF_MAC_LABEL (1u << 7) #ifdef _KERNEL -struct proc; +/* + * Masks of the currently valid flags to setcred(). + * + * Please consider reserving some of the high bits in the 'flags' argument for + * versioning when almost all of them are in use. + */ +#define SETCREDF_MASK (SETCREDF_UID | SETCREDF_RUID | SETCREDF_SVUID | \ + SETCREDF_GID | SETCREDF_RGID | SETCREDF_SVGID | SETCREDF_SUPP_GROUPS | \ + SETCREDF_MAC_LABEL) + +struct setcred32 { +#define setcred32_copy_start sc_uid + uid_t sc_uid; + uid_t sc_ruid; + uid_t sc_svuid; + gid_t sc_gid; + gid_t sc_rgid; + gid_t sc_svgid; + u_int sc_pad; + u_int sc_supp_groups_nb; +#define setcred32_copy_end sc_supp_groups + uint32_t sc_supp_groups; /* gid_t [*] */ + uint32_t sc_label; /* struct mac32 [*] */ +}; + struct thread; +/* Common native and 32-bit compatibility entry point. */ +int user_setcred(struct thread *td, const u_int flags, + const void *const uwcred, const size_t size, bool is_32bit); + +struct proc; + struct credbatch { struct ucred *cred; - int users; - int ref; + u_int users; + long ref; }; static inline void @@ -146,9 +236,9 @@ void crcopy(struct ucred *dest, struct ucred *src); struct ucred *crcopysafe(struct proc *p, struct ucred *cr); struct ucred *crdup(struct ucred *cr); void crextend(struct ucred *cr, int n); -void proc_set_cred_init(struct proc *p, struct ucred *cr); -void proc_set_cred(struct proc *p, struct ucred *cr); -void proc_unset_cred(struct proc *p); +void proc_set_cred(struct proc *p, struct ucred *newcred); +bool proc_set_cred_enforce_proc_lim(struct proc *p, struct ucred *newcred); +void proc_unset_cred(struct proc *p, bool decrement_proc_count); void crfree(struct ucred *cr); struct ucred *crcowsync(void); struct ucred *crget(void); @@ -157,9 +247,30 @@ struct ucred *crcowget(struct ucred *cr); void crcowfree(struct thread *td); void cru2x(struct ucred *cr, struct xucred *xcr); void cru2xt(struct thread *td, struct xucred *xcr); -void crsetgroups(struct ucred *cr, int n, gid_t *groups); -bool groupmember(gid_t gid, struct ucred *cred); -bool realgroupmember(gid_t gid, struct ucred *cred); +void crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups); +void crsetgroups_and_egid(struct ucred *cr, int ngrp, const gid_t *groups, + const gid_t default_egid); +bool cr_xids_subset(struct ucred *active_cred, struct ucred *obj_cred); + +/* + * Returns whether gid designates a primary group in cred. + */ +static inline bool +group_is_primary(const gid_t gid, const struct ucred *const cred) +{ + return (gid == cred->cr_groups[0] || gid == cred->cr_rgid || + gid == cred->cr_svgid); +} +bool group_is_supplementary(const gid_t gid, const struct ucred *const cred); +bool groupmember(gid_t gid, const struct ucred *cred); +bool realgroupmember(gid_t gid, const struct ucred *cred); + +#else /* !_KERNEL */ + +__BEGIN_DECLS +int setcred(u_int flags, const struct setcred *wcred, size_t size); +__END_DECLS + #endif /* _KERNEL */ #endif /* !_SYS_UCRED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/sys/uio.h b/lib/libc/include/generic-freebsd/sys/uio.h index 59a7f55e5469cb16fa5d109190818ec421f21859..067f9df3c517ba3b3124633d5c5f4d000df14b81 100644 --- a/lib/libc/include/generic-freebsd/sys/uio.h +++ b/lib/libc/include/generic-freebsd/sys/uio.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)uio.h 8.5 (Berkeley) 2/22/94 */ #ifndef _SYS_UIO_H_ @@ -86,12 +84,14 @@ int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop); int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); +void exterr_copyout(struct thread *td); int physcopyin(void *src, vm_paddr_t dst, size_t len); int physcopyout(vm_paddr_t src, void *dst, size_t len); int physcopyin_vlist(struct bus_dma_segment *src, off_t offset, vm_paddr_t dst, size_t len); int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst, off_t offset, size_t len); +void uioadvance(struct uio *, size_t); int uiomove(void *cp, int n, struct uio *uio); int uiomove_frombuf(void *buf, int buflen, struct uio *uio); int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, @@ -101,6 +101,10 @@ int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio); #else /* !_KERNEL */ +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS ssize_t readv(int, const struct iovec *, int); ssize_t writev(int, const struct iovec *, int); diff --git a/lib/libc/include/generic-freebsd/sys/umtx.h b/lib/libc/include/generic-freebsd/sys/umtx.h index 79c6d23fb389381f18ae58f0c2fea52c3347e881..a600c818df870a895b5dcb33e8ed52a4e22daafa 100644 --- a/lib/libc/include/generic-freebsd/sys/umtx.h +++ b/lib/libc/include/generic-freebsd/sys/umtx.h @@ -135,6 +135,7 @@ struct umtx_robust_lists_params { __BEGIN_DECLS int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2); +int _umtx_op_err(void *obj, int op, u_long val, void *uaddr, void *uaddr2); __END_DECLS diff --git a/lib/libc/include/generic-freebsd/sys/umtxvar.h b/lib/libc/include/generic-freebsd/sys/umtxvar.h index 988eea573eb558cf88676a6567ae873e52860af1..e9309af6a5232b1043079cf8295021305c3c5d1a 100644 --- a/lib/libc/include/generic-freebsd/sys/umtxvar.h +++ b/lib/libc/include/generic-freebsd/sys/umtxvar.h @@ -206,6 +206,7 @@ int umtx_key_get(const void *, int, int, struct umtx_key *); void umtx_key_release(struct umtx_key *); struct umtx_q *umtxq_alloc(void); void umtxq_busy(struct umtx_key *); +void umtxq_busy_unlocked(struct umtx_key *); int umtxq_count(struct umtx_key *); void umtxq_free(struct umtx_q *); struct umtxq_chain *umtxq_getchain(struct umtx_key *); diff --git a/lib/libc/include/generic-freebsd/sys/un.h b/lib/libc/include/generic-freebsd/sys/un.h index 5152ce620b28323574f965856b42588507ab3585..ce3c1c821776612ffd20ba346bd04fec1c00ef75 100644 --- a/lib/libc/include/generic-freebsd/sys/un.h +++ b/lib/libc/include/generic-freebsd/sys/un.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)un.h 8.3 (Berkeley) 2/19/95 */ #ifndef _SYS_UN_H_ @@ -67,7 +65,6 @@ struct sockaddr_un { #define LOCAL_PEERCRED 1 /* retrieve peer credentials */ #define LOCAL_CREDS 2 /* pass credentials to receiver */ #define LOCAL_CREDS_PERSISTENT 3 /* pass credentials to receiver */ -#define LOCAL_CONNWAIT 4 /* connects block until accepted */ /* Start of reserved space for third-party socket options. */ #define LOCAL_VENDOR SO_VENDOR diff --git a/lib/libc/include/generic-freebsd/sys/unistd.h b/lib/libc/include/generic-freebsd/sys/unistd.h index 5bc91c8d218f9bcf952c34faa0c57d569e1819fe..2a779bc4e799f7ed9d06c346a273a791f0f276c2 100644 --- a/lib/libc/include/generic-freebsd/sys/unistd.h +++ b/lib/libc/include/generic-freebsd/sys/unistd.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)unistd.h 8.2 (Berkeley) 1/7/94 */ #ifndef _SYS_UNISTD_H_ @@ -95,7 +93,7 @@ #endif /* Define the POSIX.1 version we target for compliance. */ -#define _POSIX_VERSION 200112L +#define _POSIX_VERSION 200809L /* access function */ #define F_OK 0 /* test for existence of file */ @@ -156,6 +154,12 @@ #define _PC_MAC_PRESENT 63 #define _PC_ACL_NFS4 64 #define _PC_DEALLOC_PRESENT 65 +#define _PC_NAMEDATTR_ENABLED 66 +#define _PC_HAS_NAMEDATTR 67 +#define _PC_XATTR_ENABLED _PC_NAMEDATTR_ENABLED /* Solaris Compatible */ +#define _PC_XATTR_EXISTS _PC_HAS_NAMEDATTR /* Solaris Compatible */ +#define _PC_HAS_HIDDENSYSTEM 68 +#define _PC_CLONE_BLKSIZE 69 #endif /* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */ @@ -210,6 +214,16 @@ * close_range() options. */ #define CLOSE_RANGE_CLOEXEC (1<<2) +#define CLOSE_RANGE_CLOFORK (1<<3) + +/* + * copy_file_range flags visible to user space. + * High order 8 bits reserved for kernel flags. + * Allocate from bit 23 down, to try and avoid conflicts with + * future Linux flags. + */ +#define COPY_FILE_RANGE_CLONE 0x00800000 /* Require cloning. */ +#define COPY_FILE_RANGE_USERFLAGS (COPY_FILE_RANGE_CLONE) #endif /* __BSD_VISIBLE */ diff --git a/lib/libc/include/generic-freebsd/sys/unpcb.h b/lib/libc/include/generic-freebsd/sys/unpcb.h index 74765ae1789f32f816deb304bd2d3e102d38b04b..762a3d907107bbaee47bfbd3896cdfbb4fdca709 100644 --- a/lib/libc/include/generic-freebsd/sys/unpcb.h +++ b/lib/libc/include/generic-freebsd/sys/unpcb.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)unpcb.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_UNPCB_H_ @@ -95,6 +93,7 @@ struct unpcb { u_int unp_msgcount; /* (g) references from message queue */ u_int unp_gcrefs; /* (g) garbage collector refcount */ ino_t unp_ino; /* (g) fake inode number */ + mode_t unp_mode; /* (g) initial pre-bind() mode */ LIST_ENTRY(unpcb) unp_dead; /* (g) link in dead list */ } __aligned(CACHE_LINE_SIZE); @@ -109,8 +108,6 @@ struct unpcb { #define UNP_HAVEPC 0x001 #define UNP_WANTCRED_ALWAYS 0x002 /* credentials wanted always */ #define UNP_WANTCRED_ONESHOT 0x004 /* credentials wanted once */ -#define UNP_CONNWAIT 0x008 /* connect blocks until accepted */ - #define UNP_WANTCRED_MASK (UNP_WANTCRED_ONESHOT | UNP_WANTCRED_ALWAYS) /* diff --git a/lib/libc/include/generic-freebsd/sys/user.h b/lib/libc/include/generic-freebsd/sys/user.h index 907fc51af04e64b55a646f4dce0e98d07efdbe7b..1ac68ffa9ed023885bc78e3667625a496c88b172 100644 --- a/lib/libc/include/generic-freebsd/sys/user.h +++ b/lib/libc/include/generic-freebsd/sys/user.h @@ -29,8 +29,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)user.h 8.2 (Berkeley) 9/23/93 */ #ifndef _SYS_USER_H_ @@ -40,6 +38,7 @@ #ifndef _KERNEL /* stuff that *used* to be included by user.h, or is now needed */ #include +#include #include #include #include @@ -87,7 +86,7 @@ */ #define KI_NSPARE_INT 2 #define KI_NSPARE_LONG 12 -#define KI_NSPARE_PTR 5 +#define KI_NSPARE_PTR 4 #ifndef _KERNEL #ifndef KINFO_PROC_SIZE @@ -213,6 +212,7 @@ struct kinfo_proc { * That way the spare room from both arrays will remain contiguous. */ struct pwddesc *ki_pd; /* pointer to process paths info */ + void *ki_uerrmsg; /* address of the ext err msg place */ void *ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ long ki_sparelongs[KI_NSPARE_LONG]; /* spare room for growth */ long ki_sflag; /* PS_* flags */ @@ -227,7 +227,7 @@ void fill_kinfo_proc(struct proc *, struct kinfo_proc *); * Legacy PS_ flag. This moved to p_flag but is maintained for * compatibility. */ -#define PS_INMEM 0x00001 /* Loaded into memory. */ +#define PS_INMEM 0x00001 /* Loaded into memory, always true. */ /* ki_sessflag values */ #define KI_CTTY 0x00000001 /* controlling tty vnode active */ @@ -265,6 +265,8 @@ struct user { #define KF_TYPE_DEV 12 #define KF_TYPE_EVENTFD 13 #define KF_TYPE_TIMERFD 14 +#define KF_TYPE_INOTIFY 15 +#define KF_TYPE_JAILDESC 16 #define KF_TYPE_UNKNOWN 255 #define KF_VTYPE_VNON 0 @@ -373,7 +375,7 @@ struct kinfo_file { struct sockaddr_storage kf_sa_peer; /* Address of so_pcb. */ uint64_t kf_sock_pcb; - /* Address of inp_ppcb. */ + /* Obsolete! May be reused as a spare. */ uint64_t kf_sock_inpcb; /* Address of unp_conn. */ uint64_t kf_sock_unpconn; @@ -451,11 +453,18 @@ struct kinfo_file { uint32_t kf_timerfd_flags; uint64_t kf_timerfd_addr; } kf_timerfd; + struct { + int32_t kf_jid; + } kf_jail; struct { uint64_t kf_kqueue_addr; int32_t kf_kqueue_count; int32_t kf_kqueue_state; } kf_kqueue; + struct { + uint64_t kf_inotify_npending; + uint64_t kf_inotify_nbpending; + } kf_inotify; } kf_un; }; uint16_t kf_status; /* Status flags. */ @@ -608,7 +617,8 @@ struct kinfo_vmobject { } kvo_type_spec; /* Type-specific union */ uint64_t kvo_me; /* Uniq handle for anon obj */ uint64_t kvo_laundry; /* Number of laundry pages. */ - uint64_t _kvo_qspare[5]; + uint64_t kvo_wired; /* Number of wired pages. */ + uint64_t _kvo_qspare[4]; uint32_t kvo_swapped; /* Number of swapped pages */ uint32_t kvo_flags; uint32_t _kvo_ispare[6]; @@ -625,7 +635,7 @@ struct kinfo_vmobject { #define KKST_MAXLEN 1024 #define KKST_STATE_STACKOK 0 /* Stack is valid. */ -#define KKST_STATE_SWAPPED 1 /* Stack swapped out. */ +#define KKST_STATE_SWAPPED 1 /* Stack swapped out, obsolete. */ #define KKST_STATE_RUNNING 2 /* Stack ephemeral. */ #if defined(__amd64__) || defined(__i386__) @@ -667,6 +677,35 @@ struct kinfo_vm_layout { uintptr_t kvm_spare[12]; }; +#define KNOTE_STATUS_ACTIVE 0x00000001 +#define KNOTE_STATUS_QUEUED 0x00000002 +#define KNOTE_STATUS_DISABLED 0x00000004 +#define KNOTE_STATUS_DETACHED 0x00000008 +#define KNOTE_STATUS_KQUEUE 0x00000010 + +#define KNOTE_EXTDATA_NONE 0 +#define KNOTE_EXTDATA_VNODE 1 +#define KNOTE_EXTDATA_PIPE 2 + +struct kinfo_knote { + int knt_kq_fd; + struct kevent knt_event; + int knt_status; + int knt_extdata; + uint64_t knt_spare0[4]; + union { + struct { + int knt_vnode_type; + uint64_t knt_vnode_fsid; + uint64_t knt_vnode_fileid; + char knt_vnode_fullpath[PATH_MAX]; + } knt_vnode; + struct { + ino_t knt_pipe_ino; + } knt_pipe; + }; +}; + #ifdef _KERNEL /* Flags for kern_proc_out function. */ #define KERN_PROC_NOTHREADS 0x1 @@ -694,6 +733,8 @@ int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen); int kern_proc_out(struct proc *p, struct sbuf *sb, int flags); int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags); +int kern_proc_kqueues_out(struct proc *p, struct sbuf *s, size_t maxlen, + bool compat32); int vntype_to_kinfo(int vtype); void pack_kinfo(struct kinfo_file *kif); diff --git a/lib/libc/include/generic-freebsd/sys/utsname.h b/lib/libc/include/generic-freebsd/sys/utsname.h index 0ee5f2995ec894d6d62c8b4dee918ce1288d44f7..e664a20255b8d6c7af8bf8279a0b5bf3f037ace3 100644 --- a/lib/libc/include/generic-freebsd/sys/utsname.h +++ b/lib/libc/include/generic-freebsd/sys/utsname.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)utsname.h 8.1 (Berkeley) 1/4/94 */ #ifndef _SYS_UTSNAME_H diff --git a/lib/libc/include/generic-freebsd/sys/vmmeter.h b/lib/libc/include/generic-freebsd/sys/vmmeter.h index b595f831336ce7eedc5f77c3e4bdb83dddc8107c..8d941f4a694c03c12480df2e759250f6cf10b4ed 100644 --- a/lib/libc/include/generic-freebsd/sys/vmmeter.h +++ b/lib/libc/include/generic-freebsd/sys/vmmeter.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_VMMETER_H_ @@ -122,6 +120,7 @@ struct vmmeter { counter_u64_t v_rforkpages; /* (p) pages affected by rfork() */ counter_u64_t v_kthreadpages; /* (p) ... and by kernel fork() */ counter_u64_t v_wire_count; /* (p) pages wired down */ + counter_u64_t v_nofree_count; /* (p) permanently allocated pages */ #define VM_METER_NCOUNTERS \ (offsetof(struct vmmeter, v_page_size) / sizeof(counter_u64_t)) /* @@ -176,6 +175,13 @@ vm_wire_count(void) return (VM_CNT_FETCH(v_wire_count)); } +static inline u_int +vm_nofree_count(void) +{ + + return (VM_CNT_FETCH(v_nofree_count)); +} + /* * Return TRUE if we are under our severe low-free-pages threshold * diff --git a/lib/libc/include/generic-freebsd/sys/vnode.h b/lib/libc/include/generic-freebsd/sys/vnode.h index 24a035d47e65da58542521b591ea3c54cd6c6004..ff75d451301e99cacf88154bc59e4f7cd9e017a2 100644 --- a/lib/libc/include/generic-freebsd/sys/vnode.h +++ b/lib/libc/include/generic-freebsd/sys/vnode.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)vnode.h 8.7 (Berkeley) 2/4/94 */ #ifndef _SYS_VNODE_H_ @@ -69,6 +67,11 @@ __enum_uint8_decl(vtype) { VLASTTYPE = VMARKER, }; +/* + * We frequently need to test is something is a device node. + */ +#define VTYPE_ISDEV(vtype) ((vtype) == VCHR || (vtype) == VBLK) + __enum_uint8_decl(vstate) { VSTATE_UNINITIALIZED, VSTATE_CONSTRUCTED, @@ -88,11 +91,13 @@ enum vgetstate { * it from v_data. If non-null, this area is freed in getnewvnode(). */ -struct namecache; struct cache_fpl; +struct inotify_watch; +struct namecache; struct vpollinfo { struct mtx vpi_lock; /* lock to protect below */ + TAILQ_HEAD(, inotify_watch) vpi_inotify; /* list of inotify watchers */ struct selinfo vpi_selinfo; /* identity of poller(s) */ short vpi_events; /* what they are looking for */ short vpi_revents; /* what has happened */ @@ -134,7 +139,7 @@ struct vnode { seqc_t v_seqc; /* i modification count */ uint32_t v_nchash; /* u namecache hash */ u_int v_hash; - struct vop_vector *v_op; /* u vnode operations vector */ + const struct vop_vector *v_op; /* u vnode operations vector */ void *v_data; /* u private data for fs */ /* @@ -199,6 +204,8 @@ struct vnode { int v_seqc_users; /* i modifications pending */ }; +#define VN_ISDEV(vp) VTYPE_ISDEV((vp)->v_type) + #ifndef DEBUG_LOCKS #ifdef _LP64 /* @@ -248,6 +255,11 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); #define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */ #define VIRF_TEXT_REF 0x0008 /* Executable mappings ref the vnode */ #define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */ +#define VIRF_NAMEDDIR 0x0020 /* Named attribute directory */ +#define VIRF_NAMEDATTR 0x0040 /* Named attribute */ +#define VIRF_INOTIFY 0x0080 /* This vnode is being watched */ +#define VIRF_INOTIFY_PARENT 0x0100 /* A parent of this vnode may be being + watched */ #define VI_UNUSED0 0x0001 /* unused */ #define VI_MOUNT 0x0002 /* Mount in progress */ @@ -283,7 +295,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); struct vattr { __enum_uint8(vtype) va_type; /* vnode type (for create) */ u_short va_mode; /* files access mode and type */ - u_short va_padding0; + uint16_t va_bsdflags; /* same as st_bsdflags from stat(2) */ uid_t va_uid; /* owner user id */ gid_t va_gid; /* owner group id */ nlink_t va_nlink; /* number of references to file */ @@ -304,6 +316,8 @@ struct vattr { long va_spare; /* remain quad aligned */ }; +#define VATTR_ISDEV(vap) VTYPE_ISDEV((vap)->va_type) + /* * Flags for va_vaflags. */ @@ -533,7 +547,7 @@ extern struct vnodeop_desc *vnodeop_descs[]; #define VOPARG_OFFSETTO(s_type, s_offset, struct_p) \ ((s_type)(((char*)(struct_p)) + (s_offset))) -#ifdef DEBUG_VFS_LOCKS +#ifdef INVARIANTS /* * Support code to aid in debugging VFS locking problems. Not totally * reliable since if the thread sleeps between changing the lock @@ -567,7 +581,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str); VNPASS(!seqc_in_modify(_vp->v_seqc), _vp); \ } while (0) -#else /* !DEBUG_VFS_LOCKS */ +#else /* !INVARIANTS */ #define ASSERT_VI_LOCKED(vp, str) ((void)0) #define ASSERT_VI_UNLOCKED(vp, str) ((void)0) @@ -578,7 +592,7 @@ void assert_vop_unlocked(struct vnode *vp, const char *str); #define ASSERT_VOP_IN_SEQC(vp) ((void)0) #define ASSERT_VOP_NOT_IN_SEQC(vp) ((void)0) -#endif /* DEBUG_VFS_LOCKS */ +#endif /* INVARIANTS */ /* * This call works for vnodes in the kernel. @@ -667,6 +681,7 @@ char *cache_symlink_alloc(size_t size, int flags); void cache_symlink_free(char *string, size_t size); int cache_symlink_resolve(struct cache_fpl *fpl, const char *string, size_t len); +void cache_vop_inotify(struct vnode *vp, int event, uint32_t cookie); void cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, struct vnode *tvp, struct componentname *fcnp, struct componentname *tcnp); void cache_vop_rmdir(struct vnode *dvp, struct vnode *vp); @@ -708,6 +723,7 @@ int speedup_syncer(void); int vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen); int vn_getcwd(char *buf, char **retbuf, size_t *buflen); int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf); +int vn_fullpath_jail(struct vnode *vp, char **retbuf, char **freebuf); int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf); int vn_fullpath_hardlink(struct vnode *vp, struct vnode *dvp, const char *hdrl_name, size_t hrdl_name_length, char **retbuf, @@ -836,18 +852,15 @@ void vn_seqc_write_end(struct vnode *vp); #define vn_seqc_consistent(vp, seq) seqc_consistent(&(vp)->v_seqc, seq) #define vn_rangelock_unlock(vp, cookie) \ - rangelock_unlock(&(vp)->v_rl, (cookie), VI_MTX(vp)) -#define vn_rangelock_unlock_range(vp, cookie, start, end) \ - rangelock_unlock_range(&(vp)->v_rl, (cookie), (start), (end), \ - VI_MTX(vp)) + rangelock_unlock(&(vp)->v_rl, (cookie)) #define vn_rangelock_rlock(vp, start, end) \ - rangelock_rlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) + rangelock_rlock(&(vp)->v_rl, (start), (end)) #define vn_rangelock_tryrlock(vp, start, end) \ - rangelock_tryrlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) + rangelock_tryrlock(&(vp)->v_rl, (start), (end)) #define vn_rangelock_wlock(vp, start, end) \ - rangelock_wlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) + rangelock_wlock(&(vp)->v_rl, (start), (end)) #define vn_rangelock_trywlock(vp, start, end) \ - rangelock_trywlock(&(vp)->v_rl, (start), (end), VI_MTX(vp)) + rangelock_trywlock(&(vp)->v_rl, (start), (end)) #define vn_irflag_read(vp) atomic_load_short(&(vp)->v_irflag) void vn_irflag_set_locked(struct vnode *vp, short toset); @@ -872,8 +885,10 @@ int vop_stdfsync(struct vop_fsync_args *); int vop_stdgetwritemount(struct vop_getwritemount_args *); int vop_stdgetpages(struct vop_getpages_args *); int vop_stdinactive(struct vop_inactive_args *); -int vop_stdioctl(struct vop_ioctl_args *); int vop_stdneed_inactive(struct vop_need_inactive_args *); +int vop_stdinotify(struct vop_inotify_args *); +int vop_stdinotify_add_watch(struct vop_inotify_add_watch_args *); +int vop_stdioctl(struct vop_ioctl_args *); int vop_stdkqfilter(struct vop_kqfilter_args *); int vop_stdlock(struct vop_lock1_args *); int vop_stdunlock(struct vop_unlock_args *); @@ -913,9 +928,12 @@ int dead_read(struct vop_read_args *ap); int dead_write(struct vop_write_args *ap); /* These are called from within the actual VOPS. */ +void vop_allocate_post(void *a, int rc); +void vop_copy_file_range_post(void *ap, int rc); void vop_close_post(void *a, int rc); void vop_create_pre(void *a); void vop_create_post(void *a, int rc); +void vop_deallocate_post(void *a, int rc); void vop_whiteout_pre(void *a); void vop_whiteout_post(void *a, int rc); void vop_deleteextattr_pre(void *a); @@ -931,7 +949,6 @@ void vop_mknod_post(void *a, int rc); void vop_open_post(void *a, int rc); void vop_read_post(void *a, int rc); void vop_read_pgcache_post(void *ap, int rc); -void vop_readdir_post(void *a, int rc); void vop_reclaim_post(void *a, int rc); void vop_remove_pre(void *a); void vop_remove_post(void *a, int rc); @@ -949,7 +966,7 @@ void vop_symlink_pre(void *a); void vop_symlink_post(void *a, int rc); int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a); -#ifdef DEBUG_VFS_LOCKS +#ifdef INVARIANTS void vop_fdatasync_debugpre(void *a); void vop_fdatasync_debugpost(void *a, int rc); void vop_fplookup_vexec_debugpre(void *a); @@ -991,9 +1008,10 @@ void vop_rename_fail(struct vop_rename_args *ap); AUDIT_ARG_VNODE1(ap->a_vp); \ _error = mac_vnode_check_stat(_ap->a_active_cred, _ap->a_file_cred, _ap->a_vp);\ if (__predict_true(_error == 0)) { \ - ap->a_sb->st_padding0 = 0; \ ap->a_sb->st_padding1 = 0; \ bzero(_ap->a_sb->st_spare, sizeof(_ap->a_sb->st_spare)); \ + ap->a_sb->st_filerev = 0; \ + ap->a_sb->st_bsdflags = 0; \ } \ _error; \ }) @@ -1006,7 +1024,36 @@ void vop_rename_fail(struct vop_rename_args *ap); _error; \ }) -#define VOP_WRITE_PRE(ap) \ +#ifdef INVARIANTS +#define vop_readdir_pre_assert(ap) \ + ssize_t nresid, oresid; \ + \ + oresid = (ap)->a_uio->uio_resid; + +#define vop_readdir_post_assert(ap, ret) \ + nresid = (ap)->a_uio->uio_resid; \ + if ((ret) == 0 && (ap)->a_eofflag != NULL) { \ + VNASSERT(oresid == 0 || nresid != oresid || \ + *(ap)->a_eofflag == 1, \ + (ap)->a_vp, ("VOP_READDIR: eofflag not set")); \ + } +#else +#define vop_readdir_pre_assert(ap) +#define vop_readdir_post_assert(ap, ret) +#endif + +#define vop_readdir_pre(ap) do { \ + vop_readdir_pre_assert(ap) + +#define vop_readdir_post(ap, ret) \ + vop_readdir_post_assert(ap, ret); \ + if ((ret) == 0) { \ + VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_READ); \ + INOTIFY((ap)->a_vp, IN_ACCESS); \ + } \ +} while (0) + +#define vop_write_pre(ap) \ struct vattr va; \ int error; \ off_t osize, ooffset, noffset; \ @@ -1020,11 +1067,14 @@ void vop_rename_fail(struct vop_rename_args *ap); osize = (off_t)va.va_size; \ } -#define VOP_WRITE_POST(ap, ret) \ +#define vop_write_post(ap, ret) \ noffset = (ap)->a_uio->uio_offset; \ - if (noffset > ooffset && !VN_KNLIST_EMPTY((ap)->a_vp)) { \ - VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE \ - | (noffset > osize ? NOTE_EXTEND : 0)); \ + if (noffset > ooffset) { \ + if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ + VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \ + (noffset > osize ? NOTE_EXTEND : 0)); \ + } \ + INOTIFY((ap)->a_vp, IN_MODIFY); \ } #define VOP_LOCK(vp, flags) VOP_LOCK1(vp, flags, __FILE__, __LINE__) @@ -1084,7 +1134,14 @@ vrefcnt(struct vnode *vp) vref(vp); \ } while (0) +/* + * The caller doesn't know the file size and vnode_create_vobject() should + * determine the size on its own. + */ +#define VNODE_NO_SIZE ((off_t)-1) + int vnode_create_vobject(struct vnode *vp, off_t size, struct thread *td); +int vnode_create_disk_vobject(struct vnode *vp, off_t size, struct thread *td); void vnode_destroy_vobject(struct vnode *vp); extern struct vop_vector fifo_specops; @@ -1190,6 +1247,7 @@ vn_get_state(struct vnode *vp) #define vfs_smr_exit() smr_exit(VFS_SMR()) #define vfs_smr_synchronize() smr_synchronize(VFS_SMR()) #define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR()) +#define VFS_SMR_ENTERED() SMR_ENTERED(VFS_SMR()) #define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR()) #define VFS_SMR_ASSERT_NOT_ENTERED() SMR_ASSERT_NOT_ENTERED(VFS_SMR()) #define VFS_SMR_ZONE_SET(zone) uma_zone_set_smr((zone), VFS_SMR()) diff --git a/lib/libc/include/generic-freebsd/sys/wait.h b/lib/libc/include/generic-freebsd/sys/wait.h index 631b3ff54fffe2dff406e60c7de6bbbc463454d1..d14631987f8d473f3874987923ba8c7d6114cb7c 100644 --- a/lib/libc/include/generic-freebsd/sys/wait.h +++ b/lib/libc/include/generic-freebsd/sys/wait.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wait.h 8.2 (Berkeley) 7/10/94 */ #ifndef _SYS_WAIT_H_ diff --git a/lib/libc/include/generic-freebsd/sys/watchdog.h b/lib/libc/include/generic-freebsd/sys/watchdog.h index f01a0c4adcaad39a65525d7ec4f72c4b116cb87c..c73be31abf581c297737103a8a0a36940be07980 100644 --- a/lib/libc/include/generic-freebsd/sys/watchdog.h +++ b/lib/libc/include/generic-freebsd/sys/watchdog.h @@ -32,15 +32,16 @@ #define _SYS_WATCHDOG_H #include +#include #define _PATH_WATCHDOG "fido" -#define WDIOCPATPAT _IOW('W', 42, u_int) /* pat the watchdog */ -#define WDIOC_SETTIMEOUT _IOW('W', 43, int) /* set/reset the timer */ -#define WDIOC_GETTIMEOUT _IOR('W', 44, int) /* get total timeout */ -#define WDIOC_GETTIMELEFT _IOR('W', 45, int) /* get time left */ -#define WDIOC_GETPRETIMEOUT _IOR('W', 46, int) /* get the pre-timeout */ -#define WDIOC_SETPRETIMEOUT _IOW('W', 47, int) /* set the pre-timeout */ +#define WDIOC_PATPAT _IOW('W', 52, sbintime_t) /* pat the watchdog */ +#define WDIOC_SETTIMEOUT _IOW('W', 53, sbintime_t) /* set/reset the timer */ +#define WDIOC_GETTIMEOUT _IOR('W', 54, sbintime_t) /* get total timeout */ +#define WDIOC_GETTIMELEFT _IOR('W', 55, sbintime_t) /* get time left */ +#define WDIOC_GETPRETIMEOUT _IOR('W', 56, sbintime_t) /* get the pre-timeout */ +#define WDIOC_SETPRETIMEOUT _IOW('W', 57, sbintime_t) /* set the pre-timeout */ /* set the action when a pre-timeout occurs see: WD_SOFT_* */ #define WDIOC_SETPRETIMEOUTACT _IOW('W', 48, int) @@ -48,6 +49,8 @@ #define WDIOC_SETSOFT _IOW('W', 49, int) #define WDIOC_SETSOFTTIMEOUTACT _IOW('W', 50, int) +#define WDIOC_CONTROL _IOW('W', 51, int) /* configure watchdog */ + #define WD_ACTIVE 0x8000000 /* * Watchdog reset, timeout set to value in WD_INTERVAL field. @@ -93,6 +96,11 @@ #define WD_TO_64SEC 36 #define WD_TO_128SEC 37 +/* Control options for WDIOC_CONTROL */ +#define WD_CTRL_DISABLE 0x00000000 +#define WD_CTRL_ENABLE 0x00000001 +#define WD_CTRL_RESET 0x00000002 + /* action on pre-timeout trigger */ #define WD_SOFT_PANIC 0x01 /* panic */ #define WD_SOFT_DDB 0x02 /* enter debugger */ @@ -105,11 +113,16 @@ #include typedef void (*watchdog_fn)(void *, u_int, int *); +typedef void (*watchdog_sbt_fn)(void *, sbintime_t, sbintime_t *, int *); EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn); +EVENTHANDLER_DECLARE(watchdog_sbt_list, watchdog_sbt_fn); u_int wdog_kern_last_timeout(void); int wdog_kern_pat(u_int utim); +sbintime_t wdog_kern_last_timeout_sbt(void); +int wdog_kern_pat_sbt(sbintime_t utim); +int wdog_control(int ctrl); /* * The following function pointer is used to attach a software watchdog diff --git a/lib/libc/include/generic-freebsd/sysexits.h b/lib/libc/include/generic-freebsd/sysexits.h index 1e5bda73c204a3c5f02ccb9a5146b6e2ca2f2dc6..3fcfe16c5666cb7bd332d9e279868c6e21e88928 100644 --- a/lib/libc/include/generic-freebsd/sysexits.h +++ b/lib/libc/include/generic-freebsd/sysexits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)sysexits.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYSEXITS_H_ diff --git a/lib/libc/include/generic-freebsd/syslog.h b/lib/libc/include/generic-freebsd/syslog.h index b6528a384113a6da21c86d56553cf04bcadae873..3c822d795d52a1c0b8d146703882ffdeacecc56f 100644 --- a/lib/libc/include/generic-freebsd/syslog.h +++ b/lib/libc/include/generic-freebsd/syslog.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)syslog.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SYS_SYSLOG_H_ diff --git a/lib/libc/include/generic-freebsd/tar.h b/lib/libc/include/generic-freebsd/tar.h index b834bf24ddc81101810b24006776400fa494d2c7..14b275e437622445d83a0c0000186bacc9efe535 100644 --- a/lib/libc/include/generic-freebsd/tar.h +++ b/lib/libc/include/generic-freebsd/tar.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tar.h 8.2 (Berkeley) 1/4/94 */ #ifndef _TAR_H diff --git a/lib/libc/include/generic-freebsd/teken/teken.h b/lib/libc/include/generic-freebsd/teken/teken.h deleted file mode 100644 index 8d4d4c14f8d4ab69cf3dbd2d40e0e097fcf59325..0000000000000000000000000000000000000000 --- a/lib/libc/include/generic-freebsd/teken/teken.h +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2008-2009 Ed Schouten - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _TEKEN_H_ -#define _TEKEN_H_ - -#include - -/* - * libteken: terminal emulation library. - * - * This library converts an UTF-8 stream of bytes to terminal drawing - * commands. - */ - -typedef uint32_t teken_char_t; -typedef unsigned short teken_unit_t; -typedef unsigned char teken_format_t; -#define TF_BOLD 0x01 /* Bold character. */ -#define TF_UNDERLINE 0x02 /* Underline character. */ -#define TF_BLINK 0x04 /* Blinking character. */ -#define TF_REVERSE 0x08 /* Reverse rendered character. */ -#define TF_CJK_RIGHT 0x10 /* Right-hand side of CJK character. */ -#define TF_IMAGE 0x20 /* This character space has image. */ -typedef unsigned char teken_color_t; -#define TC_BLACK 0 -#define TC_RED 1 -#define TC_GREEN 2 -#define TC_YELLOW 3 -#define TC_BLUE 4 -#define TC_MAGENTA 5 -#define TC_CYAN 6 -#define TC_WHITE 7 -#define TC_NCOLORS 8 -#define TC_LIGHT 8 /* ORed with the others. */ - -typedef struct { - teken_unit_t tp_row; - teken_unit_t tp_col; -} teken_pos_t; -typedef struct { - teken_pos_t tr_begin; - teken_pos_t tr_end; -} teken_rect_t; -typedef struct { - teken_format_t ta_format; - teken_color_t ta_fgcolor; - teken_color_t ta_bgcolor; -} teken_attr_t; -typedef struct { - teken_unit_t ts_begin; - teken_unit_t ts_end; -} teken_span_t; - -typedef struct __teken teken_t; - -typedef void teken_state_t(teken_t *, teken_char_t); - -/* - * Drawing routines supplied by the user. - */ - -typedef void tf_bell_t(void *); -typedef void tf_cursor_t(void *, const teken_pos_t *); -typedef void tf_putchar_t(void *, const teken_pos_t *, teken_char_t, - const teken_attr_t *); -typedef void tf_fill_t(void *, const teken_rect_t *, teken_char_t, - const teken_attr_t *); -typedef void tf_copy_t(void *, const teken_rect_t *, const teken_pos_t *); -typedef void tf_pre_input_t(void *); -typedef void tf_post_input_t(void *); -typedef void tf_param_t(void *, int, unsigned int); -#define TP_SHOWCURSOR 0 -#define TP_KEYPADAPP 1 -#define TP_AUTOREPEAT 2 -#define TP_SWITCHVT 3 -#define TP_132COLS 4 -#define TP_SETBELLPD 5 -#define TP_SETBELLPD_PITCH(pd) ((pd) >> 16) -#define TP_SETBELLPD_DURATION(pd) ((pd) & 0xffff) -#define TP_MOUSE 6 -#define TP_SETBORDER 7 -#define TP_SETLOCALCURSOR 8 -#define TP_SETGLOBALCURSOR 9 -typedef void tf_respond_t(void *, const void *, size_t); - -typedef struct { - tf_bell_t *tf_bell; - tf_cursor_t *tf_cursor; - tf_putchar_t *tf_putchar; - tf_fill_t *tf_fill; - tf_copy_t *tf_copy; - tf_pre_input_t *tf_pre_input; - tf_post_input_t *tf_post_input; - tf_param_t *tf_param; - tf_respond_t *tf_respond; -} teken_funcs_t; - -typedef teken_char_t teken_scs_t(const teken_t *, teken_char_t); - -/* - * Terminal state. - */ - -struct __teken { - const teken_funcs_t *t_funcs; - void *t_softc; - - teken_state_t *t_nextstate; - unsigned int t_stateflags; - -#define T_NUMSIZE 8 - unsigned int t_nums[T_NUMSIZE]; - unsigned int t_curnum; - - teken_pos_t t_cursor; - teken_attr_t t_curattr; - teken_pos_t t_saved_cursor; - teken_attr_t t_saved_curattr; - - teken_attr_t t_defattr; - teken_pos_t t_winsize; - - /* For DECSTBM. */ - teken_span_t t_scrollreg; - /* For DECOM. */ - teken_span_t t_originreg; - -#define T_NUMCOL 160 - unsigned int t_tabstops[T_NUMCOL / (sizeof(unsigned int) * 8)]; - - unsigned int t_utf8_left; - teken_char_t t_utf8_partial; - teken_char_t t_last; - - unsigned int t_curscs; - teken_scs_t *t_saved_curscs; - teken_scs_t *t_scs[2]; -}; - -/* Initialize teken structure. */ -void teken_init(teken_t *, const teken_funcs_t *, void *); - -/* Deliver character input. */ -void teken_input(teken_t *, const void *, size_t); - -/* Get/set teken attributes. */ -const teken_pos_t *teken_get_cursor(const teken_t *); -const teken_attr_t *teken_get_curattr(const teken_t *); -const teken_attr_t *teken_get_defattr(const teken_t *); -void teken_get_defattr_cons25(const teken_t *, int *, int *); -const teken_pos_t *teken_get_winsize(const teken_t *); -void teken_set_cursor(teken_t *, const teken_pos_t *); -void teken_set_curattr(teken_t *, const teken_attr_t *); -void teken_set_defattr(teken_t *, const teken_attr_t *); -void teken_set_winsize(teken_t *, const teken_pos_t *); -void teken_set_winsize_noreset(teken_t *, const teken_pos_t *); - -/* Key input escape sequences. */ -#define TKEY_UP 0x00 -#define TKEY_DOWN 0x01 -#define TKEY_LEFT 0x02 -#define TKEY_RIGHT 0x03 - -#define TKEY_HOME 0x04 -#define TKEY_END 0x05 -#define TKEY_INSERT 0x06 -#define TKEY_DELETE 0x07 -#define TKEY_PAGE_UP 0x08 -#define TKEY_PAGE_DOWN 0x09 - -#define TKEY_F1 0x0a -#define TKEY_F2 0x0b -#define TKEY_F3 0x0c -#define TKEY_F4 0x0d -#define TKEY_F5 0x0e -#define TKEY_F6 0x0f -#define TKEY_F7 0x10 -#define TKEY_F8 0x11 -#define TKEY_F9 0x12 -#define TKEY_F10 0x13 -#define TKEY_F11 0x14 -#define TKEY_F12 0x15 -const char *teken_get_sequence(const teken_t *, unsigned int); - -/* Legacy features. */ -void teken_set_8bit(teken_t *); -void teken_set_cons25(teken_t *); -void teken_set_cons25keys(teken_t *); - -/* Color conversion. */ -teken_color_t teken_256to16(teken_color_t); -teken_color_t teken_256to8(teken_color_t); - -#endif /* !_TEKEN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/termios.h b/lib/libc/include/generic-freebsd/termios.h index d6f7e9c79d0573f989c4d38ecaf471086356e562..e2dca44b79a4a811fcfa45e4a5e01b03b7570765 100644 --- a/lib/libc/include/generic-freebsd/termios.h +++ b/lib/libc/include/generic-freebsd/termios.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)termios.h 8.3 (Berkeley) 3/28/94 */ #ifndef _TERMIOS_H_ diff --git a/lib/libc/include/generic-freebsd/time.h b/lib/libc/include/generic-freebsd/time.h index 306c85e83285339a560f59db333c93182a2e3807..6e5ec48eabb3a308a55761011a223ae64ce7b40e 100644 --- a/lib/libc/include/generic-freebsd/time.h +++ b/lib/libc/include/generic-freebsd/time.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)time.h 8.3 (Berkeley) 1/21/94 */ /* @@ -157,6 +155,8 @@ int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); #if __POSIX_VISIBLE >= 199506 char *asctime_r(const struct tm *, char *); char *ctime_r(const time_t *, char *); +#endif +#if __POSIX_VISIBLE >= 199506 || __ISO_C_VISIBLE >= 2023 struct tm *gmtime_r(const time_t *, struct tm *); struct tm *localtime_r(const time_t *, struct tm *); #endif @@ -164,15 +164,18 @@ struct tm *localtime_r(const time_t *, struct tm *); #if __XSI_VISIBLE char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict); +extern long timezone; +extern int daylight; #endif #if __BSD_VISIBLE -char *timezone(int, int); /* XXX XSI conflict */ time_t timelocal(struct tm * const); time_t timegm(struct tm * const); int timer_oshandle_np(timer_t timerid); time_t time2posix(time_t t); time_t posix2time(time_t t); +struct tm *offtime(const time_t *, long); +struct tm *offtime_r(const time_t *__restrict, long, struct tm *__restrict); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) diff --git a/lib/libc/include/generic-freebsd/timeconv.h b/lib/libc/include/generic-freebsd/timeconv.h index 2432e7e2829065adb8630923f0a238d9775bc394..1f6a917d73860a5d2c5caed59d267c3cae3e6402 100644 --- a/lib/libc/include/generic-freebsd/timeconv.h +++ b/lib/libc/include/generic-freebsd/timeconv.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)time.h 8.3 (Berkeley) 1/21/94 */ /* diff --git a/lib/libc/include/generic-freebsd/ttyent.h b/lib/libc/include/generic-freebsd/ttyent.h index 95acdcecab93fc3977655f6a44ab51e08364c9a4..652527cf53809c041b41c8a5ba74dc473431cd84 100644 --- a/lib/libc/include/generic-freebsd/ttyent.h +++ b/lib/libc/include/generic-freebsd/ttyent.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TTYENT_H_ diff --git a/lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h b/lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h index a1772d2b5448780c60d280c55ee14901b62b7961..4471cc764712b0445eb02de86d21864d8af19e1a 100644 --- a/lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h +++ b/lib/libc/include/generic-freebsd/ufs/ffs/ffs_extern.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 */ #ifndef _UFS_FFS_EXTERN_H @@ -84,7 +82,8 @@ int ffs_inotovp(struct mount *, ino_t, uint64_t, int, struct vnode **, int); int ffs_isblock(struct fs *, uint8_t *, ufs1_daddr_t); int ffs_isfreeblock(struct fs *, uint8_t *, ufs1_daddr_t); -void ffs_oldfscompat_write(struct fs *, struct ufsmount *); +void ffs_oldfscompat_write(struct fs *); +bool ffs_oldfscompat_inode_read(struct fs *, union dinodep, time_t); int ffs_own_mount(const struct mount *mp); int ffs_sbsearch(void *, struct fs **, int, struct malloc_type *, int (*)(void *, off_t, void **, int)); diff --git a/lib/libc/include/generic-freebsd/ufs/ffs/fs.h b/lib/libc/include/generic-freebsd/ufs/ffs/fs.h index 7384b4288a1f90ee46fad997707c08ad38353f4d..d1cdfe6dfbf81a5acbe752640a8c09ecc9e8496f 100644 --- a/lib/libc/include/generic-freebsd/ufs/ffs/fs.h +++ b/lib/libc/include/generic-freebsd/ufs/ffs/fs.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)fs.h 8.13 (Berkeley) 3/21/95 */ #ifndef _UFS_FFS_FS_H_ @@ -413,7 +411,8 @@ struct fs { int64_t fs_unrefs; /* number of unreferenced inodes */ int64_t fs_providersize; /* size of underlying GEOM provider */ int64_t fs_metaspace; /* size of area reserved for metadata */ - int64_t fs_sparecon64[13]; /* old rotation block list head */ + uint64_t fs_save_maxfilesize; /* save old UFS1 maxfilesize */ + int64_t fs_sparecon64[12]; /* old rotation block list head */ int64_t fs_sblockactualloc; /* byte offset of this superblock */ int64_t fs_sblockloc; /* byte offset of standard superblock */ struct csum_total fs_cstotal; /* (u) cylinder summary information */ @@ -426,7 +425,7 @@ struct fs { uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ uint32_t fs_avgfilesize; /* expected average file size */ uint32_t fs_avgfpdir; /* expected # of files per directory */ - int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ + uint32_t fs_available_spare; /* old scratch space */ ufs_time_t fs_mtime; /* Last mount or fsck time. */ int32_t fs_sujfree; /* SUJ free list */ int32_t fs_sparecon32[21]; /* reserved for future constants */ diff --git a/lib/libc/include/generic-freebsd/ufs/ffs/softdep.h b/lib/libc/include/generic-freebsd/ufs/ffs/softdep.h index 29806182f1c4d87b4478036328ce83eabdac5b56..eb1bed13fcad94782a4a608c1b0fd734d52d4e76 100644 --- a/lib/libc/include/generic-freebsd/ufs/ffs/softdep.h +++ b/lib/libc/include/generic-freebsd/ufs/ffs/softdep.h @@ -36,8 +36,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)softdep.h 9.7 (McKusick) 6/21/00 */ #include diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/dinode.h b/lib/libc/include/generic-freebsd/ufs/ufs/dinode.h index a312361207ea400877665674574589d082aa0ce8..11d3d717d2231b63f5824996dc44364444d43dcd 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/dinode.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/dinode.h @@ -62,8 +62,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dinode.h 8.3 (Berkeley) 1/21/94 */ #ifndef _UFS_UFS_DINODE_H_ @@ -113,12 +111,13 @@ typedef int64_t ufs_time_t; #define IFWHT 0160000 /* Whiteout. */ /* - * A dinode contains all the meta-data associated with a UFS2 file. - * This structure defines the on-disk format of a dinode. Since + * Each UFS filesystem version defines the on-disk format of its dinode. + * + * A UFS2 dinode contains all the meta-data associated with a UFS2 file. + * This structure defines the on-disk format of a UFS2 dinode. Since * this structure describes an on-disk structure, all its fields * are defined by types with precise widths. */ - #define UFS_NXADDR 2 /* External addresses in inode. */ #define UFS_NDADDR 12 /* Direct addresses in inode. */ #define UFS_NIADDR 3 /* Indirect addresses in inode. */ @@ -186,11 +185,11 @@ struct ufs1_dinode { uint32_t di_dirdepth; /* 4: IFDIR: depth from root dir */ }; uint64_t di_size; /* 8: File byte count. */ - int32_t di_atime; /* 16: Last access time. */ + uint32_t di_atime; /* 16: Last access time. */ int32_t di_atimensec; /* 20: Last access time. */ - int32_t di_mtime; /* 24: Last modified time. */ + uint32_t di_mtime; /* 24: Last modified time. */ int32_t di_mtimensec; /* 28: Last modified time. */ - int32_t di_ctime; /* 32: Last inode change time. */ + uint32_t di_ctime; /* 32: Last inode change time. */ int32_t di_ctimensec; /* 36: Last inode change time. */ union { struct { @@ -212,4 +211,17 @@ struct ufs1_dinode { #define UFS_LINK_MAX 65500 /* leave a few spare for special values */ +/* + * These structures hold or reference an on-disk dinode. + */ +union dinode { + struct ufs1_dinode dp1; + struct ufs2_dinode dp2; +}; + +union dinodep { + struct ufs1_dinode *dp1; + struct ufs2_dinode *dp2; +}; + #endif /* _UFS_UFS_DINODE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/dir.h b/lib/libc/include/generic-freebsd/ufs/ufs/dir.h index 9cea53117cddf280c28317ebca4c72ea5d4e39e3..9859593beb783cef77f07aa3ceaf7e6d2b3f7263 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/dir.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/dir.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)dir.h 8.2 (Berkeley) 1/21/94 */ #ifndef _UFS_UFS_DIR_H_ diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/inode.h b/lib/libc/include/generic-freebsd/ufs/ufs/inode.h index d380d95444b5dfb19966e5af54454042ec104d0f..b71f92202940354920600b9952a6eefbab8bfbd1 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/inode.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/inode.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)inode.h 8.9 (Berkeley) 5/14/95 */ #ifndef _UFS_UFS_INODE_H_ @@ -90,10 +88,7 @@ struct inode { /* * The real copy of the on-disk inode. */ - union { - struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */ - struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */ - } dinode_u; + union dinodep i_dp; /* On-disk dinode */ ino_t i_number; /* The identity of the inode. */ uint32_t i_flag; /* flags, see below */ @@ -206,8 +201,8 @@ struct inode { #define i_dirhash i_un.dirhash #define i_snapblklist i_un.snapblklist -#define i_din1 dinode_u.din1 -#define i_din2 dinode_u.din2 +#define i_din1 i_dp.dp1 +#define i_din2 i_dp.dp2 #define ITOUMP(ip) ((ip)->i_ump) #define ITODEV(ip) (ITOUMP(ip)->um_dev) diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/quota.h b/lib/libc/include/generic-freebsd/ufs/ufs/quota.h index 1a8c8f0c74ddc14c76007af37bc4c41b88ba27df..6cb2d099ef1ad9f14e0ca154a279f805f9337779 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/quota.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/quota.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)quota.h 8.3 (Berkeley) 8/19/94 */ #ifndef _UFS_UFS_QUOTA_H_ diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h b/lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h index 5db08e03f44d2bc8f3fb594969a614df3760968a..7578dfff5769056dad913f63a46327e7f6ca8116 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/ufs_extern.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 */ #ifndef _UFS_UFS_EXTERN_H_ @@ -61,15 +59,15 @@ int ufs_bmap_seekdata(struct vnode *, off_t *); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); -int ufs_dirempty(struct inode *, ino_t, struct ucred *); +int ufs_dirempty(struct inode *, ino_t, struct ucred *, int); int ufs_extread(struct vop_read_args *); int ufs_extwrite(struct vop_write_args *); void ufs_makedirentry(struct inode *, struct componentname *, struct direct *); int ufs_direnter(struct vnode *, struct vnode *, struct direct *, struct componentname *, struct buf *); -int ufs_dirremove(struct vnode *, struct inode *, int, int); -int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int); +int ufs_dirremove(struct vnode *, struct inode *, int, bool); +int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, u_int); int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *, ino_t *); int ufs_getlbns(struct vnode *, ufs2_daddr_t, struct indir *, int *); @@ -95,9 +93,9 @@ int softdep_setup_directory_add(struct buf *, struct inode *, off_t, ino_t, struct buf *, int); void softdep_change_directoryentry_offset(struct buf *, struct inode *, caddr_t, caddr_t, caddr_t, int); -void softdep_setup_remove(struct buf *,struct inode *, struct inode *, int); +void softdep_setup_remove(struct buf *,struct inode *, struct inode *, bool); void softdep_setup_directory_change(struct buf *, struct inode *, - struct inode *, ino_t, int); + struct inode *, ino_t, u_int); void softdep_change_linkcnt(struct inode *); int softdep_slowdown(struct vnode *); void softdep_setup_create(struct inode *, struct inode *); diff --git a/lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h b/lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h index 1a5ee2522893a52b2181b7b5700483c4126f608f..ce82fb7ae0f48e0cc614e4553a5b4d4af343f634 100644 --- a/lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h +++ b/lib/libc/include/generic-freebsd/ufs/ufs/ufsmount.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 */ #ifndef _UFS_UFS_UFSMOUNT_H_ @@ -99,8 +97,6 @@ struct ufsmount { uint64_t um_maxsymlinklen; /* (c) max size of short symlink */ struct mtx um_lock; /* (c) Protects ufsmount & fs */ - struct sx um_checkpath_lock; /* (c) Protects ufs_checkpath() - result */ struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */ struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */ struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */ diff --git a/lib/libc/include/generic-freebsd/unistd.h b/lib/libc/include/generic-freebsd/unistd.h index c0d0ccbd25002dee9eec5f417e3ac68b1e4deaf2..ce7dda335d59132524416210fb664511b1cf332a 100644 --- a/lib/libc/include/generic-freebsd/unistd.h +++ b/lib/libc/include/generic-freebsd/unistd.h @@ -27,19 +27,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)unistd.h 8.12 (Berkeley) 4/27/95 */ #ifndef _UNISTD_H_ #define _UNISTD_H_ -#include #include /* XXX adds too much pollution. */ #include #include #include +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + #ifndef _GID_T_DECLARED typedef __gid_t gid_t; #define _GID_T_DECLARED @@ -291,6 +292,11 @@ typedef __useconds_t useconds_t; #define _SC_NPROCESSORS_CONF 57 #define _SC_NPROCESSORS_ONLN 58 #define _SC_CPUSET_SIZE 122 +#define _SC_UEXTERR_MAXLEN 123 /* user */ +#endif + +#if __POSIX_VISIBLE >= 202405 +#define _SC_NSIG 124 #endif /* Extensions found in Solaris and Linux. */ @@ -506,6 +512,7 @@ int exect(const char *, char * const *, char * const *); int execvP(const char *, const char *, char * const *); int execvpe(const char *, char * const *, char * const *); int feature_present(const char *); +int fchroot(int); char *fflagstostr(u_long); int getdomainname(char *, int); int getentropy(void *, size_t); diff --git a/lib/libc/include/generic-freebsd/utime.h b/lib/libc/include/generic-freebsd/utime.h index 7f82ad6e8d59416113952a12631201397ebcc731..95adb12f6ce4aba5df67eefacde043ad3a241143 100644 --- a/lib/libc/include/generic-freebsd/utime.h +++ b/lib/libc/include/generic-freebsd/utime.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)utime.h 8.1 (Berkeley) 6/2/93 */ #ifndef _UTIME_H_ diff --git a/lib/libc/include/generic-freebsd/vm/_vm_radix.h b/lib/libc/include/generic-freebsd/vm/_vm_radix.h index f5930a35dc0bcd886da5aa13eada2731364c6601..fa71e618180eeacf194d7f870e6c7f0a186c0172 100644 --- a/lib/libc/include/generic-freebsd/vm/_vm_radix.h +++ b/lib/libc/include/generic-freebsd/vm/_vm_radix.h @@ -31,16 +31,13 @@ #ifndef __VM_RADIX_H_ #define __VM_RADIX_H_ -/* - * Radix tree node. - */ -struct vm_radix_node; +#include /* - * Radix tree root. + * Radix tree */ struct vm_radix { - struct vm_radix_node *rt_root; + struct pctrie rt_trie; }; #endif /* !__VM_RADIX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/vm/pmap.h b/lib/libc/include/generic-freebsd/vm/pmap.h index 0bb55fe34bb03a0dd29d558fdc9f6811d82c764f..ed1c6e5561745dcd4b08a3951018f60c1477d7df 100644 --- a/lib/libc/include/generic-freebsd/vm/pmap.h +++ b/lib/libc/include/generic-freebsd/vm/pmap.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)pmap.h 8.1 (Berkeley) 6/11/93 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -83,8 +81,8 @@ typedef struct pmap_statistics *pmap_statistics_t; * Each machine-dependent implementation is required to provide: * * vm_memattr_t pmap_page_get_memattr(vm_page_t); - * boolean_t pmap_page_is_mapped(vm_page_t); - * boolean_t pmap_page_is_write_mapped(vm_page_t); + * bool pmap_page_is_mapped(vm_page_t); + * bool pmap_page_is_write_mapped(vm_page_t); * void pmap_page_set_memattr(vm_page_t, vm_memattr_t); */ #include @@ -138,17 +136,17 @@ void pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va); vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot); -void pmap_growkernel(vm_offset_t); +int pmap_growkernel(vm_offset_t); void pmap_init(void); -boolean_t pmap_is_modified(vm_page_t m); -boolean_t pmap_is_prefaultable(pmap_t pmap, vm_offset_t va); -boolean_t pmap_is_referenced(vm_page_t m); -boolean_t pmap_is_valid_memattr(pmap_t, vm_memattr_t); +bool pmap_is_modified(vm_page_t m); +bool pmap_is_prefaultable(pmap_t pmap, vm_offset_t va); +bool pmap_is_referenced(vm_page_t m); +bool pmap_is_valid_memattr(pmap_t, vm_memattr_t); vm_offset_t pmap_map(vm_offset_t *, vm_paddr_t, vm_paddr_t, int); int pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *pap); void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, vm_pindex_t pindex, vm_size_t size); -boolean_t pmap_page_exists_quick(pmap_t pmap, vm_page_t m); +bool pmap_page_exists_quick(pmap_t pmap, vm_page_t m); void pmap_page_init(vm_page_t m); int pmap_page_wired_mappings(vm_page_t m); int pmap_pinit(pmap_t); diff --git a/lib/libc/include/generic-freebsd/vm/swap_pager.h b/lib/libc/include/generic-freebsd/vm/swap_pager.h index 070d50c3a7a859943ed8824f9c6a3449d8856fc8..8a72a964866c972f490301b0cc5da2e155b94c99 100644 --- a/lib/libc/include/generic-freebsd/vm/swap_pager.h +++ b/lib/libc/include/generic-freebsd/vm/swap_pager.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)swap_pager.h 7.1 (Berkeley) 12/5/90 */ #ifndef _VM_SWAP_PAGER_H_ @@ -70,13 +68,16 @@ struct swdevt { #ifdef _KERNEL +extern bool swap_pager_almost_full; extern int swap_pager_avail; extern int nsw_cluster_max; struct xswdev; int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len); void swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int); -vm_pindex_t swap_pager_find_least(vm_object_t object, vm_pindex_t pindex); +bool swap_pager_scan_all_shadowed(vm_object_t object); +vm_pindex_t swap_pager_seek_data(vm_object_t object, vm_pindex_t pindex); +vm_pindex_t swap_pager_seek_hole(vm_object_t object, vm_pindex_t pindex); void swap_pager_freespace(vm_object_t object, vm_pindex_t start, vm_size_t size, vm_size_t *freed); void swap_pager_swap_init(void); diff --git a/lib/libc/include/generic-freebsd/vm/uma.h b/lib/libc/include/generic-freebsd/vm/uma.h index ac67d2924040a21b2e214e773c2cd4ee608071cf..d950d3d3ff6cb34f687b76bd27a611f8eaab89c2 100644 --- a/lib/libc/include/generic-freebsd/vm/uma.h +++ b/lib/libc/include/generic-freebsd/vm/uma.h @@ -252,6 +252,7 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor, #define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ #define UMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */ #define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */ +#define UMA_ZONE_NOTRIM 0x1000 /* Don't trim this zone */ #define UMA_ZONE_CACHESPREAD 0x2000 /* * Spread memory start locations across * all possible cache lines. May diff --git a/lib/libc/include/generic-freebsd/vm/vm.h b/lib/libc/include/generic-freebsd/vm/vm.h index d23d52f033b1f54e9b73342d3e884cdf9501657a..1889a461cb8fb20c2db9a0b6dacda0b4aaebcec3 100644 --- a/lib/libc/include/generic-freebsd/vm/vm.h +++ b/lib/libc/include/generic-freebsd/vm/vm.h @@ -28,10 +28,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)vm.h 8.2 (Berkeley) 12/13/93 - * @(#)vm_prot.h 8.1 (Berkeley) 6/11/93 - * @(#)vm_inherit.h 8.1 (Berkeley) 6/11/93 - * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. * @@ -80,6 +76,7 @@ typedef u_char vm_prot_t; /* protection codes */ #define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */ #define VM_PROT_PRIV_FLAG ((vm_prot_t) 0x10) #define VM_PROT_FAULT_LOOKUP VM_PROT_PRIV_FLAG +#define VM_PROT_NO_PROMOTE VM_PROT_PRIV_FLAG #define VM_PROT_QUICK_NOFAULT VM_PROT_PRIV_FLAG /* same to save bits */ #define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) @@ -158,6 +155,12 @@ struct kva_md_info { #define SWAP_RESERVE_RLIMIT_ON (1 << 1) #define SWAP_RESERVE_ALLOW_NONWIRED (1 << 2) +#ifdef NUMA +#define __numa_used +#else +#define __numa_used __unused +#endif + #ifdef _KERNEL struct ucred; @@ -167,7 +170,6 @@ bool swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred); void swap_reserve_force(vm_ooffset_t incr); void swap_release(vm_ooffset_t decr); void swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred); -void swapper(void); extern struct kva_md_info kmi; #define VA_IS_CLEANMAP(va) \ diff --git a/lib/libc/include/generic-freebsd/vm/vm_domainset.h b/lib/libc/include/generic-freebsd/vm/vm_domainset.h index 38c06b00fa5ac02b0c0af69c767fcf264003edaa..cd03f91eda75f0974c7452f99d1b6f42d4fcc6b0 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_domainset.h +++ b/lib/libc/include/generic-freebsd/vm/vm_domainset.h @@ -28,25 +28,33 @@ #ifndef __VM_DOMAINSET_H__ #define __VM_DOMAINSET_H__ +struct pctrie_iter; + struct vm_domainset_iter { struct domainset *di_domain; unsigned int *di_iter; + /* Initialized from 'di_domain', initial value after reset. */ + domainset_t di_valid_mask; + /* Domains to browse in the current phase. */ + domainset_t di_remain_mask; + /* Domains skipped in phase 1 because under 'v_free_min'. */ + domainset_t di_min_mask; vm_pindex_t di_offset; int di_flags; uint16_t di_policy; - domainid_t di_n; bool di_minskip; }; int vm_domainset_iter_page(struct vm_domainset_iter *, struct vm_object *, - int *); -void vm_domainset_iter_page_init(struct vm_domainset_iter *, + int *, struct pctrie_iter *); +int vm_domainset_iter_page_init(struct vm_domainset_iter *, struct vm_object *, vm_pindex_t, int *, int *); int vm_domainset_iter_policy(struct vm_domainset_iter *, int *); -void vm_domainset_iter_policy_init(struct vm_domainset_iter *, +int vm_domainset_iter_policy_init(struct vm_domainset_iter *, struct domainset *, int *, int *); -void vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *, +int vm_domainset_iter_policy_ref_init(struct vm_domainset_iter *, struct domainset_ref *, int *, int *); +void vm_domainset_iter_ignore(struct vm_domainset_iter *, int); int vm_wait_doms(const domainset_t *, int mflags); diff --git a/lib/libc/include/generic-freebsd/vm/vm_extern.h b/lib/libc/include/generic-freebsd/vm/vm_extern.h index 715f6f88686a7fb71d3dbff7f07c155eec8ce3d8..f548a6337745c80bac5f2de5c8d46fa0ae14b1d1 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_extern.h +++ b/lib/libc/include/generic-freebsd/vm/vm_extern.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94 */ #ifndef _VM_EXTERN_H_ @@ -85,14 +83,16 @@ void kmem_init(vm_offset_t, vm_offset_t); void kmem_init_zero_region(void); void kmeminit(void); -int kernacc(void *, int, int); -int useracc(void *, int, int); +bool kernacc(void *, int, int); +bool useracc(void *, int, int); int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags, vm_page_t *m_hold); void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t, vm_ooffset_t *); int vm_fault_disable_pagefaults(void); void vm_fault_enable_pagefaults(int save); +int vm_fault_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len, + vm_prot_t prot, vm_page_t *ma, int max_count, int *ppages_count); int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len, vm_prot_t prot, vm_page_t *ma, int max_count); int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, @@ -129,8 +129,6 @@ struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset); void vm_imgact_unmap_page(struct sf_buf *sf); void vm_thread_dispose(struct thread *td); int vm_thread_new(struct thread *td, int pages); -void vm_thread_stack_back(struct domainset *ds, vm_offset_t kaddr, - vm_page_t ma[], int npages, int req_class); u_int vm_active_count(void); u_int vm_inactive_count(void); u_int vm_laundry_count(void); diff --git a/lib/libc/include/generic-freebsd/vm/vm_kern.h b/lib/libc/include/generic-freebsd/vm/vm_kern.h index e124ca1f7c4f5254e279b50eae86ccf58f39303f..0162d894eeb5dbe5ba34aebce4e014652c0c35c3 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_kern.h +++ b/lib/libc/include/generic-freebsd/vm/vm_kern.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_kern.h 8.1 (Berkeley) 6/11/93 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -71,13 +69,10 @@ extern struct vm_map exec_map_store; extern struct vm_map pipe_map_store; #define pipe_map (&pipe_map_store) extern struct vmem *kernel_arena; -extern struct vmem *kmem_arena; extern struct vmem *buffer_arena; extern struct vmem *transient_arena; extern struct vmem *memguard_arena; extern u_long vm_kmem_size; extern u_int exec_map_entries; extern u_int exec_map_entry_size; -extern vm_object_t kstack_object; - #endif /* _VM_VM_KERN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/vm/vm_map.h b/lib/libc/include/generic-freebsd/vm/vm_map.h index a188bd2a3471c5aca1a917a3a200ee7b2c66fa77..7fa353f14bbec70c3b479828e35edbb1832bf5b4 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_map.h +++ b/lib/libc/include/generic-freebsd/vm/vm_map.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)vm_map.h 8.9 (Berkeley) 5/17/95 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -77,7 +75,6 @@ * vm_map_entry_t an entry in an address map. */ -typedef u_char vm_flags_t; typedef u_int vm_eflags_t; /* @@ -96,9 +93,9 @@ union vm_map_object { * and user-exported inheritance and protection information. * Also included is control information for virtual copy operations. * - * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_GROWS_DOWN - * or UP), the next_read member is reused as the stack_guard_page - * storage, and offset is the stack protection. + * For stack gap map entries (MAP_ENTRY_GUARD | MAP_ENTRY_STACK_GAP), + * the next_read member is reused as the stack_guard_page storage, and + * offset is the stack protection. */ struct vm_map_entry { struct vm_map_entry *left; /* left child or previous entry */ @@ -141,14 +138,14 @@ struct vm_map_entry { a core */ #define MAP_ENTRY_VN_EXEC 0x00000800 /* text vnode mapping */ #define MAP_ENTRY_GROWS_DOWN 0x00001000 /* top-down stacks */ -#define MAP_ENTRY_GROWS_UP 0x00002000 /* bottom-up stacks */ +#define MAP_ENTRY_UNUSED0 0x00002000 #define MAP_ENTRY_WIRE_SKIPPED 0x00004000 #define MAP_ENTRY_WRITECNT 0x00008000 /* tracked writeable mapping */ #define MAP_ENTRY_GUARD 0x00010000 -#define MAP_ENTRY_STACK_GAP_DN 0x00020000 -#define MAP_ENTRY_STACK_GAP_UP 0x00040000 +#define MAP_ENTRY_STACK_GAP 0x00020000 +#define MAP_ENTRY_UNUSED1 0x00040000 #define MAP_ENTRY_HEADER 0x00080000 #define MAP_ENTRY_SPLIT_BOUNDARY_MASK 0x00300000 @@ -205,14 +202,14 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry) */ struct vm_map { struct vm_map_entry header; /* List of entries */ - struct sx lock; /* Lock for map data */ - struct mtx system_mtx; + union { + struct sx lock; /* Lock for map data */ + struct mtx system_mtx; + }; int nentries; /* Number of entries */ vm_size_t size; /* virtual size */ u_int timestamp; /* Version number */ - u_char needs_wakeup; - u_char system_map; /* (c) Am I a system map? */ - vm_flags_t flags; /* flags for this vm_map */ + u_int flags; /* flags for this vm_map */ vm_map_entry_t root; /* Root of a binary search tree */ pmap_t pmap; /* (c) Physical map */ vm_offset_t anon_loc; @@ -223,16 +220,21 @@ struct vm_map { }; /* - * vm_flags_t values + * vm_map flags values */ -#define MAP_WIREFUTURE 0x01 /* wire all future pages */ -#define MAP_BUSY_WAKEUP 0x02 /* thread(s) waiting on busy state */ -#define MAP_IS_SUB_MAP 0x04 /* has parent */ -#define MAP_ASLR 0x08 /* enabled ASLR */ -#define MAP_ASLR_IGNSTART 0x10 /* ASLR ignores data segment */ -#define MAP_REPLENISH 0x20 /* kmapent zone needs to be refilled */ -#define MAP_WXORX 0x40 /* enforce W^X */ -#define MAP_ASLR_STACK 0x80 /* stack location is randomized */ +#define MAP_WIREFUTURE 0x00000001 /* wire all future pages */ +#define MAP_BUSY_WAKEUP 0x00000002 /* thread(s) waiting on busy + state */ +#define MAP_IS_SUB_MAP 0x00000004 /* has parent */ +#define MAP_ASLR 0x00000008 /* enabled ASLR */ +#define MAP_ASLR_IGNSTART 0x00000010 /* ASLR ignores data segment */ +#define MAP_REPLENISH 0x00000020 /* kmapent zone needs to be + refilled */ +#define MAP_WXORX 0x00000040 /* enforce W^X */ +#define MAP_ASLR_STACK 0x00000080 /* stack location is + randomized */ +#define MAP_NEEDS_WAKEUP 0x40000000 +#define MAP_SYSTEM_MAP 0x80000000 #ifdef _KERNEL #if defined(KLD_MODULE) && !defined(KLD_TIED) @@ -263,7 +265,7 @@ vm_map_pmap(vm_map_t map) } static __inline void -vm_map_modflags(vm_map_t map, vm_flags_t set, vm_flags_t clear) +vm_map_modflags(vm_map_t map, u_int set, u_int clear) { map->flags = (map->flags | set) & ~clear; } @@ -278,6 +280,12 @@ vm_map_range_valid(vm_map_t map, vm_offset_t start, vm_offset_t end) return (true); } +static inline bool +vm_map_is_system(vm_map_t map) +{ + return ((map->flags & MAP_SYSTEM_MAP) != 0); +} + #endif /* KLD_MODULE */ #endif /* _KERNEL */ @@ -378,12 +386,12 @@ long vmspace_resident_count(struct vmspace *vmspace); #define MAP_PREFAULT_MADVISE 0x00000200 /* from (user) madvise request */ #define MAP_WRITECOUNT 0x00000400 #define MAP_REMAP 0x00000800 -#define MAP_STACK_GROWS_DOWN 0x00001000 -#define MAP_STACK_GROWS_UP 0x00002000 +#define MAP_STACK_AREA 0x00001000 +#define MAP_COW_UNUSED0 0x00002000 #define MAP_ACC_CHARGED 0x00004000 #define MAP_ACC_NO_CHARGE 0x00008000 -#define MAP_CREATE_STACK_GAP_UP 0x00010000 -#define MAP_CREATE_STACK_GAP_DN 0x00020000 +#define MAP_COW_UNUSED1 0x00010000 +#define MAP_CREATE_STACK_GAP 0x00020000 #define MAP_VN_EXEC 0x00040000 #define MAP_SPLIT_BOUNDARY_MASK 0x00180000 #define MAP_NO_HINT 0x00200000 @@ -486,6 +494,7 @@ int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t); int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); +void vm_map_init_system(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int); int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, vm_pindex_t *, vm_prot_t *, boolean_t *); diff --git a/lib/libc/include/generic-freebsd/vm/vm_object.h b/lib/libc/include/generic-freebsd/vm/vm_object.h index ddc3b4358e1a34af56248ca0898648d4d12d23d0..d81cd4b0fb309deb54bd463fe08625706193cc19 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_object.h +++ b/lib/libc/include/generic-freebsd/vm/vm_object.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_object.h 8.3 (Berkeley) 1/12/94 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -100,7 +98,6 @@ struct vm_object { TAILQ_ENTRY(vm_object) object_list; /* list of all objects */ LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */ LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */ - struct pglist memq; /* list of resident pages */ struct vm_radix rtree; /* root of the resident page radix trie*/ vm_pindex_t size; /* Object size */ struct domainset_ref domain; /* NUMA policy. */ @@ -206,7 +203,6 @@ struct vm_object { #define OBJ_PAGERPRIV2 0x00008000 /* Pager private */ #define OBJ_SYSVSHM 0x00010000 /* SysV SHM */ #define OBJ_POSIXSHM 0x00020000 /* Posix SHM */ -#define OBJ_CDEVH 0x00040000 /* OBJT_DEVICE handle is cdev */ /* * Helpers to perform conversion between vm_object page indexes and offsets. @@ -379,6 +375,8 @@ void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start, void vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, int options); boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t); +void vm_object_prepare_buf_pages(vm_object_t object, vm_page_t *ma_dst, + int count, int *rbehind, int *rahead, vm_page_t *ma_src); void vm_object_print(long addr, boolean_t have_addr, long count, char *modif); void vm_object_reference (vm_object_t); void vm_object_reference_locked(vm_object_t); diff --git a/lib/libc/include/generic-freebsd/vm/vm_page.h b/lib/libc/include/generic-freebsd/vm/vm_page.h index 5f9d222c0bd33de64757e2c9a78c92662b5d8279..54a32049e2c8c5f509edf492957512d7570aace9 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_page.h +++ b/lib/libc/include/generic-freebsd/vm/vm_page.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -80,10 +78,6 @@ * A radix tree used to quickly * perform object/offset lookups * - * A list of all pages for a given object, - * so they can be quickly deactivated at - * time of deallocation. - * * An ordered list of pages due for pageout. * * In addition, the structure contains the object @@ -235,7 +229,6 @@ struct vm_page { void *zone; } uma; } plinks; - TAILQ_ENTRY(vm_page) listq; /* pages in same object (O) */ vm_object_t object; /* which object am I in (O) */ vm_pindex_t pindex; /* offset into object (O,P) */ vm_paddr_t phys_addr; /* physical address of page (C) */ @@ -343,50 +336,6 @@ SLIST_HEAD(spglist, vm_page); extern vm_page_t bogus_page; #endif /* _KERNEL */ -extern struct mtx_padalign pa_lock[]; - -#if defined(__arm__) -#define PDRSHIFT PDR_SHIFT -#elif !defined(PDRSHIFT) -#define PDRSHIFT 21 -#endif - -#define pa_index(pa) ((pa) >> PDRSHIFT) -#define PA_LOCKPTR(pa) ((struct mtx *)(&pa_lock[pa_index(pa) % PA_LOCK_COUNT])) -#define PA_LOCKOBJPTR(pa) ((struct lock_object *)PA_LOCKPTR((pa))) -#define PA_LOCK(pa) mtx_lock(PA_LOCKPTR(pa)) -#define PA_TRYLOCK(pa) mtx_trylock(PA_LOCKPTR(pa)) -#define PA_UNLOCK(pa) mtx_unlock(PA_LOCKPTR(pa)) -#define PA_UNLOCK_COND(pa) \ - do { \ - if ((pa) != 0) { \ - PA_UNLOCK((pa)); \ - (pa) = 0; \ - } \ - } while (0) - -#define PA_LOCK_ASSERT(pa, a) mtx_assert(PA_LOCKPTR(pa), (a)) - -#if defined(KLD_MODULE) && !defined(KLD_TIED) -#define vm_page_lock(m) vm_page_lock_KBI((m), LOCK_FILE, LOCK_LINE) -#define vm_page_unlock(m) vm_page_unlock_KBI((m), LOCK_FILE, LOCK_LINE) -#define vm_page_trylock(m) vm_page_trylock_KBI((m), LOCK_FILE, LOCK_LINE) -#else /* !KLD_MODULE */ -#define vm_page_lockptr(m) (PA_LOCKPTR(VM_PAGE_TO_PHYS((m)))) -#define vm_page_lock(m) mtx_lock(vm_page_lockptr((m))) -#define vm_page_unlock(m) mtx_unlock(vm_page_lockptr((m))) -#define vm_page_trylock(m) mtx_trylock(vm_page_lockptr((m))) -#endif -#if defined(INVARIANTS) -#define vm_page_assert_locked(m) \ - vm_page_assert_locked_KBI((m), __FILE__, __LINE__) -#define vm_page_lock_assert(m, a) \ - vm_page_lock_assert_KBI((m), (a), __FILE__, __LINE__) -#else -#define vm_page_assert_locked(m) -#define vm_page_lock_assert(m, a) -#endif - /* * The vm_page's aflags are updated using atomic operations. To set or clear * these flags, the functions vm_page_aflag_set() and vm_page_aflag_clear() @@ -459,6 +408,7 @@ extern struct mtx_padalign pa_lock[]; #define PG_ZERO 0x04 /* page is zeroed */ #define PG_MARKER 0x08 /* special queue marker page */ #define PG_NODUMP 0x10 /* don't include this page in a dump */ +#define PG_NOFREE 0x20 /* page should never be freed. */ /* * Misc constants. @@ -472,6 +422,7 @@ extern struct mtx_padalign pa_lock[]; #include #include +struct pctrie_iter; /* * Each pageable resident page falls into one of five lists: @@ -511,13 +462,15 @@ extern long first_page; /* first physical page number */ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); /* - * Page allocation parameters for vm_page for the functions - * vm_page_alloc(), vm_page_grab(), vm_page_alloc_contig() and - * vm_page_alloc_freelist(). Some functions support only a subset - * of the flags, and ignore others, see the flags legend. + * vm_page allocation arguments for the functions vm_page_alloc(), + * vm_page_alloc_contig(), vm_page_alloc_noobj(), vm_page_grab(), and + * vm_page_grab_pages(). Each function supports only a subset of the flags. + * See the flags legend. * - * The meaning of VM_ALLOC_ZERO differs slightly between the vm_page_alloc*() - * and the vm_page_grab*() functions. See these functions for details. + * The meaning of VM_ALLOC_ZERO varies: vm_page_alloc_noobj(), vm_page_grab(), + * and vm_page_grab_pages() guarantee that the returned pages are zeroed; in + * contrast vm_page_alloc() and vm_page_alloc_contig() do not, leaving it to + * the caller to test the page's flags for PG_ZERO. * * Bits 0 - 1 define class. * Bits 2 - 15 dedicated for flags. @@ -525,7 +478,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); * (a) - vm_page_alloc() supports the flag. * (c) - vm_page_alloc_contig() supports the flag. * (g) - vm_page_grab() supports the flag. - * (n) - vm_page_alloc_noobj() and vm_page_alloc_freelist() support the flag. + * (n) - vm_page_alloc_noobj() supports the flag. * (p) - vm_page_grab_pages() supports the flag. * Bits above 15 define the count of additional pages that the caller * intends to allocate. @@ -534,26 +487,26 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); #define VM_ALLOC_INTERRUPT 1 #define VM_ALLOC_SYSTEM 2 #define VM_ALLOC_CLASS_MASK 3 -#define VM_ALLOC_WAITOK 0x0008 /* (acn) Sleep and retry */ -#define VM_ALLOC_WAITFAIL 0x0010 /* (acn) Sleep and return error */ +#define VM_ALLOC_WAITOK 0x0008 /* (gnp) Sleep and retry */ +#define VM_ALLOC_WAITFAIL 0x0010 /* (acgnp) Sleep and return error */ #define VM_ALLOC_WIRED 0x0020 /* (acgnp) Allocate a wired page */ #define VM_ALLOC_ZERO 0x0040 /* (acgnp) Allocate a zeroed page */ #define VM_ALLOC_NORECLAIM 0x0080 /* (c) Do not reclaim after failure */ -#define VM_ALLOC_AVAIL0 0x0100 +#define VM_ALLOC_NOFREE 0x0100 /* (agnp) Page will never be freed */ #define VM_ALLOC_NOBUSY 0x0200 /* (acgp) Do not excl busy the page */ -#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Don't create a page */ +#define VM_ALLOC_NOCREAT 0x0400 /* (gp) Do not allocate a page */ #define VM_ALLOC_AVAIL1 0x0800 -#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy flag */ -#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */ +#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy state */ +#define VM_ALLOC_NODUMP 0x2000 /* (acgnp) Do not include in dump */ #define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */ #define VM_ALLOC_NOWAIT 0x8000 /* (acgnp) Do not sleep */ #define VM_ALLOC_COUNT_MAX 0xffff #define VM_ALLOC_COUNT_SHIFT 16 #define VM_ALLOC_COUNT_MASK (VM_ALLOC_COUNT(VM_ALLOC_COUNT_MAX)) -#define VM_ALLOC_COUNT(count) ({ \ - KASSERT((count) <= VM_ALLOC_COUNT_MAX, \ - ("%s: invalid VM_ALLOC_COUNT value", __func__)); \ - (count) << VM_ALLOC_COUNT_SHIFT; \ +#define VM_ALLOC_COUNT(count) ({ /* (acgn) Additional pages */ \ + KASSERT((count) <= VM_ALLOC_COUNT_MAX, \ + ("%s: invalid VM_ALLOC_COUNT value", __func__)); \ + (count) << VM_ALLOC_COUNT_SHIFT; \ }) #ifdef M_NOWAIT @@ -577,6 +530,8 @@ malloc2vm_flags(int malloc_flags) pflags |= VM_ALLOC_WAITOK; if ((malloc_flags & M_NORECLAIM)) pflags |= VM_ALLOC_NORECLAIM; + if ((malloc_flags & M_NEVERFREED)) + pflags |= VM_ALLOC_NOFREE; return (pflags); } #endif @@ -593,22 +548,9 @@ malloc2vm_flags(int malloc_flags) #define PS_ALL_VALID 0x2 #define PS_NONE_BUSY 0x4 -bool vm_page_busy_acquire(vm_page_t m, int allocflags); -void vm_page_busy_downgrade(vm_page_t m); -int vm_page_busy_tryupgrade(vm_page_t m); -bool vm_page_busy_sleep(vm_page_t m, const char *msg, int allocflags); -void vm_page_busy_sleep_unlocked(vm_object_t obj, vm_page_t m, - vm_pindex_t pindex, const char *wmesg, int allocflags); -void vm_page_free(vm_page_t m); -void vm_page_free_zero(vm_page_t m); - void vm_page_activate (vm_page_t); void vm_page_advise(vm_page_t m, int advice); vm_page_t vm_page_alloc(vm_object_t, vm_pindex_t, int); -vm_page_t vm_page_alloc_domain(vm_object_t, vm_pindex_t, int, int); -vm_page_t vm_page_alloc_after(vm_object_t, vm_pindex_t, int, vm_page_t); -vm_page_t vm_page_alloc_domain_after(vm_object_t, vm_pindex_t, int, int, - vm_page_t); vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr); @@ -616,8 +558,10 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr); -vm_page_t vm_page_alloc_freelist(int, int); -vm_page_t vm_page_alloc_freelist_domain(int, int, int); +vm_page_t vm_page_alloc_domain_iter(vm_object_t object, vm_pindex_t pindex, + int domain, int req, struct pctrie_iter *pages); +vm_page_t vm_page_alloc_iter(vm_object_t object, vm_pindex_t pindex, int req, + struct pctrie_iter *pages); vm_page_t vm_page_alloc_noobj(int); vm_page_t vm_page_alloc_noobj_domain(int, int); vm_page_t vm_page_alloc_noobj_contig(int req, u_long npages, vm_paddr_t low, @@ -628,7 +572,26 @@ vm_page_t vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages, vm_memattr_t memattr); void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set); bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose); +bool vm_page_busy_acquire(vm_page_t m, int allocflags); +void vm_page_busy_downgrade(vm_page_t m); +int vm_page_busy_tryupgrade(vm_page_t m); +bool vm_page_busy_sleep(vm_page_t m, const char *msg, int allocflags); +void vm_page_busy_sleep_unlocked(vm_object_t obj, vm_page_t m, + vm_pindex_t pindex, const char *wmesg, int allocflags); +void vm_page_deactivate(vm_page_t m); +void vm_page_deactivate_noreuse(vm_page_t m); +void vm_page_dequeue(vm_page_t m); +void vm_page_dequeue_deferred(vm_page_t m); +void vm_page_free(vm_page_t m); +void vm_page_free_invalid(vm_page_t m); +int vm_page_free_pages_toq(struct spglist *free, bool update_wire_count); +void vm_page_free_zero(vm_page_t m); +vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr); +int vm_page_grab_zero_partial(vm_object_t object, vm_pindex_t pindex, int base, + int end); vm_page_t vm_page_grab(vm_object_t, vm_pindex_t, int); +vm_page_t vm_page_grab_iter(vm_object_t object, vm_pindex_t pindex, + int allocflags, struct pctrie_iter *pages); vm_page_t vm_page_grab_unlocked(vm_object_t, vm_pindex_t, int); int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags, vm_page_t *ma, int count); @@ -636,37 +599,38 @@ int vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex, int allocflags, vm_page_t *ma, int count); int vm_page_grab_valid(vm_page_t *mp, vm_object_t object, vm_pindex_t pindex, int allocflags); +int vm_page_grab_valid_iter(vm_page_t *mp, vm_object_t object, + vm_pindex_t pindex, int allocflags, struct pctrie_iter *pages); int vm_page_grab_valid_unlocked(vm_page_t *mp, vm_object_t object, vm_pindex_t pindex, int allocflags); -void vm_page_deactivate(vm_page_t); -void vm_page_deactivate_noreuse(vm_page_t); -void vm_page_dequeue(vm_page_t m); -void vm_page_dequeue_deferred(vm_page_t m); -vm_page_t vm_page_find_least(vm_object_t, vm_pindex_t); -void vm_page_free_invalid(vm_page_t); -vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr); void vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr); void vm_page_init_marker(vm_page_t marker, int queue, uint16_t aflags); -void vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind); +void vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind, int pool); int vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t); void vm_page_invalid(vm_page_t m); +void vm_page_iter_free(struct pctrie_iter *pages, vm_page_t m); +void vm_page_iter_init(struct pctrie_iter *, vm_object_t); +int vm_page_iter_insert(vm_page_t m, vm_object_t, vm_pindex_t, + struct pctrie_iter *); +void vm_page_iter_limit_init(struct pctrie_iter *, vm_object_t, vm_pindex_t); +bool vm_page_iter_remove(struct pctrie_iter *pages, vm_page_t m); +bool vm_page_iter_rename(struct pctrie_iter *old_pages, vm_page_t m, + vm_object_t new_object, vm_pindex_t new_pindex); void vm_page_launder(vm_page_t m); vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t); vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t); -vm_page_t vm_page_next(vm_page_t m); void vm_page_pqbatch_drain(void); void vm_page_pqbatch_submit(vm_page_t m, uint8_t queue); bool vm_page_pqstate_commit(vm_page_t m, vm_page_astate_t *old, vm_page_astate_t new); -vm_page_t vm_page_prev(vm_page_t m); -bool vm_page_ps_test(vm_page_t m, int flags, vm_page_t skip_m); +bool vm_page_ps_test(vm_page_t m, int psind, int flags, vm_page_t skip_m); void vm_page_putfake(vm_page_t m); void vm_page_readahead_finish(vm_page_t m); -bool vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low, +int vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary); -bool vm_page_reclaim_contig_domain(int domain, int req, u_long npages, +int vm_page_reclaim_contig_domain(int domain, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary); -bool vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages, +int vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, int desired_runs); void vm_page_reference(vm_page_t m); @@ -677,7 +641,6 @@ void vm_page_release_locked(vm_page_t m, int flags); vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t); bool vm_page_remove(vm_page_t); bool vm_page_remove_xbusy(vm_page_t); -int vm_page_rename(vm_page_t, vm_object_t, vm_pindex_t); void vm_page_replace(vm_page_t mnew, vm_object_t object, vm_pindex_t pindex, vm_page_t mold); int vm_page_sbusied(vm_page_t m); @@ -706,16 +669,8 @@ int vm_page_is_valid(vm_page_t, int, int); void vm_page_test_dirty(vm_page_t); vm_page_bits_t vm_page_bits(int base, int size); void vm_page_zero_invalid(vm_page_t m, boolean_t setvalid); -int vm_page_free_pages_toq(struct spglist *free, bool update_wire_count); void vm_page_dirty_KBI(vm_page_t m); -void vm_page_lock_KBI(vm_page_t m, const char *file, int line); -void vm_page_unlock_KBI(vm_page_t m, const char *file, int line); -int vm_page_trylock_KBI(vm_page_t m, const char *file, int line); -#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) -void vm_page_assert_locked_KBI(vm_page_t m, const char *file, int line); -void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line); -#endif #define vm_page_busy_fetch(m) atomic_load_int(&(m)->busy_lock) @@ -732,9 +687,9 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line); #define vm_page_assert_unbusied(m) \ KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) != \ VPB_CURTHREAD_EXCLUSIVE, \ - ("vm_page_assert_xbusied: page %p busy_lock %#x owned" \ - " by me @ %s:%d", \ - (m), (m)->busy_lock, __FILE__, __LINE__)); \ + ("vm_page_assert_unbusied: page %p busy_lock %#x owned" \ + " by me (%p) @ %s:%d", \ + (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \ #define vm_page_assert_xbusied_unchecked(m) do { \ KASSERT(vm_page_xbusied(m), \ @@ -746,8 +701,8 @@ void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line); KASSERT((vm_page_busy_fetch(m) & ~VPB_BIT_WAITERS) == \ VPB_CURTHREAD_EXCLUSIVE, \ ("vm_page_assert_xbusied: page %p busy_lock %#x not owned" \ - " by me @ %s:%d", \ - (m), (m)->busy_lock, __FILE__, __LINE__)); \ + " by me (%p) @ %s:%d", \ + (m), (m)->busy_lock, curthread, __FILE__, __LINE__)); \ } while (0) #define vm_page_busied(m) \ @@ -1018,7 +973,7 @@ vm_page_none_valid(vm_page_t m) } static inline int -vm_page_domain(vm_page_t m) +vm_page_domain(vm_page_t m __numa_used) { #ifdef NUMA int domn, segind; diff --git a/lib/libc/include/generic-freebsd/vm/vm_pageout.h b/lib/libc/include/generic-freebsd/vm/vm_pageout.h index d353c28d31bea165015aab3aa453dc5bfb126018..6d393195617cd815dad8c232c4f4a61f88a7ed8d 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_pageout.h +++ b/lib/libc/include/generic-freebsd/vm/vm_pageout.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -102,11 +100,8 @@ void vm_wait_domain(int domain); void vm_wait_min(void); void vm_wait_severe(void); -int vm_pageout_flush(vm_page_t *, int, int, int, int *, boolean_t *); +int vm_pageout_flush(vm_page_t *mc, int count, int flags, bool *eio); void vm_pageout_oom(int shortage); -void vm_swapout_run(void); -void vm_swapout_run_idle(void); - #endif /* _KERNEL */ #endif /* _VM_VM_PAGEOUT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/vm/vm_pagequeue.h b/lib/libc/include/generic-freebsd/vm/vm_pagequeue.h index 52a7b1dd39e6d1dec97afcf3f46c9268a2ed778f..2e387212cf6c3d27b052bb94f284f18a921028a6 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_pagequeue.h +++ b/lib/libc/include/generic-freebsd/vm/vm_pagequeue.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_page.h 8.2 (Berkeley) 12/13/93 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -245,23 +243,26 @@ struct vm_domain { } vmd_pgcache[VM_NFREEPOOL]; struct vmem *vmd_kernel_arena; /* (c) per-domain kva R/W arena. */ struct vmem *vmd_kernel_rwx_arena; /* (c) per-domain kva R/W/X arena. */ + struct vmem *vmd_kernel_nofree_arena; /* (c) per-domain kva NOFREE arena. */ u_int vmd_domain; /* (c) Domain number. */ u_int vmd_page_count; /* (c) Total page count. */ long vmd_segs; /* (c) bitmask of the segments */ + struct pglist vmd_nofreeq; /* (f) NOFREE page bump allocator. */ u_int __aligned(CACHE_LINE_SIZE) vmd_free_count; /* (a,f) free page count */ u_int vmd_pageout_deficit; /* (a) Estimated number of pages deficit */ uint8_t vmd_pad[CACHE_LINE_SIZE - (sizeof(u_int) * 2)]; /* Paging control variables, used within single threaded page daemon. */ struct pidctrl vmd_pid; /* Pageout controller. */ - boolean_t vmd_oom; - u_int vmd_inactive_threads; + bool vmd_oom; /* An OOM kill was requested. */ + bool vmd_helper_threads_enabled;/* Use multiple threads to scan. */ + u_int vmd_inactive_threads; /* Number of extra helper threads. */ u_int vmd_inactive_shortage; /* Per-thread shortage. */ blockcount_t vmd_inactive_running; /* Number of inactive threads. */ blockcount_t vmd_inactive_starting; /* Number of threads started. */ - volatile u_int vmd_addl_shortage; /* Shortage accumulator. */ - volatile u_int vmd_inactive_freed; /* Successful inactive frees. */ - volatile u_int vmd_inactive_us; /* Microseconds for above. */ + u_int vmd_addl_shortage; /* (a) Shortage accumulator. */ + u_int vmd_inactive_freed; /* (a) Successful inactive frees. */ + u_int vmd_inactive_us; /* (a) Microseconds for above. */ u_int vmd_inactive_pps; /* Exponential decay frees/second. */ int vmd_oom_seq; int vmd_last_active_scan; @@ -356,6 +357,12 @@ vm_batchqueue_init(struct vm_batchqueue *bq) bq->bq_cnt = 0; } +static inline bool +vm_batchqueue_empty(const struct vm_batchqueue *bq) +{ + return (bq->bq_cnt == 0); +} + static inline int vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m) { diff --git a/lib/libc/include/generic-freebsd/vm/vm_pager.h b/lib/libc/include/generic-freebsd/vm/vm_pager.h index 06eb99fe7d649962680aedc80e54b9b9f10bacb5..84324fb65e2c031d02c75091a769c605d087387e 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_pager.h +++ b/lib/libc/include/generic-freebsd/vm/vm_pager.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)vm_pager.h 8.4 (Berkeley) 1/12/94 */ /* @@ -295,6 +293,7 @@ struct cdev_pager_ops { int (*cdev_pg_ctor)(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred, u_short *color); void (*cdev_pg_dtor)(void *handle); + void (*cdev_pg_path)(void *handle, char *path, size_t len); }; vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp, @@ -302,6 +301,9 @@ vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp, vm_ooffset_t foff, struct ucred *cred); vm_object_t cdev_pager_lookup(void *handle); void cdev_pager_free_page(vm_object_t object, vm_page_t m); +void cdev_mgtdev_pager_free_page(struct pctrie_iter *pages, vm_page_t m); +void cdev_mgtdev_pager_free_pages(vm_object_t object); +void cdev_pager_get_path(vm_object_t object, char *path, size_t sz); struct phys_pager_ops { int (*phys_pg_getpages)(vm_object_t vm_obj, vm_page_t *m, int count, diff --git a/lib/libc/include/generic-freebsd/vm/vm_param.h b/lib/libc/include/generic-freebsd/vm/vm_param.h index a0f6311b4c2171daf328130d1abfee2073f7681f..bc4327fa0eaf33949aaa082f1ad9ec54787fb957 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_param.h +++ b/lib/libc/include/generic-freebsd/vm/vm_param.h @@ -31,8 +31,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)vm_param.h 8.1 (Berkeley) 6/11/93 - * * * Copyright (c) 1987, 1990 Carnegie-Mellon University. * All rights reserved. @@ -114,14 +112,6 @@ struct xswdev { #define KERN_OUT_OF_BOUNDS 9 #define KERN_RESTART 10 -#ifndef PA_LOCK_COUNT -#ifdef SMP -#define PA_LOCK_COUNT 32 -#else -#define PA_LOCK_COUNT 1 -#endif /* !SMP */ -#endif /* !PA_LOCK_COUNT */ - #ifndef KSTACK_MAX_PAGES #define KSTACK_MAX_PAGES 32 #endif diff --git a/lib/libc/include/generic-freebsd/vm/vm_phys.h b/lib/libc/include/generic-freebsd/vm/vm_phys.h index 6e00638d5dbe9a1165ca4547f5c0862ced3f2e7a..a7e1c14c2ad493d8b732e7f1a459dbaf2bd7301f 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_phys.h +++ b/lib/libc/include/generic-freebsd/vm/vm_phys.h @@ -61,25 +61,24 @@ extern int *mem_locality; void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end); vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary); -vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool, - int order); int vm_phys_alloc_npages(int domain, int pool, int npages, vm_page_t ma[]); vm_page_t vm_phys_alloc_pages(int domain, int pool, int order); int vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high); -void vm_phys_enqueue_contig(vm_page_t m, u_long npages); +void vm_phys_enqueue_contig(vm_page_t m, int pool, u_long npages); int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, vm_memattr_t memattr); void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); int vm_phys_find_range(vm_page_t bounds[], int segind, int domain, u_long npages, vm_paddr_t low, vm_paddr_t high); -void vm_phys_free_contig(vm_page_t m, u_long npages); -void vm_phys_free_pages(vm_page_t m, int order); +void vm_phys_free_contig(vm_page_t m, int pool, u_long npages); +void vm_phys_free_pages(vm_page_t m, int pool, int order); void vm_phys_init(void); vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa); +vm_page_t vm_phys_seg_paddr_to_vm_page(struct vm_phys_seg *seg, vm_paddr_t pa); void vm_phys_register_domains(int ndomains, struct mem_affinity *affinity, int *locality); -bool vm_phys_unfree_page(vm_page_t m); +bool vm_phys_unfree_page(vm_paddr_t pa); int vm_phys_mem_affinity(int f, int t); void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end); vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size); @@ -89,7 +88,7 @@ vm_paddr_t vm_phys_avail_size(int i); bool vm_phys_is_dumpable(vm_paddr_t pa); static inline int -vm_phys_domain(vm_paddr_t pa) +vm_phys_domain(vm_paddr_t pa __numa_used) { #ifdef NUMA int i; diff --git a/lib/libc/include/generic-freebsd/vm/vm_radix.h b/lib/libc/include/generic-freebsd/vm/vm_radix.h index e309ca5e5b0a4b1efdaf4b598e39e9668519b754..8f7e7e7ea4d1f512d1d30f6ad69930af0f0c6580 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_radix.h +++ b/lib/libc/include/generic-freebsd/vm/vm_radix.h @@ -34,36 +34,327 @@ #include #ifdef _KERNEL +#include +#include +#include -int vm_radix_insert(struct vm_radix *rtree, vm_page_t page); void vm_radix_wait(void); -vm_page_t vm_radix_lookup(struct vm_radix *rtree, vm_pindex_t index); -vm_page_t vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t index); -vm_page_t vm_radix_lookup_le(struct vm_radix *rtree, vm_pindex_t index); -vm_page_t vm_radix_lookup_unlocked(struct vm_radix *rtree, vm_pindex_t index); -void vm_radix_reclaim_allnodes(struct vm_radix *rtree); -vm_page_t vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index); -vm_page_t vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage); void vm_radix_zinit(void); - -/* - * Each search path in the trie terminates at a leaf, which is a pointer to a - * page marked with a set 1-bit. A leaf may be associated with a null pointer - * to indicate no page there. - */ -#define VM_RADIX_ISLEAF 0x1 -#define VM_RADIX_NULL (struct vm_radix_node *)VM_RADIX_ISLEAF +void *vm_radix_node_alloc(struct pctrie *ptree); +void vm_radix_node_free(struct pctrie *ptree, void *node); +extern smr_t vm_radix_smr; static __inline void vm_radix_init(struct vm_radix *rtree) { - rtree->rt_root = VM_RADIX_NULL; + pctrie_init(&rtree->rt_trie); } static __inline bool vm_radix_is_empty(struct vm_radix *rtree) { - return (rtree->rt_root == VM_RADIX_NULL); + return (pctrie_is_empty(&rtree->rt_trie)); +} + +PCTRIE_DEFINE_SMR(VM_RADIX, vm_page, pindex, vm_radix_node_alloc, + vm_radix_node_free, vm_radix_smr); + +/* + * Inserts the key-value pair into the trie, starting search from root. + * Panics if the key already exists. + */ +static __inline int +vm_radix_insert(struct vm_radix *rtree, vm_page_t page) +{ + return (VM_RADIX_PCTRIE_INSERT(&rtree->rt_trie, page)); +} + +/* + * Inserts the key-value pair into the trie, starting search from iterator. + * Panics if the key already exists. + */ +static __inline int +vm_radix_iter_insert(struct pctrie_iter *pages, vm_page_t page) +{ + return (VM_RADIX_PCTRIE_ITER_INSERT(pages, page)); +} + +/* + * Returns the value stored at the index assuming there is an external lock. + * + * If the index is not present, NULL is returned. + */ +static __inline vm_page_t +vm_radix_lookup(struct vm_radix *rtree, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_LOOKUP(&rtree->rt_trie, index)); +} + +/* + * Returns the value stored at the index without requiring an external lock. + * + * If the index is not present, NULL is returned. + */ +static __inline vm_page_t +vm_radix_lookup_unlocked(struct vm_radix *rtree, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_LOOKUP_UNLOCKED(&rtree->rt_trie, index)); +} + +/* + * Returns the number of contiguous, non-NULL pages read into the ma[] + * array, without requiring an external lock. + */ +static __inline int +vm_radix_lookup_range_unlocked(struct vm_radix *rtree, vm_pindex_t index, + vm_page_t ma[], int count) +{ + return (VM_RADIX_PCTRIE_LOOKUP_RANGE_UNLOCKED(&rtree->rt_trie, index, + ma, count)); +} + +/* + * Returns the number of contiguous, non-NULL pages read into the ma[] + * array, without requiring an external lock. + */ +static __inline int +vm_radix_iter_lookup_range(struct pctrie_iter *pages, vm_pindex_t index, + vm_page_t ma[], int count) +{ + return (VM_RADIX_PCTRIE_ITER_LOOKUP_RANGE(pages, index, ma, count)); +} + +/* + * Initialize an iterator for vm_radix. + */ +static __inline void +vm_radix_iter_init(struct pctrie_iter *pages, struct vm_radix *rtree) +{ + pctrie_iter_init(pages, &rtree->rt_trie); +} + +/* + * Initialize an iterator for vm_radix. + */ +static __inline void +vm_radix_iter_limit_init(struct pctrie_iter *pages, struct vm_radix *rtree, + vm_pindex_t limit) +{ + pctrie_iter_limit_init(pages, &rtree->rt_trie, limit); +} + +/* + * Returns the value stored at the index. + * Requires that access be externally synchronized by a lock. + * + * If the index is not present, NULL is returned. + */ +static __inline vm_page_t +vm_radix_iter_lookup(struct pctrie_iter *pages, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_ITER_LOOKUP(pages, index)); +} + +/* + * Returns the value stored 'stride' steps beyond the current position. + * Requires that access be externally synchronized by a lock. + * + * If the index is not present, NULL is returned. + */ +static __inline vm_page_t +vm_radix_iter_stride(struct pctrie_iter *pages, int stride) +{ + return (VM_RADIX_PCTRIE_ITER_STRIDE(pages, stride)); +} + +/* + * Returns the page with the least pindex that is greater than or equal to the + * specified pindex, or NULL if there are no such pages. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_lookup_ge(struct vm_radix *rtree, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_LOOKUP_GE(&rtree->rt_trie, index)); +} + +/* + * Returns the page with the greatest pindex that is less than or equal to the + * specified pindex, or NULL if there are no such pages. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_lookup_le(struct vm_radix *rtree, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_LOOKUP_LE(&rtree->rt_trie, index)); +} + +/* + * Remove the specified index from the trie, and return the value stored at + * that index. If the index is not present, return NULL. + */ +static __inline vm_page_t +vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_REMOVE_LOOKUP(&rtree->rt_trie, index)); +} + +/* + * Remove the current page from the trie. + */ +static __inline void +vm_radix_iter_remove(struct pctrie_iter *pages) +{ + VM_RADIX_PCTRIE_ITER_REMOVE(pages); +} + +/* + * Reclaim all the interior nodes of the trie, and invoke the callback + * on all the pages, in order. + */ +static __inline void +vm_radix_reclaim_callback(struct vm_radix *rtree, + void (*page_cb)(vm_page_t, void *), void *arg) +{ + VM_RADIX_PCTRIE_RECLAIM_CALLBACK(&rtree->rt_trie, page_cb, arg); +} + +/* + * Initialize an iterator pointing to the page with the least pindex that is + * greater than or equal to the specified pindex, or NULL if there are no such + * pages. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_lookup_ge(struct pctrie_iter *pages, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_ITER_LOOKUP_GE(pages, index)); +} + +/* + * Update the iterator to point to the page with the least pindex that is 'jump' + * or more greater than or equal to the current pindex, or NULL if there are no + * such pages. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_jump(struct pctrie_iter *pages, vm_pindex_t jump) +{ + return (VM_RADIX_PCTRIE_ITER_JUMP_GE(pages, jump)); +} + +/* + * Update the iterator to point to the page with the least pindex that is one or + * more greater than the current pindex, or NULL if there are no such pages. + * Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_step(struct pctrie_iter *pages) +{ + return (VM_RADIX_PCTRIE_ITER_STEP_GE(pages)); +} + +/* + * Iterate over each non-NULL page from page 'start' to the end of the object. + */ +#define VM_RADIX_FOREACH_FROM(m, pages, start) \ + for (m = vm_radix_iter_lookup_ge(pages, start); m != NULL; \ + m = vm_radix_iter_step(pages)) + +/* + * Iterate over each non-NULL page from the beginning to the end of the object. + */ +#define VM_RADIX_FOREACH(m, pages) VM_RADIX_FOREACH_FROM(m, pages, 0) + +/* + * Initialize an iterator pointing to the page with the greatest pindex that is + * less than or equal to the specified pindex, or NULL if there are no such + * pages. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_lookup_le(struct pctrie_iter *pages, vm_pindex_t index) +{ + return (VM_RADIX_PCTRIE_ITER_LOOKUP_LE(pages, index)); +} + +/* + * Initialize an iterator pointing to the page with the greatest pindex that is + * less than to the specified pindex, or NULL if there are no such + * pages. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_lookup_lt(struct pctrie_iter *pages, vm_pindex_t index) +{ + return (index == 0 ? NULL : vm_radix_iter_lookup_le(pages, index - 1)); +} + +/* + * Update the iterator to point to the page with the pindex that is one greater + * than the current pindex, or NULL if there is no such page. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_next(struct pctrie_iter *pages) +{ + return (VM_RADIX_PCTRIE_ITER_NEXT(pages)); +} + +/* + * Iterate over consecutive non-NULL pages from position 'start' to first NULL + * page. + */ +#define VM_RADIX_FORALL_FROM(m, pages, start) \ + for (m = vm_radix_iter_lookup(pages, start); m != NULL; \ + m = vm_radix_iter_next(pages)) + +/* + * Iterate over consecutive non-NULL pages from the beginning to first NULL + * page. + */ +#define VM_RADIX_FORALL(m, pages) VM_RADIX_FORALL_FROM(m, pages, 0) + +/* + * Update the iterator to point to the page with the pindex that is one less + * than the current pindex, or NULL if there is no such page. Return the page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_prev(struct pctrie_iter *pages) +{ + return (VM_RADIX_PCTRIE_ITER_PREV(pages)); +} + +/* + * Return the current page. + * + * Requires that access be externally synchronized by a lock. + */ +static __inline vm_page_t +vm_radix_iter_page(struct pctrie_iter *pages) +{ + return (VM_RADIX_PCTRIE_ITER_VALUE(pages)); +} + +/* + * Replace an existing page in the trie with another one. + * Panics if there is not an old page in the trie at the new page's index. + */ +static __inline vm_page_t +vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage) +{ + return (VM_RADIX_PCTRIE_REPLACE(&rtree->rt_trie, newpage)); } #endif /* _KERNEL */ diff --git a/lib/libc/include/generic-freebsd/vm/vm_reserv.h b/lib/libc/include/generic-freebsd/vm/vm_reserv.h index 271697ea25ff3e2742e1ff3a04ec505c349e3607..52ad7176e075d9792749ec826c66bf47b2dc4f69 100644 --- a/lib/libc/include/generic-freebsd/vm/vm_reserv.h +++ b/lib/libc/include/generic-freebsd/vm/vm_reserv.h @@ -46,15 +46,16 @@ * The following functions are only to be used by the virtual memory system. */ vm_page_t vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, - int domain, int req, vm_page_t mpred, u_long npages, - vm_paddr_t low, vm_paddr_t high, u_long alignment, - vm_paddr_t boundary); + int domain, int req, u_long npages, vm_paddr_t low, + vm_paddr_t high, u_long alignment, vm_paddr_t boundary, + struct pctrie_iter *pages); vm_page_t vm_reserv_alloc_page(vm_object_t object, vm_pindex_t pindex, - int domain, int req, vm_page_t mpred); + int domain, int req, struct pctrie_iter *pages); void vm_reserv_break_all(vm_object_t object); boolean_t vm_reserv_free_page(vm_page_t m); void vm_reserv_init(void); bool vm_reserv_is_page_free(vm_page_t m); +bool vm_reserv_is_populated(vm_page_t m, int npages); int vm_reserv_level(vm_page_t m); int vm_reserv_level_iffullpop(vm_page_t m); vm_page_t vm_reserv_reclaim_contig(int domain, u_long npages, diff --git a/lib/libc/include/generic-freebsd/vm/vnode_pager.h b/lib/libc/include/generic-freebsd/vm/vnode_pager.h index 2decab026850b718432df0a6f17db5e32dbddf6b..188b30ff885ba593e216b07cd777d68aef9d7219 100644 --- a/lib/libc/include/generic-freebsd/vm/vnode_pager.h +++ b/lib/libc/include/generic-freebsd/vm/vnode_pager.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)vnode_pager.h 8.1 (Berkeley) 6/11/93 */ #ifndef _VNODE_PAGER_ diff --git a/lib/libc/include/generic-freebsd/wchar.h b/lib/libc/include/generic-freebsd/wchar.h index 8a49f5419c05b92770f3ee5cc51cab77a53c1798..b4f6504fbd0618b28aafccc85d5027c0679d2e79 100644 --- a/lib/libc/include/generic-freebsd/wchar.h +++ b/lib/libc/include/generic-freebsd/wchar.h @@ -78,7 +78,7 @@ typedef __size_t size_t; #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE #ifndef _VA_LIST_DECLARED -typedef __va_list va_list; +typedef __builtin_va_list va_list; #define _VA_LIST_DECLARED #endif #endif @@ -108,6 +108,14 @@ typedef struct __sFILE FILE; #endif struct tm; +__BEGIN_DECLS +size_t wcslen(const wchar_t *) __pure; +__END_DECLS + +#if !defined(_STANDALONE) && defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#include +#endif + __BEGIN_DECLS wint_t btowc(int); wint_t fgetwc(FILE *); @@ -146,7 +154,6 @@ wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict); size_t wcscspn(const wchar_t *, const wchar_t *) __pure; size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict, const struct tm * __restrict); -size_t wcslen(const wchar_t *) __pure; wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict, size_t); int wcsncmp(const wchar_t *, const wchar_t *, size_t) __pure; diff --git a/lib/libc/include/generic-freebsd/x86/_align.h b/lib/libc/include/generic-freebsd/x86/_align.h index c56e1e6110d2c2caa73793b5054ae2c906887df1..0a06d280b6a4216a54487e29e3f366c1d2fa167f 100644 --- a/lib/libc/include/generic-freebsd/x86/_align.h +++ b/lib/libc/include/generic-freebsd/x86/_align.h @@ -35,8 +35,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _X86_INCLUDE__ALIGN_H_ diff --git a/lib/libc/include/generic-freebsd/x86/_limits.h b/lib/libc/include/generic-freebsd/x86/_limits.h index 5d0cef1a236be8a9c749b65f00374f015f47a865..50ba6e5f48e1d28bfd6ca550f4efce1abec874cb 100644 --- a/lib/libc/include/generic-freebsd/x86/_limits.h +++ b/lib/libc/include/generic-freebsd/x86/_limits.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE__LIMITS_H_ diff --git a/lib/libc/include/generic-freebsd/x86/_types.h b/lib/libc/include/generic-freebsd/x86/_types.h index f6c95d32871c613531ca5a9bb67cf9fdc2a6f4be..40717048332aa2b19f73c823559ab69fbfca5157 100644 --- a/lib/libc/include/generic-freebsd/x86/_types.h +++ b/lib/libc/include/generic-freebsd/x86/_types.h @@ -32,9 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifndef _MACHINE__TYPES_H_ diff --git a/lib/libc/include/generic-freebsd/x86/acpica_machdep.h b/lib/libc/include/generic-freebsd/x86/acpica_machdep.h index 3e7b05a179d9283f437d4da114fde05cbf9374f2..dc3322d42edef30ef4a8064904bcb95a6695989b 100644 --- a/lib/libc/include/generic-freebsd/x86/acpica_machdep.h +++ b/lib/libc/include/generic-freebsd/x86/acpica_machdep.h @@ -84,6 +84,8 @@ void madt_parse_interrupt_values(void *entry, extern int madt_found_sci_override; extern int (*apei_nmi)(void); +void acpi_set_root(vm_paddr_t addr); + #endif /* _KERNEL */ #endif /* __ACPICA_MACHDEP_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/apicreg.h b/lib/libc/include/generic-freebsd/x86/apicreg.h index 7d30918b1dc97e9ba4494faad9bb5838ecf7e314..3d3840f4ef3f71352f3ed8e28d2839c61a894d3c 100644 --- a/lib/libc/include/generic-freebsd/x86/apicreg.h +++ b/lib/libc/include/generic-freebsd/x86/apicreg.h @@ -296,6 +296,8 @@ typedef struct IOAPIC ioapic_t; /* constants relating to APIC ID registers */ #define APIC_ID_MASK 0xff000000 #define APIC_ID_SHIFT 24 +#define APIC_EXT_ID_MASK 0x00fe0000 +#define APIC_EXT_ID_SHIFT 17 #define APIC_ID_CLUSTER 0xf0 #define APIC_ID_CLUSTER_ID 0x0f #define APIC_MAX_CLUSTER 0xe diff --git a/lib/libc/include/generic-freebsd/x86/apicvar.h b/lib/libc/include/generic-freebsd/x86/apicvar.h index 08a5babc6bd5f1f461367507f563f817b4b9ac7c..404cc3da99e15a97618e9456b2a9bcd76705d172 100644 --- a/lib/libc/include/generic-freebsd/x86/apicvar.h +++ b/lib/libc/include/generic-freebsd/x86/apicvar.h @@ -196,19 +196,21 @@ extern int *apic_cpuids; /* Allow to replace the lapic_ipi_vectored implementation. */ extern void (*ipi_vectored)(u_int, int); +typedef struct ioapic *ioapic_drv_t; + void apic_register_enumerator(struct apic_enumerator *enumerator); -void *ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase); -int ioapic_disable_pin(void *cookie, u_int pin); -int ioapic_get_vector(void *cookie, u_int pin); -void ioapic_register(void *cookie); -int ioapic_remap_vector(void *cookie, u_int pin, int vector); -int ioapic_set_bus(void *cookie, u_int pin, int bus_type); -int ioapic_set_extint(void *cookie, u_int pin); -int ioapic_set_nmi(void *cookie, u_int pin); -int ioapic_set_polarity(void *cookie, u_int pin, enum intr_polarity pol); -int ioapic_set_triggermode(void *cookie, u_int pin, +ioapic_drv_t ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase); +int ioapic_disable_pin(ioapic_drv_t cookie, u_int pin); +int ioapic_get_vector(ioapic_drv_t cookie, u_int pin); +void ioapic_register(ioapic_drv_t cookie); +int ioapic_remap_vector(ioapic_drv_t cookie, u_int pin, int vector); +int ioapic_set_bus(ioapic_drv_t cookie, u_int pin, int bus_type); +int ioapic_set_extint(ioapic_drv_t cookie, u_int pin); +int ioapic_set_nmi(ioapic_drv_t cookie, u_int pin); +int ioapic_set_polarity(ioapic_drv_t cookie, u_int pin, enum intr_polarity pol); +int ioapic_set_triggermode(ioapic_drv_t cookie, u_int pin, enum intr_trigger trigger); -int ioapic_set_smi(void *cookie, u_int pin); +int ioapic_set_smi(ioapic_drv_t cookie, u_int pin); void lapic_create(u_int apic_id, int boot_cpu); void lapic_init(vm_paddr_t addr); @@ -229,9 +231,9 @@ void apic_enable_vector(u_int apic_id, u_int vector); void apic_disable_vector(u_int apic_id, u_int vector); void apic_free_vector(u_int apic_id, u_int vector, u_int irq); void lapic_calibrate_timer(void); -int lapic_enable_pmc(void); -void lapic_disable_pmc(void); -void lapic_reenable_pmc(void); +int lapic_enable_pcint(void); +void lapic_disable_pcint(void); +void lapic_reenable_pcint(void); void lapic_enable_cmc(void); int lapic_enable_mca_elvt(void); void lapic_ipi_raw(register_t icrlo, u_int dest); diff --git a/lib/libc/include/generic-freebsd/x86/bus.h b/lib/libc/include/generic-freebsd/x86/bus.h index 53ad81391c4d3881f9c79eb20ecb1b7b6bbe0584..194c4c60a4c3a2011612bf76435e997168f7e0d8 100644 --- a/lib/libc/include/generic-freebsd/x86/bus.h +++ b/lib/libc/include/generic-freebsd/x86/bus.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-ClauseE + * SPDX-License-Identifier: BSD-3-Clause AND BSD-2-Clause * * Copyright (c) KATO Takenori, 1999. * diff --git a/lib/libc/include/generic-freebsd/x86/bus_dma.h b/lib/libc/include/generic-freebsd/x86/bus_dma.h index 03fdf98814a8811aedfb3e7a982ee1483400ec59..2c780a6697b9cf4da5b04e6ac75ad03f2438de4b 100644 --- a/lib/libc/include/generic-freebsd/x86/bus_dma.h +++ b/lib/libc/include/generic-freebsd/x86/bus_dma.h @@ -88,7 +88,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, /* * Free a piece of memory and it's allociated dmamap, that was allocated - * via bus_dmamem_alloc. Make the same choice for free/contigfree. + * via bus_dmamem_alloc. */ static inline void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) diff --git a/lib/libc/include/generic-freebsd/x86/busdma_impl.h b/lib/libc/include/generic-freebsd/x86/busdma_impl.h index 1c8775fb84baa6f22aa7e0bcd8739e5d16728556..247e77544fa2a3d823f768ed96dedcb595e8b6b7 100644 --- a/lib/libc/include/generic-freebsd/x86/busdma_impl.h +++ b/lib/libc/include/generic-freebsd/x86/busdma_impl.h @@ -33,28 +33,23 @@ struct bus_dma_tag_common { struct bus_dma_impl *impl; - struct bus_dma_tag_common *parent; bus_size_t alignment; bus_addr_t boundary; bus_addr_t lowaddr; bus_addr_t highaddr; - bus_dma_filter_t *filter; - void *filterarg; bus_size_t maxsize; u_int nsegments; bus_size_t maxsegsz; int flags; bus_dma_lock_t *lockfunc; void *lockfuncarg; - int ref_count; int domain; }; struct bus_dma_impl { int (*tag_create)(bus_dma_tag_t parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, - bus_addr_t highaddr, bus_dma_filter_t *filter, - void *filterarg, bus_size_t maxsize, int nsegments, + bus_addr_t highaddr, bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat); int (*tag_destroy)(bus_dma_tag_t dmat); @@ -87,13 +82,11 @@ struct bus_dma_impl { #endif }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, - bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, - int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, - void *lockfuncarg, size_t sz, void **dmat); + bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags, + bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat); extern struct bus_dma_impl bus_dma_bounce_impl; diff --git a/lib/libc/include/generic-freebsd/x86/dump.h b/lib/libc/include/generic-freebsd/x86/dump.h index 0e730eaf4b132ee4e29aa921f5d76769031618b9..93d208af956a4b0aadb28dbe1562b73b2f5fd6e2 100644 --- a/lib/libc/include/generic-freebsd/x86/dump.h +++ b/lib/libc/include/generic-freebsd/x86/dump.h @@ -38,7 +38,11 @@ /* 20 phys_avail entry pairs correspond to 10 pa's */ #define DUMPSYS_MD_PA_NPAIRS 10 +#ifdef __amd64__ +#define DUMPSYS_NUM_AUX_HDRS 1 +#else #define DUMPSYS_NUM_AUX_HDRS 0 +#endif /* How often to check the dump progress bar? */ #define DUMPSYS_PB_CHECK_BITS 24 /* Every 16MB */ @@ -71,12 +75,16 @@ dumpsys_unmap_chunk(vm_paddr_t pa, size_t s, void *va) dumpsys_gen_unmap_chunk(pa, s, va); } +#ifdef __amd64__ +int dumpsys_write_aux_headers(struct dumperinfo *di); +#else static inline int dumpsys_write_aux_headers(struct dumperinfo *di) { return (dumpsys_gen_write_aux_headers(di)); } +#endif static inline int dumpsys(struct dumperinfo *di) diff --git a/lib/libc/include/generic-freebsd/x86/endian.h b/lib/libc/include/generic-freebsd/x86/endian.h index 2e20329bb9aa332455de25db4b8dcb76c8c31c08..d36faaf557ce07a987600bb4243d6dd9418c4471 100644 --- a/lib/libc/include/generic-freebsd/x86/endian.h +++ b/lib/libc/include/generic-freebsd/x86/endian.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)endian.h 7.8 (Berkeley) 4/3/91 */ #ifndef _MACHINE_ENDIAN_H_ diff --git a/lib/libc/include/generic-freebsd/x86/float.h b/lib/libc/include/generic-freebsd/x86/float.h index 1f6845eea3f4dacb8e42e14f70af7af4d7ad5b7f..027082dbe4ee863f52880c96569be8d4548232fd 100644 --- a/lib/libc/include/generic-freebsd/x86/float.h +++ b/lib/libc/include/generic-freebsd/x86/float.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/generic-freebsd/x86/fpu.h b/lib/libc/include/generic-freebsd/x86/fpu.h index 8eb8eb6863a5c8bb09b2cd261ec91fefb1aacfff..675183075a42f4e611a93639bf6f39f65a8bc14f 100644 --- a/lib/libc/include/generic-freebsd/x86/fpu.h +++ b/lib/libc/include/generic-freebsd/x86/fpu.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 */ /* @@ -220,6 +218,13 @@ struct savefpu_ymm { */ #define fpu_enable() clts() #define fpu_disable() load_cr0(rcr0() | CR0_TS) + +bool xsave_extfeature_supported(uint64_t feature, bool supervisor); +bool xsave_extension_supported(uint64_t extension); +size_t xsave_area_hdr_offset(void); +size_t xsave_area_offset(uint64_t xstate_bv, uint64_t feature, bool compact, + bool supervisor); +size_t xsave_area_size(uint64_t xstate_bv, bool compact, bool supervisor); #endif #endif /* !_X86_FPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/frame.h b/lib/libc/include/generic-freebsd/x86/frame.h index 8cacd1a714e7b096f16cc3fa0b4551908b176c31..422c038874c3cb8ce1d8180fcd7afab0e24ca06c 100644 --- a/lib/libc/include/generic-freebsd/x86/frame.h +++ b/lib/libc/include/generic-freebsd/x86/frame.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 */ #ifndef _MACHINE_FRAME_H_ @@ -154,6 +152,7 @@ struct trapframe { #define TF_HASSEGS 0x1 #define TF_HASBASES 0x2 #define TF_HASFPXSTATE 0x4 +#define TF_RESERV0 0x8 /* no tlsbase in the trapframe */ #endif /* __amd64__ */ #endif /* _MACHINE_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/init.h b/lib/libc/include/generic-freebsd/x86/init.h index b5c4b9168a9c2b0cefa4d564ac4a4515775a0704..e8946ae206a84169447b7972d8055213a2475c0a 100644 --- a/lib/libc/include/generic-freebsd/x86/init.h +++ b/lib/libc/include/generic-freebsd/x86/init.h @@ -35,10 +35,10 @@ * hypervisor environment. */ struct init_ops { - caddr_t (*parse_preload_data)(u_int64_t); + void (*parse_preload_data)(u_int64_t); void (*early_clock_source_init)(void); void (*early_delay)(int); - void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); + void (*parse_memmap)(vm_paddr_t *, int *); }; extern struct init_ops init_ops; diff --git a/lib/libc/include/generic-freebsd/x86/intr_machdep.h b/lib/libc/include/generic-freebsd/x86/intr_machdep.h index 6b62eb65c847185173bb6cfe3ae03f5cb61bc6bd..ae90cd01e41bfddc740f13712f90a8180fa24a02 100644 --- a/lib/libc/include/generic-freebsd/x86/intr_machdep.h +++ b/lib/libc/include/generic-freebsd/x86/intr_machdep.h @@ -62,8 +62,6 @@ extern u_int num_msi_irqs; */ #define MSI_INTEL_ADDR_BASE 0xfee00000 -#ifndef LOCORE - typedef void inthand_t(void); #define IDTVEC(name) __CONCAT(X,name) @@ -138,12 +136,12 @@ void elcr_write_trigger(u_int irq, enum intr_trigger trigger); #ifdef SMP void intr_add_cpu(u_int cpu); #endif -int intr_add_handler(const char *name, int vector, driver_filter_t filter, - driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep, - int domain); -int intr_config_intr(int vector, enum intr_trigger trig, +int intr_add_handler(struct intsrc *isrc, const char *name, + driver_filter_t filter, driver_intr_t handler, void *arg, + enum intr_type flags, void **cookiep, int domain); +int intr_config_intr(struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol); -int intr_describe(u_int vector, void *ih, const char *descr); +int intr_describe(struct intsrc *isrc, void *ih, const char *descr); void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame); u_int intr_next_cpu(int domain); struct intsrc *intr_lookup_source(int vector); @@ -165,6 +163,5 @@ int msix_release(int irq); void xen_intr_alloc_irqs(void); #endif -#endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* !__X86_INTR_MACHDEP_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/legacyvar.h b/lib/libc/include/generic-freebsd/x86/legacyvar.h index a17e3b00427f6148e8bc678531931f39846012e8..09ee05b11ad7a0b6b00c8639b25b9ced9447ff9e 100644 --- a/lib/libc/include/generic-freebsd/x86/legacyvar.h +++ b/lib/libc/include/generic-freebsd/x86/legacyvar.h @@ -58,10 +58,14 @@ int legacy_pcib_write_ivar(device_t dev, device_t child, int which, struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); -int legacy_pcib_adjust_resource(device_t dev, device_t child, int type, +int legacy_pcib_adjust_resource(device_t dev, device_t child, struct resource *r, rman_res_t start, rman_res_t end); -int legacy_pcib_release_resource(device_t dev, device_t child, int type, - int rid, struct resource *r); +int legacy_pcib_release_resource(device_t dev, device_t child, + struct resource *r); +int legacy_pcib_activate_resource(device_t dev, device_t child, + struct resource *r); +int legacy_pcib_deactivate_resource(device_t dev, device_t child, + struct resource *r); int legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs); int legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq); diff --git a/lib/libc/include/generic-freebsd/x86/mca.h b/lib/libc/include/generic-freebsd/x86/mca.h index c5e0f8552db701a357e58d51d9a632d70706938a..9d9b4a1d6f4ba2221d58dba25f39968dec83e16d 100644 --- a/lib/libc/include/generic-freebsd/x86/mca.h +++ b/lib/libc/include/generic-freebsd/x86/mca.h @@ -44,6 +44,31 @@ struct mca_record { int mr_cpu; }; +enum mca_stat_types { + MCA_T_NONE = 0, + MCA_T_UNCLASSIFIED, + MCA_T_UCODE_ROM_PARITY, + MCA_T_EXTERNAL, + MCA_T_FRC, + MCA_T_INTERNAL_PARITY, + MCA_T_SMM_HANDLER, + MCA_T_INTERNAL_TIMER, + MCA_T_GENERIC_IO, + MCA_T_INTERNAL, + MCA_T_MEMORY, + MCA_T_TLB, + MCA_T_MEMCONTROLLER_GEN, + MCA_T_MEMCONTROLLER_RD, + MCA_T_MEMCONTROLLER_WR, + MCA_T_MEMCONTROLLER_AC, + MCA_T_MEMCONTROLLER_MS, + MCA_T_MEMCONTROLLER_OTHER, + MCA_T_CACHE, + MCA_T_BUS, + MCA_T_UNKNOWN, + MCA_T_COUNT /* Must stay last */ +}; + #ifdef _KERNEL void cmc_intr(void); diff --git a/lib/libc/include/generic-freebsd/x86/metadata.h b/lib/libc/include/generic-freebsd/x86/metadata.h index 357c8ac9ad15203997a986d4e72b27b629b78f87..dbe87384214109d605d41fdf6e9a98169d39002c 100644 --- a/lib/libc/include/generic-freebsd/x86/metadata.h +++ b/lib/libc/include/generic-freebsd/x86/metadata.h @@ -34,11 +34,17 @@ #define MODINFOMD_EFI_FB 0x1005 #define MODINFOMD_MODULEP 0x1006 #define MODINFOMD_VBE_FB 0x1007 +#define MODINFOMD_EFI_ARCH 0x1008 +/* + * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though + * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table + * starting at a 16-byte alignment. + */ struct efi_map_header { - uint64_t memory_size; - uint64_t descriptor_size; - uint32_t descriptor_version; + uint64_t memory_size; /* Numnber of bytes that follow */ + uint64_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */ + uint32_t descriptor_version; /* Currently '1' */ }; struct efi_fb { diff --git a/lib/libc/include/generic-freebsd/x86/mptable.h b/lib/libc/include/generic-freebsd/x86/mptable.h index ed9c7ddea70bb94a4c27a8ed5733c92d850ec547..7a5334ab59b8cbdcb47cf130323ea57de7dbdb55 100644 --- a/lib/libc/include/generic-freebsd/x86/mptable.h +++ b/lib/libc/include/generic-freebsd/x86/mptable.h @@ -188,16 +188,12 @@ typedef struct CBASMENTRY { #ifdef _KERNEL struct mptable_hostb_softc { -#ifdef NEW_PCIB struct pcib_host_resources sc_host_res; int sc_decodes_vga_io; int sc_decodes_isa_io; -#endif }; -#ifdef NEW_PCIB void mptable_pci_host_res_init(device_t pcib); -#endif int mptable_pci_probe_table(int bus); int mptable_pci_route_interrupt(device_t pcib, device_t dev, int pin); #endif diff --git a/lib/libc/include/generic-freebsd/x86/pci_cfgreg.h b/lib/libc/include/generic-freebsd/x86/pci_cfgreg.h index df03d454b45ff030115ca187fb6597bfa4d05344..0a331d384c0fec503244d93cec0431b71384803a 100644 --- a/lib/libc/include/generic-freebsd/x86/pci_cfgreg.h +++ b/lib/libc/include/generic-freebsd/x86/pci_cfgreg.h @@ -58,15 +58,12 @@ extern int cfgmech; rman_res_t hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count); int pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus); int pci_cfgregopen(void); -u_int32_t pci_cfgregread_domain(int domain, int bus, int slot, int func, int reg, int bytes); -void pci_cfgregwrite_domain(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes); +u_int32_t pci_cfgregread(int domain, int bus, int slot, int func, int reg, int bytes); +void pci_cfgregwrite(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes); #ifdef __HAVE_PIR void pci_pir_open(void); int pci_pir_probe(int bus, int require_parse); int pci_pir_route_interrupt(int bus, int device, int func, int pin); #endif -#define pci_cfgregread pci_cfgregread_domain -#define pci_cfgregwrite pci_cfgregwrite_domain - #endif /* !__X86_PCI_CFGREG_H__ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/psl.h b/lib/libc/include/generic-freebsd/x86/psl.h index e60c767b2a5fe804fb594457c9ad141e10b6208e..38d9c84cd60b0453a06037a2c1d02c67cef6e986 100644 --- a/lib/libc/include/generic-freebsd/x86/psl.h +++ b/lib/libc/include/generic-freebsd/x86/psl.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)psl.h 5.2 (Berkeley) 1/18/91 */ #ifndef _MACHINE_PSL_H_ diff --git a/lib/libc/include/generic-freebsd/x86/ptrace.h b/lib/libc/include/generic-freebsd/x86/ptrace.h index ee0977abb97542c97a561afb9a7e10f4614a27f0..6a278413cc0cfe8038fdf3b4ce7148228d9f917f 100644 --- a/lib/libc/include/generic-freebsd/x86/ptrace.h +++ b/lib/libc/include/generic-freebsd/x86/ptrace.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_PTRACE_H_ @@ -56,6 +54,8 @@ #define PT_SETFSBASE (PT_FIRSTMACH + 8) #define PT_GETGSBASE (PT_FIRSTMACH + 9) #define PT_SETGSBASE (PT_FIRSTMACH + 10) +#define PT_GETTLSBASE (PT_FIRSTMACH + 11) +#define PT_SETTLSBASE (PT_FIRSTMACH + 12) /* Argument structure for PT_GETXSTATE_INFO. */ struct ptrace_xstate_info { diff --git a/lib/libc/include/generic-freebsd/x86/reg.h b/lib/libc/include/generic-freebsd/x86/reg.h index 35c2f9a15e65185f18a5a64d18d656801ac791b1..31b9b3841fd7e1181eea29e43a1170fdfc049659 100644 --- a/lib/libc/include/generic-freebsd/x86/reg.h +++ b/lib/libc/include/generic-freebsd/x86/reg.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 */ #ifndef _MACHINE_REG_H_ diff --git a/lib/libc/include/generic-freebsd/x86/segments.h b/lib/libc/include/generic-freebsd/x86/segments.h index a51e8affbbd3bf51722ab66c177ddaa07b73a2a8..7332e4be6ab5939aeec06700191412a7d7c64de3 100644 --- a/lib/libc/include/generic-freebsd/x86/segments.h +++ b/lib/libc/include/generic-freebsd/x86/segments.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 */ #ifndef _X86_SEGMENTS_H_ diff --git a/lib/libc/include/generic-freebsd/x86/signal.h b/lib/libc/include/generic-freebsd/x86/signal.h index 2d43dfd25bccf45c340a66d33e7d0e41c12d7894..4e15bee2e91c68395d639281b966880beff65288 100644 --- a/lib/libc/include/generic-freebsd/x86/signal.h +++ b/lib/libc/include/generic-freebsd/x86/signal.h @@ -28,8 +28,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 */ #ifndef _X86_SIGNAL_H diff --git a/lib/libc/include/generic-freebsd/x86/specialreg.h b/lib/libc/include/generic-freebsd/x86/specialreg.h index deddda0a3badb6cdf3810c2568ff3438eeace8e0..6a482d94f0b6a56caf7aff4c1841ff79d6ec71e3 100644 --- a/lib/libc/include/generic-freebsd/x86/specialreg.h +++ b/lib/libc/include/generic-freebsd/x86/specialreg.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91 */ #ifndef _MACHINE_SPECIALREG_H_ @@ -125,6 +123,7 @@ #define XFEATURE_ENABLED_OPMASK 0x00000020 #define XFEATURE_ENABLED_ZMM_HI256 0x00000040 #define XFEATURE_ENABLED_HI16_ZMM 0x00000080 +#define XFEATURE_ENABLED_PT 0x00000100 #define XFEATURE_ENABLED_PKRU 0x00000200 #define XFEATURE_ENABLED_TILECONFIG 0x00020000 #define XFEATURE_ENABLED_TILEDATA 0x00040000 @@ -215,6 +214,7 @@ #define CPUPT_MTC (1 << 3) /* MTC Supported */ #define CPUPT_PRW (1 << 4) /* PTWRITE Supported */ #define CPUPT_PWR (1 << 5) /* Power Event Trace Supported */ +#define CPUPT_DIS_TNT (1 << 8) /* TNT disable supported */ /* Leaf 0 ecx. */ #define CPUPT_TOPA (1 << 0) /* ToPA Output Supported */ @@ -388,6 +388,14 @@ #define CPUID_EXTSTATE_XINUSE 0x00000004 #define CPUID_EXTSTATE_XSAVES 0x00000008 +/* + * CPUID instruction 0xd Processor Extended State Enumeration + * Sub-leaf > 1 ecx info + */ +#define CPUID_EXTSTATE_SUPERVISOR 0x00000001 +#define CPUID_EXTSTATE_ALIGNED 0x00000002 +#define CPUID_EXTSTATE_XFD_SUPPORTED 0x00000004 + /* * AMD extended function 8000_0007h ebx info */ @@ -648,6 +656,12 @@ #define MSR_PAT 0x277 #define MSR_MC0_CTL2 0x280 #define MSR_MTRRdefType 0x2ff +#define MSR_IA_GLOBAL_STATUS 0x38E +#define MSR_IA_GLOBAL_CTRL 0x38F +#define MSR_IA_GLOBAL_OVF_CTRL 0x390 +#define MSR_IA_GLOBAL_STATUS_RESET 0x390 +#define MSR_IA_GLOBAL_STATUS_SET 0x391 +#define GLOBAL_STATUS_FLAG_TRACETOPAPMI (1ULL << 55) #define MSR_MC0_CTL 0x400 #define MSR_MC0_STATUS 0x401 #define MSR_MC0_ADDR 0x402 @@ -775,6 +789,7 @@ #define RTIT_CTL_ADDR2_CFG_M (0xfULL << RTIT_CTL_ADDR2_CFG_S) #define RTIT_CTL_ADDR3_CFG_S 44 #define RTIT_CTL_ADDR3_CFG_M (0xfULL << RTIT_CTL_ADDR3_CFG_S) +#define RTIT_CTL_DIS_TNT (1ULL << 55) #define MSR_IA32_RTIT_STATUS 0x571 /* Tracing Status Register (R/W) */ #define RTIT_STATUS_FILTEREN (1 << 0) #define RTIT_STATUS_CONTEXTEN (1 << 1) @@ -991,7 +1006,7 @@ #define CCR4 0xe8 #define CCR4_IOMASK 0x07 -#define CCR4_MEM 0x08 /* Enables momory bypassing */ +#define CCR4_MEM 0x08 /* Enables memory bypassing */ #define CCR4_DTE 0x10 /* Enables directory table entry cache */ #define CCR4_FASTFPE 0x20 /* Fast FPU exception */ #define CCR4_CPUID 0x80 /* Enables CPUID instruction */ @@ -1011,7 +1026,7 @@ #define PCR0_RSTK 0x01 /* Enables return stack */ #define PCR0_BTB 0x02 /* Enables branch target buffer */ #define PCR0_LOOP 0x04 /* Enables loop */ -#define PCR0_AIS 0x08 /* Enables all instrcutions stalled to +#define PCR0_AIS 0x08 /* Enables all instructions stalled to serialize pipe. */ #define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */ #define PCR0_BTBRT 0x40 /* Enables BTB test register. */ @@ -1165,7 +1180,7 @@ /* * The region control registers specify the attributes associated with - * the ARRx addres regions. + * the ARRx address regions. */ #define RCR0 0xdc #define RCR1 0xdd diff --git a/lib/libc/include/generic-freebsd/x86/sysarch.h b/lib/libc/include/generic-freebsd/x86/sysarch.h index 7f897caa4329af34e0d8f11d237b9fc7b0abb1bb..dc22c3636a21c45eb2db1163e47c84762ba8f663 100644 --- a/lib/libc/include/generic-freebsd/x86/sysarch.h +++ b/lib/libc/include/generic-freebsd/x86/sysarch.h @@ -61,6 +61,9 @@ #define AMD64_GET_XFPUSTATE 132 #define AMD64_SET_PKRU 133 #define AMD64_CLEAR_PKRU 134 +#define AMD64_GET_TLSBASE 135 +#define AMD64_SET_TLSBASE 136 +#define AMD64_DISABLE_TLSBASE 137 /* Flags for AMD64_SET_PKRU */ #define AMD64_PKRU_EXCL 0x0001 @@ -140,6 +143,7 @@ int amd64_get_fsbase(void **); int amd64_get_gsbase(void **); int amd64_set_fsbase(void *); int amd64_set_gsbase(void *); +int amd64_set_tlsbase(void *); int x86_pkru_get_perm(unsigned int keyidx, int *access, int *modify); int x86_pkru_set_perm(unsigned int keyidx, int access, int modify); int x86_pkru_protect_range(void *addr, unsigned long len, unsigned int keyidx, diff --git a/lib/libc/include/generic-freebsd/x86/tls.h b/lib/libc/include/generic-freebsd/x86/tls.h index fe42da8c49527ce8ced50ebf969599d65a331ef6..a4f54258a29c71a9568150b08f64e284557cf715 100644 --- a/lib/libc/include/generic-freebsd/x86/tls.h +++ b/lib/libc/include/generic-freebsd/x86/tls.h @@ -36,13 +36,23 @@ struct pthread; +struct dtv_slot { + char *dtvs_tls; +}; + +struct dtv { + uintptr_t dtv_gen; + uintptr_t dtv_size; + struct dtv_slot dtv_slots[]; +}; + /* * Variant II tcb, first two members are required by rtld, * %fs (amd64) / %gs (i386) points to the structure. */ struct tcb { struct tcb *tcb_self; /* required by rtld */ - uintptr_t *tcb_dtv; /* required by rtld */ + struct dtv *tcb_dtv; /* required by rtld */ struct pthread *tcb_thread; }; @@ -59,7 +69,7 @@ static __inline void _tcb_set(struct tcb *tcb) { #ifdef __amd64__ - amd64_set_fsbase(tcb); + amd64_set_tlsbase(tcb); #else i386_set_gsbase(tcb); #endif diff --git a/lib/libc/include/generic-freebsd/x86/trap.h b/lib/libc/include/generic-freebsd/x86/trap.h index d0986944d024b5561ddad9a3065479712bda4208..a17cc44f0c27f846d354178351605331476670d2 100644 --- a/lib/libc/include/generic-freebsd/x86/trap.h +++ b/lib/libc/include/generic-freebsd/x86/trap.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)trap.h 5.4 (Berkeley) 5/9/91 */ #ifndef _MACHINE_TRAP_H_ diff --git a/lib/libc/include/generic-freebsd/x86/ucode.h b/lib/libc/include/generic-freebsd/x86/ucode.h index b13a8b94a98151d0ef5e5a0cf3dc3202cfbc3eb0..9d258b13698fb39f1a3814b544107052341b6395 100644 --- a/lib/libc/include/generic-freebsd/x86/ucode.h +++ b/lib/libc/include/generic-freebsd/x86/ucode.h @@ -31,6 +31,12 @@ #ifndef _MACHINE_UCODE_H_ #define _MACHINE_UCODE_H_ +#ifdef _KERNEL +#include +#else +#include +#endif + struct ucode_intel_header { uint32_t header_version; int32_t update_revision; @@ -56,7 +62,14 @@ struct ucode_intel_extsig_table { } entries[0]; }; -int ucode_intel_load(void *data, bool unsafe, +typedef enum { SAFE, UNSAFE, EARLY } ucode_load_how; + +const void *ucode_amd_find(const char *path, uint32_t signature, + uint32_t *revision, const uint8_t *fw_data, size_t fw_size, + size_t *selected_sizep); +int ucode_intel_load(const void *data, ucode_load_how unsafe, + uint64_t *nrevp, uint64_t *orevp); +int ucode_amd_load(const void *data, ucode_load_how how, uint64_t *nrevp, uint64_t *orevp); size_t ucode_load_bsp(uintptr_t free); void ucode_load_ap(int cpu); diff --git a/lib/libc/include/generic-freebsd/x86/ucontext.h b/lib/libc/include/generic-freebsd/x86/ucontext.h index 78ed7c6decedb8bc69d58994ba7190dfe855235c..ee13d85dcc768590432d921f5d0453e6072c4482 100644 --- a/lib/libc/include/generic-freebsd/x86/ucontext.h +++ b/lib/libc/include/generic-freebsd/x86/ucontext.h @@ -99,7 +99,9 @@ typedef struct __mcontext { #define _MC_HASSEGS 0x1 #define _MC_HASBASES 0x2 #define _MC_HASFPXSTATE 0x4 -#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE) +#define _MC_HASTLSBASE 0x8 +#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE | \ + _MC_HASTLSBASE) typedef struct __mcontext { /* @@ -158,7 +160,9 @@ typedef struct __mcontext { __register_t mc_xfpustate; __register_t mc_xfpustate_len; - long mc_spare[4]; + __register_t mc_tlsbase; + + long mc_spare[3]; } mcontext_t; #endif /* __amd64__ */ diff --git a/lib/libc/include/generic-freebsd/x86/vmware.h b/lib/libc/include/generic-freebsd/x86/vmware.h index 6c8b53cfe3e021f6ddca051067da11f2529ff3fe..8a44eed6ad06ad002b2d6b7dfeeb0b3d90d3093d 100644 --- a/lib/libc/include/generic-freebsd/x86/vmware.h +++ b/lib/libc/include/generic-freebsd/x86/vmware.h @@ -31,19 +31,23 @@ #define VMW_HVPORT 0x5658 #define VMW_HVCMD_GETVERSION 10 +#define VMW_HVCMD_GUESTRPC 30 #define VMW_HVCMD_GETHZ 45 #define VMW_HVCMD_GETVCPU_INFO 68 +#define VMW_HVCMD_DEFAULT_PARAM UINT_MAX + #define VMW_VCPUINFO_LEGACY_X2APIC (1 << 3) #define VMW_VCPUINFO_VCPU_RESERVED (1 << 31) static __inline void -vmware_hvcall(u_int cmd, u_int *p) +vmware_hvcall(int chan, u_int cmd, u_int param, u_int *p) { __asm __volatile("inl %w3, %0" : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) - : "0" (VMW_HVMAGIC), "1" (UINT_MAX), "2" (cmd), "3" (VMW_HVPORT) + : "0" (VMW_HVMAGIC), "1" (param), "2" (cmd), + "3" (VMW_HVPORT | (chan << 16)) : "memory"); } diff --git a/lib/libc/include/generic-freebsd/x86/vmware_guestrpc.h b/lib/libc/include/generic-freebsd/x86/vmware_guestrpc.h new file mode 100644 index 0000000000000000000000000000000000000000..c6e2dacb28e7886f0734735dcb93bd9ce841107b --- /dev/null +++ b/lib/libc/include/generic-freebsd/x86/vmware_guestrpc.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2015-2024, Juniper Networks, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _X86_VMWARE_GUESTRPC_H_ +#define _X86_VMWARE_GUESTRPC_H_ + +struct sbuf; + +int vmware_guestrpc_cmd(struct sbuf *sbufp); +int vmware_guestrpc_set_guestinfo(const char *keyword, const char *val); +int vmware_guestrpc_get_guestinfo(const char *keyword, struct sbuf *sbufp); + +#endif /* _X86_VMWARE_GUESTRPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/generic-freebsd/x86/x86_ieeefp.h b/lib/libc/include/generic-freebsd/x86/x86_ieeefp.h index 517b2af4329c9bde9bcc0ab391f5fe08cb72a2a8..042ddcf2169ab825c8fb0233c10af1b09d75a1df 100644 --- a/lib/libc/include/generic-freebsd/x86/x86_ieeefp.h +++ b/lib/libc/include/generic-freebsd/x86/x86_ieeefp.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 */ #ifndef _X86_X86_IEEEFP_H_ diff --git a/lib/libc/include/generic-freebsd/x86/x86_var.h b/lib/libc/include/generic-freebsd/x86/x86_var.h index bde6953598801a69fcb24a1d742e5a01bcfc1816..530786a16144657d9a40554597782772547a7505 100644 --- a/lib/libc/include/generic-freebsd/x86/x86_var.h +++ b/lib/libc/include/generic-freebsd/x86/x86_var.h @@ -50,6 +50,7 @@ extern u_int cpu_clflush_line_size; extern u_int cpu_stdext_feature; extern u_int cpu_stdext_feature2; extern u_int cpu_stdext_feature3; +extern u_int cpu_stdext_feature4; extern uint64_t cpu_ia32_arch_caps; extern u_int cpu_high; extern u_int cpu_id; @@ -62,6 +63,7 @@ extern char cpu_vendor[]; extern char cpu_model[]; extern u_int cpu_vendor_id; extern u_int cpu_mon_mwait_flags; +extern u_int cpu_mon_mwait_edx; extern u_int cpu_mon_min_size; extern u_int cpu_mon_max_size; extern u_int cpu_maxphyaddr; @@ -147,7 +149,9 @@ void zenbleed_sanitize_enable(void); void zenbleed_check_and_apply(bool all_cpus); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); -void nmi_handle_intr(u_int type, struct trapframe *frame); +void nmi_register_handler(int (*handler)(struct trapframe *)); +void nmi_remove_handler(int (*handler)(struct trapframe *)); +void nmi_handle_intr(struct trapframe *frame); void pagecopy(void *from, void *to); void printcpuinfo(void); int pti_get_default(void); diff --git a/lib/libc/include/powerpc-freebsd-eabihf/machine/sigframe.h b/lib/libc/include/powerpc-freebsd-eabihf/machine/sigframe.h deleted file mode 100644 index 72447f3e69782419c7237d6ea4e88ac3405a7fd7..0000000000000000000000000000000000000000 --- a/lib/libc/include/powerpc-freebsd-eabihf/machine/sigframe.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_SIGFRAME_H_ -#define _MACHINE_SIGFRAME_H_ 1 - -struct sigframe { - ucontext_t sf_uc; - siginfo_t sf_si; -}; - -#endif /* _MACHINE_SIGFRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/dev/powermac_nvram/powermac_nvramvar.h b/lib/libc/include/powerpc64-freebsd-none/dev/powermac_nvram/powermac_nvramvar.h new file mode 100644 index 0000000000000000000000000000000000000000..48172b858b4f2647c81d028bafbb9e9e228427d8 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/dev/powermac_nvram/powermac_nvramvar.h @@ -0,0 +1,82 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 Maxim Sobolev + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ +#define _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ + +#define NVRAM_SIZE 0x2000 + +#define CORE99_SIGNATURE 0x5a + +#define SM_FLASH_CMD_ERASE_CONFIRM 0xd0 +#define SM_FLASH_CMD_ERASE_SETUP 0x20 +#define SM_FLASH_CMD_RESET 0xff +#define SM_FLASH_CMD_WRITE_SETUP 0x40 +#define SM_FLASH_CMD_CLEAR_STATUS 0x50 +#define SM_FLASH_CMD_READ_STATUS 0x70 + +#define SM_FLASH_STATUS_DONE 0x80 +#define SM_FLASH_STATUS_ERR 0x38 + +#ifdef _KERNEL + +struct powermac_nvram_softc { + device_t sc_dev; + struct sx sc_lock; + phandle_t sc_node; + void * sc_bank; + void * sc_bank0; + void * sc_bank1; + uint8_t sc_data[NVRAM_SIZE]; + + struct cdev * sc_cdev; + int sc_type; +#define FLASH_TYPE_SM 0 +#define FLASH_TYPE_AMD 1 + int sc_isopen; + int sc_rpos; + int sc_wpos; +}; + +#endif /* _KERNEL */ + +struct chrp_header { + uint8_t signature; + uint8_t chrp_checksum; + uint16_t length; + char name[12]; +}; + +struct core99_header { + struct chrp_header chrp_header; + uint32_t adler_checksum; + uint32_t generation; + uint32_t reserved[2]; +}; + +#endif /* _POWERPC_POWERMAC_POWERMAC_NVRAMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/fenv.h b/lib/libc/include/powerpc64-freebsd-none/fenv.h new file mode 100644 index 0000000000000000000000000000000000000000..1838590a9950fd2ddfeb88d71094a6525f1b117d --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/fenv.h @@ -0,0 +1,305 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2004-2005 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _FENV_H_ +#define _FENV_H_ + +#include +#include + +#ifndef __fenv_static +#define __fenv_static static +#endif + +typedef __uint32_t fenv_t; +typedef __uint32_t fexcept_t; + +/* Exception flags */ +#ifdef __SPE__ +#define FE_OVERFLOW 0x00000100 +#define FE_UNDERFLOW 0x00000200 +#define FE_DIVBYZERO 0x00000400 +#define FE_INVALID 0x00000800 +#define FE_INEXACT 0x00001000 + +#define FE_ALL_INVALID FE_INVALID + +#define _FPUSW_SHIFT 6 +#else +#define FE_INEXACT 0x02000000 +#define FE_DIVBYZERO 0x04000000 +#define FE_UNDERFLOW 0x08000000 +#define FE_OVERFLOW 0x10000000 +#define FE_INVALID 0x20000000 /* all types of invalid FP ops */ + +/* + * The PowerPC architecture has extra invalid flags that indicate the + * specific type of invalid operation occurred. These flags may be + * tested, set, and cleared---but not masked---separately. All of + * these bits are cleared when FE_INVALID is cleared, but only + * FE_VXSOFT is set when FE_INVALID is explicitly set in software. + */ +#define FE_VXCVI 0x00000100 /* invalid integer convert */ +#define FE_VXSQRT 0x00000200 /* square root of a negative */ +#define FE_VXSOFT 0x00000400 /* software-requested exception */ +#define FE_VXVC 0x00080000 /* ordered comparison involving NaN */ +#define FE_VXIMZ 0x00100000 /* inf * 0 */ +#define FE_VXZDZ 0x00200000 /* 0 / 0 */ +#define FE_VXIDI 0x00400000 /* inf / inf */ +#define FE_VXISI 0x00800000 /* inf - inf */ +#define FE_VXSNAN 0x01000000 /* operation on a signalling NaN */ +#define FE_ALL_INVALID (FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \ + FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \ + FE_VXSNAN | FE_INVALID) + +#define _FPUSW_SHIFT 22 +#endif +#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ + FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +/* Rounding modes */ +#define FE_TONEAREST 0x0000 +#define FE_TOWARDZERO 0x0001 +#define FE_UPWARD 0x0002 +#define FE_DOWNWARD 0x0003 +#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ + FE_UPWARD | FE_TOWARDZERO) + +__BEGIN_DECLS + +/* Default floating-point environment */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +/* We need to be able to map status flag positions to mask flag positions */ +#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \ + FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT) + +#ifndef _SOFT_FLOAT +#ifdef __SPE__ +#define __mffs(__env) \ + __asm __volatile("mfspr %0, 512" : "=r" ((__env)->__bits.__reg)) +#define __mtfsf(__env) \ + __asm __volatile("mtspr 512,%0;isync" :: "r" ((__env).__bits.__reg)) +#else +#define __mffs(__env) \ + __asm __volatile("mffs %0" : "=f" ((__env)->__d)) +#define __mtfsf(__env) \ + __asm __volatile("mtfsf 255,%0" :: "f" ((__env).__d)) +#endif +#else +#define __mffs(__env) +#define __mtfsf(__env) +#endif + +union __fpscr { + double __d; + struct { +#if _BYTE_ORDER == _LITTLE_ENDIAN + fenv_t __reg; + __uint32_t __junk; +#else + __uint32_t __junk; + fenv_t __reg; +#endif + } __bits; +}; + +__fenv_static inline int +feclearexcept(int __excepts) +{ + union __fpscr __r; + + if (__excepts & FE_INVALID) + __excepts |= FE_ALL_INVALID; + __mffs(&__r); + __r.__bits.__reg &= ~__excepts; + __mtfsf(__r); + return (0); +} + +__fenv_static inline int +fegetexceptflag(fexcept_t *__flagp, int __excepts) +{ + union __fpscr __r; + + __mffs(&__r); + *__flagp = __r.__bits.__reg & __excepts; + return (0); +} + +__fenv_static inline int +fesetexceptflag(const fexcept_t *__flagp, int __excepts) +{ + union __fpscr __r; + + if (__excepts & FE_INVALID) + __excepts |= FE_ALL_INVALID; + __mffs(&__r); + __r.__bits.__reg &= ~__excepts; + __r.__bits.__reg |= *__flagp & __excepts; + __mtfsf(__r); + return (0); +} + +#ifdef __SPE__ +extern int feraiseexcept(int __excepts); +#else +__fenv_static inline int +feraiseexcept(int __excepts) +{ + union __fpscr __r; + + if (__excepts & FE_INVALID) + __excepts |= FE_VXSOFT; + __mffs(&__r); + __r.__bits.__reg |= __excepts; + __mtfsf(__r); + return (0); +} +#endif + +__fenv_static inline int +fetestexcept(int __excepts) +{ + union __fpscr __r; + + __mffs(&__r); + return (__r.__bits.__reg & __excepts); +} + +__fenv_static inline int +fegetround(void) +{ + union __fpscr __r; + + __mffs(&__r); + return (__r.__bits.__reg & _ROUND_MASK); +} + +__fenv_static inline int +fesetround(int __round) +{ + union __fpscr __r; + + if (__round & ~_ROUND_MASK) + return (-1); + __mffs(&__r); + __r.__bits.__reg &= ~_ROUND_MASK; + __r.__bits.__reg |= __round; + __mtfsf(__r); + return (0); +} + +__fenv_static inline int +fegetenv(fenv_t *__envp) +{ + union __fpscr __r; + + __mffs(&__r); + *__envp = __r.__bits.__reg; + return (0); +} + +__fenv_static inline int +feholdexcept(fenv_t *__envp) +{ + union __fpscr __r; + + __mffs(&__r); + *__envp = __r.__bits.__reg; + __r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK); + __mtfsf(__r); + return (0); +} + +__fenv_static inline int +fesetenv(const fenv_t *__envp) +{ + union __fpscr __r; + + __r.__bits.__reg = *__envp; + __mtfsf(__r); + return (0); +} + +__fenv_static inline int +feupdateenv(const fenv_t *__envp) +{ + union __fpscr __r; + + __mffs(&__r); + __r.__bits.__reg &= FE_ALL_EXCEPT; + __r.__bits.__reg |= *__envp; + __mtfsf(__r); + return (0); +} + +#if __BSD_VISIBLE + +__fenv_static inline int +feenableexcept(int __mask) +{ + union __fpscr __r; + fenv_t __oldmask; + + __mffs(&__r); + __oldmask = __r.__bits.__reg; + __r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT; + __mtfsf(__r); + return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +__fenv_static inline int +fedisableexcept(int __mask) +{ + union __fpscr __r; + fenv_t __oldmask; + + __mffs(&__r); + __oldmask = __r.__bits.__reg; + __r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT); + __mtfsf(__r); + return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +/* We currently provide no external definition of fegetexcept(). */ +static inline int +fegetexcept(void) +{ + union __fpscr __r; + + __mffs(&__r); + return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT); +} + +#endif /* __BSD_VISIBLE */ + +__END_DECLS + +#endif /* !_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/float.h b/lib/libc/include/powerpc64-freebsd-none/float.h new file mode 100644 index 0000000000000000000000000000000000000000..a832240666f0e403949fa5e56079bba16e75ba0c --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/float.h @@ -0,0 +1,98 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 + */ + +#ifndef _MACHINE_FLOAT_H_ +#define _MACHINE_FLOAT_H_ 1 + +#include + +#ifndef _SOFT_FLOAT +__BEGIN_DECLS +extern int __flt_rounds(void); +__END_DECLS +#define FLT_ROUNDS __flt_rounds() +#else +#define FLT_ROUNDS (-1) +#endif + +#define FLT_RADIX 2 /* b */ +#if __ISO_C_VISIBLE >= 1999 +#define FLT_EVAL_METHOD 0 +#define DECIMAL_DIG 17 /* max precision in decimal digits */ +#endif + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ +#if __ISO_C_VISIBLE >= 2011 +#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */ +#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */ +#define FLT_HAS_SUBNORM 1 +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MAX_10_EXP 308 +#if __ISO_C_VISIBLE >= 2011 +#define DBL_TRUE_MIN 4.9406564584124654E-324 +#define DBL_DECIMAL_DIG 17 +#define DBL_HAS_SUBNORM 1 +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON ((long double)DBL_EPSILON) +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN ((long double)DBL_MIN) +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX ((long double)DBL_MAX) +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP +#if __ISO_C_VISIBLE >= 2011 +#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN) +#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG +#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#endif /* _MACHINE_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/floatingpoint.h b/lib/libc/include/powerpc64-freebsd-none/floatingpoint.h new file mode 100644 index 0000000000000000000000000000000000000000..d2c7e15ad2e8ae4c8fff302ee2365f352fd05c79 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/floatingpoint.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2004 Suleiman Souhlal + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _FLOATINGPOINT_H_ +#define _FLOATINGPOINT_H_ + +#include + +#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_align.h b/lib/libc/include/powerpc64-freebsd-none/machine/_align.h new file mode 100644 index 0000000000000000000000000000000000000000..d42a79c96f4aa52a9352818a9d3a748302d4edf4 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_align.h @@ -0,0 +1,51 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _POWERPC_INCLUDE__ALIGN_H_ +#define _POWERPC_INCLUDE__ALIGN_H_ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define _ALIGNBYTES (sizeof(register_t) - 1) +#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) + +#endif /* !_POWERPC_INCLUDE__ALIGN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_bus.h b/lib/libc/include/powerpc64-freebsd-none/machine/_bus.h new file mode 100644 index 0000000000000000000000000000000000000000..5bc548592d1472dd4dbd0de4b59af9fd2b0f5997 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_bus.h @@ -0,0 +1,30 @@ +/*- + * Copyright (c) 2005 The FreeBSD Foundation. + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Derived in part from NetBSD's bus.h files by (alphabetically): + * Christopher G. Demetriou + * Charles M. Hannum + * Jason Thorpe + * The NetBSD Foundation. + */ + +#ifndef POWERPC_INCLUDE__BUS_H +#define POWERPC_INCLUDE__BUS_H + +#include + +/* + * Bus address and size types + */ +typedef vm_paddr_t bus_addr_t; +typedef vm_size_t bus_size_t; + +/* + * Access methods for bus resources and address space. + */ +typedef struct bus_space *bus_space_tag_t; +typedef vm_offset_t bus_space_handle_t; + +#endif /* POWERPC_INCLUDE__BUS_H */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_inttypes.h b/lib/libc/include/powerpc64-freebsd-none/machine/_inttypes.h new file mode 100644 index 0000000000000000000000000000000000000000..770c91e434159779f77b1c0b3510f82aa98d9bd7 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_inttypes.h @@ -0,0 +1,222 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $ + */ + +#ifndef _MACHINE_INTTYPES_H_ +#define _MACHINE_INTTYPES_H_ + +/* + * Macros for format specifiers. + */ + +#ifdef __LP64__ +#define __PRI64 "l" +#define __PRIptr "l" +#else +#define __PRI64 "ll" +#define __PRIptr +#endif + +/* fprintf(3) macros for signed integers. */ + +#define PRId8 "d" /* int8_t */ +#define PRId16 "d" /* int16_t */ +#define PRId32 "d" /* int32_t */ +#define PRId64 __PRI64"d" /* int64_t */ +#define PRIdLEAST8 "d" /* int_least8_t */ +#define PRIdLEAST16 "d" /* int_least16_t */ +#define PRIdLEAST32 "d" /* int_least32_t */ +#define PRIdLEAST64 __PRI64"d" /* int_least64_t */ +#define PRIdFAST8 "d" /* int_fast8_t */ +#define PRIdFAST16 "d" /* int_fast16_t */ +#define PRIdFAST32 "d" /* int_fast32_t */ +#define PRIdFAST64 __PRI64"d" /* int_fast64_t */ +#define PRIdMAX "jd" /* intmax_t */ +#define PRIdPTR __PRIptr"d" /* intptr_t */ + +#define PRIi8 "i" /* int8_t */ +#define PRIi16 "i" /* int16_t */ +#define PRIi32 "i" /* int32_t */ +#define PRIi64 __PRI64"i" /* int64_t */ +#define PRIiLEAST8 "i" /* int_least8_t */ +#define PRIiLEAST16 "i" /* int_least16_t */ +#define PRIiLEAST32 "i" /* int_least32_t */ +#define PRIiLEAST64 __PRI64"i" /* int_least64_t */ +#define PRIiFAST8 "i" /* int_fast8_t */ +#define PRIiFAST16 "i" /* int_fast16_t */ +#define PRIiFAST32 "i" /* int_fast32_t */ +#define PRIiFAST64 __PRI64"i" /* int_fast64_t */ +#define PRIiMAX "ji" /* intmax_t */ +#define PRIiPTR __PRIptr"i" /* intptr_t */ + +/* fprintf(3) macros for unsigned integers. */ + +#define PRIo8 "o" /* uint8_t */ +#define PRIo16 "o" /* uint16_t */ +#define PRIo32 "o" /* uint32_t */ +#define PRIo64 __PRI64"o" /* uint64_t */ +#define PRIoLEAST8 "o" /* uint_least8_t */ +#define PRIoLEAST16 "o" /* uint_least16_t */ +#define PRIoLEAST32 "o" /* uint_least32_t */ +#define PRIoLEAST64 __PRI64"o" /* uint_least64_t */ +#define PRIoFAST8 "o" /* uint_fast8_t */ +#define PRIoFAST16 "o" /* uint_fast16_t */ +#define PRIoFAST32 "o" /* uint_fast32_t */ +#define PRIoFAST64 __PRI64"o" /* uint_fast64_t */ +#define PRIoMAX "jo" /* uintmax_t */ +#define PRIoPTR __PRIptr"o" /* uintptr_t */ + +#define PRIu8 "u" /* uint8_t */ +#define PRIu16 "u" /* uint16_t */ +#define PRIu32 "u" /* uint32_t */ +#define PRIu64 __PRI64"u" /* uint64_t */ +#define PRIuLEAST8 "u" /* uint_least8_t */ +#define PRIuLEAST16 "u" /* uint_least16_t */ +#define PRIuLEAST32 "u" /* uint_least32_t */ +#define PRIuLEAST64 __PRI64"u" /* uint_least64_t */ +#define PRIuFAST8 "u" /* uint_fast8_t */ +#define PRIuFAST16 "u" /* uint_fast16_t */ +#define PRIuFAST32 "u" /* uint_fast32_t */ +#define PRIuFAST64 __PRI64"u" /* uint_fast64_t */ +#define PRIuMAX "ju" /* uintmax_t */ +#define PRIuPTR __PRIptr"u" /* uintptr_t */ + +#define PRIx8 "x" /* uint8_t */ +#define PRIx16 "x" /* uint16_t */ +#define PRIx32 "x" /* uint32_t */ +#define PRIx64 __PRI64"x" /* uint64_t */ +#define PRIxLEAST8 "x" /* uint_least8_t */ +#define PRIxLEAST16 "x" /* uint_least16_t */ +#define PRIxLEAST32 "x" /* uint_least32_t */ +#define PRIxLEAST64 __PRI64"x" /* uint_least64_t */ +#define PRIxFAST8 "x" /* uint_fast8_t */ +#define PRIxFAST16 "x" /* uint_fast16_t */ +#define PRIxFAST32 "x" /* uint_fast32_t */ +#define PRIxFAST64 __PRI64"x" /* uint_fast64_t */ +#define PRIxMAX "jx" /* uintmax_t */ +#define PRIxPTR __PRIptr"x" /* uintptr_t */ + +#define PRIX8 "X" /* uint8_t */ +#define PRIX16 "X" /* uint16_t */ +#define PRIX32 "X" /* uint32_t */ +#define PRIX64 __PRI64"X" /* uint64_t */ +#define PRIXLEAST8 "X" /* uint_least8_t */ +#define PRIXLEAST16 "X" /* uint_least16_t */ +#define PRIXLEAST32 "X" /* uint_least32_t */ +#define PRIXLEAST64 __PRI64"X" /* uint_least64_t */ +#define PRIXFAST8 "X" /* uint_fast8_t */ +#define PRIXFAST16 "X" /* uint_fast16_t */ +#define PRIXFAST32 "X" /* uint_fast32_t */ +#define PRIXFAST64 __PRI64"X" /* uint_fast64_t */ +#define PRIXMAX "jX" /* uintmax_t */ +#define PRIXPTR __PRIptr"X" /* uintptr_t */ + +/* fscanf(3) macros for signed integers. */ + +#define SCNd8 "hhd" /* int8_t */ +#define SCNd16 "hd" /* int16_t */ +#define SCNd32 "d" /* int32_t */ +#define SCNd64 __PRI64"d" /* int64_t */ +#define SCNdLEAST8 "hhd" /* int_least8_t */ +#define SCNdLEAST16 "hd" /* int_least16_t */ +#define SCNdLEAST32 "d" /* int_least32_t */ +#define SCNdLEAST64 __PRI64"d" /* int_least64_t */ +#define SCNdFAST8 "d" /* int_fast8_t */ +#define SCNdFAST16 "d" /* int_fast16_t */ +#define SCNdFAST32 "d" /* int_fast32_t */ +#define SCNdFAST64 __PRI64"d" /* int_fast64_t */ +#define SCNdMAX "jd" /* intmax_t */ +#define SCNdPTR __PRIptr"d" /* intptr_t */ + +#define SCNi8 "hhi" /* int8_t */ +#define SCNi16 "hi" /* int16_t */ +#define SCNi32 "i" /* int32_t */ +#define SCNi64 __PRI64"i" /* int64_t */ +#define SCNiLEAST8 "hhi" /* int_least8_t */ +#define SCNiLEAST16 "hi" /* int_least16_t */ +#define SCNiLEAST32 "i" /* int_least32_t */ +#define SCNiLEAST64 __PRI64"i" /* int_least64_t */ +#define SCNiFAST8 "i" /* int_fast8_t */ +#define SCNiFAST16 "i" /* int_fast16_t */ +#define SCNiFAST32 "i" /* int_fast32_t */ +#define SCNiFAST64 __PRI64"i" /* int_fast64_t */ +#define SCNiMAX "ji" /* intmax_t */ +#define SCNiPTR __PRIptr"i" /* intptr_t */ + +/* fscanf(3) macros for unsigned integers. */ + +#define SCNo8 "hho" /* uint8_t */ +#define SCNo16 "ho" /* uint16_t */ +#define SCNo32 "o" /* uint32_t */ +#define SCNo64 __PRI64"o" /* uint64_t */ +#define SCNoLEAST8 "hho" /* uint_least8_t */ +#define SCNoLEAST16 "ho" /* uint_least16_t */ +#define SCNoLEAST32 "o" /* uint_least32_t */ +#define SCNoLEAST64 __PRI64"o" /* uint_least64_t */ +#define SCNoFAST8 "o" /* uint_fast8_t */ +#define SCNoFAST16 "o" /* uint_fast16_t */ +#define SCNoFAST32 "o" /* uint_fast32_t */ +#define SCNoFAST64 __PRI64"o" /* uint_fast64_t */ +#define SCNoMAX "jo" /* uintmax_t */ +#define SCNoPTR __PRIptr"o" /* uintptr_t */ + +#define SCNu8 "hhu" /* uint8_t */ +#define SCNu16 "hu" /* uint16_t */ +#define SCNu32 "u" /* uint32_t */ +#define SCNu64 __PRI64"u" /* uint64_t */ +#define SCNuLEAST8 "hhu" /* uint_least8_t */ +#define SCNuLEAST16 "hu" /* uint_least16_t */ +#define SCNuLEAST32 "u" /* uint_least32_t */ +#define SCNuLEAST64 __PRI64"u" /* uint_least64_t */ +#define SCNuFAST8 "u" /* uint_fast8_t */ +#define SCNuFAST16 "u" /* uint_fast16_t */ +#define SCNuFAST32 "u" /* uint_fast32_t */ +#define SCNuFAST64 __PRI64"u" /* uint_fast64_t */ +#define SCNuMAX "ju" /* uintmax_t */ +#define SCNuPTR __PRIptr"u" /* uintptr_t */ + +#define SCNx8 "hhx" /* uint8_t */ +#define SCNx16 "hx" /* uint16_t */ +#define SCNx32 "x" /* uint32_t */ +#define SCNx64 __PRI64"x" /* uint64_t */ +#define SCNxLEAST8 "hhx" /* uint_least8_t */ +#define SCNxLEAST16 "hx" /* uint_least16_t */ +#define SCNxLEAST32 "x" /* uint_least32_t */ +#define SCNxLEAST64 __PRI64"x" /* uint_least64_t */ +#define SCNxFAST8 "x" /* uint_fast8_t */ +#define SCNxFAST16 "x" /* uint_fast16_t */ +#define SCNxFAST32 "x" /* uint_fast32_t */ +#define SCNxFAST64 __PRI64"x" /* uint_fast64_t */ +#define SCNxMAX "jx" /* uintmax_t */ +#define SCNxPTR __PRIptr"x" /* uintptr_t */ + +#endif /* !_MACHINE_INTTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_limits.h b/lib/libc/include/powerpc64-freebsd-none/machine/_limits.h new file mode 100644 index 0000000000000000000000000000000000000000..e8451d22fef1b9325bdbba7f667bc9de0dc86895 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_limits.h @@ -0,0 +1,96 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE__LIMITS_H_ +#define _MACHINE__LIMITS_H_ + +/* + * According to ANSI (section 2.2.4.2), the values below must be usable by + * #if preprocessing directives. Additionally, the expression must have the + * same type as would an expression that is an object of the corresponding + * type converted according to the integral promotions. The subtraction for + * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + */ + +#define __CHAR_BIT 8 /* number of bits in a char */ + +#define __SCHAR_MAX 0x7f /* max value for a signed char */ +#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ + +#define __UCHAR_MAX 0xff /* max value for an unsigned char */ + +#define __USHRT_MAX 0xffff /* max value for an unsigned short */ +#define __SHRT_MAX 0x7fff /* max value for a short */ +#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */ + +#define __UINT_MAX 0xffffffff /* max value for an unsigned int */ +#define __INT_MAX 0x7fffffff /* max value for an int */ +#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */ + +#ifdef __LP64__ +#define __ULONG_MAX 0xffffffffffffffff +#define __LONG_MAX 0x7fffffffffffffff +#define __LONG_MIN (-0x7fffffffffffffff - 1) +#define __LONG_BIT 64 +#else +#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */ +#define __LONG_MAX 0x7fffffffL /* max value for a long */ +#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */ +#define __LONG_BIT 32 +#endif + +#define __ULLONG_MAX 0xffffffffffffffffULL +#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ +#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ + +#ifdef __LP64__ +#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ +#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ +#else +#define __SSIZE_MAX __INT_MAX /* max value for a ssize_t */ +#define __SIZE_T_MAX __UINT_MAX /* max value for a size_t */ +#endif + +#define __OFF_MAX __LLONG_MAX /* max value for an off_t */ +#define __OFF_MIN __LLONG_MIN /* min value for an off_t */ + +/* Quads and long longs are the same size. Ensure they stay in sync. */ +#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */ +#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */ +#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */ + +#define __WORD_BIT 32 + +/* Minimum signal stack size. */ +#define __MINSIGSTKSZ (512 * 4) + +#endif /* !_MACHINE__LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_stdint.h b/lib/libc/include/powerpc64-freebsd-none/machine/_stdint.h new file mode 100644 index 0000000000000000000000000000000000000000..6111b8467c09c33f2dafc78839b5035a1d68a2f1 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_stdint.h @@ -0,0 +1,200 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2001, 2002 Mike Barcroft + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE__STDINT_H_ +#define _MACHINE__STDINT_H_ + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) + +#define INT8_C(c) (c) +#define INT16_C(c) (c) +#define INT32_C(c) (c) + +#define UINT8_C(c) (c) +#define UINT16_C(c) (c) +#define UINT32_C(c) (c ## U) + +#ifdef __LP64__ +#define INT64_C(c) (c ## L) +#define UINT64_C(c) (c ## UL) +#else +#define INT64_C(c) (c ## LL) +#define UINT64_C(c) (c ## ULL) +#endif + +#define INTMAX_C(c) INT64_C(c) +#define UINTMAX_C(c) UINT64_C(c) + +#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) + +#ifndef __INT64_C +#ifdef __LP64__ +#define __INT64_C(c) (c ## L) +#define __UINT64_C(c) (c ## UL) +#else +#define __INT64_C(c) (c ## LL) +#define __UINT64_C(c) (c ## ULL) +#endif +#endif + +/* + * ISO/IEC 9899:1999 + * 7.18.2.1 Limits of exact-width integer types + */ +/* Minimum values of exact-width signed integer types. */ +#define INT8_MIN (-0x7f-1) +#define INT16_MIN (-0x7fff-1) +#define INT32_MIN (-0x7fffffff-1) +#define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1) + +/* Maximum values of exact-width signed integer types. */ +#define INT8_MAX 0x7f +#define INT16_MAX 0x7fff +#define INT32_MAX 0x7fffffff +#define INT64_MAX __INT64_C(0x7fffffffffffffff) + +/* Maximum values of exact-width unsigned integer types. */ +#define UINT8_MAX 0xff +#define UINT16_MAX 0xffff +#define UINT32_MAX 0xffffffff +#define UINT64_MAX __UINT64_C(0xffffffffffffffff) + +/* + * ISO/IEC 9899:1999 + * 7.18.2.2 Limits of minimum-width integer types + */ +/* Minimum values of minimum-width signed integer types. */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +/* Maximum values of minimum-width signed integer types. */ +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +/* Maximum values of minimum-width unsigned integer types. */ +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +/* + * ISO/IEC 9899:1999 + * 7.18.2.3 Limits of fastest minimum-width integer types + */ +/* Minimum values of fastest minimum-width signed integer types. */ +#define INT_FAST8_MIN INT32_MIN +#define INT_FAST16_MIN INT32_MIN +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST64_MIN INT64_MIN + +/* Maximum values of fastest minimum-width signed integer types. */ +#define INT_FAST8_MAX INT32_MAX +#define INT_FAST16_MAX INT32_MAX +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MAX INT64_MAX + +/* Maximum values of fastest minimum-width unsigned integer types. */ +#define UINT_FAST8_MAX UINT32_MAX +#define UINT_FAST16_MAX UINT32_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +/* + * ISO/IEC 9899:1999 + * 7.18.2.4 Limits of integer types capable of holding object pointers + */ +#ifdef __LP64__ +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#else +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#endif + +/* + * ISO/IEC 9899:1999 + * 7.18.2.5 Limits of greatest-width integer types + */ +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +/* + * ISO/IEC 9899:1999 + * 7.18.3 Limits of other integer types + */ +#ifdef __LP64__ +/* Limits of ptrdiff_t. */ +#define PTRDIFF_MIN INT64_MIN +#define PTRDIFF_MAX INT64_MAX + +/* Limits of sig_atomic_t. */ +#define SIG_ATOMIC_MIN INT64_MIN +#define SIG_ATOMIC_MAX INT64_MAX + +/* Limit of size_t. */ +#define SIZE_MAX UINT64_MAX +#else +/* Limits of ptrdiff_t. */ +#define PTRDIFF_MIN INT32_MIN +#define PTRDIFF_MAX INT32_MAX + +/* Limits of sig_atomic_t. */ +#define SIG_ATOMIC_MIN INT32_MIN +#define SIG_ATOMIC_MAX INT32_MAX + +/* Limit of size_t. */ +#define SIZE_MAX UINT32_MAX +#endif + +/* Limits of wint_t. */ +#define WINT_MIN INT32_MIN +#define WINT_MAX INT32_MAX + +#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ + +#endif /* !_MACHINE__STDINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/_types.h b/lib/libc/include/powerpc64-freebsd-none/machine/_types.h new file mode 100644 index 0000000000000000000000000000000000000000..00294d9f9857e5ae8929ced773ae75f02558109b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/_types.h @@ -0,0 +1,89 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2002 Mike Barcroft + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE__TYPES_H_ +#define _MACHINE__TYPES_H_ + +#ifndef _SYS__TYPES_H_ +#error do not include this header, use sys/_types.h +#endif + +/* + * Standard type definitions. + */ +typedef __uint32_t __clock_t; /* clock()... */ +#ifndef _STANDALONE +typedef double __double_t; +typedef float __float_t; +#endif +#ifdef __LP64__ +typedef __int64_t __critical_t; +#else +typedef __int32_t __critical_t; +#endif +typedef __int32_t __int_fast8_t; +typedef __int32_t __int_fast16_t; +typedef __int32_t __int_fast32_t; +typedef __int64_t __int_fast64_t; +#ifdef __LP64__ +typedef __int64_t __register_t; +typedef __int64_t __segsz_t; /* segment size (in pages) */ +#else +typedef __int32_t __register_t; +typedef __int32_t __segsz_t; /* segment size (in pages) */ +#endif +typedef __int64_t __time_t; /* time()... */ +typedef __uint32_t __uint_fast8_t; +typedef __uint32_t __uint_fast16_t; +typedef __uint32_t __uint_fast32_t; +typedef __uint64_t __uint_fast64_t; +#ifdef __LP64__ +typedef __uint64_t __u_register_t; +typedef __uint64_t __vm_paddr_t; +#else +typedef __uint32_t __u_register_t; +#ifdef BOOKE +typedef __uint64_t __vm_paddr_t; +#else +typedef __uint32_t __vm_paddr_t; +#endif +#endif +typedef int ___wchar_t; + +#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */ +#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */ + +#endif /* !_MACHINE__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/altivec.h b/lib/libc/include/powerpc64-freebsd-none/machine/altivec.h new file mode 100644 index 0000000000000000000000000000000000000000..87f795c6ee43606f2c85f2a9e3ce6c581b59045b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/altivec.h @@ -0,0 +1,41 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2008 Nathan Whitehorn + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_ALTIVEC_H_ +#define _MACHINE_ALTIVEC_H_ + +#define ALTIVEC_VSCR_NJ 0x00010000 /* Enable non-Java mode */ +#define ALTIVEC_VSCR_SAT 0x00000001 /* Saturation status bit */ + +void enable_vec(struct thread *); +void save_vec(struct thread *); +void save_vec_nodrop(struct thread *); +void enable_vec_kern(void); +void disable_vec(struct thread *td); + +#endif /* _MACHINE_ALTIVEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/asm.h b/lib/libc/include/powerpc64-freebsd-none/machine/asm.h new file mode 100644 index 0000000000000000000000000000000000000000..5f886582518e86fd6ce4171cbba318088dc8eb4c --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/asm.h @@ -0,0 +1,267 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $ + */ + +#ifndef _MACHINE_ASM_H_ +#define _MACHINE_ASM_H_ + +#include + +#if defined(PIC) && !defined(__powerpc64__) +#define PIC_PROLOGUE XXX +#define PIC_EPILOGUE XXX +#define PIC_PLT(x) x@plt +#ifdef __STDC__ +#define PIC_GOT(x) XXX +#else /* not __STDC__ */ +#define PIC_GOT(x) XXX +#endif /* __STDC__ */ +#else +#define PIC_PROLOGUE +#define PIC_EPILOGUE +#define PIC_PLT(x) x +#define PIC_GOT(x) x +#endif + +#define CNAME(csym) csym +#define ASMNAME(asmsym) asmsym +#ifdef __powerpc64__ +#define HIDENAME(asmsym) __CONCAT(_,asmsym) +#else +#define HIDENAME(asmsym) __CONCAT(.,asmsym) +#endif + +#if !defined(_CALL_ELF) || _CALL_ELF == 1 +#ifdef _KERNEL +/* ELFv1 kernel uses global dot symbols */ +#define DOT_LABEL(name) __CONCAT(.,name) +#define TYPE_ENTRY(name) .size name,24; \ + .type DOT_LABEL(name),@function; \ + .globl DOT_LABEL(name); +#define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name); +#else /* !_KERNEL */ +/* ELFv1 user code uses local function entry points */ +#define DOT_LABEL(name) __CONCAT(.L.,name) +#define TYPE_ENTRY(name) .type name,@function; +#define END_SIZE(name) .size name,.-DOT_LABEL(name); +#endif /* _KERNEL */ +#else +/* ELFv2 doesn't have any of this complication */ +#define DOT_LABEL(name) name +#define TYPE_ENTRY(name) .type name,@function; +#define END_SIZE(name) .size name,.-DOT_LABEL(name); +#endif + +#define _GLOBAL(name) \ + .data; \ + .p2align 2; \ + .globl name; \ + name: + +#ifdef __powerpc64__ +#define TOC_NAME_FOR_REF(name) __CONCAT(.L,name) +#define TOC_REF(name) TOC_NAME_FOR_REF(name)@toc +#define TOC_ENTRY(name) \ + .section ".toc","aw"; \ + TOC_NAME_FOR_REF(name): \ + .tc name[TC],name +#endif + +#ifdef __powerpc64__ + +#if !defined(_CALL_ELF) || _CALL_ELF == 1 +#define _ENTRY(name) \ + .section ".text"; \ + .p2align 2; \ + .globl name; \ + .section ".opd","aw"; \ + .p2align 3; \ +name: \ + .quad DOT_LABEL(name),.TOC.@tocbase,0; \ + .previous; \ + .p2align 4; \ + TYPE_ENTRY(name) \ +DOT_LABEL(name): \ + .cfi_startproc +#define _NAKED_ENTRY(name) _ENTRY(name) +#else +#define _ENTRY(name) \ + .text; \ + .p2align 4; \ + .globl name; \ + .type name,@function; \ +name: \ + .cfi_startproc; \ + addis %r2, %r12, (.TOC.-name)@ha; \ + addi %r2, %r2, (.TOC.-name)@l; \ + .localentry name, .-name; + +/* "Naked" function entry. No TOC prologue for ELFv2. */ +#define _NAKED_ENTRY(name) \ + .text; \ + .p2align 4; \ + .globl name; \ + .type name,@function; \ +name: \ + .cfi_startproc; \ + .localentry name, .-name; +#endif + +#define _END(name) \ + .cfi_endproc; \ + .long 0; \ + .byte 0,0,0,0,0,0,0,0; \ + END_SIZE(name) + +#define LOAD_ADDR(reg, var) \ + lis reg, var@highest; \ + ori reg, reg, var@higher; \ + rldicr reg, reg, 32, 31; \ + oris reg, reg, var@h; \ + ori reg, reg, var@l; +#else /* !__powerpc64__ */ +#define _ENTRY(name) \ + .text; \ + .p2align 4; \ + .globl name; \ + .type name,@function; \ +name: \ + .cfi_startproc +#define _END(name) \ + .cfi_endproc; \ + .size name, . - name + +#define _NAKED_ENTRY(name) _ENTRY(name) + +#define LOAD_ADDR(reg, var) \ + lis reg, var@ha; \ + ori reg, reg, var@l; +#endif /* __powerpc64__ */ + +#if defined(PROF) || (defined(_KERNEL) && defined(GPROF)) +# ifdef __powerpc64__ +# define _PROF_PROLOGUE mflr 0; \ + std 3,48(1); \ + std 4,56(1); \ + std 5,64(1); \ + std 0,16(1); \ + stdu 1,-112(1); \ + bl _mcount; \ + nop; \ + ld 0,112+16(1); \ + ld 3,112+48(1); \ + ld 4,112+56(1); \ + ld 5,112+64(1); \ + mtlr 0; \ + addi 1,1,112 +# else +# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount +# endif +#else +# define _PROF_PROLOGUE +#endif + +#define ASEND(y) _END(ASMNAME(y)) +#define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE +#define END(y) _END(CNAME(y)) +#define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE +#define GLOBAL(y) _GLOBAL(CNAME(y)) + +#define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y)) +#define ENTRY_NOPROF(y) _ENTRY(CNAME(y)) + +/* Load NIA without affecting branch prediction */ +#define LOAD_LR_NIA bcl 20, 31, .+4 + +/* + * Magic sequence to return to native endian. + * Overwrites r0 and r11. + * + * The encoding of the instruction "tdi 0, %r0, 0x48" in opposite endian + * happens to be "b . + 8". This is useful because we can write a sequence + * of instructions that can execute in either endian. + * + * Use a sequence of handcoded instructions that switches contexts to the + * instruction following the sequence, but with the correct PSL_LE bit. + * + * The same sequence works for both BE and LE because the xori will flip + * the bit to the other state, and the code only runs when running in the + * wrong endian. + * + * This sequence is NMI-reentrant. + * + * Do not change the length of this sequence without looking at the users, + * this is used in size-constrained places like the reset vector! + */ +#define RETURN_TO_NATIVE_ENDIAN \ + tdi 0, %r0, 0x48; /* Endian swapped: b . + 8 */\ + b 1f; /* Will fall through to here if correct */\ + .long 0xa600607d; /* mfmsr %r11 */\ + .long 0x00000038; /* li %r0, 0 */\ + .long 0x6401617d; /* mtmsrd %r0, 1 (L=1 EE,RI bits only) */\ + .long 0x01006b69; /* xori %r11, %r11, 0x1 (PSL_LE) */\ + .long 0xa602087c; /* mflr %r0 */\ + .long 0x05009f42; /* LOAD_LR_NIA */\ + .long 0xa6037b7d; /* 0: mtsrr1 %r11 */\ + .long 0xa602687d; /* mflr %r11 */\ + .long 0x18006b39; /* addi %r11, %r11, (1f - 0b) */\ + .long 0xa6037a7d; /* mtsrr0 %r11 */\ + .long 0xa603087c; /* mtlr %r0 */\ + .long 0x2400004c; /* rfid */\ +1: /* RETURN_TO_NATIVE_ENDIAN */ + +#define ASMSTR .asciz + +#define RCSID(x) .text; .asciz x + +#undef __FBSDID +#if !defined(lint) && !defined(STRIP_FBSDID) +#define __FBSDID(s) .ident s +#else +#define __FBSDID(s) /* nothing */ +#endif /* not lint and not STRIP_FBSDID */ + +#define WEAK_REFERENCE(sym, alias) \ + .weak alias; \ + .equ alias,sym + +#ifdef __STDC__ +#define WARN_REFERENCES(_sym,_msg) \ + .section .gnu.warning. ## _sym ; .ascii _msg ; .text +#else +#define WARN_REFERENCES(_sym,_msg) \ + .section .gnu.warning./**/_sym ; .ascii _msg ; .text +#endif /* __STDC__ */ + +#endif /* !_MACHINE_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/atomic.h b/lib/libc/include/powerpc64-freebsd-none/machine/atomic.h new file mode 100644 index 0000000000000000000000000000000000000000..6be658483ef52de99a6bee7b8a1d70c8cf99ade0 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/atomic.h @@ -0,0 +1,1183 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2008 Marcel Moolenaar + * Copyright (c) 2001 Benno Rice + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1998 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_ATOMIC_H_ +#define _MACHINE_ATOMIC_H_ + +#include + +#ifndef __powerpc64__ +#include +#endif + +/* + * The __ATOMIC_REL/ACQ() macros provide memory barriers only in conjunction + * with the atomic lXarx/stXcx. sequences below. They are not exposed outside + * of this file. See also Appendix B.2 of Book II of the architecture manual. + * + * Note that not all Book-E processors accept the light-weight sync variant. + * In particular, early models of E500 cores are known to wedge. Bank on all + * 64-bit capable CPUs to accept lwsync properly and pressimize 32-bit CPUs + * to use the heavier-weight sync. + */ + +#ifdef __powerpc64__ +#define mb() __asm __volatile("sync" : : : "memory") +#define rmb() __asm __volatile("lwsync" : : : "memory") +#define wmb() __asm __volatile("lwsync" : : : "memory") +#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") +#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") +#else +#define mb() __asm __volatile("sync" : : : "memory") +#define rmb() __asm __volatile("sync" : : : "memory") +#define wmb() __asm __volatile("sync" : : : "memory") +#define __ATOMIC_REL() __asm __volatile("sync" : : : "memory") +#define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") +#endif + +static __inline void +powerpc_lwsync(void) +{ + +#ifdef __powerpc64__ + __asm __volatile("lwsync" : : : "memory"); +#else + __asm __volatile("sync" : : : "memory"); +#endif +} + +/* + * atomic_add(p, v) + * { *p += v; } + */ + +#define __atomic_add_int(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " add %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_add_int */ + +#ifdef __powerpc64__ +#define __atomic_add_long(p, v, t) \ + __asm __volatile( \ + "1: ldarx %0, 0, %2\n" \ + " add %0, %3, %0\n" \ + " stdcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_add_long */ +#else +#define __atomic_add_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " add %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_add_long */ +#endif + +#define _ATOMIC_ADD(type) \ + static __inline void \ + atomic_add_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ + __ATOMIC_ACQ(); \ + } \ + \ + static __inline void \ + atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_REL(); \ + __atomic_add_##type(p, v, t); \ + } \ + /* _ATOMIC_ADD */ + +_ATOMIC_ADD(int) +_ATOMIC_ADD(long) + +#define atomic_add_32 atomic_add_int +#define atomic_add_acq_32 atomic_add_acq_int +#define atomic_add_rel_32 atomic_add_rel_int + +#ifdef __powerpc64__ +#define atomic_add_64 atomic_add_long +#define atomic_add_acq_64 atomic_add_acq_long +#define atomic_add_rel_64 atomic_add_rel_long + +#define atomic_add_ptr atomic_add_long +#define atomic_add_acq_ptr atomic_add_acq_long +#define atomic_add_rel_ptr atomic_add_rel_long +#else +#define atomic_add_ptr atomic_add_int +#define atomic_add_acq_ptr atomic_add_acq_int +#define atomic_add_rel_ptr atomic_add_rel_int +#endif +#undef _ATOMIC_ADD +#undef __atomic_add_long +#undef __atomic_add_int + +/* + * atomic_clear(p, v) + * { *p &= ~v; } + */ + +#define __atomic_clear_int(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " andc %0, %0, %3\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_clear_int */ + +#ifdef __powerpc64__ +#define __atomic_clear_long(p, v, t) \ + __asm __volatile( \ + "1: ldarx %0, 0, %2\n" \ + " andc %0, %0, %3\n" \ + " stdcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_clear_long */ +#else +#define __atomic_clear_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " andc %0, %0, %3\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_clear_long */ +#endif + +#define _ATOMIC_CLEAR(type) \ + static __inline void \ + atomic_clear_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ + __ATOMIC_ACQ(); \ + } \ + \ + static __inline void \ + atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_REL(); \ + __atomic_clear_##type(p, v, t); \ + } \ + /* _ATOMIC_CLEAR */ + +_ATOMIC_CLEAR(int) +_ATOMIC_CLEAR(long) + +#define atomic_clear_32 atomic_clear_int +#define atomic_clear_acq_32 atomic_clear_acq_int +#define atomic_clear_rel_32 atomic_clear_rel_int + +#ifdef __powerpc64__ +#define atomic_clear_64 atomic_clear_long +#define atomic_clear_acq_64 atomic_clear_acq_long +#define atomic_clear_rel_64 atomic_clear_rel_long + +#define atomic_clear_ptr atomic_clear_long +#define atomic_clear_acq_ptr atomic_clear_acq_long +#define atomic_clear_rel_ptr atomic_clear_rel_long +#else +#define atomic_clear_ptr atomic_clear_int +#define atomic_clear_acq_ptr atomic_clear_acq_int +#define atomic_clear_rel_ptr atomic_clear_rel_int +#endif +#undef _ATOMIC_CLEAR +#undef __atomic_clear_long +#undef __atomic_clear_int + +/* + * atomic_cmpset(p, o, n) + */ +/* TODO -- see below */ + +/* + * atomic_load_acq(p) + */ +/* TODO -- see below */ + +/* + * atomic_readandclear(p) + */ +/* TODO -- see below */ + +/* + * atomic_set(p, v) + * { *p |= v; } + */ + +#define __atomic_set_int(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " or %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_set_int */ + +#ifdef __powerpc64__ +#define __atomic_set_long(p, v, t) \ + __asm __volatile( \ + "1: ldarx %0, 0, %2\n" \ + " or %0, %3, %0\n" \ + " stdcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_set_long */ +#else +#define __atomic_set_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " or %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_set_long */ +#endif + +#define _ATOMIC_SET(type) \ + static __inline void \ + atomic_set_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ + __ATOMIC_ACQ(); \ + } \ + \ + static __inline void \ + atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_REL(); \ + __atomic_set_##type(p, v, t); \ + } \ + /* _ATOMIC_SET */ + +_ATOMIC_SET(int) +_ATOMIC_SET(long) + +#define atomic_set_32 atomic_set_int +#define atomic_set_acq_32 atomic_set_acq_int +#define atomic_set_rel_32 atomic_set_rel_int + +#ifdef __powerpc64__ +#define atomic_set_64 atomic_set_long +#define atomic_set_acq_64 atomic_set_acq_long +#define atomic_set_rel_64 atomic_set_rel_long + +#define atomic_set_ptr atomic_set_long +#define atomic_set_acq_ptr atomic_set_acq_long +#define atomic_set_rel_ptr atomic_set_rel_long +#else +#define atomic_set_ptr atomic_set_int +#define atomic_set_acq_ptr atomic_set_acq_int +#define atomic_set_rel_ptr atomic_set_rel_int +#endif +#undef _ATOMIC_SET +#undef __atomic_set_long +#undef __atomic_set_int + +/* + * atomic_subtract(p, v) + * { *p -= v; } + */ + +#define __atomic_subtract_int(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " subf %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_subtract_int */ + +#ifdef __powerpc64__ +#define __atomic_subtract_long(p, v, t) \ + __asm __volatile( \ + "1: ldarx %0, 0, %2\n" \ + " subf %0, %3, %0\n" \ + " stdcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_subtract_long */ +#else +#define __atomic_subtract_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " subf %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cr0", "memory") \ + /* __atomic_subtract_long */ +#endif + +#define _ATOMIC_SUBTRACT(type) \ + static __inline void \ + atomic_subtract_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + __ATOMIC_ACQ(); \ + } \ + \ + static __inline void \ + atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_REL(); \ + __atomic_subtract_##type(p, v, t); \ + } \ + /* _ATOMIC_SUBTRACT */ + +_ATOMIC_SUBTRACT(int) +_ATOMIC_SUBTRACT(long) + +#define atomic_subtract_32 atomic_subtract_int +#define atomic_subtract_acq_32 atomic_subtract_acq_int +#define atomic_subtract_rel_32 atomic_subtract_rel_int + +#ifdef __powerpc64__ +#define atomic_subtract_64 atomic_subtract_long +#define atomic_subtract_acq_64 atomic_subract_acq_long +#define atomic_subtract_rel_64 atomic_subtract_rel_long + +#define atomic_subtract_ptr atomic_subtract_long +#define atomic_subtract_acq_ptr atomic_subtract_acq_long +#define atomic_subtract_rel_ptr atomic_subtract_rel_long +#else +#define atomic_subtract_ptr atomic_subtract_int +#define atomic_subtract_acq_ptr atomic_subtract_acq_int +#define atomic_subtract_rel_ptr atomic_subtract_rel_int +#endif +#undef _ATOMIC_SUBTRACT +#undef __atomic_subtract_long +#undef __atomic_subtract_int + +/* + * atomic_store_rel(p, v) + */ +/* TODO -- see below */ + +/* + * Old/original implementations that still need revisiting. + */ + +static __inline u_int +atomic_readandclear_int(volatile u_int *addr) +{ + u_int result,temp; + + __asm __volatile ( + "\tsync\n" /* drain writes */ + "1:\tlwarx %0, 0, %3\n\t" /* load old value */ + "li %1, 0\n\t" /* load new value */ + "stwcx. %1, 0, %3\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + : "=&r"(result), "=&r"(temp), "=m" (*addr) + : "r" (addr), "m" (*addr) + : "cr0", "memory"); + + return (result); +} + +#ifdef __powerpc64__ +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) +{ + u_long result,temp; + + __asm __volatile ( + "\tsync\n" /* drain writes */ + "1:\tldarx %0, 0, %3\n\t" /* load old value */ + "li %1, 0\n\t" /* load new value */ + "stdcx. %1, 0, %3\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + : "=&r"(result), "=&r"(temp), "=m" (*addr) + : "r" (addr), "m" (*addr) + : "cr0", "memory"); + + return (result); +} +#endif + +#define atomic_readandclear_32 atomic_readandclear_int + +#ifdef __powerpc64__ +#define atomic_readandclear_64 atomic_readandclear_long + +#define atomic_readandclear_ptr atomic_readandclear_long +#else +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) +{ + + return ((u_long)atomic_readandclear_int((volatile u_int *)addr)); +} + +#define atomic_readandclear_ptr atomic_readandclear_int +#endif + +/* + * We assume that a = b will do atomic loads and stores. + */ +#define ATOMIC_STORE_LOAD(TYPE) \ +static __inline u_##TYPE \ +atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \ +{ \ + u_##TYPE v; \ + \ + v = *p; \ + powerpc_lwsync(); \ + return (v); \ +} \ + \ +static __inline void \ +atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \ +{ \ + \ + powerpc_lwsync(); \ + *p = v; \ +} + +ATOMIC_STORE_LOAD(int) + +#define atomic_load_acq_32 atomic_load_acq_int +#define atomic_store_rel_32 atomic_store_rel_int + +#ifdef __powerpc64__ +ATOMIC_STORE_LOAD(long) + +#define atomic_load_acq_64 atomic_load_acq_long +#define atomic_store_rel_64 atomic_store_rel_long + +#define atomic_load_acq_ptr atomic_load_acq_long +#define atomic_store_rel_ptr atomic_store_rel_long +#else +static __inline u_long +atomic_load_acq_long(const volatile u_long *addr) +{ + + return ((u_long)atomic_load_acq_int((const volatile u_int *)addr)); +} + +static __inline void +atomic_store_rel_long(volatile u_long *addr, u_long val) +{ + + atomic_store_rel_int((volatile u_int *)addr, (u_int)val); +} + +#define atomic_load_acq_ptr atomic_load_acq_int +#define atomic_store_rel_ptr atomic_store_rel_int +#endif +#undef ATOMIC_STORE_LOAD + +/* + * Atomically compare the value stored at *p with cmpval and if the + * two values are equal, update the value of *p with newval. Returns + * zero if the compare failed, nonzero otherwise. + */ +#ifdef ISA_206_ATOMICS +static __inline int +atomic_cmpset_char(volatile u_char *p, u_char cmpval, u_char newval) +{ + int ret; + + __asm __volatile ( + "1:\tlbarx %0, 0, %2\n\t" /* load old value */ + "cmplw %3, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "stbcx. %4, 0, %2\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + "stbcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) + : "cr0", "memory"); + + return (ret); +} + +static __inline int +atomic_cmpset_short(volatile u_short *p, u_short cmpval, u_short newval) +{ + int ret; + + __asm __volatile ( + "1:\tlharx %0, 0, %2\n\t" /* load old value */ + "cmplw %3, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "sthcx. %4, 0, %2\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + "sthcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) + : "cr0", "memory"); + + return (ret); +} +#else +static __inline int +atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval, + uint32_t mask) +{ + int ret; + uint32_t tmp; + + __asm __volatile ( + "1:\tlwarx %2, 0, %3\n\t" /* load old value */ + "and %0, %2, %7\n\t" + "cmplw %4, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "andc %2, %2, %7\n\t" + "or %2, %2, %5\n\t" + "stwcx. %2, 0, %3\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + "stwcx. %2, 0, %3\n\t" /* clear reservation (74xx) */ + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p), "+&r" (tmp) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p), + "r" (mask) + : "cr0", "memory"); + + return (ret); +} + +#define _atomic_cmpset_masked_word(a,o,v,m) atomic_cmpset_masked(a, o, v, m) +#endif + +static __inline int +atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) +{ + int ret; + + __asm __volatile ( + "1:\tlwarx %0, 0, %2\n\t" /* load old value */ + "cmplw %3, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "stwcx. %4, 0, %2\n\t" /* attempt to store */ + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) + : "cr0", "memory"); + + return (ret); +} +static __inline int +atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) +{ + int ret; + + __asm __volatile ( + #ifdef __powerpc64__ + "1:\tldarx %0, 0, %2\n\t" /* load old value */ + "cmpld %3, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "stdcx. %4, 0, %2\n\t" /* attempt to store */ + #else + "1:\tlwarx %0, 0, %2\n\t" /* load old value */ + "cmplw %3, %0\n\t" /* compare */ + "bne- 2f\n\t" /* exit if not equal */ + "stwcx. %4, 0, %2\n\t" /* attempt to store */ + #endif + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + #ifdef __powerpc64__ + "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + #else + "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + #endif + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) + : "cr0", "memory"); + + return (ret); +} + +#define ATOMIC_CMPSET_ACQ_REL(type) \ + static __inline int \ + atomic_cmpset_acq_##type(volatile u_##type *p, \ + u_##type cmpval, u_##type newval)\ + {\ + u_##type retval; \ + retval = atomic_cmpset_##type(p, cmpval, newval);\ + __ATOMIC_ACQ();\ + return (retval);\ + }\ + static __inline int \ + atomic_cmpset_rel_##type(volatile u_##type *p, \ + u_##type cmpval, u_##type newval)\ + {\ + __ATOMIC_REL();\ + return (atomic_cmpset_##type(p, cmpval, newval));\ + }\ + struct hack + +ATOMIC_CMPSET_ACQ_REL(int); +ATOMIC_CMPSET_ACQ_REL(long); + +#ifdef ISA_206_ATOMICS +#define atomic_cmpset_8 atomic_cmpset_char +#endif +#define atomic_cmpset_acq_8 atomic_cmpset_acq_char +#define atomic_cmpset_rel_8 atomic_cmpset_rel_char + +#ifdef ISA_206_ATOMICS +#define atomic_cmpset_16 atomic_cmpset_short +#endif +#define atomic_cmpset_acq_16 atomic_cmpset_acq_short +#define atomic_cmpset_rel_16 atomic_cmpset_rel_short + +#define atomic_cmpset_32 atomic_cmpset_int +#define atomic_cmpset_acq_32 atomic_cmpset_acq_int +#define atomic_cmpset_rel_32 atomic_cmpset_rel_int + +#ifdef __powerpc64__ +#define atomic_cmpset_64 atomic_cmpset_long +#define atomic_cmpset_acq_64 atomic_cmpset_acq_long +#define atomic_cmpset_rel_64 atomic_cmpset_rel_long + +#define atomic_cmpset_ptr atomic_cmpset_long +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long +#else +#define atomic_cmpset_ptr atomic_cmpset_int +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int +#endif + +/* + * Atomically compare the value stored at *p with *cmpval and if the + * two values are equal, update the value of *p with newval. Returns + * zero if the compare failed and sets *cmpval to the read value from *p, + * nonzero otherwise. + */ +#ifdef ISA_206_ATOMICS +static __inline int +atomic_fcmpset_char(volatile u_char *p, u_char *cmpval, u_char newval) +{ + int ret; + + __asm __volatile ( + "lbarx %0, 0, %3\n\t" /* load old value */ + "cmplw %4, %0\n\t" /* compare */ + "bne- 1f\n\t" /* exit if not equal */ + "stbcx. %5, 0, %3\n\t" /* attempt to store */ + "bne- 1f\n\t" /* exit if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 2f\n\t" /* we've succeeded */ + "1:\n\t" + "stbcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ + "stbx %0, 0, %7\n\t" + "li %0, 0\n\t" /* failure - retval = 0 */ + "2:\n\t" + : "=&r" (ret), "=m" (*p), "=m" (*cmpval) + : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) + : "cr0", "memory"); + + return (ret); +} + +static __inline int +atomic_fcmpset_short(volatile u_short *p, u_short *cmpval, u_short newval) +{ + int ret; + + __asm __volatile ( + "lharx %0, 0, %3\n\t" /* load old value */ + "cmplw %4, %0\n\t" /* compare */ + "bne- 1f\n\t" /* exit if not equal */ + "sthcx. %5, 0, %3\n\t" /* attempt to store */ + "bne- 1f\n\t" /* exit if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 2f\n\t" /* we've succeeded */ + "1:\n\t" + "sthcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ + "sthx %0, 0, %7\n\t" + "li %0, 0\n\t" /* failure - retval = 0 */ + "2:\n\t" + : "=&r" (ret), "=m" (*p), "=m" (*cmpval) + : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) + : "cr0", "memory"); + + return (ret); +} +#endif /* ISA_206_ATOMICS */ + +static __inline int +atomic_fcmpset_int(volatile u_int *p, u_int *cmpval, u_int newval) +{ + int ret; + + __asm __volatile ( + "lwarx %0, 0, %3\n\t" /* load old value */ + "cmplw %4, %0\n\t" /* compare */ + "bne- 1f\n\t" /* exit if not equal */ + "stwcx. %5, 0, %3\n\t" /* attempt to store */ + "bne- 1f\n\t" /* exit if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 2f\n\t" /* we've succeeded */ + "1:\n\t" + "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ + "stwx %0, 0, %7\n\t" + "li %0, 0\n\t" /* failure - retval = 0 */ + "2:\n\t" + : "=&r" (ret), "=m" (*p), "=m" (*cmpval) + : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) + : "cr0", "memory"); + + return (ret); +} +static __inline int +atomic_fcmpset_long(volatile u_long *p, u_long *cmpval, u_long newval) +{ + int ret; + + __asm __volatile ( + #ifdef __powerpc64__ + "ldarx %0, 0, %3\n\t" /* load old value */ + "cmpld %4, %0\n\t" /* compare */ + "bne- 1f\n\t" /* exit if not equal */ + "stdcx. %5, 0, %3\n\t" /* attempt to store */ + #else + "lwarx %0, 0, %3\n\t" /* load old value */ + "cmplw %4, %0\n\t" /* compare */ + "bne- 1f\n\t" /* exit if not equal */ + "stwcx. %5, 0, %3\n\t" /* attempt to store */ + #endif + "bne- 1f\n\t" /* exit if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 2f\n\t" /* we've succeeded */ + "1:\n\t" + #ifdef __powerpc64__ + "stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ + "stdx %0, 0, %7\n\t" + #else + "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ + "stwx %0, 0, %7\n\t" + #endif + "li %0, 0\n\t" /* failure - retval = 0 */ + "2:\n\t" + : "=&r" (ret), "=m" (*p), "=m" (*cmpval) + : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) + : "cr0", "memory"); + + return (ret); +} + +#define ATOMIC_FCMPSET_ACQ_REL(type) \ + static __inline int \ + atomic_fcmpset_acq_##type(volatile u_##type *p, \ + u_##type *cmpval, u_##type newval)\ + {\ + u_##type retval; \ + retval = atomic_fcmpset_##type(p, cmpval, newval);\ + __ATOMIC_ACQ();\ + return (retval);\ + }\ + static __inline int \ + atomic_fcmpset_rel_##type(volatile u_##type *p, \ + u_##type *cmpval, u_##type newval)\ + {\ + __ATOMIC_REL();\ + return (atomic_fcmpset_##type(p, cmpval, newval));\ + }\ + struct hack + +ATOMIC_FCMPSET_ACQ_REL(int); +ATOMIC_FCMPSET_ACQ_REL(long); + +#ifdef ISA_206_ATOMICS +#define atomic_fcmpset_8 atomic_fcmpset_char +#endif +#define atomic_fcmpset_acq_8 atomic_fcmpset_acq_char +#define atomic_fcmpset_rel_8 atomic_fcmpset_rel_char + +#ifdef ISA_206_ATOMICS +#define atomic_fcmpset_16 atomic_fcmpset_short +#endif +#define atomic_fcmpset_acq_16 atomic_fcmpset_acq_short +#define atomic_fcmpset_rel_16 atomic_fcmpset_rel_short + +#define atomic_fcmpset_32 atomic_fcmpset_int +#define atomic_fcmpset_acq_32 atomic_fcmpset_acq_int +#define atomic_fcmpset_rel_32 atomic_fcmpset_rel_int + +#ifdef __powerpc64__ +#define atomic_fcmpset_64 atomic_fcmpset_long +#define atomic_fcmpset_acq_64 atomic_fcmpset_acq_long +#define atomic_fcmpset_rel_64 atomic_fcmpset_rel_long + +#define atomic_fcmpset_ptr atomic_fcmpset_long +#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long +#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long +#else +#define atomic_fcmpset_ptr atomic_fcmpset_int +#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_int +#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_int +#endif + +static __inline u_int +atomic_fetchadd_int(volatile u_int *p, u_int v) +{ + u_int value; + + do { + value = *p; + } while (!atomic_cmpset_int(p, value, value + v)); + return (value); +} + +static __inline u_long +atomic_fetchadd_long(volatile u_long *p, u_long v) +{ + u_long value; + + do { + value = *p; + } while (!atomic_cmpset_long(p, value, value + v)); + return (value); +} + +static __inline u_int +atomic_swap_32(volatile u_int *p, u_int v) +{ + u_int prev; + + __asm __volatile( + "1: lwarx %0,0,%2\n" + " stwcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_int *)p) + : "r" (p), "r" (v) + : "cr0", "memory"); + + return (prev); +} + +#ifdef __powerpc64__ +static __inline u_long +atomic_swap_64(volatile u_long *p, u_long v) +{ + u_long prev; + + __asm __volatile( + "1: ldarx %0,0,%2\n" + " stdcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_long *)p) + : "r" (p), "r" (v) + : "cr0", "memory"); + + return (prev); +} +#endif + +#define atomic_fetchadd_32 atomic_fetchadd_int +#define atomic_swap_int atomic_swap_32 + +#ifdef __powerpc64__ +#define atomic_fetchadd_64 atomic_fetchadd_long +#define atomic_swap_long atomic_swap_64 +#define atomic_swap_ptr atomic_swap_64 +#else +#define atomic_swap_long(p,v) atomic_swap_32((volatile u_int *)(p), v) +#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v) +#endif + +static __inline int +atomic_testandset_int(volatile u_int *p, u_int v) +{ + u_int m = (1u << (v & 0x1f)); + u_int res; + u_int tmp; + + __asm __volatile( + "1: lwarx %0,0,%3\n" + " and %1,%0,%4\n" + " or %0,%0,%4\n" + " stwcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +static __inline int +atomic_testandclear_int(volatile u_int *p, u_int v) +{ + u_int m = (1u << (v & 0x1f)); + u_int res; + u_int tmp; + + __asm __volatile( + "1: lwarx %0,0,%3\n" + " and %1,%0,%4\n" + " andc %0,%0,%4\n" + " stwcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +#ifdef __powerpc64__ +static __inline int +atomic_testandset_long(volatile u_long *p, u_int v) +{ + u_long m = (1ul << (v & 0x3f)); + u_long res; + u_long tmp; + + __asm __volatile( + "1: ldarx %0,0,%3\n" + " and %1,%0,%4\n" + " or %0,%0,%4\n" + " stdcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} + +static __inline int +atomic_testandclear_long(volatile u_long *p, u_int v) +{ + u_long m = (1ul << (v & 0x3f)); + u_long res; + u_long tmp; + + __asm __volatile( + "1: ldarx %0,0,%3\n" + " and %1,%0,%4\n" + " andc %0,%0,%4\n" + " stdcx. %0,0,%3\n" + " bne- 1b\n" + : "=&r"(tmp), "=&r"(res), "+m"(*p) + : "r"(p), "r"(m) + : "cr0", "memory"); + + return (res != 0); +} +#else +static __inline int +atomic_testandset_long(volatile u_long *p, u_int v) +{ + return (atomic_testandset_int((volatile u_int *)p, v)); +} + +static __inline int +atomic_testandclear_long(volatile u_long *p, u_int v) +{ + return (atomic_testandclear_int((volatile u_int *)p, v)); +} +#endif + +#define atomic_testandclear_32 atomic_testandclear_int +#define atomic_testandset_32 atomic_testandset_int + +static __inline int +atomic_testandset_acq_long(volatile u_long *p, u_int v) +{ + u_int a = atomic_testandset_long(p, v); + __ATOMIC_ACQ(); + return (a); +} + +#ifdef __powerpc64__ +#define atomic_testandclear_ptr atomic_testandclear_long +#define atomic_testandset_ptr atomic_testandset_long +#else +#define atomic_testandclear_ptr(p,v) \ + atomic_testandclear_32((volatile u_int *)(p), v) +#define atomic_testandset_ptr(p,v) \ + atomic_testandset_32((volatile u_int *)(p), v) +#endif + +static __inline void +atomic_thread_fence_acq(void) +{ + + powerpc_lwsync(); +} + +static __inline void +atomic_thread_fence_rel(void) +{ + + powerpc_lwsync(); +} + +static __inline void +atomic_thread_fence_acq_rel(void) +{ + + powerpc_lwsync(); +} + +static __inline void +atomic_thread_fence_seq_cst(void) +{ + + __asm __volatile("sync" : : : "memory"); +} + +#ifndef ISA_206_ATOMICS +#include +#define atomic_cmpset_char atomic_cmpset_8 +#define atomic_cmpset_short atomic_cmpset_16 +#define atomic_fcmpset_char atomic_fcmpset_8 +#define atomic_fcmpset_short atomic_fcmpset_16 +#define atomic_set_short atomic_set_16 +#define atomic_clear_short atomic_clear_16 +#else + +static __inline void +atomic_set_short(volatile u_short *p, u_short bit) +{ + u_short v; + + v = atomic_load_short(p); + for (;;) { + if (atomic_fcmpset_16(p, &v, v | bit)) + break; + } +} + +static __inline void +atomic_clear_short(volatile u_short *p, u_short bit) +{ + u_short v; + + v = atomic_load_short(p); + for (;;) { + if (atomic_fcmpset_16(p, &v, v & ~bit)) + break; + } +} + +#define atomic_set_16 atomic_set_short +#define atomic_clear_16 atomic_clear_short + +#endif /* ISA_206_ATOMICS */ + +/* These need sys/_atomic_subword.h on non-ISA-2.06-atomic platforms. */ +ATOMIC_CMPSET_ACQ_REL(char); +ATOMIC_CMPSET_ACQ_REL(short); + +ATOMIC_FCMPSET_ACQ_REL(char); +ATOMIC_FCMPSET_ACQ_REL(short); + +#undef __ATOMIC_REL +#undef __ATOMIC_ACQ + +#endif /* ! _MACHINE_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/bat.h b/lib/libc/include/powerpc64-freebsd-none/machine/bat.h new file mode 100644 index 0000000000000000000000000000000000000000..69f74286c2f40d8fd7bd2a604240fa4b3bbb64e1 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/bat.h @@ -0,0 +1,167 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause + * + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: bat.h,v 1.2 1999/12/18 01:36:06 thorpej Exp $ + */ + +#ifndef _MACHINE_BAT_H_ +#define _MACHINE_BAT_H_ + +#ifndef LOCORE +struct bat { + u_int32_t batu; + u_int32_t batl; +}; +#endif + +/* Lower BAT bits (all but PowerPC 601): */ +#define BAT_PBS 0xfffe0000 /* physical block start */ +#define BAT_W 0x00000040 /* 1 = write-through, 0 = write-back */ +#define BAT_I 0x00000020 /* cache inhibit */ +#define BAT_M 0x00000010 /* memory coherency enable */ +#define BAT_G 0x00000008 /* guarded region */ + +#define BAT_PP_NONE 0x00000000 /* no access permission */ +#define BAT_PP_RO_S 0x00000001 /* read-only (soft) */ +#define BAT_PP_RW 0x00000002 /* read/write */ +#define BAT_PP_RO 0x00000003 /* read-only */ + +/* Upper BAT bits (all but PowerPC 601): */ +#define BAT_EBS 0xfffe0000 /* effective block start */ +#define BAT_BL 0x00001ffc /* block length */ +#define BAT_Vs 0x00000002 /* valid in supervisor mode */ +#define BAT_Vu 0x00000001 /* valid in user mode */ + +#define BAT_V (BAT_Vs|BAT_Vu) + +/* Block Length encoding (all but PowerPC 601): */ +#define BAT_BL_128K 0x00000000 +#define BAT_BL_256K 0x00000004 +#define BAT_BL_512K 0x0000000c +#define BAT_BL_1M 0x0000001c +#define BAT_BL_2M 0x0000003c +#define BAT_BL_4M 0x0000007c +#define BAT_BL_8M 0x000000fc +#define BAT_BL_16M 0x000001fc +#define BAT_BL_32M 0x000003fc +#define BAT_BL_64M 0x000007fc +#define BAT_BL_128M 0x00000ffc +#define BAT_BL_256M 0x00001ffc + +#define BATU(va, len, v) \ + (((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V)) + +#define BATL(pa, wimg, pp) \ + (((pa) & BAT_PBS) | (wimg) | (pp)) + +/* Lower BAT bits (PowerPC 601): */ +#define BAT601_PBN 0xfffe0000 /* physical block number */ +#define BAT601_V 0x00000040 /* valid */ +#define BAT601_BSM 0x0000003f /* block size mask */ + +/* Upper BAT bits (PowerPC 601): */ +#define BAT601_BLPI 0xfffe0000 /* block logical page index */ +#define BAT601_W 0x00000040 /* 1 = write-through, 0 = write-back */ +#define BAT601_I 0x00000020 /* cache inhibit */ +#define BAT601_M 0x00000010 /* memory coherency enable */ +#define BAT601_Ks 0x00000008 /* key-supervisor */ +#define BAT601_Ku 0x00000004 /* key-user */ + +/* + * Permission bits on the PowerPC 601 are modified by the appropriate + * Key bit: + * + * Key PP Access + * 0 NONE read/write + * 0 RO_S read/write + * 0 RW read/write + * 0 RO read-only + * + * 1 NONE none + * 1 RO_S read-only + * 1 RW read/write + * 1 RO read-only + */ +#define BAT601_PP_NONE 0x00000000 /* no access permission */ +#define BAT601_PP_RO_S 0x00000001 /* read-only (soft) */ +#define BAT601_PP_RW 0x00000002 /* read/write */ +#define BAT601_PP_RO 0x00000003 /* read-only */ + +/* Block Size Mask encoding (PowerPC 601): */ +#define BAT601_BSM_128K 0x00000000 +#define BAT601_BSM_256K 0x00000001 +#define BAT601_BSM_512K 0x00000003 +#define BAT601_BSM_1M 0x00000007 +#define BAT601_BSM_2M 0x0000000f +#define BAT601_BSM_4M 0x0000001f +#define BAT601_BSM_8M 0x0000003f + +#define BATU601(va, wim, key, pp) \ + (((va) & BAT601_BLPI) | (wim) | (key) | (pp)) + +#define BATL601(pa, size, v) \ + (((pa) & BAT601_PBN) | (v) | (size)) + +#if defined(_KERNEL) && !defined(LOCORE) +extern struct bat battable[16]; +#endif + +#endif /* _MACHINE_BAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/bus.h b/lib/libc/include/powerpc64-freebsd-none/machine/bus.h new file mode 100644 index 0000000000000000000000000000000000000000..74b14ddfd53ed7e5ed8963b0c84bf214daad7390 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/bus.h @@ -0,0 +1,493 @@ +/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ + +/*- + * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause + * + * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*- + * Copyright (c) 1996 Charles M. Hannum. All rights reserved. + * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou + * for the NetBSD Project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_BUS_H_ +#define _MACHINE_BUS_H_ + +#include + +#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) + +#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL +#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL +#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL +#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL + +#ifdef __powerpc64__ +#define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL +#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL +#else +#ifdef BOOKE +#define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL +#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL +#else +#define BUS_SPACE_MAXADDR 0xFFFFFFFFUL +#define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL +#endif +#endif + +#define BUS_SPACE_MAP_CACHEABLE 0x01 +#define BUS_SPACE_MAP_LINEAR 0x02 +#define BUS_SPACE_MAP_PREFETCHABLE 0x04 + +#define BUS_SPACE_UNRESTRICTED (~0) + +#define BUS_SPACE_BARRIER_READ 0x01 +#define BUS_SPACE_BARRIER_WRITE 0x02 + +struct bus_space_access; + +struct bus_space { + /* mapping/unmapping */ + int (*bs_map)(bus_addr_t, bus_size_t, int, + bus_space_handle_t *); + void (*bs_unmap)(bus_space_handle_t, bus_size_t); + int (*bs_subregion)(bus_space_handle_t, bus_size_t, + bus_size_t, bus_space_handle_t *); + + /* allocation/deallocation */ + int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t, + bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *); + void (*bs_free)(bus_space_handle_t, bus_size_t); + + void (*bs_barrier)(bus_space_handle_t, bus_size_t, + bus_size_t, int); + + /* Read single. */ + uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t); + uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t); + uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t); + uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t); + + uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t); + uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t); + uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t); + + /* read multiple */ + void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *, + bus_size_t); + void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *, + bus_size_t); + void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *, + bus_size_t); + void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *, + bus_size_t); + + void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, + bus_size_t); + void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, + bus_size_t); + void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, + bus_size_t); + + /* read region */ + void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *, + bus_size_t); + void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *, + bus_size_t); + void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *, + bus_size_t); + void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *, + bus_size_t); + + void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, + bus_size_t); + void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, + bus_size_t); + void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, + bus_size_t); + + /* write */ + void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t); + void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t); + void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t); + void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t); + + void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t); + void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t); + void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t); + + /* write multiple */ + void (*bs_wm_1)(bus_space_handle_t, bus_size_t, + const uint8_t *, bus_size_t); + void (*bs_wm_2)(bus_space_handle_t, bus_size_t, + const uint16_t *, bus_size_t); + void (*bs_wm_4)(bus_space_handle_t, bus_size_t, + const uint32_t *, bus_size_t); + void (*bs_wm_8)(bus_space_handle_t, bus_size_t, + const uint64_t *, bus_size_t); + + void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t, + const uint16_t *, bus_size_t); + void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t, + const uint32_t *, bus_size_t); + void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t, + const uint64_t *, bus_size_t); + + /* write region */ + void (*bs_wr_1)(bus_space_handle_t, bus_size_t, + const uint8_t *, bus_size_t); + void (*bs_wr_2)(bus_space_handle_t, bus_size_t, + const uint16_t *, bus_size_t); + void (*bs_wr_4)(bus_space_handle_t, bus_size_t, + const uint32_t *, bus_size_t); + void (*bs_wr_8)(bus_space_handle_t, bus_size_t, + const uint64_t *, bus_size_t); + + void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t, + const uint16_t *, bus_size_t); + void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t, + const uint32_t *, bus_size_t); + void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t, + const uint64_t *, bus_size_t); + + /* set multiple */ + void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t, + bus_size_t); + void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t, + bus_size_t); + void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t, + bus_size_t); + void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t, + bus_size_t); + + void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t, + bus_size_t); + void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t, + bus_size_t); + void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t, + bus_size_t); + + /* set region */ + void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t, + bus_size_t); + void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t, + bus_size_t); + void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t, + bus_size_t); + void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t, + bus_size_t); + + void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t, + bus_size_t); + void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t, + bus_size_t); + void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t, + bus_size_t); + + /* copy region */ + void (*bs_cr_1)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*bs_cr_2)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*bs_cr_4)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*bs_cr_8)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + + void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); + void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t, + bus_space_handle_t, bus_size_t, bus_size_t); +}; + +extern struct bus_space bs_be_tag; +extern struct bus_space bs_le_tag; + +#define __bs_c(a,b) __CONCAT(a,b) +#define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) + +#define __bs_rs(sz, t, h, o) \ + (*(t)->__bs_opname(r,sz))(h, o) +#define __bs_ws(sz, t, h, o, v) \ + (*(t)->__bs_opname(w,sz))(h, o, v) +#define __bs_nonsingle(type, sz, t, h, o, a, c) \ + (*(t)->__bs_opname(type,sz))(h, o, a, c) +#define __bs_set(type, sz, t, h, o, v, c) \ + (*(t)->__bs_opname(type,sz))(h, o, v, c) +#define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ + (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt) + +/* + * Mapping and unmapping operations. + */ +#define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp) +#define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s) +#define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp) + +/* + * Allocation and deallocation operations. + */ +#define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ + (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp) +#define bus_space_free(t, h, s) \ + (*(t)->bs_free)(h, s) + +/* + * Bus barrier operations. + */ +#define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f) + +/* + * Bus read (single) operations. + */ +#define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o) +#define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o) +#define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o) +#define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o) + +#define bus_space_read_stream_1 bus_space_read_1 +#define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o) +#define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o) +#define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o) + +/* + * Bus read multiple operations. + */ +#define bus_space_read_multi_1(t, h, o, a, c) \ + __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_2(t, h, o, a, c) \ + __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_4(t, h, o, a, c) \ + __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_8(t, h, o, a, c) \ + __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) + +#define bus_space_read_multi_stream_1 bus_space_read_multi_1 +#define bus_space_read_multi_stream_2(t, h, o, a, c) \ + __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_stream_4(t, h, o, a, c) \ + __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c)) +#define bus_space_read_multi_stream_8(t, h, o, a, c) \ + __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c)) + +/* + * Bus read region operations. + */ +#define bus_space_read_region_1(t, h, o, a, c) \ + __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) +#define bus_space_read_region_2(t, h, o, a, c) \ + __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) +#define bus_space_read_region_4(t, h, o, a, c) \ + __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) +#define bus_space_read_region_8(t, h, o, a, c) \ + __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) + +#define bus_space_read_region_stream_1 bus_space_read_region_1 +#define bus_space_read_region_stream_2(t, h, o, a, c) \ + __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c)) +#define bus_space_read_region_stream_4(t, h, o, a, c) \ + __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c)) +#define bus_space_read_region_stream_8(t, h, o, a, c) \ + __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c)) + +/* + * Bus write (single) operations. + */ +#define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) +#define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) +#define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) +#define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) + +#define bus_space_write_stream_1 bus_space_write_1 +#define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v)) +#define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v)) +#define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v)) + +/* + * Bus write multiple operations. + */ +#define bus_space_write_multi_1(t, h, o, a, c) \ + __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_2(t, h, o, a, c) \ + __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_4(t, h, o, a, c) \ + __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_8(t, h, o, a, c) \ + __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) + +#define bus_space_write_multi_stream_1 bus_space_write_multi_1 +#define bus_space_write_multi_stream_2(t, h, o, a, c) \ + __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_stream_4(t, h, o, a, c) \ + __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c)) +#define bus_space_write_multi_stream_8(t, h, o, a, c) \ + __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c)) + +/* + * Bus write region operations. + */ +#define bus_space_write_region_1(t, h, o, a, c) \ + __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) +#define bus_space_write_region_2(t, h, o, a, c) \ + __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) +#define bus_space_write_region_4(t, h, o, a, c) \ + __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) +#define bus_space_write_region_8(t, h, o, a, c) \ + __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) + +#define bus_space_write_region_stream_1 bus_space_write_region_1 +#define bus_space_write_region_stream_2(t, h, o, a, c) \ + __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c)) +#define bus_space_write_region_stream_4(t, h, o, a, c) \ + __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c)) +#define bus_space_write_region_stream_8(t, h, o, a, c) \ + __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c)) + +/* + * Set multiple operations. + */ +#define bus_space_set_multi_1(t, h, o, v, c) \ + __bs_set(sm,1,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_2(t, h, o, v, c) \ + __bs_set(sm,2,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_4(t, h, o, v, c) \ + __bs_set(sm,4,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_8(t, h, o, v, c) \ + __bs_set(sm,8,(t),(h),(o),(v),(c)) + +#define bus_space_set_multi_stream_1 bus_space_set_multi_1 +#define bus_space_set_multi_stream_2(t, h, o, v, c) \ + __bs_set(sm,s_2,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_stream_4(t, h, o, v, c) \ + __bs_set(sm,s_4,(t),(h),(o),(v),(c)) +#define bus_space_set_multi_stream_8(t, h, o, v, c) \ + __bs_set(sm,s_8,(t),(h),(o),(v),(c)) + +/* + * Set region operations. + */ +#define bus_space_set_region_1(t, h, o, v, c) \ + __bs_set(sr,1,(t),(h),(o),(v),(c)) +#define bus_space_set_region_2(t, h, o, v, c) \ + __bs_set(sr,2,(t),(h),(o),(v),(c)) +#define bus_space_set_region_4(t, h, o, v, c) \ + __bs_set(sr,4,(t),(h),(o),(v),(c)) +#define bus_space_set_region_8(t, h, o, v, c) \ + __bs_set(sr,8,(t),(h),(o),(v),(c)) + +#define bus_space_set_region_stream_1 bus_space_set_region_1 +#define bus_space_set_region_stream_2(t, h, o, v, c) \ + __bs_set(sr,s_2,(t),(h),(o),(v),(c)) +#define bus_space_set_region_stream_4(t, h, o, v, c) \ + __bs_set(sr,s_4,(t),(h),(o),(v),(c)) +#define bus_space_set_region_stream_8(t, h, o, v, c) \ + __bs_set(sr,s_8,(t),(h),(o),(v),(c)) + +#if 0 +/* + * Copy operations. + */ +#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ + __bs_copy(1, t, h1, o1, h2, o2, c) +#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ + __bs_copy(2, t, h1, o1, h2, o2, c) +#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ + __bs_copy(4, t, h1, o1, h2, o2, c) +#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ + __bs_copy(8, t, h1, o1, h2, o2, c) + +#define bus_space_copy_region_stream_1 bus_space_copy_region_1 +#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \ + __bs_copy(s_2, t, h1, o1, h2, o2, c) +#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \ + __bs_copy(s_4, t, h1, o1, h2, o2, c) +#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \ + __bs_copy(s_8, t, h1, o1, h2, o2, c) +#endif + +#define BUS_PEEK_FUNC(width, type) \ + static inline int \ + bus_space_peek_##width(bus_space_tag_t tag, \ + bus_space_handle_t hnd, bus_size_t offset, type *value) \ + { \ + type tmp; \ + tmp = bus_space_read_##width(tag, hnd, offset); \ + *value = (type)tmp; \ + return (0); \ + } +BUS_PEEK_FUNC(1, uint8_t) +BUS_PEEK_FUNC(2, uint16_t) +BUS_PEEK_FUNC(4, uint32_t) +BUS_PEEK_FUNC(8, uint64_t) + +#define BUS_POKE_FUNC(width, type) \ + static inline int \ + bus_space_poke_##width(bus_space_tag_t tag, \ + bus_space_handle_t hnd, bus_size_t offset, type value) \ + { \ + bus_space_write_##width(tag, hnd, offset, value); \ + return (0); \ + } +BUS_POKE_FUNC(1, uint8_t) +BUS_POKE_FUNC(2, uint16_t) +BUS_POKE_FUNC(4, uint32_t) +BUS_POKE_FUNC(8, uint64_t) + +#include + +#endif /* _MACHINE_BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/bus_dma.h b/lib/libc/include/powerpc64-freebsd-none/machine/bus_dma.h new file mode 100644 index 0000000000000000000000000000000000000000..0f66234aeb045ddc37e15ed76b32b7e3d453ad3d --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/bus_dma.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2005 Scott Long + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _POWERPC_BUS_DMA_H_ +#define _POWERPC_BUS_DMA_H_ + +#include +#include + +int bus_dma_tag_set_iommu(bus_dma_tag_t, device_t iommu, void *cookie); + +#endif /* _POWERPC_BUS_DMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/clock.h b/lib/libc/include/powerpc64-freebsd-none/machine/clock.h new file mode 100644 index 0000000000000000000000000000000000000000..9998037028b5bdf81d77188d6ac564acf81c3c80 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/clock.h @@ -0,0 +1,18 @@ +/*- + * Kernel interface to machine-dependent clock driver. + * Garrett Wollman, September 1994. + * This file is in the public domain. + */ + +#ifndef _MACHINE_CLOCK_H_ +#define _MACHINE_CLOCK_H_ + +#ifdef _KERNEL + +struct trapframe; + +void decr_intr(struct trapframe *); + +#endif + +#endif /* !_MACHINE_CLOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/counter.h b/lib/libc/include/powerpc64-freebsd-none/machine/counter.h new file mode 100644 index 0000000000000000000000000000000000000000..b996a3d07e2c1575e757bc7d9beed59add322374 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/counter.h @@ -0,0 +1,164 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2012, 2013 Konstantin Belousov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __MACHINE_COUNTER_H__ +#define __MACHINE_COUNTER_H__ + +#include +#ifdef INVARIANTS +#include +#endif + +#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter + +#ifdef __powerpc64__ + +#define counter_enter() do {} while (0) +#define counter_exit() do {} while (0) + +#ifdef IN_SUBR_COUNTER_C +static inline uint64_t +counter_u64_read_one(uint64_t *p, int cpu) +{ + + return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); +} + +static inline uint64_t +counter_u64_fetch_inline(uint64_t *p) +{ + uint64_t r; + int i; + + r = 0; + CPU_FOREACH(i) + r += counter_u64_read_one((uint64_t *)p, i); + + return (r); +} + +static void +counter_u64_zero_one_cpu(void *arg) +{ + + *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * + PCPU_GET(cpuid))) = 0; +} + +static inline void +counter_u64_zero_inline(counter_u64_t c) +{ + + smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu, + smp_no_rendezvous_barrier, c); +} +#endif + +#define counter_u64_add_protected(c, i) counter_u64_add(c, i) + +static inline void +counter_u64_add(counter_u64_t c, int64_t inc) +{ + uint64_t ccpu, old; + + __asm __volatile("\n" + "1:\n\t" + "mfsprg %0, 0\n\t" + "ldarx %1, %0, %2\n\t" + "add %1, %1, %3\n\t" + "stdcx. %1, %0, %2\n\t" + "bne- 1b" + : "=&b" (ccpu), "=&r" (old) + : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc) + : "cr0", "memory"); +} + +#else /* !64bit */ + +#include + +#define counter_enter() critical_enter() +#define counter_exit() critical_exit() + +#ifdef IN_SUBR_COUNTER_C +/* XXXKIB non-atomic 64bit read */ +static inline uint64_t +counter_u64_read_one(uint64_t *p, int cpu) +{ + + return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); +} + +static inline uint64_t +counter_u64_fetch_inline(uint64_t *p) +{ + uint64_t r; + int i; + + r = 0; + for (i = 0; i < mp_ncpus; i++) + r += counter_u64_read_one((uint64_t *)p, i); + + return (r); +} + +/* XXXKIB non-atomic 64bit store, might interrupt increment */ +static void +counter_u64_zero_one_cpu(void *arg) +{ + + *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * + PCPU_GET(cpuid))) = 0; +} + +static inline void +counter_u64_zero_inline(counter_u64_t c) +{ + + smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu, + smp_no_rendezvous_barrier, c); +} +#endif + +#define counter_u64_add_protected(c, inc) do { \ + CRITICAL_ASSERT(curthread); \ + *(uint64_t *)zpcpu_get(c) += (inc); \ +} while (0) + +static inline void +counter_u64_add(counter_u64_t c, int64_t inc) +{ + + counter_enter(); + counter_u64_add_protected(c, inc); + counter_exit(); +} + +#endif /* 64bit */ + +#endif /* ! __MACHINE_COUNTER_H__ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/cpu.h b/lib/libc/include/powerpc64-freebsd-none/machine/cpu.h new file mode 100644 index 0000000000000000000000000000000000000000..2442a9207380ec69adbd3a8f0d6581c7ea9039dd --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/cpu.h @@ -0,0 +1,157 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995-1997 Wolfgang Solfrank. + * Copyright (C) 1995-1997 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: cpu.h,v 1.11 2000/05/26 21:19:53 thorpej Exp $ + */ + +#ifndef _MACHINE_CPU_H_ +#define _MACHINE_CPU_H_ + +#include +#include +#include + +/* + * CPU Feature Attributes + * + * These are defined in the PowerPC ELF ABI for the AT_HWCAP vector, + * and are exported to userland via the machdep.cpu_features + * sysctl. + */ + +extern u_long cpu_features; +extern u_long cpu_features2; + +#define PPC_FEATURE_32 0x80000000 /* Always true */ +#define PPC_FEATURE_64 0x40000000 /* Defined on a 64-bit CPU */ +#define PPC_FEATURE_601_INSTR 0x20000000 /* Defined on a 64-bit CPU */ +#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 +#define PPC_FEATURE_HAS_FPU 0x08000000 +#define PPC_FEATURE_HAS_MMU 0x04000000 +#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 +#define PPC_FEATURE_HAS_SPE 0x00800000 +#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 +#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 +#define PPC_FEATURE_NO_TB 0x00100000 +#define PPC_FEATURE_POWER4 0x00080000 +#define PPC_FEATURE_POWER5 0x00040000 +#define PPC_FEATURE_POWER5_PLUS 0x00020000 +#define PPC_FEATURE_CELL 0x00010000 +#define PPC_FEATURE_BOOKE 0x00008000 +#define PPC_FEATURE_SMT 0x00004000 +#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 +#define PPC_FEATURE_ARCH_2_05 0x00001000 +#define PPC_FEATURE_HAS_DFP 0x00000400 +#define PPC_FEATURE_POWER6_EXT 0x00000200 +#define PPC_FEATURE_ARCH_2_06 0x00000100 +#define PPC_FEATURE_HAS_VSX 0x00000080 +#define PPC_FEATURE_TRUE_LE 0x00000002 +#define PPC_FEATURE_PPC_LE 0x00000001 + +#define PPC_FEATURE2_ARCH_2_07 0x80000000 +#define PPC_FEATURE2_HTM 0x40000000 +#define PPC_FEATURE2_DSCR 0x20000000 +#define PPC_FEATURE2_EBB 0x10000000 +#define PPC_FEATURE2_ISEL 0x08000000 +#define PPC_FEATURE2_TAR 0x04000000 +#define PPC_FEATURE2_HAS_VEC_CRYPTO 0x02000000 +#define PPC_FEATURE2_HTM_NOSC 0x01000000 +#define PPC_FEATURE2_ARCH_3_00 0x00800000 +#define PPC_FEATURE2_HAS_IEEE128 0x00400000 +#define PPC_FEATURE2_DARN 0x00200000 +#define PPC_FEATURE2_SCV 0x00100000 +#define PPC_FEATURE2_HTM_NOSUSPEND 0x00080000 +#define PPC_FEATURE2_ARCH_3_1 0x00040000 +#define PPC_FEATURE2_MMA 0x00020000 + +#define PPC_FEATURE_BITMASK \ + "\20" \ + "\040PPC32\037PPC64\036PPC601\035ALTIVEC\034FPU\033MMU\031UNIFIEDCACHE" \ + "\030SPE\027SPESFP\026DPESFP\025NOTB\024POWER4\023POWER5\022P5PLUS\021CELL"\ + "\020BOOKE\017SMT\016ISNOOP\015ARCH205\013DFP\011ARCH206\010VSX"\ + "\002TRUELE\001PPCLE" +#define PPC_FEATURE2_BITMASK \ + "\20" \ + "\040ARCH207\037HTM\036DSCR\034ISEL\033TAR\032VCRYPTO\031HTMNOSC" \ + "\030ARCH300\027IEEE128\026DARN\025SCV\024HTMNOSUSP" + +#define TRAPF_USERMODE(frame) (((frame)->srr1 & PSL_PR) != 0) +#define TRAPF_PC(frame) ((frame)->srr0) + +/* + * CTL_MACHDEP definitions. + */ +#define CPU_CACHELINE 1 + +static __inline u_int64_t +get_cyclecount(void) +{ + u_int32_t _upper, _lower; + u_int64_t _time; + + __asm __volatile( + "mftb %0\n" + "mftbu %1" + : "=r" (_lower), "=r" (_upper)); + + _time = (u_int64_t)_upper; + _time = (_time << 32) + _lower; + return (_time); +} + +#define cpu_getstack(td) ((td)->td_frame->fixreg[1]) +#define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */ +#define cpu_lock_delay() DELAY(1) + +extern char btext[]; +extern char etext[]; + +struct thread; + +#ifdef __powerpc64__ +extern void enter_idle_powerx(void); +extern uint64_t can_wakeup; +extern register_t lpcr; +#endif + +void cpu_halt(void); +void cpu_reset(void); +void flush_disable_caches(void); +void fork_trampoline(void); +int cpu_machine_check(struct thread *, struct trapframe *, int *); + + +#ifndef __powerpc64__ +void mpc745x_sleep(void); +#endif + +#endif /* _MACHINE_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/cpufunc.h b/lib/libc/include/powerpc64-freebsd-none/machine/cpufunc.h new file mode 100644 index 0000000000000000000000000000000000000000..633899d5546d7e49da785eb843e3b1ad6c05f6e6 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/cpufunc.h @@ -0,0 +1,298 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 1998 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_CPUFUNC_H_ +#define _MACHINE_CPUFUNC_H_ + +#ifdef _KERNEL + +#include + +#include +#include + +struct thread; + +#ifdef KDB +void breakpoint(void); +#else +static __inline void +breakpoint(void) +{ + + return; +} +#endif + +/* CPU register mangling inlines */ + +static __inline void +mtmsr(register_t value) +{ + + __asm __volatile ("mtmsr %0; isync" :: "r"(value)); +} + +#ifdef __powerpc64__ +static __inline void +mtmsrd(register_t value) +{ + + __asm __volatile ("mtmsrd %0; isync" :: "r"(value)); +} +#endif + +static __inline register_t +mfmsr(void) +{ + register_t value; + + __asm __volatile ("mfmsr %0" : "=r"(value)); + + return (value); +} + +#ifndef __powerpc64__ +static __inline void +mtsrin(vm_offset_t va, register_t value) +{ + + __asm __volatile ("mtsrin %0,%1; isync" :: "r"(value), "r"(va)); +} + +static __inline register_t +mfsrin(vm_offset_t va) +{ + register_t value; + + __asm __volatile ("mfsrin %0,%1" : "=r"(value) : "r"(va)); + + return (value); +} +#endif + +static __inline register_t +mfctrl(void) +{ + register_t value; + + __asm __volatile ("mfspr %0,136" : "=r"(value)); + + return (value); +} + +static __inline void +mtdec(register_t value) +{ + + __asm __volatile ("mtdec %0" :: "r"(value)); +} + +static __inline register_t +mfdec(void) +{ + register_t value; + + __asm __volatile ("mfdec %0" : "=r"(value)); + + return (value); +} + +static __inline uint32_t +mfpvr(void) +{ + uint32_t value; + + __asm __volatile ("mfpvr %0" : "=r"(value)); + + return (value); +} + +static __inline u_quad_t +mftb(void) +{ + u_quad_t tb; + #ifdef __powerpc64__ + __asm __volatile ("mftb %0" : "=r"(tb)); + #else + uint32_t *tbup = (uint32_t *)&tb; + uint32_t *tblp = tbup + 1; + + do { + *tbup = mfspr(TBR_TBU); + *tblp = mfspr(TBR_TBL); + } while (*tbup != mfspr(TBR_TBU)); + #endif + + return (tb); +} + +static __inline void +mttb(u_quad_t time) +{ + + mtspr(TBR_TBWL, 0); + mtspr(TBR_TBWU, (uint32_t)(time >> 32)); + mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff)); +} + +static __inline register_t +mffs(void) +{ + uint64_t value; + + __asm __volatile ("mffs 0; stfd 0,0(%0)" + :: "b"(&value)); + + return ((register_t)value); +} + +static __inline void +mtfsf(uint64_t value) +{ + + __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0" + :: "b"(&value)); +} + +static __inline void +eieio(void) +{ + + __asm __volatile ("eieio" : : : "memory"); +} + +static __inline void +isync(void) +{ + + __asm __volatile ("isync" : : : "memory"); +} + +static __inline void +powerpc_sync(void) +{ + + __asm __volatile ("sync" : : : "memory"); +} + +static __inline int +cntlzd(uint64_t word) +{ + uint64_t result; + /* cntlzd %0, %1 */ + __asm __volatile(".long 0x7c000074 | (%1 << 21) | (%0 << 16)" : + "=r"(result) : "r"(word)); + + return (int)result; +} + +static __inline int +cnttzd(uint64_t word) +{ + uint64_t result; + /* cnttzd %0, %1 */ + __asm __volatile(".long 0x7c000474 | (%1 << 21) | (%0 << 16)" : + "=r"(result) : "r"(word)); + + return (int)result; +} + +static __inline void +ptesync(void) +{ + __asm __volatile("ptesync"); +} + +static __inline register_t +intr_disable(void) +{ + register_t msr; + + msr = mfmsr(); + mtmsr(msr & ~PSL_EE); + return (msr); +} + +static __inline void +intr_restore(register_t msr) +{ + + mtmsr(msr); +} + +static __inline struct pcpu * +get_pcpu(void) +{ + struct pcpu *ret; + + __asm __volatile("mfsprg %0, 0" : "=r"(ret)); + + return (ret); +} + +/* "NOP" operations to signify priorities to the kernel. */ +static __inline void +nop_prio_vlow(void) +{ + __asm __volatile("or 31,31,31"); +} + +static __inline void +nop_prio_low(void) +{ + __asm __volatile("or 1,1,1"); +} + +static __inline void +nop_prio_mlow(void) +{ + __asm __volatile("or 6,6,6"); +} + +static __inline void +nop_prio_medium(void) +{ + __asm __volatile("or 2,2,2"); +} + +static __inline void +nop_prio_mhigh(void) +{ + __asm __volatile("or 5,5,5"); +} + +static __inline void +nop_prio_high(void) +{ + __asm __volatile("or 3,3,3"); +} + +#endif /* _KERNEL */ + +#endif /* !_MACHINE_CPUFUNC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/db_machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/db_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..6707b3bb7420ab80439818ce5f229bdbce436996 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/db_machdep.h @@ -0,0 +1,87 @@ +/*- + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + * + * $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ + * $NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $ + */ + +/* + * Machine-dependent defines for new kernel debugger. + */ +#ifndef _POWERPC_DB_MACHDEP_H_ +#define _POWERPC_DB_MACHDEP_H_ + +#include +#include + +#define DB_ELF_SYMBOLS +#define DB_ELFSIZE __ELF_WORD_SIZE + +typedef vm_offset_t db_addr_t; /* address - unsigned */ +typedef intptr_t db_expr_t; /* expression - signed */ + +#define PC_REGS(regs) ((db_addr_t)kdb_thrctx->pcb_lr) + +#define BKPT_INST 0x7C810808 /* breakpoint instruction */ + +#define BKPT_SIZE (4) /* size of breakpoint inst */ +#define BKPT_SET(inst) (BKPT_INST) + +#define db_clear_single_step kdb_cpu_clear_singlestep +#define db_set_single_step kdb_cpu_set_singlestep + +#if 0 +#define SR_SINGLESTEP 0x400 +#define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP) +#define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP) +#endif + +#define T_BREAKPOINT 0xffff +#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) + +#define T_WATCHPOINT 0xeeee +#ifdef T_WATCHPOINT +#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) +#else +#define IS_WATCHPOINT_TRAP(type, code) 0 +#endif + +#define M_RTS 0xfc0007fe +#define I_RTS 0x4c000020 +#define M_BC 0xfc000000 +#define I_BC 0x40000000 +#define M_B 0xfc000000 +#define I_B 0x50000000 +#define M_RFI 0xfc0007fe +#define I_RFI 0x4c000064 + +#define inst_trap_return(ins) (((ins)&M_RFI) == I_RFI) +#define inst_return(ins) (((ins)&M_RTS) == I_RTS) +#define inst_call(ins) (((ins)&M_BC ) == I_BC || \ + ((ins)&M_B ) == I_B ) +#define inst_load(ins) 0 +#define inst_store(ins) 0 + +#endif /* _POWERPC_DB_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/dbdma.h b/lib/libc/include/powerpc64-freebsd-none/machine/dbdma.h new file mode 100644 index 0000000000000000000000000000000000000000..c04ae1ba80e89e545635906aa658079ccddf953e --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/dbdma.h @@ -0,0 +1,153 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2008 Nathan Whitehorn + * All rights reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_DBDMA_H_ +#define _MACHINE_DBDMA_H_ + +#include +#include + +/* + * Apple's DBDMA (Descriptor-based DMA) interface is a common DMA engine + * used by a variety of custom Apple ASICs. It is described in the CHRP + * specification and in the book Macintosh Technology in the Common + * Hardware Reference Platform, copyright 1995 Apple Computer. + */ + +/* DBDMA Command Values */ + +enum { + DBDMA_OUTPUT_MORE = 0, + DBDMA_OUTPUT_LAST = 1, + DBDMA_INPUT_MORE = 2, + DBDMA_INPUT_LAST = 3, + + DBDMA_STORE_QUAD = 4, + DBDMA_LOAD_QUAD = 5, + DBDMA_NOP = 6, + DBDMA_STOP = 7 +}; + +/* These codes are for the interrupt, branch, and wait flags */ + +enum { + DBDMA_NEVER = 0, + DBDMA_COND_TRUE = 1, + DBDMA_COND_FALSE = 2, + DBDMA_ALWAYS = 3 +}; + +/* Channel status bits */ +#define DBDMA_STATUS_RUN (0x01 << 15) +#define DBDMA_STATUS_PAUSE (0x01 << 14) +#define DBDMA_STATUS_FLUSH (0x01 << 13) +#define DBDMA_STATUS_WAKE (0x01 << 12) +#define DBDMA_STATUS_DEAD (0x01 << 11) +#define DBDMA_STATUS_ACTIVE (0x01 << 10) + +/* Set by hardware if a branch was taken */ +#define DBDMA_STATUS_BRANCH 8 + +struct dbdma_command; +typedef struct dbdma_command dbdma_command_t; +struct dbdma_channel; +typedef struct dbdma_channel dbdma_channel_t; + +int dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset, + bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan); + +int dbdma_resize_channel(dbdma_channel_t *chan, int newslots); +int dbdma_free_channel(dbdma_channel_t *chan); + +void dbdma_run(dbdma_channel_t *chan); +void dbdma_stop(dbdma_channel_t *chan); +void dbdma_reset(dbdma_channel_t *chan); +void dbdma_set_current_cmd(dbdma_channel_t *chan, int slot); + +void dbdma_pause(dbdma_channel_t *chan); +void dbdma_wake(dbdma_channel_t *chan); + +/* + * DBDMA uses a 16 bit channel control register to describe the current + * state of DMA on the channel. The high-order bits (8-15) contain information + * on the run state and are listed in the DBDMA_STATUS_* constants above. These + * are manipulated with the dbdma_run/stop/reset() routines above. + * + * The low order bits (0-7) are device dependent status bits. These can be set + * and read by both hardware and software. The mask is the set of bits to + * modify; if mask is 0x03 and value is 0, the lowest order 2 bits will be + * zeroed. + */ + +uint16_t dbdma_get_chan_status(dbdma_channel_t *chan); + +uint8_t dbdma_get_device_status(dbdma_channel_t *chan); +void dbdma_set_device_status(dbdma_channel_t *chan, uint8_t mask, + uint8_t value); + +/* + * Each DBDMA command word has the current channel status register and the + * number of residual bytes (requested - actually transferred) written to it + * at time of command completion. + */ + +uint16_t dbdma_get_cmd_status(dbdma_channel_t *chan, int slot); +uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot); + +void dbdma_clear_cmd_status(dbdma_channel_t *chan, int slot); + +/* + * The interrupt/branch/wait selector let you specify a set of values + * of the device dependent status bits that will cause intterupt/branch/wait + * conditions to be taken if the flags for these are set to one of the + * DBDMA_COND_* values. + * + * The condition is considered true if (status & mask) == value. + */ + +void dbdma_set_interrupt_selector(dbdma_channel_t *chan, uint8_t mask, + uint8_t value); +void dbdma_set_branch_selector(dbdma_channel_t *chan, uint8_t mask, + uint8_t value); +void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask, + uint8_t value); + +void dbdma_insert_command(dbdma_channel_t *chan, int slot, int command, + int stream, bus_addr_t data, size_t count, uint8_t interrupt, + uint8_t branch, uint8_t wait, uint32_t branch_slot); + +void dbdma_insert_stop(dbdma_channel_t *chan, int slot); +void dbdma_insert_nop(dbdma_channel_t *chan, int slot); +void dbdma_insert_branch(dbdma_channel_t *chan, int slot, int to_slot); + +void dbdma_sync_commands(dbdma_channel_t *chan, bus_dmasync_op_t op); + +void dbdma_save_state(dbdma_channel_t *chan); +void dbdma_restore_state(dbdma_channel_t *chan); + +#endif /* _MACHINE_DBDMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/dump.h b/lib/libc/include/powerpc64-freebsd-none/machine/dump.h new file mode 100644 index 0000000000000000000000000000000000000000..68051ae782c057dd79bfaf99b8daa41c71828144 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/dump.h @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2014 EMC Corp. + * Author: Conrad Meyer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_DUMP_H_ +#define _MACHINE_DUMP_H_ + +#define KERNELDUMP_ARCH_VERSION KERNELDUMP_POWERPC_VERSION +#define EM_VALUE ELF_ARCH /* Defined in powerpc/include/elf.h */ +#define DUMPSYS_MD_PA_NPAIRS (PHYS_AVAIL_SZ + 1) +#define DUMPSYS_NUM_AUX_HDRS 0 + +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 20 /* Every 1MB */ + +void dumpsys_pa_init(void); +void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *); +size_t dumpsys_scan_pmap(struct bitset *); +void *dumpsys_dump_pmap_init(unsigned blkpgs); +void *dumpsys_dump_pmap(void *ctx, void *buf, u_long *nbytes); + +static inline struct dump_pa * +dumpsys_pa_next(struct dump_pa *p) +{ + + return (dumpsys_gen_pa_next(p)); +} + +static inline void +dumpsys_wbinv_all(void) +{ + + dumpsys_gen_wbinv_all(); +} + +static inline int +dumpsys_write_aux_headers(struct dumperinfo *di) +{ + + return (dumpsys_gen_write_aux_headers(di)); +} + +static inline int +dumpsys(struct dumperinfo *di) +{ + + return (dumpsys_generic(di)); +} + +#endif /* !_MACHINE_DUMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/efi.h b/lib/libc/include/powerpc64-freebsd-none/machine/efi.h new file mode 100644 index 0000000000000000000000000000000000000000..13f09c46613f07898a6266d2cfdde5bfef0f3ef3 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/efi.h @@ -0,0 +1,12 @@ +/*- + * This file is in the public domain since it's just boilerplate. + */ + +#ifndef __POWERPC_INCLUDE_EFI_H_ +#define __POWERPC_INCLUDE_EFI_H_ + +#define EFIABI_ATTR + +/* Note: we don't actually support this on powerpc */ + +#endif /* __POWERPC_INCLUDE_EFI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/elf.h b/lib/libc/include/powerpc64-freebsd-none/machine/elf.h new file mode 100644 index 0000000000000000000000000000000000000000..b643c6592160dc9a5c21a62788a16a93a41d358b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/elf.h @@ -0,0 +1,146 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1996-1997 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_ELF_H_ +#define _MACHINE_ELF_H_ 1 + +/* + * EABI ELF definitions for the PowerPC architecture. + * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation" + * [ppc-eabi-1995-01.pdf] for details. + */ + +#ifndef __ELF_WORD_SIZE +#ifdef __powerpc64__ +#define __ELF_WORD_SIZE 64 /* Used by */ +#else +#define __ELF_WORD_SIZE 32 /* Used by */ +#endif +#endif + +#include /* Definitions common to all 32 bit architectures. */ +#include /* Definitions common to all 64 bit architectures. */ +#include + +#if __ELF_WORD_SIZE == 64 +#define ELF_ARCH EM_PPC64 +#define ELF_MACHINE_OK(x) ((x) == EM_PPC64) +#else +#define ELF_ARCH EM_PPC +#define ELF_ARCH32 EM_PPC +#define ELF_MACHINE_OK(x) ((x) == EM_PPC) +#endif + +/* + * Auxiliary vector entries for passing information to the interpreter. + * + * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t", + * but POSIX lays claim to all symbols ending with "_t". + */ + +typedef struct { /* Auxiliary vector entry on initial stack */ + int a_type; /* Entry type. */ + union { +#ifdef __powerpc64__ + int a_val; /* Integer value */ +#else + long a_val; /* Integer value. */ + void *a_ptr; /* Address. */ + void (*a_fcn)(void); /* Function pointer (not used). */ +#endif + } a_un; +} Elf32_Auxinfo; + +typedef struct { /* Auxiliary vector entry on initial stack */ + long a_type; /* Entry type. */ + union { + long a_val; /* Integer value. */ + void *a_ptr; /* Address. */ + void (*a_fcn)(void); /* Function pointer (not used). */ + } a_un; +} Elf64_Auxinfo; + +__ElfType(Auxinfo); + +/* + * Relocation types. + */ + +#define R_PPC_COUNT 37 /* Count of defined relocation types. */ + + /* Count of defined relocation types. */ +#define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1) + +/* Define "machine" characteristics */ +#if BYTE_ORDER == LITTLE_ENDIAN +#define ELF_TARG_DATA ELFDATA2LSB +#else +#define ELF_TARG_DATA ELFDATA2MSB +#endif +#if __ELF_WORD_SIZE == 64 +#define ELF_TARG_CLASS ELFCLASS64 +#define ELF_TARG_MACH EM_PPC64 +#define ELF_TARG_VER 1 +#else +#define ELF_TARG_CLASS ELFCLASS32 +#define ELF_TARG_MACH EM_PPC +#define ELF_TARG_VER 1 +#endif + +#define ET_DYN_LOAD_ADDR 0x01010000 + +#define AT_OLD_NULL AT_NULL +#define AT_OLD_IGNORE AT_IGNORE +#define AT_OLD_EXECFD AT_EXECFD +#define AT_OLD_PHDR AT_PHDR +#define AT_OLD_PHENT AT_PHENT +#define AT_OLD_PHNUM AT_PHNUM +#define AT_OLD_PAGESZ AT_PAGESZ +#define AT_OLD_BASE AT_BASE +#define AT_OLD_FLAGS AT_FLAGS +#define AT_OLD_ENTRY AT_ENTRY +#define AT_OLD_NOTELF AT_NOTELF +#define AT_OLD_UID AT_UID +#define AT_OLD_EUID AT_EUID +#define AT_OLD_EXECPATH 13 +#define AT_OLD_CANARY 14 +#define AT_OLD_CANARYLEN 15 +#define AT_OLD_OSRELDATE 16 +#define AT_OLD_NCPUS 17 +#define AT_OLD_PAGESIZES 18 +#define AT_OLD_PAGESIZESLEN 19 +#define AT_OLD_STACKPROT 21 +#define AT_OLD_TIMEKEEP AT_TIMEKEEP +#define AT_OLD_EHDRFLAGS AT_EHDRFLAGS +#define AT_OLD_HWCAP AT_HWCAP +#define AT_OLD_HWCAP2 AT_HWCAP2 + +#define AT_OLD_COUNT 27 /* Count of defined aux entry types. */ + +#endif /* !_MACHINE_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/endian.h b/lib/libc/include/powerpc64-freebsd-none/machine/endian.h new file mode 100644 index 0000000000000000000000000000000000000000..11f5bb5fd838773f8f763e1204f5f646d0da19a7 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/endian.h @@ -0,0 +1,38 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1987, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include +#include + +#endif /* !_MACHINE_ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/exec.h b/lib/libc/include/powerpc64-freebsd-none/machine/exec.h new file mode 100644 index 0000000000000000000000000000000000000000..8a2c6bd93612eab956558a8e7d56c3243c4edf7a --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/exec.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2001 David E. O'Brien + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_EXEC_H_ +#define _MACHINE_EXEC_H_ + +#define __LDPGSZ 4096 + +#endif /* !_MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/float.h b/lib/libc/include/powerpc64-freebsd-none/machine/float.h new file mode 100644 index 0000000000000000000000000000000000000000..a832240666f0e403949fa5e56079bba16e75ba0c --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/float.h @@ -0,0 +1,98 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * from: FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 + */ + +#ifndef _MACHINE_FLOAT_H_ +#define _MACHINE_FLOAT_H_ 1 + +#include + +#ifndef _SOFT_FLOAT +__BEGIN_DECLS +extern int __flt_rounds(void); +__END_DECLS +#define FLT_ROUNDS __flt_rounds() +#else +#define FLT_ROUNDS (-1) +#endif + +#define FLT_RADIX 2 /* b */ +#if __ISO_C_VISIBLE >= 1999 +#define FLT_EVAL_METHOD 0 +#define DECIMAL_DIG 17 /* max precision in decimal digits */ +#endif + +#define FLT_MANT_DIG 24 /* p */ +#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ +#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ +#define FLT_MIN_EXP (-125) /* emin */ +#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ +#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ +#define FLT_MAX_EXP 128 /* emax */ +#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ +#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ +#if __ISO_C_VISIBLE >= 2011 +#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */ +#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */ +#define FLT_HAS_SUBNORM 1 +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131E-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014E-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.7976931348623157E+308 +#define DBL_MAX_10_EXP 308 +#if __ISO_C_VISIBLE >= 2011 +#define DBL_TRUE_MIN 4.9406564584124654E-324 +#define DBL_DECIMAL_DIG 17 +#define DBL_HAS_SUBNORM 1 +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON ((long double)DBL_EPSILON) +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN ((long double)DBL_MIN) +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX ((long double)DBL_MAX) +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP +#if __ISO_C_VISIBLE >= 2011 +#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN) +#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG +#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM +#endif /* __ISO_C_VISIBLE >= 2011 */ + +#endif /* _MACHINE_FLOAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/floatingpoint.h b/lib/libc/include/powerpc64-freebsd-none/machine/floatingpoint.h new file mode 100644 index 0000000000000000000000000000000000000000..d2c7e15ad2e8ae4c8fff302ee2365f352fd05c79 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/floatingpoint.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2004 Suleiman Souhlal + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _FLOATINGPOINT_H_ +#define _FLOATINGPOINT_H_ + +#include + +#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/fpu.h b/lib/libc/include/powerpc64-freebsd-none/machine/fpu.h new file mode 100644 index 0000000000000000000000000000000000000000..a291b1817afe567d1db46d1196d95a51c549250f --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/fpu.h @@ -0,0 +1,102 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: fpu.h,v 1.2 1999/12/07 15:14:56 danw Exp $ + */ + +#ifndef _MACHINE_FPU_H_ +#define _MACHINE_FPU_H_ + +#define FPSCR_FX 0x80000000 +#define FPSCR_FEX 0x40000000 +#define FPSCR_VX 0x20000000 +#define FPSCR_OX 0x10000000 +#define FPSCR_UX 0x08000000 +#define FPSCR_ZX 0x04000000 +#define FPSCR_XX 0x02000000 +#define FPSCR_VXSNAN 0x01000000 +#define FPSCR_VXISI 0x00800000 +#define FPSCR_VXIDI 0x00400000 +#define FPSCR_VXZDZ 0x00200000 +#define FPSCR_VXIMZ 0x00100000 +#define FPSCR_VXVC 0x00080000 +#define FPSCR_FR 0x00040000 +#define FPSCR_FI 0x00020000 +#define FPSCR_FPRF 0x0001f000 +#define FPSCR_C 0x00010000 +#define FPSCR_FPCC 0x0000f000 +#define FPSCR_FL 0x00008000 +#define FPSCR_FG 0x00004000 +#define FPSCR_FE 0x00002000 +#define FPSCR_FU 0x00001000 +#define FPSCR_VXSOFT 0x00000400 +#define FPSCR_VXSQRT 0x00000200 +#define FPSCR_VXCVI 0x00000100 +#define FPSCR_VE 0x00000080 +#define FPSCR_OE 0x00000040 +#define FPSCR_UE 0x00000020 +#define FPSCR_ZE 0x00000010 +#define FPSCR_XE 0x00000008 +#define FPSCR_NI 0x00000004 +#define FPSCR_RN 0x00000003 + +#ifdef _KERNEL + +void enable_fpu(struct thread *); +void save_fpu(struct thread *); +void save_fpu_nodrop(struct thread *); +void cleanup_fpscr(void); +u_int get_fpu_exception(struct thread *); +void enable_fpu_kern(void); +void disable_fpu(struct thread *td); + +/* + * Flags for fpu_kern_alloc_ctx(), fpu_kern_enter() and fpu_kern_thread(). + */ +#define FPU_KERN_NORMAL 0x0000 +#define FPU_KERN_NOWAIT 0x0001 +#define FPU_KERN_KTHR 0x0002 +#define FPU_KERN_NOCTX 0x0004 + +struct fpu_kern_ctx; + +struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); +void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); +void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, + u_int flags); +int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); +int fpu_kern_thread(u_int flags); +int is_fpu_kern_thread(u_int flags); + +#endif /* _KERNEL */ + +#endif /* _MACHINE_FPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/frame.h b/lib/libc/include/powerpc64-freebsd-none/machine/frame.h new file mode 100644 index 0000000000000000000000000000000000000000..01008712c3ce395601cac770bc777461afc6dc3f --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/frame.h @@ -0,0 +1,114 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $ + */ + +#ifndef _MACHINE_FRAME_H_ +#define _MACHINE_FRAME_H_ + +#include + +/* + * We have to save all registers on every trap, because + * 1. user could attach this process every time + * 2. we must be able to restore all user registers in case of fork + * Actually, we do not save the fp registers on trap, since + * these are not used by the kernel. They are saved only when switching + * between processes using the FPU. + * + * Change ordering to cluster together these register_t's. XXX + */ +struct trapframe { + register_t fixreg[32]; + register_t lr; + register_t cr; + register_t xer; + register_t ctr; + register_t srr0; + register_t srr1; + register_t exc; + register_t dar; /* DAR/DEAR filled in on DSI traps */ + union { + struct { + /* dsisr only filled on a DSI trap */ + register_t dsisr; + } aim; + struct { + register_t esr; + register_t dbcr0; + } booke; + } cpu; +}; + +/* + * FRAMELEN is the size of the stack region used by the low-level trap + * handler. It is the size of its data (trapframe) plus the callframe + * header (sizeof(struct callframe) - 3 register widths). It must also + * be 16-byte aligned. + */ +#define FRAMELEN roundup(sizeof(struct trapframe) + \ + sizeof(struct callframe) - 3*sizeof(register_t), 16) +#define trapframe(td) ((td)->td_frame) + +/* + * Call frame for PowerPC used during fork. + */ +#ifdef __powerpc64__ +struct callframe { + register_t cf_dummy_fp; /* dummy frame pointer */ + register_t cf_cr; + register_t cf_lr; + register_t cf_compiler; + register_t cf_linkeditor; + register_t cf_toc; + register_t cf_func; + register_t cf_arg0; + register_t cf_arg1; + register_t _padding; /* Maintain 16-byte alignment */ +}; +#else +struct callframe { + register_t cf_dummy_fp; /* dummy frame pointer */ + register_t cf_lr; /* space for link register save */ + register_t cf_func; + register_t cf_arg0; + register_t cf_arg1; + register_t _padding; /* Maintain 16-byte alignment */ +}; +#endif + +/* Definitions for syscalls */ +#define FIRSTARG 3 /* first arg in reg 3 */ +#define NARGREG 8 /* 8 args in regs */ + +#endif /* _MACHINE_FRAME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/gdb_machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/gdb_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..443aa6f27feb4942988bcf6240e29cc642dc3995 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/gdb_machdep.h @@ -0,0 +1,140 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2006 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_GDB_MACHDEP_H_ +#define _MACHINE_GDB_MACHDEP_H_ + +#ifdef BOOKE +#define PPC_GDB_NREGS0 1 +#define PPC_GDB_NREGS4 (70 + 1) +#define PPC_GDB_NREGS8 (1 + 32) +#define PPC_GDB_NREGS16 0 + +#else +/* + * 0 - 32*GPR(4/8) + * 32 - 32*FPR(8) + * 64 - PC, PS (4/8) + * 66 - CR (4) + * 67 - LR, CTR (4/8) + * 69 - XER, FPSCR (4) + * 71 - 32*VR(16) + * 103 - VSCR, VRSAVE (4) + */ + +#define PPC_REGNUM_R0 0 +#define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31) +#define PPC_REGNUM_FR0 32 +#define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31) +#define PPC_REGNUM_PC 64 +#define PPC_REGNUM_PS 65 +#define PPC_REGNUM_CR 66 +#define PPC_REGNUM_LR 67 +#define PPC_REGNUM_CTR 68 +#define PPC_REGNUM_XER 69 +#define PPC_REGNUM_FPSCR 70 +#define PPC_REGNUM_VR0 71 +#define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31) + +#define PPC_GDB_NREGS0 0 + +#ifdef __powerpc64__ +#define PPC_GDB_NREGS4 5 +#define PPC_GDB_NREGS8 (64 + 4) +#else +#define PPC_GDB_NREGS4 (32 + 7 + 2) +#define PPC_GDB_NREGS8 32 +#endif + +#define PPC_GDB_NREGS16 32 +#endif + +#define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \ + PPC_GDB_NREGS8 + PPC_GDB_NREGS16) +#define GDB_REG_PC 64 + +#define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \ + PPC_GDB_NREGS8 * 16 + \ + PPC_GDB_NREGS16 * 32) + +static __inline size_t +gdb_cpu_regsz(int regnum) +{ + +#ifdef BOOKE + if (regnum == 70) + return (0); + if (regnum == 71 || regnum >= 73) + return (8); +#else +#ifdef __powerpc64__ + if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) || + regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR) + return (8); +#else + if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31) + return (8); +#endif + if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31) + return (16); +#endif + return (4); +} + +static __inline int +gdb_cpu_query(void) +{ + + return (0); +} + +static __inline void * +gdb_begin_write(void) +{ + + return (NULL); +} + +static __inline void +gdb_end_write(void *arg __unused) +{ + +} + +static __inline void +gdb_cpu_stop_reason(int type __unused, int code __unused) +{ + +} + +void *gdb_cpu_getreg(int, size_t *); +void gdb_cpu_setreg(int, void *); +int gdb_cpu_signal(int, int); +void gdb_cpu_do_offsets(void); + +#endif /* !_MACHINE_GDB_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/hid.h b/lib/libc/include/powerpc64-freebsd-none/machine/hid.h new file mode 100644 index 0000000000000000000000000000000000000000..97267189216f277239812a5e3e00dcee2beeaf84 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/hid.h @@ -0,0 +1,223 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2000 Tsubai Masanari. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: hid.h,v 1.2 2001/08/22 21:05:25 matt Exp $ + */ + +#ifndef _POWERPC_HID_H_ +#define _POWERPC_HID_H_ + +/* Hardware Implementation Dependent registers for the PowerPC */ +#define HID0_RADIX 0x0080000000000000 /* Enable Radix page tables (POWER9) */ + +#define HID0_EMCP 0x80000000 /* Enable machine check pin */ +#define HID0_DBP 0x40000000 /* Disable 60x bus parity generation */ +#define HID0_EBA 0x20000000 /* Enable 60x bus address parity checking */ +#define HID0_EBD 0x10000000 /* Enable 60x bus data parity checking */ +#define HID0_BCLK 0x08000000 /* CLK_OUT clock type selection */ +#define HID0_EICE 0x04000000 /* Enable ICE output */ +#define HID0_ECLK 0x02000000 /* CLK_OUT clock type selection */ +#define HID0_PAR 0x01000000 /* Disable precharge of ARTRY */ +#define HID0_STEN 0x01000000 /* Software table search enable (7450) */ +#define HID0_DEEPNAP 0x01000000 /* Enable deep nap mode (970) */ +#define HID0_HBATEN 0x00800000 /* High BAT enable (74[45][578]) */ +#define HID0_DOZE 0x00800000 /* Enable doze mode */ +#define HID0_NAP 0x00400000 /* Enable nap mode */ +#define HID0_SLEEP 0x00200000 /* Enable sleep mode */ +#define HID0_DPM 0x00100000 /* Enable Dynamic power management */ +#define HID0_RISEG 0x00080000 /* Read I-SEG */ +#define HID0_TG 0x00040000 /* Timebase Granularity (OEA64) */ +#define HID0_BHTCLR 0x00040000 /* Clear branch history table (7450) */ +#define HID0_EIEC 0x00040000 /* Enable internal error checking */ +#define HID0_XAEN 0x00020000 /* Enable eXtended Addressing (7450) */ +#define HID0_NHR 0x00010000 /* Not hard reset */ +#define HID0_ICE 0x00008000 /* Enable i-cache */ +#define HID0_DCE 0x00004000 /* Enable d-cache */ +#define HID0_ILOCK 0x00002000 /* i-cache lock */ +#define HID0_DLOCK 0x00001000 /* d-cache lock */ +#define HID0_ICFI 0x00000800 /* i-cache flush invalidate */ +#define HID0_DCFI 0x00000400 /* d-cache flush invalidate */ +#define HID0_SPD 0x00000200 /* Disable speculative cache access */ +#define HID0_XBSEN 0x00000100 /* Extended BAT block-size enable (7457) */ +#define HID0_IFEM 0x00000100 /* Enable M-bit for I-fetch */ +#define HID0_XBSEN 0x00000100 /* Extended BAT block size enable (7455+)*/ +#define HID0_SGE 0x00000080 /* Enable store gathering */ +#define HID0_DCFA 0x00000040 /* Data cache flush assist */ +#define HID0_BTIC 0x00000020 /* Enable BTIC */ +#define HID0_LRSTK 0x00000010 /* Link register stack enable (7450) */ +#define HID0_ABE 0x00000008 /* Enable address broadcast */ +#define HID0_FOLD 0x00000008 /* Branch folding enable (7450) */ +#define HID0_BHT 0x00000004 /* Enable branch history table */ +#define HID0_NOPTI 0x00000001 /* No-op the dcbt(st) */ + +#define HID0_AIM_TBEN 0x04000000 /* Time base enable (7450) */ + +#define HID0_E500_TBEN 0x00004000 /* Time Base and decr. enable */ +#define HID0_E500_SEL_TBCLK 0x00002000 /* Select Time Base clock */ +#define HID0_E500_MAS7UPDEN 0x00000080 /* Enable MAS7 update (e500v2) */ + +#define HID0_E500MC_L2MMU_MHD 0x40000000 /* L2MMU Multiple Hit Detection */ + +#define HID0_BITMASK \ + "\20" \ + "\040EMCP\037DBP\036EBA\035EBD\034BCLK\033EICE\032ECLK\031PAR" \ + "\030DOZE\027NAP\026SLEEP\025DPM\024RISEG\023EIEC\022res\021NHR" \ + "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011IFEM" \ + "\010SGE\007DCFA\006BTIC\005FBIOB\004ABE\003BHT\002NOPDST\001NOPTI" + +#define HID0_7450_BITMASK \ + "\20" \ + "\040EMCP\037b1\036b2\035b3\034b4\033TBEN\032b6\031STEN" \ + "\030HBATEN\027NAP\026SLEEP\025DPM\024b12\023BHTCLR\022XAEN\021NHR" \ + "\020ICE\017DCE\016ILOCK\015DLOCK\014ICFI\013DCFI\012SPD\011XBSEN" \ + "\010SGE\007b25\006BTIC\005LRSTK\004FOLD\003BHT\002NOPDST\001NOPTI" + +#define HID0_E500_BITMASK \ + "\20" \ + "\040EMCP\037b1\036b2\035b3\034b4\033b5\032b6\031b7" \ + "\030DOZE\027NAP\026SLEEP\025b11\024b12\023b13\022b14\021b15" \ + "\020b16\017TBEN\016SEL_TBCLK\015b19\014b20\013b21\012b22\011b23" \ + "\010EN_MAS7_UPDATE\007DCFA\006b26\005b27\004b28\003b29\002b30\001NOPTI" + +#define HID0_970_BITMASK \ + "\20" \ + "\040ONEPPC\037SINGLE\036ISYNCSC\035SERGP\031DEEPNAP\030DOZE" \ + "\027NAP\025DPM\023TG\022HANGDETECT\021NHR\020INORDER" \ + "\016TBCTRL\015TBEN\012CIABREN\011HDICEEN\001ENATTN" + +#define HID0_E500MC_BITMASK \ + "\20" \ + "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \ + "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \ + "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \ + "\010EN_MAS7_UPDATE\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI" + +#define HID0_E5500_BITMASK \ + "\20" \ + "\040EMCP\037EN_L2MMU_MHD\036b2\035b3\034b4\033b5\032b6\031b7" \ + "\030b8\027b9\026b10\025b11\024b12\023b13\022b14\021b15" \ + "\020b16\017b17\016b18\015b19\014b20\013b21\012b22\011b23" \ + "\010b24\007DCFA\006b26\005CIGLSO\004b28\003b29\002b30\001NOPTI" + +/* + * HID0 bit definitions per cpu model + * + * bit 603 604 750 7400 7410 7450 7457 e500 + * 0 EMCP EMCP EMCP EMCP EMCP - - EMCP + * 1 - ECP DBP - - - - - + * 2 EBA EBA EBA EBA EDA - - - + * 3 EBD EBD EBD EBD EBD - - - + * 4 SBCLK - BCLK BCKL BCLK - - - + * 5 EICE - - - - TBEN TBEN - + * 6 ECLK - ECLK ECLK ECLK - - - + * 7 PAR PAR PAR PAR PAR STEN STEN - + * 8 DOZE - DOZE DOZE DOZE - HBATEN DOZE + * 9 NAP - NAP NAP NAP NAP NAP NAP + * 10 SLEEP - SLEEP SLEEP SLEEP SLEEP SLEEP SLEEP + * 11 DPM - DPM DPM DPM DPM DPM - + * 12 RISEG - - RISEG - - - - + * 13 - - - EIEC EIEC BHTCLR BHTCLR - + * 14 - - - - - XAEN XAEN - + * 15 - NHR NHR NHR NHR NHR NHR - + * 16 ICE ICE ICE ICE ICE ICE ICE - + * 17 DCE DCE DCE DCE DCE DCE DCE TBEN + * 18 ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK ILOCK SEL_TBCLK + * 19 DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK DLOCK - + * 20 ICFI ICFI ICFI ICFI ICFI ICFI ICFI - + * 21 DCFI DCFI DCFI DCFI DCFI DCFI DCFI - + * 22 - - SPD SPD SPG SPD SPD - + * 23 - - IFEM IFTT IFTT - XBSEN - + * 24 - SIE SGE SGE SGE SGE SGE EN_MAS7_UPDATE + * 25 - - DCFA DCFA DCFA - - DCFA + * 26 - - BTIC BTIC BTIC BTIC BTIC - + * 27 FBIOB - - - - LRSTK LRSTK - + * 28 - - ABE - - FOLD FOLD - + * 29 - BHT BHT BHT BHT BHT BHT - + * 30 - - - NOPDST NOPDST NOPDST NOPDST - + * 31 NOOPTI - NOOPTI NOPTI NOPTI NOPTI NOPTI NOPTI + * + * bit e500mc e5500 + * 0 EMCP EMCP + * 1 EN_L2MMU_MHD EN_L2MMU_MHD + * 2 - - + * 3 - - + * 4 - - + * 5 - - + * 6 - - + * 7 - - + * 8 - - + * 9 - - + * 10 - - + * 11 - - + * 12 - - + * 13 - - + * 14 - - + * 15 - - + * 16 - - + * 17 - - + * 18 - - + * 19 - - + * 20 - - + * 21 - - + * 22 - - + * 23 - - + * 24 EN_MAS7_UPDATE - + * 25 DCFA DCFA + * 26 - - + * 27 CIGLSO CIGLSO + * 28 - - + * 29 - - + * 30 - - + * 31 NOPTI NOPTI + * + * 604: ECP = Enable cache parity checking + * 604: SIE = Serial instruction execution disable + * 7450: TBEN = Time Base Enable + * 7450: STEN = Software table lookup enable + * 7450: BHTCLR = Branch history clear + * 7450: XAEN = Extended Addressing Enabled + * 7450: LRSTK = Link Register Stack Enable + * 7450: FOLD = Branch folding enable + * 7457: HBATEN = High BAT Enable + * 7457: XBSEN = Extended BAT Block Size Enable + */ + +#define HID1_E500_ABE 0x00001000 /* Address broadcast enable */ +#define HID1_E500_ASTME 0x00002000 /* Address bus streaming mode enable */ +#define HID1_E500_RFXE 0x00020000 /* Read fault exception enable */ + +#define HID0_E500_DEFAULT_SET (HID0_EMCP | HID0_E500_TBEN | \ + HID0_E500_MAS7UPDEN) +#define HID1_E500_DEFAULT_SET (HID1_E500_ABE | HID1_E500_ASTME) +#define HID0_E500MC_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD | \ + HID0_E500_MAS7UPDEN) +#define HID0_E5500_DEFAULT_SET (HID0_EMCP | HID0_E500MC_L2MMU_MHD) + +#define HID5_970_DCBZ_SIZE_HI 0x00000080UL /* dcbz does a 32-byte store */ +#define HID4_970_DISABLE_LG_PG 0x00000004ULL /* disables large pages */ + +#endif /* _POWERPC_HID_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ieee.h b/lib/libc/include/powerpc64-freebsd-none/machine/ieee.h new file mode 100644 index 0000000000000000000000000000000000000000..91686834c1537690a1295d92d97fbc88de578fd5 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ieee.h @@ -0,0 +1,141 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp + */ + +#ifndef _MACHINE_IEEE_H_ +#define _MACHINE_IEEE_H_ + +/* + * ieee.h defines the machine-dependent layout of the machine's IEEE + * floating point. It does *not* define (yet?) any of the rounding + * mode bits, exceptions, and so forth. + */ + +/* + * Define the number of bits in each fraction and exponent. + * + * k k+1 + * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented + * + * (-exp_bias+1) + * as fractions that look like 0.fffff x 2 . This means that + * + * -126 + * the number 0.10000 x 2 , for instance, is the same as the normalized + * + * -127 -128 + * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero + * + * -129 + * in the fraction; to represent 2 , we need two, and so on. This + * + * (-exp_bias-fracbits+1) + * implies that the smallest denormalized number is 2 + * + * for whichever format we are talking about: for single precision, for + * + * -126 -149 + * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and + * + * -149 == -127 - 23 + 1. + */ +#define SNG_EXPBITS 8 +#define SNG_FRACBITS 23 + +#define DBL_EXPBITS 11 +#define DBL_FRACBITS 52 + +#ifdef notyet +#define E80_EXPBITS 15 +#define E80_FRACBITS 64 +#endif + +#define EXT_EXPBITS 15 +#define EXT_FRACBITS 112 + +struct ieee_single { + u_int sng_sign:1; + u_int sng_exp:8; + u_int sng_frac:23; +}; + +struct ieee_double { + u_int dbl_sign:1; + u_int dbl_exp:11; + u_int dbl_frach:20; + u_int dbl_fracl; +}; + +struct ieee_ext { + u_int ext_sign:1; + u_int ext_exp:15; + u_int ext_frach:16; + u_int ext_frachm; + u_int ext_fraclm; + u_int ext_fracl; +}; + +/* + * Floats whose exponent is in [1..INFNAN) (of whatever type) are + * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. + * Floats whose exponent is zero are either zero (iff all fraction + * bits are zero) or subnormal values. + * + * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its + * high fraction; if the bit is set, it is a `quiet NaN'. + */ +#define SNG_EXP_INFNAN 255 +#define DBL_EXP_INFNAN 2047 +#define EXT_EXP_INFNAN 32767 + +#if 0 +#define SNG_QUIETNAN (1 << 22) +#define DBL_QUIETNAN (1 << 19) +#define EXT_QUIETNAN (1 << 15) +#endif + +/* + * Exponent biases. + */ +#define SNG_EXP_BIAS 127 +#define DBL_EXP_BIAS 1023 +#define EXT_EXP_BIAS 16383 + +#endif \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ieeefp.h b/lib/libc/include/powerpc64-freebsd-none/machine/ieeefp.h new file mode 100644 index 0000000000000000000000000000000000000000..37cb89cd5f805582e5fb3a619b159b62867b7d49 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ieeefp.h @@ -0,0 +1,42 @@ +/* - + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + * $NetBSD: ieeefp.h,v 1.2 1999/07/07 01:52:26 danw Exp $ + */ + +#ifndef _MACHINE_IEEEFP_H_ +#define _MACHINE_IEEEFP_H_ + +/* Deprecated historical FPU control interface */ + +typedef int fp_except_t; +#ifdef __SPE__ +#define FP_X_OFL 0x01 /* overflow exception */ +#define FP_X_UFL 0x02 /* underflow exception */ +#define FP_X_DZ 0x04 /* divide-by-zero exception */ +#define FP_X_INV 0x08 /* invalid operation exception */ +#define FP_X_IMP 0x10 /* imprecise (loss of precision) */ +#else +#define FP_X_IMP 0x01 /* imprecise (loss of precision) */ +#define FP_X_DZ 0x02 /* divide-by-zero exception */ +#define FP_X_UFL 0x04 /* underflow exception */ +#define FP_X_OFL 0x08 /* overflow exception */ +#define FP_X_INV 0x10 /* invalid operation exception */ +#endif + +typedef enum { + FP_RN=0, /* round to nearest representable number */ + FP_RZ=1, /* round to zero (truncate) */ + FP_RP=2, /* round toward positive infinity */ + FP_RM=3 /* round toward negative infinity */ +} fp_rnd_t; + +__BEGIN_DECLS +extern fp_rnd_t fpgetround(void); +extern fp_rnd_t fpsetround(fp_rnd_t); +extern fp_except_t fpgetmask(void); +extern fp_except_t fpsetmask(fp_except_t); +extern fp_except_t fpgetsticky(void); +__END_DECLS + +#endif /* _MACHINE_IEEEFP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ifunc.h b/lib/libc/include/powerpc64-freebsd-none/machine/ifunc.h new file mode 100644 index 0000000000000000000000000000000000000000..7c82fe0af8c2d5591d6c29570a3590d90e00c1a6 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ifunc.h @@ -0,0 +1,58 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Brandon Bergren + * Copyright (c) 2015-2018 The FreeBSD Foundation. All rights reserved. + * + * Part of this software was developed by + * Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __POWERPC_IFUNC_H +#define __POWERPC_IFUNC_H + +#include + +#define DEFINE_IFUNC(qual, ret_type, name, args) \ + static ret_type (*name##_resolver(void))args __used; \ + qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ + static ret_type (*name##_resolver(void))args + +#define DEFINE_UIFUNC(qual, ret_type, name, args) \ + static ret_type (*name##_resolver(register_t, register_t, \ + register_t, register_t, register_t, register_t, register_t, \ + register_t))args __used; \ + qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ + static ret_type (*name##_resolver( \ + register_t cpu_features, \ + register_t cpu_features2, \ + register_t arg3 __unused, \ + register_t arg4 __unused, \ + register_t arg5 __unused, \ + register_t arg6 __unused, \ + register_t arg7 __unused, \ + register_t arg8 __unused))args + +#endif \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/intr_machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/intr_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..1a5dce02f23463db86843c9c7ee79659d3626ab3 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/intr_machdep.h @@ -0,0 +1,64 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2002 Benno Rice. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_INTR_MACHDEP_H_ +#define _MACHINE_INTR_MACHDEP_H_ + +#define INTR_VECTORS 256 + +#define MAX_PICS 32 +#define MAP_IRQ(node, pin) powerpc_get_irq(node, pin) + +/* + * Default base address for MSI messages on PowerPC + */ +#define MSI_INTEL_ADDR_BASE 0xfee00000 + +extern device_t root_pic; + +struct trapframe; + +driver_filter_t powerpc_ipi_handler; + +void intrcnt_add(const char *name, u_long **countp); + +u_int powerpc_register_pic(device_t, uint32_t, u_int, u_int, u_int); +u_int powerpc_get_irq(uint32_t, u_int); + +void powerpc_dispatch_intr(u_int, struct trapframe *); +int powerpc_enable_intr(void); +int powerpc_setup_intr(const char *, u_int, driver_filter_t, driver_intr_t, + void *, enum intr_type, void **, int); +int powerpc_teardown_intr(void *); +int powerpc_bind_intr(u_int irq, u_char cpu); +int powerpc_config_intr(int, enum intr_trigger, enum intr_polarity); +int powerpc_fw_config_intr(int irq, int sense_code); + +void powerpc_intr_mask(u_int irq); +void powerpc_intr_unmask(u_int irq); + +#endif /* _MACHINE_INTR_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/kdb.h b/lib/libc/include/powerpc64-freebsd-none/machine/kdb.h new file mode 100644 index 0000000000000000000000000000000000000000..14c555233a789d75504d5d4b113fbf4dad842137 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/kdb.h @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_KDB_H_ +#define _MACHINE_KDB_H_ + +#include +#include +#include +#include +#include + +void kdb_cpu_clear_singlestep(void); +void kdb_cpu_set_singlestep(void); + +static __inline void +kdb_cpu_sync_icache(unsigned char *addr, size_t size) +{ + + __syncicache(addr, size); +} + +static __inline void +kdb_cpu_trap(int vector, int _) +{ +} + +static __inline int +kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access) +{ + + return (ENXIO); +} + +static __inline int +kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size) +{ + + return (0); +} + +#endif /* _MACHINE_KDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..dcd54c9b570019eba683db3010b872a8cf4b265d --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/machdep.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2011-2012 Semihalf + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _POWERPC_MACHDEP_H_ +#define _POWERPC_MACHDEP_H_ + +void booke_disable_l2_cache(void); +void booke_enable_l1_cache(void); +void booke_enable_l2_cache(void); +void booke_enable_bpred(void); + +#endif /* _POWERPC_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/md_var.h b/lib/libc/include/powerpc64-freebsd-none/machine/md_var.h new file mode 100644 index 0000000000000000000000000000000000000000..6d49ce2eda8feeaa82c52fd54c6e7ebd2158ee5a --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/md_var.h @@ -0,0 +1,71 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 1998 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_MD_VAR_H_ +#define _MACHINE_MD_VAR_H_ + +/* + * Miscellaneous machine-dependent declarations. + */ + +extern char sigcode32[]; +extern int szsigcode32; + +#ifdef __powerpc64__ +extern char sigcode64[], sigcode64_elfv2[]; +extern int szsigcode64, szsigcode64_elfv2; + +struct dumperinfo; +struct minidumpstate; +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); +#endif + +extern long Maxmem; + +extern vm_offset_t kstack0; +extern vm_offset_t kstack0_phys; + +extern int powerpc_pow_enabled; +extern int cacheline_size; +extern int hw_direct_map; + +void __syncicache(void *, int); + +int mem_valid(vm_offset_t addr, int len); + +void decr_init(void); +void decr_ap_init(void); +void decr_tc_init(void); + +void cpu_feature_setup(void); +void cpu_setup(u_int); + +struct trapframe; +void powerpc_interrupt(struct trapframe *); + +#endif /* !_MACHINE_MD_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/metadata.h b/lib/libc/include/powerpc64-freebsd-none/machine/metadata.h new file mode 100644 index 0000000000000000000000000000000000000000..e82eb2790b10d76b5e0b466198be53260f86f0f9 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/metadata.h @@ -0,0 +1,38 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2001 Jake Burkholder. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_METADATA_H_ +#define _MACHINE_METADATA_H_ + +#define MODINFOMD_ENVP 0x1001 +#define MODINFOMD_HOWTO 0x1002 +#define MODINFOMD_KERNEND 0x1003 +#define MODINFOMD_BOOTINFO 0x1004 +#define MODINFOMD_DTBP 0x1005 + +#endif /* !_MACHINE_METADATA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/minidump.h b/lib/libc/include/powerpc64-freebsd-none/machine/minidump.h new file mode 100644 index 0000000000000000000000000000000000000000..d55bb4dfa3e5d22c718c260b72c8aae63fc4c5c0 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/minidump.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2006 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * From i386: FreeBSD: 157909 2006-04-21 04:28:43Z peter + */ + +#ifndef _MACHINE_MINIDUMP_H_ +#define _MACHINE_MINIDUMP_H_ 1 + +#define MINIDUMP_MAGIC "minidump FreeBSD/powerpc64" +#define MINIDUMP_VERSION 2 + +struct minidumphdr { + char magic[32]; + char mmu_name[32]; + uint32_t version; + uint32_t msgbufsize; + uint32_t bitmapsize; + uint32_t pmapsize; + uint64_t kernbase; + uint64_t kernend; + uint64_t dmapbase; + uint64_t dmapend; + int hw_direct_map; + uint64_t startkernel; + uint64_t endkernel; + uint32_t dumpavailsize; +}; + +#endif /* _MACHINE_MINIDUMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/mmuvar.h b/lib/libc/include/powerpc64-freebsd-none/machine/mmuvar.h new file mode 100644 index 0000000000000000000000000000000000000000..0eecb51adf90c64d6110d0eda09d95339b6a978c --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/mmuvar.h @@ -0,0 +1,224 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2005 Peter Grehan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_MMUVAR_H_ +#define _MACHINE_MMUVAR_H_ + +typedef void (*pmap_bootstrap_t)(vm_offset_t, vm_offset_t); +typedef void (*pmap_cpu_bootstrap_t)(int); +typedef void (*pmap_kenter_t)(vm_offset_t, vm_paddr_t pa); +typedef void (*pmap_kenter_attr_t)(vm_offset_t, vm_paddr_t, vm_memattr_t); +typedef void (*pmap_kremove_t)(vm_offset_t); +typedef void *(*pmap_mapdev_t)(vm_paddr_t, vm_size_t); +typedef void *(*pmap_mapdev_attr_t)(vm_paddr_t, vm_size_t, vm_memattr_t); +typedef void (*pmap_unmapdev_t)(void *, vm_size_t); +typedef void (*pmap_page_set_memattr_t)(vm_page_t, vm_memattr_t); +typedef int (*pmap_change_attr_t)(vm_offset_t, vm_size_t, vm_memattr_t); +typedef int (*pmap_map_user_ptr_t)(pmap_t, volatile const void *, + void **, size_t, size_t *); +typedef int (*pmap_decode_kernel_ptr_t)(vm_offset_t, int *, vm_offset_t *); +typedef vm_paddr_t (*pmap_kextract_t)(vm_offset_t); +typedef int (*pmap_dev_direct_mapped_t)(vm_paddr_t, vm_size_t); + +typedef void (*pmap_page_array_startup_t)(long); +typedef void (*pmap_advise_t)(pmap_t, vm_offset_t, vm_offset_t, int); +typedef void (*pmap_clear_modify_t)(vm_page_t); +typedef void (*pmap_remove_write_t)(vm_page_t); +typedef void (*pmap_copy_t)(pmap_t, pmap_t, vm_offset_t, vm_size_t, vm_offset_t); +typedef void (*pmap_copy_page_t)(vm_page_t, vm_page_t); +typedef void (*pmap_copy_pages_t)(vm_page_t *, vm_offset_t, + vm_page_t *, vm_offset_t, int); +typedef int (*pmap_enter_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t, + u_int, int8_t); +typedef void (*pmap_enter_object_t)(pmap_t, vm_offset_t, vm_offset_t, + vm_page_t, vm_prot_t); +typedef void (*pmap_enter_quick_t)(pmap_t, vm_offset_t, vm_page_t, vm_prot_t); +typedef vm_paddr_t (*pmap_extract_t)(pmap_t, vm_offset_t); +typedef vm_page_t (*pmap_extract_and_hold_t)(pmap_t, vm_offset_t, vm_prot_t); +typedef int (*pmap_growkernel_nopanic_t)(vm_offset_t); +typedef void (*pmap_init_t)(void); +typedef bool (*pmap_is_modified_t)(vm_page_t); +typedef bool (*pmap_is_prefaultable_t)(pmap_t, vm_offset_t); +typedef bool (*pmap_is_referenced_t)(vm_page_t); +typedef int (*pmap_ts_referenced_t)(vm_page_t); +typedef vm_offset_t (*pmap_map_t)(vm_offset_t *, vm_paddr_t, vm_paddr_t, int); +typedef void (*pmap_object_init_pt_t)(pmap_t, vm_offset_t, vm_object_t, + vm_pindex_t, vm_size_t); +typedef bool (*pmap_page_exists_quick_t)(pmap_t, vm_page_t); +typedef bool (*pmap_page_is_mapped_t)(vm_page_t); +typedef void (*pmap_page_init_t)(vm_page_t); +typedef int (*pmap_page_wired_mappings_t)(vm_page_t); +typedef void (*pmap_pinit0_t)(pmap_t); +typedef void (*pmap_protect_t)(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t); +typedef void (*pmap_qenter_t)(vm_offset_t, vm_page_t *, int); +typedef void (*pmap_qremove_t)(vm_offset_t, int); +typedef void (*pmap_release_t)(pmap_t); +typedef void (*pmap_remove_t)(pmap_t, vm_offset_t, vm_offset_t); +typedef void (*pmap_remove_all_t)(vm_page_t); +typedef void (*pmap_remove_pages_t)(pmap_t); +typedef void (*pmap_unwire_t)(pmap_t, vm_offset_t, vm_offset_t); +typedef void (*pmap_zero_page_t)(vm_page_t); +typedef void (*pmap_zero_page_area_t)(vm_page_t, int, int); +typedef int (*pmap_mincore_t)(pmap_t, vm_offset_t, vm_paddr_t *); +typedef void (*pmap_activate_t)(struct thread *); +typedef void (*pmap_deactivate_t)(struct thread *); +typedef void (*pmap_align_superpage_t)(vm_object_t, vm_ooffset_t, + vm_offset_t *, vm_size_t); + +typedef void (*pmap_sync_icache_t)(pmap_t, vm_offset_t, vm_size_t); +typedef void (*pmap_dumpsys_map_chunk_t)(vm_paddr_t, size_t, void **); +typedef void (*pmap_dumpsys_unmap_chunk_t)(vm_paddr_t, size_t, void *); +typedef void (*pmap_dumpsys_pa_init_t)(void); +typedef size_t (*pmap_dumpsys_scan_pmap_t)(struct bitset *dump_bitset); +typedef void *(*pmap_dumpsys_dump_pmap_init_t)(unsigned); +typedef void *(*pmap_dumpsys_dump_pmap_t)(void *, void *, u_long *); +typedef vm_offset_t (*pmap_quick_enter_page_t)(vm_page_t); +typedef void (*pmap_quick_remove_page_t)(vm_offset_t); +typedef bool (*pmap_ps_enabled_t)(pmap_t); +typedef void (*pmap_tlbie_all_t)(void); +typedef void (*pmap_installer_t)(void); + +struct pmap_funcs { + pmap_installer_t install; + pmap_bootstrap_t bootstrap; + pmap_cpu_bootstrap_t cpu_bootstrap; + pmap_kenter_t kenter; + pmap_kenter_attr_t kenter_attr; + pmap_kremove_t kremove; + pmap_mapdev_t mapdev; + pmap_mapdev_attr_t mapdev_attr; + pmap_unmapdev_t unmapdev; + pmap_page_set_memattr_t page_set_memattr; + pmap_change_attr_t change_attr; + pmap_map_user_ptr_t map_user_ptr; + pmap_decode_kernel_ptr_t decode_kernel_ptr; + pmap_kextract_t kextract; + pmap_dev_direct_mapped_t dev_direct_mapped; + pmap_advise_t advise; + pmap_clear_modify_t clear_modify; + pmap_remove_write_t remove_write; + pmap_copy_t copy; + pmap_copy_page_t copy_page; + pmap_copy_pages_t copy_pages; + pmap_enter_t enter; + pmap_enter_object_t enter_object; + pmap_enter_quick_t enter_quick; + pmap_extract_t extract; + pmap_extract_and_hold_t extract_and_hold; + pmap_growkernel_nopanic_t growkernel_nopanic; + pmap_init_t init; + pmap_is_modified_t is_modified; + pmap_is_prefaultable_t is_prefaultable; + pmap_is_referenced_t is_referenced; + pmap_ts_referenced_t ts_referenced; + pmap_page_is_mapped_t page_is_mapped; + pmap_ps_enabled_t ps_enabled; + pmap_map_t map; + pmap_object_init_pt_t object_init_pt; + pmap_page_exists_quick_t page_exists_quick; + pmap_page_init_t page_init; + pmap_page_wired_mappings_t page_wired_mappings; + pmap_pinit_t pinit; + pmap_pinit0_t pinit0; + pmap_protect_t protect; + pmap_qenter_t qenter; + pmap_qremove_t qremove; + pmap_release_t release; + pmap_remove_t remove; + pmap_remove_all_t remove_all; + pmap_remove_pages_t remove_pages; + pmap_unwire_t unwire; + pmap_zero_page_t zero_page; + pmap_zero_page_area_t zero_page_area; + pmap_mincore_t mincore; + pmap_activate_t activate; + pmap_deactivate_t deactivate; + pmap_align_superpage_t align_superpage; + pmap_sync_icache_t sync_icache; + pmap_quick_enter_page_t quick_enter_page; + pmap_quick_remove_page_t quick_remove_page; + pmap_page_array_startup_t page_array_startup; + pmap_dumpsys_map_chunk_t dumpsys_map_chunk; + pmap_dumpsys_unmap_chunk_t dumpsys_unmap_chunk; + pmap_dumpsys_pa_init_t dumpsys_pa_init; + pmap_dumpsys_scan_pmap_t dumpsys_scan_pmap; + pmap_dumpsys_dump_pmap_init_t dumpsys_dump_pmap_init; + pmap_dumpsys_dump_pmap_t dumpsys_dump_pmap; + pmap_tlbie_all_t tlbie_all; + +}; +struct mmu_kobj { + const char *name; + const struct mmu_kobj *base; + const struct pmap_funcs *funcs; +}; + +typedef struct mmu_kobj *mmu_t; + +/* The currently installed pmap object. */ +extern mmu_t mmu_obj; + +/* + * Resolve a given pmap function. + * 'func' is the function name less the 'pmap_' * prefix. + */ +#define PMAP_RESOLVE_FUNC(func) \ + ({ \ + pmap_##func##_t f; \ + const struct mmu_kobj *mmu = mmu_obj; \ + do { \ + f = mmu->funcs->func; \ + if (f != NULL) break; \ + mmu = mmu->base; \ + } while (mmu != NULL); \ + f;}) + +#define MMU_DEF(name, ident, methods) \ + \ +const struct mmu_kobj name = { \ + ident, NULL, &methods \ +}; \ +DATA_SET(mmu_set, name) + +#define MMU_DEF_INHERIT(name, ident, methods, base1) \ + \ +const struct mmu_kobj name = { \ + ident, &base1, &methods, \ +}; \ +DATA_SET(mmu_set, name) + +/* + * Known MMU names + */ +#define MMU_TYPE_BOOKE "mmu_booke" /* Book-E MMU specification */ +#define MMU_TYPE_OEA "mmu_oea" /* 32-bit OEA */ +#define MMU_TYPE_G5 "mmu_g5" /* 64-bit bridge (ibm 970) */ +#define MMU_TYPE_RADIX "mmu_radix" /* 64-bit native ISA 3.0 (POWER9) radix */ +#define MMU_TYPE_8xx "mmu_8xx" /* 8xx quicc TLB */ + +#endif /* _MACHINE_MMUVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ofw_machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/ofw_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..1b059dd08cab222468ec1fd5fce3c492d3c15c44 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ofw_machdep.h @@ -0,0 +1,57 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2001 by Thomas Moestl . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_OFW_MACHDEP_H_ +#define _MACHINE_OFW_MACHDEP_H_ + +#include +#include +#include +#include +#include + +struct mem_region; +struct numa_mem_region; + +typedef uint32_t cell_t; + +void OF_getetheraddr(device_t dev, u_char *addr); + +void OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *)); +bool OF_bootstrap(void); + +void OF_reboot(void); + +void ofw_mem_regions(struct mem_region *, int *, struct mem_region *, int *); +void ofw_numa_mem_regions(struct numa_mem_region *, int *); +void ofw_quiesce(void); /* Must be called before VM is up! */ +void ofw_save_trap_vec(char *); +int ofw_pcibus_get_domain(device_t dev, device_t child, int *domain); +int ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op, + size_t setsize, cpuset_t *cpuset); + +#endif /* _MACHINE_OFW_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/openpicreg.h b/lib/libc/include/powerpc64-freebsd-none/machine/openpicreg.h new file mode 100644 index 0000000000000000000000000000000000000000..f3f3e602de33e67431b7937bd78e1ee62778de86 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/openpicreg.h @@ -0,0 +1,141 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2000 Tsubai Masanari. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * from NetBSD: openpicreg.h,v 1.3 2001/08/30 03:08:52 briggs Exp + */ + +/* + * Size of OpenPIC register space + */ +#define OPENPIC_SIZE 0x40000 + +/* + * Per Processor Registers [private access] (0x00000 - 0x00fff) + */ + +/* IPI dispatch command reg */ +#define OPENPIC_IPI_DISPATCH(ipi) (0x40 + (ipi) * 0x10) + +/* current task priority reg */ +#define OPENPIC_TPR 0x80 +#define OPENPIC_TPR_MASK 0x0000000f + +#define OPENPIC_WHOAMI 0x90 + +/* interrupt acknowledge reg */ +#define OPENPIC_IACK 0xa0 + +/* end of interrupt reg */ +#define OPENPIC_EOI 0xb0 + +/* + * Global registers (0x01000-0x0ffff) + */ + +/* feature reporting reg 0 */ +#define OPENPIC_FEATURE 0x1000 +#define OPENPIC_FEATURE_VERSION_MASK 0x000000ff +#define OPENPIC_FEATURE_LAST_CPU_MASK 0x00001f00 +#define OPENPIC_FEATURE_LAST_CPU_SHIFT 8 +#define OPENPIC_FEATURE_LAST_IRQ_MASK 0x07ff0000 +#define OPENPIC_FEATURE_LAST_IRQ_SHIFT 16 + +/* global config reg 0 */ +#define OPENPIC_CONFIG 0x1020 +#define OPENPIC_CONFIG_RESET 0x80000000 +#define OPENPIC_CONFIG_8259_PASSTHRU_DISABLE 0x20000000 + +/* interrupt configuration mode (direct or serial) */ +#define OPENPIC_ICR 0x1030 +#define OPENPIC_ICR_SERIAL_MODE (1 << 27) +#define OPENPIC_ICR_SERIAL_RATIO_MASK (0x7 << 28) +#define OPENPIC_ICR_SERIAL_RATIO_SHIFT 28 + +/* vendor ID */ +#define OPENPIC_VENDOR_ID 0x1080 + +/* processor initialization reg */ +#define OPENPIC_PROC_INIT 0x1090 + +/* IPI vector/priority reg */ +#define OPENPIC_IPI_VECTOR(ipi) (0x10a0 + (ipi) * 0x10) + +/* spurious intr. vector */ +#define OPENPIC_SPURIOUS_VECTOR 0x10e0 + +/* Timer registers */ +#define OPENPIC_TIMERS 4 +#define OPENPIC_TFREQ 0x10f0 +#define OPENPIC_TCNT(t) (0x1100 + (t) * 0x40) +#define OPENPIC_TBASE(t) (0x1110 + (t) * 0x40) +#define OPENPIC_TVEC(t) (0x1120 + (t) * 0x40) +#define OPENPIC_TDST(t) (0x1130 + (t) * 0x40) + +/* + * Interrupt Source Configuration Registers (0x10000 - 0x1ffff) + */ + +/* interrupt vector/priority reg */ +#define OPENPIC_SRC_VECTOR_COUNT 64 +#ifndef OPENPIC_SRC_VECTOR +#define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20) +#endif +#define OPENPIC_SENSE_LEVEL 0x00400000 +#define OPENPIC_SENSE_EDGE 0x00000000 +#define OPENPIC_POLARITY_POSITIVE 0x00800000 +#define OPENPIC_POLARITY_NEGATIVE 0x00000000 +#define OPENPIC_IMASK 0x80000000 +#define OPENPIC_ACTIVITY 0x40000000 +#define OPENPIC_PRIORITY_MASK 0x000f0000 +#define OPENPIC_PRIORITY_SHIFT 16 +#define OPENPIC_VECTOR_MASK 0x000000ff + +/* interrupt destination cpu */ +#ifndef OPENPIC_IDEST +#define OPENPIC_IDEST(irq) (0x10010 + (irq) * 0x20) +#endif + +/* + * Per Processor Registers [global access] (0x20000 - 0x3ffff) + */ + +#define OPENPIC_PCPU_BASE(cpu) (0x20000 + (cpu) * 0x1000) + +#define OPENPIC_PCPU_IPI_DISPATCH(cpu, ipi) \ + (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IPI_DISPATCH(ipi)) + +#define OPENPIC_PCPU_TPR(cpu) \ + (OPENPIC_PCPU_BASE(cpu) + OPENPIC_TPR) + +#define OPENPIC_PCPU_WHOAMI(cpu) \ + (OPENPIC_PCPU_BASE(cpu) + OPENPIC_WHOAMI) + +#define OPENPIC_PCPU_IACK(cpu) \ + (OPENPIC_PCPU_BASE(cpu) + OPENPIC_IACK) + +#define OPENPIC_PCPU_EOI(cpu) \ + (OPENPIC_PCPU_BASE(cpu) + OPENPIC_EOI) \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/openpicvar.h b/lib/libc/include/powerpc64-freebsd-none/machine/openpicvar.h new file mode 100644 index 0000000000000000000000000000000000000000..5077b8a82390c123286a998b65f634ec6c7f6804 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/openpicvar.h @@ -0,0 +1,90 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2002 Benno Rice. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _POWERPC_OPENPICVAR_H_ +#define _POWERPC_OPENPICVAR_H_ + +#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller" + +#define OPENPIC_IRQMAX 256 /* h/w allows more */ + +#define OPENPIC_QUIRK_SINGLE_BIND 1 /* Bind interrupts to only 1 CPU */ +#define OPENPIC_QUIRK_HIDDEN_IRQS 2 /* May have IRQs beyond FRR[NIRQ] */ + +/* Names match the macros in openpicreg.h. */ +struct openpic_timer { + uint32_t tcnt; + uint32_t tbase; + uint32_t tvec; + uint32_t tdst; +}; + +struct openpic_softc { + device_t sc_dev; + struct resource *sc_memr; + struct resource *sc_intr; + bus_space_tag_t sc_bt; + bus_space_handle_t sc_bh; + char *sc_version; + int sc_rid; + int sc_irq; + void *sc_icookie; + u_int sc_ncpu; + u_int sc_nirq; + int sc_psim; + u_int sc_quirks; + + /* Saved states. */ + uint32_t sc_saved_config; + uint32_t sc_saved_ipis[4]; + uint32_t sc_saved_prios[4]; + struct openpic_timer sc_saved_timers[OPENPIC_TIMERS]; + uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT]; + +}; + +/* + * Bus-independent attach i/f + */ +int openpic_common_attach(device_t, uint32_t); + +/* + * PIC interface. + */ +void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **); +void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); +void openpic_dispatch(device_t, struct trapframe *); +void openpic_enable(device_t, u_int, u_int, void **); +void openpic_eoi(device_t, u_int, void *); +void openpic_ipi(device_t, u_int); +void openpic_mask(device_t, u_int, void *); +void openpic_unmask(device_t, u_int, void *); + +int openpic_suspend(device_t dev); +int openpic_resume(device_t dev); + +#endif /* _POWERPC_OPENPICVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/param.h b/lib/libc/include/powerpc64-freebsd-none/machine/param.h new file mode 100644 index 0000000000000000000000000000000000000000..f4fc0a2efa620667dee32093bdef5ea59027041a --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/param.h @@ -0,0 +1,150 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2001 David E. O'Brien + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _POWERPC_INCLUDE_PARAM_H_ +#define _POWERPC_INCLUDE_PARAM_H_ + +/* + * Machine dependent constants for PowerPC + */ + +#include + +#ifndef MACHINE +#define MACHINE "powerpc" +#endif +#ifndef MACHINE_ARCH +#ifdef __powerpc64__ +#if defined(__LITTLE_ENDIAN__) +#define MACHINE_ARCH "powerpc64le" +#else +#define MACHINE_ARCH "powerpc64" +#endif +#else +#ifdef __SPE__ +#define MACHINE_ARCH "powerpcspe" +#else +#define MACHINE_ARCH "powerpc" +#endif +#endif +#endif +#define MID_MACHINE MID_POWERPC +#ifdef __powerpc64__ +#ifndef MACHINE_ARCH32 +#define MACHINE_ARCH32 "powerpc" +#endif +#endif + +#ifdef SMP +#ifndef MAXCPU +#define MAXCPU 256 +#endif +#else +#define MAXCPU 1 +#endif + +#ifndef MAXMEMDOM +#define MAXMEMDOM 8 +#endif + +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) +/* + * ALIGNED_POINTER is a boolean macro that checks whether an address + * is valid to fetch data elements of type t from on this architecture. + * This does not reflect the optimal alignment, just the possibility + * (within reasonable limits). + */ +#define ALIGNED_POINTER(p, t) ((((uintptr_t)(p)) & (sizeof (t) - 1)) == 0) + +/* + * CACHE_LINE_SIZE is the compile-time maximum cache line size for an + * architecture. It should be used with appropriate caution. + */ +#define CACHE_LINE_SHIFT 7 +#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ +#define PAGE_MASK (PAGE_SIZE - 1) +#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) +#define NPDEPG (PAGE_SIZE/(sizeof (pt_entry_t))) + +#define L1_PAGE_SIZE_SHIFT 39 +#define L1_PAGE_SIZE (1UL<> PAGE_SHIFT) +#define powerpc_ptob(x) ((x) << PAGE_SHIFT) + +#define btoc(x) ((vm_offset_t)(((x)+PAGE_MASK)>>PAGE_SHIFT)) + +#endif /* !_POWERPC_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pcb.h b/lib/libc/include/powerpc64-freebsd-none/machine/pcb.h new file mode 100644 index 0000000000000000000000000000000000000000..a6f003b67de796b6df8fa49e623d068eda056816 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pcb.h @@ -0,0 +1,129 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: pcb.h,v 1.4 2000/06/04 11:57:17 tsubai Exp $ + */ + +#ifndef _MACHINE_PCB_H_ +#define _MACHINE_PCB_H_ + +#include + +#include + +#ifndef _STANDALONE +struct pcb { + register_t pcb_context[20]; /* non-volatile r12-r31 */ + register_t pcb_cr; /* Condition register */ + register_t pcb_sp; /* stack pointer */ + register_t pcb_toc; /* toc pointer */ + register_t pcb_lr; /* link register */ + register_t pcb_dscr; /* dscr value */ + register_t pcb_fscr; + register_t pcb_tar; + struct pmap *pcb_pm; /* pmap of our vmspace */ + jmp_buf *pcb_onfault; /* For use during + copyin/copyout */ + int pcb_flags; +#define PCB_FPU 0x1 /* Process uses FPU */ +#define PCB_FPREGS 0x2 /* Process had FPU registers initialized */ +#define PCB_VEC 0x4 /* Process uses Altivec */ +#define PCB_VSX 0x8 /* Process had VSX initialized */ +#define PCB_CDSCR 0x10 /* Process had Custom DSCR initialized */ +#define PCB_HTM 0x20 /* Process had HTM initialized */ +#define PCB_CFSCR 0x40 /* Process had FSCR updated */ +#define PCB_KERN_FPU 0x80 /* Kernel is using FPU/Vector unit */ +#define PCB_KERN_FPU_NOSAVE 0x100 /* FPU/Vec state not saved for kernel use */ +#define PCB_VECREGS 0x200 /* Process had Altivec registers initialized */ + struct fpu { + union { + uint32_t vsr[4]; + double fpr; + } fpr[32]; + double fpscr; /* FPSCR stored as double for easier access */ + } pcb_fpu; /* Floating point processor */ + unsigned int pcb_fpcpu; /* which CPU had our FPU + stuff. */ + struct vec { + uint32_t vr[32][4]; + uint32_t spare[2]; + uint32_t vrsave; + uint32_t vscr; /* aligned at vector element 3 */ + } pcb_vec __aligned(16); /* Vector processor */ + unsigned int pcb_veccpu; /* which CPU had our vector + stuff. */ + struct htm { + uint64_t tfhar; + uint64_t texasr; + uint64_t tfiar; + } pcb_htm; + + struct ebb { + uint64_t ebbhr; + uint64_t ebbrr; + uint64_t bescr; + } pcb_ebb; + + struct lmon { + uint64_t lmrr; + uint64_t lmser; + } pcb_lm; + + union { + struct { + vm_offset_t usr_segm; /* Base address */ + register_t usr_vsid; /* USER_SR segment */ + } aim; + struct { + register_t dbcr0; + } booke; + } pcb_cpu; + vm_offset_t pcb_lastill; /* Last illegal instruction */ +}; +#endif + +#ifdef _KERNEL + +struct trapframe; + +#ifndef curpcb +extern struct pcb *curpcb; +#endif + +extern struct pmap *curpm; +extern struct proc *fpuproc; + +void makectx(struct trapframe *, struct pcb *); +void savectx(struct pcb *) __returns_twice; + +#endif +#endif /* _MACHINE_PCB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pcpu.h b/lib/libc/include/powerpc64-freebsd-none/machine/pcpu.h new file mode 100644 index 0000000000000000000000000000000000000000..630ddf6499bea6a42004ec353854bff3d321ba79 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pcpu.h @@ -0,0 +1,174 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 1999 Luoqi Chen + * Copyright (c) Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_PCPU_H_ +#define _MACHINE_PCPU_H_ + +#include +#include +#include + +struct pmap; +struct pvo_entry; +#define CPUSAVE_LEN 9 + +#define PCPU_MD_COMMON_FIELDS \ + int pc_inside_intr; \ + struct pmap *pc_curpmap; /* current pmap */ \ + struct thread *pc_fputhread; /* current fpu user */ \ + struct thread *pc_vecthread; /* current vec user */ \ + struct thread *pc_htmthread; /* current htm user */ \ + uintptr_t pc_hwref; \ + int pc_bsp; \ + volatile int pc_awake; \ + uint32_t pc_ipimask; \ + uint32_t pc_flags; /* cpu feature flags */ \ + register_t pc_tempsave[CPUSAVE_LEN]; \ + register_t pc_disisave[CPUSAVE_LEN]; \ + register_t pc_dbsave[CPUSAVE_LEN]; \ + void *pc_restore; \ + vm_offset_t pc_qmap_addr; + +#define PCPU_MD_AIM32_FIELDS \ + struct pvo_entry *qmap_pvo; \ + struct mtx qmap_lock; \ + char __pad[128]; + +#define PCPU_MD_AIM64_FIELDS \ + struct slb slb[64]; \ + struct slb **userslb; \ + register_t slbsave[18]; \ + uint8_t slbstack[1024]; \ + struct pvo_entry *qmap_pvo; \ + struct mtx qmap_lock; \ + uint64_t opal_hmi_flags; \ + char __pad[1337]; + +#ifdef __powerpc64__ +#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM64_FIELDS +#else +#define PCPU_MD_AIM_FIELDS PCPU_MD_AIM32_FIELDS +#endif + +/* CPU feature flags, can be used for cached flow control. */ +#define PC_FLAG_NOSRS 0x80000000 + +#define BOOKE_CRITSAVE_LEN (CPUSAVE_LEN + 2) +#define BOOKE_TLB_MAXNEST 4 +#define BOOKE_TLB_SAVELEN 16 +#define BOOKE_TLBSAVE_LEN (BOOKE_TLB_SAVELEN * BOOKE_TLB_MAXNEST) + +#ifdef __powerpc64__ +#define BOOKE_PCPU_PAD 901 +#else +#define BOOKE_PCPU_PAD 365 +#endif +#define PCPU_MD_BOOKE_FIELDS \ + register_t critsave[BOOKE_CRITSAVE_LEN]; \ + register_t mchksave[CPUSAVE_LEN]; \ + register_t tlbsave[BOOKE_TLBSAVE_LEN]; \ + register_t tlb_level; \ + uintptr_t *tlb_lock; \ + int tid_next; \ + char __pad[BOOKE_PCPU_PAD]; + +/* Definitions for register offsets within the exception tmp save areas */ +#define CPUSAVE_R27 0 /* where r27 gets saved */ +#define CPUSAVE_R28 1 /* where r28 gets saved */ +#define CPUSAVE_R29 2 /* where r29 gets saved */ +#define CPUSAVE_R30 3 /* where r30 gets saved */ +#define CPUSAVE_R31 4 /* where r31 gets saved */ +#define CPUSAVE_AIM_DAR 5 /* where SPR_DAR gets saved */ +#define CPUSAVE_AIM_DSISR 6 /* where SPR_DSISR gets saved */ +#define CPUSAVE_BOOKE_DEAR 5 /* where SPR_DEAR gets saved */ +#define CPUSAVE_BOOKE_ESR 6 /* where SPR_ESR gets saved */ +#define CPUSAVE_SRR0 7 /* where SRR0 gets saved */ +#define CPUSAVE_SRR1 8 /* where SRR1 gets saved */ +#define BOOKE_CRITSAVE_SRR0 9 /* where real SRR0 gets saved (critical) */ +#define BOOKE_CRITSAVE_SRR1 10 /* where real SRR0 gets saved (critical) */ + +/* Book-E TLBSAVE is more elaborate */ +#define TLBSAVE_BOOKE_LR 0 +#define TLBSAVE_BOOKE_CR 1 +#define TLBSAVE_BOOKE_SRR0 2 +#define TLBSAVE_BOOKE_SRR1 3 +#define TLBSAVE_BOOKE_R20 4 +#define TLBSAVE_BOOKE_R21 5 +#define TLBSAVE_BOOKE_R22 6 +#define TLBSAVE_BOOKE_R23 7 +#define TLBSAVE_BOOKE_R24 8 +#define TLBSAVE_BOOKE_R25 9 +#define TLBSAVE_BOOKE_R26 10 +#define TLBSAVE_BOOKE_R27 11 +#define TLBSAVE_BOOKE_R28 12 +#define TLBSAVE_BOOKE_R29 13 +#define TLBSAVE_BOOKE_R30 14 +#define TLBSAVE_BOOKE_R31 15 + +#define PCPU_MD_FIELDS \ + PCPU_MD_COMMON_FIELDS \ + union { \ + struct { \ + PCPU_MD_AIM_FIELDS \ + } pc_aim; \ + struct { \ + PCPU_MD_BOOKE_FIELDS \ + } pc_booke; \ + } + +#ifdef _KERNEL + +#define pcpup (get_pcpu()) + +static __inline __pure2 struct thread * +__curthread(void) +{ + struct thread *td; +#ifdef __powerpc64__ + __asm __volatile("mr %0,13" : "=r"(td)); +#else + __asm __volatile("mr %0,2" : "=r"(td)); +#endif + return (td); +} +#define curthread (__curthread()) + +#define PCPU_GET(member) (pcpup->pc_ ## member) + +/* + * XXX The implementation of this operation should be made atomic + * with respect to preemption. + */ +#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) +#define PCPU_PTR(member) (&pcpup->pc_ ## member) +#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) + +#endif /* _KERNEL */ + +#endif /* !_MACHINE_PCPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pio.h b/lib/libc/include/powerpc64-freebsd-none/machine/pio.h new file mode 100644 index 0000000000000000000000000000000000000000..fd63a44b0ab4b60ce6cf78cd49057c6255ecafed --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pio.h @@ -0,0 +1,304 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed under OpenBSD by + * Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $NetBSD: pio.h,v 1.1 1998/05/15 10:15:54 tsubai Exp $ + * $OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $ + */ + +#ifndef _MACHINE_PIO_H_ +#define _MACHINE_PIO_H_ +/* + * I/O macros. + */ + +/* + * Use sync so that bus space operations cannot sneak out the bottom of + * mutex-protected sections (mutex release does not guarantee completion of + * accesses to caching-inhibited memory on some systems) + */ +#define powerpc_iomb() __asm __volatile("sync" : : : "memory") + +static __inline void +__outb(volatile u_int8_t *a, u_int8_t v) +{ + *a = v; + powerpc_iomb(); +} + +static __inline void +__outw(volatile u_int16_t *a, u_int16_t v) +{ + *a = v; + powerpc_iomb(); +} + +static __inline void +__outl(volatile u_int32_t *a, u_int32_t v) +{ + *a = v; + powerpc_iomb(); +} + +static __inline void +__outll(volatile u_int64_t *a, u_int64_t v) +{ + *a = v; + powerpc_iomb(); +} + +static __inline void +__outwrb(volatile u_int16_t *a, u_int16_t v) +{ + __asm__ volatile("sthbrx %0, 0, %1" :: "r"(v), "r"(a)); + powerpc_iomb(); +} + +static __inline void +__outlrb(volatile u_int32_t *a, u_int32_t v) +{ + __asm__ volatile("stwbrx %0, 0, %1" :: "r"(v), "r"(a)); + powerpc_iomb(); +} + +static __inline u_int8_t +__inb(volatile u_int8_t *a) +{ + u_int8_t _v_; + + _v_ = *a; + powerpc_iomb(); + return _v_; +} + +static __inline u_int16_t +__inw(volatile u_int16_t *a) +{ + u_int16_t _v_; + + _v_ = *a; + powerpc_iomb(); + return _v_; +} + +static __inline u_int32_t +__inl(volatile u_int32_t *a) +{ + u_int32_t _v_; + + _v_ = *a; + powerpc_iomb(); + return _v_; +} + +static __inline u_int64_t +__inll(volatile u_int64_t *a) +{ + u_int64_t _v_; + + _v_ = *a; + powerpc_iomb(); + return _v_; +} + +static __inline u_int16_t +__inwrb(volatile u_int16_t *a) +{ + u_int16_t _v_; + + __asm__ volatile("lhbrx %0, 0, %1" : "=r"(_v_) : "r"(a)); + powerpc_iomb(); + return _v_; +} + +static __inline u_int32_t +__inlrb(volatile u_int32_t *a) +{ + u_int32_t _v_; + + __asm__ volatile("lwbrx %0, 0, %1" : "=r"(_v_) : "r"(a)); + powerpc_iomb(); + return _v_; +} + +#define outb(a,v) (__outb((volatile u_int8_t *)(a), v)) +#define out8(a,v) outb(a,v) +#define outw(a,v) (__outw((volatile u_int16_t *)(a), v)) +#define out16(a,v) outw(a,v) +#define outl(a,v) (__outl((volatile u_int32_t *)(a), v)) +#define out32(a,v) outl(a,v) +#define outll(a,v) (__outll((volatile u_int64_t *)(a), v)) +#define out64(a,v) outll(a,v) +#define inb(a) (__inb((volatile u_int8_t *)(a))) +#define in8(a) inb(a) +#define inw(a) (__inw((volatile u_int16_t *)(a))) +#define in16(a) inw(a) +#define inl(a) (__inl((volatile u_int32_t *)(a))) +#define in32(a) inl(a) +#define inll(a) (__inll((volatile u_int64_t *)(a))) +#define in64(a) inll(a) + +#define out8rb(a,v) outb(a,v) +#define outwrb(a,v) (__outwrb((volatile u_int16_t *)(a), v)) +#define out16rb(a,v) outwrb(a,v) +#define outlrb(a,v) (__outlrb((volatile u_int32_t *)(a), v)) +#define out32rb(a,v) outlrb(a,v) +#define in8rb(a) inb(a) +#define inwrb(a) (__inwrb((volatile u_int16_t *)(a))) +#define in16rb(a) inwrb(a) +#define inlrb(a) (__inlrb((volatile u_int32_t *)(a))) +#define in32rb(a) inlrb(a) + +static __inline void +__outsb(volatile u_int8_t *a, const u_int8_t *s, size_t c) +{ + while (c--) + *a = *s++; + powerpc_iomb(); +} + +static __inline void +__outsw(volatile u_int16_t *a, const u_int16_t *s, size_t c) +{ + while (c--) + *a = *s++; + powerpc_iomb(); +} + +static __inline void +__outsl(volatile u_int32_t *a, const u_int32_t *s, size_t c) +{ + while (c--) + *a = *s++; + powerpc_iomb(); +} + +static __inline void +__outsll(volatile u_int64_t *a, const u_int64_t *s, size_t c) +{ + while (c--) + *a = *s++; + powerpc_iomb(); +} + +static __inline void +__outswrb(volatile u_int16_t *a, const u_int16_t *s, size_t c) +{ + while (c--) + __asm__ volatile("sthbrx %0, 0, %1" :: "r"(*s++), "r"(a)); + powerpc_iomb(); +} + +static __inline void +__outslrb(volatile u_int32_t *a, const u_int32_t *s, size_t c) +{ + while (c--) + __asm__ volatile("stwbrx %0, 0, %1" :: "r"(*s++), "r"(a)); + powerpc_iomb(); +} + +static __inline void +__insb(volatile u_int8_t *a, u_int8_t *d, size_t c) +{ + while (c--) + *d++ = *a; + powerpc_iomb(); +} + +static __inline void +__insw(volatile u_int16_t *a, u_int16_t *d, size_t c) +{ + while (c--) + *d++ = *a; + powerpc_iomb(); +} + +static __inline void +__insl(volatile u_int32_t *a, u_int32_t *d, size_t c) +{ + while (c--) + *d++ = *a; + powerpc_iomb(); +} + +static __inline void +__insll(volatile u_int64_t *a, u_int64_t *d, size_t c) +{ + while (c--) + *d++ = *a; + powerpc_iomb(); +} + +static __inline void +__inswrb(volatile u_int16_t *a, u_int16_t *d, size_t c) +{ + while (c--) + __asm__ volatile("lhbrx %0, 0, %1" : "=r"(*d++) : "r"(a)); + powerpc_iomb(); +} + +static __inline void +__inslrb(volatile u_int32_t *a, u_int32_t *d, size_t c) +{ + while (c--) + __asm__ volatile("lwbrx %0, 0, %1" : "=r"(*d++) : "r"(a)); + powerpc_iomb(); +} + +#define outsb(a,s,c) (__outsb((volatile u_int8_t *)(a), s, c)) +#define outs8(a,s,c) outsb(a,s,c) +#define outsw(a,s,c) (__outsw((volatile u_int16_t *)(a), s, c)) +#define outs16(a,s,c) outsw(a,s,c) +#define outsl(a,s,c) (__outsl((volatile u_int32_t *)(a), s, c)) +#define outs32(a,s,c) outsl(a,s,c) +#define outsll(a,s,c) (__outsll((volatile u_int64_t *)(a), s, c)) +#define outs64(a,s,c) outsll(a,s,c) +#define insb(a,d,c) (__insb((volatile u_int8_t *)(a), d, c)) +#define ins8(a,d,c) insb(a,d,c) +#define insw(a,d,c) (__insw((volatile u_int16_t *)(a), d, c)) +#define ins16(a,d,c) insw(a,d,c) +#define insl(a,d,c) (__insl((volatile u_int32_t *)(a), d, c)) +#define ins32(a,d,c) insl(a,d,c) +#define insll(a,d,c) (__insll((volatile u_int64_t *)(a), d, c)) +#define ins64(a,d,c) insll(a,d,c) + +#define outs8rb(a,s,c) outsb(a,s,c) +#define outswrb(a,s,c) (__outswrb((volatile u_int16_t *)(a), s, c)) +#define outs16rb(a,s,c) outswrb(a,s,c) +#define outslrb(a,s,c) (__outslrb((volatile u_int32_t *)(a), s, c)) +#define outs32rb(a,s,c) outslrb(a,s,c) +#define ins8rb(a,d,c) insb(a,d,c) +#define inswrb(a,d,c) (__inswrb((volatile u_int16_t *)(a), d, c)) +#define ins16rb(a,d,c) inswrb(a,d,c) +#define inslrb(a,d,c) (__inslrb((volatile u_int32_t *)(a), d, c)) +#define ins32rb(a,d,c) inslrb(a,d,c) + +#endif /*_MACHINE_PIO_H_*/ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/platform.h b/lib/libc/include/powerpc64-freebsd-none/machine/platform.h new file mode 100644 index 0000000000000000000000000000000000000000..51104cae74a455cc61e1ac0e929930b9a9bde11c --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/platform.h @@ -0,0 +1,76 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: powerpc.h,v 1.3 2000/06/01 00:49:59 matt Exp $ + */ + +#ifndef _MACHINE_PLATFORM_H_ +#define _MACHINE_PLATFORM_H_ + +#include +#include +#include + +struct mem_region { + uint64_t mr_start; + uint64_t mr_size; +}; + +struct numa_mem_region { + uint64_t mr_start; + uint64_t mr_size; + uint64_t mr_domain; +}; + +/* Documentation for these functions is in platform_if.m */ + +void mem_regions(struct mem_region **, int *, struct mem_region **, int *); +void numa_mem_regions(struct numa_mem_region **, int *); +vm_offset_t platform_real_maxaddr(void); + +u_long platform_timebase_freq(struct cpuref *); + +int platform_smp_first_cpu(struct cpuref *); +int platform_smp_next_cpu(struct cpuref *); +int platform_smp_get_bsp(struct cpuref *); +int platform_smp_start_cpu(struct pcpu *); +void platform_smp_timebase_sync(u_long tb, int ap); +void platform_smp_ap_init(void); +void platform_smp_probe_threads(void); +int platform_node_numa_domain(phandle_t); + +const char *installed_platform(void); +void platform_probe_and_attach(void); + +void platform_sleep(void); + +#endif /* _MACHINE_PLATFORM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/platformvar.h b/lib/libc/include/powerpc64-freebsd-none/machine/platformvar.h new file mode 100644 index 0000000000000000000000000000000000000000..dff641944a7fb4c82a0e2a2c9bfb1817ff633a10 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/platformvar.h @@ -0,0 +1,89 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2005 Peter Grehan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_PLATFORMVAR_H_ +#define _MACHINE_PLATFORMVAR_H_ + +/* + * A PowerPC platform implementation is declared with a kernel object and + * an associated method table, similar to a device driver. + * + * e.g. + * + * static platform_method_t chrp_methods[] = { + * PLATFORMMETHOD(platform_probe, chrp_probe), + * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions), + * ... + * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu), + * { 0, 0 } + * }; + * + * static platform_def_t chrp_platform = { + * "chrp", + * chrp_methods, + * sizeof(chrp_platform_softc), // or 0 if no softc + * }; + * + * PLATFORM_DEF(chrp_platform); + */ + +#include + +struct platform_kobj { + /* + * A platform instance is a kernel object + */ + KOBJ_FIELDS; + + /* + * Utility elements that an instance may use + */ + struct mtx platform_mtx; /* available for instance use */ + void *platform_iptr; /* instance data pointer */ + + /* + * Opaque data that can be overlaid with an instance-private + * structure. Platform code can test that this is large enough at + * compile time with a sizeof() test againt it's softc. There + * is also a run-time test when the platform kernel object is + * registered. + */ +#define PLATFORM_OPAQUESZ 64 + u_int platform_opaque[PLATFORM_OPAQUESZ]; +}; + +typedef struct platform_kobj *platform_t; +typedef struct kobj_class platform_def_t; +#define platform_method_t kobj_method_t + +#define PLATFORMMETHOD KOBJMETHOD +#define PLATFORMMETHOD_END KOBJMETHOD_END + +#define PLATFORM_DEF(name) DATA_SET(platform_set, name) + +#endif /* _MACHINE_PLATFORMVAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pmap.h b/lib/libc/include/powerpc64-freebsd-none/machine/pmap.h new file mode 100644 index 0000000000000000000000000000000000000000..e83a788689cf3083b81ec6bdc085928051eafa5b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pmap.h @@ -0,0 +1,361 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause AND BSD-4-Clause + * + * Copyright (C) 2006 Semihalf, Marian Balakowicz + * All rights reserved. + * + * Adapted for Freescale's e500 core CPUs. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*- + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * from: $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $ + */ + +#ifndef _MACHINE_PMAP_H_ +#define _MACHINE_PMAP_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __powerpc64__ +#include +#endif + +/* + * The radix page table structure is described by levels 1-4. + * See Fig 33. on p. 1002 of Power ISA v3.0B + * + * Page directories and tables must be size aligned. + */ + +/* Root page directory - 64k -- each entry covers 512GB */ +typedef uint64_t pml1_entry_t; +/* l2 page directory - 4k -- each entry covers 1GB */ +typedef uint64_t pml2_entry_t; +/* l3 page directory - 4k -- each entry covers 2MB */ +typedef uint64_t pml3_entry_t; +/* l4 page directory - 256B/4k -- each entry covers 64k/4k */ +typedef uint64_t pml4_entry_t; + +typedef uint64_t pt_entry_t; + +struct pmap; +typedef struct pmap *pmap_t; + +#define PMAP_ENTER_QUICK_LOCKED 0x10000000 + +#if !defined(NPMAPS) +#define NPMAPS 32768 +#endif /* !defined(NPMAPS) */ + +struct slbtnode; + +struct pvo_entry { + LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */ +#ifndef __powerpc64__ + LIST_ENTRY(pvo_entry) pvo_olink; /* Link to overflow entry */ +#endif + union { + RB_ENTRY(pvo_entry) pvo_plink; /* Link to pmap entries */ + SLIST_ENTRY(pvo_entry) pvo_dlink; /* Link to delete enty */ + }; + struct { +#ifndef __powerpc64__ + /* 32-bit fields */ + pte_t pte; +#endif + /* 64-bit fields */ + uintptr_t slot; + vm_paddr_t pa; + vm_prot_t prot; + } pvo_pte; + pmap_t pvo_pmap; /* Owning pmap */ + vm_offset_t pvo_vaddr; /* VA of entry */ + uint64_t pvo_vpn; /* Virtual page number */ +}; +LIST_HEAD(pvo_head, pvo_entry); +SLIST_HEAD(pvo_dlist, pvo_entry); +RB_HEAD(pvo_tree, pvo_entry); +int pvo_vaddr_compare(struct pvo_entry *, struct pvo_entry *); +RB_PROTOTYPE(pvo_tree, pvo_entry, pvo_plink, pvo_vaddr_compare); + +/* Used by 32-bit PMAP */ +#define PVO_PTEGIDX_MASK 0x007UL /* which PTEG slot */ +#define PVO_PTEGIDX_VALID 0x008UL /* slot is valid */ +/* Used by 64-bit PMAP */ +#define PVO_HID 0x008UL /* PVO entry in alternate hash*/ +/* Used by both */ +#define PVO_WIRED 0x010UL /* PVO entry is wired */ +#define PVO_MANAGED 0x020UL /* PVO entry is managed */ +#define PVO_BOOTSTRAP 0x080UL /* PVO entry allocated during + bootstrap */ +#define PVO_DEAD 0x100UL /* waiting to be deleted */ +#define PVO_LARGE 0x200UL /* large page */ +#define PVO_VADDR(pvo) ((pvo)->pvo_vaddr & ~ADDR_POFF) +#define PVO_PTEGIDX_GET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_MASK) +#define PVO_PTEGIDX_ISSET(pvo) ((pvo)->pvo_vaddr & PVO_PTEGIDX_VALID) +#define PVO_PTEGIDX_CLR(pvo) \ + ((void)((pvo)->pvo_vaddr &= ~(PVO_PTEGIDX_VALID|PVO_PTEGIDX_MASK))) +#define PVO_PTEGIDX_SET(pvo, i) \ + ((void)((pvo)->pvo_vaddr |= (i)|PVO_PTEGIDX_VALID)) +#define PVO_VSID(pvo) ((pvo)->pvo_vpn >> 16) + +struct pmap { + struct pmap_statistics pm_stats; + struct mtx pm_mtx; + cpuset_t pm_active; + union { + struct { + #ifdef __powerpc64__ + struct slbtnode *pm_slb_tree_root; + struct slb **pm_slb; + int pm_slb_len; + #else + register_t pm_sr[16]; + #endif + + struct pmap *pmap_phys; + struct pvo_tree pmap_pvo; + }; +#ifdef __powerpc64__ + /* Radix support */ + struct { + pml1_entry_t *pm_pml1; /* KVA of root page directory */ + struct vm_radix pm_radix; /* spare page table pages */ + TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ + uint64_t pm_pid; /* PIDR value */ + int pm_flags; + }; +#endif + struct { + /* TID to identify this pmap entries in TLB */ + tlbtid_t pm_tid[MAXCPU]; + +#ifdef __powerpc64__ + /* + * Page table directory, + * array of pointers to page directories. + */ + pte_t ****pm_root; +#else + /* + * Page table directory, + * array of pointers to page tables. + */ + pte_t **pm_pdir; + + /* List of allocated ptbl bufs (ptbl kva regions). */ + TAILQ_HEAD(, ptbl_buf) pm_ptbl_list; +#endif + }; + } __aligned(CACHE_LINE_SIZE); +}; + +/* + * pv_entries are allocated in chunks per-process. This avoids the + * need to track per-pmap assignments. + */ +#define _NPCPV 126 +#define _NPCM howmany(_NPCPV, 64) + +#define PV_CHUNK_HEADER \ + pmap_t pc_pmap; \ + TAILQ_ENTRY(pv_chunk) pc_list; \ + uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \ + TAILQ_ENTRY(pv_chunk) pc_lru; + +struct pv_entry { + pmap_t pv_pmap; + vm_offset_t pv_va; + TAILQ_ENTRY(pv_entry) pv_link; +}; +typedef struct pv_entry *pv_entry_t; + +struct pv_chunk_header { + PV_CHUNK_HEADER +}; +struct pv_chunk { + PV_CHUNK_HEADER + uint64_t reserved; + struct pv_entry pc_pventry[_NPCPV]; +}; + +struct md_page { + union { + struct { + volatile int32_t mdpg_attrs; + vm_memattr_t mdpg_cache_attrs; + struct pvo_head mdpg_pvoh; + int pv_gen; /* (p) */ + }; + struct { + int pv_tracked; + }; + }; + TAILQ_HEAD(, pv_entry) pv_list; /* (p) */ +}; + +#ifdef AIM +#define pmap_page_get_memattr(m) ((m)->md.mdpg_cache_attrs) +#else +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT +#endif /* AIM */ + +/* + * Return the VSID corresponding to a given virtual address. + * If no VSID is currently defined, it will allocate one, and add + * it to a free slot if available. + * + * NB: The PMAP MUST be locked already. + */ +uint64_t va_to_vsid(pmap_t pm, vm_offset_t va); + +/* Lock-free, non-allocating lookup routines */ +uint64_t kernel_va_to_slbv(vm_offset_t va); +struct slb *user_va_to_slb_entry(pmap_t pm, vm_offset_t va); + +uint64_t allocate_user_vsid(pmap_t pm, uint64_t esid, int large); +void free_vsid(pmap_t pm, uint64_t esid, int large); +void slb_insert_user(pmap_t pm, struct slb *slb); +void slb_insert_kernel(uint64_t slbe, uint64_t slbv); + +struct slbtnode *slb_alloc_tree(void); +void slb_free_tree(pmap_t pm); +struct slb **slb_alloc_user_cache(void); +void slb_free_user_cache(struct slb **); + +extern struct pmap kernel_pmap_store; +#define kernel_pmap (&kernel_pmap_store) + +#ifdef _KERNEL + +#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) +#define PMAP_LOCK_ASSERT(pmap, type) \ + mtx_assert(&(pmap)->pm_mtx, (type)) +#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) +#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, \ + (pmap == kernel_pmap) ? "kernelpmap" : \ + "pmap", NULL, MTX_DEF | MTX_DUPOK) +#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) +#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) +#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) +#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) + +#define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) + +#define pmap_vm_page_alloc_check(m) + +void pmap_bootstrap(vm_offset_t, vm_offset_t); +void pmap_kenter(vm_offset_t va, vm_paddr_t pa); +void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t); +void pmap_kremove(vm_offset_t); +void *pmap_mapdev(vm_paddr_t, vm_size_t); +void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t); +void pmap_unmapdev(void *, vm_size_t); +void pmap_page_set_memattr(vm_page_t, vm_memattr_t); +int pmap_change_attr(vm_offset_t, vm_size_t, vm_memattr_t); +int pmap_map_user_ptr(pmap_t pm, volatile const void *uaddr, + void **kaddr, size_t ulen, size_t *klen); +int pmap_decode_kernel_ptr(vm_offset_t addr, int *is_user, + vm_offset_t *decoded_addr); +void pmap_deactivate(struct thread *); +vm_paddr_t pmap_kextract(vm_offset_t); +int pmap_dev_direct_mapped(vm_paddr_t, vm_size_t); +bool pmap_mmu_install(char *name, int prio); +void pmap_mmu_init(void); +const char *pmap_mmu_name(void); +bool pmap_ps_enabled(pmap_t pmap); +int pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t flags); +bool pmap_page_is_mapped(vm_page_t m); +#define pmap_map_delete(pmap, sva, eva) pmap_remove(pmap, sva, eva) + +void pmap_page_array_startup(long count); + +#define vtophys(va) pmap_kextract((vm_offset_t)(va)) + +extern vm_offset_t virtual_avail; +extern vm_offset_t virtual_end; +extern caddr_t crashdumpmap; + +extern vm_offset_t msgbuf_phys; + +extern int pmap_bootstrapped; +extern int radix_mmu; +extern int superpages_enabled; + +#ifdef AIM +void pmap_early_io_map_init(void); +#endif +vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size); +void pmap_early_io_unmap(vm_offset_t va, vm_size_t size); +void pmap_track_page(pmap_t pmap, vm_offset_t va); +void pmap_page_print_mappings(vm_page_t m); +void pmap_tlbie_all(void); + +static inline int +pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) +{ + + return (0); +} + +#endif + +#endif /* !_MACHINE_PMAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pmc_mdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/pmc_mdep.h new file mode 100644 index 0000000000000000000000000000000000000000..3e772d63864fca9b5dec3388a3775dddad33221a --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pmc_mdep.h @@ -0,0 +1,95 @@ +/*- + * This file is in the public domain. + */ + +#ifndef _MACHINE_PMC_MDEP_H_ +#define _MACHINE_PMC_MDEP_H_ + +#define PMC_MDEP_CLASS_INDEX_POWERPC 1 + +union pmc_md_op_pmcallocate { + uint32_t pm_event; + uint64_t __pad[4]; +}; + +/* Logging */ +#ifdef __powerpc64__ +#define PMCLOG_READADDR PMCLOG_READ64 +#define PMCLOG_EMITADDR PMCLOG_EMIT64 +#else +#define PMCLOG_READADDR PMCLOG_READ32 +#define PMCLOG_EMITADDR PMCLOG_EMIT32 +#endif + +#define mtpmr(reg, val) \ + __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val)) +#define mfpmr(reg) \ + ( { register_t val; \ + __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg)); \ + val; } ) + +#define PMR_PMC0 16 +#define PMR_PMC1 17 +#define PMR_PMC2 18 +#define PMR_PMC3 19 +#define PMR_PMLCa0 144 +#define PMLCax_FC 0x80000000 +#define PMLCax_FCS 0x40000000 +#define PMLCax_FCU 0x20000000 +#define PMLCax_FCM1 0x10000000 +#define PMLCax_FCM0 0x08000000 +#define PMLCax_CE 0x04000000 +#define PMLCax_EVENT(x) ((x) << 16) +#define PMLCax_FCGS1 0x00000002 +#define PMLCax_FCGS0 0x00000001 +#define PMR_PMLCa1 145 +#define PMR_PMLCa2 146 +#define PMR_PMLCa3 147 +#define PMR_PMLCb0 272 +#define PMLCbx_TRIGONCTL(x) ((x) << 28) +#define PMLCbx_TRIGOFFCTL(x) ((x) << 24) +#define PMLCbx_PMCC 0x00800000 +#define PMLCbx_PMP(x) ((x) << 13) +#define PMLCbx_TREHMUL(x) ((x) << 8) +#define PMLCbx_TRESHOLD(x) ((x) << 0) +#define PMR_PMLCb1 273 +#define PMR_PMLCb2 274 +#define PMR_PMLCb3 275 +#define PMR_PMGC0 400 +#define PMGC_FAC 0x80000000 +#define PMGC_PMIE 0x40000000 +#define PMGC_FCECE 0x20000000 +#define PMGC_TBSEL(x) ((x) << 11) +#define PMGC_TBEE 0x00000100 +#define PMR_UPMC0 0 +#define PMR_UPMC1 1 +#define PMR_UPMC2 2 +#define PMR_UPMC3 3 +#define PMR_UPMLCa0 128 +#define PMR_UPMLCa1 129 +#define PMR_UPMLCa2 130 +#define PMR_UPMLCa3 131 +#define PMR_UPMLCb0 256 +#define PMR_UPMLCb1 257 +#define PMR_UPMLCb2 258 +#define PMR_UPMLCb3 259 +#define PMR_UPMGC0 384 + +#if _KERNEL + +struct pmc_md_powerpc_pmc { + uint64_t pm_powerpc_overflowcnt; + uint32_t pm_powerpc_evsel; +}; + +union pmc_md_pmc { + struct pmc_md_powerpc_pmc pm_powerpc; +}; + +#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0) +#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1]) +#define PMC_TRAPFRAME_TO_SP(TF) (0) + +#endif + +#endif /* !_MACHINE_PMC_MDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/proc.h b/lib/libc/include/powerpc64-freebsd-none/machine/proc.h new file mode 100644 index 0000000000000000000000000000000000000000..a5eeb66941386aa528815a4fa37637fbc69178d5 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/proc.h @@ -0,0 +1,61 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: proc.h,v 1.2 1997/04/16 22:57:48 thorpej Exp $ + */ + +#ifndef _MACHINE_PROC_H_ +#define _MACHINE_PROC_H_ + +/* + * Machine-dependent part of the proc structure + */ +struct mdthread { + int md_spinlock_count; /* (k) */ + register_t md_saved_msr; /* (k) */ +}; + +struct mdproc { + /* + * Avoid empty structs because they are undefined behavior. + */ + long md_spare; +}; + +#ifdef __powerpc64__ +#define KINFO_PROC_SIZE 1088 +#define KINFO_PROC32_SIZE 816 +#else +#define KINFO_PROC_SIZE 816 +#endif + +#endif /* !_MACHINE_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/profile.h b/lib/libc/include/powerpc64-freebsd-none/machine/profile.h new file mode 100644 index 0000000000000000000000000000000000000000..054386a5aa625eb20f065a2ecb7729c6cc7fa521 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/profile.h @@ -0,0 +1,234 @@ +/*- + * SPDX-License-Identifier: MIT-CMU + * + * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + * + * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp + * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 + */ + +#ifndef _MACHINE_PROFILE_H_ +#define _MACHINE_PROFILE_H_ + +#define _MCOUNT_DECL void __mcount + +#define FUNCTION_ALIGNMENT 4 + +typedef __ptrdiff_t fptrdiff_t; + +/* + * The mcount trampoline macro, expanded in libc/gmon/mcount.c + * + * For PowerPC SVR4 ABI profiling, the compiler will insert + * a data declaration and code sequence at the start of a routine of the form + * + * .function_mc: .data + * .align 2 + * .long 0 + * .text + * + * function: mflr %r0 + * addis %r11,%r0, .function_mc@ha + * stw %r0,4(%r1) + * addi %r0,%r11, .function_mc@l + * bl _mcount + * + * The link register is saved in the LR save word in the caller's + * stack frame, r0 is set up to point to the allocated longword, + * and control is transferred to _mcount. + * + * On return from _mcount, the routine should function as it would + * with no profiling so _mcount must restore register state to that upon + * entry. Any routine called by the _mcount trampoline will save + * callee-save registers, so _mcount must make sure it saves volatile + * registers that may have state after it returns i.e. parameter registers. + * + * The FreeBSD libc mcount routine ignores the r0 longword pointer, but + * instead requires as parameters the current PC and called PC. The current + * PC is obtained from the link register, as a result of "bl _mcount" in + * the stub, while the caller's PC is obtained from the LR save word. + * + * On return from libc mcount, the return is done indirectly with the + * ctr register rather than the link register, to allow the link register + * to be restored to what it was on entry to the profiled routine. + */ + +#if defined(__powerpc64__) + +#if !defined(_CALL_ELF) || _CALL_ELF == 1 +#define MCOUNT_PREAMBLE \ + " .align 2 \n" \ + " .globl _mcount \n" \ + " .section \".opd\",\"aw\" \n" \ + " .align 3 \n" \ + "_mcount: \n" \ + " .quad .L._mcount,.TOC.@tocbase,0\n" \ + " .previous \n" \ + " .size _mcount,24 \n" \ + " .type _mcount,@function \n" \ + " .align 4 \n" \ + ".L._mcount: \n" +#else +#define MCOUNT_PREAMBLE \ + " .globl _mcount \n" \ + " .type _mcount,@function \n" \ + " .align 4 \n" \ + "_mcount: \n" +#endif + +#define MCOUNT \ +__asm( MCOUNT_PREAMBLE \ + " stdu %r1,-(288+128)(%r1) \n" \ + " std %r3,48(%r1) \n" \ + " std %r4,56(%r1) \n" \ + " std %r5,64(%r1) \n" \ + " std %r6,72(%r1) \n" \ + " std %r7,80(%r1) \n" \ + " std %r8,88(%r1) \n" \ + " std %r9,96(%r1) \n" \ + " std %r10,104(%r1) \n" \ + " mflr %r4 \n" \ + " std %r4,112(%r1) \n" \ + " ld %r3,0(%r1) \n" \ + " ld %r3,0(%r3) \n" \ + " ld %r3,16(%r3) \n" \ + " bl __mcount \n" \ + " nop \n" \ + " ld %r4,112(%r1) \n" \ + " mtlr %r4 \n" \ + " ld %r3,48(%r1) \n" \ + " ld %r4,56(%r1) \n" \ + " ld %r5,64(%r1) \n" \ + " ld %r6,72(%r1) \n" \ + " ld %r7,80(%r1) \n" \ + " ld %r8,88(%r1) \n" \ + " ld %r9,96(%r1) \n" \ + " ld %r10,104(%r1) \n" \ + " addi %r1,%r1,(288+128) \n" \ + " blr \n"); +#else + +#ifdef PIC +#define _PLT "@plt" +#else +#define _PLT +#endif + +#define MCOUNT \ +__asm( " .globl _mcount \n" \ + " .type _mcount,@function \n" \ + " .align 4 \n" \ + "_mcount: \n" \ + " stwu %r1,-64(%r1) \n" \ + " stw %r3,16(%r1) \n" \ + " stw %r4,20(%r1) \n" \ + " stw %r5,24(%r1) \n" \ + " stw %r6,28(%r1) \n" \ + " stw %r7,32(%r1) \n" \ + " stw %r8,36(%r1) \n" \ + " stw %r9,40(%r1) \n" \ + " stw %r10,44(%r1) \n" \ + " mflr %r4 \n" \ + " stw %r4,48(%r1) \n" \ + " lwz %r3,68(%r1) \n" \ + " bl __mcount" _PLT " \n" \ + " lwz %r3,68(%r1) \n" \ + " mtlr %r3 \n" \ + " lwz %r4,48(%r1) \n" \ + " mtctr %r4 \n" \ + " lwz %r3,16(%r1) \n" \ + " lwz %r4,20(%r1) \n" \ + " lwz %r5,24(%r1) \n" \ + " lwz %r6,28(%r1) \n" \ + " lwz %r7,32(%r1) \n" \ + " lwz %r8,36(%r1) \n" \ + " lwz %r9,40(%r1) \n" \ + " lwz %r10,44(%r1) \n" \ + " addi %r1,%r1,64 \n" \ + " bctr \n" \ + "_mcount_end: \n" \ + " .size _mcount,_mcount_end-_mcount"); +#endif + +#ifdef _KERNEL +#define MCOUNT_ENTER(s) s = intr_disable() +#define MCOUNT_EXIT(s) intr_restore(s) +#define MCOUNT_DECL(s) register_t s; + +#ifndef COMPILING_LINT +#ifdef AIM +#include +#define __PROFILE_VECTOR_BASE EXC_RST +#define __PROFILE_VECTOR_TOP (EXC_LAST + 0x100) +#endif /* AIM */ +#if defined(BOOKE) +extern char interrupt_vector_base[]; +extern char interrupt_vector_top[]; +#define __PROFILE_VECTOR_BASE (uintfptr_t)interrupt_vector_base +#define __PROFILE_VECTOR_TOP (uintfptr_t)interrupt_vector_top +#endif /* BOOKE_E500 */ + +#endif /* !COMPILING_LINT */ + +#ifndef __PROFILE_VECTOR_BASE +#define __PROFILE_VECTOR_BASE 0 +#endif +#ifndef __PROFILE_VECTOR_TOP +#define __PROFILE_VECTOR_TOP 1 +#endif + +static __inline void +powerpc_profile_interrupt(void) +{ +} + +static __inline void +powerpc_profile_userspace(void) +{ +} + +#define MCOUNT_FROMPC_USER(pc) \ + ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? \ + (uintfptr_t)powerpc_profile_userspace : pc) + +#define MCOUNT_FROMPC_INTR(pc) \ + ((pc >= __PROFILE_VECTOR_BASE && \ + pc < __PROFILE_VECTOR_TOP) ? \ + (uintfptr_t)powerpc_profile_interrupt : ~0U) + +void __mcount(uintfptr_t frompc, uintfptr_t selfpc); + +#else /* !_KERNEL */ + +#ifdef __powerpc64__ +typedef u_long uintfptr_t; +#else +typedef u_int uintfptr_t; +#endif + +#endif /* _KERNEL */ + +#endif /* !_MACHINE_PROFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/psl.h b/lib/libc/include/powerpc64-freebsd-none/machine/psl.h new file mode 100644 index 0000000000000000000000000000000000000000..b8aed73f27df3fb8fb09300da0993f360c789f25 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/psl.h @@ -0,0 +1,101 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: psl.h,v 1.5 2000/11/19 19:52:37 matt Exp $ + */ + +#ifndef _MACHINE_PSL_H_ +#define _MACHINE_PSL_H_ + +/* + * Machine State Register (MSR) - All cores + */ +#define PSL_VEC 0x02000000UL /* AltiVec/SPE vector unit available */ +#define PSL_VSX 0x00800000UL /* Vector-Scalar unit available */ +#define PSL_EE 0x00008000UL /* external interrupt enable */ +#define PSL_PR 0x00004000UL /* privilege mode (1 == user) */ +#define PSL_FP 0x00002000UL /* floating point enable */ +#define PSL_ME 0x00001000UL /* machine check enable */ +#define PSL_FE0 0x00000800UL /* floating point interrupt mode 0 */ +#define PSL_FE1 0x00000100UL /* floating point interrupt mode 1 */ +#define PSL_PMM 0x00000004UL /* performance monitor mark */ +#define PSL_RI 0x00000002UL /* recoverable interrupt */ + +/* Machine State Register - Book-E cores */ +#ifdef __powerpc64__ +#define PSL_CM 0x80000000UL /* Computation Mode (64-bit) */ +#endif + +#define PSL_GS 0x10000000UL /* Guest state */ +#define PSL_UCLE 0x04000000UL /* User mode cache lock enable */ +#define PSL_WE 0x00040000UL /* Wait state enable */ +#define PSL_CE 0x00020000UL /* Critical interrupt enable */ +#define PSL_UBLE 0x00000400UL /* BTB lock enable - e500 only */ +#define PSL_DWE 0x00000400UL /* Debug Wait Enable - 440 only*/ +#define PSL_DE 0x00000200UL /* Debug interrupt enable */ +#define PSL_IS 0x00000020UL /* Instruction address space */ +#define PSL_DS 0x00000010UL /* Data address space */ + +/* Machine State Register (MSR) - AIM cores */ +#ifdef __powerpc64__ +#define PSL_SF 0x8000000000000000UL /* 64-bit addressing */ +#define PSL_HV 0x1000000000000000UL /* hyper-privileged mode */ +#endif + +#define PSL_POW 0x00040000UL /* power management */ +#define PSL_ILE 0x00010000UL /* interrupt endian mode (1 == le) */ +#define PSL_SE 0x00000400UL /* single-step trace enable */ +#define PSL_BE 0x00000200UL /* branch trace enable */ +#define PSL_IP 0x00000040UL /* interrupt prefix - 601 only */ +#define PSL_IR 0x00000020UL /* instruction address relocation */ +#define PSL_DR 0x00000010UL /* data address relocation */ +#define PSL_LE 0x00000001UL /* endian mode (1 == le) */ + +/* + * Floating-point exception modes: + */ +#define PSL_FE_DIS 0 /* none */ +#define PSL_FE_NONREC PSL_FE1 /* imprecise non-recoverable */ +#define PSL_FE_REC PSL_FE0 /* imprecise recoverable */ +#define PSL_FE_PREC (PSL_FE0 | PSL_FE1) /* precise */ +#define PSL_FE_DFLT PSL_FE_PREC /* default == precise */ + +#ifndef LOCORE +extern register_t psl_kernset; /* Default MSR values for kernel */ +extern register_t psl_userset; /* Default MSR values for userland */ +#ifdef __powerpc64__ +extern register_t psl_userset32; /* Default user MSR values for 32-bit */ +#endif +extern register_t psl_userstatic; /* Bits of SRR1 userland may not set */ +#endif + +#endif /* _MACHINE_PSL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/pte.h b/lib/libc/include/powerpc64-freebsd-none/machine/pte.h new file mode 100644 index 0000000000000000000000000000000000000000..24ef8d98694299428304ea0daa303bebf3464f7e --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/pte.h @@ -0,0 +1,432 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: pte.h,v 1.2 1998/08/31 14:43:40 tsubai Exp $ + */ + +#ifndef _MACHINE_PTE_H_ +#define _MACHINE_PTE_H_ + +#if defined(AIM) + +/* + * Page Table Entries + */ +#ifndef LOCORE + +/* 32-bit PTE */ +struct pte { + u_int32_t pte_hi; + u_int32_t pte_lo; +}; + +struct pteg { + struct pte pt[8]; +}; + +/* 64-bit (long) PTE */ +struct lpte { + u_int64_t pte_hi; + u_int64_t pte_lo; +}; + +struct lpteg { + struct lpte pt[8]; +}; + +/* Partition table entry */ +struct pate { + u_int64_t pagetab; + u_int64_t proctab; +}; + +/* Process table entry */ +struct prte { + u_int64_t proctab0; + u_int64_t proctab1; +}; + +typedef struct pte pte_t; +typedef struct lpte lpte_t; +#endif /* LOCORE */ + +/* 32-bit PTE definitions */ + +/* High word: */ +#define PTE_VALID 0x80000000 +#define PTE_VSID_SHFT 7 +#define PTE_HID 0x00000040 +#define PTE_API 0x0000003f +/* Low word: */ +#define PTE_RPGN 0xfffff000 +#define PTE_REF 0x00000100 +#define PTE_CHG 0x00000080 +#define PTE_WIMG 0x00000078 +#define PTE_W 0x00000040 +#define PTE_I 0x00000020 +#define PTE_M 0x00000010 +#define PTE_G 0x00000008 +#define PTE_PP 0x00000003 +#define PTE_SO 0x00000000 /* Super. Only (U: XX, S: RW) */ +#define PTE_SW 0x00000001 /* Super. Write-Only (U: RO, S: RW) */ +#define PTE_BW 0x00000002 /* Supervisor (U: RW, S: RW) */ +#define PTE_BR 0x00000003 /* Both Read Only (U: RO, S: RO) */ +#define PTE_RW PTE_BW +#define PTE_RO PTE_BR + +#define PTE_EXEC 0x00000200 /* pseudo bit in attrs; page is exec */ + +/* 64-bit PTE definitions */ + +/* High quadword: */ +#define LPTE_VSID_SHIFT 12 +#define LPTE_AVPN_MASK 0xFFFFFFFFFFFFFF80ULL +#define LPTE_AVA_MASK 0x3FFFFFFFFFFFFF80ULL +#define LPTE_API 0x0000000000000F80ULL +#define LPTE_SWBITS 0x0000000000000078ULL +#define LPTE_WIRED 0x0000000000000010ULL +#define LPTE_LOCKED 0x0000000000000008ULL +#define LPTE_BIG 0x0000000000000004ULL /* 4kb/16Mb page */ +#define LPTE_HID 0x0000000000000002ULL +#define LPTE_VALID 0x0000000000000001ULL + +/* Low quadword: */ +#define LP_4K_16M 0x38 /* 4KB base, 16MB actual page size */ + +#define EXTEND_PTE(x) UINT64_C(x) /* make constants 64-bit */ +#define LPTE_RPGN 0xfffffffffffff000ULL +#define LPTE_LP_MASK 0x00000000000ff000ULL +#define LPTE_LP_SHIFT 12 +#define LPTE_LP_4K_16M ((unsigned long long)(LP_4K_16M) << LPTE_LP_SHIFT) +#define LPTE_REF EXTEND_PTE( PTE_REF ) +#define LPTE_CHG EXTEND_PTE( PTE_CHG ) +#define LPTE_WIMG EXTEND_PTE( PTE_WIMG ) +#define LPTE_W EXTEND_PTE( PTE_W ) +#define LPTE_I EXTEND_PTE( PTE_I ) +#define LPTE_M EXTEND_PTE( PTE_M ) +#define LPTE_G EXTEND_PTE( PTE_G ) +#define LPTE_NOEXEC 0x0000000000000004ULL +#define LPTE_PP EXTEND_PTE( PTE_PP ) + +#define LPTE_SO EXTEND_PTE( PTE_SO ) /* Super. Only */ +#define LPTE_SW EXTEND_PTE( PTE_SW ) /* Super. Write-Only */ +#define LPTE_BW EXTEND_PTE( PTE_BW ) /* Supervisor */ +#define LPTE_BR EXTEND_PTE( PTE_BR ) /* Both Read Only */ +#define LPTE_RW LPTE_BW +#define LPTE_RO LPTE_BR + +/* HPT superpage definitions */ +#define HPT_SP_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT) +#define HPT_SP_SIZE (1 << HPT_SP_SHIFT) +#define HPT_SP_MASK (HPT_SP_SIZE - 1) +#define HPT_SP_PAGES (1 << VM_LEVEL_0_ORDER) + +/* POWER ISA 3.0 Radix Table Definitions */ +#define RPTE_VALID 0x8000000000000000ULL +#define RPTE_LEAF 0x4000000000000000ULL /* is a PTE: always 1 */ +#define RPTE_SW0 0x2000000000000000ULL +#define RPTE_RPN_MASK 0x00FFFFFFFFFFF000ULL +#define RPTE_RPN_SHIFT 12 +#define RPTE_SW1 0x0000000000000800ULL +#define RPTE_SW2 0x0000000000000400ULL +#define RPTE_SW3 0x0000000000000200ULL +#define RPTE_R 0x0000000000000100ULL +#define RPTE_C 0x0000000000000080ULL + +#define RPTE_MANAGED RPTE_SW1 +#define RPTE_WIRED RPTE_SW2 +#define RPTE_PROMOTED RPTE_SW3 + +#define RPTE_ATTR_MASK 0x0000000000000030ULL +#define RPTE_ATTR_MEM 0x0000000000000000ULL /* PTE M */ +#define RPTE_ATTR_SAO 0x0000000000000010ULL /* PTE WIM */ +#define RPTE_ATTR_GUARDEDIO 0x0000000000000020ULL /* PTE IMG */ +#define RPTE_ATTR_UNGUARDEDIO 0x0000000000000030ULL /* PTE IM */ + +#define RPTE_EAA_MASK 0x000000000000000FULL +#define RPTE_EAA_P 0x0000000000000008ULL /* Supervisor only */ +#define RPTE_EAA_R 0x0000000000000004ULL /* Read allowed */ +#define RPTE_EAA_W 0x0000000000000002ULL /* Write (+read) */ +#define RPTE_EAA_X 0x0000000000000001ULL /* Execute allowed */ + +#define RPDE_VALID RPTE_VALID +#define RPDE_LEAF RPTE_LEAF /* is a PTE: always 0 */ +#define RPDE_NLB_MASK 0x00FFFFFFFFFFFF00ULL +#define RPDE_NLB_SHIFT 8 +#define RPDE_NLS_MASK 0x000000000000001FULL + +#define PG_FRAME (0x000ffffffffff000ul) +#define PG_PS_FRAME (0x000fffffffe00000ul) +/* + * Extract bits from address + */ +#define ADDR_SR_SHFT 28 +#define ADDR_PIDX 0x0ffff000UL +#define ADDR_PIDX_SHFT 12 +#define ADDR_API_SHFT 22 +#define ADDR_API_SHFT64 16 +#define ADDR_POFF 0x00000fffUL + +/* + * Bits in DSISR: + */ +#define DSISR_DIRECT 0x80000000 +#define DSISR_NOTFOUND 0x40000000 +#define DSISR_PROTECT 0x08000000 +#define DSISR_INVRX 0x04000000 +#define DSISR_STORE 0x02000000 +#define DSISR_DABR 0x00400000 +#define DSISR_SEGMENT 0x00200000 +#define DSISR_EAR 0x00100000 + +/* + * Bits in SRR1 on ISI: + */ +#define ISSRR1_NOTFOUND 0x40000000 +#define ISSRR1_DIRECT 0x10000000 +#define ISSRR1_PROTECT 0x08000000 +#define ISSRR1_SEGMENT 0x00200000 + +#else /* BOOKE */ + +#include + +/* + * Flags for pte_remove() routine. + */ +#define PTBL_HOLD 0x00000001 /* do not unhold ptbl pages */ +#define PTBL_UNHOLD 0x00000002 /* unhold and attempt to free ptbl pages */ + +#define PTBL_HOLD_FLAG(pmap) (((pmap) == kernel_pmap) ? PTBL_HOLD : PTBL_UNHOLD) + +/* + * Page Table Entry definitions and macros. + * + * RPN need only be 32-bit because Book-E has 36-bit addresses, and the smallest + * page size is 4k (12-bit mask), so RPN can really fit into 24 bits. + */ +#ifndef LOCORE +typedef uint64_t pte_t; +#endif + +/* RPN mask, TLB0 4K pages */ +#define PTE_PA_MASK PAGE_MASK + +#if defined(BOOKE_E500) + +/* PTE bits assigned to MAS2, MAS3 flags */ +#define PTE_MAS2_SHIFT 19 +#define PTE_W (MAS2_W << PTE_MAS2_SHIFT) +#define PTE_I (MAS2_I << PTE_MAS2_SHIFT) +#define PTE_M (MAS2_M << PTE_MAS2_SHIFT) +#define PTE_G (MAS2_G << PTE_MAS2_SHIFT) +#define PTE_MAS2_MASK (MAS2_G | MAS2_M | MAS2_I | MAS2_W) + +#define PTE_MAS3_SHIFT 2 +#define PTE_UX (MAS3_UX << PTE_MAS3_SHIFT) +#define PTE_SX (MAS3_SX << PTE_MAS3_SHIFT) +#define PTE_UW (MAS3_UW << PTE_MAS3_SHIFT) +#define PTE_SW (MAS3_SW << PTE_MAS3_SHIFT) +#define PTE_UR (MAS3_UR << PTE_MAS3_SHIFT) +#define PTE_SR (MAS3_SR << PTE_MAS3_SHIFT) +#define PTE_MAS3_MASK ((MAS3_UX | MAS3_SX | MAS3_UW \ + | MAS3_SW | MAS3_UR | MAS3_SR) << PTE_MAS3_SHIFT) + +#define PTE_PS_SHIFT 8 +#define PTE_PS_4KB (2 << PTE_PS_SHIFT) + +#endif + +/* Other PTE flags */ +#define PTE_VALID 0x00000001 /* Valid */ +#define PTE_MODIFIED 0x00001000 /* Modified */ +#define PTE_WIRED 0x00002000 /* Wired */ +#define PTE_MANAGED 0x00000002 /* Managed */ +#define PTE_REFERENCED 0x00040000 /* Referenced */ + +/* + * Page Table Entry definitions and macros. + * + * We use the hardware page table entry format: + * + * 63 24 23 19 18 17 14 13 12 11 8 7 6 5 4 3 2 1 0 + * --------------------------------------------------------------- + * ARPN(12:51) WIMGE R U0:U3 SW0 C PSIZE UX SX UW SW UR SR SW1 V + * --------------------------------------------------------------- + */ + +/* PTE fields. */ +#define PTE_TSIZE_SHIFT (63-54) +#define PTE_TSIZE_MASK 0x7 +#define PTE_TSIZE_SHIFT_DIRECT (63-55) +#define PTE_TSIZE_MASK_DIRECT 0xf +#define PTE_PS_DIRECT(ps) (ps<> PTE_TSIZE_SHIFT) & PTE_TSIZE_MASK) +#define PTE_TSIZE_DIRECT(pte) (int)((*pte >> PTE_TSIZE_SHIFT_DIRECT) & PTE_TSIZE_MASK_DIRECT) + +/* Macro argument must of pte_t type. */ +#define PTE_ARPN_SHIFT 12 +#define PTE_FLAGS_MASK 0x00ffffff +#define PTE_RPN_FROM_PA(pa) (((pa) & ~PAGE_MASK) << PTE_ARPN_SHIFT) +#define PTE_PA(pte) ((vm_paddr_t)(*pte >> PTE_ARPN_SHIFT) & ~PAGE_MASK) +#define PTE_ISVALID(pte) ((*pte) & PTE_VALID) +#define PTE_ISWIRED(pte) ((*pte) & PTE_WIRED) +#define PTE_ISMANAGED(pte) ((*pte) & PTE_MANAGED) +#define PTE_ISMODIFIED(pte) ((*pte) & PTE_MODIFIED) +#define PTE_ISREFERENCED(pte) ((*pte) & PTE_REFERENCED) + +#endif /* BOOKE */ + +/* Book-E page table format, broken out for the generic pmap.h. */ +#ifdef __powerpc64__ + +#include + +/* + * The virtual address is: + * + * 4K page size + * +-----+-----------+-------+-------------+-------------+----------------+ + * | - | pg_root |pdir_l1| dir# | pte# | off in 4K page | + * +-----+-----------+-------+-------------+-------------+----------------+ + * 63 52 51 39 38 30 29 ^ 21 20 ^ 12 11 0 + * | | + * index in 1 page of pointers + * + * 1st level - Root page table + * + * pp2d consists of PG_ROOT_NENTRIES entries, each being a pointer to + * second level entity, i.e. the page table directory (pdir). + */ +#define PG_ROOT_H 51 +#define PG_ROOT_L 39 +#define PG_ROOT_SIZE (1UL << PG_ROOT_L) /* va range mapped by pp2d */ +#define PG_ROOT_SHIFT PG_ROOT_L +#define PG_ROOT_NUM (PG_ROOT_H - PG_ROOT_L + 1) +#define PG_ROOT_MASK ((1 << PG_ROOT_NUM) - 1) +#define PG_ROOT_IDX(va) ((va >> PG_ROOT_SHIFT) & PG_ROOT_MASK) +#define PG_ROOT_NENTRIES (1 << PG_ROOT_NUM) +#define PG_ROOT_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry **)) */ + +/* + * 2nd level - page directory directory (pdir l1) + * + * pdir consists of PDIR_NENTRIES entries, each being a pointer to + * second level entity, i.e. the actual page table (ptbl). + */ +#define PDIR_L1_H (PG_ROOT_L-1) +#define PDIR_L1_L 30 +#define PDIR_L1_NUM (PDIR_L1_H-PDIR_L1_L+1) +#define PDIR_L1_SIZE (1 << PDIR_L1_L) /* va range mapped by pdir */ +#define PDIR_L1_MASK ((1<> PDIR_L1_SHIFT) & PDIR_L1_MASK) +#define PDIR_L1_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */ +#define PDIR_L1_PAGES ((PDIR_L1_NENTRIES * (1<> PDIR_SHIFT) & PDIR_MASK) +#define PDIR_ENTRY_SHIFT 3 /* log2 (sizeof(struct pte_entry *)) */ +#define PDIR_PAGES ((PDIR_NENTRIES * (1<> PTBL_SHIFT) & PTBL_MASK) +#define PTBL_ENTRY_SHIFT 3 /* log2 (sizeof (struct pte_entry)) */ +#define PTBL_PAGES ((PTBL_NENTRIES * (1<> PDIR_SHIFT) + +#define PDIR_ENTRY_SHIFT 2 /* entry size is 2^2 = 4 bytes */ + +/* + * 2nd level - page table (ptbl) + * + * Page table covers 1024 page table entries. Page + * table entry (pte) is 32 bit wide and defines mapping + * for a single page. + */ +#define PTBL_SHIFT PAGE_SHIFT +#define PTBL_SIZE PAGE_SIZE /* va range mapped by ptbl entry */ +#define PTBL_MASK ((PDIR_SIZE - 1) & ~((1 << PAGE_SHIFT) - 1)) +#define PTBL_NENTRIES 1024 /* number of pages mapped by ptbl */ + +/* Returns ptbl entry number for given va */ +#define PTBL_IDX(va) (((va) & PTBL_MASK) >> PTBL_SHIFT) + +/* Size of ptbl in pages, 1024 entries, each sizeof(struct pte_entry). */ +#define PTBL_PAGES 2 +#define PTBL_ENTRY_SHIFT 3 /* entry size is 2^3 = 8 bytes */ + +#endif +#endif /* _MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ptrace.h b/lib/libc/include/powerpc64-freebsd-none/machine/ptrace.h new file mode 100644 index 0000000000000000000000000000000000000000..64bd0b7b7ab1928b0279ca75d1b28d4308bf2c5b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ptrace.h @@ -0,0 +1,42 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2014 Justin Hibbits + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_PTRACE_H_ +#define _MACHINE_PTRACE_H_ + +#define __HAVE_PTRACE_MACHDEP + +#define PT_GETVRREGS (PT_FIRSTMACH + 0) +#define PT_SETVRREGS (PT_FIRSTMACH + 1) +#define PT_GETVSRREGS (PT_FIRSTMACH + 2) +#define PT_SETVSRREGS (PT_FIRSTMACH + 3) + +#endif \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/reg.h b/lib/libc/include/powerpc64-freebsd-none/machine/reg.h new file mode 100644 index 0000000000000000000000000000000000000000..b3be9b413b0aeabaf92d195832e55389fa7a2dcc --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/reg.h @@ -0,0 +1,87 @@ +/* $NetBSD: reg.h,v 1.4 2000/06/04 09:30:44 tsubai Exp $ */ + +#ifndef _POWERPC_REG_H_ +#define _POWERPC_REG_H_ + +#include + +/* Must match struct trapframe */ +struct reg { + __register_t fixreg[32]; + __register_t lr; + __register_t cr; + __register_t xer; + __register_t ctr; + __register_t pc; +}; + +struct fpreg { + double fpreg[32]; + double fpscr; +}; + +/* Must match pcb.pcb_vec */ +struct vmxreg { + __uint32_t vr[32][4]; + __uint32_t pad[2]; + __uint32_t vrsave; + __uint32_t vscr; +}; + +struct dbreg { + unsigned int junk; +}; + +#ifdef __LP64__ +/* Must match struct trapframe */ +struct reg32 { + __int32_t fixreg[32]; + __int32_t lr; + __int32_t cr; + __int32_t xer; + __int32_t ctr; + __int32_t pc; +}; + +struct fpreg32 { + struct fpreg data; +}; + +struct vmxreg32 { + struct vmxreg data; +}; + +struct dbreg32 { + struct dbreg data; +}; + +#define __HAVE_REG32 +#endif + +#ifdef _KERNEL +/* + * XXX these interfaces are MI, so they should be declared in a MI place. + */ +int fill_regs(struct thread *, struct reg *); +int set_regs(struct thread *, struct reg *); +int fill_fpregs(struct thread *, struct fpreg *); +int set_fpregs(struct thread *, struct fpreg *); +int fill_dbregs(struct thread *, struct dbreg *); +int set_dbregs(struct thread *, struct dbreg *); + +#ifdef COMPAT_FREEBSD32 +struct image_params; + +int fill_regs32(struct thread *, struct reg32 *); +int set_regs32(struct thread *, struct reg32 *); +void ppc32_setregs(struct thread *, struct image_params *, uintptr_t); + +#define fill_fpregs32(td, reg) fill_fpregs(td,(struct fpreg *)reg) +#define set_fpregs32(td, reg) set_fpregs(td,(struct fpreg *)reg) +#define fill_dbregs32(td, reg) fill_dbregs(td,(struct dbreg *)reg) +#define set_dbregs32(td, reg) set_dbregs(td,(struct dbreg *)reg) +#endif + +#endif + +#endif /* _POWERPC_REG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/reloc.h b/lib/libc/include/powerpc64-freebsd-none/machine/reloc.h new file mode 100644 index 0000000000000000000000000000000000000000..592510637e39dc3c968c945e19fe35c21e13cedc --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/reloc.h @@ -0,0 +1,30 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1998 John Birrell . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/resource.h b/lib/libc/include/powerpc64-freebsd-none/machine/resource.h new file mode 100644 index 0000000000000000000000000000000000000000..db8a89b516cc2c3ba66ae91e7a3ff6c37d331bf0 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/resource.h @@ -0,0 +1,51 @@ +/*- + * Copyright 1998 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_RESOURCE_H_ +#define _MACHINE_RESOURCE_H_ 1 + +/* + * Definitions of resource types for Intel Architecture machines + * with support for legacy ISA devices and drivers. + */ + +#define SYS_RES_IRQ 1 /* interrupt lines */ +#define SYS_RES_DRQ 2 /* isa dma lines */ +#define SYS_RES_MEMORY 3 /* i/o memory */ +#define SYS_RES_IOPORT 4 /* i/o ports */ +#define PCI_RES_BUS 5 /* PCI bus numbers */ + +/* + * A powerpc-specific resource flag to request little-endian bus tags + * for a resource. + */ + +#define RF_LITTLEENDIAN RF_SPARE1 + +#endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/rtas.h b/lib/libc/include/powerpc64-freebsd-none/machine/rtas.h new file mode 100644 index 0000000000000000000000000000000000000000..2ee4dc9f406fce40ab33793a47e5d8fcfa1e4885 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/rtas.h @@ -0,0 +1,59 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2011 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_RTAS_H_ +#define _MACHINE_RTAS_H_ + +#include +#include + +/* + * RTAS functions are defined by 32-bit integer tokens. These vary from + * system to system, and can be looked up from their standardized names + * using rtas_token_lookup(). If RTAS is not available, rtas_token_lookup() + * and rtas_call_method() return -1; this can be checked in advance using + * rtas_exists(). Otherwise, rtas_call_method() returns one of the RTAS + * status codes from the bottom of this file. + */ + +int rtas_exists(void); +int rtas_call_method(cell_t token, int nargs, int nreturns, ...); +cell_t rtas_token_lookup(const char *method); + +/* RTAS Status Codes: see CHRP or PAPR specification */ +#define RTAS_OK 0 +#define RTAS_HW_ERROR -1 +#define RTAS_BUSY -2 +#define RTAS_PARAM_ERROR -3 +#define RTAS_STATE_CHANGE -7 +#define RTAS_VENDOR_BEGIN 9000 +#define RTAS_EXTENDED_DELAY 9900 +#define RTAS_ISOLATION_ERROR -9000 +#define RTAS_VENDOR_ERROR_BEGIN -9004 + +#endif /* _MACHINE_RTAS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/sdt_machdep.h b/lib/libc/include/powerpc64-freebsd-none/machine/sdt_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..f1f09c2ceba447ea87299e16091dac7e9caa7f3a --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/sdt_machdep.h @@ -0,0 +1,12 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Mark Johnston + */ + +#ifndef _SYS_SDT_MACHDEP_H_ +#define _SYS_SDT_MACHDEP_H_ + +#define _SDT_ASM_PATCH_INSTR "nop" + +#endif \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/setjmp.h b/lib/libc/include/powerpc64-freebsd-none/machine/setjmp.h new file mode 100644 index 0000000000000000000000000000000000000000..fcc287508602b69bbd7b622f8a3c985023a1e710 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/setjmp.h @@ -0,0 +1,27 @@ +/*- + * $NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $ + */ + +#ifndef _MACHINE_SETJMP_H_ +#define _MACHINE_SETJMP_H_ + +#include + +#ifdef _KERNEL +#define _JBLEN 25 /* Kernel doesn't save FP and Altivec regs */ +#else +#define _JBLEN 100 +#endif + +/* + * jmp_buf and sigjmp_buf are encapsulated in different structs to force + * compile-time diagnostics for mismatches. The structs are the same + * internally to avoid some run-time errors for mismatches. + */ +#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE +typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1]; +#endif + +typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1]; + +#endif /* !_MACHINE_SETJMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/signal.h b/lib/libc/include/powerpc64-freebsd-none/machine/signal.h new file mode 100644 index 0000000000000000000000000000000000000000..59df51d1fa51404dcf28cac3475f0d896732313d --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/signal.h @@ -0,0 +1,54 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $ + */ + +#ifndef _MACHINE_SIGNAL_H_ +#define _MACHINE_SIGNAL_H_ + +#include + +typedef int sig_atomic_t; + +#if __BSD_VISIBLE +#include + +struct sigcontext { + int sc_onstack; /* saved onstack flag */ + int __sc_mask13; /* saved signal mask (old style) */ + struct trapframe sc_frame; /* saved registers */ + struct __sigset sc_mask; /* saved signal mask (new style) */ +}; +#endif + +#endif /* !_MACHINE_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/slb.h b/lib/libc/include/powerpc64-freebsd-none/machine/slb.h new file mode 100644 index 0000000000000000000000000000000000000000..38bee5fbc00fe158c44b9b656a9f4a600f6e0763 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/slb.h @@ -0,0 +1,92 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2009 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_SLB_H_ +#define _MACHINE_SLB_H_ + +/* + * Bit definitions for segment lookaside buffer entries. + * + * PowerPC Microprocessor Family: The Programming Environments for 64-bit + * Microprocessors, section 7.4.2.1 + * + * Note that these bitmasks are relative to the values for one of the two + * values for slbmte, slbmfee, and slbmfev, not the internal SLB + * representation. + */ + +#define SLBV_KS 0x0000000000000800UL /* Supervisor-state prot key */ +#define SLBV_KP 0x0000000000000400UL /* User-state prot key */ +#define SLBV_N 0x0000000000000200UL /* No-execute protection */ +#define SLBV_L 0x0000000000000100UL /* Large page selector */ +#define SLBV_CLASS 0x0000000000000080UL /* Class selector */ +#define SLBV_VSID_MASK 0xfffffffffffff000UL /* Virtual segment ID mask */ +#define SLBV_VSID_SHIFT 12 + +/* + * Make a predictable 1:1 map from ESIDs to VSIDs for the kernel. Hash table + * coverage is increased by swizzling the ESID and multiplying by a prime + * number (0x13bb). + */ +#define KERNEL_VSID_BIT 0x0000001000000000UL /* Bit set in all kernel VSIDs */ +#define KERNEL_VSID(esid) ((((((uint64_t)esid << 8) | ((uint64_t)esid >> 28)) \ + * 0x13bbUL) & (KERNEL_VSID_BIT - 1)) | \ + KERNEL_VSID_BIT) + +#define SLBE_VALID 0x0000000008000000UL /* SLB entry valid */ +#define SLBE_INDEX_MASK 0x0000000000000fffUL /* SLB index mask*/ +#define SLBE_ESID_MASK 0xfffffffff0000000UL /* Effective segment ID mask */ +#define SLBE_ESID_SHIFT 28 + +/* + * SLB page sizes encoding, as present in property ibm,segment-page-sizes + * of CPU device tree node. + * + * See LoPAPR: CPU Node Properties, section C.6.1.4. + */ +#define SLB_PGSZ_4K_4K 0 + +/* Virtual real-mode VSID in LPARs */ +#define VSID_VRMA 0x1ffffff + +/* + * User segment for copyin/out + */ +#define USER_SLB_SLOT 0 +#define USER_SLB_SLBE (((USER_ADDR >> ADDR_SR_SHFT) << SLBE_ESID_SHIFT) | \ + SLBE_VALID | USER_SLB_SLOT) + +struct slb { + uint64_t slbv; + uint64_t slbe; +}; + +struct pmap; +void handle_kernel_slb_spill(int, register_t, register_t); +int handle_user_slb_spill(struct pmap *pm, vm_offset_t addr); + +#endif /* !_MACHINE_SLB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/smp.h b/lib/libc/include/powerpc64-freebsd-none/machine/smp.h new file mode 100644 index 0000000000000000000000000000000000000000..5af3459aff21f93ea0e000730d46ba9d24ea9456 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/smp.h @@ -0,0 +1,64 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2008 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_SMP_H_ +#define _MACHINE_SMP_H_ + +#ifdef _KERNEL + +#define IPI_AST 0 +#define IPI_PREEMPT 1 +#define IPI_RENDEZVOUS 2 +#define IPI_STOP 3 +#define IPI_STOP_HARD 3 +#define IPI_HARDCLOCK 4 + +#ifndef LOCORE + +#include +#include + +void ipi_all_but_self(int ipi); +void ipi_cpu(int cpu, u_int ipi); +void ipi_selected(cpuset_t cpus, int ipi); + +struct cpuref { + uintptr_t cr_hwref; + u_int cr_cpuid; + u_int cr_domain; +}; + +void pmap_cpu_bootstrap(int); +void cpudep_ap_early_bootstrap(void); +uintptr_t cpudep_ap_bootstrap(void); +void cpudep_ap_setup(void); +void machdep_ap_bootstrap(void); + +#endif /* !LOCORE */ +#endif /* _KERNEL */ +#endif /* !_MACHINE_SMP_H */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/spr.h b/lib/libc/include/powerpc64-freebsd-none/machine/spr.h new file mode 100644 index 0000000000000000000000000000000000000000..587fa4ed24baae49685ed2b2291b8192f90ccf83 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/spr.h @@ -0,0 +1,868 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: spr.h,v 1.25 2002/08/14 15:38:40 matt Exp $ + */ +#ifndef _POWERPC_SPR_H_ +#define _POWERPC_SPR_H_ + +#ifndef _LOCORE +#define mtspr(reg, val) \ + __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val)) +#define mfspr(reg) \ + ( { register_t val; \ + __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \ + val; } ) + +#ifndef __powerpc64__ + +/* The following routines allow manipulation of the full 64-bit width + * of SPRs on 64 bit CPUs in bridge mode */ + +#define mtspr64(reg,valhi,vallo,scratch) \ + __asm __volatile(" \ + mfmsr %0; \ + insrdi %0,%5,1,0; \ + mtmsrd %0; \ + isync; \ + \ + sld %1,%1,%4; \ + or %1,%1,%2; \ + mtspr %3,%1; \ + srd %1,%1,%4; \ + \ + clrldi %0,%0,1; \ + mtmsrd %0; \ + isync;" \ + : "=r"(scratch), "=r"(valhi) : "r"(vallo), "K"(reg), "r"(32), "r"(1)) + +#define mfspr64upper(reg,scratch) \ + ( { register_t val; \ + __asm __volatile(" \ + mfmsr %0; \ + insrdi %0,%4,1,0; \ + mtmsrd %0; \ + isync; \ + \ + mfspr %1,%2; \ + srd %1,%1,%3; \ + \ + clrldi %0,%0,1; \ + mtmsrd %0; \ + isync;" \ + : "=r"(scratch), "=r"(val) : "K"(reg), "r"(32), "r"(1)); \ + val; } ) + +#endif + +#endif /* _LOCORE */ + +/* + * Special Purpose Register declarations. + * + * The first column in the comments indicates which PowerPC + * architectures the SPR is valid on - 4 for 4xx series, + * 6 for 6xx/7xx series and 8 for 8xx and 8xxx series. + */ + +#define SPR_MQ 0x000 /* .6. 601 MQ register */ +#define SPR_XER 0x001 /* 468 Fixed Point Exception Register */ +#define SPR_DSCR 0x003 /* .6. Data Stream Control Register (Unprivileged) */ +#define SPR_RTCU_R 0x004 /* .6. 601 RTC Upper - Read */ +#define SPR_RTCL_R 0x005 /* .6. 601 RTC Lower - Read */ +#define SPR_LR 0x008 /* 468 Link Register */ +#define SPR_CTR 0x009 /* 468 Count Register */ +#define SPR_DSCRP 0x011 /* Data Stream Control Register (Privileged) */ +#define SPR_DSISR 0x012 /* .68 DSI exception source */ +#define DSISR_DIRECT 0x80000000 /* Direct-store error exception */ +#define DSISR_NOTFOUND 0x40000000 /* Translation not found */ +#define DSISR_PROTECT 0x08000000 /* Memory access not permitted */ +#define DSISR_INVRX 0x04000000 /* Reserve-indexed insn direct-store access */ +#define DSISR_STORE 0x02000000 /* Store operation */ +#define DSISR_DABR 0x00400000 /* DABR match */ +#define DSISR_SEGMENT 0x00200000 /* XXX; not in 6xx PEM */ +#define DSISR_EAR 0x00100000 /* eciwx/ecowx && EAR[E] == 0 */ +#define DSISR_MC_UE_DEFERRED 0x00008000 /* UE deferred error */ +#define DSISR_MC_UE_TABLEWALK 0x00004000 /* UE deferred error during tablewalk */ +#define DSISR_MC_DERAT_MULTIHIT 0x00000800 /* D-ERAT multi-hit */ +#define DSISR_MC_TLB_MULTIHIT 0x00000400 /* TLB multi-hit */ +#define DSISR_MC_TLBIE_ERR 0x00000200 /* TLBIE or TLBIEL programming error */ +#define DSISR_MC_SLB_PARITY 0x00000100 /* SLB parity error */ +#define DSISR_MC_SLB_MULTIHIT 0x00000080 /* SLB Multi-hit detected (D-side) */ +#define DSISR_MC_BAD_REAL_LD 0x00000040 /* Bad real address for load. */ +#define DSISR_MC_BAD_ADDR 0x00000020 /* Bad address for load or store tablewalk */ +#define SPR_DAR 0x013 /* .68 Data Address Register */ +#define SPR_RTCU_W 0x014 /* .6. 601 RTC Upper - Write */ +#define SPR_RTCL_W 0x015 /* .6. 601 RTC Lower - Write */ +#define SPR_DEC 0x016 /* .68 DECrementer register */ +#define SPR_SDR1 0x019 /* .68 Page table base address register */ +#define SPR_SRR0 0x01a /* 468 Save/Restore Register 0 */ +#define SPR_SRR1 0x01b /* 468 Save/Restore Register 1 */ +#define SRR1_ISI_PFAULT 0x40000000 /* ISI page not found */ +#define SRR1_ISI_NOEXECUTE 0x10000000 /* Memory marked no-execute */ +#define SRR1_ISI_PP 0x08000000 /* PP bits forbid access */ +#define SRR1_MCHK_DATA 0x00200000 /* Machine check data in DSISR */ +#define SRR1_MCHK_IFETCH_M 0x081c0000 /* Machine check instr fetch mask */ +#define SRR1_MCHK_IFETCH_SLBMH 0x000c0000 /* SLB multihit */ +#define SPR_CFAR 0x01c /* Come From Address Register */ +#define SPR_AMR 0x01d /* Authority Mask Register */ + +#define SPR_PID 0x030 /* 4.. Process ID */ + +#define SPR_DECAR 0x036 /* ..8 Decrementer auto reload */ +#define SPR_IAMR 0x03d /* Instr. Authority Mask Reg */ + +#define SPR_EIE 0x050 /* ..8 Exception Interrupt ??? */ +#define SPR_EID 0x051 /* ..8 Exception Interrupt ??? */ +#define SPR_NRI 0x052 /* ..8 Exception Interrupt ??? */ +#define SPR_FSCR 0x099 /* Facility Status and Control Register */ +#define FSCR_IC_MASK 0xFF00000000000000ULL /* FSCR[0:7] is Interrupt Cause */ +#define FSCR_IC_FP 0x0000000000000000ULL /* FP unavailable */ +#define FSCR_IC_VSX 0x0100000000000000ULL /* VSX unavailable */ +#define FSCR_IC_DSCR 0x0200000000000000ULL /* Access to the DSCR at SPRs 3 or 17 */ +#define FSCR_IC_PM 0x0300000000000000ULL /* Read or write access of a Performance Monitor SPR in group A */ +#define FSCR_IC_BHRB 0x0400000000000000ULL /* Execution of a BHRB Instruction */ +#define FSCR_IC_HTM 0x0500000000000000ULL /* Access to a Transactional Memory */ +/* Reserved 0x0600000000000000ULL */ +#define FSCR_IC_EBB 0x0700000000000000ULL /* Access to Event-Based Branch */ +#define FSCR_IC_TAR 0x0800000000000000ULL /* Access to Target Address Register */ +#define FSCR_IC_STOP 0x0900000000000000ULL /* Access to the 'stop' instruction in privileged non-hypervisor state */ +#define FSCR_IC_MSG 0x0A00000000000000ULL /* Access to 'msgsndp' or 'msgclrp' instructions */ +#define FSCR_IC_LM 0x0A00000000000000ULL /* Access to load monitored facility */ +#define FSCR_IC_SCV 0x0C00000000000000ULL /* Execution of a 'scv' instruction */ +#define FSCR_SCV 0x0000000000001000 /* scv instruction available */ +#define FSCR_LM 0x0000000000000800 /* Load monitored facilities available */ +#define FSCR_MSGP 0x0000000000000400 /* msgsndp and SPRs available */ +#define FSCR_TAR 0x0000000000000100 /* TAR register available */ +#define FSCR_EBB 0x0000000000000080 /* Event-based branch available */ +#define FSCR_DSCR 0x0000000000000004 /* DSCR available in PR state */ +#define SPR_UAMOR 0x09d /* User Authority Mask Override Register */ +#define SPR_DPDES 0x0b0 /* .6. Directed Privileged Doorbell Exception State Register */ +#define SPR_HFSCR 0xbe /* Hypervisor Facility Status and Control Register */ +#define HFSCR_BHRB 0x0000000000000010 /* BHRB instructions */ +#define HFSCR_PM 0x0000000000000008 /* Performance monitor SPRs */ +#define HFSCR_VECVSX 0x0000000000000002 /* Vector and VSX facilities */ +#define HFSCR_FP 0x0000000000000001 /* Floating Point facility */ +#define SPR_USPRG0 0x100 /* 4.8 User SPR General 0 */ +#define SPR_VRSAVE 0x100 /* .6. AltiVec VRSAVE */ +#define SPR_SPRG0 0x110 /* 468 SPR General 0 */ +#define SPR_SPRG1 0x111 /* 468 SPR General 1 */ +#define SPR_SPRG2 0x112 /* 468 SPR General 2 */ +#define SPR_SPRG3 0x113 /* 468 SPR General 3 */ +#define SPR_SPRG4 0x114 /* 4.8 SPR General 4 */ +#define SPR_SPRG5 0x115 /* 4.8 SPR General 5 */ +#define SPR_SPRG6 0x116 /* 4.8 SPR General 6 */ +#define SPR_SPRG7 0x117 /* 4.8 SPR General 7 */ +#define SPR_SCOMC 0x114 /* ... SCOM Address Register (970) */ +#define SPR_SCOMD 0x115 /* ... SCOM Data Register (970) */ +#define SPR_ASR 0x118 /* ... Address Space Register (PPC64) */ +#define SPR_EAR 0x11a /* .68 External Access Register */ +#define SPR_PVR 0x11f /* 468 Processor Version Register */ +#define MPC601 0x0001 +#define MPC603 0x0003 +#define MPC604 0x0004 +#define MPC602 0x0005 +#define MPC603e 0x0006 +#define MPC603ev 0x0007 +#define MPC750 0x0008 +#define MPC750CL 0x7000 /* Nintendo Wii's Broadway */ +#define MPC604ev 0x0009 +#define MPC7400 0x000c +#define MPC620 0x0014 +#define IBM403 0x0020 +#define IBM401A1 0x0021 +#define IBM401B2 0x0022 +#define IBM401C2 0x0023 +#define IBM401D2 0x0024 +#define IBM401E2 0x0025 +#define IBM401F2 0x0026 +#define IBM401G2 0x0027 +#define IBMRS64II 0x0033 +#define IBMRS64III 0x0034 +#define IBMPOWER4 0x0035 +#define IBMRS64III_2 0x0036 +#define IBMRS64IV 0x0037 +#define IBMPOWER4PLUS 0x0038 +#define IBM970 0x0039 +#define IBMPOWER5 0x003a +#define IBMPOWER5PLUS 0x003b +#define IBM970FX 0x003c +#define IBMPOWER6 0x003e +#define IBMPOWER7 0x003f +#define IBMPOWER3 0x0040 +#define IBMPOWER3PLUS 0x0041 +#define IBM970MP 0x0044 +#define IBM970GX 0x0045 +#define IBMPOWERPCA2 0x0049 +#define IBMPOWER7PLUS 0x004a +#define IBMPOWER8E 0x004b +#define IBMPOWER8NVL 0x004c +#define IBMPOWER8 0x004d +#define IBMPOWER9 0x004e +#define MPC860 0x0050 +#define IBMCELLBE 0x0070 +#define IBMPOWER10 0x0080 +#define MPC8240 0x0081 +#define IBMPOWER11 0x0082 +#define PA6T 0x0090 +#define IBM405GP 0x4011 +#define IBM405L 0x4161 +#define IBM750FX 0x7000 +#define MPC745X_P(v) ((v & 0xFFF8) == 0x8000) +#define MPC7450 0x8000 +#define MPC7455 0x8001 +#define MPC7457 0x8002 +#define MPC7447A 0x8003 +#define MPC7448 0x8004 +#define MPC7410 0x800c +#define MPC8245 0x8081 +#define FSL_E500v1 0x8020 +#define FSL_E500v2 0x8021 +#define FSL_E500mc 0x8023 +#define FSL_E5500 0x8024 +#define FSL_E6500 0x8040 +#define FSL_E300C1 0x8083 +#define FSL_E300C2 0x8084 +#define FSL_E300C3 0x8085 +#define FSL_E300C4 0x8086 + +#define LPCR_PECE_WAKESET (LPCR_PECE_EXT | LPCR_PECE_DECR | LPCR_PECE_ME) + +#define SPR_DBSR 0x130 /* ..8 Debug Status Register */ +#define DBSR_IDE 0x80000000 /* Imprecise debug event. */ +#define DBSR_UDE 0x40000000 /* Unconditional debug event. */ +#define DBSR_MRR 0x30000000 /* Most recent Reset (mask). */ +#define DBSR_ICMP 0x08000000 /* Instr. complete debug event. */ +#define DBSR_BRT 0x04000000 /* Branch taken debug event. */ +#define DBSR_IRPT 0x02000000 /* Interrupt taken debug event. */ +#define DBSR_TRAP 0x01000000 /* Trap instr. debug event. */ +#define DBSR_IAC1 0x00800000 /* Instr. address compare #1. */ +#define DBSR_IAC2 0x00400000 /* Instr. address compare #2. */ +#define DBSR_IAC3 0x00200000 /* Instr. address compare #3. */ +#define DBSR_IAC4 0x00100000 /* Instr. address compare #4. */ +#define DBSR_DAC1R 0x00080000 /* Data addr. read compare #1. */ +#define DBSR_DAC1W 0x00040000 /* Data addr. write compare #1. */ +#define DBSR_DAC2R 0x00020000 /* Data addr. read compare #2. */ +#define DBSR_DAC2W 0x00010000 /* Data addr. write compare #2. */ +#define DBSR_RET 0x00008000 /* Return debug event. */ +#define SPR_EPCR 0x133 +#define EPCR_EXTGS 0x80000000 +#define EPCR_DTLBGS 0x40000000 +#define EPCR_ITLBGS 0x20000000 +#define EPCR_DSIGS 0x10000000 +#define EPCR_ISIGS 0x08000000 +#define EPCR_DUVGS 0x04000000 +#define EPCR_ICM 0x02000000 +#define EPCR_GICMGS 0x01000000 +#define EPCR_DGTMI 0x00800000 +#define EPCR_DMIUH 0x00400000 +#define EPCR_PMGS 0x00200000 +#define SPR_DBCR0 0x134 /* ..8 Debug Control Register 0 */ +#define SPR_DBCR1 0x135 /* ..8 Debug Control Register 1 */ +#define SPR_DBCR2 0x136 /* ..8 Debug Control Register 2 */ +#define SPR_IAC1 0x138 /* ..8 Instruction Address Compare 1 */ +#define SPR_IAC2 0x139 /* ..8 Instruction Address Compare 2 */ +#define SPR_IAC3 0x13a /* ..8 Instruction Address Compare 3 */ +#define SPR_IAC4 0x13b /* ..8 Instruction Address Compare 4 */ + +#define SPR_HSRR0 0x13a +#define SPR_HSRR1 0x13b +#define SPR_DAC1 0x13c /* ..8 Data Address Compare 1 */ +#define SPR_DAC2 0x13d /* ..8 Data Address Compare 2 */ +#define SPR_DVC1 0x13e /* ..8 Data Value Compare 1 */ +#define SPR_DVC2 0x13f /* ..8 Data Value Compare 2 */ + +#define SPR_LPCR 0x13e /* .6. Logical Partitioning Control */ +#define LPCR_LPES 0x008 /* Bit 60 */ +#define LPCR_HVICE 0x002 /* Hypervisor Virtualization Interrupt (Arch 3.0) */ +#define LPCR_ILE (1ULL << 25) /* Interrupt Little-Endian (ISA 2.07) */ +#define LPCR_UPRT (1ULL << 22) /* Use Process Table (ISA 3) */ +#define LPCR_HR (1ULL << 20) /* Host Radix mode */ +#define LPCR_PECE_DRBL (1ULL << 16) /* Directed Privileged Doorbell */ +#define LPCR_PECE_HDRBL (1ULL << 15) /* Directed Hypervisor Doorbell */ +#define LPCR_PECE_EXT (1ULL << 14) /* External exceptions */ +#define LPCR_PECE_DECR (1ULL << 13) /* Decrementer exceptions */ +#define LPCR_PECE_ME (1ULL << 12) /* Machine Check and Hypervisor */ + /* Maintenance exceptions */ +#define SPR_LPID 0x13f /* .6. Logical Partitioning Control */ +#define SPR_HMER 0x150 /* Hypervisor Maintenance Exception Register */ +#define SPR_HMEER 0x151 /* Hypervisor Maintenance Exception Enable Register */ +#define SPR_AMOR 0x15d /* Authority Mask Override Register */ + +#define SPR_TIR 0x1be /* .6. Thread Identification Register */ +#define SPR_PTCR 0x1d0 /* Partition Table Control Register */ +#define SPR_SPEFSCR 0x200 /* ..8 Signal Processing Engine FSCR. */ +#define SPEFSCR_SOVH 0x80000000 +#define SPEFSCR_OVH 0x40000000 +#define SPEFSCR_FGH 0x20000000 +#define SPEFSCR_FXH 0x10000000 +#define SPEFSCR_FINVH 0x08000000 +#define SPEFSCR_FDBZH 0x04000000 +#define SPEFSCR_FUNFH 0x02000000 +#define SPEFSCR_FOVFH 0x01000000 +#define SPEFSCR_FINXS 0x00200000 +#define SPEFSCR_FINVS 0x00100000 +#define SPEFSCR_FDBZS 0x00080000 +#define SPEFSCR_FUNFS 0x00040000 +#define SPEFSCR_FOVFS 0x00020000 +#define SPEFSCR_SOV 0x00008000 +#define SPEFSCR_OV 0x00004000 +#define SPEFSCR_FG 0x00002000 +#define SPEFSCR_FX 0x00001000 +#define SPEFSCR_FINV 0x00000800 +#define SPEFSCR_FDBZ 0x00000400 +#define SPEFSCR_FUNF 0x00000200 +#define SPEFSCR_FOVF 0x00000100 +#define SPEFSCR_FINXE 0x00000040 +#define SPEFSCR_FINVE 0x00000020 +#define SPEFSCR_FDBZE 0x00000010 +#define SPEFSCR_FUNFE 0x00000008 +#define SPEFSCR_FOVFE 0x00000004 +#define SPEFSCR_FRMC_M 0x00000003 +#define SPEFSCR_DFLT (SPEFSCR_FINVE | SPEFSCR_FDBZE | \ + SPEFSCR_FUNFE | SPEFSCR_FOVFE) +#define SPR_IBAT0U 0x210 /* .6. Instruction BAT Reg 0 Upper */ +#define SPR_IBAT0L 0x211 /* .6. Instruction BAT Reg 0 Lower */ +#define SPR_IBAT1U 0x212 /* .6. Instruction BAT Reg 1 Upper */ +#define SPR_IBAT1L 0x213 /* .6. Instruction BAT Reg 1 Lower */ +#define SPR_IBAT2U 0x214 /* .6. Instruction BAT Reg 2 Upper */ +#define SPR_IBAT2L 0x215 /* .6. Instruction BAT Reg 2 Lower */ +#define SPR_IBAT3U 0x216 /* .6. Instruction BAT Reg 3 Upper */ +#define SPR_IBAT3L 0x217 /* .6. Instruction BAT Reg 3 Lower */ +#define SPR_DBAT0U 0x218 /* .6. Data BAT Reg 0 Upper */ +#define SPR_DBAT0L 0x219 /* .6. Data BAT Reg 0 Lower */ +#define SPR_DBAT1U 0x21a /* .6. Data BAT Reg 1 Upper */ +#define SPR_DBAT1L 0x21b /* .6. Data BAT Reg 1 Lower */ +#define SPR_DBAT2U 0x21c /* .6. Data BAT Reg 2 Upper */ +#define SPR_DBAT2L 0x21d /* .6. Data BAT Reg 2 Lower */ +#define SPR_DBAT3U 0x21e /* .6. Data BAT Reg 3 Upper */ +#define SPR_DBAT3L 0x21f /* .6. Data BAT Reg 3 Lower */ +#define SPR_IBAT4U 0x230 /* .6. Instruction BAT Reg 4 Upper */ +#define SPR_DBCR3 0x231 /* ..8 Debug Control Register 3 */ +#define SPR_IBAT4L 0x231 /* .6. Instruction BAT Reg 4 Lower */ +#define SPR_IBAT5U 0x232 /* .6. Instruction BAT Reg 5 Upper */ +#define SPR_IBAT5L 0x233 /* .6. Instruction BAT Reg 5 Lower */ +#define SPR_DBCR4 0x233 /* ..8 Debug Control Register 4 */ +#define SPR_IBAT6U 0x234 /* .6. Instruction BAT Reg 6 Upper */ +#define SPR_DBCR5 0x234 /* ..8 Debug Control Register 5 */ +#define SPR_IBAT6L 0x235 /* .6. Instruction BAT Reg 6 Lower */ +#define SPR_IAC5 0x235 /* ..8 Instruction Address Compare 5 */ +#define SPR_IBAT7U 0x236 /* .6. Instruction BAT Reg 7 Upper */ +#define SPR_IAC6 0x236 /* ..8 Instruction Address Compare 6 */ +#define SPR_IBAT7L 0x237 /* .6. Instruction BAT Reg 7 Lower */ +#define SPR_IAC7 0x237 /* ..8 Instruction Address Compare 7 */ +#define SPR_DBAT4U 0x238 /* .6. Data BAT Reg 4 Upper */ +#define SPR_IAC8 0x238 /* ..8 Instruction Address Compare 8 */ +#define SPR_DBAT4L 0x239 /* .6. Data BAT Reg 4 Lower */ +#define SPR_DBAT5U 0x23a /* .6. Data BAT Reg 5 Upper */ +#define SPR_DBAT5L 0x23b /* .6. Data BAT Reg 5 Lower */ +#define SPR_DBAT6U 0x23c /* .6. Data BAT Reg 6 Upper */ +#define SPR_DBAT6L 0x23d /* .6. Data BAT Reg 6 Lower */ +#define SPR_DBAT7U 0x23e /* .6. Data BAT Reg 7 Upper */ +#define SPR_DBAT7L 0x23f /* .6. Data BAT Reg 7 Lower */ +#define SPR_DBCR6 0x25b /* ..8 Debug Control Register 6 */ +#define SPR_SPRG8 0x25c /* ..8 SPR General 8 */ + +#define SPR_MMCRA 0x312 /* ... Monitor Mode Control Register A */ +#define SPR_PMC1 0x313 /* ... PMC 1 */ +#define SPR_PMC2 0x314 /* ... PMC 2 */ +#define SPR_PMC3 0x315 /* ... PMC 3 */ +#define SPR_PMC4 0x316 /* ... PMC 4 */ +#define SPR_PMC5 0x317 /* ... PMC 5 */ +#define SPR_PMC6 0x318 /* ... PMC 6 */ +#define SPR_PMC7 0x319 /* ... PMC 7 */ +#define SPR_PMC8 0x31a /* ... PMC 8 */ + +#define SPR_MMCR0 0x31b /* ... Monitor Mode Control Register 0 */ +#define SPR_MMCR0_FC 0x80000000 /* Freeze counters */ +#define SPR_MMCR0_FCS 0x40000000 /* Freeze counters in supervisor mode */ +#define SPR_MMCR0_FCP 0x20000000 /* Freeze counters in user mode */ +#define SPR_MMCR0_FCM1 0x10000000 /* Freeze counters when mark=1 */ +#define SPR_MMCR0_FCM0 0x08000000 /* Freeze counters when mark=0 */ +#define SPR_MMCR0_PMXE 0x04000000 /* Enable PM interrupt */ +#define SPR_MMCR0_PMAE 0x04000000 /* PM Alert Enable */ +#define SPR_MMCR0_FCECE 0x02000000 /* Freeze counters after event */ +#define SPR_MMCR0_TBSEL_15 0x01800000 /* Count bit 15 of TBL */ +#define SPR_MMCR0_TBSEL_19 0x01000000 /* Count bit 19 of TBL */ +#define SPR_MMCR0_TBSEL_23 0x00800000 /* Count bit 23 of TBL */ +#define SPR_MMCR0_TBSEL_31 0x00000000 /* Count bit 31 of TBL */ +#define SPR_MMCR0_TBEE 0x00400000 /* Time-base event enable */ +#define SPR_MMCR0_THRESHOLD(x) ((x) << 16) /* Threshold value */ +#define SPR_MMCR0_PMC1CE 0x00008000 /* PMC1 condition enable */ +#define SPR_MMCR0_PMCNCE 0x00004000 /* PMCn condition enable */ +#define SPR_MMCR0_TRIGGER 0x00002000 /* Trigger */ +#define SPR_MMCR0_PMAO 0x00000080 /* PM Alert Occurred */ +#define SPR_MMCR0_FCPC 0x00001000 /* Freeze Counters in Problem State Cond. */ +#define SPR_MMCR0_FC56 0x00000010 /* Freeze Counters 5-6 */ +#define SPR_MMCR0_PMC1SEL(x) ((x) << 8) /* PMC1 selector (970) */ +#define SPR_MMCR0_PMC2SEL(x) ((x) << 1) /* PMC2 selector (970) */ +#define SPR_MMCR0_74XX_PMC1SEL(x) (((x) & 0x3f) << 6) /* PMC1 selector */ +#define SPR_MMCR0_74XX_PMC2SEL(x) (((x) & 0x3f) << 0) /* PMC2 selector */ + +#define SPR_MMCR1 0x31e /* ... Monitor Mode Control Register 1 */ +#define SPR_MMCR1_PMC3SEL(x) (((x) & 0x1f) << 27) /* PMC 3 selector */ +#define SPR_MMCR1_PMC4SEL(x) (((x) & 0x1f) << 22) /* PMC 4 selector */ +#define SPR_MMCR1_PMC5SEL(x) (((x) & 0x1f) << 17) /* PMC 5 selector */ +#define SPR_MMCR1_PMC6SEL(x) (((x) & 0x1f) << 12) /* PMC 6 selector */ +#define SPR_MMCR1_74XX_PMC6SEL(x) (((x) & 0x3f) << 11) /* PMC 6 selector */ +#define SPR_MMCR1_PMC7SEL(x) (((x) & 0x1f) << 7) /* PMC 7 selector */ +#define SPR_MMCR1_PMC8SEL(x) (((x) & 0x1f) << 2) /* PMC 8 selector */ +#define SPR_MMCR1_P8_PMCSEL_ALL 0xffffffff +#define SPR_MMCR1_P8_PMCNSEL_MASK(n) (0xffUL << ((3-(n))*8)) +#define SPR_MMCR1_P8_PMCNSEL(n, v) ((unsigned long)(v) << ((3-(n))*8)) + +#define SPR_MMCR2 0x311 +#define SPR_MMCR2_CNBIT(n, bit) ((bit) << (((5 - (n)) * 9) + 10)) +#define SPR_MMCR2_FCNS(n) SPR_MMCR2_CNBIT(n, 0x100ULL) +#define SPR_MMCR2_FCNP0(n) SPR_MMCR2_CNBIT(n, 0x080ULL) +#define SPR_MMCR2_FCNP1(n) SPR_MMCR2_CNBIT(n, 0x040ULL) +#define SPR_MMCR2_FCNM1(n) SPR_MMCR2_CNBIT(n, 0x020ULL) +#define SPR_MMCR2_FCNM0(n) SPR_MMCR2_CNBIT(n, 0x010ULL) +#define SPR_MMCR2_FCNWAIT(n) SPR_MMCR2_CNBIT(n, 0x008ULL) +#define SPR_MMCR2_FCNH(n) SPR_MMCR2_CNBIT(n, 0x004ULL) +/* Freeze Counter N in Hypervisor/Supervisor/Problem states */ +#define SPR_MMCR2_FCNHSP(n) \ + (SPR_MMCR2_FCNS(n) | SPR_MMCR2_FCNP0(n) | \ + SPR_MMCR2_FCNP1(n) | SPR_MMCR2_FCNH(n)) + +#define SPR_M_TWB 0x31c /* ..8 MMU tablewalk base */ +#define M_TWB_L1TB 0xfffff000 /* level-1 translation base */ +#define M_TWB_L1INDX 0x00000ffc /* level-1 index */ +#define SPR_MD_TWC 0x31d /* ..8 DMMU tablewalk control */ +#define SPR_MD_RPN 0x31e /* ..8 DMMU real (phys) page number */ +#define SPR_MD_TW 0x31f /* ..8 MMU tablewalk scratch */ +#define SPR_BESCRS 0x320 /* .6. Branch Event Status and Control Set Register */ +#define SPR_BESCRSU 0x321 /* .6. Branch Event Status and Control Set Register (upper 32-bit) */ +#define SPR_BESCRR 0x322 /* .6. Branch Event Status and Control Reset Register */ +#define SPR_BESCRRU 0x323 /* .6. Branch Event Status and Control Register (upper 32-bit) */ +#define SPR_EBBHR 0x324 /* .6. Event-based Branch Handler Register */ +#define SPR_EBBRR 0x325 /* .6. Event-based Branch Return Register */ +#define SPR_BESCR 0x326 /* .6. Branch Event Status and Control Register */ +#define SPR_LMRR 0x32d /* .6. Load Monitored Region Register */ +#define SPR_LMSER 0x32e /* .6. Load Monitored Section Enable Register */ +#define SPR_TAR 0x32f /* .6. Branch Target Address Register */ +#define SPR_MI_CAM 0x330 /* ..8 IMMU CAM entry read */ +#define SPR_MI_RAM0 0x331 /* ..8 IMMU RAM entry read reg 0 */ +#define SPR_MI_RAM1 0x332 /* ..8 IMMU RAM entry read reg 1 */ +#define SPR_MD_CAM 0x338 /* ..8 IMMU CAM entry read */ +#define SPR_MD_RAM0 0x339 /* ..8 IMMU RAM entry read reg 0 */ +#define SPR_MD_RAM1 0x33a /* ..8 IMMU RAM entry read reg 1 */ +#define SPR_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */ +#define PSSCR_PLS_S 60 +#define PSSCR_PLS_M (0xf << PSSCR_PLS_S) +#define PSSCR_SD (1 << 22) +#define PSSCR_ESL (1 << 21) +#define PSSCR_EC (1 << 20) +#define PSSCR_PSLL_S 16 +#define PSSCR_PSLL_M (0xf << PSSCR_PSLL_S) +#define PSSCR_TR_S 8 +#define PSSCR_TR_M (0x3 << PSSCR_TR_S) +#define PSSCR_MTL_S 4 +#define PSSCR_MTL_M (0xf << PSSCR_MTL_S) +#define PSSCR_RL_S 0 +#define PSSCR_RL_M (0xf << PSSCR_RL_S) +#define SPR_PMCR 0x374 /* Processor Management Control Register */ +#define SPR_UMMCR2 0x3a0 /* .6. User Monitor Mode Control Register 2 */ +#define SPR_UMMCR0 0x3a8 /* .6. User Monitor Mode Control Register 0 */ +#define SPR_USIA 0x3ab /* .6. User Sampled Instruction Address */ +#define SPR_UMMCR1 0x3ac /* .6. User Monitor Mode Control Register 1 */ +#define SPR_MMCR2_74XX 0x3b0 /* .6. Monitor Mode Control Register 2 */ +#define SPR_MMCR2_74XX_THRESHMULT_32 0x80000000 /* Multiply MMCR0 threshold by 32 */ +#define SPR_MMCR2_74XX_THRESHMULT_2 0x00000000 /* Multiply MMCR0 threshold by 2 */ +#define SPR_PMC5_74XX 0x3b1 /* .6. Performance Counter Register 5 */ +#define SPR_PMC6_74XX 0x3b2 /* .6. Performance Counter Register 6 */ +#define SPR_MMCR0_74XX 0x3b8 /* .6. Monitor Mode Control Register 0 */ +#define SPR_PMC1_74XX 0x3b9 /* .6. Performance Counter Register 1 */ +#define SPR_PMC2_74XX 0x3ba /* .6. Performance Counter Register 2 */ +#define SPR_SIA 0x3bb /* .6. Sampled Instruction Address */ +#define SPR_MMCR1_74XX 0x3bc /* .6. Monitor Mode Control Register 2 */ + +#define SPR_PMC3_74XX 0x3bd /* .6. Performance Counter Register 3 */ +#define SPR_PMC4_74XX 0x3be /* .6. Performance Counter Register 4 */ +#define SPR_DMISS 0x3d0 /* .68 Data TLB Miss Address Register */ +#define SPR_DCMP 0x3d1 /* .68 Data TLB Compare Register */ +#define SPR_HASH1 0x3d2 /* .68 Primary Hash Address Register */ +#define SPR_HASH2 0x3d3 /* .68 Secondary Hash Address Register */ +#define SPR_IMISS 0x3d4 /* .68 Instruction TLB Miss Address Register */ +#define SPR_TLBMISS 0x3d4 /* .6. TLB Miss Address Register */ +#define SPR_DEAR 0x03d /* ..8 Data Exception Address Register */ +#define SPR_ICMP 0x3d5 /* .68 Instruction TLB Compare Register */ +#define SPR_PTEHI 0x3d5 /* .6. Instruction TLB Compare Register */ +#define SPR_RPA 0x3d6 /* .68 Required Physical Address Register */ +#define SPR_PTELO 0x3d6 /* .6. Required Physical Address Register */ + +#define SPR_TSR 0x150 /* ..8 Timer Status Register */ +#define SPR_TCR 0x154 /* ..8 Timer Control Register */ + +#define TSR_ENW 0x80000000 /* Enable Next Watchdog */ +#define TSR_WIS 0x40000000 /* Watchdog Interrupt Status */ +#define TSR_WRS_MASK 0x30000000 /* Watchdog Reset Status */ +#define TSR_WRS_NONE 0x00000000 /* No watchdog reset has occurred */ +#define TSR_WRS_CORE 0x10000000 /* Core reset was forced by the watchdog */ +#define TSR_WRS_CHIP 0x20000000 /* Chip reset was forced by the watchdog */ +#define TSR_WRS_SYSTEM 0x30000000 /* System reset was forced by the watchdog */ +#define TSR_PIS 0x08000000 /* PIT Interrupt Status */ +#define TSR_DIS 0x08000000 /* Decrementer Interrupt Status */ +#define TSR_FIS 0x04000000 /* FIT Interrupt Status */ + +#define TCR_WP_MASK 0xc0000000 /* Watchdog Period mask */ +#define TCR_WP_2_17 0x00000000 /* 2**17 clocks */ +#define TCR_WP_2_21 0x40000000 /* 2**21 clocks */ +#define TCR_WP_2_25 0x80000000 /* 2**25 clocks */ +#define TCR_WP_2_29 0xc0000000 /* 2**29 clocks */ +#define TCR_WRC_MASK 0x30000000 /* Watchdog Reset Control mask */ +#define TCR_WRC_NONE 0x00000000 /* No watchdog reset */ +#define TCR_WRC_CORE 0x10000000 /* Core reset */ +#define TCR_WRC_CHIP 0x20000000 /* Chip reset */ +#define TCR_WRC_SYSTEM 0x30000000 /* System reset */ +#define TCR_WIE 0x08000000 /* Watchdog Interrupt Enable */ +#define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ +#define TCR_DIE 0x04000000 /* Pecrementer Interrupt Enable */ +#define TCR_FP_MASK 0x03000000 /* FIT Period */ +#define TCR_FP_2_9 0x00000000 /* 2**9 clocks */ +#define TCR_FP_2_13 0x01000000 /* 2**13 clocks */ +#define TCR_FP_2_17 0x02000000 /* 2**17 clocks */ +#define TCR_FP_2_21 0x03000000 /* 2**21 clocks */ +#define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ +#define TCR_ARE 0x00400000 /* Auto Reload Enable */ + +#define SPR_HID0 0x3f0 /* ..8 Hardware Implementation Register 0 */ +#define SPR_HID1 0x3f1 /* ..8 Hardware Implementation Register 1 */ +#define SPR_HID2 0x3f3 /* ..8 Hardware Implementation Register 2 */ +#define SPR_HID4 0x3f4 /* ..8 Hardware Implementation Register 4 */ +#define SPR_HID5 0x3f6 /* ..8 Hardware Implementation Register 5 */ +#define SPR_HID6 0x3f9 /* ..8 Hardware Implementation Register 6 */ + +#define SPR_CELL_TSRL 0x380 /* ... Cell BE Thread Status Register */ +#define SPR_CELL_TSCR 0x399 /* ... Cell BE Thread Switch Register */ + +#if defined(AIM) +#define SPR_PIR 0x3ff /* .6. Processor Identification Register */ +#elif defined(BOOKE) +#define SPR_PIR 0x11e /* ..8 Processor Identification Register */ +#endif + +#define DBCR0_EDM 0x80000000 /* External Debug Mode */ +#define DBCR0_IDM 0x40000000 /* Internal Debug Mode */ +#define DBCR0_RST_MASK 0x30000000 /* ReSeT */ +#define DBCR0_RST_NONE 0x00000000 /* No action */ +#define DBCR0_RST_CORE 0x10000000 /* Core reset */ +#define DBCR0_RST_CHIP 0x20000000 /* Chip reset */ +#define DBCR0_RST_SYSTEM 0x30000000 /* System reset */ +#define DBCR0_IC 0x08000000 /* Instruction Completion debug event */ +#define DBCR0_BT 0x04000000 /* Branch Taken debug event */ +#define DBCR0_EDE 0x02000000 /* Exception Debug Event */ +#define DBCR0_TDE 0x01000000 /* Trap Debug Event */ +#define DBCR0_IA1 0x00800000 /* IAC (Instruction Address Compare) 1 debug event */ +#define DBCR0_IA2 0x00400000 /* IAC 2 debug event */ +#define DBCR0_IA12 0x00200000 /* Instruction Address Range Compare 1-2 */ +#define DBCR0_IA12X 0x00100000 /* IA12 eXclusive */ +#define DBCR0_IA3 0x00080000 /* IAC 3 debug event */ +#define DBCR0_IA4 0x00040000 /* IAC 4 debug event */ +#define DBCR0_IA34 0x00020000 /* Instruction Address Range Compare 3-4 */ +#define DBCR0_IA34X 0x00010000 /* IA34 eXclusive */ +#define DBCR0_IA12T 0x00008000 /* Instruction Address Range Compare 1-2 range Toggle */ +#define DBCR0_IA34T 0x00004000 /* Instruction Address Range Compare 3-4 range Toggle */ +#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */ + +#define SPR_IABR 0x3f2 /* ..8 Instruction Address Breakpoint Register 0 */ +#define SPR_DABR 0x3f5 /* .6. Data Address Breakpoint Register */ +#define SPR_MSSCR0 0x3f6 /* .6. Memory SubSystem Control Register */ +#define MSSCR0_SHDEN 0x80000000 /* 0: Shared-state enable */ +#define MSSCR0_SHDPEN3 0x40000000 /* 1: ~SHD[01] signal enable in MEI mode */ +#define MSSCR0_L1INTVEN 0x38000000 /* 2-4: L1 data cache ~HIT intervention enable */ +#define MSSCR0_L2INTVEN 0x07000000 /* 5-7: L2 data cache ~HIT intervention enable*/ +#define MSSCR0_DL1HWF 0x00800000 /* 8: L1 data cache hardware flush */ +#define MSSCR0_MBO 0x00400000 /* 9: must be one */ +#define MSSCR0_EMODE 0x00200000 /* 10: MPX bus mode (read-only) */ +#define MSSCR0_ABD 0x00100000 /* 11: address bus driven (read-only) */ +#define MSSCR0_MBZ 0x000fffff /* 12-31: must be zero */ +#define MSSCR0_L2PFE 0x00000003 /* 30-31: L2 prefetch enable */ +#define SPR_MSSSR0 0x3f7 /* .6. Memory Subsystem Status Register (MPC745x) */ +#define MSSSR0_L2TAG 0x00040000 /* 13: L2 tag parity error */ +#define MSSSR0_L2DAT 0x00020000 /* 14: L2 data parity error */ +#define MSSSR0_L3TAG 0x00010000 /* 15: L3 tag parity error */ +#define MSSSR0_L3DAT 0x00008000 /* 16: L3 data parity error */ +#define MSSSR0_APE 0x00004000 /* 17: Address parity error */ +#define MSSSR0_DPE 0x00002000 /* 18: Data parity error */ +#define MSSSR0_TEA 0x00001000 /* 19: Bus transfer error acknowledge */ +#define SPR_LDSTCR 0x3f8 /* .6. Load/Store Control Register */ +#define SPR_L2PM 0x3f8 /* .6. L2 Private Memory Control Register */ +#define SPR_L2CR 0x3f9 /* .6. L2 Control Register */ +#define L2CR_L2E 0x80000000 /* 0: L2 enable */ +#define L2CR_L2PE 0x40000000 /* 1: L2 data parity enable */ +#define L2CR_L2SIZ 0x30000000 /* 2-3: L2 size */ +#define L2SIZ_2M 0x00000000 +#define L2SIZ_256K 0x10000000 +#define L2SIZ_512K 0x20000000 +#define L2SIZ_1M 0x30000000 +#define L2CR_L2CLK 0x0e000000 /* 4-6: L2 clock ratio */ +#define L2CLK_DIS 0x00000000 /* disable L2 clock */ +#define L2CLK_10 0x02000000 /* core clock / 1 */ +#define L2CLK_15 0x04000000 /* / 1.5 */ +#define L2CLK_20 0x08000000 /* / 2 */ +#define L2CLK_25 0x0a000000 /* / 2.5 */ +#define L2CLK_30 0x0c000000 /* / 3 */ +#define L2CR_L2RAM 0x01800000 /* 7-8: L2 RAM type */ +#define L2RAM_FLOWTHRU_BURST 0x00000000 +#define L2RAM_PIPELINE_BURST 0x01000000 +#define L2RAM_PIPELINE_LATE 0x01800000 +#define L2CR_L2DO 0x00400000 /* 9: L2 data-only. + Setting this bit disables instruction + caching. */ +#define L2CR_L2I 0x00200000 /* 10: L2 global invalidate. */ +#define L2CR_L2IO_7450 0x00010000 /* 11: L2 instruction-only (MPC745x). */ +#define L2CR_L2CTL 0x00100000 /* 11: L2 RAM control (ZZ enable). + Enables automatic operation of the + L2ZZ (low-power mode) signal. */ +#define L2CR_L2WT 0x00080000 /* 12: L2 write-through. */ +#define L2CR_L2TS 0x00040000 /* 13: L2 test support. */ +#define L2CR_L2OH 0x00030000 /* 14-15: L2 output hold. */ +#define L2CR_L2DO_7450 0x00010000 /* 15: L2 data-only (MPC745x). */ +#define L2CR_L2SL 0x00008000 /* 16: L2 DLL slow. */ +#define L2CR_L2DF 0x00004000 /* 17: L2 differential clock. */ +#define L2CR_L2BYP 0x00002000 /* 18: L2 DLL bypass. */ +#define L2CR_L2FA 0x00001000 /* 19: L2 flush assist (for software flush). */ +#define L2CR_L2HWF 0x00000800 /* 20: L2 hardware flush. */ +#define L2CR_L2IO 0x00000400 /* 21: L2 instruction-only. */ +#define L2CR_L2CLKSTP 0x00000200 /* 22: L2 clock stop. */ +#define L2CR_L2DRO 0x00000100 /* 23: L2DLL rollover checkstop enable. */ +#define L2CR_L2IP 0x00000001 /* 31: L2 global invalidate in */ + /* progress (read only). */ +#define SPR_L3CR 0x3fa /* .6. L3 Control Register */ +#define L3CR_L3E 0x80000000 /* 0: L3 enable */ +#define L3CR_L3PE 0x40000000 /* 1: L3 data parity enable */ +#define L3CR_L3APE 0x20000000 +#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */ +#define L3CR_L3CLKEN 0x08000000 /* 4: Enables L3_CLK[0:1] */ +#define L3CR_L3CLK 0x03800000 +#define L3CR_L3IO 0x00400000 +#define L3CR_L3CLKEXT 0x00200000 +#define L3CR_L3CKSPEXT 0x00100000 +#define L3CR_L3OH1 0x00080000 +#define L3CR_L3SPO 0x00040000 +#define L3CR_L3CKSP 0x00030000 +#define L3CR_L3PSP 0x0000e000 +#define L3CR_L3REP 0x00001000 +#define L3CR_L3HWF 0x00000800 +#define L3CR_L3I 0x00000400 /* 21: L3 global invalidate */ +#define L3CR_L3RT 0x00000300 +#define L3CR_L3NIRCA 0x00000080 +#define L3CR_L3DO 0x00000040 +#define L3CR_PMEN 0x00000004 +#define L3CR_PMSIZ 0x00000003 + +#define SPR_THRM1 0x3fc /* .6. Thermal Management Register */ +#define SPR_THRM2 0x3fd /* .6. Thermal Management Register */ +#define SPR_THRM_TIN 0x80000000 /* Thermal interrupt bit (RO) */ +#define SPR_THRM_TIV 0x40000000 /* Thermal interrupt valid (RO) */ +#define SPR_THRM_THRESHOLD(x) ((x) << 23) /* Thermal sensor threshold */ +#define SPR_THRM_TID 0x00000004 /* Thermal interrupt direction */ +#define SPR_THRM_TIE 0x00000002 /* Thermal interrupt enable */ +#define SPR_THRM_VALID 0x00000001 /* Valid bit */ +#define SPR_THRM3 0x3fe /* .6. Thermal Management Register */ +#define SPR_THRM_TIMER(x) ((x) << 1) /* Sampling interval timer */ +#define SPR_THRM_ENABLE 0x00000001 /* TAU Enable */ +#define SPR_FPECR 0x3fe /* .6. Floating-Point Exception Cause Register */ + +/* Time Base Register declarations */ +#define TBR_TBL 0x10c /* 468 Time Base Lower - read */ +#define TBR_TBU 0x10d /* 468 Time Base Upper - read */ +#define TBR_TBWL 0x11c /* 468 Time Base Lower - supervisor, write */ +#define TBR_TBWU 0x11d /* 468 Time Base Upper - supervisor, write */ + +/* Performance counter declarations */ +#define PMC_OVERFLOW 0x80000000 /* Counter has overflowed */ + +/* The first five countable [non-]events are common to many PMC's */ +#define PMCN_NONE 0 /* Count nothing */ +#define PMCN_CYCLES 1 /* Processor cycles */ +#define PMCN_ICOMP 2 /* Instructions completed */ +#define PMCN_TBLTRANS 3 /* TBL bit transitions */ +#define PCMN_IDISPATCH 4 /* Instructions dispatched */ + +/* Similar things for the 970 PMC direct counters */ +#define PMC970N_NONE 0x8 /* Count nothing */ +#define PMC970N_CYCLES 0xf /* Processor cycles */ +#define PMC970N_ICOMP 0x9 /* Instructions completed */ + +#if defined(BOOKE) + +#define SPR_MCARU 0x239 /* ..8 Machine Check Address register upper bits */ +#define SPR_MCSR 0x23c /* ..8 Machine Check Syndrome register */ +#define MCSR_MCP 0x80000000 /* Machine check input signal to core */ +#define MCSR_L2MMU_MHIT 0x08000000 /* L2 MMU simultaneous hit */ +#define MCSR_NMI 0x00100000 /* Non-maskable interrupt */ +#define MCSR_MAV 0x00080000 /* MCAR address valid */ +#define MCSR_MEA 0x00040000 /* MCAR effective address */ +#define MCSR_IF 0x00010000 /* Instruction fetch error report */ +#define MCSR_LD 0x00008000 /* Load instruction error report */ +#define MCSR_ST 0x00004000 /* Store instruction error report */ +#define MCSR_LDG 0x00002000 /* Guarded load instruction error report */ +#define MCSR_TLBSYNC 0x00000002 /* Simultaneous TLBSYNC detected */ +#define SPR_MCAR 0x23d /* ..8 Machine Check Address register */ + +#define SPR_ESR 0x003e /* ..8 Exception Syndrome Register */ +#define ESR_PIL 0x08000000 /* Program interrupt - illegal */ +#define ESR_PPR 0x04000000 /* Program interrupt - privileged */ +#define ESR_PTR 0x02000000 /* Program interrupt - trap */ +#define ESR_ST 0x00800000 /* Store operation */ +#define ESR_DLK 0x00200000 /* Data storage, D cache locking */ +#define ESR_ILK 0x00100000 /* Data storage, I cache locking */ +#define ESR_BO 0x00020000 /* Data/instruction storage, byte ordering */ +#define ESR_SPE 0x00000080 /* SPE exception bit */ + +#define SPR_CSRR0 0x03a /* ..8 58 Critical SRR0 */ +#define SPR_CSRR1 0x03b /* ..8 59 Critical SRR1 */ +#define SPR_MCSRR0 0x23a /* ..8 570 Machine check SRR0 */ +#define SPR_MCSRR1 0x23b /* ..8 571 Machine check SRR1 */ +#define SPR_DSRR0 0x23e /* ..8 574 Debug SRR0 */ +#define SPR_DSRR1 0x23f /* ..8 575 Debug SRR1 */ + +#define SPR_MMUCSR0 0x3f4 /* ..8 1012 MMU Control and Status Register 0 */ +#define MMUCSR0_L2TLB0_FI 0x04 /* TLB0 flash invalidate */ +#define MMUCSR0_L2TLB1_FI 0x02 /* TLB1 flash invalidate */ + +#define SPR_SVR 0x3ff /* ..8 1023 System Version Register */ +#define SVR_MPC8533 0x8034 +#define SVR_MPC8533E 0x803c +#define SVR_MPC8541 0x8072 +#define SVR_MPC8541E 0x807a +#define SVR_MPC8548 0x8031 +#define SVR_MPC8548E 0x8039 +#define SVR_MPC8555 0x8071 +#define SVR_MPC8555E 0x8079 +#define SVR_MPC8572 0x80e0 +#define SVR_MPC8572E 0x80e8 +#define SVR_P1011 0x80e5 +#define SVR_P1011E 0x80ed +#define SVR_P1013 0x80e7 +#define SVR_P1013E 0x80ef +#define SVR_P1020 0x80e4 +#define SVR_P1020E 0x80ec +#define SVR_P1022 0x80e6 +#define SVR_P1022E 0x80ee +#define SVR_P2010 0x80e3 +#define SVR_P2010E 0x80eb +#define SVR_P2020 0x80e2 +#define SVR_P2020E 0x80ea +#define SVR_P2041 0x8210 +#define SVR_P2041E 0x8218 +#define SVR_P3041 0x8211 +#define SVR_P3041E 0x8219 +#define SVR_P4040 0x8200 +#define SVR_P4040E 0x8208 +#define SVR_P4080 0x8201 +#define SVR_P4080E 0x8209 +#define SVR_P5010 0x8221 +#define SVR_P5010E 0x8229 +#define SVR_P5020 0x8220 +#define SVR_P5020E 0x8228 +#define SVR_P5021 0x8205 +#define SVR_P5021E 0x820d +#define SVR_P5040 0x8204 +#define SVR_P5040E 0x820c +#define SVR_VER(svr) (((svr) >> 16) & 0xffff) + +#define SPR_PID0 0x030 /* ..8 Process ID Register 0 */ +#define SPR_PID1 0x279 /* ..8 Process ID Register 1 */ +#define SPR_PID2 0x27a /* ..8 Process ID Register 2 */ + +#define SPR_TLB0CFG 0x2B0 /* ..8 TLB 0 Config Register */ +#define SPR_TLB1CFG 0x2B1 /* ..8 TLB 1 Config Register */ +#define TLBCFG_ASSOC_MASK 0xff000000 /* Associativity of TLB */ +#define TLBCFG_ASSOC_SHIFT 24 +#define TLBCFG_NENTRY_MASK 0x00000fff /* Number of entries in TLB */ + +#define SPR_IVPR 0x03f /* ..8 Interrupt Vector Prefix Register */ +#define SPR_IVOR0 0x190 /* ..8 Critical input */ +#define SPR_IVOR1 0x191 /* ..8 Machine check */ +#define SPR_IVOR2 0x192 +#define SPR_IVOR3 0x193 +#define SPR_IVOR4 0x194 +#define SPR_IVOR5 0x195 +#define SPR_IVOR6 0x196 +#define SPR_IVOR7 0x197 +#define SPR_IVOR8 0x198 +#define SPR_IVOR9 0x199 +#define SPR_IVOR10 0x19a +#define SPR_IVOR11 0x19b +#define SPR_IVOR12 0x19c +#define SPR_IVOR13 0x19d +#define SPR_IVOR14 0x19e +#define SPR_IVOR15 0x19f +#define SPR_IVOR32 0x210 +#define SPR_IVOR33 0x211 +#define SPR_IVOR34 0x212 +#define SPR_IVOR35 0x213 + +#define SPR_MAS0 0x270 /* ..8 MMU Assist Register 0 Book-E/e500 */ +#define SPR_MAS1 0x271 /* ..8 MMU Assist Register 1 Book-E/e500 */ +#define SPR_MAS2 0x272 /* ..8 MMU Assist Register 2 Book-E/e500 */ +#define SPR_MAS3 0x273 /* ..8 MMU Assist Register 3 Book-E/e500 */ +#define SPR_MAS4 0x274 /* ..8 MMU Assist Register 4 Book-E/e500 */ +#define SPR_MAS5 0x275 /* ..8 MMU Assist Register 5 Book-E */ +#define SPR_MAS6 0x276 /* ..8 MMU Assist Register 6 Book-E/e500 */ +#define SPR_MAS7 0x3B0 /* ..8 MMU Assist Register 7 Book-E/e500 */ +#define SPR_MAS8 0x155 /* ..8 MMU Assist Register 8 Book-E/e500 */ + +#define SPR_L1CFG0 0x203 /* ..8 L1 cache configuration register 0 */ +#define SPR_L1CFG1 0x204 /* ..8 L1 cache configuration register 1 */ + +#define SPR_CCR1 0x378 +#define CCR1_L2COBE 0x00000040 + +#define DCR_L2DCDCRAI 0x0000 /* L2 D-Cache DCR Address Pointer */ +#define DCR_L2DCDCRDI 0x0001 /* L2 D-Cache DCR Data Indirect */ +#define DCR_L2CR0 0x00 /* L2 Cache Configuration Register 0 */ +#define L2CR0_AS 0x30000000 + +#define SPR_L1CSR0 0x3F2 /* ..8 L1 Cache Control and Status Register 0 */ +#define L1CSR0_DCPE 0x00010000 /* Data Cache Parity Enable */ +#define L1CSR0_DCLFR 0x00000100 /* Data Cache Lock Bits Flash Reset */ +#define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */ +#define L1CSR0_DCE 0x00000001 /* Data Cache Enable */ +#define SPR_L1CSR1 0x3F3 /* ..8 L1 Cache Control and Status Register 1 */ +#define L1CSR1_ICPE 0x00010000 /* Instruction Cache Parity Enable */ +#define L1CSR1_ICUL 0x00000400 /* Instr Cache Unable to Lock */ +#define L1CSR1_ICLFR 0x00000100 /* Instruction Cache Lock Bits Flash Reset */ +#define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */ +#define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */ + +#define SPR_L2CFG0 0x207 /* ..8 L2 Configuration Register 0 */ +#define SPR_L2CSR0 0x3F9 /* ..8 L2 Cache Control and Status Register 0 */ +#define L2CSR0_L2E 0x80000000 /* L2 Cache Enable */ +#define L2CSR0_L2PE 0x40000000 /* L2 Cache Parity Enable */ +#define L2CSR0_L2FI 0x00200000 /* L2 Cache Flash Invalidate */ +#define L2CSR0_L2LFC 0x00000400 /* L2 Cache Lock Flags Clear */ + +#define SPR_BUCSR 0x3F5 /* ..8 Branch Unit Control and Status Register */ +#define BUCSR_BPEN 0x00000001 /* Branch Prediction Enable */ +#define BUCSR_BBFI 0x00000200 /* Branch Buffer Flash Invalidate */ + +#endif /* BOOKE */ +#endif /* !_POWERPC_SPR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/sr.h b/lib/libc/include/powerpc64-freebsd-none/machine/sr.h new file mode 100644 index 0000000000000000000000000000000000000000..e0c8a3bc56fefc46e95cbe681bc7c26101b0a6c3 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/sr.h @@ -0,0 +1,62 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2002 Benno Rice. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_SR_H_ +#define _MACHINE_SR_H_ + +/* + * Bit definitions for segment registers. + * + * PowerPC Microprocessor Family: The Programming Environments for 32-bit + * Microprocessors, section 2.3.5 + */ + +#define SR_TYPE 0x80000000 /* Type selector */ +#define SR_KS 0x40000000 /* Supervisor-state protection key */ +#define SR_KP 0x20000000 /* User-state protection key */ +#define SR_N 0x10000000 /* No-execute protection */ +#define SR_VSID_MASK 0x00ffffff /* Virtual Segment ID mask */ + +/* Kernel segment register usage */ +#define USER_SR 12 +#define KERNEL_SR 13 +#define KERNEL2_SR 14 +#define KERNEL3_SR 15 +#define KERNEL_VSIDBITS 0xfffffUL +#define KERNEL_SEGMENT (0xfffff0 + KERNEL_SR) +#define KERNEL2_SEGMENT (0xfffff0 + KERNEL2_SR) +#define EMPTY_SEGMENT 0xfffff0 +#ifdef __powerpc64__ +#define USER_ADDR 0xc00ffffff0000000UL +#else +#define USER_ADDR ((uintptr_t)USER_SR << ADDR_SR_SHFT) +#endif +#define SEGMENT_LENGTH 0x10000000UL +#define SEGMENT_INVMASK 0x0fffffffUL +#define SEGMENT_MASK ~SEGMENT_INVMASK + +#endif /* !_MACHINE_SR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/stack.h b/lib/libc/include/powerpc64-freebsd-none/machine/stack.h new file mode 100644 index 0000000000000000000000000000000000000000..34a6caee56a2762e17ee6a14f8a6be203e4221df --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/stack.h @@ -0,0 +1,54 @@ +/*- + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#ifndef _MACHINE_STACK_H_ +#define _MACHINE_STACK_H_ + +extern int trapexit[]; +extern int asttrapexit[]; +extern int end[]; + +#ifdef _SYS_PROC_H_ + +#include + +/* Get the current kernel thread stack usage. */ +#define GET_STACK_USAGE(total, used) do { \ + struct thread *td = curthread; \ + (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \ + (used) = td->td_kstack + (total) - (vm_offset_t)&td; \ +} while (0) + +static __inline bool +kstack_contains(struct thread *td, vm_offset_t va, size_t len) +{ + return (va >= td->td_kstack && va + len >= va && + va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE - + sizeof(struct pcb)); +} +#endif /* _SYS_PROC_H_ */ + +#endif /* !_MACHINE_STACK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/sysarch.h b/lib/libc/include/powerpc64-freebsd-none/machine/sysarch.h new file mode 100644 index 0000000000000000000000000000000000000000..e1911def3572a541f6f05d9bc401f8f984ef9499 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/sysarch.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1993 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_SYSARCH_H_ +#define _MACHINE_SYSARCH_H_ + +#ifndef _KERNEL +#include + +__BEGIN_DECLS +int sysarch(int, void *); +__END_DECLS +#endif + +#endif /* !_MACHINE_SYSARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/tlb.h b/lib/libc/include/powerpc64-freebsd-none/machine/tlb.h new file mode 100644 index 0000000000000000000000000000000000000000..2064827437f063366857666019dc3e100316a40b --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/tlb.h @@ -0,0 +1,181 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (C) 2006-2012 Semihalf. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MACHINE_TLB_H_ +#define _MACHINE_TLB_H_ + +#if defined(BOOKE_E500) + +/* PowerPC E500 MAS registers */ +#define MAS0_TLBSEL(x) ((x << 28) & 0x10000000) +#define MAS0_ESEL(x) ((x << 16) & 0x003F0000) + +#define MAS0_TLBSEL1 0x10000000 +#define MAS0_TLBSEL0 0x00000000 +#define MAS0_ESEL_TLB1MASK 0x000F0000 +#define MAS0_ESEL_TLB0MASK 0x00030000 +#define MAS0_ESEL_SHIFT 16 +#define MAS0_NV_MASK 0x00000003 +#define MAS0_NV_SHIFT 0 + +#define MAS1_VALID 0x80000000 +#define MAS1_IPROT 0x40000000 +#define MAS1_TID_MASK 0x00FF0000 +#define MAS1_TID_SHIFT 16 +#define MAS1_TS_MASK 0x00001000 +#define MAS1_TS_SHIFT 12 +#define MAS1_TSIZE_MASK 0x00000F00 +#define MAS1_TSIZE_SHIFT 8 + +#define TLB_SIZE_4K 1 +#define TLB_SIZE_16K 2 +#define TLB_SIZE_64K 3 +#define TLB_SIZE_256K 4 +#define TLB_SIZE_1M 5 +#define TLB_SIZE_4M 6 +#define TLB_SIZE_16M 7 +#define TLB_SIZE_64M 8 +#define TLB_SIZE_256M 9 +#define TLB_SIZE_1G 10 +#define TLB_SIZE_4G 11 + +#ifdef __powerpc64__ +#define MAS2_EPN_MASK 0xFFFFFFFFFFFFF000UL +#else +#define MAS2_EPN_MASK 0xFFFFF000 +#endif +#define MAS2_EPN_SHIFT 12 +#define MAS2_X0 0x00000040 +#define MAS2_X1 0x00000020 +#define MAS2_W 0x00000010 +#define MAS2_I 0x00000008 +#define MAS2_M 0x00000004 +#define MAS2_G 0x00000002 +#define MAS2_E 0x00000001 +#define MAS2_WIMGE_MASK 0x0000007F + +#define MAS3_RPN 0xFFFFF000 +#define MAS3_RPN_SHIFT 12 +#define MAS3_U0 0x00000200 +#define MAS3_U1 0x00000100 +#define MAS3_U2 0x00000080 +#define MAS3_U3 0x00000040 +#define MAS3_UX 0x00000020 +#define MAS3_SX 0x00000010 +#define MAS3_UW 0x00000008 +#define MAS3_SW 0x00000004 +#define MAS3_UR 0x00000002 +#define MAS3_SR 0x00000001 + +#define MAS4_TLBSELD1 0x10000000 +#define MAS4_TLBSELD0 0x00000000 +#define MAS4_TIDSELD_MASK 0x00030000 +#define MAS4_TIDSELD_SHIFT 16 +#define MAS4_TSIZED_MASK 0x00000F00 +#define MAS4_TSIZED_SHIFT 8 +#define MAS4_X0D 0x00000040 +#define MAS4_X1D 0x00000020 +#define MAS4_WD 0x00000010 +#define MAS4_ID 0x00000008 +#define MAS4_MD 0x00000004 +#define MAS4_GD 0x00000002 +#define MAS4_ED 0x00000001 + +#define MAS6_SPID0_MASK 0x00FF0000 +#define MAS6_SPID0_SHIFT 16 +#define MAS6_SAS 0x00000001 + +#define MAS7_RPN 0x0000000F + +#define MAS1_GETTID(mas1) (((mas1) & MAS1_TID_MASK) >> MAS1_TID_SHIFT) + +#define MAS2_TLB0_ENTRY_IDX_MASK 0x0007f000 +#define MAS2_TLB0_ENTRY_IDX_SHIFT 12 + +/* + * Maximum number of TLB1 entries used for a permanent mapping of kernel + * region (kernel image plus statically allocated data). + */ +#define KERNEL_REGION_MAX_TLB_ENTRIES 4 + +/* + * Use MAS2_X0 to mark entries which will be copied + * to AP CPUs during SMP bootstrap. As result entries + * marked with _TLB_ENTRY_SHARED will be shared by all CPUs. + */ +#define _TLB_ENTRY_SHARED (MAS2_X0) /* XXX under SMP? */ +#define _TLB_ENTRY_IO (MAS2_I | MAS2_G) +#define _TLB_ENTRY_MEM (MAS2_M) + +#define TLB1_MAX_ENTRIES 64 + +#if !defined(LOCORE) +typedef struct tlb_entry { + vm_paddr_t phys; + vm_offset_t virt; + vm_size_t size; + uint32_t mas1; +#ifdef __powerpc64__ + uint64_t mas2; +#else + uint32_t mas2; +#endif + uint32_t mas3; + uint32_t mas7; +} tlb_entry_t; + +void tlb1_inval_entry(unsigned int); +void tlb1_init(void); +#endif /* !LOCORE */ + +#endif /* BOOKE_E500 */ + +#define TID_KERNEL 0 /* TLB TID to use for kernel (shared) translations */ +#define TID_KRESERVED 1 /* Number of TIDs reserved for kernel */ +#define TID_URESERVED 0 /* Number of TIDs reserved for user */ +#define TID_MIN (TID_KRESERVED + TID_URESERVED) +#define TID_MAX 255 +#define TID_NONE -1 + +#define TLB_UNLOCKED 0 + +#if !defined(LOCORE) + +typedef int tlbtid_t; + +struct pmap; + +void tlb_lock(uintptr_t *); +void tlb_unlock(uintptr_t *); +void tlb1_ap_prep(void); +int tlb1_set_entry(vm_offset_t, vm_paddr_t, vm_size_t, uint32_t); + +#endif /* !LOCORE */ + +#endif /* _MACHINE_TLB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/tls.h b/lib/libc/include/powerpc64-freebsd-none/machine/tls.h new file mode 100644 index 0000000000000000000000000000000000000000..6dea3eb3a99ffb89592ce27b9ea3e78c5fb0a7ff --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/tls.h @@ -0,0 +1,66 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2004 by Peter Grehan. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_TLS_H_ +#define _MACHINE_TLS_H_ + +#include + +#define TLS_DTV_OFFSET 0x8000 +#define TLS_TCB_ALIGN TLS_TCB_SIZE +#define TLS_TP_OFFSET 0x7000 + +static __inline void +_tcb_set(struct tcb *tcb) +{ +#ifdef __powerpc64__ + __asm __volatile("mr 13,%0" :: + "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE)); +#else + __asm __volatile("mr 2,%0" :: + "r" ((uint8_t *)tcb + TLS_TP_OFFSET + TLS_TCB_SIZE)); +#endif +} + +static __inline struct tcb * +_tcb_get(void) +{ + struct tcb *tcb; + +#ifdef __powerpc64__ + __asm __volatile("addi %0,13,%1" : "=r" (tcb) : + "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE))); +#else + __asm __volatile("addi %0,2,%1" : "=r" (tcb) : + "i" (-(TLS_TP_OFFSET + TLS_TCB_SIZE))); +#endif + return (tcb); +} + +#endif /* !_MACHINE_TLS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/trap.h b/lib/libc/include/powerpc64-freebsd-none/machine/trap.h new file mode 100644 index 0000000000000000000000000000000000000000..7326ba17c5cdefd361a944051cf1555a2924107f --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/trap.h @@ -0,0 +1,160 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: trap.h,v 1.7 2002/02/22 13:51:40 kleink Exp $ + */ + +#ifndef _POWERPC_TRAP_H_ +#define _POWERPC_TRAP_H_ + +#define EXC_RSVD 0x0000 /* Reserved */ +#define EXC_RST 0x0100 /* Reset; all but IBM4xx */ +#define EXC_MCHK 0x0200 /* Machine Check */ +#define EXC_DSI 0x0300 /* Data Storage Interrupt */ +#define EXC_DSE 0x0380 /* Data Segment Interrupt */ +#define EXC_ISI 0x0400 /* Instruction Storage Interrupt */ +#define EXC_ISE 0x0480 /* Instruction Segment Interrupt */ +#define EXC_EXI 0x0500 /* External Interrupt */ +#define EXC_ALI 0x0600 /* Alignment Interrupt */ +#define EXC_PGM 0x0700 /* Program Interrupt */ +#define EXC_FPU 0x0800 /* Floating-point Unavailable */ +#define EXC_DECR 0x0900 /* Decrementer Interrupt */ +#define EXC_SC 0x0c00 /* System Call */ +#define EXC_TRC 0x0d00 /* Trace */ +#define EXC_FPA 0x0e00 /* Floating-point Assist */ + +/* The following is only available on the 601: */ +#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */ + +/* The following are only available on 970(G5): */ +#define EXC_VECAST_G5 0x1700 /* AltiVec Assist */ + +/* The following are only available on 7400(G4): */ +#define EXC_VEC 0x0f20 /* AltiVec Unavailable */ +#define EXC_VECAST_G4 0x1600 /* AltiVec Assist */ + +/* The following are only available on 604/750/7400: */ +#define EXC_PERF 0x0f00 /* Performance Monitoring */ +#define EXC_BPT 0x1300 /* Instruction Breakpoint */ +#define EXC_SMI 0x1400 /* System Managment Interrupt */ + +/* The following are only available on 750/7400: */ +#define EXC_THRM 0x1700 /* Thermal Management Interrupt */ + +/* And these are only on the 603: */ +#define EXC_IMISS 0x1000 /* Instruction translation miss */ +#define EXC_DLMISS 0x1100 /* Data load translation miss */ +#define EXC_DSMISS 0x1200 /* Data store translation miss */ + +/* Power ISA 2.06+: */ +#define EXC_HDSI 0x0e00 /* Hypervisor Data Storage */ +#define EXC_HISI 0x0e20 /* Hypervisor Instruction Storage */ +#define EXC_HEA 0x0e40 /* Hypervisor Emulation Assistance */ +#define EXC_HMI 0x0e60 /* Hypervisor Maintenance */ +#define EXC_VSX 0x0f40 /* VSX Unavailable */ + +/* Power ISA 2.07+: */ +#define EXC_FAC 0x0f60 /* Facility Unavailable */ +#define EXC_HFAC 0x0f80 /* Hypervisor Facility Unavailable */ + +/* Power ISA 3.0+: */ +#define EXC_HVI 0x0ea0 /* Hypervisor Virtualization */ + +/* The following are available on 4xx and 85xx */ +#define EXC_CRIT 0x0100 /* Critical Input Interrupt */ +#define EXC_PIT 0x1000 /* Programmable Interval Timer */ +#define EXC_FIT 0x1010 /* Fixed Interval Timer */ +#define EXC_WDOG 0x1020 /* Watchdog Timer */ +#define EXC_DTMISS 0x1100 /* Data TLB Miss */ +#define EXC_ITMISS 0x1200 /* Instruction TLB Miss */ +#define EXC_APU 0x1300 /* Auxiliary Processing Unit */ +#define EXC_DEBUG 0x2f10 /* Debug trap */ +#define EXC_VECAST_E 0x2f20 /* Altivec Assist (Book-E) */ +#define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */ +#define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */ + +/* POWER8 */ +#define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */ + +#define EXC_LAST 0x2f00 /* Last possible exception vector */ + +#define EXC_AST 0x3000 /* Fake AST vector */ + +/* Trap was in user mode */ +#define EXC_USER 0x10000 + +/* + * EXC_ALI sets bits in the DSISR and DAR to provide enough + * information to recover from the unaligned access without needing to + * parse the offending instruction. This includes certain bits of the + * opcode, and information about what registers are used. The opcode + * indicator values below come from Appendix F of Book III of "The + * PowerPC Architecture". + */ + +#define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f) +#define EXC_ALI_LFD 0x09 +#define EXC_ALI_STFD 0x0b + +/* Macros to extract register information */ +#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */ +#define EXC_ALI_RA(dsisr) (dsisr & 0x1f) +#define EXC_ALI_INST_RST(instr) ((instr >> 21) & 0x1f) + +/* + * SRR1 bits for program exception traps. These identify what caused + * the program exception. See section 6.5.9 of the Power ISA Version + * 2.05. + */ + +#define EXC_PGM_FPENABLED (1UL << 20) +#define EXC_PGM_ILLEGAL (1UL << 19) +#define EXC_PGM_PRIV (1UL << 18) +#define EXC_PGM_TRAP (1UL << 17) + +/* DTrace trap opcode. */ +#define EXC_DTRACE 0x7ffff808 + +/* Magic pointer to store TOC base and other info for trap handlers on ppc64 */ +#define TRAP_ENTRY 0x1e8 +#define TRAP_GENTRAP 0x1f0 +#define TRAP_TOCBASE 0x1f8 + +#ifndef LOCORE +struct trapframe; +struct thread; +extern int (*hmi_handler)(struct trapframe *); +void trap(struct trapframe *); +int ppc_instr_emulate(struct trapframe *, struct thread *); +#endif + +#endif /* _POWERPC_TRAP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/ucontext.h b/lib/libc/include/powerpc64-freebsd-none/machine/ucontext.h new file mode 100644 index 0000000000000000000000000000000000000000..c7a858f7d1f2cfd129f9d739c20f12670e7c49da --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/ucontext.h @@ -0,0 +1,93 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: signal.h,v 1.4 1998/09/14 02:48:34 thorpej Exp $ + */ + +#ifndef _MACHINE_UCONTEXT_H_ +#define _MACHINE_UCONTEXT_H_ + +typedef struct __mcontext { + int mc_vers; + int mc_flags; +#define _MC_FP_VALID 0x01 +#define _MC_AV_VALID 0x02 +#define _MC_VS_VALID 0x04 + int mc_onstack; /* saved onstack flag */ + int mc_len; /* sizeof(__mcontext) */ + __uint64_t mc_avec[32*2]; /* vector register file */ + __uint32_t mc_av[2]; + __register_t mc_frame[42]; + __uint64_t mc_fpreg[33]; + __uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ +} mcontext_t __aligned(16); + +#if defined(_KERNEL) && defined(__powerpc64__) +typedef struct __mcontext32 { + int mc_vers; + int mc_flags; +#define _MC_FP_VALID 0x01 +#define _MC_AV_VALID 0x02 +#define _MC_VS_VALID 0x04 + int mc_onstack; /* saved onstack flag */ + int mc_len; /* sizeof(__mcontext) */ + uint64_t mc_avec[32*2]; /* vector register file */ + uint32_t mc_av[2]; + uint32_t mc_frame[42]; + uint64_t mc_fpreg[33]; + uint64_t mc_vsxfpreg[32]; /* low-order half of VSR0-31 */ +} mcontext32_t __aligned(16); +#endif + +/* GPRs and supervisor-level regs */ +#define mc_gpr mc_frame +#define mc_lr mc_frame[32] +#define mc_cr mc_frame[33] +#define mc_xer mc_frame[34] +#define mc_ctr mc_frame[35] +#define mc_srr0 mc_frame[36] +#define mc_srr1 mc_frame[37] +#define mc_exc mc_frame[38] +#define mc_dar mc_frame[39] +#define mc_dsisr mc_frame[40] + +/* floating-point state */ +#define mc_fpscr mc_fpreg[32] + +/* altivec state */ +#define mc_vscr mc_av[0] +#define mc_vrsave mc_av[1] + +#define _MC_VERSION 0x1 +#define _MC_VERSION_KSE 0xee /* partial ucontext for libpthread */ + +#endif /* !_MACHINE_UCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/vdso.h b/lib/libc/include/powerpc64-freebsd-none/machine/vdso.h new file mode 100644 index 0000000000000000000000000000000000000000..2a3e6f6dfd8f9ef396902c6fda487f619485e786 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/vdso.h @@ -0,0 +1,43 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2012 Konstantin Belousov . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _POWERPC_VDSO_H +#define _POWERPC_VDSO_H + +#define VDSO_TIMEHANDS_MD \ + uint32_t th_res[8]; + +#define VDSO_TH_ALGO_PPC_TB VDSO_TH_ALGO_1 + +#ifdef _KERNEL +#ifdef COMPAT_FREEBSD32 + +#define VDSO_TIMEHANDS_MD32 VDSO_TIMEHANDS_MD + +#endif +#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/vm.h b/lib/libc/include/powerpc64-freebsd-none/machine/vm.h new file mode 100644 index 0000000000000000000000000000000000000000..fa397b398c8d1a027f88add570a9d7f0b6dc5343 --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/vm.h @@ -0,0 +1,45 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2009 Alan L. Cox + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_VM_H_ +#define _MACHINE_VM_H_ + +#include + +/* Memory attributes. */ +#define VM_MEMATTR_DEFAULT 0 +#define VM_MEMATTR_UNCACHEABLE 0x01 +#define VM_MEMATTR_CACHEABLE 0x02 +#define VM_MEMATTR_WRITE_COMBINING 0x04 +#define VM_MEMATTR_WRITE_BACK 0x08 +#define VM_MEMATTR_WRITE_THROUGH 0x10 +#define VM_MEMATTR_PREFETCHABLE 0x20 + +#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT + +#endif /* !_MACHINE_VM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/powerpc64-freebsd-none/machine/vmparam.h b/lib/libc/include/powerpc64-freebsd-none/machine/vmparam.h new file mode 100644 index 0000000000000000000000000000000000000000..7f49714b108b547980733095506acac68a7e33fd --- /dev/null +++ b/lib/libc/include/powerpc64-freebsd-none/machine/vmparam.h @@ -0,0 +1,327 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (C) 1995, 1996 Wolfgang Solfrank. + * Copyright (C) 1995, 1996 TooLs GmbH. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $NetBSD: vmparam.h,v 1.11 2000/02/11 19:25:16 thorpej Exp $ + */ + +#ifndef _MACHINE_VMPARAM_H_ +#define _MACHINE_VMPARAM_H_ + +#ifndef LOCORE +#include +#endif + +#define USRSTACK SHAREDPAGE + +#ifndef MAXTSIZ +#define MAXTSIZ (1*1024*1024*1024) /* max text size */ +#endif + +#ifndef DFLDSIZ +#define DFLDSIZ (128*1024*1024) /* default data size */ +#endif + +#ifndef MAXDSIZ +#ifdef __powerpc64__ +#define MAXDSIZ (32UL*1024*1024*1024) /* max data size */ +#else +#define MAXDSIZ (1*1024*1024*1024) /* max data size */ +#endif +#endif + +#ifndef DFLSSIZ +#define DFLSSIZ (8*1024*1024) /* default stack size */ +#endif + +#ifndef MAXSSIZ +#ifdef __powerpc64__ +#define MAXSSIZ (512*1024*1024) /* max stack size */ +#else +#define MAXSSIZ (64*1024*1024) /* max stack size */ +#endif +#endif + +#ifdef AIM +#define VM_MAXUSER_ADDRESS32 0xfffff000 +#else +#define VM_MAXUSER_ADDRESS32 0x7ffff000 +#endif + +/* + * Would like to have MAX addresses = 0, but this doesn't (currently) work + */ +#ifdef __powerpc64__ +/* + * Virtual addresses of things. Derived from the page directory and + * page table indexes from pmap.h for precision. + * + * kernel map should be able to start at 0xc008000000000000 - + * but at least the functional simulator doesn't like it + * + * 0x0000000000000000 - 0x000fffffffffffff user map + * 0xc000000000000000 - 0xc007ffffffffffff direct map + * 0xc008000000000000 - 0xc00fffffffffffff kernel map + * + */ +#define VM_MIN_ADDRESS 0x0000000000000000 +#define VM_MAXUSER_ADDRESS 0x000fffffc0000000 +#define VM_MAX_ADDRESS 0xc00fffffffffffff +#define VM_MIN_KERNEL_ADDRESS 0xc008000000000000 +#define VM_MAX_KERNEL_ADDRESS 0xc0080007ffffffff +#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS +#else +#define VM_MIN_ADDRESS 0 +#define VM_MAXUSER_ADDRESS VM_MAXUSER_ADDRESS32 +#define VM_MAX_ADDRESS 0xffffffff +#endif + +#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) + +#define FREEBSD32_SHAREDPAGE (VM_MAXUSER_ADDRESS32 - PAGE_SIZE) +#define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE + +#define KERNBASE 0x00100100 /* start of kernel virtual */ + +#define UMA_MD_SMALL_ALLOC + +#ifdef AIM +#ifndef __powerpc64__ +#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNEL_SR << ADDR_SR_SHFT) +#define VM_MAX_SAFE_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 2*SEGMENT_LENGTH -1) +#define VM_MAX_KERNEL_ADDRESS (VM_MIN_KERNEL_ADDRESS + 3*SEGMENT_LENGTH - 1) +#endif + +/* + * Use the direct-mapped BAT registers for UMA small allocs. This + * takes pressure off the small amount of available KVA. + */ +#define UMA_USE_DMAP + +#else /* Book-E */ + +/* Use the direct map for UMA small allocs on powerpc64. */ +#ifdef __powerpc64__ +#define UMA_USE_DMAP +#else +#define VM_MIN_KERNEL_ADDRESS 0xc0000000 +#define VM_MAX_KERNEL_ADDRESS 0xffffefff +#define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS +#endif + +#endif /* AIM/E500 */ + +#if !defined(LOCORE) +struct pmap_physseg { + struct pv_entry *pvent; + char *attrs; +}; +#endif + +#ifdef __powerpc64__ +#define VM_PHYSSEG_MAX 63 /* 1? */ +#else +#define VM_PHYSSEG_MAX 16 /* 1? */ +#endif + +#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with + * logical memory block size of 64MB. + * For more Ram increase the lmb or this value. + */ + +/* XXX This is non-sensical. Phys avail should hold contiguous regions. */ +#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ + +/* + * The physical address space is densely populated on 32-bit systems, + * but may not be on 64-bit ones. + */ +#ifdef __powerpc64__ +#define VM_PHYSSEG_SPARSE +#else +#define VM_PHYSSEG_DENSE +#endif + +/* + * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool + * from which physical pages are allocated and VM_FREEPOOL_DIRECT is + * the pool from which physical pages for small UMA objects are + * allocated. + */ +#define VM_NFREEPOOL 2 +#define VM_FREEPOOL_DEFAULT 0 +#define VM_FREEPOOL_DIRECT 1 + +/* + * Create one free page list. + */ +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 + +#ifdef __powerpc64__ +/* The largest allocation size is 16MB. */ +#define VM_NFREEORDER 13 +#else +/* The largest allocation size is 4MB. */ +#define VM_NFREEORDER 11 +#endif + +#ifndef VM_NRESERVLEVEL +#ifdef __powerpc64__ +/* Enable superpage reservations: 1 level. */ +#define VM_NRESERVLEVEL 1 +#else +/* Disable superpage reservations. */ +#define VM_NRESERVLEVEL 0 +#endif +#endif + +#ifndef VM_LEVEL_0_ORDER +/* Level 0 reservations consist of 512 (RPT) or 4096 (HPT) pages. */ +#define VM_LEVEL_0_ORDER vm_level_0_order +#ifndef __ASSEMBLER__ +extern int vm_level_0_order; +#endif +#endif + +#ifndef VM_LEVEL_0_ORDER_MAX +#define VM_LEVEL_0_ORDER_MAX 12 +#endif + +#ifndef VM_INITIAL_PAGEIN +#define VM_INITIAL_PAGEIN 16 +#endif + +#ifndef SGROWSIZ +#define SGROWSIZ (128UL*1024) /* amount to grow stack */ +#endif + +/* + * How many physical pages per kmem arena virtual page. + */ +#ifndef VM_KMEM_SIZE_SCALE +#define VM_KMEM_SIZE_SCALE (3) +#endif + +/* + * Optional floor (in bytes) on the size of the kmem arena. + */ +#ifndef VM_KMEM_SIZE_MIN +#define VM_KMEM_SIZE_MIN (12 * 1024 * 1024) +#endif + +/* + * Optional ceiling (in bytes) on the size of the kmem arena: 40% of the + * usable KVA space. + */ +#ifndef VM_KMEM_SIZE_MAX +#define VM_KMEM_SIZE_MAX ((VM_MAX_SAFE_KERNEL_ADDRESS - \ + VM_MIN_KERNEL_ADDRESS + 1) * 2 / 5) +#endif + +#ifdef __powerpc64__ +#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ +#else +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ +#endif + +/* + * On 32-bit OEA, the only purpose for which sf_buf is used is to implement + * an opaque pointer required by the machine-independent parts of the kernel. + * That pointer references the vm_page that is "mapped" by the sf_buf. The + * actual mapping is provided by the direct virtual-to-physical mapping. + * + * On OEA64 and Book-E, we need to do something a little more complicated. Use + * the runtime-detected hw_direct_map to pick between the two cases. Our + * friends in vm_machdep.c will do the same to ensure nothing gets confused. + */ +#define SFBUF +#define SFBUF_NOMD + +/* + * We (usually) have a direct map of all physical memory, so provide + * a macro to use to get the kernel VA address for a given PA. Check the + * value of PMAP_HAS_PMAP before using. + */ +#ifndef LOCORE +#ifdef __powerpc64__ +#define DMAP_BASE_ADDRESS 0xc000000000000000UL +#define DMAP_MIN_ADDRESS DMAP_BASE_ADDRESS +#define DMAP_MAX_ADDRESS 0xc007ffffffffffffUL +#else +#define DMAP_BASE_ADDRESS 0x00000000UL +#define DMAP_MAX_ADDRESS 0xbfffffffUL +#endif +#endif + +#if defined(__powerpc64__) || defined(BOOKE) +/* + * powerpc64 and Book-E will provide their own page array allocators. + * + * On AIM, this will allocate a single virtual array, with pages from the + * correct memory domains. + * On Book-E this will let us put the array in TLB1, removing the need for TLB + * thrashing. + * + * VM_MIN_KERNEL_ADDRESS is just a dummy. It will get set by the MMU driver. + */ +#define PA_MIN_ADDRESS VM_MIN_KERNEL_ADDRESS +#define PMAP_HAS_PAGE_ARRAY 1 +#endif + +#if defined(__powerpc64__) +/* + * Need a page dump array for minidump. + */ +#define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 1 +#else +/* + * No minidump with 32-bit powerpc. + */ +#define MINIDUMP_PAGE_TRACKING 0 +#define MINIDUMP_STARTUP_PAGE_TRACKING 0 +#endif + +#define PMAP_HAS_DMAP (hw_direct_map) +#define PHYS_TO_DMAP(x) ({ \ + KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ + (x) | DMAP_BASE_ADDRESS; }) +#define DMAP_TO_PHYS(x) ({ \ + KASSERT(hw_direct_map, ("Direct map not provided by PMAP")); \ + (x) &~ DMAP_BASE_ADDRESS; }) + +/* + * No non-transparent large page support in the pmap. + */ +#define PMAP_HAS_LARGEPAGES 0 + +#endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/fenv.h b/lib/libc/include/riscv64-freebsd-none/fenv.h index bb4faebfbd3bccc22e115039680fb1a1d94dad77..7946a71dc875a5d1d84c9e2e4377ff973bb2bd9b 100644 --- a/lib/libc/include/riscv64-freebsd-none/fenv.h +++ b/lib/libc/include/riscv64-freebsd-none/fenv.h @@ -36,6 +36,7 @@ #ifndef _FENV_H_ #define _FENV_H_ +#include #include #ifndef __fenv_static @@ -71,32 +72,13 @@ __BEGIN_DECLS extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) -#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double) -#if defined(__riscv_float_abi_single) -#error single precision floating point ABI not supported -#else -#error compiler did not set soft/hard float macros -#endif +#ifndef __riscv_float_abi_double +#error only double hard float ABI supported #endif -#ifndef __riscv_float_abi_soft #define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr)) #define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr)) -#endif -#ifdef __riscv_float_abi_soft -int feclearexcept(int __excepts); -int fegetexceptflag(fexcept_t *__flagp, int __excepts); -int fesetexceptflag(const fexcept_t *__flagp, int __excepts); -int feraiseexcept(int __excepts); -int fetestexcept(int __excepts); -int fegetround(void); -int fesetround(int __round); -int fegetenv(fenv_t *__envp); -int feholdexcept(fenv_t *__envp); -int fesetenv(const fenv_t *__envp); -int feupdateenv(const fenv_t *__envp); -#else __fenv_static inline int feclearexcept(int __excepts) { @@ -212,15 +194,9 @@ feupdateenv(const fenv_t *__envp) return (0); } -#endif /* !__riscv_float_abi_soft */ #if __BSD_VISIBLE -#ifdef __riscv_float_abi_soft -int feenableexcept(int __mask); -int fedisableexcept(int __mask); -int fegetexcept(void); -#else __fenv_static inline int feenableexcept(int __mask __unused) { @@ -248,7 +224,6 @@ fegetexcept(void) return (0); } -#endif /* !__riscv_float_abi_soft */ #endif /* __BSD_VISIBLE */ diff --git a/lib/libc/include/riscv64-freebsd-none/float.h b/lib/libc/include/riscv64-freebsd-none/float.h index ade407a51cf1777a65709176c1d9e08d4a70766e..38b5696e5a3e4eac3ce00f6610eea7b5ddbbac01 100644 --- a/lib/libc/include/riscv64-freebsd-none/float.h +++ b/lib/libc/include/riscv64-freebsd-none/float.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/_align.h b/lib/libc/include/riscv64-freebsd-none/machine/_align.h index 2e412076b802628bcff8679af376d8711aba608f..92180fbd20647df3ff4bf8c8e7e47a500ed229fa 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/_align.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/_align.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _MACHINE__ALIGN_H_ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/_bus.h b/lib/libc/include/riscv64-freebsd-none/machine/_bus.h deleted file mode 100644 index 8e9a287dc2ee9cf4479e64d850b296b5cf26598c..0000000000000000000000000000000000000000 --- a/lib/libc/include/riscv64-freebsd-none/machine/_bus.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE__BUS_H_ -#define _MACHINE__BUS_H_ - -/* - * Addresses (in bus space). - */ -typedef u_long bus_addr_t; -typedef u_long bus_size_t; - -/* - * Access methods for bus space. - */ -typedef u_long bus_space_handle_t; -typedef struct bus_space *bus_space_tag_t; - -#endif /* !_MACHINE__BUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/_limits.h b/lib/libc/include/riscv64-freebsd-none/machine/_limits.h index 0f4f32ce85123c31d62d7ac60c1e04913bd2ac37..d23300e5b0297b1da1ae4b1957476a129bdacacf 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/_limits.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/_limits.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE__LIMITS_H_ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/_types.h b/lib/libc/include/riscv64-freebsd-none/machine/_types.h index 1c8957ffd1a51c934eacf6a89c7e116811fcf9d4..a47d3b205e8e5aaf09a543a918185a4e5af7910a 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/_types.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/_types.h @@ -26,9 +26,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 */ #ifndef _MACHINE__TYPES_H_ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/asm.h b/lib/libc/include/riscv64-freebsd-none/machine/asm.h index 0486779337db76de20f10057fb49294b23090bf5..9805134544d87ce442997873f26d003a48ffb9c8 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/asm.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/asm.h @@ -69,4 +69,9 @@ li tmp, SSTATUS_SUM; \ csrc sstatus, tmp +#define SBI_CALL(ext, func) \ + li a7, ext; \ + li a6, func; \ + ecall + #endif /* _MACHINE_ASM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/atomic.h b/lib/libc/include/riscv64-freebsd-none/machine/atomic.h index 7fbe86c2bf928e9a21ea73dc717dd424ba1635b2..c0d1320ad44c53a9322d1fdeb84f02dee5138069 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/atomic.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/atomic.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Ruslan Bukin + * Copyright (c) 2015-2024 Ruslan Bukin * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -105,8 +105,6 @@ atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \ ATOMIC_CMPSET_ACQ_REL(8); ATOMIC_FCMPSET_ACQ_REL(8); -ATOMIC_CMPSET_ACQ_REL(16); -ATOMIC_FCMPSET_ACQ_REL(16); #define atomic_cmpset_char atomic_cmpset_8 #define atomic_cmpset_acq_char atomic_cmpset_acq_8 @@ -116,11 +114,40 @@ ATOMIC_FCMPSET_ACQ_REL(16); #define atomic_fcmpset_rel_char atomic_fcmpset_rel_8 #define atomic_cmpset_short atomic_cmpset_16 -#define atomic_cmpset_acq_short atomic_cmpset_acq_16 -#define atomic_cmpset_rel_short atomic_cmpset_rel_16 #define atomic_fcmpset_short atomic_fcmpset_16 + +ATOMIC_CMPSET_ACQ_REL(16); +ATOMIC_FCMPSET_ACQ_REL(16); + +#define atomic_load_acq_16 atomic_load_acq_16 +static __inline uint16_t +atomic_load_acq_16(const volatile uint16_t *p) +{ + uint16_t ret; + + ret = *p; + + fence(); + + return (ret); +} + +static __inline void +atomic_store_rel_16(volatile uint16_t *p, uint16_t val) +{ + + fence(); + + *p = val; +} + +#define atomic_cmpset_acq_short atomic_cmpset_acq_16 #define atomic_fcmpset_acq_short atomic_fcmpset_acq_16 +#define atomic_load_acq_short atomic_load_acq_16 + +#define atomic_cmpset_rel_short atomic_cmpset_rel_16 #define atomic_fcmpset_rel_short atomic_fcmpset_rel_16 +#define atomic_store_rel_short atomic_store_rel_16 static __inline void atomic_add_32(volatile uint32_t *p, uint32_t val) @@ -239,6 +266,34 @@ atomic_readandclear_32(volatile uint32_t *p) return (ret); } +static __inline int +atomic_testandclear_32(volatile uint32_t *p, u_int val) +{ + uint32_t mask, old; + + mask = 1u << (val & 31); + __asm __volatile("amoand.w %0, %2, %1" + : "=&r" (old), "+A" (*p) + : "r" (~mask) + : "memory"); + + return ((old & mask) != 0); +} + +static __inline int +atomic_testandset_32(volatile uint32_t *p, u_int val) +{ + uint32_t mask, old; + + mask = 1u << (val & 31); + __asm __volatile("amoor.w %0, %2, %1" + : "=&r" (old), "+A" (*p) + : "r" (mask) + : "memory"); + + return ((old & mask) != 0); +} + #define atomic_add_int atomic_add_32 #define atomic_clear_int atomic_clear_32 #define atomic_cmpset_int atomic_cmpset_32 @@ -257,7 +312,7 @@ ATOMIC_CMPSET_ACQ_REL(32); ATOMIC_FCMPSET_ACQ_REL(32); static __inline uint32_t -atomic_load_acq_32(volatile uint32_t *p) +atomic_load_acq_32(const volatile uint32_t *p) { uint32_t ret; @@ -410,6 +465,48 @@ atomic_readandclear_64(volatile uint64_t *p) return (ret); } +static __inline int +atomic_testandclear_64(volatile uint64_t *p, u_int val) +{ + uint64_t mask, old; + + mask = 1ul << (val & 63); + __asm __volatile("amoand.d %0, %2, %1" + : "=&r" (old), "+A" (*p) + : "r" (~mask) + : "memory"); + + return ((old & mask) != 0); +} + +static __inline int +atomic_testandset_64(volatile uint64_t *p, u_int val) +{ + uint64_t mask, old; + + mask = 1ul << (val & 63); + __asm __volatile("amoor.d %0, %2, %1" + : "=&r" (old), "+A" (*p) + : "r" (mask) + : "memory"); + + return ((old & mask) != 0); +} + +static __inline int +atomic_testandset_acq_64(volatile uint64_t *p, u_int val) +{ + uint64_t mask, old; + + mask = 1ul << (val & 63); + __asm __volatile("amoor.d.aq %0, %2, %1" + : "=&r" (old), "+A" (*p) + : "r" (mask) + : "memory"); + + return ((old & mask) != 0); +} + static __inline uint32_t atomic_swap_32(volatile uint32_t *p, uint32_t val) { @@ -447,6 +544,9 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val) #define atomic_set_long atomic_set_64 #define atomic_subtract_long atomic_subtract_64 #define atomic_swap_long atomic_swap_64 +#define atomic_testandclear_long atomic_testandclear_64 +#define atomic_testandset_long atomic_testandset_64 +#define atomic_testandset_acq_long atomic_testandset_acq_64 #define atomic_add_ptr atomic_add_64 #define atomic_clear_ptr atomic_clear_64 @@ -457,6 +557,8 @@ atomic_swap_64(volatile uint64_t *p, uint64_t val) #define atomic_set_ptr atomic_set_64 #define atomic_subtract_ptr atomic_subtract_64 #define atomic_swap_ptr atomic_swap_64 +#define atomic_testandclear_ptr atomic_testandclear_64 +#define atomic_testandset_ptr atomic_testandset_64 ATOMIC_ACQ_REL(set, 64) ATOMIC_ACQ_REL(clear, 64) @@ -467,7 +569,7 @@ ATOMIC_CMPSET_ACQ_REL(64); ATOMIC_FCMPSET_ACQ_REL(64); static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) +atomic_load_acq_64(const volatile uint64_t *p) { uint64_t ret; @@ -554,4 +656,7 @@ atomic_thread_fence_seq_cst(void) #include +#define atomic_set_short atomic_set_16 +#define atomic_clear_short atomic_clear_16 + #endif /* _MACHINE_ATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/bus_dma.h b/lib/libc/include/riscv64-freebsd-none/machine/bus_dma.h index b54730aa0ae84e50e5f6aa7f7c5f9c6626ac5814..05460bd4e685df15e69ace5871aaf410d86a9ffe 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/bus_dma.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/bus_dma.h @@ -49,7 +49,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, /* * Free a piece of memory and it's allociated dmamap, that was allocated - * via bus_dmamem_alloc. Make the same choice for free/contigfree. + * via bus_dmamem_alloc. */ static inline void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) diff --git a/lib/libc/include/riscv64-freebsd-none/machine/bus_dma_impl.h b/lib/libc/include/riscv64-freebsd-none/machine/bus_dma_impl.h index bda4ea6b2c6f040f89cb2c93629e5dc5acd4434d..cbded0b9660e37b2572330f300a6f58570e65bc0 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/bus_dma_impl.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/bus_dma_impl.h @@ -31,27 +31,22 @@ struct bus_dma_tag_common { struct bus_dma_impl *impl; - struct bus_dma_tag_common *parent; bus_size_t alignment; bus_addr_t boundary; bus_addr_t lowaddr; bus_addr_t highaddr; - bus_dma_filter_t *filter; - void *filterarg; bus_size_t maxsize; u_int nsegments; bus_size_t maxsegsz; int flags; bus_dma_lock_t *lockfunc; void *lockfuncarg; - int ref_count; }; struct bus_dma_impl { int (*tag_create)(bus_dma_tag_t parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, - bus_addr_t highaddr, bus_dma_filter_t *filter, - void *filterarg, bus_size_t maxsize, int nsegments, + bus_addr_t highaddr, bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat); int (*tag_destroy)(bus_dma_tag_t dmat); @@ -79,13 +74,11 @@ struct bus_dma_impl { bus_dmasync_op_t op); }; -int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr); int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, - bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, - int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, - void *lockfuncarg, size_t sz, void **dmat); + bus_size_t maxsize, int nsegments, bus_size_t maxsegsz, int flags, + bus_dma_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat); extern struct bus_dma_impl bus_dma_bounce_impl; diff --git a/lib/libc/include/riscv64-freebsd-none/machine/cbo.h b/lib/libc/include/riscv64-freebsd-none/machine/cbo.h new file mode 100644 index 0000000000000000000000000000000000000000..ce8baf79d9ae486439cdded9d4d91e76a0aa92c6 --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/cbo.h @@ -0,0 +1,33 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Ruslan Bukin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RISCV_CBO_H_ +#define _RISCV_CBO_H_ + +void cbo_zicbom_setup_cache(int cbom_block_size); + +#endif /* _RISCV_CBO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/cpu.h b/lib/libc/include/riscv64-freebsd-none/machine/cpu.h index 12f823d7ee3c13b3fe0be2121452238d0ecd989a..1d840b451f875f8b72ad6072cac5c06990ca028f 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/cpu.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/cpu.h @@ -35,9 +35,11 @@ #ifndef _MACHINE_CPU_H_ #define _MACHINE_CPU_H_ +#ifndef LOCORE #include #include #include +#endif #define TRAPF_PC(tfp) ((tfp)->tf_sepc) #define TRAPF_USERMODE(tfp) (((tfp)->tf_sstatus & SSTATUS_SPP) == 0) @@ -47,8 +49,6 @@ #define cpu_spinwait() /* nothing */ #define cpu_lock_delay() DELAY(1) -#ifdef _KERNEL - /* * Core manufacturer IDs, as reported by the mvendorid CSR. */ @@ -80,6 +80,7 @@ /* SiFive marchid values */ #define MARCHID_SIFIVE_U7 MARCHID_COMMERCIAL(7) +#define MARCHID_SIFIVE_P5 MARCHID_COMMERCIAL(8) /* * MMU virtual-addressing modes. Support for each level implies the previous, @@ -89,6 +90,9 @@ #define MMU_SV48 0x2 /* 4-level paging */ #define MMU_SV57 0x4 /* 5-level paging */ +#ifdef _KERNEL +#ifndef LOCORE + extern char btext[]; extern char etext[]; @@ -105,6 +109,7 @@ get_cyclecount(void) return (rdcycle()); } -#endif +#endif /* !LOCORE */ +#endif /* _KERNEL */ #endif /* !_MACHINE_CPU_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/cpufunc.h b/lib/libc/include/riscv64-freebsd-none/machine/cpufunc.h index 23af7f81fb9e3e8847f49318c11b32f9352236c4..df60a9a0f88e2fbceb01068226bfc2f78bf8bf41 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/cpufunc.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/cpufunc.h @@ -44,6 +44,8 @@ breakpoint(void) #ifdef _KERNEL +#include + #include static __inline register_t @@ -102,21 +104,62 @@ sfence_vma_page(uintptr_t addr) __asm __volatile("sfence.vma %0" :: "r" (addr) : "memory"); } +static __inline void +sfence_vma_asid(uint64_t asid) +{ + + __asm __volatile("sfence.vma x0, %0" :: "r" (asid) : "memory"); +} + +static __inline void +sfence_vma_asid_page(uint64_t asid, uintptr_t addr) +{ + + __asm __volatile("sfence.vma %0, %1" :: "r" (addr), "r" (asid) + : "memory"); +} + #define rdcycle() csr_read64(cycle) #define rdtime() csr_read64(time) #define rdinstret() csr_read64(instret) #define rdhpmcounter(n) csr_read64(hpmcounter##n) +/* Cache hooks. */ + extern int64_t dcache_line_size; -extern int64_t icache_line_size; -#define cpu_dcache_wbinv_range(a, s) -#define cpu_dcache_inv_range(a, s) -#define cpu_dcache_wb_range(a, s) +typedef void (*cache_op_t)(vm_offset_t start, vm_size_t size); -#define cpu_idcache_wbinv_range(a, s) -#define cpu_icache_sync_range(a, s) -#define cpu_icache_sync_range_checked(a, s) +struct riscv_cache_ops { + cache_op_t dcache_wbinv_range; + cache_op_t dcache_inv_range; + cache_op_t dcache_wb_range; +}; + +extern struct riscv_cache_ops cache_ops; + +static __inline void +cpu_dcache_wbinv_range(vm_offset_t addr, vm_size_t size) +{ + if (cache_ops.dcache_wbinv_range != NULL) + cache_ops.dcache_wbinv_range(addr, size); +} + +static __inline void +cpu_dcache_inv_range(vm_offset_t addr, vm_size_t size) +{ + if (cache_ops.dcache_inv_range != NULL) + cache_ops.dcache_inv_range(addr, size); +} + +static __inline void +cpu_dcache_wb_range(vm_offset_t addr, vm_size_t size) +{ + if (cache_ops.dcache_wb_range != NULL) + cache_ops.dcache_wb_range(addr, size); +} + +void riscv_cache_install_hooks(struct riscv_cache_ops *, u_int); #define cpufunc_nullop() riscv_nullop() diff --git a/lib/libc/include/riscv64-freebsd-none/machine/elf.h b/lib/libc/include/riscv64-freebsd-none/machine/elf.h index aab0b1713afb06b3fc80e650435a8b250cb4182f..9533750a8eeb475d5db8b925c797198677ace2f0 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/elf.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/elf.h @@ -80,7 +80,9 @@ __ElfType(Auxinfo); #define HWCAP_ISA_F HWCAP_ISA_BIT('f') #define HWCAP_ISA_D HWCAP_ISA_BIT('d') #define HWCAP_ISA_C HWCAP_ISA_BIT('c') +#define HWCAP_ISA_H HWCAP_ISA_BIT('h') #define HWCAP_ISA_G \ (HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D) +#define HWCAP_ISA_B HWCAP_ISA_BIT('b') #endif /* !_MACHINE_ELF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/endian.h b/lib/libc/include/riscv64-freebsd-none/machine/endian.h index 69d16e3fc53c4c197619b48b82ba407768fe29a4..6b21c3cb51ced2247589a9c7d87c36bfd3e6e48b 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/endian.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/endian.h @@ -24,8 +24,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)endian.h 8.1 (Berkeley) 6/10/93 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $ */ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/float.h b/lib/libc/include/riscv64-freebsd-none/machine/float.h index ade407a51cf1777a65709176c1d9e08d4a70766e..38b5696e5a3e4eac3ce00f6610eea7b5ddbbac01 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/float.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/float.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 */ #ifndef _MACHINE_FLOAT_H_ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/fpe.h b/lib/libc/include/riscv64-freebsd-none/machine/fpe.h index 0b62e481e316eef36ad732b67cd957f697b9b665..7cdbca94990ec9df1a68b404f7fca414f15b1466 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/fpe.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/fpe.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Ruslan Bukin + * Copyright (c) 2016-2024 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of @@ -34,4 +34,14 @@ void fpe_state_save(struct thread *td); void fpe_state_clear(void); +struct fpreg *fpu_save_area_alloc(void); +void fpu_save_area_free(struct fpreg *fsa); +void fpu_save_area_reset(struct fpreg *fsa); + +void fpe_enable(void); +void fpe_disable(void); + +void fpe_store(struct fpreg *state); +void fpe_restore(struct fpreg *state); + #endif /* !_MACHINE_FPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/frame.h b/lib/libc/include/riscv64-freebsd-none/machine/frame.h index c05590e2dee54367a657ff917e1f282708baa977..58aec0107c440376dc619d7ec268432d25830a69 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/frame.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/frame.h @@ -57,6 +57,10 @@ struct trapframe { uint64_t tf_scause; }; +#ifdef _KERNEL +#define TF_SIZE (roundup2(sizeof(struct trapframe), STACKALIGNBYTES + 1)) +#endif + /* * Signal frame. Pushed onto user stack before calling sigcode. */ @@ -65,6 +69,16 @@ struct sigframe { ucontext_t sf_uc; /* actual saved ucontext */ }; +#ifdef _KERNEL +/* + * Kernel frame. Reserved near the top of kernel stacks for saving kernel + * state while in userspace. + */ +struct kernframe { + register_t kf_tp; +}; +#endif + #endif /* !LOCORE */ /* Definitions for syscalls */ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/ifunc.h b/lib/libc/include/riscv64-freebsd-none/machine/ifunc.h new file mode 100644 index 0000000000000000000000000000000000000000..5ef7dfe31d9b34d2647114a8f98c5c2ef72cd0db --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/ifunc.h @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2015-2018 The FreeBSD Foundation + * Copyright (c) 2024 Jessica Clarke + * + * Part of this software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __RISCV_IFUNC_H +#define __RISCV_IFUNC_H + +#define DEFINE_IFUNC(qual, ret_type, name, args) \ + static ret_type (*name##_resolver(void))args __used; \ + qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ + static ret_type (*name##_resolver(void))args + +#define DEFINE_UIFUNC(qual, ret_type, name, args) \ + static ret_type (*name##_resolver(unsigned long, unsigned long, \ + unsigned long, unsigned long, unsigned long, unsigned long, \ + unsigned long, unsigned long))args __used; \ + qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \ + static ret_type (*name##_resolver(unsigned long elf_hwcap __unused, \ + unsigned long _arg2 __unused, unsigned long _arg3 __unused, \ + unsigned long _arg4 __unused, unsigned long _arg5 __unused, \ + unsigned long _arg6 __unused, unsigned long _arg7 __unused, \ + unsigned long _arg8 __unused))args + +#endif \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/in_cksum.h b/lib/libc/include/riscv64-freebsd-none/machine/in_cksum.h index b6519929ca3ce4cd461585ac3be90ceb0cfd80d4..ad5bd81eae39ec55236808fecb64cc6d4ba5fb10 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/in_cksum.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/in_cksum.h @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp */ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/intr.h b/lib/libc/include/riscv64-freebsd-none/machine/intr.h index f5e919f401c96eb7dc3493f2578a6a5280f05ea4..6a3a88998bac1ec183088699accc1d6d261e1403 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/intr.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/intr.h @@ -39,8 +39,7 @@ #define NIRQ 1024 #endif -#include - +#ifndef LOCORE enum { IRQ_SOFTWARE_USER, IRQ_SOFTWARE_SUPERVISOR, @@ -55,5 +54,9 @@ enum { IRQ_EXTERNAL_HYPERVISOR, IRQ_EXTERNAL_MACHINE, }; +#endif /* !LOCORE */ + +#define INTR_ROOT_IRQ 0 +#define INTR_ROOT_COUNT 1 #endif /* !_MACHINE_INTR_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/machdep.h b/lib/libc/include/riscv64-freebsd-none/machine/machdep.h index 9830497cfb4f72ccc7a572d8f4e5341e4aea3d48..d8876c847bed151a8ee12705aaa4eb67461c230b 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/machdep.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/machdep.h @@ -36,10 +36,8 @@ #define _MACHINE_MACHDEP_H_ struct riscv_bootparams { - vm_offset_t kern_l1pt; /* Kernel L1 base */ vm_offset_t kern_phys; /* Kernel base (physical) addr */ vm_offset_t kern_stack; - vm_offset_t dtbp_virt; /* Device tree blob virtual addr */ vm_offset_t dtbp_phys; /* Device tree blob physical addr */ vm_offset_t modulep; /* loader(8) metadata */ }; diff --git a/lib/libc/include/riscv64-freebsd-none/machine/md_var.h b/lib/libc/include/riscv64-freebsd-none/machine/md_var.h index 3022f4e02f7a4a5317eac730cc73026475ac7abe..53b2cf27f7924d3fff7242f94b665b56d84f8fd7 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/md_var.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/md_var.h @@ -42,8 +42,10 @@ extern register_t mimpid; extern u_int mmu_caps; /* Supervisor-mode extension support */ +extern bool has_hyp; extern bool has_sstc; extern bool has_sscofpmf; +extern bool has_svpbmt; struct dumperinfo; struct minidumpstate; diff --git a/lib/libc/include/riscv64-freebsd-none/machine/metadata.h b/lib/libc/include/riscv64-freebsd-none/machine/metadata.h index 08bc8720378c886e2609408a06a7b55854892ece..3e583bb2dc875e148f433298c17ba50ecb579628 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/metadata.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/metadata.h @@ -30,11 +30,18 @@ #define MODINFOMD_DTBP 0x1001 #define MODINFOMD_EFI_MAP 0x1002 +#define MODINFOMD_EFI_FB 0x1003 +#define MODINFOMD_BOOT_HARTID 0x1004 +/* + * This is not the same as the UEFI standard EFI_MEMORY_ATTRIBUTES_TABLE, though + * memory_size / descritpr_size entries of EFI_MEMORY_DESCRIPTORS follow this table + * starting at a 16-byte alignment. + */ struct efi_map_header { - size_t memory_size; - size_t descriptor_size; - uint32_t descriptor_version; + size_t memory_size; /* Numnber of bytes that follow */ + size_t descriptor_size; /* Size of each EFI_MEMORY_DESCRIPTOR */ + uint32_t descriptor_version; /* Currently '1' */ }; /* diff --git a/lib/libc/include/riscv64-freebsd-none/machine/param.h b/lib/libc/include/riscv64-freebsd-none/machine/param.h index d8f05877155dc19429b5373a92fefdbbd925def1..ca250fee4ccbdcfee9bb8769b29e8b04845e558a 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/param.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/param.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _MACHINE_PARAM_H_ @@ -41,8 +39,6 @@ #define STACKALIGNBYTES (16 - 1) #define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES) -#define __PCI_REROUTE_INTERRUPT - #ifndef MACHINE #define MACHINE "riscv" #endif @@ -95,15 +91,7 @@ /* * Mach derived conversion macros */ -#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK) -#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK) - -#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) - #define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) #define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) -#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) - #endif /* !_MACHINE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/pcpu.h b/lib/libc/include/riscv64-freebsd-none/machine/pcpu.h index adf445fc2be2b88df99070ab2b67c9967e32bbf7..03f8fa47f8cec16bdea84b48446bdad1682c99ae 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/pcpu.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/pcpu.h @@ -46,7 +46,8 @@ struct pmap *pc_curpmap; /* Currently active pmap */ \ uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \ uint32_t pc_hart; /* Hart ID */ \ - char __pad[56] /* Pad to factor of PAGE_SIZE */ + uint64_t pc_clock; \ + char __pad[48] /* Pad to factor of PAGE_SIZE */ #ifdef _KERNEL diff --git a/lib/libc/include/riscv64-freebsd-none/machine/pmap.h b/lib/libc/include/riscv64-freebsd-none/machine/pmap.h index ee06de490d62b80847b185d23342ad50119db7d3..70dc01e969775698f95be314b9a402a9078c30b9 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/pmap.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/pmap.h @@ -67,6 +67,12 @@ struct md_page { vm_memattr_t pv_memattr; }; +enum pmap_stage { + PM_INVALID, + PM_STAGE1, + PM_STAGE2, +}; + struct pmap { struct mtx pm_mtx; struct pmap_statistics pm_stats; /* pmap statictics */ @@ -76,6 +82,7 @@ struct pmap { TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ struct vm_radix pm_root; + enum pmap_stage pm_stage; }; typedef struct pmap *pmap_t; @@ -126,7 +133,7 @@ struct thread; void pmap_activate_boot(pmap_t); void pmap_activate_sw(struct thread *); -void pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t); +void pmap_bootstrap(vm_paddr_t, vm_size_t); int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode); void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode); void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t); @@ -134,6 +141,7 @@ vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kremove(vm_offset_t); void pmap_kremove_device(vm_offset_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma); +int pmap_pinit_stage(pmap_t, enum pmap_stage); bool pmap_page_is_mapped(vm_page_t m); bool pmap_ps_enabled(pmap_t); diff --git a/lib/libc/include/riscv64-freebsd-none/machine/proc.h b/lib/libc/include/riscv64-freebsd-none/machine/proc.h index cb453c4b43a6994189e827418c3c51fba404c20d..b6745a76b332d848a85c4bffddac40761b1914c7 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/proc.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/proc.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 */ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/pte.h b/lib/libc/include/riscv64-freebsd-none/machine/pte.h index 5a905bedeee310571c9fbb5f7d3831ae763a7c42..de6de5213dcbf8e3281b2f8c561aefcbe94a00a7 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/pte.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/pte.h @@ -83,6 +83,51 @@ typedef uint64_t pn_t; /* page number */ #define PTE_PROMOTE (PTE_V | PTE_RWX | PTE_D | PTE_G | PTE_U | \ PTE_SW_MANAGED | PTE_SW_WIRED) +/* + * Svpbmt Memory Attribute (MA) bits [62:61]. + * + * +------+-------+------------------------------------------------------------+ + * | Mode | Value | Requested Memory Attributes | + * +------+-------+------------------------------------------------------------+ + * | PMA | 00 | None, inherited from Physical Memory Attributes (firmware) | + * | NC | 01 | Non-cacheable, idempotent, weakly-ordered (RVWMO), | + * | | | main memory | + * | IO | 10 | Non-cacheable, non-idempotent, strongly-ordered, I/O | + * | -- | 11 | Reserved | + * +------+-------+------------------------------------------------------------+ + */ +#define PTE_MA_SHIFT 61 +#define PTE_MA_MASK (0x3ul << PTE_MA_SHIFT) +#define PTE_MA_NONE (0ul) +#define PTE_MA_NC (1ul << PTE_MA_SHIFT) +#define PTE_MA_IO (2ul << PTE_MA_SHIFT) + +/* + * T-HEAD Custom Memory Attribute (MA) bits [63:59]. + * + * bit 59: Trustable (relating to TEE) + * bit 60: Shareable (among CPUs, not configurable) + * bit 61: Bufferable (writes to device memory) + * bit 62: Cacheable + * bit 63: Memory Ordering (1 = strongly ordered (device), 0 = default) + * + * +------+-------+------------------------------------------------------------+ + * | Mode | Value | Requested Memory Attributes | + * +------+-------+------------------------------------------------------------+ + * | NC | 00110 | Weakly-ordered, non-cacheable, bufferable, shareable, | + * | | | non-trustable | + * | PMA | 01110 | Weakly-ordered, cacheable, bufferable, shareable, | + * | | | non-trustable | + * | IO | 10010 | Strongly-ordered, non-cacheable, non-bufferable, | + * | | | shareable, non-trustable | + * +------+-------+------------------------------------------------------------+ + */ +#define PTE_THEAD_MA_SHIFT 59 +#define PTE_THEAD_MA_MASK (0x1ful << PTE_THEAD_MA_SHIFT) +#define PTE_THEAD_MA_NC (0x6ul << PTE_THEAD_MA_SHIFT) +#define PTE_THEAD_MA_NONE (0xeul << PTE_THEAD_MA_SHIFT) +#define PTE_THEAD_MA_IO (0x12ul << PTE_THEAD_MA_SHIFT) + /* Bits 63 - 54 are reserved for future use. */ #define PTE_HI_MASK 0xFFC0000000000000ULL @@ -92,6 +137,4 @@ typedef uint64_t pn_t; /* page number */ #define PTE_PPN3_S 37 #define PTE_SIZE 8 -#endif /* !_MACHINE_PTE_H_ */ - -/* End of pte.h */ \ No newline at end of file +#endif /* !_MACHINE_PTE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/resource.h b/lib/libc/include/riscv64-freebsd-none/machine/resource.h index 8b40a35d963536216063bcdff8e7621ce01d6e8e..8df4f2f2cd36d6e1b0bac010c3297ee9cdec47d2 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/resource.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/resource.h @@ -40,8 +40,6 @@ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ #define SYS_RES_GPIO 5 /* general purpose i/o */ -#ifdef NEW_PCIB #define PCI_RES_BUS 6 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/riscvreg.h b/lib/libc/include/riscv64-freebsd-none/machine/riscvreg.h index e65c349e4ea0ed04d4721be5034eed792342ccba..159b8d531f562d1ade859875f42b69e33d811b7c 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/riscvreg.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/riscvreg.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015-2017 Ruslan Bukin + * Copyright (c) 2015-2024 Ruslan Bukin * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -47,9 +47,15 @@ #define SCAUSE_STORE_ACCESS_FAULT 7 #define SCAUSE_ECALL_USER 8 #define SCAUSE_ECALL_SUPERVISOR 9 +#define SCAUSE_VIRTUAL_SUPERVISOR_ECALL 10 +#define SCAUSE_MACHINE_ECALL 11 #define SCAUSE_INST_PAGE_FAULT 12 #define SCAUSE_LOAD_PAGE_FAULT 13 #define SCAUSE_STORE_PAGE_FAULT 15 +#define SCAUSE_FETCH_GUEST_PAGE_FAULT 20 +#define SCAUSE_LOAD_GUEST_PAGE_FAULT 21 +#define SCAUSE_VIRTUAL_INSTRUCTION 22 +#define SCAUSE_STORE_GUEST_PAGE_FAULT 23 #define SSTATUS_UIE (1 << 0) #define SSTATUS_SIE (1 << 1) @@ -116,6 +122,17 @@ #define MSTATUS_PRV_H 2 /* hypervisor */ #define MSTATUS_PRV_M 3 /* machine */ +#define HSTATUS_VSBE (1 << 5) +#define HSTATUS_GVA (1 << 6) +#define HSTATUS_SPV (1 << 7) +#define HSTATUS_SPVP (1 << 8) +#define HSTATUS_HU (1 << 9) +#define HSTATUS_VGEIN_S 12 +#define HSTATUS_VGEIN_M (0xf << HSTATUS_VGEIN_S) +#define HSTATUS_VTVM (1 << 20) +#define HSTATUS_VTW (1 << 21) +#define HSTATUS_VTSR (1 << 22) + #define MIE_USIE (1 << 0) #define MIE_SSIE (1 << 1) #define MIE_HSIE (1 << 2) @@ -143,10 +160,31 @@ #define MIP_SEIP (1 << 9) +#define HVIP_VSSIP (1 << 2) +#define HVIP_VSTIP (1 << 6) +#define HVIP_VSEIP (1 << 10) + +#define HIE_VSSIE (1 << 2) +#define HIE_VSTIE (1 << 6) +#define HIE_VSEIE (1 << 10) +#define HIE_SGEIE (1 << 12) + /* Note: sip register has no SIP_STIP bit in Spike simulator */ #define SIP_SSIP (1 << 1) #define SIP_STIP (1 << 5) +#define HENVCFG_STCE (1UL << 63) +#define HENVCFG_PBMTE (1UL << 62) +#define HENVCFG_CBZE (1UL << 7) +#define HENVCFG_CBCFE (1UL << 6) +#define HENVCFG_CBIE_S 4 +#define HENVCFG_CBIE_M (0x3 << HENVCFG_CBIE_S) +#define HENVCFG_FIOM (1UL << 0) + +#define HCOUNTEREN_CY (1UL << 0) /* Cycle */ +#define HCOUNTEREN_TM (1UL << 1) /* Time */ +#define HCOUNTEREN_IR (1UL << 2) /* Instret */ + #define SATP_PPN_S 0 #define SATP_PPN_M (0xfffffffffffUL << SATP_PPN_S) #define SATP_ASID_S 44 @@ -189,13 +227,14 @@ (__builtin_constant_p(val) && ((u_long)(val) < 32)) #define csr_swap(csr, val) \ -({ if (CSR_ZIMM(val)) \ +({ u_long ret; \ + if (CSR_ZIMM(val)) \ __asm __volatile("csrrwi %0, " #csr ", %1" \ - : "=r" (val) : "i" (val)); \ + : "=r" (ret) : "i" (val)); \ else \ __asm __volatile("csrrw %0, " #csr ", %1" \ - : "=r" (val) : "r" (val)); \ - val; \ + : "=r" (ret) : "r" (val)); \ + ret; \ }) #define csr_write(csr, val) \ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/runq.h b/lib/libc/include/riscv64-freebsd-none/machine/runq.h deleted file mode 100644 index 392bf093b433251ba04a632d0448d3e4d8433e04..0000000000000000000000000000000000000000 --- a/lib/libc/include/riscv64-freebsd-none/machine/runq.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (1) /* Number of priority status words. */ -#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (ffsl(word) - 1) - -/* - * Type of run queue status word. - */ -typedef unsigned long rqb_word_t; - -#endif \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/sbi.h b/lib/libc/include/riscv64-freebsd-none/machine/sbi.h index 2cf51a83413d79aa4cc7891869e79a24ae59123f..c982de0c0d261b5de0a2b4aa2b49c9d50b5c486f 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/sbi.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/sbi.h @@ -49,6 +49,12 @@ #define SBI_IMPL_ID_KVM 3 #define SBI_IMPL_ID_RUSTSBI 4 #define SBI_IMPL_ID_DIOSIX 5 +#define SBI_IMPL_ID_COFFER 6 +#define SBI_IMPL_ID_XEN_PROJECT 7 +#define SBI_IMPL_ID_POLARFIRE_HSS 8 +#define SBI_IMPL_ID_COREBOOT 9 +#define SBI_IMPL_ID_OREBOOT 10 +#define SBI_IMPL_ID_BHYVE 11 /* SBI Error Codes */ #define SBI_SUCCESS 0 @@ -117,6 +123,8 @@ #define SBI_REMOTE_SFENCE_VMA_ASID 7 #define SBI_SHUTDOWN 8 +#ifndef LOCORE + #define SBI_CALL0(e, f) SBI_CALL5(e, f, 0, 0, 0, 0, 0) #define SBI_CALL1(e, f, p1) SBI_CALL5(e, f, p1, 0, 0, 0, 0) #define SBI_CALL2(e, f, p1, p2) SBI_CALL5(e, f, p1, p2, 0, 0, 0) @@ -236,4 +244,5 @@ sbi_console_getchar(void) void sbi_print_version(void); void sbi_init(void); +#endif /* !LOCORE */ #endif /* !_MACHINE_SBI_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/sdt_machdep.h b/lib/libc/include/riscv64-freebsd-none/machine/sdt_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..d64ccbd61edf512500dccfca87c1a0bfee2f01ed --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/sdt_machdep.h @@ -0,0 +1,12 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Mark Johnston + */ + +#ifndef _SYS_SDT_MACHDEP_H_ +#define _SYS_SDT_MACHDEP_H_ + +#define _SDT_ASM_PATCH_INSTR ".option push; .option norvc; nop; .option pop" + +#endif /* _SYS_SDT_MACHDEP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/signal.h b/lib/libc/include/riscv64-freebsd-none/machine/signal.h index d1935504bacb74200206de5e007bc05a67c78002..c1d7d8ff82dd98688cc5963010670be7cbee9f57 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/signal.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/signal.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 * from: FreeBSD: src/sys/sparc64/include/signal.h,v 1.6 2001/09/30 18:52:17 */ diff --git a/lib/libc/include/riscv64-freebsd-none/machine/thead.h b/lib/libc/include/riscv64-freebsd-none/machine/thead.h new file mode 100644 index 0000000000000000000000000000000000000000..8d3d50bbe2f4c98d0223ac55a721886a0f71fa41 --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/thead.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 The FreeBSD Foundation + * + * This software was developed by Mitchell Horne under + * sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _RISCV_THEAD_H_ +#define _RISCV_THEAD_H_ + +extern bool has_errata_thead_pbmt; + +void thead_setup_cache(void); + +#endif /* _RISCV_THEAD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/vm.h b/lib/libc/include/riscv64-freebsd-none/machine/vm.h index 13ffd9a8fc929b9fa64d9f82f22f3c66da14b4d9..b28fa7d95106937f64d3defee551d2319f4df48b 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/vm.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/vm.h @@ -28,10 +28,14 @@ #define _MACHINE_VM_H_ /* Memory attribute configuration. */ -#define VM_MEMATTR_DEVICE 0 +#define VM_MEMATTR_PMA 0 #define VM_MEMATTR_UNCACHEABLE 1 -#define VM_MEMATTR_WRITE_BACK 2 +#define VM_MEMATTR_DEVICE 2 -#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK +#define VM_MEMATTR_WRITE_BACK VM_MEMATTR_PMA +#define VM_MEMATTR_DEFAULT VM_MEMATTR_PMA + +#define VM_MEMATTR_LAST VM_MEMATTR_DEVICE +#define VM_MEMATTR_TOTAL (VM_MEMATTR_LAST + 1) #endif /* !_MACHINE_VM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/vmm.h b/lib/libc/include/riscv64-freebsd-none/machine/vmm.h new file mode 100644 index 0000000000000000000000000000000000000000..d9a27a2f850d198ed8c0548826205a1e288e3810 --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/vmm.h @@ -0,0 +1,299 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2015 Mihai Carabas + * Copyright (c) 2024 Ruslan Bukin + * + * This software was developed by the University of Cambridge Computer + * Laboratory (Department of Computer Science and Technology) under Innovate + * UK project 105694, "Digital Security by Design (DSbD) Technology Platform + * Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_H_ +#define _VMM_H_ + +#include +#include +#include +#include + +#include "pte.h" +#include "pmap.h" + +struct vcpu; + +enum vm_suspend_how { + VM_SUSPEND_NONE, + VM_SUSPEND_RESET, + VM_SUSPEND_POWEROFF, + VM_SUSPEND_HALT, + VM_SUSPEND_DESTROY, + VM_SUSPEND_LAST +}; + +/* + * Identifiers for architecturally defined registers. + */ +enum vm_reg_name { + VM_REG_GUEST_ZERO = 0, + VM_REG_GUEST_RA, + VM_REG_GUEST_SP, + VM_REG_GUEST_GP, + VM_REG_GUEST_TP, + VM_REG_GUEST_T0, + VM_REG_GUEST_T1, + VM_REG_GUEST_T2, + VM_REG_GUEST_S0, + VM_REG_GUEST_S1, + VM_REG_GUEST_A0, + VM_REG_GUEST_A1, + VM_REG_GUEST_A2, + VM_REG_GUEST_A3, + VM_REG_GUEST_A4, + VM_REG_GUEST_A5, + VM_REG_GUEST_A6, + VM_REG_GUEST_A7, + VM_REG_GUEST_S2, + VM_REG_GUEST_S3, + VM_REG_GUEST_S4, + VM_REG_GUEST_S5, + VM_REG_GUEST_S6, + VM_REG_GUEST_S7, + VM_REG_GUEST_S8, + VM_REG_GUEST_S9, + VM_REG_GUEST_S10, + VM_REG_GUEST_S11, + VM_REG_GUEST_T3, + VM_REG_GUEST_T4, + VM_REG_GUEST_T5, + VM_REG_GUEST_T6, + VM_REG_GUEST_SEPC, + VM_REG_LAST +}; + +#define VM_INTINFO_VECTOR(info) ((info) & 0xff) +#define VM_INTINFO_DEL_ERRCODE 0x800 +#define VM_INTINFO_RSVD 0x7ffff000 +#define VM_INTINFO_VALID 0x80000000 +#define VM_INTINFO_TYPE 0x700 +#define VM_INTINFO_HWINTR (0 << 8) +#define VM_INTINFO_NMI (2 << 8) +#define VM_INTINFO_HWEXCEPTION (3 << 8) +#define VM_INTINFO_SWINTR (4 << 8) + +#define VM_MAX_NAMELEN 32 +#define VM_MAX_SUFFIXLEN 15 + +#ifdef _KERNEL + +struct vm; +struct vm_exception; +struct vm_exit; +struct vm_run; +struct vm_object; +struct vm_guest_paging; +struct vm_aplic_descr; +struct pmap; + +struct vm_eventinfo { + void *rptr; /* rendezvous cookie */ + int *sptr; /* suspend cookie */ + int *iptr; /* reqidle cookie */ +}; + +int vm_create(const char *name, struct vm **retvm); +struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid); +void vm_disable_vcpu_creation(struct vm *vm); +void vm_slock_vcpus(struct vm *vm); +void vm_unlock_vcpus(struct vm *vm); +void vm_destroy(struct vm *vm); +int vm_reinit(struct vm *vm); +const char *vm_name(struct vm *vm); + +uint16_t vm_get_maxcpus(struct vm *vm); +void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, + uint16_t *threads, uint16_t *maxcpus); +int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, + uint16_t threads, uint16_t maxcpus); +int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); +int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); +int vm_run(struct vcpu *vcpu); +int vm_suspend(struct vm *vm, enum vm_suspend_how how); +void* vm_get_cookie(struct vm *vm); +int vcpu_vcpuid(struct vcpu *vcpu); +void *vcpu_get_cookie(struct vcpu *vcpu); +struct vm *vcpu_vm(struct vcpu *vcpu); +struct vcpu *vm_vcpu(struct vm *vm, int cpu); +int vm_get_capability(struct vcpu *vcpu, int type, int *val); +int vm_set_capability(struct vcpu *vcpu, int type, int val); +int vm_activate_cpu(struct vcpu *vcpu); +int vm_suspend_cpu(struct vm *vm, struct vcpu *vcpu); +int vm_resume_cpu(struct vm *vm, struct vcpu *vcpu); +int vm_inject_exception(struct vcpu *vcpu, uint64_t scause); +int vm_attach_aplic(struct vm *vm, struct vm_aplic_descr *descr); +int vm_assert_irq(struct vm *vm, uint32_t irq); +int vm_deassert_irq(struct vm *vm, uint32_t irq); +int vm_raise_msi(struct vm *vm, uint64_t msg, uint64_t addr, int bus, int slot, + int func); +struct vm_exit *vm_exitinfo(struct vcpu *vcpu); +void vm_exit_suspended(struct vcpu *vcpu, uint64_t pc); +void vm_exit_debug(struct vcpu *vcpu, uint64_t pc); +void vm_exit_rendezvous(struct vcpu *vcpu, uint64_t pc); +void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc); + +cpuset_t vm_active_cpus(struct vm *vm); +cpuset_t vm_debug_cpus(struct vm *vm); +cpuset_t vm_suspended_cpus(struct vm *vm); + +static __inline int +vcpu_rendezvous_pending(struct vm_eventinfo *info) +{ + + return (*((uintptr_t *)(info->rptr)) != 0); +} + +static __inline int +vcpu_suspended(struct vm_eventinfo *info) +{ + + return (*info->sptr); +} + +int vcpu_debugged(struct vcpu *vcpu); + +enum vcpu_state { + VCPU_IDLE, + VCPU_FROZEN, + VCPU_RUNNING, + VCPU_SLEEPING, +}; + +int vcpu_set_state(struct vcpu *vcpu, enum vcpu_state state, bool from_idle); +enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu); + +static int __inline +vcpu_is_running(struct vcpu *vcpu, int *hostcpu) +{ + return (vcpu_get_state(vcpu, hostcpu) == VCPU_RUNNING); +} + +#ifdef _SYS_PROC_H_ +static int __inline +vcpu_should_yield(struct vcpu *vcpu) +{ + struct thread *td; + + td = curthread; + return (td->td_ast != 0 || td->td_owepreempt != 0); +} +#endif + +void *vcpu_stats(struct vcpu *vcpu); +void vcpu_notify_event(struct vcpu *vcpu); +struct vmspace *vm_vmspace(struct vm *vm); +struct vm_mem *vm_mem(struct vm *vm); + +enum vm_reg_name vm_segment_name(int seg_encoding); + +#endif /* _KERNEL */ + +#define VM_DIR_READ 0 +#define VM_DIR_WRITE 1 + +#define VM_GP_M_MASK 0x1f +#define VM_GP_MMU_ENABLED (1 << 5) + +struct vm_guest_paging { + int flags; + int padding; +}; + +struct vie { + uint8_t access_size:4, sign_extend:1, dir:1, unused:2; + enum vm_reg_name reg; +}; + +struct vre { + uint32_t inst_syndrome; + uint8_t dir:1, unused:7; + enum vm_reg_name reg; +}; + +/* + * Identifiers for optional vmm capabilities + */ +enum vm_cap_type { + VM_CAP_UNRESTRICTED_GUEST, + VM_CAP_SSTC, + VM_CAP_MAX +}; + +enum vm_exitcode { + VM_EXITCODE_BOGUS, + VM_EXITCODE_ECALL, + VM_EXITCODE_HYP, + VM_EXITCODE_PAGING, + VM_EXITCODE_SUSPENDED, + VM_EXITCODE_DEBUG, + VM_EXITCODE_INST_EMUL, + VM_EXITCODE_WFI, + VM_EXITCODE_MAX +}; + +struct vm_exit { + uint64_t scause; + uint64_t sepc; + uint64_t stval; + uint64_t htval; + uint64_t htinst; + enum vm_exitcode exitcode; + int inst_length; + uint64_t pc; + union { + struct { + uint64_t gpa; + } paging; + + struct { + uint64_t gpa; + struct vm_guest_paging paging; + struct vie vie; + } inst_emul; + + struct { + uint64_t args[8]; + } ecall; + + struct { + enum vm_suspend_how how; + } suspended; + + struct { + uint64_t scause; + } hyp; + } u; +}; + +#endif /* _VMM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/vmm_dev.h b/lib/libc/include/riscv64-freebsd-none/machine/vmm_dev.h new file mode 100644 index 0000000000000000000000000000000000000000..2e186a113f4c84c9adf6578b0ab652d8471a0e5a --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/vmm_dev.h @@ -0,0 +1,265 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2015 Mihai Carabas + * Copyright (c) 2024 Ruslan Bukin + * + * This software was developed by the University of Cambridge Computer + * Laboratory (Department of Computer Science and Technology) under Innovate + * UK project 105694, "Digital Security by Design (DSbD) Technology Platform + * Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_DEV_H_ +#define _VMM_DEV_H_ + +#include + +#include + +struct vm_memmap { + vm_paddr_t gpa; + int segid; /* memory segment */ + vm_ooffset_t segoff; /* offset into memory segment */ + size_t len; /* mmap length */ + int prot; /* RWX */ + int flags; +}; +#define VM_MEMMAP_F_WIRED 0x01 + +struct vm_munmap { + vm_paddr_t gpa; + size_t len; +}; + +#define VM_MEMSEG_NAME(m) ((m)->name[0] != '\0' ? (m)->name : NULL) +struct vm_memseg { + int segid; + size_t len; + char name[VM_MAX_SUFFIXLEN + 1]; + domainset_t *ds_mask; + size_t ds_mask_size; + int ds_policy; +}; + +struct vm_register { + int cpuid; + int regnum; /* enum vm_reg_name */ + uint64_t regval; +}; + +struct vm_register_set { + int cpuid; + unsigned int count; + const int *regnums; /* enum vm_reg_name */ + uint64_t *regvals; +}; + +struct vm_run { + int cpuid; + cpuset_t *cpuset; /* CPU set storage */ + size_t cpusetsize; + struct vm_exit *vm_exit; +}; + +struct vm_exception { + int cpuid; + uint64_t scause; +}; + +struct vm_msi { + uint64_t msg; + uint64_t addr; + int bus; + int slot; + int func; +}; + +struct vm_capability { + int cpuid; + enum vm_cap_type captype; + int capval; + int allcpus; +}; + +#define MAX_VM_STATS 64 +struct vm_stats { + int cpuid; /* in */ + int index; /* in */ + int num_entries; /* out */ + struct timeval tv; + uint64_t statbuf[MAX_VM_STATS]; +}; +struct vm_stat_desc { + int index; /* in */ + char desc[128]; /* out */ +}; + +struct vm_suspend { + enum vm_suspend_how how; +}; + +struct vm_gla2gpa { + int vcpuid; /* inputs */ + int prot; /* PROT_READ or PROT_WRITE */ + uint64_t gla; + struct vm_guest_paging paging; + int fault; /* outputs */ + uint64_t gpa; +}; + +struct vm_activate_cpu { + int vcpuid; +}; + +struct vm_cpuset { + int which; + int cpusetsize; + cpuset_t *cpus; +}; +#define VM_ACTIVE_CPUS 0 +#define VM_SUSPENDED_CPUS 1 +#define VM_DEBUG_CPUS 2 + +struct vm_aplic_descr { + uint64_t mem_start; + uint64_t mem_size; +}; + +struct vm_irq { + uint32_t irq; +}; + +struct vm_cpu_topology { + uint16_t sockets; + uint16_t cores; + uint16_t threads; + uint16_t maxcpus; +}; + +enum { + /* general routines */ + IOCNUM_ABIVERS = 0, + IOCNUM_RUN = 1, + IOCNUM_SET_CAPABILITY = 2, + IOCNUM_GET_CAPABILITY = 3, + IOCNUM_SUSPEND = 4, + IOCNUM_REINIT = 5, + + /* memory apis */ + IOCNUM_GET_GPA_PMAP = 12, + IOCNUM_GLA2GPA_NOFAULT = 13, + IOCNUM_ALLOC_MEMSEG = 14, + IOCNUM_GET_MEMSEG = 15, + IOCNUM_MMAP_MEMSEG = 16, + IOCNUM_MMAP_GETNEXT = 17, + IOCNUM_MUNMAP_MEMSEG = 18, + + /* register/state accessors */ + IOCNUM_SET_REGISTER = 20, + IOCNUM_GET_REGISTER = 21, + IOCNUM_SET_REGISTER_SET = 24, + IOCNUM_GET_REGISTER_SET = 25, + + /* statistics */ + IOCNUM_VM_STATS = 50, + IOCNUM_VM_STAT_DESC = 51, + + /* CPU Topology */ + IOCNUM_SET_TOPOLOGY = 63, + IOCNUM_GET_TOPOLOGY = 64, + + /* interrupt injection */ + IOCNUM_ASSERT_IRQ = 80, + IOCNUM_DEASSERT_IRQ = 81, + IOCNUM_RAISE_MSI = 82, + IOCNUM_INJECT_EXCEPTION = 83, + + /* vm_cpuset */ + IOCNUM_ACTIVATE_CPU = 90, + IOCNUM_GET_CPUSET = 91, + IOCNUM_SUSPEND_CPU = 92, + IOCNUM_RESUME_CPU = 93, + + /* vm_attach_aplic */ + IOCNUM_ATTACH_APLIC = 110, +}; + +#define VM_RUN \ + _IOWR('v', IOCNUM_RUN, struct vm_run) +#define VM_SUSPEND \ + _IOW('v', IOCNUM_SUSPEND, struct vm_suspend) +#define VM_REINIT \ + _IO('v', IOCNUM_REINIT) +#define VM_ALLOC_MEMSEG \ + _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg) +#define VM_GET_MEMSEG \ + _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg) +#define VM_MMAP_MEMSEG \ + _IOW('v', IOCNUM_MMAP_MEMSEG, struct vm_memmap) +#define VM_MMAP_GETNEXT \ + _IOWR('v', IOCNUM_MMAP_GETNEXT, struct vm_memmap) +#define VM_MUNMAP_MEMSEG \ + _IOW('v', IOCNUM_MUNMAP_MEMSEG, struct vm_munmap) +#define VM_SET_REGISTER \ + _IOW('v', IOCNUM_SET_REGISTER, struct vm_register) +#define VM_GET_REGISTER \ + _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register) +#define VM_SET_REGISTER_SET \ + _IOW('v', IOCNUM_SET_REGISTER_SET, struct vm_register_set) +#define VM_GET_REGISTER_SET \ + _IOWR('v', IOCNUM_GET_REGISTER_SET, struct vm_register_set) +#define VM_SET_CAPABILITY \ + _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability) +#define VM_GET_CAPABILITY \ + _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability) +#define VM_STATS \ + _IOWR('v', IOCNUM_VM_STATS, struct vm_stats) +#define VM_STAT_DESC \ + _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc) +#define VM_ASSERT_IRQ \ + _IOW('v', IOCNUM_ASSERT_IRQ, struct vm_irq) +#define VM_DEASSERT_IRQ \ + _IOW('v', IOCNUM_DEASSERT_IRQ, struct vm_irq) +#define VM_RAISE_MSI \ + _IOW('v', IOCNUM_RAISE_MSI, struct vm_msi) +#define VM_INJECT_EXCEPTION \ + _IOW('v', IOCNUM_INJECT_EXCEPTION, struct vm_exception) +#define VM_SET_TOPOLOGY \ + _IOW('v', IOCNUM_SET_TOPOLOGY, struct vm_cpu_topology) +#define VM_GET_TOPOLOGY \ + _IOR('v', IOCNUM_GET_TOPOLOGY, struct vm_cpu_topology) +#define VM_GLA2GPA_NOFAULT \ + _IOWR('v', IOCNUM_GLA2GPA_NOFAULT, struct vm_gla2gpa) +#define VM_ACTIVATE_CPU \ + _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu) +#define VM_GET_CPUS \ + _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset) +#define VM_SUSPEND_CPU \ + _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu) +#define VM_RESUME_CPU \ + _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu) +#define VM_ATTACH_APLIC \ + _IOW('v', IOCNUM_ATTACH_APLIC, struct vm_aplic_descr) +#endif \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/vmm_instruction_emul.h b/lib/libc/include/riscv64-freebsd-none/machine/vmm_instruction_emul.h new file mode 100644 index 0000000000000000000000000000000000000000..4aef995ba45c6b767a2cd13ecd28bebd8d65bc30 --- /dev/null +++ b/lib/libc/include/riscv64-freebsd-none/machine/vmm_instruction_emul.h @@ -0,0 +1,85 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2015 Mihai Carabas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VMM_INSTRUCTION_EMUL_H_ +#define _VMM_INSTRUCTION_EMUL_H_ + +/* + * Callback functions to read and write memory regions. + */ +typedef int (*mem_region_read_t)(struct vcpu *vcpu, uint64_t gpa, + uint64_t *rval, int rsize, void *arg); +typedef int (*mem_region_write_t)(struct vcpu *vcpu, uint64_t gpa, + uint64_t wval, int wsize, void *arg); + +/* + * Callback functions to read and write registers. + */ +typedef int (*reg_read_t)(struct vcpu *vcpu, uint64_t *rval, void *arg); +typedef int (*reg_write_t)(struct vcpu *vcpu, uint64_t wval, void *arg); + +/* + * Emulate the decoded 'vie' instruction when it contains a memory operation. + * + * The callbacks 'mrr' and 'mrw' emulate reads and writes to the memory region + * containing 'gpa'. 'mrarg' is an opaque argument that is passed into the + * callback functions. + * + * 'void *vm' should be 'struct vm *' when called from kernel context and + * 'struct vmctx *' when called from user context. + * + */ +int vmm_emulate_instruction(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, + struct vm_guest_paging *paging, mem_region_read_t mrr, + mem_region_write_t mrw, void *mrarg); + +/* + * Emulate the decoded 'vre' instruction when it contains a register access. + * + * The callbacks 'regread' and 'regwrite' emulate reads and writes to the + * register from 'vie'. 'regarg' is an opaque argument that is passed into the + * callback functions. + * + * 'void *vm' should be 'struct vm *' when called from kernel context and + * 'struct vmctx *' when called from user context. + * + */ +int vmm_emulate_register(struct vcpu *vcpu, struct vre *vre, reg_read_t regread, + reg_write_t regwrite, void *regarg); + +#ifdef _KERNEL +void vm_register_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask, + reg_read_t reg_read, reg_write_t reg_write, void *arg); +void vm_deregister_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask); + +void vm_register_inst_handler(struct vm *vm, uint64_t start, uint64_t size, + mem_region_read_t mmio_read, mem_region_write_t mmio_write); +void vm_deregister_inst_handler(struct vm *vm, uint64_t start, uint64_t size); +#endif + +#endif /* _VMM_INSTRUCTION_EMUL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/riscv64-freebsd-none/machine/vmparam.h b/lib/libc/include/riscv64-freebsd-none/machine/vmparam.h index d6f5d5342a574b519b28d4ea7254a74c68db0586..ead7b93b28f6c4c6d4234ea4572310f00e2565a0 100644 --- a/lib/libc/include/riscv64-freebsd-none/machine/vmparam.h +++ b/lib/libc/include/riscv64-freebsd-none/machine/vmparam.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30 */ @@ -211,8 +209,6 @@ #define PS_STRINGS_SV39 (USRSTACK_SV39 - sizeof(struct ps_strings)) #define PS_STRINGS_SV48 (USRSTACK_SV48 - sizeof(struct ps_strings)) -#define VM_EARLY_DTB_ADDRESS (VM_MAX_KERNEL_ADDRESS - (2 * L2_SIZE)) - /* * How many physical pages per kmem arena virtual page. */ @@ -236,19 +232,22 @@ #define VM_INITIAL_PAGEIN 16 #endif -#define UMA_MD_SMALL_ALLOC +#define UMA_USE_DMAP #ifndef LOCORE extern vm_paddr_t dmap_phys_base; extern vm_paddr_t dmap_phys_max; extern vm_offset_t dmap_max_addr; -extern vm_offset_t init_pt_va; #endif #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ +/* + * The top of KVA is reserved for early device mappings. + */ #define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS -#define PMAP_MAPDEV_EARLY_SIZE L2_SIZE +#define DEVMAP_MIN_VADDR (DEVMAP_MAX_VADDR - PMAP_MAPDEV_EARLY_SIZE) +#define PMAP_MAPDEV_EARLY_SIZE (4 * L2_SIZE) /* * No non-transparent large page support in the pmap. @@ -259,5 +258,6 @@ extern vm_offset_t init_pt_va; * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 1 #endif /* !_MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/fenv.h b/lib/libc/include/x86-freebsd-none/fenv.h deleted file mode 100644 index 3f511b649c27bce6386552d238177be428320ddd..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/fenv.h +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2004-2005 David Schultz - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _FENV_H_ -#define _FENV_H_ - -#include -#include -#include - -#ifndef __fenv_static -#define __fenv_static static -#endif - -typedef __uint16_t fexcept_t; - -/* Exception flags */ -#define FE_INVALID 0x01 -#define FE_DENORMAL 0x02 -#define FE_DIVBYZERO 0x04 -#define FE_OVERFLOW 0x08 -#define FE_UNDERFLOW 0x10 -#define FE_INEXACT 0x20 -#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \ - FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) - -/* Rounding modes */ -#define FE_TONEAREST 0x0000 -#define FE_DOWNWARD 0x0400 -#define FE_UPWARD 0x0800 -#define FE_TOWARDZERO 0x0c00 -#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ - FE_UPWARD | FE_TOWARDZERO) - -/* - * As compared to the x87 control word, the SSE unit's control word - * has the rounding control bits offset by 3 and the exception mask - * bits offset by 7. - */ -#define _SSE_ROUND_SHIFT 3 -#define _SSE_EMASK_SHIFT 7 - -#ifdef __i386__ -/* - * To preserve binary compatibility with FreeBSD 5.3, we pack the - * mxcsr into some reserved fields, rather than changing sizeof(fenv_t). - */ -typedef struct { - __uint16_t __control; - __uint16_t __mxcsr_hi; - __uint16_t __status; - __uint16_t __mxcsr_lo; - __uint32_t __tag; - char __other[16]; -} fenv_t; -#else /* __amd64__ */ -typedef struct { - struct { - __uint32_t __control; - __uint32_t __status; - __uint32_t __tag; - char __other[16]; - } __x87; - __uint32_t __mxcsr; -} fenv_t; -#endif /* __i386__ */ - -__BEGIN_DECLS - -/* Default floating-point environment */ -extern const fenv_t __fe_dfl_env; -#define FE_DFL_ENV (&__fe_dfl_env) - -#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \ - : "st", "st(1)", "st(2)", "st(3)", "st(4)", \ - "st(5)", "st(6)", "st(7)") -#define __fwait() __asm __volatile("fwait") - -int fegetenv(fenv_t *__envp); -int feholdexcept(fenv_t *__envp); -int fesetexceptflag(const fexcept_t *__flagp, int __excepts); -int feraiseexcept(int __excepts); -int feupdateenv(const fenv_t *__envp); - -__fenv_static inline int -fegetround(void) -{ - __uint16_t __control; - - /* - * We assume that the x87 and the SSE unit agree on the - * rounding mode. Reading the control word on the x87 turns - * out to be about 5 times faster than reading it on the SSE - * unit on an Opteron 244. - */ - __fnstcw(&__control); - return (__control & _ROUND_MASK); -} - -#if __BSD_VISIBLE - -int feenableexcept(int __mask); -int fedisableexcept(int __mask); - -/* We currently provide no external definition of fegetexcept(). */ -static inline int -fegetexcept(void) -{ - __uint16_t __control; - - /* - * We assume that the masks for the x87 and the SSE unit are - * the same. - */ - __fnstcw(&__control); - return (~__control & FE_ALL_EXCEPT); -} - -#endif /* __BSD_VISIBLE */ - -#ifdef __i386__ - -/* After testing for SSE support once, we cache the result in __has_sse. */ -enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK }; -extern enum __sse_support __has_sse; -int __test_sse(void); -#ifdef __SSE__ -#define __HAS_SSE() 1 -#else -#define __HAS_SSE() (__has_sse == __SSE_YES || \ - (__has_sse == __SSE_UNK && __test_sse())) -#endif - -#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \ - ((env).__mxcsr_lo)) -#define __set_mxcsr(env, x) do { \ - (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \ - (env).__mxcsr_lo = (__uint16_t)(x); \ -} while (0) - -__fenv_static inline int -feclearexcept(int __excepts) -{ - fenv_t __env; - __uint32_t __mxcsr; - - if (__excepts == FE_ALL_EXCEPT) { - __fnclex(); - } else { - __fnstenv(&__env); - __env.__status &= ~__excepts; - __fldenv(&__env); - } - if (__HAS_SSE()) { - __stmxcsr(&__mxcsr); - __mxcsr &= ~__excepts; - __ldmxcsr(&__mxcsr); - } - return (0); -} - -__fenv_static inline int -fegetexceptflag(fexcept_t *__flagp, int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __fnstsw(&__status); - if (__HAS_SSE()) - __stmxcsr(&__mxcsr); - else - __mxcsr = 0; - *__flagp = (__mxcsr | __status) & __excepts; - return (0); -} - -__fenv_static inline int -fetestexcept(int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __fnstsw(&__status); - if (__HAS_SSE()) - __stmxcsr(&__mxcsr); - else - __mxcsr = 0; - return ((__status | __mxcsr) & __excepts); -} - -__fenv_static inline int -fesetround(int __round) -{ - __uint32_t __mxcsr; - __uint16_t __control; - - if (__round & ~_ROUND_MASK) - return (-1); - - __fnstcw(&__control); - __control &= ~_ROUND_MASK; - __control |= __round; - __fldcw(&__control); - - if (__HAS_SSE()) { - __stmxcsr(&__mxcsr); - __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); - __mxcsr |= __round << _SSE_ROUND_SHIFT; - __ldmxcsr(&__mxcsr); - } - - return (0); -} - -__fenv_static inline int -fesetenv(const fenv_t *__envp) -{ - fenv_t __env = *__envp; - __uint32_t __mxcsr; - - __mxcsr = __get_mxcsr(__env); - __set_mxcsr(__env, 0xffffffff); - /* - * XXX Using fldenvx() instead of fldenv() tells the compiler that this - * instruction clobbers the i387 register stack. This happens because - * we restore the tag word from the saved environment. Normally, this - * would happen anyway and we wouldn't care, because the ABI allows - * function calls to clobber the i387 regs. However, fesetenv() is - * inlined, so we need to be more careful. - */ - __fldenvx(__env); - if (__HAS_SSE()) - __ldmxcsr(&__mxcsr); - return (0); -} - -#else /* __amd64__ */ - -__fenv_static inline int -feclearexcept(int __excepts) -{ - fenv_t __env; - - if (__excepts == FE_ALL_EXCEPT) { - __fnclex(); - } else { - __fnstenv(&__env.__x87); - __env.__x87.__status &= ~__excepts; - __fldenv(&__env.__x87); - } - __stmxcsr(&__env.__mxcsr); - __env.__mxcsr &= ~__excepts; - __ldmxcsr(&__env.__mxcsr); - return (0); -} - -__fenv_static inline int -fegetexceptflag(fexcept_t *__flagp, int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __stmxcsr(&__mxcsr); - __fnstsw(&__status); - *__flagp = (__mxcsr | __status) & __excepts; - return (0); -} - -__fenv_static inline int -fetestexcept(int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __stmxcsr(&__mxcsr); - __fnstsw(&__status); - return ((__status | __mxcsr) & __excepts); -} - -__fenv_static inline int -fesetround(int __round) -{ - __uint32_t __mxcsr; - __uint16_t __control; - - if (__round & ~_ROUND_MASK) - return (-1); - - __fnstcw(&__control); - __control &= ~_ROUND_MASK; - __control |= __round; - __fldcw(&__control); - - __stmxcsr(&__mxcsr); - __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); - __mxcsr |= __round << _SSE_ROUND_SHIFT; - __ldmxcsr(&__mxcsr); - - return (0); -} - -__fenv_static inline int -fesetenv(const fenv_t *__envp) -{ - - /* - * XXX Using fldenvx() instead of fldenv() tells the compiler that this - * instruction clobbers the i387 register stack. This happens because - * we restore the tag word from the saved environment. Normally, this - * would happen anyway and we wouldn't care, because the ABI allows - * function calls to clobber the i387 regs. However, fesetenv() is - * inlined, so we need to be more careful. - */ - __fldenvx(__envp->__x87); - __ldmxcsr(&__envp->__mxcsr); - return (0); -} - -#endif /* __i386__ */ - -__END_DECLS - -#endif /* !_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/float.h b/lib/libc/include/x86-freebsd-none/float.h deleted file mode 100644 index 0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/float.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/floatingpoint.h b/lib/libc/include/x86-freebsd-none/floatingpoint.h deleted file mode 100644 index 134415f2e6e7f3cd3a85949a74e5de1187c18ba8..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/floatingpoint.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1993 Andrew Moore, Talke Studio - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include -#include - -#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/_align.h b/lib/libc/include/x86-freebsd-none/machine/_align.h deleted file mode 100644 index 4af6dd67a7aa6c4b62acf80c30081e1bf4906702..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/_align.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/_bus.h b/lib/libc/include/x86-freebsd-none/machine/_bus.h index d244b86af3b77a62b36527ac252ea6d400b90fab..5f916269fecee31fa778139c68010157c72e4011 100644 --- a/lib/libc/include/x86-freebsd-none/machine/_bus.h +++ b/lib/libc/include/x86-freebsd-none/machine/_bus.h @@ -1,30 +1,13 @@ /*- + * Copyright (c) 2005 The FreeBSD Foundation. + * * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Derived in part from NetBSD's bus.h files by (alphabetically): + * Christopher G. Demetriou + * Charles M. Hannum + * Jason Thorpe + * The NetBSD Foundation. */ #ifndef I386_INCLUDE__BUS_H diff --git a/lib/libc/include/x86-freebsd-none/machine/_inttypes.h b/lib/libc/include/x86-freebsd-none/machine/_inttypes.h deleted file mode 100644 index 218f00871b1659c2232d879ebfe3581c925689dc..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/_inttypes.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/_limits.h b/lib/libc/include/x86-freebsd-none/machine/_limits.h deleted file mode 100644 index 71d8b62434e11012148499c26cc5d41499c4c7c7..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/_limits.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/_stdint.h b/lib/libc/include/x86-freebsd-none/machine/_stdint.h deleted file mode 100644 index 4fb2b3fb4ada6fdd4e1741429ba79b866b6475d4..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/_stdint.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/_types.h b/lib/libc/include/x86-freebsd-none/machine/_types.h deleted file mode 100644 index da8cb16909c45a62b2bcd0064c37989424176da7..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/_types.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/asm.h b/lib/libc/include/x86-freebsd-none/machine/asm.h index c51c45ae72121c746ba8b6b79b01072e141c0f5f..7a0b90fc1d4c2275102d6d1032668ca1c97a8b63 100644 --- a/lib/libc/include/x86-freebsd-none/machine/asm.h +++ b/lib/libc/include/x86-freebsd-none/machine/asm.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 */ #ifndef _MACHINE_ASM_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/atomic.h b/lib/libc/include/x86-freebsd-none/machine/atomic.h index 3211d15efae783c9638049588bae230b56343a97..63143fe5a35a8cb5c02a7911c5f8ff14061b7d52 100644 --- a/lib/libc/include/x86-freebsd-none/machine/atomic.h +++ b/lib/libc/include/x86-freebsd-none/machine/atomic.h @@ -49,8 +49,8 @@ static __inline void __mbk(void) { - __asm __volatile("lock; addl $0,%%fs:%0" - : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc"); + __asm __volatile("lock; addl $0,%%fs:%c0" + : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc"); } static __inline void @@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v) #define ATOMIC_LOAD(TYPE) \ static __inline u_##TYPE \ -atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ +atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \ { \ u_##TYPE res; \ \ @@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void) #ifdef _KERNEL -#ifdef WANT_FUNCTIONS -int atomic_cmpset_64_i386(volatile uint64_t *, uint64_t, uint64_t); -int atomic_cmpset_64_i586(volatile uint64_t *, uint64_t, uint64_t); -uint64_t atomic_load_acq_64_i386(volatile uint64_t *); -uint64_t atomic_load_acq_64_i586(volatile uint64_t *); -void atomic_store_rel_64_i386(volatile uint64_t *, uint64_t); -void atomic_store_rel_64_i586(volatile uint64_t *, uint64_t); -uint64_t atomic_swap_64_i386(volatile uint64_t *, uint64_t); -uint64_t atomic_swap_64_i586(volatile uint64_t *, uint64_t); -#endif - /* I486 does not support SMP or CMPXCHG8B. */ static __inline int atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src) @@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src) } static __inline uint64_t -atomic_load_acq_64_i386(volatile uint64_t *p) +atomic_load_acq_64_i386(const volatile uint64_t *p) { - volatile uint32_t *q; + const volatile uint32_t *q; uint64_t res; - q = (volatile uint32_t *)p; + q = (const volatile uint32_t *)p; __asm __volatile( " pushfl ; " " cli ; " @@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src) return (res); } +/* + * Architecturally always writes back some value to '*p' so will trigger + * a #GP(0) on read-only mappings. + */ static __inline uint64_t -atomic_load_acq_64_i586(volatile uint64_t *p) +atomic_load_acq_64_i586(const volatile uint64_t *p) { uint64_t res; @@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p) " movl %%ebx,%%eax ; " " movl %%ecx,%%edx ; " " lock; cmpxchg8b %1" - : "=&A" (res), /* 0 */ - "+m" (*p) /* 1 */ - : : "memory", "cc"); + : "=&A" (res) /* 0 */ + : "m" (*p) /* 1 */ + : "memory", "cc"); return (res); } @@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src) } static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) +atomic_load_acq_64(const volatile uint64_t *p) { if ((cpu_feature & CPUID_CX8) == 0) @@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long); #undef ATOMIC_STORE #undef ATOMIC_LOADSTORE -#ifndef WANT_FUNCTIONS - static __inline int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) { @@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v) #define atomic_subtract_rel_ptr(p, v) \ atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) #define atomic_load_acq_ptr(p) \ - atomic_load_acq_int((volatile u_int *)(p)) + atomic_load_acq_int((const volatile u_int *)(p)) #define atomic_store_rel_ptr(p, v) \ atomic_store_rel_int((volatile u_int *)(p), (v)) #define atomic_cmpset_ptr(dst, old, new) \ @@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v) atomic_swap_int((volatile u_int *)(p), (u_int)(v)) #define atomic_readandclear_ptr(p) \ atomic_readandclear_int((volatile u_int *)(p)) - -#endif /* !WANT_FUNCTIONS */ +#define atomic_testandclear_ptr(p, val) \ + atomic_testandclear_int((volatile u_int *)(p), (val)) +#define atomic_testandset_ptr(p, val) \ + atomic_testandset_int((volatile u_int *)(p), (val)) #if defined(_KERNEL) #define mb() __mbk() diff --git a/lib/libc/include/x86-freebsd-none/machine/bus.h b/lib/libc/include/x86-freebsd-none/machine/bus.h deleted file mode 100644 index 025c59ba2f2fba0441deaf254e60b905a59101bc..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/bus.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/clock.h b/lib/libc/include/x86-freebsd-none/machine/clock.h deleted file mode 100644 index 838e4abd59164efa7f0ef931839aed473eace111..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/clock.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/cpu.h b/lib/libc/include/x86-freebsd-none/machine/cpu.h index 62ddef75f5e6139bf133ff02e47cdae48074c83e..21d0051493df9922661d989f9fa9de3ad0d1849f 100644 --- a/lib/libc/include/x86-freebsd-none/machine/cpu.h +++ b/lib/libc/include/x86-freebsd-none/machine/cpu.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 */ #ifndef _MACHINE_CPU_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/cpufunc.h b/lib/libc/include/x86-freebsd-none/machine/cpufunc.h index 0c8667b08dc1473e9e1d22910c233e3229e48ede..22cd1b7cd1db2e08371c0ebe904e98685065e2b3 100644 --- a/lib/libc/include/x86-freebsd-none/machine/cpufunc.h +++ b/lib/libc/include/x86-freebsd-none/machine/cpufunc.h @@ -63,15 +63,6 @@ bsfl(u_int mask) return (result); } -static __inline __pure2 u_int -bsrl(u_int mask) -{ - u_int result; - - __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc"); - return (result); -} - static __inline void clflush(u_long addr) { @@ -83,7 +74,7 @@ static __inline void clflushopt(u_long addr) { - __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr)); + __asm __volatile("clflushopt %0" : : "m" (*(char *)addr)); } static __inline void diff --git a/lib/libc/include/x86-freebsd-none/machine/dump.h b/lib/libc/include/x86-freebsd-none/machine/dump.h deleted file mode 100644 index cf91d4b47952976f754ec6c400c30433a5ed7207..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/dump.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/elf.h b/lib/libc/include/x86-freebsd-none/machine/elf.h deleted file mode 100644 index 36a7ae1abaaddc874cebe8843e66d7d68e6d97ee..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/elf.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/endian.h b/lib/libc/include/x86-freebsd-none/machine/endian.h deleted file mode 100644 index 02be261a3b8025118a48fffd3c5b56be6f2aa0f3..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/exec.h b/lib/libc/include/x86-freebsd-none/machine/exec.h deleted file mode 100644 index 3a992321ba552502c8cd433a6ab572b7615bcfe6..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/exec.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)exec.h 8.1 (Berkeley) 6/11/93 - */ - -#ifndef _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ - -#define __LDPGSZ 4096 - -#endif /* !_MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/float.h b/lib/libc/include/x86-freebsd-none/machine/float.h deleted file mode 100644 index 0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/float.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/floatingpoint.h b/lib/libc/include/x86-freebsd-none/machine/floatingpoint.h deleted file mode 100644 index 134415f2e6e7f3cd3a85949a74e5de1187c18ba8..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/floatingpoint.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1993 Andrew Moore, Talke Studio - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include -#include - -#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/ieeefp.h b/lib/libc/include/x86-freebsd-none/machine/ieeefp.h index 14dc1311d27285b9ac134f81fcf39c42777a49c6..2fc5a4785fadf993aec0ce9174265b18aab70d0f 100644 --- a/lib/libc/include/x86-freebsd-none/machine/ieeefp.h +++ b/lib/libc/include/x86-freebsd-none/machine/ieeefp.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 */ #ifndef _MACHINE_IEEEFP_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/in_cksum.h b/lib/libc/include/x86-freebsd-none/machine/in_cksum.h index a9b78c12f7238abd12b1e84d18c536578cba56f1..8d037a9bef2544a298d5b05b89e0da7001d5f1a2 100644 --- a/lib/libc/include/x86-freebsd-none/machine/in_cksum.h +++ b/lib/libc/include/x86-freebsd-none/machine/in_cksum.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp */ diff --git a/lib/libc/include/x86-freebsd-none/machine/metadata.h b/lib/libc/include/x86-freebsd-none/machine/metadata.h deleted file mode 100644 index 2b194e06d14b745d26826928625e63311dd55ef2..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/metadata.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/npx.h b/lib/libc/include/x86-freebsd-none/machine/npx.h index c5d62ba579b652782d6dc515b7bb21009fd68bff..3c66e65dff5b888e10be52c7fe7dc2a4e4d15837 100644 --- a/lib/libc/include/x86-freebsd-none/machine/npx.h +++ b/lib/libc/include/x86-freebsd-none/machine/npx.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 */ /* diff --git a/lib/libc/include/x86-freebsd-none/machine/ofw_machdep.h b/lib/libc/include/x86-freebsd-none/machine/ofw_machdep.h deleted file mode 100644 index 21d28906f0dda8d9607400b9a6f5c6890cacbbca..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/ofw_machdep.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/param.h b/lib/libc/include/x86-freebsd-none/machine/param.h index 392093d8157847beb4fe9ab73b1dc271fdd8d67b..5699c7f0fd238beb233404d1b05ed49a8207260a 100644 --- a/lib/libc/include/x86-freebsd-none/machine/param.h +++ b/lib/libc/include/x86-freebsd-none/machine/param.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _I386_INCLUDE_PARAM_H_ @@ -43,9 +41,7 @@ * Machine dependent constants for Intel 386. */ -#define __HAVE_ACPI #define __HAVE_PIR -#define __PCI_REROUTE_INTERRUPT #ifndef MACHINE #define MACHINE "i386" @@ -146,19 +142,12 @@ /* * Mach derived conversion macros */ -#define trunc_page(x) ((x) & ~PAGE_MASK) -#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) #define trunc_4mpage(x) ((x) & ~PDRMASK) #define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK) -#define atop(x) ((x) >> PAGE_SHIFT) -#define ptoa(x) ((x) << PAGE_SHIFT) - #define i386_btop(x) ((x) >> PAGE_SHIFT) #define i386_ptob(x) ((x) << PAGE_SHIFT) -#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) - #define INKERNEL(va) (TRUE) #endif /* !_I386_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/pcb.h b/lib/libc/include/x86-freebsd-none/machine/pcb.h index 1a973ebe0b3576c546ac5d1a35ca5c555846a719..897227eb4d0a828bb11c5f7265e806eafd03cda9 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pcb.h +++ b/lib/libc/include/x86-freebsd-none/machine/pcb.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 */ #ifndef _I386_PCB_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/pcpu.h b/lib/libc/include/x86-freebsd-none/machine/pcpu.h index 48704d4b6016a0a8ff8688e83d6770c6ada664b1..87c6b69f2bfd5f5fafb655b4b41d4173db5e8659 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pcpu.h +++ b/lib/libc/include/x86-freebsd-none/machine/pcpu.h @@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Evaluates to the address of the per-cpu variable name. */ -#define __PCPU_PTR(name) __extension__ ({ \ - __pcpu_type(name) *__p; \ - \ - __asm __volatile("movl %%fs:%1,%0; addl %2,%0" \ - : "=r" (__p) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ - "i" (__pcpu_offset(name))); \ - \ - __p; \ -}) +#define __PCPU_PTR(name) \ + (&get_pcpu()->name) /* * Evaluates to the value of the per-cpu variable name. @@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __res; \ struct __s { \ u_char __b[MIN(sizeof(__res), 4)]; \ - } __s; \ + }; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ sizeof(__res) == 4) { \ - __asm __volatile("mov %%fs:%1,%0" \ - : "=r" (__s) \ - : "m" (*(struct __s *)(__pcpu_offset(name)))); \ - *(struct __s *)(void *)&__res = __s; \ + __asm __volatile("mov %%fs:%c1,%0" \ + : "=r" (*(struct __s *)(void *)&__res) \ + : "i" (__pcpu_offset(name))); \ } else { \ __res = *__PCPU_PTR(name); \ } \ @@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("add %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("add %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "cc", "memory"); \ } else \ *__PCPU_PTR(name) += __val; \ } while (0) @@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("mov %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("mov %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "memory"); \ } else { \ *__PCPU_PTR(name) = __val; \ } \ @@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); #define get_pcpu() __extension__ ({ \ struct pcpu *__pc; \ \ - __asm __volatile("movl %%fs:%1,%0" \ + __asm __volatile("movl %%fs:%c1,%0" \ : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + : "i" (__pcpu_offset(pc_prvspace))); \ __pc; \ }) diff --git a/lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h b/lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h index 4fc13cdfd3fa0e9ef5fe8259a078e5757211f650..5807079df3a6a91610890abc753088493b2ae012 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h +++ b/lib/libc/include/x86-freebsd-none/machine/pcpu_aux.h @@ -49,8 +49,8 @@ __curthread(void) { struct thread *td; - __asm("movl %%fs:%1,%0" : "=r" (td) - : "m" (*(char *)offsetof(struct pcpu, pc_curthread))); + __asm("movl %%fs:%c1,%0" : "=r" (td) + : "i" (offsetof(struct pcpu, pc_curthread))); return (td); } #define curthread (__curthread()) @@ -60,8 +60,8 @@ __curpcb(void) { struct pcb *pcb; - __asm("movl %%fs:%1,%0" : "=r" (pcb) - : "m" (*(char *)offsetof(struct pcpu, pc_curpcb))); + __asm("movl %%fs:%c1,%0" : "=r" (pcb) + : "i" (offsetof(struct pcpu, pc_curpcb))); return (pcb); } #define curpcb (__curpcb()) diff --git a/lib/libc/include/x86-freebsd-none/machine/pmap.h b/lib/libc/include/x86-freebsd-none/machine/pmap.h index c4971b12424c7c82bbc99415dc06c4175c6e957a..886993cbbdd3a5b1f8a3c5a6cabc76e55a9e66c6 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pmap.h +++ b/lib/libc/include/x86-freebsd-none/machine/pmap.h @@ -37,9 +37,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 */ #ifndef _MACHINE_PMAP_H_ @@ -83,7 +80,7 @@ * 4KB (PTE) page mappings have identical settings for the following fields: */ #define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \ - PG_M | PG_A | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V) + PG_M | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V) /* * Page Protection Exception bits @@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem); void *pmap_bios16_enter(void); void pmap_bios16_leave(void *handle); void pmap_bootstrap(vm_paddr_t); -int pmap_cache_bits(pmap_t, int mode, boolean_t is_pde); +int pmap_cache_bits(pmap_t, int mode, bool is_pde); int pmap_change_attr(vm_offset_t, vm_size_t, int); caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits); void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma); @@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va); void *pmap_mapbios(vm_paddr_t, vm_size_t); void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int); -boolean_t pmap_page_is_mapped(vm_page_t m); +bool pmap_page_is_mapped(vm_page_t m); void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); vm_paddr_t pmap_pg_frame(vm_paddr_t pa); bool pmap_ps_enabled(pmap_t pmap); diff --git a/lib/libc/include/x86-freebsd-none/machine/pmap_base.h b/lib/libc/include/x86-freebsd-none/machine/pmap_base.h index 73a6dcbd3b142c4076588afd5c653b7dec3c727e..e590f96a05da401e3ec296e506c7ffc510646da1 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pmap_base.h +++ b/lib/libc/include/x86-freebsd-none/machine/pmap_base.h @@ -58,8 +58,8 @@ struct pmap_methods { void *(*pm_bios16_enter)(void); void (*pm_bios16_leave)(void *handle); void (*pm_bootstrap)(vm_paddr_t firstaddr); - boolean_t (*pm_is_valid_memattr)(pmap_t, vm_memattr_t); - int (*pm_cache_bits)(pmap_t, int, boolean_t); + bool (*pm_is_valid_memattr)(pmap_t, vm_memattr_t); + int (*pm_cache_bits)(pmap_t, int, bool); bool (*pm_ps_enabled)(pmap_t); void (*pm_pinit0)(pmap_t); int (*pm_pinit)(pmap_t); @@ -84,13 +84,13 @@ struct pmap_methods { void (*pm_object_init_pt)(pmap_t, vm_offset_t, vm_object_t, vm_pindex_t, vm_size_t); void (*pm_unwire)(pmap_t, vm_offset_t, vm_offset_t); - boolean_t (*pm_page_exists_quick)(pmap_t, vm_page_t); + bool (*pm_page_exists_quick)(pmap_t, vm_page_t); int (*pm_page_wired_mappings)(vm_page_t); - boolean_t (*pm_page_is_mapped)(vm_page_t); + bool (*pm_page_is_mapped)(vm_page_t); void (*pm_remove_pages)(pmap_t); - boolean_t (*pm_is_modified)(vm_page_t); - boolean_t (*pm_is_prefaultable)(pmap_t, vm_offset_t); - boolean_t (*pm_is_referenced)(vm_page_t); + bool (*pm_is_modified)(vm_page_t); + bool (*pm_is_prefaultable)(pmap_t, vm_offset_t); + bool (*pm_is_referenced)(vm_page_t); void (*pm_remove_write)(vm_page_t); int (*pm_ts_referenced)(vm_page_t); void *(*pm_mapdev_attr)(vm_paddr_t, vm_size_t, int, int); @@ -107,7 +107,7 @@ struct pmap_methods { void (*pm_remove_all)(vm_page_t); void (*pm_init)(void); void (*pm_init_pat)(void); - void (*pm_growkernel)(vm_offset_t); + int (*pm_growkernel)(vm_offset_t); void (*pm_invalidate_page)(pmap_t, vm_offset_t); void (*pm_invalidate_range)(pmap_t, vm_offset_t, vm_offset_t); void (*pm_invalidate_all)(pmap_t); diff --git a/lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h b/lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h index c3ce424beb14e78709076d73f98fd527f20600e6..3af191062f586865413d76bb12a42cb15d6ea8ab 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h +++ b/lib/libc/include/x86-freebsd-none/machine/pmap_nopae.h @@ -44,9 +44,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 */ #ifndef _MACHINE_PMAP_NOPAE_H diff --git a/lib/libc/include/x86-freebsd-none/machine/pmap_pae.h b/lib/libc/include/x86-freebsd-none/machine/pmap_pae.h index df87eeaee8732e0b370e8643149c7316b88a947b..859fdc59a40fea90ba9754b929969923c6adf9e6 100644 --- a/lib/libc/include/x86-freebsd-none/machine/pmap_pae.h +++ b/lib/libc/include/x86-freebsd-none/machine/pmap_pae.h @@ -44,9 +44,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 */ #ifndef _MACHINE_PMAP_PAE_H diff --git a/lib/libc/include/x86-freebsd-none/machine/proc.h b/lib/libc/include/x86-freebsd-none/machine/proc.h index 8ba00996450b29b1529f90d02d2babc309958a9f..3377daab2ca42300358b1f0775b86b03380ae61c 100644 --- a/lib/libc/include/x86-freebsd-none/machine/proc.h +++ b/lib/libc/include/x86-freebsd-none/machine/proc.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 */ #ifndef _MACHINE_PROC_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/profile.h b/lib/libc/include/x86-freebsd-none/machine/profile.h index c58517f687731447b76f204cb2187d22aaf142e2..2789d419f554f067dc6f4885626757a822505a80 100644 --- a/lib/libc/include/x86-freebsd-none/machine/profile.h +++ b/lib/libc/include/x86-freebsd-none/machine/profile.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_PROFILE_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/psl.h b/lib/libc/include/x86-freebsd-none/machine/psl.h deleted file mode 100644 index 59536384fca5d786df3ad89e0d9cee9d9005d8ec..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/psl.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/ptrace.h b/lib/libc/include/x86-freebsd-none/machine/ptrace.h deleted file mode 100644 index 0a426e24fabda625bb4750562767d4bb248dfe76..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/ptrace.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/reg.h b/lib/libc/include/x86-freebsd-none/machine/reg.h deleted file mode 100644 index 419b2756cc0d2ee86d493fb6ab9a01f6efad94d1..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/reg.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/reloc.h b/lib/libc/include/x86-freebsd-none/machine/reloc.h deleted file mode 100644 index 4b31acb73c7b9d461aed401496fbbbd7d7f5e2a4..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/reloc.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)reloc.h 8.1 (Berkeley) 6/10/93 - */ - -#ifndef _I386_MACHINE_RELOC_H_ -#define _I386_MACHINE_RELOC_H_ - -/* Relocation format. */ -struct relocation_info { - int r_address; /* offset in text or data segment */ - unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ - r_pcrel : 1, /* 1 if value should be pc-relative */ - r_length : 2, /* log base 2 of value's width */ - r_extern : 1, /* 1 if need to add symbol to value */ - r_baserel : 1, /* linkage table relative */ - r_jmptable : 1, /* relocate to jump table */ - r_relative : 1, /* load address relative */ - r_copy : 1; /* run time copy */ -}; - -#endif \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/resource.h b/lib/libc/include/x86-freebsd-none/machine/resource.h index aaafc404fff32ee7ac30517226d5a09313a88ee8..4c356f38308e156c31327dfeaa387b50d2463795 100644 --- a/lib/libc/include/x86-freebsd-none/machine/resource.h +++ b/lib/libc/include/x86-freebsd-none/machine/resource.h @@ -39,8 +39,6 @@ #define SYS_RES_DRQ 2 /* isa dma lines */ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ -#ifdef NEW_PCIB #define PCI_RES_BUS 5 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/runq.h b/lib/libc/include/x86-freebsd-none/machine/runq.h deleted file mode 100644 index 63b30d582a975d12398ac7d6df338e6f19996202..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/runq.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (2) /* Number of priority status words. */ -#define RQB_L2BPW (5) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (ffs(word) - 1) - -/* - * Type of run queue status word. - */ -typedef u_int32_t rqb_word_t; - -#endif \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/sdt_machdep.h b/lib/libc/include/x86-freebsd-none/machine/sdt_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..127c93cbc82a619a25d52819a7d2a346b0e6094c --- /dev/null +++ b/lib/libc/include/x86-freebsd-none/machine/sdt_machdep.h @@ -0,0 +1,19 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Mark Johnston + */ + +#ifndef _SYS_SDT_MACHDEP_H_ +#define _SYS_SDT_MACHDEP_H_ + +#define _SDT_ASM_PATCH_INSTR "nop; nop; nop; nop; nop" + +/* + * Work around an apparent clang bug or limitation which prevents the use of the + * "i" (immediate) constraint with the probe structure. + */ +#define _SDT_ASM_PROBE_CONSTRAINT "Ws" +#define _SDT_ASM_PROBE_OPERAND "p" + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/segments.h b/lib/libc/include/x86-freebsd-none/machine/segments.h index c2d38f970b235783d112cd8d179f58dc5852df58..cfb3054fd8bb3ee855a830b8652f9bbc8ca875d2 100644 --- a/lib/libc/include/x86-freebsd-none/machine/segments.h +++ b/lib/libc/include/x86-freebsd-none/machine/segments.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 */ #ifndef _MACHINE_SEGMENTS_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/setjmp.h b/lib/libc/include/x86-freebsd-none/machine/setjmp.h deleted file mode 100644 index 41ef6217a78d6c901bb819cbf79f593f5a4effff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/setjmp.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/signal.h b/lib/libc/include/x86-freebsd-none/machine/signal.h index 926a34f56392b3d978b029c51f1b7c104edd2f79..c2a08dcb753503827f66f15dccf2f2d99b115c42 100644 --- a/lib/libc/include/x86-freebsd-none/machine/signal.h +++ b/lib/libc/include/x86-freebsd-none/machine/signal.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_SIGNAL_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/sysarch.h b/lib/libc/include/x86-freebsd-none/machine/sysarch.h deleted file mode 100644 index 7a878970793205ac7033c38ab745ae9a93a4dfbb..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/sysarch.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/tls.h b/lib/libc/include/x86-freebsd-none/machine/tls.h deleted file mode 100644 index 9a386029151eaf9da9c7e5747f8992d4d1c2e721..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/tls.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/trap.h b/lib/libc/include/x86-freebsd-none/machine/trap.h deleted file mode 100644 index d8320b7b3503429b2fcffd38825a130c4bb26faf..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/trap.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/tss.h b/lib/libc/include/x86-freebsd-none/machine/tss.h index 3d315ded6328c3fde40ca5325ce901ddcff75cea..0a59c54a60da306097cca51d66f7530881d6af17 100644 --- a/lib/libc/include/x86-freebsd-none/machine/tss.h +++ b/lib/libc/include/x86-freebsd-none/machine/tss.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 */ #ifndef _MACHINE_TSS_H_ diff --git a/lib/libc/include/x86-freebsd-none/machine/vdso.h b/lib/libc/include/x86-freebsd-none/machine/vdso.h deleted file mode 100644 index 57db69e06a7c2c84ff7cbc3a9913d6470271923d..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/vdso.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/vm.h b/lib/libc/include/x86-freebsd-none/machine/vm.h deleted file mode 100644 index fdd08a2e4de48f9f2449ec87870fab54d16cbae5..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/machine/vm.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2009 Hudson River Trading LLC - * Written by: John H. Baldwin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_VM_H_ -#define _MACHINE_VM_H_ - -#include - -/* Memory attributes. */ -#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) -#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) -#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) -#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) -#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) -#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED) - -#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK -#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE - -#endif /* !_MACHINE_VM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/machine/vmparam.h b/lib/libc/include/x86-freebsd-none/machine/vmparam.h index 2e484065761302f11e2a7d7332b44445cf572a52..625944650a1e7b2c765ab43385b5d903ff245d8a 100644 --- a/lib/libc/include/x86-freebsd-none/machine/vmparam.h +++ b/lib/libc/include/x86-freebsd-none/machine/vmparam.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 */ #ifndef _MACHINE_VMPARAM_H_ @@ -248,5 +246,6 @@ * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 0 #endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86-freebsd-none/stdarg.h b/lib/libc/include/x86-freebsd-none/stdarg.h deleted file mode 100644 index 20289894d6befa8cbbdb343cbb9c4c4e679c019f..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86-freebsd-none/stdarg.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/fenv.h b/lib/libc/include/x86_64-freebsd-none/fenv.h deleted file mode 100644 index 3f511b649c27bce6386552d238177be428320ddd..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/fenv.h +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2004-2005 David Schultz - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _FENV_H_ -#define _FENV_H_ - -#include -#include -#include - -#ifndef __fenv_static -#define __fenv_static static -#endif - -typedef __uint16_t fexcept_t; - -/* Exception flags */ -#define FE_INVALID 0x01 -#define FE_DENORMAL 0x02 -#define FE_DIVBYZERO 0x04 -#define FE_OVERFLOW 0x08 -#define FE_UNDERFLOW 0x10 -#define FE_INEXACT 0x20 -#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \ - FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) - -/* Rounding modes */ -#define FE_TONEAREST 0x0000 -#define FE_DOWNWARD 0x0400 -#define FE_UPWARD 0x0800 -#define FE_TOWARDZERO 0x0c00 -#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \ - FE_UPWARD | FE_TOWARDZERO) - -/* - * As compared to the x87 control word, the SSE unit's control word - * has the rounding control bits offset by 3 and the exception mask - * bits offset by 7. - */ -#define _SSE_ROUND_SHIFT 3 -#define _SSE_EMASK_SHIFT 7 - -#ifdef __i386__ -/* - * To preserve binary compatibility with FreeBSD 5.3, we pack the - * mxcsr into some reserved fields, rather than changing sizeof(fenv_t). - */ -typedef struct { - __uint16_t __control; - __uint16_t __mxcsr_hi; - __uint16_t __status; - __uint16_t __mxcsr_lo; - __uint32_t __tag; - char __other[16]; -} fenv_t; -#else /* __amd64__ */ -typedef struct { - struct { - __uint32_t __control; - __uint32_t __status; - __uint32_t __tag; - char __other[16]; - } __x87; - __uint32_t __mxcsr; -} fenv_t; -#endif /* __i386__ */ - -__BEGIN_DECLS - -/* Default floating-point environment */ -extern const fenv_t __fe_dfl_env; -#define FE_DFL_ENV (&__fe_dfl_env) - -#define __fldenvx(__env) __asm __volatile("fldenv %0" : : "m" (__env) \ - : "st", "st(1)", "st(2)", "st(3)", "st(4)", \ - "st(5)", "st(6)", "st(7)") -#define __fwait() __asm __volatile("fwait") - -int fegetenv(fenv_t *__envp); -int feholdexcept(fenv_t *__envp); -int fesetexceptflag(const fexcept_t *__flagp, int __excepts); -int feraiseexcept(int __excepts); -int feupdateenv(const fenv_t *__envp); - -__fenv_static inline int -fegetround(void) -{ - __uint16_t __control; - - /* - * We assume that the x87 and the SSE unit agree on the - * rounding mode. Reading the control word on the x87 turns - * out to be about 5 times faster than reading it on the SSE - * unit on an Opteron 244. - */ - __fnstcw(&__control); - return (__control & _ROUND_MASK); -} - -#if __BSD_VISIBLE - -int feenableexcept(int __mask); -int fedisableexcept(int __mask); - -/* We currently provide no external definition of fegetexcept(). */ -static inline int -fegetexcept(void) -{ - __uint16_t __control; - - /* - * We assume that the masks for the x87 and the SSE unit are - * the same. - */ - __fnstcw(&__control); - return (~__control & FE_ALL_EXCEPT); -} - -#endif /* __BSD_VISIBLE */ - -#ifdef __i386__ - -/* After testing for SSE support once, we cache the result in __has_sse. */ -enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK }; -extern enum __sse_support __has_sse; -int __test_sse(void); -#ifdef __SSE__ -#define __HAS_SSE() 1 -#else -#define __HAS_SSE() (__has_sse == __SSE_YES || \ - (__has_sse == __SSE_UNK && __test_sse())) -#endif - -#define __get_mxcsr(env) (((env).__mxcsr_hi << 16) | \ - ((env).__mxcsr_lo)) -#define __set_mxcsr(env, x) do { \ - (env).__mxcsr_hi = (__uint32_t)(x) >> 16; \ - (env).__mxcsr_lo = (__uint16_t)(x); \ -} while (0) - -__fenv_static inline int -feclearexcept(int __excepts) -{ - fenv_t __env; - __uint32_t __mxcsr; - - if (__excepts == FE_ALL_EXCEPT) { - __fnclex(); - } else { - __fnstenv(&__env); - __env.__status &= ~__excepts; - __fldenv(&__env); - } - if (__HAS_SSE()) { - __stmxcsr(&__mxcsr); - __mxcsr &= ~__excepts; - __ldmxcsr(&__mxcsr); - } - return (0); -} - -__fenv_static inline int -fegetexceptflag(fexcept_t *__flagp, int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __fnstsw(&__status); - if (__HAS_SSE()) - __stmxcsr(&__mxcsr); - else - __mxcsr = 0; - *__flagp = (__mxcsr | __status) & __excepts; - return (0); -} - -__fenv_static inline int -fetestexcept(int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __fnstsw(&__status); - if (__HAS_SSE()) - __stmxcsr(&__mxcsr); - else - __mxcsr = 0; - return ((__status | __mxcsr) & __excepts); -} - -__fenv_static inline int -fesetround(int __round) -{ - __uint32_t __mxcsr; - __uint16_t __control; - - if (__round & ~_ROUND_MASK) - return (-1); - - __fnstcw(&__control); - __control &= ~_ROUND_MASK; - __control |= __round; - __fldcw(&__control); - - if (__HAS_SSE()) { - __stmxcsr(&__mxcsr); - __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); - __mxcsr |= __round << _SSE_ROUND_SHIFT; - __ldmxcsr(&__mxcsr); - } - - return (0); -} - -__fenv_static inline int -fesetenv(const fenv_t *__envp) -{ - fenv_t __env = *__envp; - __uint32_t __mxcsr; - - __mxcsr = __get_mxcsr(__env); - __set_mxcsr(__env, 0xffffffff); - /* - * XXX Using fldenvx() instead of fldenv() tells the compiler that this - * instruction clobbers the i387 register stack. This happens because - * we restore the tag word from the saved environment. Normally, this - * would happen anyway and we wouldn't care, because the ABI allows - * function calls to clobber the i387 regs. However, fesetenv() is - * inlined, so we need to be more careful. - */ - __fldenvx(__env); - if (__HAS_SSE()) - __ldmxcsr(&__mxcsr); - return (0); -} - -#else /* __amd64__ */ - -__fenv_static inline int -feclearexcept(int __excepts) -{ - fenv_t __env; - - if (__excepts == FE_ALL_EXCEPT) { - __fnclex(); - } else { - __fnstenv(&__env.__x87); - __env.__x87.__status &= ~__excepts; - __fldenv(&__env.__x87); - } - __stmxcsr(&__env.__mxcsr); - __env.__mxcsr &= ~__excepts; - __ldmxcsr(&__env.__mxcsr); - return (0); -} - -__fenv_static inline int -fegetexceptflag(fexcept_t *__flagp, int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __stmxcsr(&__mxcsr); - __fnstsw(&__status); - *__flagp = (__mxcsr | __status) & __excepts; - return (0); -} - -__fenv_static inline int -fetestexcept(int __excepts) -{ - __uint32_t __mxcsr; - __uint16_t __status; - - __stmxcsr(&__mxcsr); - __fnstsw(&__status); - return ((__status | __mxcsr) & __excepts); -} - -__fenv_static inline int -fesetround(int __round) -{ - __uint32_t __mxcsr; - __uint16_t __control; - - if (__round & ~_ROUND_MASK) - return (-1); - - __fnstcw(&__control); - __control &= ~_ROUND_MASK; - __control |= __round; - __fldcw(&__control); - - __stmxcsr(&__mxcsr); - __mxcsr &= ~(_ROUND_MASK << _SSE_ROUND_SHIFT); - __mxcsr |= __round << _SSE_ROUND_SHIFT; - __ldmxcsr(&__mxcsr); - - return (0); -} - -__fenv_static inline int -fesetenv(const fenv_t *__envp) -{ - - /* - * XXX Using fldenvx() instead of fldenv() tells the compiler that this - * instruction clobbers the i387 register stack. This happens because - * we restore the tag word from the saved environment. Normally, this - * would happen anyway and we wouldn't care, because the ABI allows - * function calls to clobber the i387 regs. However, fesetenv() is - * inlined, so we need to be more careful. - */ - __fldenvx(__envp->__x87); - __ldmxcsr(&__envp->__mxcsr); - return (0); -} - -#endif /* __i386__ */ - -__END_DECLS - -#endif /* !_FENV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/float.h b/lib/libc/include/x86_64-freebsd-none/float.h deleted file mode 100644 index 0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/float.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/floatingpoint.h b/lib/libc/include/x86_64-freebsd-none/floatingpoint.h deleted file mode 100644 index 134415f2e6e7f3cd3a85949a74e5de1187c18ba8..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/floatingpoint.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1993 Andrew Moore, Talke Studio - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include -#include - -#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/i386/asm.h b/lib/libc/include/x86_64-freebsd-none/i386/asm.h index c51c45ae72121c746ba8b6b79b01072e141c0f5f..7a0b90fc1d4c2275102d6d1032668ca1c97a8b63 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/asm.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/asm.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 */ #ifndef _MACHINE_ASM_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/i386/atomic.h b/lib/libc/include/x86_64-freebsd-none/i386/atomic.h index 3211d15efae783c9638049588bae230b56343a97..63143fe5a35a8cb5c02a7911c5f8ff14061b7d52 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/atomic.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/atomic.h @@ -49,8 +49,8 @@ static __inline void __mbk(void) { - __asm __volatile("lock; addl $0,%%fs:%0" - : "+m" (*(u_int *)__OFFSETOF_MONITORBUF) : : "memory", "cc"); + __asm __volatile("lock; addl $0,%%fs:%c0" + : : "i" (__OFFSETOF_MONITORBUF) : "memory", "cc"); } static __inline void @@ -249,7 +249,7 @@ atomic_testandclear_int(volatile u_int *p, u_int v) #define ATOMIC_LOAD(TYPE) \ static __inline u_##TYPE \ -atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ +atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \ { \ u_##TYPE res; \ \ @@ -299,17 +299,6 @@ atomic_thread_fence_seq_cst(void) #ifdef _KERNEL -#ifdef WANT_FUNCTIONS -int atomic_cmpset_64_i386(volatile uint64_t *, uint64_t, uint64_t); -int atomic_cmpset_64_i586(volatile uint64_t *, uint64_t, uint64_t); -uint64_t atomic_load_acq_64_i386(volatile uint64_t *); -uint64_t atomic_load_acq_64_i586(volatile uint64_t *); -void atomic_store_rel_64_i386(volatile uint64_t *, uint64_t); -void atomic_store_rel_64_i586(volatile uint64_t *, uint64_t); -uint64_t atomic_swap_64_i386(volatile uint64_t *, uint64_t); -uint64_t atomic_swap_64_i586(volatile uint64_t *, uint64_t); -#endif - /* I486 does not support SMP or CMPXCHG8B. */ static __inline int atomic_cmpset_64_i386(volatile uint64_t *dst, uint64_t expect, uint64_t src) @@ -353,12 +342,12 @@ atomic_fcmpset_64_i386(volatile uint64_t *dst, uint64_t *expect, uint64_t src) } static __inline uint64_t -atomic_load_acq_64_i386(volatile uint64_t *p) +atomic_load_acq_64_i386(const volatile uint64_t *p) { - volatile uint32_t *q; + const volatile uint32_t *q; uint64_t res; - q = (volatile uint32_t *)p; + q = (const volatile uint32_t *)p; __asm __volatile( " pushfl ; " " cli ; " @@ -447,8 +436,12 @@ atomic_fcmpset_64_i586(volatile uint64_t *dst, uint64_t *expect, uint64_t src) return (res); } +/* + * Architecturally always writes back some value to '*p' so will trigger + * a #GP(0) on read-only mappings. + */ static __inline uint64_t -atomic_load_acq_64_i586(volatile uint64_t *p) +atomic_load_acq_64_i586(const volatile uint64_t *p) { uint64_t res; @@ -456,9 +449,9 @@ atomic_load_acq_64_i586(volatile uint64_t *p) " movl %%ebx,%%eax ; " " movl %%ecx,%%edx ; " " lock; cmpxchg8b %1" - : "=&A" (res), /* 0 */ - "+m" (*p) /* 1 */ - : : "memory", "cc"); + : "=&A" (res) /* 0 */ + : "m" (*p) /* 1 */ + : "memory", "cc"); return (res); } @@ -514,7 +507,7 @@ atomic_fcmpset_64(volatile uint64_t *dst, uint64_t *expect, uint64_t src) } static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) +atomic_load_acq_64(const volatile uint64_t *p) { if ((cpu_feature & CPUID_CX8) == 0) @@ -614,8 +607,6 @@ ATOMIC_LOADSTORE(long); #undef ATOMIC_STORE #undef ATOMIC_LOADSTORE -#ifndef WANT_FUNCTIONS - static __inline int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) { @@ -842,7 +833,7 @@ atomic_swap_long(volatile u_long *p, u_long v) #define atomic_subtract_rel_ptr(p, v) \ atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) #define atomic_load_acq_ptr(p) \ - atomic_load_acq_int((volatile u_int *)(p)) + atomic_load_acq_int((const volatile u_int *)(p)) #define atomic_store_rel_ptr(p, v) \ atomic_store_rel_int((volatile u_int *)(p), (v)) #define atomic_cmpset_ptr(dst, old, new) \ @@ -865,8 +856,10 @@ atomic_swap_long(volatile u_long *p, u_long v) atomic_swap_int((volatile u_int *)(p), (u_int)(v)) #define atomic_readandclear_ptr(p) \ atomic_readandclear_int((volatile u_int *)(p)) - -#endif /* !WANT_FUNCTIONS */ +#define atomic_testandclear_ptr(p, val) \ + atomic_testandclear_int((volatile u_int *)(p), (val)) +#define atomic_testandset_ptr(p, val) \ + atomic_testandset_int((volatile u_int *)(p), (val)) #if defined(_KERNEL) #define mb() __mbk() diff --git a/lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h b/lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h index 0c8667b08dc1473e9e1d22910c233e3229e48ede..22cd1b7cd1db2e08371c0ebe904e98685065e2b3 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/cpufunc.h @@ -63,15 +63,6 @@ bsfl(u_int mask) return (result); } -static __inline __pure2 u_int -bsrl(u_int mask) -{ - u_int result; - - __asm("bsrl %1,%0" : "=r" (result) : "rm" (mask) : "cc"); - return (result); -} - static __inline void clflush(u_long addr) { @@ -83,7 +74,7 @@ static __inline void clflushopt(u_long addr) { - __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr)); + __asm __volatile("clflushopt %0" : : "m" (*(char *)addr)); } static __inline void diff --git a/lib/libc/include/x86_64-freebsd-none/i386/pcpu.h b/lib/libc/include/x86_64-freebsd-none/i386/pcpu.h index 48704d4b6016a0a8ff8688e83d6770c6ada664b1..87c6b69f2bfd5f5fafb655b4b41d4173db5e8659 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/pcpu.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/pcpu.h @@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Evaluates to the address of the per-cpu variable name. */ -#define __PCPU_PTR(name) __extension__ ({ \ - __pcpu_type(name) *__p; \ - \ - __asm __volatile("movl %%fs:%1,%0; addl %2,%0" \ - : "=r" (__p) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ - "i" (__pcpu_offset(name))); \ - \ - __p; \ -}) +#define __PCPU_PTR(name) \ + (&get_pcpu()->name) /* * Evaluates to the value of the per-cpu variable name. @@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __res; \ struct __s { \ u_char __b[MIN(sizeof(__res), 4)]; \ - } __s; \ + }; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ sizeof(__res) == 4) { \ - __asm __volatile("mov %%fs:%1,%0" \ - : "=r" (__s) \ - : "m" (*(struct __s *)(__pcpu_offset(name)))); \ - *(struct __s *)(void *)&__res = __s; \ + __asm __volatile("mov %%fs:%c1,%0" \ + : "=r" (*(struct __s *)(void *)&__res) \ + : "i" (__pcpu_offset(name))); \ } else { \ __res = *__PCPU_PTR(name); \ } \ @@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("add %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("add %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "cc", "memory"); \ } else \ *__PCPU_PTR(name) += __val; \ } while (0) @@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("mov %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("mov %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "memory"); \ } else { \ *__PCPU_PTR(name) = __val; \ } \ @@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); #define get_pcpu() __extension__ ({ \ struct pcpu *__pc; \ \ - __asm __volatile("movl %%fs:%1,%0" \ + __asm __volatile("movl %%fs:%c1,%0" \ : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + : "i" (__pcpu_offset(pc_prvspace))); \ __pc; \ }) diff --git a/lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h b/lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h index 4fc13cdfd3fa0e9ef5fe8259a078e5757211f650..5807079df3a6a91610890abc753088493b2ae012 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/pcpu_aux.h @@ -49,8 +49,8 @@ __curthread(void) { struct thread *td; - __asm("movl %%fs:%1,%0" : "=r" (td) - : "m" (*(char *)offsetof(struct pcpu, pc_curthread))); + __asm("movl %%fs:%c1,%0" : "=r" (td) + : "i" (offsetof(struct pcpu, pc_curthread))); return (td); } #define curthread (__curthread()) @@ -60,8 +60,8 @@ __curpcb(void) { struct pcb *pcb; - __asm("movl %%fs:%1,%0" : "=r" (pcb) - : "m" (*(char *)offsetof(struct pcpu, pc_curpcb))); + __asm("movl %%fs:%c1,%0" : "=r" (pcb) + : "i" (offsetof(struct pcpu, pc_curpcb))); return (pcb); } #define curpcb (__curpcb()) diff --git a/lib/libc/include/x86_64-freebsd-none/i386/pmap.h b/lib/libc/include/x86_64-freebsd-none/i386/pmap.h index c4971b12424c7c82bbc99415dc06c4175c6e957a..886993cbbdd3a5b1f8a3c5a6cabc76e55a9e66c6 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/pmap.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/pmap.h @@ -37,9 +37,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 */ #ifndef _MACHINE_PMAP_H_ @@ -83,7 +80,7 @@ * 4KB (PTE) page mappings have identical settings for the following fields: */ #define PG_PTE_PROMOTE (PG_MANAGED | PG_W | PG_G | PG_PTE_PAT | \ - PG_M | PG_A | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V) + PG_M | PG_NC_PCD | PG_NC_PWT | PG_U | PG_RW | PG_V) /* * Page Protection Exception bits @@ -221,7 +218,7 @@ void pmap_basemem_setup(u_int basemem); void *pmap_bios16_enter(void); void pmap_bios16_leave(void *handle); void pmap_bootstrap(vm_paddr_t); -int pmap_cache_bits(pmap_t, int mode, boolean_t is_pde); +int pmap_cache_bits(pmap_t, int mode, bool is_pde); int pmap_change_attr(vm_offset_t, vm_size_t, int); caddr_t pmap_cmap3(vm_paddr_t pa, u_int pte_bits); void pmap_cp_slow0_map(vm_offset_t kaddr, int plen, vm_page_t *ma); @@ -239,7 +236,7 @@ void pmap_ksetrw(vm_offset_t va); void *pmap_mapbios(vm_paddr_t, vm_size_t); void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int); -boolean_t pmap_page_is_mapped(vm_page_t m); +bool pmap_page_is_mapped(vm_page_t m); void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); vm_paddr_t pmap_pg_frame(vm_paddr_t pa); bool pmap_ps_enabled(pmap_t pmap); diff --git a/lib/libc/include/x86_64-freebsd-none/i386/proc.h b/lib/libc/include/x86_64-freebsd-none/i386/proc.h index 8ba00996450b29b1529f90d02d2babc309958a9f..3377daab2ca42300358b1f0775b86b03380ae61c 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/proc.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/proc.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 */ #ifndef _MACHINE_PROC_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/i386/profile.h b/lib/libc/include/x86_64-freebsd-none/i386/profile.h index c58517f687731447b76f204cb2187d22aaf142e2..2789d419f554f067dc6f4885626757a822505a80 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/profile.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/profile.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ #ifndef _MACHINE_PROFILE_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/i386/segments.h b/lib/libc/include/x86_64-freebsd-none/i386/segments.h index c2d38f970b235783d112cd8d179f58dc5852df58..cfb3054fd8bb3ee855a830b8652f9bbc8ca875d2 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/segments.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/segments.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 */ #ifndef _MACHINE_SEGMENTS_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/i386/vmparam.h b/lib/libc/include/x86_64-freebsd-none/i386/vmparam.h index 2e484065761302f11e2a7d7332b44445cf572a52..625944650a1e7b2c765ab43385b5d903ff245d8a 100644 --- a/lib/libc/include/x86_64-freebsd-none/i386/vmparam.h +++ b/lib/libc/include/x86_64-freebsd-none/i386/vmparam.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 */ #ifndef _MACHINE_VMPARAM_H_ @@ -248,5 +246,6 @@ * Need a page dump array for minidump. */ #define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 0 #endif /* _MACHINE_VMPARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_align.h b/lib/libc/include/x86_64-freebsd-none/machine/_align.h deleted file mode 100644 index 4af6dd67a7aa6c4b62acf80c30081e1bf4906702..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/_align.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_bus.h b/lib/libc/include/x86_64-freebsd-none/machine/_bus.h index 2a13caba31eef2811223d88962ef511373c442c2..ce1bada4344e4da4c24ae7fb2be0ef92ae5ae3ba 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/_bus.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/_bus.h @@ -1,30 +1,13 @@ /*- + * Copyright (c) 2005 The FreeBSD Foundation. + * * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 M. Warner Losh - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Derived in part from NetBSD's bus.h files by (alphabetically): + * Christopher G. Demetriou + * Charles M. Hannum + * Jason Thorpe + * The NetBSD Foundation. */ #ifndef AMD64_INCLUDE__BUS_H diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_inttypes.h b/lib/libc/include/x86_64-freebsd-none/machine/_inttypes.h deleted file mode 100644 index 218f00871b1659c2232d879ebfe3581c925689dc..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/_inttypes.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_limits.h b/lib/libc/include/x86_64-freebsd-none/machine/_limits.h deleted file mode 100644 index 71d8b62434e11012148499c26cc5d41499c4c7c7..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/_limits.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_stdint.h b/lib/libc/include/x86_64-freebsd-none/machine/_stdint.h deleted file mode 100644 index 4fb2b3fb4ada6fdd4e1741429ba79b866b6475d4..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/_stdint.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/_types.h b/lib/libc/include/x86_64-freebsd-none/machine/_types.h deleted file mode 100644 index da8cb16909c45a62b2bcd0064c37989424176da7..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/_types.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/asm.h b/lib/libc/include/x86_64-freebsd-none/machine/asm.h index 11184f2213172fd0faddfe5f3b773bbca57de470..d3ca1f7208c1230e6f2780c9b84cf3340002fcd0 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/asm.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/asm.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 */ #ifdef __i386__ @@ -94,7 +92,7 @@ #define END(x) .size x, . - x; .cfi_endproc /* - * WEAK_REFERENCE(): create a weak reference alias from sym. + * WEAK_REFERENCE(): create a weak reference alias from sym. * The macro is not a general asm macro that takes arbitrary names, * but one that takes only C names. It does the non-null name * translation inside the macro. diff --git a/lib/libc/include/x86_64-freebsd-none/machine/atomic.h b/lib/libc/include/x86_64-freebsd-none/machine/atomic.h index 8e1b656ce7d055b3f1b3123575235473af795680..eeefa748c86e32088f187e7cd5b8406faf0383dd 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/atomic.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/atomic.h @@ -102,7 +102,7 @@ */ /* - * Always use lock prefixes. The result is slighly less optimal for + * Always use lock prefixes. The result is slightly less optimal for * UP systems, but it matters less now, and sometimes UP is emulated * over SMP. * @@ -295,8 +295,8 @@ static __inline void __storeload_barrier(void) { #if defined(_KERNEL) - __asm __volatile("lock; addl $0,%%gs:%0" - : "+m" (*(u_int *)OFFSETOF_MONITORBUF) : : "memory", "cc"); + __asm __volatile("lock; addl $0,%%gs:%c0" + : : "i" (OFFSETOF_MONITORBUF) : "memory", "cc"); #else /* !_KERNEL */ __asm __volatile("lock; addl $0,-8(%%rsp)" : : : "memory", "cc"); #endif /* _KERNEL*/ @@ -304,7 +304,7 @@ __storeload_barrier(void) #define ATOMIC_LOAD(TYPE) \ static __inline u_##TYPE \ -atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ +atomic_load_acq_##TYPE(const volatile u_##TYPE *p) \ { \ u_##TYPE res; \ \ @@ -385,7 +385,6 @@ ATOMIC_LOADSTORE(long); #undef ATOMIC_LOAD #undef ATOMIC_STORE #undef ATOMIC_LOADSTORE -#ifndef WANT_FUNCTIONS /* Read the current value and store a new value in the destination. */ static __inline u_int @@ -589,8 +588,8 @@ atomic_swap_long(volatile u_long *p, u_long v) #define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long #define atomic_swap_ptr atomic_swap_long #define atomic_readandclear_ptr atomic_readandclear_long - -#endif /* !WANT_FUNCTIONS */ +#define atomic_testandset_ptr atomic_testandset_long +#define atomic_testandclear_ptr atomic_testandclear_long #endif /* !SAN_NEEDS_INTERCEPTORS || SAN_RUNTIME */ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/bus.h b/lib/libc/include/x86_64-freebsd-none/machine/bus.h deleted file mode 100644 index 025c59ba2f2fba0441deaf254e60b905a59101bc..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/bus.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/bus_dma.h b/lib/libc/include/x86_64-freebsd-none/machine/bus_dma.h index a7a39a174fa6b6f3f37a23cd3a72553cd68ed7c2..6435c896e2fae0b1fea0e7e680c7c58e60de660c 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/bus_dma.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/bus_dma.h @@ -29,6 +29,6 @@ #ifndef _AMD64_BUS_DMA_H_ #define _AMD64_BUS_DMA_H_ -#include +#include #endif /* _AMD64_BUS_DMA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/clock.h b/lib/libc/include/x86_64-freebsd-none/machine/clock.h deleted file mode 100644 index 838e4abd59164efa7f0ef931839aed473eace111..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/clock.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/cpu.h b/lib/libc/include/x86_64-freebsd-none/machine/cpu.h index 7d947e6b6e1422ef85227b93f6614291f499b09c..bbd38817fb7e4421a24de0d0e7ebf02cc44dcdf1 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/cpu.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/cpu.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 */ #ifndef _MACHINE_CPU_H_ @@ -72,7 +70,8 @@ extern char btext[]; extern char _end[]; extern char etext[]; -/* Resume hook for VMM. */ +/* Suspend and resume hook for VMM. */ +extern void (*vmm_suspend_p)(void); extern void (*vmm_resume_p)(void); void cpu_halt(void); diff --git a/lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h b/lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h index 7d2fdf0af924f07a5cffefa52c9134ff36a30d73..2d339f84b44d8e890a1483078fa639f963d8893e 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/cpufunc.h @@ -65,10 +65,6 @@ breakpoint(void) #define bsfq(mask) __builtin_ctzl(mask) -#define bsrl(mask) (__builtin_clz(mask) ^ 0x1f) - -#define bsrq(mask) (__builtin_clzl(mask) ^ 0x3f) - static __inline void clflush(u_long addr) { @@ -80,7 +76,7 @@ static __inline void clflushopt(u_long addr) { - __asm __volatile(".byte 0x66;clflush %0" : : "m" (*(char *)addr)); + __asm __volatile("clflushopt %0" : : "m" (*(char *)addr)); } static __inline void @@ -576,6 +572,15 @@ rss(void) return (sel); } +static __inline u_short +rcs(void) +{ + u_short sel; + + __asm __volatile("movw %%cs,%0" : "=rm" (sel)); + return (sel); +} + static __inline void load_ds(u_short sel) { @@ -946,6 +951,29 @@ sgx_eremove(void *epc) return (sgx_encls(SGX_EREMOVE, 0, (uint64_t)epc, 0)); } +static __inline void +xrstors(uint8_t *save_area, uint64_t state_bitmap) +{ + uint32_t low, hi; + + low = state_bitmap; + hi = state_bitmap >> 32; + __asm __volatile("xrstors %0" : : "m"(*save_area), "a"(low), + "d"(hi)); +} + +static __inline void +xsaves(uint8_t *save_area, uint64_t state_bitmap) +{ + uint32_t low, hi; + + low = state_bitmap; + hi = state_bitmap >> 32; + __asm __volatile("xsaves %0" : "=m"(*save_area) : "a"(low), + "d"(hi) + : "memory"); +} + void reset_dbregs(void); #ifdef _KERNEL diff --git a/lib/libc/include/x86_64-freebsd-none/machine/dump.h b/lib/libc/include/x86_64-freebsd-none/machine/dump.h deleted file mode 100644 index cf91d4b47952976f754ec6c400c30433a5ed7207..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/dump.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/efi.h b/lib/libc/include/x86_64-freebsd-none/machine/efi.h index d1dc00371a1efde9c344c68b23fca7d9f1350f5e..0c60991208834048e2efa9b253b154f9c9f9ef5e 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/efi.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/efi.h @@ -29,6 +29,8 @@ #ifndef __AMD64_INCLUDE_EFI_H_ #define __AMD64_INCLUDE_EFI_H_ +#include + /* * XXX: from gcc 6.2 manual: * Note, the ms_abi attribute for Microsoft Windows 64-bit targets @@ -51,6 +53,10 @@ #define EFI_TIME_OWNED() mtx_assert(&atrtc_time_lock, MA_OWNED) #define EFI_RT_HANDLE_FAULTS_DEFAULT 1 + +#define EFI_MAP_BOOTTYPE_ALLOWED(type) (((efi_map_regs >> (type)) & 1) != 0) + +extern uint32_t efi_map_regs; #endif struct efirt_callinfo { diff --git a/lib/libc/include/x86_64-freebsd-none/machine/elf.h b/lib/libc/include/x86_64-freebsd-none/machine/elf.h deleted file mode 100644 index 36a7ae1abaaddc874cebe8843e66d7d68e6d97ee..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/elf.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/endian.h b/lib/libc/include/x86_64-freebsd-none/machine/endian.h deleted file mode 100644 index 02be261a3b8025118a48fffd3c5b56be6f2aa0f3..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/exec.h b/lib/libc/include/x86_64-freebsd-none/machine/exec.h deleted file mode 100644 index 3a992321ba552502c8cd433a6ab572b7615bcfe6..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/exec.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)exec.h 8.1 (Berkeley) 6/11/93 - */ - -#ifndef _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ - -#define __LDPGSZ 4096 - -#endif /* !_MACHINE_EXEC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/float.h b/lib/libc/include/x86_64-freebsd-none/machine/float.h deleted file mode 100644 index 0e6d11c8c393a60c06d469a8c4c7022b98f8d0ff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/float.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/floatingpoint.h b/lib/libc/include/x86_64-freebsd-none/machine/floatingpoint.h deleted file mode 100644 index 134415f2e6e7f3cd3a85949a74e5de1187c18ba8..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/floatingpoint.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1993 Andrew Moore, Talke Studio - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include -#include - -#endif /* !_FLOATINGPOINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/fpu.h b/lib/libc/include/x86_64-freebsd-none/machine/fpu.h index f4ada921ebd22730e2ac54811896479de5c5a4ee..e5bf23ad9f882ab529271cb3cb94f86a2aba21fa 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/fpu.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/fpu.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 */ /* diff --git a/lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h b/lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h index 79a55381f197d4e704ce8d8f0802eca83f05fa4a..27f5ef58c3144f66a1779275a7a17d0a8632f20c 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/ieeefp.h @@ -32,8 +32,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 */ #ifndef _MACHINE_IEEEFP_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/md_var.h b/lib/libc/include/x86_64-freebsd-none/machine/md_var.h index 6a55cd48d5d296d2fdda5f41f4bcd7959c610fdc..57036e48d494948762d5e7a400efd3429703b838 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/md_var.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/md_var.h @@ -50,6 +50,7 @@ extern vm_paddr_t intel_graphics_stolen_base; extern vm_paddr_t intel_graphics_stolen_size; extern int la57; +extern int prefer_uva_la48; extern vm_paddr_t kernphys; extern vm_paddr_t KERNend; @@ -98,6 +99,10 @@ void get_fpcontext(struct thread *td, struct __mcontext *mcp, int set_fpcontext(struct thread *td, struct __mcontext *mcp, char *xfpustate, size_t xfpustate_len); +void wrmsr_early_safe_start(void); +void wrmsr_early_safe_end(void); +int wrmsr_early_safe(u_int msr, uint64_t data); + #endif /* !_MACHINE_MD_VAR_H_ */ #endif /* __i386__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/metadata.h b/lib/libc/include/x86_64-freebsd-none/machine/metadata.h deleted file mode 100644 index 2b194e06d14b745d26826928625e63311dd55ef2..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/metadata.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/msan.h b/lib/libc/include/x86_64-freebsd-none/machine/msan.h index 085cba7833671da28d81aa960d344654d114e1f1..95abd83ea5c932237640ca1c5e1efe95fffeefb3 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/msan.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/msan.h @@ -81,7 +81,7 @@ kmsan_md_unsupported(vm_offset_t addr) * The kernel itself isn't shadowed: for most purposes global variables * are always initialized, and because KMSAN kernels are large * (GENERIC-KMSAN is ~80MB at the time of writing), shadowing would - * incur signficant memory usage. + * incur significant memory usage. */ return (addr < VM_MIN_KERNEL_ADDRESS || addr >= KERNBASE); } diff --git a/lib/libc/include/x86_64-freebsd-none/machine/ofw_machdep.h b/lib/libc/include/x86_64-freebsd-none/machine/ofw_machdep.h deleted file mode 100644 index 21d28906f0dda8d9607400b9a6f5c6890cacbbca..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/ofw_machdep.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/param.h b/lib/libc/include/x86_64-freebsd-none/machine/param.h index b98eb83cf39398745aec64e2659843e7bfdec17f..0403f0d36a02d231ccb8eb39a926efdcee5693b4 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/param.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/param.h @@ -36,8 +36,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)param.h 8.1 (Berkeley) 6/10/93 */ #ifndef _AMD64_INCLUDE_PARAM_H_ @@ -49,9 +47,6 @@ * Machine dependent constants for AMD64. */ -#define __HAVE_ACPI -#define __PCI_REROUTE_INTERRUPT - #ifndef MACHINE #define MACHINE "amd64" #endif @@ -80,7 +75,7 @@ * ALIGNED_POINTER is a boolean macro that checks whether an address * is valid to fetch data elements of type t from on this architecture. * This does not reflect the optimal alignment, just the possibility - * (within reasonable limits). + * (within reasonable limits). */ #define ALIGNED_POINTER(p, t) 1 @@ -144,25 +139,17 @@ /* * Mach derived conversion macros */ -#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) -#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) #define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) #define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) #define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) -#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) - #define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) #define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) -#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) +#define INKERNEL(va) \ + (((va) >= kva_layout.dmap_low && (va) < kva_layout.dmap_high) || \ + ((va) >= kva_layout.km_low && (va) < kva_layout.km_high)) -#define INKERNEL(va) (((va) >= DMAP_MIN_ADDRESS && (va) < DMAP_MAX_ADDRESS) \ - || ((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS)) - -#ifdef SMP #define SC_TABLESIZE 1024 /* Must be power of 2. */ -#endif #endif /* !_AMD64_INCLUDE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/pcb.h b/lib/libc/include/x86_64-freebsd-none/machine/pcb.h index 7ab79170372210e65c9d6a21859e43f63d47687d..b478c3064e008562aec2640d838a74dba8d67e2d 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/pcb.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/pcb.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 */ #ifndef _AMD64_PCB_H_ @@ -86,6 +84,7 @@ struct pcb { #define PCB_KERNFPU_THR 0x0020 /* fpu_kern_thread() */ #define PCB_32BIT 0x0040 /* process has 32 bit context (segs etc) */ #define PCB_FPUNOSAVE 0x0080 /* no save area for current FPU ctx */ +#define PCB_TLSBASE 0x0100 /* tlsbase was set */ uint16_t pcb_initial_fpucw; @@ -106,7 +105,8 @@ struct pcb { struct savefpu *pcb_save; - uint64_t pcb_pad[5]; + register_t pcb_tlsbase; /* not same as pcb_fsbase */ + uint64_t pcb_pad[4]; }; /* Per-CPU state saved during suspend and resume. */ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/pcpu.h b/lib/libc/include/x86_64-freebsd-none/machine/pcpu.h index e9ed33c71218eb56729012fcb1a160036c7f67ff..469ae6213dc52f58f394bb7c339026ddbee5a7af 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/pcpu.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/pcpu.h @@ -182,16 +182,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Evaluates to the address of the per-cpu variable name. */ -#define __PCPU_PTR(name) __extension__ ({ \ - __pcpu_type(name) *__p; \ - \ - __asm __volatile("movq %%gs:%1,%0; addq %2,%0" \ - : "=r" (__p) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ - "i" (__pcpu_offset(name))); \ - \ - __p; \ -}) +#define __PCPU_PTR(name) \ + (&get_pcpu()->name) /* * Evaluates to the value of the per-cpu variable name. @@ -200,14 +192,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __res; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ sizeof(__res) == 4 || sizeof(__res) == 8) { \ - __asm __volatile("mov %%gs:%1,%0" \ - : "=r" (__s) \ - : "m" (*(struct __s *)(__pcpu_offset(name)))); \ - *(struct __s *)(void *)&__res = __s; \ + __asm __volatile("mov %%gs:%c1,%0" \ + : "=r" (*(struct __s *)(void *)&__res) \ + : "i" (__pcpu_offset(name))); \ } else { \ __res = *__PCPU_PTR(name); \ } \ @@ -222,15 +213,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4 || sizeof(__val) == 8) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("add %1,%%gs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("add %1,%%gs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "cc", "memory"); \ } else \ *__PCPU_PTR(name) += __val; \ } while (0) @@ -238,30 +230,31 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Sets the value of the per-cpu variable name to value val. */ -#define __PCPU_SET(name, val) { \ +#define __PCPU_SET(name, val) do { \ __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4 || sizeof(__val) == 8) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("mov %1,%%gs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("mov %1,%%gs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "memory"); \ } else { \ *__PCPU_PTR(name) = __val; \ } \ -} +} while (0) #define get_pcpu() __extension__ ({ \ struct pcpu *__pc; \ \ - __asm __volatile("movq %%gs:%1,%0" \ + __asm __volatile("movq %%gs:%c1,%0" \ : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + : "i" (__pcpu_offset(pc_prvspace))); \ __pc; \ }) #endif /* !__SEG_GS */ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h b/lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h index c42a421182c252e51a65f88179cc169dd481830f..b8d87dc04c4b3c866a3de192d2374af8b1a095cf 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/pcpu_aux.h @@ -54,8 +54,8 @@ __curthread(void) { struct thread *td; - __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu, - pc_curthread))); + __asm("movq %%gs:%c1,%0" : "=r" (td) + : "i" (offsetof(struct pcpu, pc_curthread))); return (td); } #define curthread (__curthread()) diff --git a/lib/libc/include/x86_64-freebsd-none/machine/pmap.h b/lib/libc/include/x86_64-freebsd-none/machine/pmap.h index bfcb1c0cd686dd9d35d65b7571be380b7806e355..fc01fc724979a96bd829fa1833d99e9d35ecdc03 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/pmap.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/pmap.h @@ -38,9 +38,6 @@ * map the page tables using the pagetables themselves. This is done to * reduce the impact on kernel virtual memory for lots of sparse address * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 */ #ifdef __i386__ @@ -50,48 +47,7 @@ #ifndef _MACHINE_PMAP_H_ #define _MACHINE_PMAP_H_ -/* - * Page-directory and page-table entries follow this format, with a few - * of the fields not present here and there, depending on a lot of things. - */ - /* ---- Intel Nomenclature ---- */ -#define X86_PG_V 0x001 /* P Valid */ -#define X86_PG_RW 0x002 /* R/W Read/Write */ -#define X86_PG_U 0x004 /* U/S User/Supervisor */ -#define X86_PG_NC_PWT 0x008 /* PWT Write through */ -#define X86_PG_NC_PCD 0x010 /* PCD Cache disable */ -#define X86_PG_A 0x020 /* A Accessed */ -#define X86_PG_M 0x040 /* D Dirty */ -#define X86_PG_PS 0x080 /* PS Page size (0=4k,1=2M) */ -#define X86_PG_PTE_PAT 0x080 /* PAT PAT index */ -#define X86_PG_G 0x100 /* G Global */ -#define X86_PG_AVAIL1 0x200 /* / Available for system */ -#define X86_PG_AVAIL2 0x400 /* < programmers use */ -#define X86_PG_AVAIL3 0x800 /* \ */ -#define X86_PG_PDE_PAT 0x1000 /* PAT PAT index */ -#define X86_PG_PKU(idx) ((pt_entry_t)idx << 59) -#define X86_PG_NX (1ul<<63) /* No-execute */ -#define X86_PG_AVAIL(x) (1ul << (x)) - -/* Page level cache control fields used to determine the PAT type */ -#define X86_PG_PDE_CACHE (X86_PG_PDE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) -#define X86_PG_PTE_CACHE (X86_PG_PTE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) - -/* Protection keys indexes */ -#define PMAP_MAX_PKRU_IDX 0xf -#define X86_PG_PKU_MASK X86_PG_PKU(PMAP_MAX_PKRU_IDX) - -/* - * Intel extended page table (EPT) bit definitions. - */ -#define EPT_PG_READ 0x001 /* R Read */ -#define EPT_PG_WRITE 0x002 /* W Write */ -#define EPT_PG_EXECUTE 0x004 /* X Execute */ -#define EPT_PG_IGNORE_PAT 0x040 /* IPAT Ignore PAT */ -#define EPT_PG_PS 0x080 /* PS Page size */ -#define EPT_PG_A 0x100 /* A Accessed */ -#define EPT_PG_M 0x200 /* D Dirty */ -#define EPT_PG_MEMORY_TYPE(x) ((x) << 3) /* MT Memory Type */ +#include /* * Define the PG_xx macros in terms of the bits on x86 PTEs. @@ -120,9 +76,6 @@ #define EPT_PG_EMUL_V X86_PG_AVAIL(52) #define EPT_PG_EMUL_RW X86_PG_AVAIL(53) #define PG_PROMOTED X86_PG_AVAIL(54) /* PDE only */ -#define PG_FRAME (0x000ffffffffff000ul) -#define PG_PS_FRAME (0x000fffffffe00000ul) -#define PG_PS_PDP_FRAME (0x000fffffc0000000ul) /* * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB @@ -132,18 +85,6 @@ PG_M | PG_U | PG_RW | PG_V | PG_PKU_MASK) /* - * Page Protection Exception bits - */ - -#define PGEX_P 0x01 /* Protection violation vs. not present */ -#define PGEX_W 0x02 /* during a Write cycle */ -#define PGEX_U 0x04 /* access from User mode (UPL) */ -#define PGEX_RSV 0x08 /* reserved PTE field is non-zero */ -#define PGEX_I 0x10 /* during an instruction fetch */ -#define PGEX_PK 0x20 /* protection key violation */ -#define PGEX_SGX 0x8000 /* SGX-related */ - -/* * undef the PG_xx macros that define bits in the regular x86 PTEs that * have a different position in nested PTEs. This is done when compiling * code that needs to be aware of the differences between regular x86 and @@ -169,12 +110,7 @@ * Pte related macros. This is complicated by having to deal with * the sign extension of the 48th bit. */ -#define KV4ADDR(l4, l3, l2, l1) ( \ - ((unsigned long)-1 << 47) | \ - ((unsigned long)(l4) << PML4SHIFT) | \ - ((unsigned long)(l3) << PDPSHIFT) | \ - ((unsigned long)(l2) << PDRSHIFT) | \ - ((unsigned long)(l1) << PAGE_SHIFT)) +#define KV4ADDR(l4, l3, l2, l1) KV5ADDR(-1, l4, l3, l2, l1) #define KV5ADDR(l5, l4, l3, l2, l1) ( \ ((unsigned long)-1 << 56) | \ ((unsigned long)(l5) << PML5SHIFT) | \ @@ -233,11 +169,12 @@ * the recursive page table map. */ #define NDMPML4E 8 +#define NDMPML5E 32 /* - * These values control the layout of virtual memory. The starting address - * of the direct map, which is controlled by DMPML4I, must be a multiple of - * its size. (See the PHYS_TO_DMAP() and DMAP_TO_PHYS() macros.) + * These values control the layout of virtual memory. The starting + * address of the direct map is controlled by DMPML4I on LA48 and + * DMPML5I on LA57. * * Note: KPML4I is the index of the (single) level 4 page that maps * the KVA that holds KERNBASE, while KPML4BASE is the index of the @@ -255,6 +192,7 @@ #define KPML4BASE (NPML4EPG-NKPML4E) /* KVM at highest addresses */ #define DMPML4I rounddown(KPML4BASE-NDMPML4E, NDMPML4E) /* Below KVM */ +#define DMPML5I (NPML5EPG / 2 + 1) #define KPML4I (NPML4EPG-1) #define KPDPI (NPDPEPG-2) /* kernbase at -2GB */ @@ -264,9 +202,14 @@ #define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E) #define KMSANORIGPML4I (DMPML4I - NKMSANORIGPML4E) -/* Large map: index of the first and max last pml4 entry */ +/* + * Large map: index of the first and max last pml4/la48 and pml5/la57 + * entry. + */ #define LMSPML4I (PML4PML4I + 1) #define LMEPML4I (KASANPML4I - 1) +#define LMSPML5I (DMPML5I + NDMPML5E) +#define LMEPML5I (LMSPML5I + 32 - 1) /* 32 slots for large map */ /* * XXX doesn't really belong here I guess... @@ -448,10 +391,10 @@ void pmap_activate_boot(pmap_t pmap); void pmap_activate_sw(struct thread *); void pmap_allow_2m_x_ept_recalculate(void); void pmap_bootstrap(vm_paddr_t *); -int pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde); +int pmap_cache_bits(pmap_t pmap, int mode, bool is_pde); int pmap_change_attr(vm_offset_t, vm_size_t, int); int pmap_change_prot(vm_offset_t, vm_size_t, vm_prot_t); -void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate); +void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, bool invalidate); void pmap_flush_cache_range(vm_offset_t, vm_offset_t); void pmap_flush_cache_phys_range(vm_paddr_t, vm_paddr_t, vm_memattr_t); void pmap_init_pat(void); @@ -467,7 +410,7 @@ void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int); void *pmap_mapdev_pciecfg(vm_paddr_t pa, vm_size_t size); bool pmap_not_in_di(void); -boolean_t pmap_page_is_mapped(vm_page_t m); +bool pmap_page_is_mapped(vm_page_t m); void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); void pmap_page_set_memattr_noflush(vm_page_t m, vm_memattr_t ma); void pmap_pinit_pml4(vm_page_t); @@ -612,6 +555,25 @@ pmap_pml5e_index(vm_offset_t va) return ((va >> PML5SHIFT) & ((1ul << NPML5EPGSHIFT) - 1)); } +struct kva_layout_s { + vm_offset_t kva_min; + vm_offset_t kva_max; + vm_offset_t dmap_low; /* DMAP_MIN_ADDRESS */ + vm_offset_t dmap_high; /* DMAP_MAX_ADDRESS */ + vm_offset_t lm_low; /* LARGEMAP_MIN_ADDRESS */ + vm_offset_t lm_high; /* LARGEMAP_MAX_ADDRESS */ + vm_offset_t km_low; /* VM_MIN_KERNEL_ADDRESS */ + vm_offset_t km_high; /* VM_MAX_KERNEL_ADDRESS */ + vm_offset_t rec_pt; + vm_offset_t kasan_shadow_low; /* KASAN_MIN_ADDRESS */ + vm_offset_t kasan_shadow_high; /* KASAN_MAX_ADDRESS */ + vm_offset_t kmsan_shadow_low; /* KMSAN_SHAD_MIN_ADDRESS */ + vm_offset_t kmsan_shadow_high; /* KMSAN_SHAD_MAX_ADDRESS */ + vm_offset_t kmsan_origin_low; /* KMSAN_ORIG_MIN_ADDRESS */ + vm_offset_t kmsan_origin_high; /* KMSAN_ORIG_MAX_ADDRESS */ +}; +extern struct kva_layout_s kva_layout; + #endif /* !LOCORE */ #endif /* !_MACHINE_PMAP_H_ */ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/proc.h b/lib/libc/include/x86_64-freebsd-none/machine/proc.h index 1bfc5a199676ff6b9f3322b417a1a972c40cb4f8..12b06f653c4f1d6d1e34cfe52f59e661b292aacc 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/proc.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/proc.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 */ #ifdef __i386__ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/profile.h b/lib/libc/include/x86_64-freebsd-none/machine/profile.h index 8b0c79da822ca664d5a335b150673fc284a538ad..1648bf947925a5b952097e0ca726b7a2f993144f 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/profile.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/profile.h @@ -27,8 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 */ #ifdef __i386__ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/psl.h b/lib/libc/include/x86_64-freebsd-none/machine/psl.h deleted file mode 100644 index 59536384fca5d786df3ad89e0d9cee9d9005d8ec..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/psl.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/pte.h b/lib/libc/include/x86_64-freebsd-none/machine/pte.h new file mode 100644 index 0000000000000000000000000000000000000000..2a123b73736649d944131ca87ef913e55ba5b707 --- /dev/null +++ b/lib/libc/include/x86_64-freebsd-none/machine/pte.h @@ -0,0 +1,104 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2003 Peter Wemm. + * Copyright (c) 1991 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the Systems Programming Group of the University of Utah Computer + * Science Department and William Jolitz of UUNET Technologies Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Derived from hp300 version by Mike Hibler, this version by William + * Jolitz uses a recursive map [a pde points to the page directory] to + * map the page tables using the pagetables themselves. This is done to + * reduce the impact on kernel virtual memory for lots of sparse address + * space, and to reduce the cost of memory to each process. + */ + +#ifndef _MACHINE_PTE_H_ +#define _MACHINE_PTE_H_ + +/* + * Page-directory and page-table entries follow this format, with a few + * of the fields not present here and there, depending on a lot of things. + */ + /* ---- Intel Nomenclature ---- */ +#define X86_PG_V 0x001 /* P Valid */ +#define X86_PG_RW 0x002 /* R/W Read/Write */ +#define X86_PG_U 0x004 /* U/S User/Supervisor */ +#define X86_PG_NC_PWT 0x008 /* PWT Write through */ +#define X86_PG_NC_PCD 0x010 /* PCD Cache disable */ +#define X86_PG_A 0x020 /* A Accessed */ +#define X86_PG_M 0x040 /* D Dirty */ +#define X86_PG_PS 0x080 /* PS Page size (0=4k,1=2M) */ +#define X86_PG_PTE_PAT 0x080 /* PAT PAT index */ +#define X86_PG_G 0x100 /* G Global */ +#define X86_PG_AVAIL1 0x200 /* / Available for system */ +#define X86_PG_AVAIL2 0x400 /* < programmers use */ +#define X86_PG_AVAIL3 0x800 /* \ */ +#define X86_PG_PDE_PAT 0x1000 /* PAT PAT index */ +#define X86_PG_PKU(idx) ((pt_entry_t)idx << 59) +#define X86_PG_NX (1ul<<63) /* No-execute */ +#define X86_PG_AVAIL(x) (1ul << (x)) + +/* Page level cache control fields used to determine the PAT type */ +#define X86_PG_PDE_CACHE (X86_PG_PDE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) +#define X86_PG_PTE_CACHE (X86_PG_PTE_PAT | X86_PG_NC_PWT | X86_PG_NC_PCD) + +/* Protection keys indexes */ +#define PMAP_MAX_PKRU_IDX 0xf +#define X86_PG_PKU_MASK X86_PG_PKU(PMAP_MAX_PKRU_IDX) + +/* + * Intel extended page table (EPT) bit definitions. + */ +#define EPT_PG_READ 0x001 /* R Read */ +#define EPT_PG_WRITE 0x002 /* W Write */ +#define EPT_PG_EXECUTE 0x004 /* X Execute */ +#define EPT_PG_IGNORE_PAT 0x040 /* IPAT Ignore PAT */ +#define EPT_PG_PS 0x080 /* PS Page size */ +#define EPT_PG_A 0x100 /* A Accessed */ +#define EPT_PG_M 0x200 /* D Dirty */ +#define EPT_PG_MEMORY_TYPE(x) ((x) << 3) /* MT Memory Type */ + +#define PG_FRAME (0x000ffffffffff000ul) +#define PG_PS_FRAME (0x000fffffffe00000ul) +#define PG_PS_PDP_FRAME (0x000fffffc0000000ul) + +/* + * Page Protection Exception bits + */ +#define PGEX_P 0x01 /* Protection violation vs. not present */ +#define PGEX_W 0x02 /* during a Write cycle */ +#define PGEX_U 0x04 /* access from User mode (UPL) */ +#define PGEX_RSV 0x08 /* reserved PTE field is non-zero */ +#define PGEX_I 0x10 /* during an instruction fetch */ +#define PGEX_PK 0x20 /* protection key violation */ +#define PGEX_SGX 0x8000 /* SGX-related */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/ptrace.h b/lib/libc/include/x86_64-freebsd-none/machine/ptrace.h deleted file mode 100644 index 0a426e24fabda625bb4750562767d4bb248dfe76..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/ptrace.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/reg.h b/lib/libc/include/x86_64-freebsd-none/machine/reg.h deleted file mode 100644 index 419b2756cc0d2ee86d493fb6ab9a01f6efad94d1..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/reg.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/reloc.h b/lib/libc/include/x86_64-freebsd-none/machine/reloc.h deleted file mode 100644 index 4b31acb73c7b9d461aed401496fbbbd7d7f5e2a4..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/reloc.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)reloc.h 8.1 (Berkeley) 6/10/93 - */ - -#ifndef _I386_MACHINE_RELOC_H_ -#define _I386_MACHINE_RELOC_H_ - -/* Relocation format. */ -struct relocation_info { - int r_address; /* offset in text or data segment */ - unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ - r_pcrel : 1, /* 1 if value should be pc-relative */ - r_length : 2, /* log base 2 of value's width */ - r_extern : 1, /* 1 if need to add symbol to value */ - r_baserel : 1, /* linkage table relative */ - r_jmptable : 1, /* relocate to jump table */ - r_relative : 1, /* load address relative */ - r_copy : 1; /* run time copy */ -}; - -#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/resource.h b/lib/libc/include/x86_64-freebsd-none/machine/resource.h index aaafc404fff32ee7ac30517226d5a09313a88ee8..55cf68e28253404f9e817c4549124a63e9440a3b 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/resource.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/resource.h @@ -12,7 +12,7 @@ * no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied * warranty. - * + * * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF @@ -39,8 +39,6 @@ #define SYS_RES_DRQ 2 /* isa dma lines */ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ -#ifdef NEW_PCIB #define PCI_RES_BUS 5 /* PCI bus numbers */ -#endif #endif /* !_MACHINE_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/runq.h b/lib/libc/include/x86_64-freebsd-none/machine/runq.h deleted file mode 100644 index ac2270b627b13a91adcaec5e4acf0c474cc8eedb..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/runq.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jake Burkholder - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (1) /* Number of priority status words. */ -#define RQB_L2BPW (6) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1<> RQB_L2BPW) - -#define RQB_FFS(word) (bsfq(word)) - -/* - * Type of run queue status word. - */ -typedef u_int64_t rqb_word_t; - -#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/sdt_machdep.h b/lib/libc/include/x86_64-freebsd-none/machine/sdt_machdep.h new file mode 100644 index 0000000000000000000000000000000000000000..3e07c58fb9770a35099c30360a2f8f8a0ccad893 --- /dev/null +++ b/lib/libc/include/x86_64-freebsd-none/machine/sdt_machdep.h @@ -0,0 +1,12 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Mark Johnston + */ + +#ifndef _SYS_SDT_MACHDEP_H_ +#define _SYS_SDT_MACHDEP_H_ + +#define _SDT_ASM_PATCH_INSTR "nopw 0(%%rax,%%rax,1)" + +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/segments.h b/lib/libc/include/x86_64-freebsd-none/machine/segments.h index d33cde3649db10da6ea0cd5607777ea46a959a34..ee443e5b122a15c1f0c1f85c70e56edecf78a94f 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/segments.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/segments.h @@ -31,8 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 */ #ifdef __i386__ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/setjmp.h b/lib/libc/include/x86_64-freebsd-none/machine/setjmp.h deleted file mode 100644 index 41ef6217a78d6c901bb819cbf79f593f5a4effff..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/setjmp.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/sf_buf.h b/lib/libc/include/x86_64-freebsd-none/machine/sf_buf.h index 619fa972636bb56a2b60202a401a348a02abeca5..6d34e9dcf4d4454bf65a29ed452c7908db5aa27a 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/sf_buf.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/sf_buf.h @@ -34,7 +34,7 @@ * On this machine, the only purpose for which sf_buf is used is to implement * an opaque pointer required by the machine-independent parts of the kernel. * That pointer references the vm_page that is "mapped" by the sf_buf. The - * actual mapping is provided by the direct virtual-to-physical mapping. + * actual mapping is provided by the direct virtual-to-physical mapping. */ static inline vm_offset_t sf_buf_kva(struct sf_buf *sf) diff --git a/lib/libc/include/x86_64-freebsd-none/machine/smp.h b/lib/libc/include/x86_64-freebsd-none/machine/smp.h index 5fd858a2a1d15f5e01a119ba66d7211f91931867..20f408b5d46bf8fc743cd40e0e728838654acd6c 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/smp.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/smp.h @@ -13,8 +13,6 @@ #ifdef _KERNEL -#ifdef SMP - #ifndef LOCORE #include @@ -39,7 +37,6 @@ void invlop_handler(void); int start_all_aps(void); #endif /* !LOCORE */ -#endif /* SMP */ #endif /* _KERNEL */ #endif /* _MACHINE_SMP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/sysarch.h b/lib/libc/include/x86_64-freebsd-none/machine/sysarch.h deleted file mode 100644 index 7a878970793205ac7033c38ab745ae9a93a4dfbb..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/sysarch.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/tls.h b/lib/libc/include/x86_64-freebsd-none/machine/tls.h deleted file mode 100644 index 9a386029151eaf9da9c7e5747f8992d4d1c2e721..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/tls.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/trap.h b/lib/libc/include/x86_64-freebsd-none/machine/trap.h deleted file mode 100644 index d8320b7b3503429b2fcffd38825a130c4bb26faf..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/trap.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/tss.h b/lib/libc/include/x86_64-freebsd-none/machine/tss.h index 420abc785125f9c7f28ff147cfe461064cf8800f..b92b5c902d6ebbe92ce8aeeabe4e080df9485adb 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/tss.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/tss.h @@ -30,8 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 */ #ifndef _MACHINE_TSS_H_ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vdso.h b/lib/libc/include/x86_64-freebsd-none/machine/vdso.h deleted file mode 100644 index 57db69e06a7c2c84ff7cbc3a9913d6470271923d..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/vdso.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vm.h b/lib/libc/include/x86_64-freebsd-none/machine/vm.h deleted file mode 100644 index fdd08a2e4de48f9f2449ec87870fab54d16cbae5..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/machine/vm.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2009 Hudson River Trading LLC - * Written by: John H. Baldwin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _MACHINE_VM_H_ -#define _MACHINE_VM_H_ - -#include - -/* Memory attributes. */ -#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) -#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) -#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) -#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) -#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) -#define VM_MEMATTR_WEAK_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHED) - -#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK -#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE - -#endif /* !_MACHINE_VM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vmm.h b/lib/libc/include/x86_64-freebsd-none/machine/vmm.h index d922750dcdcb8dc68cd5cd1bdd4317854a4cf4f9..53a16e7a26ac2dbd9a49d28919c2c3bcf260bed9 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/vmm.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/vmm.h @@ -46,6 +46,7 @@ enum vm_suspend_how { VM_SUSPEND_POWEROFF, VM_SUSPEND_HALT, VM_SUSPEND_TRIPLEFAULT, + VM_SUSPEND_DESTROY, VM_SUSPEND_LAST }; @@ -124,7 +125,7 @@ enum x2apic_state { /* * The VM name has to fit into the pathname length constraints of devfs, * governed primarily by SPECNAMELEN. The length is the total number of - * characters in the full path, relative to the mount point and not + * characters in the full path, relative to the mount point and not * including any leading '/' characters. * A prefix and a suffix are added to the name specified by the user. * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters @@ -150,6 +151,7 @@ CTASSERT(VM_MAX_NAMELEN >= VM_MIN_NAMELEN); struct vm; struct vm_exception; +struct vm_mem; struct seg_desc; struct vm_exit; struct vm_run; @@ -170,6 +172,7 @@ struct vm_eventinfo { typedef int (*vmm_init_func_t)(int ipinum); typedef int (*vmm_cleanup_func_t)(void); +typedef void (*vmm_suspend_func_t)(void); typedef void (*vmm_resume_func_t)(void); typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap); typedef int (*vmi_run_func_t)(void *vcpui, register_t rip, @@ -194,6 +197,7 @@ typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now); struct vmm_ops { vmm_init_func_t modinit; /* module wide initialization */ vmm_cleanup_func_t modcleanup; + vmm_resume_func_t modsuspend; vmm_resume_func_t modresume; vmi_init_func_t init; /* vm-specific initialization */ @@ -236,39 +240,11 @@ void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, uint16_t threads, uint16_t maxcpus); -/* - * APIs that modify the guest memory map require all vcpus to be frozen. - */ -void vm_slock_memsegs(struct vm *vm); -void vm_xlock_memsegs(struct vm *vm); -void vm_unlock_memsegs(struct vm *vm); -int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off, - size_t len, int prot, int flags); -int vm_munmap_memseg(struct vm *vm, vm_paddr_t gpa, size_t len); -int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem); -void vm_free_memseg(struct vm *vm, int ident); int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa); int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len); int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func); int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func); -/* - * APIs that inspect the guest memory map require only a *single* vcpu to - * be frozen. This acts like a read lock on the guest memory map since any - * modification requires *all* vcpus to be frozen. - */ -int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid, - vm_ooffset_t *segoff, size_t *len, int *prot, int *flags); -int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem, - struct vm_object **objptr); -vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm); -void *vm_gpa_hold(struct vcpu *vcpu, vm_paddr_t gpa, size_t len, - int prot, void **cookie); -void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len, - int prot, void **cookie); -void vm_gpa_release(void *cookie); -bool vm_mem_allocated(struct vcpu *vcpu, vm_paddr_t gpa); - int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); int vm_get_seg_desc(struct vcpu *vcpu, int reg, @@ -399,7 +375,8 @@ vcpu_should_yield(struct vcpu *vcpu) void *vcpu_stats(struct vcpu *vcpu); void vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr); -struct vmspace *vm_get_vmspace(struct vm *vm); +struct vmspace *vm_vmspace(struct vm *vm); +struct vm_mem *vm_mem(struct vm *vm); struct vatpic *vm_atpic(struct vm *vm); struct vatpit *vm_atpit(struct vm *vm); struct vpmtmr *vm_pmtmr(struct vm *vm); @@ -448,7 +425,7 @@ int vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2); /* * Function used to keep track of the guest's TSC offset. The - * offset is used by the virutalization extensions to provide a consistent + * offset is used by the virtualization extensions to provide a consistent * value for the Time Stamp Counter to the guest. */ void vm_set_tsc_offset(struct vcpu *vcpu, uint64_t offset); @@ -465,7 +442,7 @@ struct vm_copyinfo { /* * Set up 'copyinfo[]' to copy to/from guest linear address space starting * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for - * a copyin or PROT_WRITE for a copyout. + * a copyin or PROT_WRITE for a copyout. * * retval is_fault Interpretation * 0 0 Success @@ -673,6 +650,8 @@ struct vm_inout_str { int addrsize; enum vm_reg_name seg_name; struct seg_desc seg_desc; + int cs_d; + uint64_t cs_base; }; enum task_switch_reason { diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h b/lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h index 997a34a5518e0533ee4d00ecfe8119b2f88b4f11..23f06ff5c3420a1d52edba4718a307e601c3c257 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/vmm_dev.h @@ -29,12 +29,10 @@ #ifndef _VMM_DEV_H_ #define _VMM_DEV_H_ -struct vm_snapshot_meta; +#include -#ifdef _KERNEL -void vmmdev_init(void); -int vmmdev_cleanup(void); -#endif +#include +#include struct vm_memmap { vm_paddr_t gpa; @@ -56,16 +54,12 @@ struct vm_munmap { struct vm_memseg { int segid; size_t len; - char name[VM_MAX_SUFFIXLEN + 1]; + char name[VM_MAX_SUFFIXLEN + 1]; + domainset_t *ds_mask; + size_t ds_mask_size; + int ds_policy; }; -struct vm_memseg_fbsd12 { - int segid; - size_t len; - char name[64]; -}; -_Static_assert(sizeof(struct vm_memseg_fbsd12) == 80, "COMPAT_FREEBSD12 ABI"); - struct vm_register { int cpuid; int regnum; /* enum vm_reg_name */ @@ -312,7 +306,7 @@ enum { IOCNUM_UNMAP_PPTDEV_MMIO = 46, /* statistics */ - IOCNUM_VM_STATS = 50, + IOCNUM_VM_STATS = 50, IOCNUM_VM_STAT_DESC = 51, /* kernel device state */ @@ -354,12 +348,8 @@ enum { _IOW('v', IOCNUM_SUSPEND, struct vm_suspend) #define VM_REINIT \ _IO('v', IOCNUM_REINIT) -#define VM_ALLOC_MEMSEG_FBSD12 \ - _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg_fbsd12) #define VM_ALLOC_MEMSEG \ _IOW('v', IOCNUM_ALLOC_MEMSEG, struct vm_memseg) -#define VM_GET_MEMSEG_FBSD12 \ - _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg_fbsd12) #define VM_GET_MEMSEG \ _IOWR('v', IOCNUM_GET_MEMSEG, struct vm_memseg) #define VM_MMAP_MEMSEG \ diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h b/lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h index 52ca34b48f9c57b4954f9e87b80982249f354f23..164ed16e9d280178d199d2ddc16c01a1d6174bcb 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/vmm_instruction_emul.h @@ -31,6 +31,31 @@ #include +/* struct vie_op.op_type */ +enum { + VIE_OP_TYPE_NONE = 0, + VIE_OP_TYPE_MOV, + VIE_OP_TYPE_MOVSX, + VIE_OP_TYPE_MOVZX, + VIE_OP_TYPE_AND, + VIE_OP_TYPE_OR, + VIE_OP_TYPE_SUB, + VIE_OP_TYPE_TWO_BYTE, + VIE_OP_TYPE_PUSH, + VIE_OP_TYPE_CMP, + VIE_OP_TYPE_POP, + VIE_OP_TYPE_MOVS, + VIE_OP_TYPE_GROUP1, + VIE_OP_TYPE_STOS, + VIE_OP_TYPE_BITTEST, + VIE_OP_TYPE_TWOB_GRP15, + VIE_OP_TYPE_ADD, + VIE_OP_TYPE_TEST, + VIE_OP_TYPE_BEXTR, + VIE_OP_TYPE_OUTS, + VIE_OP_TYPE_LAST +}; + /* * Callback functions to read and write memory regions. */ @@ -112,7 +137,7 @@ void vie_init(struct vie *vie, const char *inst_bytes, int inst_length); * 'gla' is the guest linear address provided by the hardware assist * that caused the nested page table fault. It is used to verify that * the software instruction decoding is in agreement with the hardware. - * + * * Some hardware assists do not provide the 'gla' to the hypervisor. * To skip the 'gla' verification for this or any other reason pass * in VIE_INVALID_GLA instead. diff --git a/lib/libc/include/x86_64-freebsd-none/machine/vmparam.h b/lib/libc/include/x86_64-freebsd-none/machine/vmparam.h index b4ee0e03e56a67c22f6c8e321a7b9addfd8ca826..862c29760b159c7750fce1d98d099401a02a41d0 100644 --- a/lib/libc/include/x86_64-freebsd-none/machine/vmparam.h +++ b/lib/libc/include/x86_64-freebsd-none/machine/vmparam.h @@ -38,8 +38,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 */ #ifdef __i386__ @@ -74,12 +72,12 @@ #endif /* - * We provide a machine specific single page allocator through the use - * of the direct mapped segment. This uses 2MB pages for reduced + * We provide a single page allocator through the use of the + * direct mapped segment. This uses 2MB pages for reduced * TLB pressure. */ #if !defined(KASAN) && !defined(KMSAN) -#define UMA_MD_SMALL_ALLOC +#define UMA_USE_DMAP #endif /* @@ -91,19 +89,21 @@ * The number of PHYSSEG entries must be one greater than the number * of phys_avail entries because the phys_avail entry that spans the * largest physical address that is accessible by ISA DMA is split - * into two PHYSSEG entries. + * into two PHYSSEG entries. */ #define VM_PHYSSEG_MAX 63 /* - * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool - * from which physical pages are allocated and VM_FREEPOOL_DIRECT is - * the pool from which physical pages for page tables and small UMA - * objects are allocated. + * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool from + * which physical pages are allocated and VM_FREEPOOL_DIRECT is the pool from + * which physical pages for page tables and small UMA objects are allocated. + * VM_FREEPOOL_LAZYINIT is a special-purpose pool that is populated only during + * boot and is used to implement deferred initialization of page structures. */ -#define VM_NFREEPOOL 2 -#define VM_FREEPOOL_DEFAULT 0 -#define VM_FREEPOOL_DIRECT 1 +#define VM_NFREEPOOL 3 +#define VM_FREEPOOL_LAZYINIT 0 +#define VM_FREEPOOL_DEFAULT 1 +#define VM_FREEPOOL_DIRECT 2 /* * Create up to three free page lists: VM_FREELIST_DMA32 is for physical pages @@ -149,10 +149,6 @@ #define VM_LEVEL_0_ORDER 9 #endif -#ifdef SMP -#define PA_LOCK_COUNT 256 -#endif - /* * Kernel physical load address for non-UEFI boot and for legacy UEFI loader. * Newer UEFI loader loads kernel anywhere below 4G, with memory allocated @@ -167,6 +163,7 @@ * Virtual addresses of things. Derived from the page directory and * page table indexes from pmap.h for precision. * + * LA48: * 0x0000000000000000 - 0x00007fffffffffff user map * 0x0000800000000000 - 0xffff7fffffffffff does not exist (hole) * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) @@ -179,32 +176,38 @@ * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map * + * LA57: + * 0x0000000000000000 - 0x00ffffffffffffff user map + * 0x0100000000000000 - 0xf0ffffffffffffff does not exist (hole) + * 0xff00000000000000 - 0xff00ffffffffffff recursive page table (2048TB slot) + * 0xff01000000000000 - 0xff20ffffffffffff direct map (32 x 2048TB slots) + * 0xff21000000000000 - 0xff40ffffffffffff large map + * 0xff41000000000000 - 0xffff7fffffffffff unused + * 0xffff800000000000 - 0xfffff5ffffffffff unused (start of kernel pml4 entry) + * 0xfffff60000000000 - 0xfffff7ffffffffff 2TB KMSAN origin map, optional + * 0xfffff78000000000 - 0xfffff7bfffffffff 512GB KASAN shadow map, optional + * 0xfffff80000000000 - 0xfffffbffffffffff 4TB unused + * 0xfffffc0000000000 - 0xfffffdffffffffff 2TB KMSAN shadow map, optional + * 0xfffffe0000000000 - 0xffffffffffffffff 2TB kernel map + * * Within the kernel map: * * 0xfffffe0000000000 vm_page_array * 0xffffffff80000000 KERNBASE */ -#define VM_MIN_KERNEL_ADDRESS KV4ADDR(KPML4BASE, 0, 0, 0) -#define VM_MAX_KERNEL_ADDRESS KV4ADDR(KPML4BASE + NKPML4E - 1, \ - NPDPEPG-1, NPDEPG-1, NPTEPG-1) +#define VM_MIN_KERNEL_ADDRESS_LA48 KV4ADDR(KPML4BASE, 0, 0, 0) +#define VM_MIN_KERNEL_ADDRESS kva_layout.km_low +#define VM_MAX_KERNEL_ADDRESS kva_layout.km_high -#define DMAP_MIN_ADDRESS KV4ADDR(DMPML4I, 0, 0, 0) -#define DMAP_MAX_ADDRESS KV4ADDR(DMPML4I + NDMPML4E, 0, 0, 0) +#define KASAN_MIN_ADDRESS (kva_layout.kasan_shadow_low) +#define KASAN_MAX_ADDRESS (kva_layout.kasan_shadow_high) -#define KASAN_MIN_ADDRESS KV4ADDR(KASANPML4I, 0, 0, 0) -#define KASAN_MAX_ADDRESS KV4ADDR(KASANPML4I + NKASANPML4E, 0, 0, 0) +#define KMSAN_SHAD_MIN_ADDRESS (kva_layout.kmsan_shadow_low) +#define KMSAN_SHAD_MAX_ADDRESS (kva_layout.kmsan_shadow_high) -#define KMSAN_SHAD_MIN_ADDRESS KV4ADDR(KMSANSHADPML4I, 0, 0, 0) -#define KMSAN_SHAD_MAX_ADDRESS KV4ADDR(KMSANSHADPML4I + NKMSANSHADPML4E, \ - 0, 0, 0) - -#define KMSAN_ORIG_MIN_ADDRESS KV4ADDR(KMSANORIGPML4I, 0, 0, 0) -#define KMSAN_ORIG_MAX_ADDRESS KV4ADDR(KMSANORIGPML4I + NKMSANORIGPML4E, \ - 0, 0, 0) - -#define LARGEMAP_MIN_ADDRESS KV4ADDR(LMSPML4I, 0, 0, 0) -#define LARGEMAP_MAX_ADDRESS KV4ADDR(LMEPML4I + 1, 0, 0, 0) +#define KMSAN_ORIG_MIN_ADDRESS (kva_layout.kmsan_origin_low) +#define KMSAN_ORIG_MAX_ADDRESS (kva_layout.kmsan_origin_high) /* * Formally kernel mapping starts at KERNBASE, but kernel linker @@ -243,21 +246,21 @@ * vt fb startup needs to be reworked. */ #define PHYS_IN_DMAP(pa) (dmaplimit == 0 || (pa) < dmaplimit) -#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \ - (va) < (DMAP_MIN_ADDRESS + dmaplimit)) +#define VIRT_IN_DMAP(va) \ + ((va) >= kva_layout.dmap_low && (va) < kva_layout.dmap_low + dmaplimit) #define PMAP_HAS_DMAP 1 -#define PHYS_TO_DMAP(x) ({ \ +#define PHYS_TO_DMAP(x) __extension__ ({ \ KASSERT(PHYS_IN_DMAP(x), \ ("physical address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ - (x) | DMAP_MIN_ADDRESS; }) + (x) + kva_layout.dmap_low; }) -#define DMAP_TO_PHYS(x) ({ \ +#define DMAP_TO_PHYS(x) __extension__ ({ \ KASSERT(VIRT_IN_DMAP(x), \ ("virtual address %#jx not covered by the DMAP", \ (uintmax_t)x)); \ - (x) & ~DMAP_MIN_ADDRESS; }) + (x) - kva_layout.dmap_low; }) /* * amd64 maps the page array into KVA so that it can be more easily @@ -278,7 +281,7 @@ */ #ifndef VM_KMEM_SIZE_MAX #define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \ - VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5) + kva_layout.km_low + 1) * 3 / 5) #endif /* initial pagein size of beginning of executable file */ @@ -296,7 +299,8 @@ /* * Need a page dump array for minidump. */ -#define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_PAGE_TRACKING 1 +#define MINIDUMP_STARTUP_PAGE_TRACKING 1 #endif /* _MACHINE_VMPARAM_H_ */ diff --git a/lib/libc/include/x86_64-freebsd-none/stdarg.h b/lib/libc/include/x86_64-freebsd-none/stdarg.h deleted file mode 100644 index 20289894d6befa8cbbdb343cbb9c4c4e679c019f..0000000000000000000000000000000000000000 --- a/lib/libc/include/x86_64-freebsd-none/stdarg.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include \ No newline at end of file